extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libswscale/swscale.h" #include "libavutil/imgutils.h" } #pragma comment(lib, "avcodec.lib") #pragma comment(lib, "avformat.lib") #pragma comment(lib, "avutil.lib") #pragma comment(lib, "swscale.lib") typedef void (*CallbackFun)(unsigned char* data,int width,int height); class Decoder_Software { public: Decoder_Software() { mSrcWth = 0; mSrcHth = 0; mDstWth = 0; mDstHth = 0; mPixFmt = 0; dst_bgr_pic_size = 0; dst_yuv_pic_size = 0; codec = NULL; codecctx= NULL; mSrcFrame = NULL; mDstFrame = NULL; scxt = NULL; // AVPacket pkt; s = NULL; opix_fmt = AV_PIX_FMT_YUV420P; mOutBuf = NULL; } ~Decoder_Software(){} bool decoder_sw_init(int srcWth,int srcHth,int dstWth,int dstHth,int oPixFmt); void decoder_sw_decoding(unsigned char* in_buf,int in_len); void decoder_sw_release(); void set_decoding_callback(CallbackFun fun){decodingCallback = fun;} protected: void ffmpeg_ref_release(); void pic_ref_mem_release(); private: int mSrcWth; int mSrcHth; int mDstWth; int mDstHth; int mPixFmt; int dst_bgr_pic_size; int dst_yuv_pic_size; AVCodec *codec; AVCodecContext *codecctx; AVFrame *mSrcFrame; AVFrame *mDstFrame; SwsContext *scxt; AVPacket pkt; AVCodecParserContext *s; uint8_t *mOutBuf; AVPixelFormat opix_fmt; CallbackFun decodingCallback; };