Blame view

src/decoder/dvpp/DvppDecoder.h 3.08 KB
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
1
2
3
4
5
6
7
8
9
10
11
  #include<string>
  
  #include "depend_headers.h"
  #include "dvpp_headers.h"
  #include "DvppDataMemory.hpp"
  
  #include <queue>
  #include <mutex>
  #include <thread>
  #include <chrono>
  #include <atomic>
4061a3c3   Hu Chunming   更换decoder
12
  #include <memory>
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
13
  
4061a3c3   Hu Chunming   更换decoder
14
  #include "FFRecoderTask.h"
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
15
16
17
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
47
48
49
50
51
52
  
  using namespace std;
  
  typedef void(*RECEIVER_FINISHED_CALLBACK)(const void* userPtr);
  
  
  struct Vdec_CallBack_UserData;
  
  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 getOutResolution( int &width, int &height );
  
      bool isSurport(FFDecConfig& cfg);
  
      float fps();
  
      void setName(string nm){
          m_dec_name = nm;
      }
  
      string getName(){
          return m_dec_name;
      }
  
4061a3c3   Hu Chunming   更换decoder
53
      DvppDataMemory* snapshot();
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
54
55
56
57
58
59
60
61
62
63
64
65
66
  
      void setPostDecArg(const void* postDecArg);
      void setFinishedDecArg(const void* finishedDecArg);
  
      int getCachedQueueLength();
  
      void doRecode(RecoderInfo& recoderInfo);
  
      void set_mq_callback(mq_callback_t cb);
  
  public:
      void doVdppVdecCallBack(acldvppStreamDesc *input, acldvppPicDesc *output, void *pUserData);
      void doProcessReport();
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
67
68
69
  
  private:
      AVCodecContext* init_FFmpeg(FFDecConfig config);
4061a3c3   Hu Chunming   更换decoder
70
      bool init_vdpp(FFDecConfig cfg, AVCodecContext* avctx);
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
71
72
73
74
75
76
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
117
118
119
120
121
122
123
124
125
126
127
      void release_ffmpeg();
      void read_thread();
      
      int sendPkt(aclvdecChannelDesc *vdecChannelDesc, AVPacket* pkt, unsigned long long frame_nb);
      bool sendVdecEos(aclvdecChannelDesc *vdecChannelDesc);
      void release_dvpp();
  
      void display_thread();
  
      int getVdecType(int videoType, int profile);
  
      void calcOutResolution(int w, int h);
  
  private:
      FFDecConfig m_cfg;
      string m_dec_name;
  
      const void * m_finishedDecArg {nullptr};
      DECODE_FINISHED_CALLBACK decode_finished_cbk {nullptr};
  
      bool m_bFinished{false};
      bool m_bRunning{false};
      bool m_bPause{false};
  
      bool m_bExitReportThd{false};
      bool m_bExitDisplayThd{false};
  
      // 读取数据
      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};
      int out_frame_width{0};
  	int out_frame_height{0};
      bool m_bReal {false}; // 是否实时流
      float m_fps{0.0};
  
      std::thread* m_read_thread{nullptr};
  
      bool m_dec_keyframe {false};
      bool m_bResize {false};
  
      // 解码
      int m_dvpp_deviceId {-1};
      int m_dvpp_channel {-1};
      aclrtContext m_context{nullptr};
      acldvppStreamFormat m_enType;
  
      const void * m_postDecArg {nullptr};
      POST_DECODE_CALLBACK post_decoded_cbk {nullptr};
  
      int m_vdec_out_size {-1};
  
4061a3c3   Hu Chunming   更换decoder
128
129
130
  #ifdef USE_VILLAGE
      FFRecoderTask m_recoderTask;
  #endif
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
131
132
133
134
135
136
  
      queue<DvppDataMemory*> m_decoded_data_queue;
      mutex m_decoded_data_queue_mtx;
  
      long long last_ts {0};
  
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
137
138
139
      uint64_t m_in_count {0};
      uint64_t m_out_count {0};
  
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
140
      std::atomic<int> m_DvppCacheCounter{0};
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
141
  
4061a3c3   Hu Chunming   更换decoder
142
      bool m_bSnapshot{false};
6fdcb6a5   Hu Chunming   初次提交,代码大体完成编写,完善中
143
  };