video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-09 68a19a73681301c6712e10d55bc64324716dbd24
csrc/worker/decoder.hpp
@@ -10,34 +10,29 @@
#include <condition_variable>
struct AVFrame;
struct AVCodecContext;
namespace ffwrapper
{
    class FormatIn;
    class cvbridge;
    class CodedData;
} // namespace ffwrapper
namespace cffmpeg_wrap
{
    typedef struct _pic_bgr24{
        unsigned char *data;
        int w;
        int h;
    typedef struct _frm{
        AVFrame *frm;
        int64_t id;
    }BGR24;
    }FRM;
    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_;
        std::list<FRM> list_frm_;
        std::mutex mutex_frm_;
    private:
        int initDecoder();
@@ -45,9 +40,10 @@
    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);
        void GetFrame(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id);
    public:
        decoder(ffwrapper::FormatIn *dec, const int w, const int h, const int f);
        explicit decoder(ffwrapper::FormatIn *dec);
        ~decoder();
    };