video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-09-24 9792631e9d038ac34e287323961b78cc3d470873
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
53
54
55
56
57
#ifndef _cffmpeg_decoder_hpp_
#define _cffmpeg_decoder_hpp_
 
#include <stdint.h>
#include <memory>
#include <list>
#include <mutex>
#include <thread>
#include <atomic>
#include <condition_variable>
 
struct AVFrame;
 
namespace ffwrapper
{
    class FormatIn;
    class cvbridge;
    class CodedData;
} // namespace ffwrapper
 
namespace cffmpeg_wrap
{
    typedef struct _pic_bgr24{
        unsigned char *data;
        int w;
        int h;
 
        int64_t id;
    }BGR24;
 
    class decoder
    {
    private:
        ffwrapper::cvbridge *conv_;
        int conv_w_, conv_h_, conv_flag_;
 
        ffwrapper::FormatIn *decRef_;
 
        std::list<BGR24> list_pic_;
        std::mutex mutex_pic_;
 
    private:
        int initDecoder();
        int saveFrame(AVFrame *frame, int64_t &id);
    public: 
        void Start();
        int SetFrame(std::shared_ptr<ffwrapper::CodedData> data, int64_t &id);
        void GetFrame(unsigned char **data, int *w, int *h, int64_t *id);
    public:
        decoder(ffwrapper::FormatIn *dec, const int w, const int h, const int f);
        ~decoder();
    };
    
} // namespace cffmpeg_wrap
 
 
#endif