1 Description: Backport changes for the libav 9 API
2 Also replace loading of libavcodec and libavutil via dlopen by linking against
4 Author: Sebastian Ramacher <sramacher@debian.org>
5 Bug-Debian: http://bugs.debian.org/720824
6 Last-Update: 2013-09-12
8 --- a/plugins/video/H.263-1998/h263-1998.cxx
9 +++ b/plugins/video/H.263-1998/h263-1998.cxx
14 - m_context = FFMPEGLibraryInstance.AvcodecAllocContext();
15 + m_context = FFMPEGLibraryInstance.AvcodecAllocContext(m_codec);
16 if (m_context == NULL) {
17 PTRACE(1, m_prefix, "Failed to allocate context for encoder");
23 +#ifdef CODEC_FLAG_H263P_UMV
24 if (STRCMPI(option, H263_ANNEX_D) == 0) {
25 // Annex D: Unrestructed Motion Vectors
28 m_context->flags &= ~CODEC_FLAG_H263P_UMV;
33 #if 0 // DO NOT ENABLE THIS FLAG. FFMPEG IS NOT THREAD_SAFE WHEN THIS FLAG IS SET
34 if (STRCMPI(option, H263_ANNEX_F) == 0) {
39 +#ifdef CODEC_FLAG_H263P_SLICE_STRUCT
40 if (STRCMPI(option, H263_ANNEX_K) == 0) {
41 // Annex K: Slice Structure
42 // does not work with eyeBeam
44 m_context->flags &= ~CODEC_FLAG_H263P_SLICE_STRUCT;
49 +#ifdef CODEC_FLAG_H263P_AIV
50 if (STRCMPI(option, H263_ANNEX_S) == 0) {
51 // Annex S: Alternative INTER VLC mode
52 // does not work with eyeBeam
54 m_context->flags &= ~CODEC_FLAG_H263P_AIV;
59 if (STRCMPI(option, PLUGINCODEC_MEDIA_PACKETIZATION) == 0 ||
60 STRCMPI(option, PLUGINCODEC_MEDIA_PACKETIZATIONS) == 0) {
62 PTRACE(5, m_prefix, "qmax set to " << m_context->qmax);
63 PTRACE(5, m_prefix, "payload size set to " << m_context->rtp_payload_size);
65 - #define CODEC_TRACER_FLAG(tracer, flag) \
66 - PTRACE(4, m_prefix, #flag " is " << ((m_context->flags & flag) ? "enabled" : "disabled"));
67 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_UMV);
68 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_OBMC);
69 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_AC_PRED);
70 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_SLICE_STRUCT)
71 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_LOOP_FILTER);
72 - CODEC_TRACER_FLAG(tracer, CODEC_FLAG_H263P_AIV);
74 return FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) == 0;
79 // Need to copy to local buffer to guarantee 16 byte alignment
80 memcpy(m_inputFrame->data[0], OPAL_VIDEO_FRAME_DATA_PTR(header), header->width*header->height*3/2);
81 - m_inputFrame->pict_type = (flags & PluginCodec_CoderForceIFrame) ? FF_I_TYPE : AV_PICTURE_TYPE_NONE;
82 + m_inputFrame->pict_type = (flags & PluginCodec_CoderForceIFrame) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_NONE;
85 m_inputFrame->pts = (int64_t)srcRTP.GetTimestamp()*m_context->time_base.den/m_context->time_base.num/VIDEO_CLOCKRATE;
87 m_context->rtp_callback = &H263_RFC2190_EncoderContext::RTPCallBack;
88 m_context->opaque = this; // used to separate out packets from different encode threads
90 +#ifdef CODEC_FLAG_H263P_UMV
91 m_context->flags &= ~CODEC_FLAG_H263P_UMV;
93 m_context->flags &= ~CODEC_FLAG_4MV;
94 #if LIBAVCODEC_RTP_MODE
95 m_context->flags &= ~CODEC_FLAG_H263P_AIC;
97 +#ifdef CODEC_FLAG_H263P_AIV
98 m_context->flags &= ~CODEC_FLAG_H263P_AIV;
100 +#ifdef CODEC_FLAG_H263P_SLICE_STRUCT
101 m_context->flags &= ~CODEC_FLAG_H263P_SLICE_STRUCT;
110 - m_context = FFMPEGLibraryInstance.AvcodecAllocContext();
111 + m_context = FFMPEGLibraryInstance.AvcodecAllocContext(m_codec);
112 if (m_context == NULL) {
113 PTRACE(1, m_prefix, "Failed to allocate context for decoder");
115 --- a/plugins/video/H.264/h264-x264.cxx
116 +++ b/plugins/video/H.264/h264-x264.cxx
118 #include "shared/h264frame.h"
119 #include "shared/x264wrap.h"
123 #define MY_CODEC x264 // Name of codec (use C variable characters)
124 #define MY_CODEC_LOG "x264"
125 @@ -1067,18 +1068,17 @@
126 if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H264)) == NULL)
129 - if ((m_context = FFMPEGLibraryInstance.AvcodecAllocContext()) == NULL)
130 + if ((m_context = FFMPEGLibraryInstance.AvcodecAllocContext(m_codec)) == NULL)
133 m_context->workaround_bugs = FF_BUG_AUTODETECT;
134 - m_context->error_recognition = FF_ER_AGGRESSIVE;
135 m_context->idct_algo = FF_IDCT_H264;
136 m_context->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
137 m_context->flags = CODEC_FLAG_INPUT_PRESERVED | CODEC_FLAG_EMU_EDGE;
138 - m_context->flags2 = CODEC_FLAG2_BRDO |
139 - CODEC_FLAG2_MEMC_ONLY |
140 + m_context->flags2 = CODEC_FLAG2_SKIP_RD |
141 +#ifdef CODEC_FLAG2_DROP_FRAME_TIMECODE
142 CODEC_FLAG2_DROP_FRAME_TIMECODE |
143 - CODEC_FLAG2_SKIP_RD |
147 if ((m_picture = FFMPEGLibraryInstance.AvcodecAllocFrame()) == NULL)
148 --- a/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
149 +++ b/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
150 @@ -589,17 +589,14 @@
151 m_avpicture->quality = m_videoQMin;
154 - m_avcontext->flags |= CODEC_FLAG_PART; // data partitioning
155 m_avcontext->flags |= CODEC_FLAG_4MV; // 4 motion vectors
157 m_avcontext->max_b_frames=0; /*don't use b frames*/
158 m_avcontext->flags|=CODEC_FLAG_AC_PRED;
159 - m_avcontext->flags|=CODEC_FLAG_H263P_UMV;
160 /*c->flags|=CODEC_FLAG_QPEL;*/ /*don't enable this one: this forces profile_level to advanced simple profile */
161 m_avcontext->flags|=CODEC_FLAG_4MV;
162 m_avcontext->flags|=CODEC_FLAG_GMC;
163 m_avcontext->flags|=CODEC_FLAG_LOOP_FILTER;
164 - m_avcontext->flags|=CODEC_FLAG_H263P_SLICE_STRUCT;
166 m_avcontext->opaque = this; // for use in RTP callback
170 bool MPEG4EncoderContext::OpenCodec()
172 - m_avcontext = FFMPEGLibraryInstance.AvcodecAllocContext();
173 + if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(CODEC_ID_MPEG4)) == NULL){
174 + PTRACE(1, "MPEG4", "Encoder not found");
178 + m_avcontext = FFMPEGLibraryInstance.AvcodecAllocContext(m_avcodec);
179 if (m_avcontext == NULL) {
180 PTRACE(1, "MPEG4", "Encoder failed to allocate context for encoder");
186 - if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(CODEC_ID_MPEG4)) == NULL){
187 - PTRACE(1, "MPEG4", "Encoder not found");
191 #if PLUGINCODEC_TRACING
193 if (PTRACE_CHECK(4)) {
195 // Should the next frame be an I-Frame?
196 if ((flags & PluginCodec_CoderForceIFrame) || (m_frameNum == 0))
198 - m_avpicture->pict_type = FF_I_TYPE;
199 + m_avpicture->pict_type = AV_PICTURE_TYPE_I;
201 else // No IFrame requested, let avcodec decide what to do
203 @@ -1325,7 +1322,6 @@
205 void MPEG4DecoderContext::SetStaticDecodingParams() {
206 m_avcontext->flags |= CODEC_FLAG_4MV;
207 - m_avcontext->flags |= CODEC_FLAG_PART;
208 m_avcontext->workaround_bugs = 0; // no workaround for buggy implementations
211 @@ -1399,7 +1395,7 @@
215 - m_avcontext = FFMPEGLibraryInstance.AvcodecAllocContext();
216 + m_avcontext = FFMPEGLibraryInstance.AvcodecAllocContext(m_avcodec);
217 if (m_avcontext == NULL) {
218 PTRACE(1, "MPEG4", "Decoder failed to allocate context");
220 --- a/plugins/video/common/dyna.cxx
221 +++ b/plugins/video/common/dyna.cxx
223 * Matthias Schneider (ma30002000@yahoo.de)
230 +#include <libavcodec/avcodec.h>
231 +#include <libavutil/mem.h>
234 bool DynaLink::Open(const char *name)
236 @@ -228,101 +235,15 @@
240 -#define CHECK_AVUTIL(name, func) \
241 - (seperateLibAvutil ? \
242 - m_libAvutil.GetFunction(name, (DynaLink::Function &)func) : \
243 - m_libAvcodec.GetFunction(name, (DynaLink::Function &)func) \
247 bool FFMPEGLibrary::Load()
249 WaitAndSignal m(processLock);
253 - bool seperateLibAvutil = false;
255 -#ifdef LIBAVCODEC_LIB_NAME
256 - if (m_libAvcodec.Open(LIBAVCODEC_LIB_NAME))
257 - seperateLibAvutil = true;
260 - if (m_libAvcodec.Open("libavcodec"))
261 - seperateLibAvutil = false;
262 - else if (m_libAvcodec.Open("avcodec-" AV_STRINGIFY(LIBAVCODEC_VERSION_MAJOR)))
263 - seperateLibAvutil = true;
265 - PTRACE(1, m_codecString, "Failed to load FFMPEG libavcodec library");
269 - if (seperateLibAvutil &&
271 -#ifdef LIBAVUTIL_LIB_NAME
272 - m_libAvutil.Open(LIBAVUTIL_LIB_NAME) ||
274 - m_libAvutil.Open("libavutil") ||
275 - m_libAvutil.Open("avutil-" AV_STRINGIFY(LIBAVUTIL_VERSION_MAJOR))
277 - PTRACE(1, m_codecString, "Failed to load FFMPEG libavutil library");
281 - strcpy(m_libAvcodec.m_codecString, m_codecString);
282 - strcpy(m_libAvutil.m_codecString, m_codecString);
284 - if (!m_libAvcodec.GetFunction("avcodec_init", (DynaLink::Function &)Favcodec_init))
287 - if (!m_libAvcodec.GetFunction("av_init_packet", (DynaLink::Function &)Fav_init_packet))
290 - if (!m_libAvcodec.GetFunction("avcodec_register_all", (DynaLink::Function &)Favcodec_register_all))
293 - if (!m_libAvcodec.GetFunction("avcodec_find_encoder", (DynaLink::Function &)Favcodec_find_encoder))
296 - if (!m_libAvcodec.GetFunction("avcodec_find_decoder", (DynaLink::Function &)Favcodec_find_decoder))
299 - if (!m_libAvcodec.GetFunction("avcodec_alloc_context", (DynaLink::Function &)Favcodec_alloc_context))
302 - if (!m_libAvcodec.GetFunction("avcodec_alloc_frame", (DynaLink::Function &)Favcodec_alloc_frame))
305 - if (!m_libAvcodec.GetFunction("avcodec_open", (DynaLink::Function &)Favcodec_open))
308 - if (!m_libAvcodec.GetFunction("avcodec_close", (DynaLink::Function &)Favcodec_close))
311 - if (!m_libAvcodec.GetFunction("avcodec_encode_video", (DynaLink::Function &)Favcodec_encode_video))
314 - if (!m_libAvcodec.GetFunction("avcodec_decode_video2", (DynaLink::Function &)Favcodec_decode_video))
317 - if (!m_libAvcodec.GetFunction("avcodec_set_dimensions", (DynaLink::Function &)Favcodec_set_dimensions))
320 - if (!CHECK_AVUTIL("av_free", Favcodec_free))
323 - if(!m_libAvcodec.GetFunction("avcodec_version", (DynaLink::Function &)Favcodec_version))
326 - if (!CHECK_AVUTIL("av_log_set_level", FAv_log_set_level))
329 - if (!CHECK_AVUTIL("av_log_set_callback", FAv_log_set_callback))
332 // must be called before using avcodec lib
334 - unsigned libVer = Favcodec_version();
335 + unsigned libVer = avcodec_version();
336 if (libVer != LIBAVCODEC_VERSION_INT) {
337 PTRACE(2, m_codecString, "Warning: compiled against libavcodec headers from version "
338 << LIBAVCODEC_VERSION_MAJOR << '.' << LIBAVCODEC_VERSION_MINOR << '.' << LIBAVCODEC_VERSION_MICRO
340 << (libVer >> 16) << ((libVer>>8) & 0xff) << (libVer & 0xff));
344 - Favcodec_register_all ();
345 + avcodec_register_all();
347 #if PLUGINCODEC_TRACING
348 AvLogSetLevel(AV_LOG_DEBUG);
349 @@ -350,49 +270,49 @@
351 AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum CodecID id)
353 - return Favcodec_find_encoder(id);
354 + return avcodec_find_encoder(id);
357 AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum CodecID id)
359 WaitAndSignal m(processLock);
361 - return Favcodec_find_decoder(id);
362 + return avcodec_find_decoder(id);
365 -AVCodecContext *FFMPEGLibrary::AvcodecAllocContext(void)
366 +AVCodecContext *FFMPEGLibrary::AvcodecAllocContext(AVCodec *codec)
368 WaitAndSignal m(processLock);
370 - return Favcodec_alloc_context();
371 + return avcodec_alloc_context3(codec);
374 AVFrame *FFMPEGLibrary::AvcodecAllocFrame(void)
376 WaitAndSignal m(processLock);
378 - return Favcodec_alloc_frame();
379 + return avcodec_alloc_frame();
382 int FFMPEGLibrary::AvcodecOpen(AVCodecContext *ctx, AVCodec *codec)
384 WaitAndSignal m(processLock);
386 - return Favcodec_open(ctx, codec);
387 + return avcodec_open2(ctx, codec, NULL);
390 int FFMPEGLibrary::AvcodecClose(AVCodecContext *ctx)
392 WaitAndSignal m(processLock);
394 - return Favcodec_close(ctx);
395 + return avcodec_close(ctx);
398 int FFMPEGLibrary::AvcodecEncodeVideo(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict)
402 - res = Favcodec_encode_video(ctx, buf, buf_size, pict);
403 + res = avcodec_encode_video(ctx, buf, buf_size, pict);
405 PTRACE(6, m_codecString, "DYNA\tEncoded into " << res << " bytes, max " << buf_size);
407 @@ -401,35 +321,35 @@
408 int FFMPEGLibrary::AvcodecDecodeVideo(AVCodecContext *ctx, AVFrame *pict, int *got_picture_ptr, BYTE *buf, int buf_size)
411 - Fav_init_packet(&avpkt);
412 + av_init_packet(&avpkt);
414 avpkt.size = buf_size;
416 - return Favcodec_decode_video(ctx, pict, got_picture_ptr, &avpkt);
417 + return avcodec_decode_video2(ctx, pict, got_picture_ptr, &avpkt);
420 void FFMPEGLibrary::AvcodecFree(void * ptr)
422 WaitAndSignal m(processLock);
424 - Favcodec_free(ptr);
428 void FFMPEGLibrary::AvSetDimensions(AVCodecContext *s, int width, int height)
430 WaitAndSignal m(processLock);
432 - Favcodec_set_dimensions(s, width, height);
433 + avcodec_set_dimensions(s, width, height);
436 void FFMPEGLibrary::AvLogSetLevel(int level)
438 - FAv_log_set_level(level);
439 + av_log_set_level(level);
442 void FFMPEGLibrary::AvLogSetCallback(void (*callback)(void*, int, const char*, va_list))
444 - FAv_log_set_callback(callback);
445 + av_log_set_callback(callback);
448 bool FFMPEGLibrary::IsLoaded()
449 --- a/plugins/video/common/dyna.h
450 +++ b/plugins/video/common/dyna.h
453 AVCodec *AvcodecFindEncoder(enum CodecID id);
454 AVCodec *AvcodecFindDecoder(enum CodecID id);
455 - AVCodecContext *AvcodecAllocContext(void);
456 + AVCodecContext *AvcodecAllocContext(AVCodec*);
457 AVFrame *AvcodecAllocFrame(void);
458 int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec);
459 int AvcodecClose(AVCodecContext *ctx);
462 char m_codecString[32];
464 - void (*Favcodec_init)(void);
465 - void (*Fav_init_packet)(AVPacket *pkt);
467 - void (*Favcodec_register_all)(void);
468 - AVCodec *(*Favcodec_find_encoder)(enum CodecID id);
469 - AVCodec *(*Favcodec_find_decoder)(enum CodecID id);
470 - AVCodecContext *(*Favcodec_alloc_context)(void);
471 - AVFrame *(*Favcodec_alloc_frame)(void);
472 - int (*Favcodec_open)(AVCodecContext *ctx, AVCodec *codec);
473 - int (*Favcodec_close)(AVCodecContext *ctx);
474 - int (*Favcodec_encode_video)(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict);
475 - int (*Favcodec_decode_video)(AVCodecContext *ctx, AVFrame *pict, int *got_picture_ptr, AVPacket *avpkt);
476 - unsigned (*Favcodec_version)(void);
477 - void (*Favcodec_set_dimensions)(AVCodecContext *ctx, int width, int height);
479 - void (*Favcodec_free)(void *);
481 - void (*FAv_log_set_level)(int level);
482 - void (*FAv_log_set_callback)(void (*callback)(void*, int, const char*, va_list));
487 --- a/plugins/video/common/ffmpeg.h
488 +++ b/plugins/video/common/ffmpeg.h
491 #include "platform.h"
493 -#include "libavcodec/avcodec.h"
495 +#include <libavcodec/avcodec.h>
496 // AVPacket was declared in avformat.h before April 2009
497 #if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 25, 0)
498 -#include "libavformat/avformat.h"
499 +#include <libavformat/avformat.h>
503 #ifndef LIBAVCODEC_VERSION_INT
504 #error Libavcodec include is not correct
505 --- a/plugins/video/H.263-1998/Makefile.in
506 +++ b/plugins/video/H.263-1998/Makefile.in
508 $(COMMONDIR)/mpi.cxx \
509 $(COMMONDIR)/dyna.cxx
511 -CFLAGS += @LIBAVCODEC_CFLAGS@ -I$(COMMONDIR)
513 +CFLAGS += @LIBAVCODEC_CFLAGS@ @LIBAVUTIL_CFLAGS@ -I$(COMMONDIR)
514 +LIBS += @DL_LIBS@ @LIBAVCODEC_LIBS@ @LIBAVUTIL_LIBS@
516 HAVE_LIBAVCODEC_RTP_MODE=@HAVE_LIBAVCODEC_RTP_MODE@
517 ifeq ($(HAVE_LIBAVCODEC_RTP_MODE),yes)
518 --- a/plugins/video/H.264/Makefile.in
519 +++ b/plugins/video/H.264/Makefile.in
521 $(SHAREDDIR)/x264wrap.cxx \
522 $(COMMONDIR)/dyna.cxx \
524 -CFLAGS += @LIBAVCODEC_CFLAGS@ -I$(COMMONDIR) -DLIB_DIR='"$(libdir)"' -DVC_PLUGIN_DIR='"@VC_PLUGIN_DIR@"'
526 +CFLAGS += @LIBAVCODEC_CFLAGS@ @LIBAVUTIL_CFLAGS@ -I$(COMMONDIR) -DLIB_DIR='"$(libdir)"' -DVC_PLUGIN_DIR='"@VC_PLUGIN_DIR@"'
527 +LIBS += @DL_LIBS@ @LIBAVCODEC_LIBS@ @LIBAVUTIL_LIBS@
529 IS_H264_LICENSED:=@IS_H264_LICENSED@
530 ifeq ($(IS_H264_LICENSED),yes)
531 --- a/plugins/video/MPEG4-ffmpeg/Makefile.in
532 +++ b/plugins/video/MPEG4-ffmpeg/Makefile.in
535 SRCS := mpeg4.cxx $(COMMONDIR)/dyna.cxx
537 -CFLAGS += @LIBAVCODEC_CFLAGS@ -I$(COMMONDIR)
539 +CFLAGS += @LIBAVCODEC_CFLAGS@ @LIBAVUTIL_CFLAGS@ -I$(COMMONDIR)
540 +LIBS += @DL_LIBS@ @LIBAVCODEC_LIBS@ @LIBAVUTIL_LIBS@
542 # Add LIBAVCODEC_SOURCE_DIR to the include path so we can #include <libavcodec/...h>
543 # Also add libavutil, so ffmpeg headers can #include "log.h".
544 Description: Fix compilation against libav10
545 Author: Reinhard Tartler <siretart@tauware.de>
546 Bug-Debian: http://bugs.debian.org/739439
548 --- a/plugins/video/H.263-1998/h263-1998.cxx
549 +++ b/plugins/video/H.263-1998/h263-1998.cxx
550 @@ -94,7 +94,7 @@ static struct StdSizes {
551 { CIF16_WIDTH, CIF16_HEIGHT, PLUGINCODEC_CIF16_MPI },
554 -static FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H263P);
555 +static FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H263P);
558 /////////////////////////////////////////////////////////////////////////////
559 @@ -203,7 +203,7 @@ H263_Base_EncoderContext::~H263_Base_Enc
560 PTRACE(4, m_prefix, "Encoder closed");
563 -bool H263_Base_EncoderContext::Init(CodecID codecId)
564 +bool H263_Base_EncoderContext::Init(AVCodecID codecId)
566 PTRACE(5, m_prefix, "Opening encoder");
568 @@ -589,7 +589,7 @@ void H263_RFC2190_EncoderContext::RTPCal
570 bool H263_RFC2190_EncoderContext::Init()
572 - if (!H263_Base_EncoderContext::Init(CODEC_ID_H263))
573 + if (!H263_Base_EncoderContext::Init(AV_CODEC_ID_H263))
576 #if LIBAVCODEC_RTP_MODE
577 @@ -632,7 +632,7 @@ H263_RFC2429_EncoderContext::~H263_RFC24
579 bool H263_RFC2429_EncoderContext::Init()
581 - return H263_Base_EncoderContext::Init(CODEC_ID_H263P);
582 + return H263_Base_EncoderContext::Init(AV_CODEC_ID_H263P);
586 @@ -656,7 +656,7 @@ H263_Base_DecoderContext::H263_Base_Deco
587 if (!FFMPEGLibraryInstance.Load())
590 - if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H263)) == NULL) {
591 + if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H263)) == NULL) {
592 PTRACE(1, m_prefix, "Codec not found for decoder");
595 --- a/plugins/video/H.264/h264-x264.cxx
596 +++ b/plugins/video/H.264/h264-x264.cxx
597 @@ -105,7 +105,7 @@ static struct PluginCodec_information Li
599 ///////////////////////////////////////////////////////////////////////////////
601 -FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H264);
602 +FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H264);
604 PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF
606 @@ -1065,17 +1065,17 @@ class MyDecoder : public PluginCodec<MY_
607 allows you to fail the create operation (return false), which cannot
608 be done in the normal C++ constructor. */
610 - if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H264)) == NULL)
611 + if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H264)) == NULL)
614 if ((m_context = FFMPEGLibraryInstance.AvcodecAllocContext(m_codec)) == NULL)
617 m_context->workaround_bugs = FF_BUG_AUTODETECT;
618 - m_context->idct_algo = FF_IDCT_H264;
619 + m_context->idct_algo = FF_IDCT_AUTO;
620 m_context->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
621 m_context->flags = CODEC_FLAG_INPUT_PRESERVED | CODEC_FLAG_EMU_EDGE;
622 - m_context->flags2 = CODEC_FLAG2_SKIP_RD |
623 + m_context->flags2 =
624 #ifdef CODEC_FLAG2_DROP_FRAME_TIMECODE
625 CODEC_FLAG2_DROP_FRAME_TIMECODE |
627 --- a/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
628 +++ b/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
629 @@ -205,7 +205,7 @@ const static struct mpeg4_resolution {
633 -FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_MPEG4);
634 +FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_MPEG4);
637 static bool mpeg4IsIframe (BYTE * frameBuffer, unsigned int frameLen )
638 @@ -688,7 +688,7 @@ void MPEG4EncoderContext::ResizeEncoding
640 bool MPEG4EncoderContext::OpenCodec()
642 - if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(CODEC_ID_MPEG4)) == NULL){
643 + if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(AV_CODEC_ID_MPEG4)) == NULL){
644 PTRACE(1, "MPEG4", "Encoder not found");
647 @@ -1390,7 +1390,7 @@ void MPEG4DecoderContext::ResizeDecoding
649 bool MPEG4DecoderContext::OpenCodec()
651 - if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_MPEG4)) == NULL) {
652 + if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_MPEG4)) == NULL) {
653 PTRACE(1, "MPEG4", "Decoder not found for encoder");
656 --- a/plugins/video/H.263-1998/h263-1998.h
657 +++ b/plugins/video/H.263-1998/h263-1998.h
658 @@ -115,7 +115,7 @@ class H263_Base_EncoderContext
659 virtual ~H263_Base_EncoderContext();
661 virtual bool Init() = 0;
662 - virtual bool Init(CodecID codecId);
663 + virtual bool Init(AVCodecID codecId);
665 virtual bool SetOptions(const char * const * options);
666 virtual void SetOption(const char * option, const char * value);
667 --- a/plugins/video/common/dyna.cxx
668 +++ b/plugins/video/common/dyna.cxx
669 @@ -217,14 +217,14 @@ static void logCallbackFFMPEG(void * avc
673 -FFMPEGLibrary::FFMPEGLibrary(CodecID codec)
674 +FFMPEGLibrary::FFMPEGLibrary(AVCodecID codec)
677 - if (m_codec==CODEC_ID_H264)
678 + if (m_codec==AV_CODEC_ID_H264)
679 snprintf( m_codecString, sizeof(m_codecString), "H264");
680 - if (m_codec==CODEC_ID_H263P)
681 + if (m_codec==AV_CODEC_ID_H263P)
682 snprintf( m_codecString, sizeof(m_codecString), "H263+");
683 - if (m_codec==CODEC_ID_MPEG4)
684 + if (m_codec==AV_CODEC_ID_MPEG4)
685 snprintf( m_codecString, sizeof(m_codecString), "MPEG4");
686 m_isLoadedOK = false;
688 @@ -268,12 +268,12 @@ bool FFMPEGLibrary::Load()
692 -AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum CodecID id)
693 +AVCodec *FFMPEGLibrary::AvcodecFindEncoder(enum AVCodecID id)
695 return avcodec_find_encoder(id);
698 -AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum CodecID id)
699 +AVCodec *FFMPEGLibrary::AvcodecFindDecoder(enum AVCodecID id)
701 WaitAndSignal m(processLock);
703 @@ -308,13 +308,18 @@ int FFMPEGLibrary::AvcodecClose(AVCodecC
704 return avcodec_close(ctx);
708 +#define FFMAX(a,b) ((a) > (b) ? (a) : (b))
709 int FFMPEGLibrary::AvcodecEncodeVideo(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict)
711 + AVPacket pkt = { 0 };
712 + int ret, got_output;
715 - res = avcodec_encode_video(ctx, buf, buf_size, pict);
716 + ret = avcodec_encode_video2(ctx, &pkt, pict, &got_output);
718 - PTRACE(6, m_codecString, "DYNA\tEncoded into " << res << " bytes, max " << buf_size);
719 + PTRACE(6, m_codecString, "DYNA\tEncoded into " << ret << " bytes, max " << buf_size);
720 + memcpy(buf, pkt.data, FFMAX(pkt.size, buf_size));
724 --- a/plugins/video/common/dyna.h
725 +++ b/plugins/video/common/dyna.h
726 @@ -88,13 +88,13 @@ class DynaLink
730 - FFMPEGLibrary(CodecID codec);
731 + FFMPEGLibrary(AVCodecID codec);
736 - AVCodec *AvcodecFindEncoder(enum CodecID id);
737 - AVCodec *AvcodecFindDecoder(enum CodecID id);
738 + AVCodec *AvcodecFindEncoder(enum AVCodecID id);
739 + AVCodec *AvcodecFindDecoder(enum AVCodecID id);
740 AVCodecContext *AvcodecAllocContext(AVCodec*);
741 AVFrame *AvcodecAllocFrame(void);
742 int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec);
743 @@ -117,7 +117,7 @@ class FFMPEGLibrary
744 DynaLink m_libAvcodec;
745 DynaLink m_libAvutil;
749 char m_codecString[32];
752 Description: Replace deprecated FFmpeg API
753 Author: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
754 Last-Update: <2015-11-02>
756 --- opal-3.10.10~dfsg2.orig/plugins/video/H.263-1998/h263-1998.cxx
757 +++ opal-3.10.10~dfsg2/plugins/video/H.263-1998/h263-1998.cxx
758 @@ -230,11 +230,10 @@ bool H263_Base_EncoderContext::Init(AVCo
760 m_context->opaque = this;
762 - m_context->flags = CODEC_FLAG_EMU_EDGE // don't draw edges
763 - | CODEC_FLAG_TRUNCATED // Possible missing packets
764 + m_context->flags = CODEC_FLAG_TRUNCATED // Possible missing packets
767 - m_context->pix_fmt = PIX_FMT_YUV420P;
768 + m_context->pix_fmt = AV_PIX_FMT_YUV420P;
769 m_context->gop_size = H263_KEY_FRAME_INTERVAL;
771 // X-Lite does not like Custom Picture frequency clocks... stick to 29.97Hz
772 @@ -440,9 +439,6 @@ bool H263_Base_EncoderContext::OpenCodec
773 m_inputFrame->data[1] = m_inputFrame->data[0] + planeSize;
774 m_inputFrame->data[2] = m_inputFrame->data[1] + (planeSize / 4);
776 - if (m_context->width > 352)
777 - m_context->flags &= ~CODEC_FLAG_EMU_EDGE; // Totally bizarre! FFMPEG crashes if on for CIF4
780 PTRACE(5, m_prefix, "Size is " << m_context->width << "x" << m_context->height);
781 PTRACE(5, m_prefix, "GOP is " << m_context->gop_size);
782 @@ -456,7 +452,7 @@ bool H263_Base_EncoderContext::OpenCodec
783 PTRACE(5, m_prefix, "qmax set to " << m_context->qmax);
784 PTRACE(5, m_prefix, "payload size set to " << m_context->rtp_payload_size);
786 - return FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) == 0;
787 + return FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) == 0;
790 void H263_Base_EncoderContext::CloseCodec()
791 @@ -707,7 +703,7 @@ bool H263_Base_DecoderContext::OpenCodec
795 - if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) < 0) {
796 + if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) < 0) {
797 PTRACE(1, m_prefix, "Failed to open H.263 decoder");
800 --- opal-3.10.10~dfsg2.orig/plugins/video/H.264/h264-x264.cxx
801 +++ opal-3.10.10~dfsg2/plugins/video/H.264/h264-x264.cxx
802 @@ -1074,7 +1074,6 @@ class MyDecoder : public PluginCodec<MY_
803 m_context->workaround_bugs = FF_BUG_AUTODETECT;
804 m_context->idct_algo = FF_IDCT_AUTO;
805 m_context->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
806 - m_context->flags = CODEC_FLAG_INPUT_PRESERVED | CODEC_FLAG_EMU_EDGE;
808 #ifdef CODEC_FLAG2_DROP_FRAME_TIMECODE
809 CODEC_FLAG2_DROP_FRAME_TIMECODE |
810 @@ -1084,7 +1083,7 @@ class MyDecoder : public PluginCodec<MY_
811 if ((m_picture = FFMPEGLibraryInstance.AvcodecAllocFrame()) == NULL)
814 - if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) < 0)
815 + if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) < 0)
818 PTRACE(4, MY_CODEC_LOG, "Opened decoder (SVN $Revision: 28048 $)");
819 --- opal-3.10.10~dfsg2.orig/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
820 +++ opal-3.10.10~dfsg2/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
821 @@ -539,7 +539,7 @@ void MPEG4EncoderContext::ResetBitCounte
824 void MPEG4EncoderContext::SetStaticEncodingParams(){
825 - m_avcontext->pix_fmt = PIX_FMT_YUV420P;
826 + m_avcontext->pix_fmt = AV_PIX_FMT_YUV420P;
827 m_avcontext->mb_decision = FF_MB_DECISION_SIMPLE; // high quality off
828 m_avcontext->rtp_payload_size = 750; // ffh263 uses 750
829 m_avcontext->rtp_callback = &MPEG4EncoderContext::RtpCallback;
830 @@ -595,7 +595,6 @@ void MPEG4EncoderContext::SetStaticEncod
831 m_avcontext->flags|=CODEC_FLAG_AC_PRED;
832 /*c->flags|=CODEC_FLAG_QPEL;*/ /*don't enable this one: this forces profile_level to advanced simple profile */
833 m_avcontext->flags|=CODEC_FLAG_4MV;
834 - m_avcontext->flags|=CODEC_FLAG_GMC;
835 m_avcontext->flags|=CODEC_FLAG_LOOP_FILTER;
837 m_avcontext->opaque = this; // for use in RTP callback
838 @@ -710,13 +709,15 @@ bool MPEG4EncoderContext::OpenCodec()
839 if (PTRACE_CHECK(4)) {
840 m_avcontext->debug |= FF_DEBUG_RC;
841 m_avcontext->debug |= FF_DEBUG_PICT_INFO;
842 - m_avcontext->debug |= FF_DEBUG_MV;
843 +// m_avcontext->debug |= FF_DEBUG_MV;
847 SetStaticEncodingParams();
848 SetDynamicEncodingParams(false); // don't force a restart, it's not open
849 - if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec) < 0)
850 + AVDictionary *opts = NULL;
851 + av_dict_set_int(&opts, "gmc", 1, 0);
852 + if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec, &opts) < 0)
854 PTRACE(1, "MPEG4", "Encoder could not be opened");
856 @@ -1411,7 +1412,7 @@ bool MPEG4DecoderContext::OpenCodec()
858 SetStaticDecodingParams();
859 SetDynamicDecodingParams(false); // don't force a restart, it's not open
860 - if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec) < 0) {
861 + if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec, NULL) < 0) {
862 PTRACE(1, "MPEG4", "Decoder failed to open");
865 --- opal-3.10.10~dfsg2.orig/plugins/video/common/dyna.cxx
866 +++ opal-3.10.10~dfsg2/plugins/video/common/dyna.cxx
867 @@ -291,14 +291,14 @@ AVFrame *FFMPEGLibrary::AvcodecAllocFram
869 WaitAndSignal m(processLock);
871 - return avcodec_alloc_frame();
872 + return av_frame_alloc();
875 -int FFMPEGLibrary::AvcodecOpen(AVCodecContext *ctx, AVCodec *codec)
876 +int FFMPEGLibrary::AvcodecOpen(AVCodecContext *ctx, AVCodec *codec, AVDictionary **options)
878 WaitAndSignal m(processLock);
880 - return avcodec_open2(ctx, codec, NULL);
881 + return avcodec_open2(ctx, codec, options);
884 int FFMPEGLibrary::AvcodecClose(AVCodecContext *ctx)
885 @@ -344,7 +344,15 @@ void FFMPEGLibrary::AvSetDimensions(AVCo
887 WaitAndSignal m(processLock);
889 - avcodec_set_dimensions(s, width, height);
890 + if (av_image_check_size(width, height, 0, s) < 0) {
891 + av_log(s, AV_LOG_WARNING, "Failed to set dimensions %d %d\n", width, height);
892 + width = height = 0;
895 + s->coded_width = width;
896 + s->coded_height = height;
897 + s->width = (width + (1 << av_codec_get_lowres(s)) - 1) >> av_codec_get_lowres(s);
898 + s->height = (height + (1 << av_codec_get_lowres(s)) - 1) >> av_codec_get_lowres(s);
901 void FFMPEGLibrary::AvLogSetLevel(int level)
902 --- opal-3.10.10~dfsg2.orig/plugins/video/common/dyna.h
903 +++ opal-3.10.10~dfsg2/plugins/video/common/dyna.h
904 @@ -97,7 +97,7 @@ class FFMPEGLibrary
905 AVCodec *AvcodecFindDecoder(enum AVCodecID id);
906 AVCodecContext *AvcodecAllocContext(AVCodec*);
907 AVFrame *AvcodecAllocFrame(void);
908 - int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec);
909 + int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec, AVDictionary **options);
910 int AvcodecClose(AVCodecContext *ctx);
911 int AvcodecEncodeVideo(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict);
912 int AvcodecDecodeVideo(AVCodecContext *ctx, AVFrame *pict, int *got_picture_ptr, BYTE *buf, int buf_size);
913 --- opal-3.10.10~dfsg2.orig/plugins/video/common/ffmpeg.h
914 +++ opal-3.10.10~dfsg2/plugins/video/common/ffmpeg.h
918 #include <libavcodec/avcodec.h>
919 +#include <libavutil/imgutils.h>
920 // AVPacket was declared in avformat.h before April 2009
921 #if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 25, 0)
922 #include <libavformat/avformat.h>
923 diff -ur opal-3.10.11.org/plugins/video/H.263-1998/h263-1998.cxx opal-3.10.11/plugins/video/H.263-1998/h263-1998.cxx
924 --- opal-3.10.11.org/plugins/video/H.263-1998/h263-1998.cxx 2018-09-27 12:41:23.304757504 +0200
925 +++ opal-3.10.11/plugins/video/H.263-1998/h263-1998.cxx 2018-09-27 12:59:25.737615925 +0200
928 m_context->opaque = this;
930 - m_context->flags = CODEC_FLAG_TRUNCATED // Possible missing packets
931 + m_context->flags = AV_CODEC_FLAG_TRUNCATED // Possible missing packets
934 m_context->pix_fmt = AV_PIX_FMT_YUV420P;
937 // works with eyeBeam
938 if (atoi(value) == 1)
939 - m_context->flags |= CODEC_FLAG_AC_PRED;
940 + m_context->flags |= AV_CODEC_FLAG_AC_PRED;
942 - m_context->flags &= ~CODEC_FLAG_AC_PRED;
943 + m_context->flags &= ~AV_CODEC_FLAG_AC_PRED;
948 // Annex J: Deblocking Filter
949 // works with eyeBeam
950 if (atoi(value) == 1)
951 - m_context->flags |= CODEC_FLAG_LOOP_FILTER;
952 + m_context->flags |= AV_CODEC_FLAG_LOOP_FILTER;
954 - m_context->flags &= ~CODEC_FLAG_LOOP_FILTER;
955 + m_context->flags &= ~AV_CODEC_FLAG_LOOP_FILTER;
960 #ifdef CODEC_FLAG_H263P_UMV
961 m_context->flags &= ~CODEC_FLAG_H263P_UMV;
963 - m_context->flags &= ~CODEC_FLAG_4MV;
964 + m_context->flags &= ~AV_CODEC_FLAG_4MV;
965 #if LIBAVCODEC_RTP_MODE
966 m_context->flags &= ~CODEC_FLAG_H263P_AIC;
968 diff -ur opal-3.10.11.org/plugins/video/H.263-1998/rfc2429.cxx opal-3.10.11/plugins/video/H.263-1998/rfc2429.cxx
969 --- opal-3.10.11.org/plugins/video/H.263-1998/rfc2429.cxx 2013-08-15 01:22:47.000000000 +0200
970 +++ opal-3.10.11/plugins/video/H.263-1998/rfc2429.cxx 2018-09-27 12:46:38.534350768 +0200
973 unsigned char * RFC2429Frame::GetBuffer()
975 - memset (m_encodedFrame.ptr + m_encodedFrame.pos,0 , FF_INPUT_BUFFER_PADDING_SIZE);
976 + memset (m_encodedFrame.ptr + m_encodedFrame.pos,0 , AV_INPUT_BUFFER_PADDING_SIZE);
977 return (m_encodedFrame.ptr);
980 @@ -340,10 +340,10 @@
982 unsigned remBytes = packet.GetPayloadSize() - headerPLEN - (headerV ? 3 : 2);
984 - if ((m_encodedFrame.pos + (headerP ? 2 : 0) + remBytes) > (m_maxFrameSize - FF_INPUT_BUFFER_PADDING_SIZE)) {
985 + if ((m_encodedFrame.pos + (headerP ? 2 : 0) + remBytes) > (m_maxFrameSize - AV_INPUT_BUFFER_PADDING_SIZE)) {
986 PTRACE(2, "H.263-RFC2429", "Trying to add " << remBytes
987 << " bytes to frame at position " << m_encodedFrame.pos + (headerP ? 2 : 0)
988 - << " bytes while maximum frame size is " << m_maxFrameSize << "-" << FF_INPUT_BUFFER_PADDING_SIZE << " bytes");
989 + << " bytes while maximum frame size is " << m_maxFrameSize << "-" << AV_INPUT_BUFFER_PADDING_SIZE << " bytes");
993 diff -ur opal-3.10.11.org/plugins/video/MPEG4-ffmpeg/mpeg4.cxx opal-3.10.11/plugins/video/MPEG4-ffmpeg/mpeg4.cxx
994 --- opal-3.10.11.org/plugins/video/MPEG4-ffmpeg/mpeg4.cxx 2018-09-27 12:41:23.304757504 +0200
995 +++ opal-3.10.11/plugins/video/MPEG4-ffmpeg/mpeg4.cxx 2018-09-27 12:57:41.014440233 +0200
996 @@ -589,13 +589,13 @@
997 m_avpicture->quality = m_videoQMin;
1000 - m_avcontext->flags |= CODEC_FLAG_4MV; // 4 motion vectors
1001 + m_avcontext->flags |= AV_CODEC_FLAG_4MV; // 4 motion vectors
1003 m_avcontext->max_b_frames=0; /*don't use b frames*/
1004 - m_avcontext->flags|=CODEC_FLAG_AC_PRED;
1005 + m_avcontext->flags|=AV_CODEC_FLAG_AC_PRED;
1006 /*c->flags|=CODEC_FLAG_QPEL;*/ /*don't enable this one: this forces profile_level to advanced simple profile */
1007 - m_avcontext->flags|=CODEC_FLAG_4MV;
1008 - m_avcontext->flags|=CODEC_FLAG_LOOP_FILTER;
1009 + m_avcontext->flags|=AV_CODEC_FLAG_4MV;
1010 + m_avcontext->flags|=AV_CODEC_FLAG_LOOP_FILTER;
1012 m_avcontext->opaque = this; // for use in RTP callback
1017 void MPEG4EncoderContext::SetDynamicEncodingParams(bool restartOnResize) {
1019 // If no bitrate limit is set, max out at 3 mbit
1020 // Use 75% of available bandwidth so not as many frames are dropped
1024 delete[] m_rawFrameBuffer;
1026 - m_rawFrameBuffer = new BYTE[m_rawFrameLen + FF_INPUT_BUFFER_PADDING_SIZE];
1027 + m_rawFrameBuffer = new BYTE[m_rawFrameLen + AV_INPUT_BUFFER_PADDING_SIZE];
1029 if (m_encFrameBuffer)
1032 m_encFrameBuffer = new BYTE[m_encFrameLen];
1034 // Clear the back padding
1035 - memset(m_rawFrameBuffer + m_rawFrameLen, 0, FF_INPUT_BUFFER_PADDING_SIZE);
1036 + memset(m_rawFrameBuffer + m_rawFrameLen, 0, AV_INPUT_BUFFER_PADDING_SIZE);
1037 const unsigned fsz = m_frameWidth * m_frameHeight;
1038 m_avpicture->data[0] = m_rawFrameBuffer; // luminance
1039 m_avpicture->data[1] = m_rawFrameBuffer + fsz; // first chroma channel
1040 @@ -1322,7 +1323,7 @@
1043 void MPEG4DecoderContext::SetStaticDecodingParams() {
1044 - m_avcontext->flags |= CODEC_FLAG_4MV;
1045 + m_avcontext->flags |= AV_CODEC_FLAG_4MV;
1046 m_avcontext->workaround_bugs = 0; // no workaround for buggy implementations