summarylogtreecommitdiffstats
path: root/libquicktime-1.2.4-ffmpeg5.patch
blob: d340f084af41d027c872141fee6f104f36ad0aae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
--- a/plugins/ffmpeg/audio.c
+++ b/plugins/ffmpeg/audio.c
@@ -423,8 +423,8 @@ static int a52_header_read(a52_header *
 typedef struct
   {
   AVCodecContext * avctx;
-  AVCodec * encoder;
-  AVCodec * decoder;
+  AVCodec const * encoder;
+  AVCodec const * decoder;
 
   int initialized;
   
@@ -512,7 +512,6 @@ static int decode_chunk_vbr(quicktime_t
 
 #if DECODE_AUDIO4
   AVFrame f;
-  int got_frame;
 #endif
   
   chunk_packets = lqt_audio_num_vbr_packets(file, track, track_map->cur_chunk, &num_samples);
@@ -548,13 +547,14 @@ static int decode_chunk_vbr(quicktime_t
     codec->pkt.size = packet_size + AV_INPUT_BUFFER_PADDING_SIZE;
 
 #if DECODE_AUDIO4
-    frame_bytes = avcodec_decode_audio4(codec->avctx, &f,
-                                        &got_frame, &codec->pkt);
-    if(frame_bytes < 0)
+    if(avcodec_send_packet(codec->avctx, &codec->pkt) < 0 &&
+       avcodec_receive_frame(codec->avctx, &f) < 0)
       {
       lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "avcodec_decode_audio4 error");
       break;
       }
+    frame_bytes = codec->pkt.size;
+
     bytes_decoded = f.nb_samples * 2 * track_map->channels;
     memcpy(&codec->sample_buffer[track_map->channels *
                                  (codec->sample_buffer_end -
@@ -615,7 +615,6 @@ static int decode_chunk(quicktime_t * fi
 
 #if DECODE_AUDIO4
   AVFrame f;
-  int got_frame;
 #endif
   
   /* Read chunk */
@@ -764,14 +763,14 @@ static int decode_chunk(quicktime_t * fi
     codec->pkt.size = codec->bytes_in_chunk_buffer + AV_INPUT_BUFFER_PADDING_SIZE;
 
 #if DECODE_AUDIO4
-    
-    frame_bytes = avcodec_decode_audio4(codec->avctx, &f,
-                                        &got_frame, &codec->pkt);
-    if(frame_bytes < 0)
+    if(avcodec_send_packet(codec->avctx, &codec->pkt) < 0 ||
+       avcodec_receive_frame(codec->avctx, &f) < 0)
       {
       lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "avcodec_decode_audio4 error");
       break;
       }
+    frame_bytes = codec->pkt.size;
+
     bytes_decoded = f.nb_samples * 2 * track_map->channels;
     memcpy(&codec->sample_buffer[track_map->channels *
                                  (codec->sample_buffer_end -
@@ -1198,7 +1197,6 @@ static int lqt_ffmpeg_encode_audio(quick
 #if ENCODE_AUDIO2
   AVFrame f;
   AVPacket pkt;
-  int got_packet;
 #endif
   
   if(!codec->initialized)
@@ -1274,15 +1272,11 @@ static int lqt_ffmpeg_encode_audio(quick
                              codec->avctx->frame_size * channels * 2, 
                              1);
 
-    if(avcodec_encode_audio2(codec->avctx, &pkt,
-                             &f, &got_packet) < 0)
+    if(avcodec_send_frame(codec->avctx, &f) < 0 ||
+       avcodec_receive_packet(codec->avctx, &pkt) < 0)
       return 0;
 
-    if(got_packet && pkt.size)
-      frame_bytes = pkt.size;
-    else
-      frame_bytes = 0;
-
+    frame_bytes = pkt.size;
 #else
     frame_bytes = avcodec_encode_audio(codec->avctx, codec->chunk_buffer,
                                        codec->chunk_buffer_alloc,
@@ -1474,8 +1468,9 @@ static int read_packet_ac3(quicktime_t *
   }
 
 void quicktime_init_audio_codec_ffmpeg(quicktime_codec_t * codec_base,
-                                       quicktime_audio_map_t *atrack, AVCodec *encoder,
-                                       AVCodec *decoder)
+                                       quicktime_audio_map_t *atrack,
+                                       const AVCodec *encoder,
+                                       const AVCodec *decoder)
   {
   quicktime_ffmpeg_audio_codec_t *codec;
   
--- a/plugins/ffmpeg/ffmpeg.h
+++ b/plugins/ffmpeg/ffmpeg.h
@@ -30,10 +30,12 @@
 
 void quicktime_init_video_codec_ffmpeg(quicktime_codec_t * codec,
                                        quicktime_video_map_t *vtrack,
-                                       AVCodec *encoder, AVCodec *decoder);
+                                       const AVCodec *encoder,
+                                       const AVCodec *decoder);
 void quicktime_init_audio_codec_ffmpeg(quicktime_codec_t * codec,
                                        quicktime_audio_map_t *vtrack,
-                                       AVCodec *encoder, AVCodec *decoder);
+                                       const AVCodec *encoder,
+                                       const AVCodec *decoder);
 
 void lqt_ffmpeg_set_parameter(AVCodecContext * ctx,
 #if LIBAVCODEC_VERSION_MAJOR >= 54
--- a/plugins/ffmpeg/lqt_ffmpeg.c
+++ b/plugins/ffmpeg/lqt_ffmpeg.c
@@ -315,8 +315,8 @@ struct CODECIDMAP
   {
   int id;
   int index;
-  AVCodec *encoder;
-  AVCodec *decoder;
+  AVCodec const *encoder;
+  AVCodec const *decoder;
   lqt_parameter_info_static_t * encode_parameters;
   lqt_parameter_info_static_t * decode_parameters;
   lqt_image_size_static_t     * image_sizes;
@@ -947,7 +947,9 @@ static void ffmpeg_map_init(void)
     return;
     }
     
+#if LIBAVCODEC_VERSION_MAJOR < 59
   avcodec_register_all();
+#endif
   //  avcodec_init();
   ffmpeg_num_video_codecs = 0;
   ffmpeg_num_audio_codecs = 0;
--- a/plugins/ffmpeg/params.c
+++ b/plugins/ffmpeg/params.c
@@ -124,12 +124,14 @@ typedef struct
   }
 
 
+#if LIBAVCODEC_VERSION_MAJOR < 59
 enum_t prediction_method[] =
   {
     { "Left",   FF_PRED_LEFT },
     { "Plane",  FF_PRED_PLANE },
     { "Median", FF_PRED_MEDIAN }
   };
+#endif
 
 enum_t compare_func[] =
   {
@@ -193,7 +195,9 @@ void lqt_ffmpeg_set_parameter(AVCodecCon
   PARAM_INT("ff_max_qdiff",max_qdiff);
   PARAM_INT("ff_max_b_frames",max_b_frames);
   PARAM_FLOAT("ff_b_quant_factor",b_quant_factor);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_b_frame_strategy",b_frame_strategy);
+#endif
 
 #if LIBAVCODEC_VERSION_MAJOR >= 55
   PARAM_DICT_INT("ff_luma_elim_threshold","luma_elim_threshold");
@@ -216,7 +220,9 @@ void lqt_ffmpeg_set_parameter(AVCodecCon
   PARAM_FLOAT("ff_spatial_cplx_masking",spatial_cplx_masking);
   PARAM_FLOAT("ff_p_masking",p_masking);
   PARAM_FLOAT("ff_dark_masking",dark_masking);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_ENUM("ff_prediction_method",prediction_method,prediction_method);
+#endif
   PARAM_ENUM("ff_me_cmp",me_cmp,compare_func);
   PARAM_CMP_CHROMA("ff_me_cmp_chroma",me_cmp);
   PARAM_ENUM("ff_me_sub_cmp",me_sub_cmp,compare_func);
@@ -227,17 +233,23 @@ void lqt_ffmpeg_set_parameter(AVCodecCon
   PARAM_CMP_CHROMA("ff_ildct_cmp_chroma",ildct_cmp);
   PARAM_INT("ff_dia_size",dia_size);
   PARAM_INT("ff_last_predictor_count",last_predictor_count);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_pre_me",pre_me);
+#endif
   PARAM_ENUM("ff_me_pre_cmp",me_pre_cmp,compare_func);
   PARAM_CMP_CHROMA("ff_pre_me_cmp_chroma",me_pre_cmp);
   PARAM_INT("ff_pre_dia_size",pre_dia_size);
   PARAM_INT("ff_me_subpel_quality",me_subpel_quality);
   PARAM_INT("ff_me_range",me_range);
   PARAM_ENUM("ff_mb_decision",mb_decision,mb_decision);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_scenechange_threshold",scenechange_threshold);
+#endif
   PARAM_DICT_INT("ff_lmin", "lmin");
   PARAM_DICT_INT("ff_lmax", "lmax");
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_noise_reduction",noise_reduction);
+#endif
   PARAM_INT_SCALE("ff_rc_initial_buffer_occupancy",rc_initial_buffer_occupancy,1000);
 
 #if LIBAVCODEC_VERSION_MAJOR >= 55
@@ -253,9 +265,13 @@ void lqt_ffmpeg_set_parameter(AVCodecCon
   PARAM_DICT_INT("ff_border_masking","border_mask");
   PARAM_QP2LAMBDA("ff_mb_lmin", mb_lmin);
   PARAM_QP2LAMBDA("ff_mb_lmax", mb_lmax);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_me_penalty_compensation",me_penalty_compensation);
+#endif
   PARAM_INT("ff_bidir_refine",bidir_refine);
+#if LIBAVCODEC_VERSION_MAJOR < 59
   PARAM_INT("ff_brd_scale",brd_scale);
+#endif
   PARAM_FLAG("ff_flag_qscale",AV_CODEC_FLAG_QSCALE);
   PARAM_FLAG("ff_flag_4mv",AV_CODEC_FLAG_4MV);
   PARAM_FLAG("ff_flag_qpel",AV_CODEC_FLAG_QPEL);
--- a/plugins/ffmpeg/video.c
+++ b/plugins/ffmpeg/video.c
@@ -61,8 +61,8 @@ enum AvidYuvRange
 typedef struct
   {
   AVCodecContext * avctx;
-  AVCodec * encoder;
-  AVCodec * decoder;
+  AVCodec const * encoder;
+  AVCodec const * decoder;
   int initialized;
 
   int decoding_delay;
@@ -878,10 +878,12 @@ static int lqt_ffmpeg_decode_video(quick
         }
 #endif
       
-      if(avcodec_decode_video2(codec->avctx,
-                               codec->frame,
-                               &got_pic,
-                               &codec->pkt) < 0)
+      if(avcodec_send_packet(codec->avctx, &codec->pkt) == 0 &&
+         avcodec_receive_frame(codec->avctx, codec->frame) == 0)
+        {
+        got_pic = 1;
+        }
+      else
         {
         lqt_log(file, LQT_LOG_ERROR, LOG_DOMAIN, "Skipping corrupted frame");
         continue;
@@ -1062,10 +1064,8 @@ static void resync_ffmpeg(quicktime_t *f
 #if LIBAVCODEC_BUILD >= ((52<<16)+(26<<8)+0)
         codec->pkt.data = codec->buffer;
         codec->pkt.size = buffer_size;
-        avcodec_decode_video2(codec->avctx,
-                              codec->frame,
-                              &got_pic,
-                              &codec->pkt);
+        got_pic = (avcodec_send_packet(codec->avctx, &codec->pkt) == 0 &&
+                   avcodec_receive_frame(codec->avctx, codec->frame) == 0);
 #else
         avcodec_decode_video(codec->avctx,
                              codec->frame,
@@ -1139,7 +1139,9 @@ static int init_imx_encoder(quicktime_t
   codec->avctx->intra_dc_precision = 2;
   codec->avctx->qmin = 1;
   codec->avctx->qmax = 3;
+#if (LIBAVCODEC_VERSION_MAJOR < 59)
   codec->avctx->rtp_payload_size = 1; // ??
+#endif
   av_dict_set(&codec->options, "rc_buf_aggressivity", "0.25", 0);
   codec->avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT|AV_CODEC_FLAG_LOW_DELAY;
 
@@ -1290,7 +1292,6 @@ static int lqt_ffmpeg_encode_video(quick
   int stats_len;
 #if ENCODE_VIDEO2
   AVPacket pkt;
-  int got_packet;
 #endif
   int64_t pts;
   int kf;
@@ -1530,16 +1531,12 @@ static int lqt_ffmpeg_encode_video(quick
 #if ENCODE_VIDEO2 // New
   av_init_packet(&pkt);
   pkt.data = codec->buffer;
-  pkt.size = codec->buffer_alloc;
+  pkt.size = bytes_encoded = codec->buffer_alloc;
 
-  if(avcodec_encode_video2(codec->avctx, &pkt, codec->frame, &got_packet) < 0)
+  if(avcodec_send_frame(codec->avctx, codec->frame) < 0 ||
+     avcodec_receive_packet(codec->avctx, &pkt) < 0)
     return -1;
 
-  if(got_packet)
-    bytes_encoded = pkt.size;
-  else
-    bytes_encoded = 0;
-  
   pts = pkt.pts;
   kf = !!(pkt.flags & AV_PKT_FLAG_KEY);
     
@@ -1621,7 +1618,6 @@ static int flush(quicktime_t *file, int
   
 #if ENCODE_VIDEO2
   AVPacket pkt;
-  int got_packet;
 #endif
   
   /* Do nothing if we didn't encode anything yet */
@@ -1631,18 +1627,13 @@ static int flush(quicktime_t *file, int
 #if ENCODE_VIDEO2
   av_init_packet(&pkt);
   pkt.data = codec->buffer;
-  pkt.size = codec->buffer_alloc;
+  pkt.size = bytes_encoded = codec->buffer_alloc;
   
-  if(avcodec_encode_video2(codec->avctx, &pkt, (AVFrame*)0, &got_packet) < 0)
+  if(avcodec_send_frame(codec->avctx, NULL) < 0 ||
+     avcodec_receive_packet(codec->avctx, &pkt) < 0)
     return -1;
 
-  if(got_packet)
-    bytes_encoded = pkt.size;
-  else
-    return 0;
-  
   pts = pkt.pts;
-
   kf = !!(pkt.flags & AV_PKT_FLAG_KEY);
   
 #else
@@ -1872,8 +1863,8 @@ static int init_compressed_dv(quicktime_
 
 void quicktime_init_video_codec_ffmpeg(quicktime_codec_t * codec_base,
                                        quicktime_video_map_t *vtrack,
-                                       AVCodec *encoder,
-                                       AVCodec *decoder)
+                                       const AVCodec *encoder,
+                                       const AVCodec *decoder)
   {
   quicktime_ffmpeg_video_codec_t *codec;
   char *compressor;