View | Details | Raw Unified | Return to bug 209346
Collapse All | Expand All

(-)net/opal/files/patch-ffmpeg3 (+247 lines)
Line 0 Link Here
1
Description: Replace deprecated FFmpeg API
2
Author: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
3
Last-Update: <2015-11-02>
4
5
--- plugins/video/H.263-1998/h263-1998.cxx.orig
6
+++ plugins/video/H.263-1998/h263-1998.cxx
7
@@ -230,11 +230,10 @@ bool H263_Base_EncoderContext::Init(AVCo
8
 
9
   m_context->opaque = this;
10
 
11
-  m_context->flags = CODEC_FLAG_EMU_EDGE   // don't draw edges
12
-                   | CODEC_FLAG_TRUNCATED  // Possible missing packets
13
+  m_context->flags = CODEC_FLAG_TRUNCATED  // Possible missing packets
14
                    ;
15
 
16
-  m_context->pix_fmt = PIX_FMT_YUV420P;
17
+  m_context->pix_fmt = AV_PIX_FMT_YUV420P;
18
   m_context->gop_size = H263_KEY_FRAME_INTERVAL;
19
 
20
   // X-Lite does not like Custom Picture frequency clocks... stick to 29.97Hz
21
@@ -440,9 +439,6 @@ bool H263_Base_EncoderContext::OpenCodec
22
   m_inputFrame->data[1] = m_inputFrame->data[0] + planeSize;
23
   m_inputFrame->data[2] = m_inputFrame->data[1] + (planeSize / 4);
24
 
25
-  if (m_context->width > 352)
26
-    m_context->flags &= ~CODEC_FLAG_EMU_EDGE; // Totally bizarre! FFMPEG crashes if on for CIF4
27
-
28
   // Dump info
29
   PTRACE(5, m_prefix, "Size is " << m_context->width << "x" << m_context->height);
30
   PTRACE(5, m_prefix, "GOP is " << m_context->gop_size);
31
@@ -456,7 +452,7 @@ bool H263_Base_EncoderContext::OpenCodec
32
   PTRACE(5, m_prefix, "qmax set to " << m_context->qmax);
33
   PTRACE(5, m_prefix, "payload size set to " << m_context->rtp_payload_size);
34
 
35
-  return FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) == 0;
36
+  return FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) == 0;
37
 }
38
 
39
 void H263_Base_EncoderContext::CloseCodec()
40
@@ -707,7 +703,7 @@ bool H263_Base_DecoderContext::OpenCodec
41
     return 0;
42
   }
43
 
44
-  if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) < 0) {
45
+  if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) < 0) {
46
     PTRACE(1, m_prefix, "Failed to open H.263 decoder");
47
     return false;
48
   }
49
--- plugins/video/H.264/h264-x264.cxx.orig
50
+++ plugins/video/H.264/h264-x264.cxx
51
@@ -1074,7 +1074,6 @@ class MyDecoder : public PluginCodec<MY_
52
       m_context->workaround_bugs = FF_BUG_AUTODETECT;
53
       m_context->idct_algo = FF_IDCT_H264;
54
       m_context->error_concealment = FF_EC_GUESS_MVS | FF_EC_DEBLOCK;
55
-      m_context->flags = CODEC_FLAG_INPUT_PRESERVED | CODEC_FLAG_EMU_EDGE;
56
       m_context->flags2 = CODEC_FLAG2_DROP_FRAME_TIMECODE |
57
                           CODEC_FLAG2_SKIP_RD |
58
                           CODEC_FLAG2_CHUNKS;
59
@@ -1084,7 +1083,7 @@ class MyDecoder : public PluginCodec<MY_
60
       if ((m_picture = FFMPEGLibraryInstance.AvcodecAllocFrame()) == NULL)
61
         return false;
62
 
63
-      if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec) < 0)
64
+      if (FFMPEGLibraryInstance.AvcodecOpen(m_context, m_codec, NULL) < 0)
65
         return false;
66
 
67
       PTRACE(4, MY_CODEC_LOG, "Opened decoder (SVN $Revision: 28048 $)");
68
--- plugins/video/MPEG4-ffmpeg/mpeg4.cxx.orig
69
+++ plugins/video/MPEG4-ffmpeg/mpeg4.cxx
70
@@ -539,7 +539,7 @@ void MPEG4EncoderContext::ResetBitCounte
71
 //
72
 
