Blame view

src/decoder/dvpp/DvppDecoder.h 2.68 KB
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
1
2
3
  #include<string>
  
  #include "depend_headers.h"
fce4580d   Hu Chunming   更新最新代码:修改解码器实现方式并...
4
5
6
7
8
9
10
  #include "dvpp_headers.h"
  #include "DvppDataMemory.hpp"
  
  #include <queue>
  #include <mutex>
  #include <condition_variable>
  
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
11
12
13
  
  using namespace std;
  
fce4580d   Hu Chunming   更新最新代码:修改解码器实现方式并...
14
15
16
17
  typedef void(*RECEIVER_FINISHED_CALLBACK)(const void* userPtr);
  
  const int g_pkt_size = 1024 * 1024;  // 单个AVPacket大小的最大值
  
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  class DvppDecoder{
  public:
      DvppDecoder();
      ~DvppDecoder();
      bool init(FFDecConfig cfg);
      void close();
      bool start();
      void pause();
      void resume();
  
      void setDecKeyframe(bool bKeyframe);
  
      bool isRunning();
      bool isFinished();
      bool isPausing();
      bool getResolution( int &width, int &height );
  
      bool isSurport(FFDecConfig& cfg);
  
      float fps();
  
      void setName(string nm){
          m_dec_name = nm;
      }
  
      string getName(){
          return m_dec_name;
      }
  
9b4d4adf   Hu Chunming   添加定时抓拍;
47
      DeviceMemory* snapshot();
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
48
49
50
51
52
53
54
  
      void setPostDecArg(const void* postDecArg);
      void setFinishedDecArg(const void* finishedDecArg);
  
      int getCachedQueueLength();
  
  public:
fce4580d   Hu Chunming   更新最新代码:修改解码器实现方式并...
55
56
57
58
59
60
61
62
63
64
65
66
67
      void doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *output);
      void doProcessReport();
  
  private:
      AVCodecContext* init_FFmpeg(FFDecConfig config);
      bool init_vdpp(FFDecConfig cfg, AVCodecContext* avctx);
      void release_ffmpeg();
      void read_thread();
      
      void decode_thread();
      int sentFrame(aclvdecChannelDesc *vdecChannelDesc, uint64_t frame_count);
      bool sendVdecEos(aclvdecChannelDesc *vdecChannelDesc);
      void release_dvpp();
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
68
69
70
71
72
  
  private:
      FFDecConfig m_cfg;
      string m_dec_name;
  
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
73
74
75
76
      const void * m_finishedDecArg;
      DECODE_FINISHED_CALLBACK decode_finished_cbk;
  
      bool m_bFinished{false};
fce4580d   Hu Chunming   更新最新代码:修改解码器实现方式并...
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
      bool m_bRunning{false};
      bool m_bPause{false};
      bool m_bExitReportThd{false};
  
      // 读取数据
      AVStream* stream{nullptr};
      int video_index{-1};
      AVFormatContext *fmt_ctx{nullptr};
      AVPixelFormat pix_fmt;
      AVCodecContext *avctx{nullptr};
      AVBSFContext * h264bsfc{nullptr};
  
      int frame_width{0};
  	int frame_height{0};
      bool m_bReal; // 是否实时流
      float m_fps{0.0};
  
      RECEIVER_FINISHED_CALLBACK receiver_finished_cbk;
  
      pthread_t m_read_thread{0};
  
      bool m_dec_keyframe;
  
      mutex m_pktQueue_mutex;
      queue<AVPacket*> m_pktQueue;
  
      // 解码
      int m_dvpp_deviceId {-1};
      int m_dvpp_channel {-1};
      aclrtContext m_context{nullptr};
      acldvppStreamFormat enType;
  
      pthread_t m_decode_thread{0};
      mutex m_vdecQueue_mutex;
      queue<void*> m_vdecQueue;
  
      const void * m_postDecArg;
      POST_DECODE_CALLBACK post_decoded_cbk;
  
      int m_vdec_out_size {-1};
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
117
  
fce4580d   Hu Chunming   更新最新代码:修改解码器实现方式并...
118
119
120
121
122
      // 截图
      bool m_bSnapShoting{false};
      DvppDataMemory* m_cached_mem{nullptr};
      mutex m_cached_mutex;
      condition_variable m_cached_cond;
0b4cd5d5   Hu Chunming   完成轨迹定时抓拍
123
  };