From efc057e128ec2a2a19df4e1a66a566e25885c0a9 Mon Sep 17 00:00:00 2001 From: AsamK Date: Fri, 4 Sep 2015 23:42:26 +0200 Subject: [PATCH 1/2] Fix build with libavcodec < 55 --- plugins/VOIP/gui/VideoProcessor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/VOIP/gui/VideoProcessor.cpp b/plugins/VOIP/gui/VideoProcessor.cpp index 27129216f..60b57e716 100644 --- a/plugins/VOIP/gui/VideoProcessor.cpp +++ b/plugins/VOIP/gui/VideoProcessor.cpp @@ -536,12 +536,24 @@ bool FFmpegVideo::encodeData(const QImage& image, uint32_t target_encoding_bitra AVPacket pkt ; av_init_packet(&pkt); +#if LIBAVCODEC_VERSION_MAJOR < 55 + pkt.size = avpicture_get_size(encoding_context->pix_fmt, encoding_context->width, encoding_context->height); + pkt.data = (uint8_t*)av_malloc(pkt.size); + + // do + // { + int ret = avcodec_encode_video(encoding_context, pkt.data, pkt.size, frame) ; + if (ret > 0) { + got_output = ret; + } +#else pkt.data = NULL; // packet data will be allocated by the encoder pkt.size = 0; // do // { int ret = avcodec_encode_video2(encoding_context, &pkt, frame, &got_output) ; +#endif if (ret < 0) { From f2994b7558d47a1bf6992ff2ab05c26f8dc593b7 Mon Sep 17 00:00:00 2001 From: AsamK Date: Fri, 4 Sep 2015 23:59:13 +0200 Subject: [PATCH 2/2] Old libav versions used constant without AV_ prefix From Jenster --- plugins/VOIP/gui/VideoProcessor.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/VOIP/gui/VideoProcessor.cpp b/plugins/VOIP/gui/VideoProcessor.cpp index 60b57e716..0bc16dab0 100644 --- a/plugins/VOIP/gui/VideoProcessor.cpp +++ b/plugins/VOIP/gui/VideoProcessor.cpp @@ -325,8 +325,11 @@ FFmpegVideo::FFmpegVideo() //AVCodecID codec_id = AV_CODEC_ID_H264 ; //AVCodecID codec_id = AV_CODEC_ID_MPEG2VIDEO; +#if LIBAVCODEC_VERSION_MAJOR < 55 + CodecID codec_id = CODEC_ID_MPEG4; +#else AVCodecID codec_id = AV_CODEC_ID_MPEG4; - +#endif uint8_t endcode[] = { 0, 0, 1, 0xb7 }; /* find the mpeg1 video encoder */ @@ -385,10 +388,15 @@ FFmpegVideo::FFmpegVideo() */ encoding_context->gop_size = 100; //encoding_context->max_b_frames = 1; +#if LIBAVCODEC_VERSION_MAJOR < 55 + encoding_context->pix_fmt = PIX_FMT_YUV420P; //context->pix_fmt = PIX_FMT_RGB24; + if (codec_id == CODEC_ID_H264) { +#else encoding_context->pix_fmt = AV_PIX_FMT_YUV420P; //context->pix_fmt = AV_PIX_FMT_RGB24; - - if (codec_id == AV_CODEC_ID_H264) + if (codec_id == AV_CODEC_ID_H264) { +#endif av_opt_set(encoding_context->priv_data, "preset", "slow", 0); + } /* open it */ if (avcodec_open2(encoding_context, encoding_codec, NULL) < 0) @@ -428,7 +436,11 @@ FFmpegVideo::FFmpegVideo() decoding_context->width = encoding_context->width; decoding_context->height = encoding_context->height; +#if LIBAVCODEC_VERSION_MAJOR < 55 + decoding_context->pix_fmt = PIX_FMT_YUV420P; +#else decoding_context->pix_fmt = AV_PIX_FMT_YUV420P; +#endif if(decoding_codec->capabilities & CODEC_CAP_TRUNCATED) decoding_context->flags |= CODEC_FLAG_TRUNCATED; // we do not send complete frames @@ -694,4 +706,3 @@ bool FFmpegVideo::decodeData(const RsVOIPDataChunk& chunk,QImage& image) return true ; } -