73
 void MPEG4EncoderContext::SetStaticEncodingParams(){
74
-    m_avcontext->pix_fmt = PIX_FMT_YUV420P;
75
+    m_avcontext->pix_fmt = AV_PIX_FMT_YUV420P;
76
     m_avcontext->mb_decision = FF_MB_DECISION_SIMPLE;    // high quality off
77
     m_avcontext->rtp_payload_size = 750;                 // ffh263 uses 750
78
     m_avcontext->rtp_callback = &MPEG4EncoderContext::RtpCallback;
79
@@ -595,7 +595,6 @@ void MPEG4EncoderContext::SetStaticEncod
80
     m_avcontext->flags|=CODEC_FLAG_AC_PRED;
81
     /*c->flags|=CODEC_FLAG_QPEL;*/ /*don't enable this one: this forces profile_level to advanced simple profile */
82
     m_avcontext->flags|=CODEC_FLAG_4MV;
83
-    m_avcontext->flags|=CODEC_FLAG_GMC;
84
     m_avcontext->flags|=CODEC_FLAG_LOOP_FILTER;
85
 #endif
86
     m_avcontext->opaque = this;              // for use in RTP callback
87
@@ -710,13 +709,15 @@ bool MPEG4EncoderContext::OpenCodec()
88
   if (PTRACE_CHECK(4)) {
89
     m_avcontext->debug |= FF_DEBUG_RC;
90
     m_avcontext->debug |= FF_DEBUG_PICT_INFO;
91
-    m_avcontext->debug |= FF_DEBUG_MV;
92
+//    m_avcontext->debug |= FF_DEBUG_MV;
93
   }
94
 #endif
95
   
96
   SetStaticEncodingParams();
97
   SetDynamicEncodingParams(false);    // don't force a restart, it's not open
98
-  if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec) < 0)
99
+  AVDictionary *opts = NULL;
100
+  av_dict_set_int(&opts, "gmc", 1, 0);
101
+  if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec, &opts) < 0)
102
   {
103
     PTRACE(1, "MPEG4", "Encoder could not be opened");
104
     return false;
105
@@ -1411,7 +1412,7 @@ bool MPEG4DecoderContext::OpenCodec()
106
 
107
     SetStaticDecodingParams();
108
     SetDynamicDecodingParams(false);    // don't force a restart, it's not open
109
-    if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec) < 0) {
110
+    if (FFMPEGLibraryInstance.AvcodecOpen(m_avcontext, m_avcodec, NULL) < 0) {
111
         PTRACE(1, "MPEG4", "Decoder failed to open");
112
         return false;
113
     }
114
--- plugins/video/common/dyna.h.orig
115
+++ plugins/video/common/dyna.h
116
@@ -97,7 +97,7 @@ class FFMPEGLibrary
117
     AVCodec *AvcodecFindDecoder(enum AVCodecID id);
118
     AVCodecContext *AvcodecAllocContext(AVCodec*);
119
     AVFrame *AvcodecAllocFrame(void);
120
-    int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec);
121
+    int AvcodecOpen(AVCodecContext *ctx, AVCodec *codec, AVDictionary **options);
122
     int AvcodecClose(AVCodecContext *ctx);
123
     int AvcodecEncodeVideo(AVCodecContext *ctx, BYTE *buf, int buf_size, const AVFrame *pict);
124
     int AvcodecDecodeVideo(AVCodecContext *ctx, AVFrame *pict, int *got_picture_ptr, BYTE *buf, int buf_size);
125
--- plugins/video/common/ffmpeg.h.orig
126
+++ plugins/video/common/ffmpeg.h
127
@@ -47,6 +47,7 @@
128
 
129
 extern "C" {
130
 #include "libavcodec/avcodec.h"
131
+#include "libavutil/imgutils.h"
132
 // AVPacket was declared in avformat.h before April 2009
133
 #if LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52, 25, 0)
134
 #include <libavformat/avformat.h>
135
--- plugins/video/H.263-1998/h263-1998.cxx.orig
136
+++ plugins/video/H.263-1998/h263-1998.cxx
137
@@ -98,7 +98,7 @@
138
   { CIF16_WIDTH, CIF16_HEIGHT, PLUGINCODEC_CIF16_MPI },
139
 };
140
 
141
-static FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H263P);
142
+static FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H263P);
143
 
144
 
145
 /////////////////////////////////////////////////////////////////////////////
146
@@ -583,7 +583,7 @@
147
 
148
 bool H263_RFC2190_EncoderContext::Init()
