Blame view

src/nvdecoder/FFCuContextManager.cpp 741 Bytes
f40cc409   Hu Chunming   优化显存占用。当前在3080显卡上...
1
  #include "FFCuContextManager.h"
92989af0   ming   更新解码器
2
  
63e6f7bc   Hu Chunming   完成dvpp。但是nv和gb281...
3
  #include "common_header.h"
f40cc409   Hu Chunming   优化显存占用。当前在3080显卡上...
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  
  using namespace std;
  
  FFCuContextManager::~FFCuContextManager()
  {
      for(auto iter = ctxMap.begin(); iter != ctxMap.end(); iter++){
          av_buffer_unref(&iter->second);
      }
      ctxMap.clear();
  }
  
  AVBufferRef *FFCuContextManager::getCuCtx(string gpuid)
  {
       AVBufferRef *hw_device_ctx = ctxMap[gpuid];
       if (nullptr == hw_device_ctx)
       {
          // 初始化硬件解码器
          if (av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_CUDA, gpuid.c_str(), nullptr, 0) < 0) 
          {
92989af0   ming   更新解码器
23
              LOG_ERROR("Failed to create specified HW device.");
f40cc409   Hu Chunming   优化显存占用。当前在3080显卡上...
24
25
26
27
28
29
              return nullptr;
          }
          ctxMap[gpuid] = hw_device_ctx;
       }
       return hw_device_ctx;
  }