NVIDIA DeepStream SDK API Reference

9.1 Release
sources/gst-plugins/gst-nvtracker/convbufmanager.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2019-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 _CONVBUFMANAGER_H
19 #define _CONVBUFMANAGER_H
20 
21 #include <vector>
22 #include <queue>
23 #include <mutex>
24 #include <condition_variable>
25 #include <cuda.h>
26 #include <cuda_runtime.h>
27 
28 #include "nvbufsurface.h"
29 #include "nvbufsurftransform.h"
30 
31 #define MAX_BUFFER_POOL_SIZE 2 // Set surface buffer pool size as a fixed number.
32 
34 {
35 public:
38 
39  bool init(uint32_t batchSize, int32_t gpuId, int32_t compute_hw,
40  NvBufSurfaceCreateParams& bufferParam, const bool empty);
41  void deInit();
42 
46  void returnBuffer(NvBufSurface *pBufferSet);
48  void syncBuffer(NvBufSurface *pBufferSet, NvBufSurfTransformSyncObj_t *bufSetSyncObjs);
50  bool isQueueFull() {
51  return (m_FreeQueue.size() == MAX_BUFFER_POOL_SIZE);
52  }
53  bool isQueueEmpty() {
54  return (m_FreeQueue.empty());
55  }
58  return MAX_BUFFER_POOL_SIZE;
59  }
60 
61 private:
63  std::vector<NvBufSurface *> m_BufferSet;
64 
66  bool m_Running;
68  bool m_Initialized;
70  bool m_IntentionallyEmpty;
72  NvBufSurfTransformParams m_TransformParams;
74  NvBufSurfTransformConfigParams m_TransformConfigParams;
76  std::queue<NvBufSurface *> m_FreeQueue;
77 };
78 
79 #endif
ConvBufManager
Definition: sources/gst-plugins/gst-nvtracker/convbufmanager.h:33
NvBufSurfTransformSyncObj_t
struct NvBufSurfTransformSyncObj * NvBufSurfTransformSyncObj_t
Holds the information about synchronization objects for asynchronous transform/composite APIs.
Definition: sources/includes/nvbufsurftransform.h:301
_NvBufSurfaceTransformParams
Holds transform parameters for a transform call.
Definition: sources/includes/nvbufsurftransform.h:196
ConvBufManager::convertBatchAsync
NvBufSurface * convertBatchAsync(NvBufSurface *pBatchIn, NvBufSurfTransformSyncObj_t *bufSetSyncObjs)
Perform surface transform for a batch asynchronously.
NvBufSurface
Holds information about batched buffers.
Definition: sources/includes/nvbufsurface.h:597
ConvBufManager::deInit
void deInit()
ConvBufManager::isQueueEmpty
bool isQueueEmpty()
Definition: sources/gst-plugins/gst-nvtracker/convbufmanager.h:53
MAX_BUFFER_POOL_SIZE
#define MAX_BUFFER_POOL_SIZE
Definition: sources/gst-plugins/gst-nvtracker/convbufmanager.h:31
_NvBufSurfTransformConfigParams
Holds configuration parameters for a transform/composite session.
Definition: sources/includes/nvbufsurftransform.h:175
ConvBufManager::isQueueFull
bool isQueueFull()
Getter.
Definition: sources/gst-plugins/gst-nvtracker/convbufmanager.h:50
ConvBufManager::syncBuffer
void syncBuffer(NvBufSurface *pBufferSet, NvBufSurfTransformSyncObj_t *bufSetSyncObjs)
Wait until surface transform is finished.
ConvBufManager::getMaxPoolSize
int getMaxPoolSize()
Definition: sources/gst-plugins/gst-nvtracker/convbufmanager.h:56
ConvBufManager::init
bool init(uint32_t batchSize, int32_t gpuId, int32_t compute_hw, NvBufSurfaceCreateParams &bufferParam, const bool empty)
ConvBufManager::returnBuffer
void returnBuffer(NvBufSurface *pBufferSet)
Return unused buffer.
ConvBufManager::~ConvBufManager
~ConvBufManager()
ConvBufManager::ConvBufManager
ConvBufManager()
NvBufSurfaceCreateParams
Holds parameters required to allocate an NvBufSurface.
Definition: sources/includes/nvbufsurface.h:447