From fa8b072f4c5359703ae664ef8a5d79139742e2e8 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期五, 29 十一月 2019 11:20:08 +0800 Subject: [PATCH] optimize ffmpeg decode cpu and memory --- csrc/worker/decoder.hpp | 16 +++++++++++----- 1 files changed, 11 insertions(+), 5 deletions(-) diff --git a/csrc/worker/decoder.hpp b/csrc/worker/decoder.hpp index 94bbb03..533140d 100644 --- a/csrc/worker/decoder.hpp +++ b/csrc/worker/decoder.hpp @@ -12,6 +12,8 @@ struct AVFrame; struct AVCodecContext; +class CPacket; + namespace ffwrapper { class FormatIn; @@ -21,7 +23,10 @@ namespace cffmpeg_wrap { typedef struct _frm{ - AVFrame *frm; + AVFrame *avframe; + int length; + int width; + int height; int64_t id; }FRM; @@ -30,18 +35,19 @@ private: ffwrapper::FormatIn *decRef_; - + std::list<FRM> list_frm_; std::mutex mutex_frm_; private: int initDecoder(); - int saveFrame(AVFrame *frame, int64_t &id); + int saveFrame(AVFrame *frame, const int64_t &id); public: void Start(); - int SetFrame(std::shared_ptr<ffwrapper::CodedData> data, int64_t &id); + int SetFrame(const CPacket &pkt); void GetFrame(unsigned char **data, int *w, int *h, int *format, int *length, int64_t *id); - + private: + public: explicit decoder(ffwrapper::FormatIn *dec); ~decoder(); -- Gitblit v1.8.0