149
 {
150
-  if (!H263_Base_EncoderContext::Init(CODEC_ID_H263))
151
+  if (!H263_Base_EncoderContext::Init(AV_CODEC_ID_H263))
152
     return false;
153
 
154
 #if LIBAVCODEC_RTP_MODE
155
@@ -620,7 +620,7 @@
156
 
157
 bool H263_RFC2429_EncoderContext::Init()
158
 {
159
-  return H263_Base_EncoderContext::Init(CODEC_ID_H263P);
160
+  return H263_Base_EncoderContext::Init(AV_CODEC_ID_H263P);
161
 }
162
 
163
 
164
@@ -644,7 +644,7 @@
165
   if (!FFMPEGLibraryInstance.Load())
166
     return;
167
 
168
-  if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H263)) == NULL) {
169
+  if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H263)) == NULL) {
170
     PTRACE(1, m_prefix, "Codec not found for decoder");
171
     return;
172
   }
173
--- plugins/video/common/dyna.cxx.orig
174
+++ plugins/video/common/dyna.cxx
175
@@ -213,11 +213,11 @@
176
 FFMPEGLibrary::FFMPEGLibrary(AVCodecID codec)
177
 {
178
   m_codec = codec;
179
-  if (m_codec==CODEC_ID_H264)
180
+  if (m_codec==AV_CODEC_ID_H264)
181
       snprintf( m_codecString, sizeof(m_codecString), "H264");
182
-  if (m_codec==CODEC_ID_H263P)
183
+  if (m_codec==AV_CODEC_ID_H263P)
184
       snprintf( m_codecString, sizeof(m_codecString), "H263+");
185
-  if (m_codec==CODEC_ID_MPEG4)
186
+  if (m_codec==AV_CODEC_ID_MPEG4)
187
       snprintf( m_codecString, sizeof(m_codecString), "MPEG4");
188
   m_isLoadedOK = false;
189
 }
190
@@ -374,7 +374,7 @@
191
   return Favcodec_alloc_frame();
192
 }
193
 
194
-int FFMPEGLibrary::AvcodecOpen(AVCodecContext *ctx, AVCodec *codec)
195
+int FFMPEGLibrary::AvcodecOpen(AVCodecContext *ctx, AVCodec *codec, AVDictionary **options)
196
 {
197
   WaitAndSignal m(processLock);
198
 
199
--- plugins/video/MPEG4-ffmpeg/mpeg4.cxx.orig
200
+++ plugins/video/MPEG4-ffmpeg/mpeg4.cxx
201
@@ -206,7 +206,7 @@
202
     { 0 }
203
 };
204
 
205
-FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_MPEG4);
206
+FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_MPEG4);
207
 
208
 
209
 static bool mpeg4IsIframe (BYTE * frameBuffer, unsigned int frameLen )
210
@@ -703,7 +703,7 @@
211
     return false;
212
   }
213
 
214
-  if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(CODEC_ID_MPEG4)) == NULL){
215
+  if((m_avcodec = FFMPEGLibraryInstance.AvcodecFindEncoder(AV_CODEC_ID_MPEG4)) == NULL){
216
     PTRACE(1, "MPEG4", "Encoder not found");
217
     return false;
218
   }
219
@@ -1396,7 +1396,7 @@
220
 
221
 bool MPEG4DecoderContext::OpenCodec()
222
 {
223
-    if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_MPEG4)) == NULL) {
224
+    if ((m_avcodec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_MPEG4)) == NULL) {
225
         PTRACE(1, "MPEG4", "Decoder not found for encoder");
226
         return false;
227
     }
228
--- plugins/video/H.264/h264-x264.cxx.orig
229
+++ plugins/video/H.264/h264-x264.cxx
230
@@ -107,7 +107,7 @@
231
 
232
 ///////////////////////////////////////////////////////////////////////////////
233
 
234
-FFMPEGLibrary FFMPEGLibraryInstance(CODEC_ID_H264);
235
+FFMPEGLibrary FFMPEGLibraryInstance(AV_CODEC_ID_H264);
236
 
237
 PLUGINCODEC_CONTROL_LOG_FUNCTION_DEF
238
 
239
@@ -1067,7 +1067,7 @@
240
          allows you to fail the create operation (return false), which cannot
241
          be done in the normal C++ constructor. */
242
 
243
-      if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(CODEC_ID_H264)) == NULL)
244
+      if ((m_codec = FFMPEGLibraryInstance.AvcodecFindDecoder(AV_CODEC_ID_H264)) == NULL)
245
         return false;
246
 
247
       if ((m_context = FFMPEGLibraryInstance.AvcodecAllocContext()) == NULL)

Return to bug 209346