From 95f19fa05f4d55e2eb384e9d05feff2f9e53ab4e Mon Sep 17 00:00:00 2001 From: codestation Date: Sun, 10 Jan 2016 10:20:47 -0430 Subject: [PATCH] Do not use avcodec_free_context on older avcodec versions. --- common/avdecoder.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/common/avdecoder.cpp b/common/avdecoder.cpp index 9d5afd3..d4ff140 100644 --- a/common/avdecoder.cpp +++ b/common/avdecoder.cpp @@ -286,7 +286,12 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int pOCodecCtx = avcodec_alloc_context3(pOCodec); if(pOCodecCtx == NULL) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0) avcodec_free_context(&pOCodecCtx); +#else + avcodec_close(pOCodecCtx); + av_free(pOCodecCtx); +#endif av_free(buffer); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) av_frame_free(&pFrameRGB); @@ -308,7 +313,12 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int AVDictionary *opts = NULL; if(avcodec_open2(pOCodecCtx, pOCodec, &opts) < 0) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0) avcodec_free_context(&pOCodecCtx); +#else + avcodec_close(pOCodecCtx); + av_free(pOCodecCtx); +#endif av_free(buffer); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) av_frame_free(&pFrameRGB); @@ -338,7 +348,12 @@ QByteArray AVDecoder::WriteJPEG(AVCodecContext *pCodecCtx, AVFrame *pFrame, int QByteArray buffer2(reinterpret_cast(pkt.data), pkt.size); - avcodec_free_context(&pOCodecCtx); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,52,0) + avcodec_free_context(&pOCodecCtx); +#else + avcodec_close(pOCodecCtx); + av_free(pOCodecCtx); +#endif av_free(buffer); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1) av_frame_free(&pFrameRGB);