NVIDIA DeepStream SDK API Reference

9.1 Release
9.1/sources/includes/ds3d/common/helper/memdata.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef DS3D_COMMON_HELPER_MEMDATA_H
19 #define DS3D_COMMON_HELPER_MEMDATA_H
20 
21 #include "ds3d/common/helper/safe_queue.h"
22 
23 namespace ds3d {
24 
25 struct MemData {
26  void* data = nullptr;
27  size_t byteSize = 0;
28  int devId = 0;
30  MemData() = default;
31  virtual ~MemData() = default;
32 
33 protected:
35 };
36 
37 class CpuMemBuf : public MemData {
38 public:
39  CpuMemBuf() {}
40  static std::unique_ptr<CpuMemBuf> CreateBuf(size_t size)
41  {
42  auto mem = std::make_unique<CpuMemBuf>();
43  void* data = malloc(size);
44  if (!data) {
45  LOG_ERROR("DS3D, malloc out of memory");
46  return nullptr;
47  }
48  mem->data = data;
49  mem->byteSize = size;
50  mem->devId = 0;
51  mem->type = MemType::kCpu;
52  return mem;
53  }
55  {
56  if (data) {
57  free(data);
58  }
59  }
60 };
61 
62 };
63 #endif
ds3d::MemType::kCpu
@ kCpu
ds3d::MemData::type
MemType type
Definition: sources/includes/ds3d/common/helper/memdata.h:29
ds3d::CpuMemBuf::CpuMemBuf
CpuMemBuf()
Definition: 9.1/sources/includes/ds3d/common/helper/memdata.h:39
ds3d::MemData::data
void * data
Definition: sources/includes/ds3d/common/helper/memdata.h:26
ds3d::MemData::byteSize
size_t byteSize
Definition: sources/includes/ds3d/common/helper/memdata.h:27
ds3d::MemData::DS3D_DISABLE_CLASS_COPY
DS3D_DISABLE_CLASS_COPY(MemData)
LOG_ERROR
#define LOG_ERROR(fmt,...)
Definition: sources/apps/sample_apps/deepstream-3d-action-recognition/deepstream_action.h:60
ds3d::CpuMemBuf::~CpuMemBuf
~CpuMemBuf()
Definition: 9.1/sources/includes/ds3d/common/helper/memdata.h:54
ds3d::MemData::devId
int devId
Definition: sources/includes/ds3d/common/helper/memdata.h:28
ds3d::MemData::~MemData
virtual ~MemData()=default
ds3d::CpuMemBuf::CreateBuf
static std::unique_ptr< CpuMemBuf > CreateBuf(size_t size)
Definition: 9.1/sources/includes/ds3d/common/helper/memdata.h:40
ds3d
Definition: sources/includes/ds3d/common/abi_dataprocess.h:25
ds3d::MemType
MemType
Definition: sources/includes/ds3d/common/idatatype.h:106
ds3d::MemData::MemData
MemData()=default