Browse code

libx264: add 'direct-pred' private option

Deprecate AVCodecContext.directpred

Anton Khirnov authored on 2011/09/01 20:15:09
Showing 6 changed files
... ...
@@ -2484,14 +2484,14 @@ typedef struct AVCodecContext {
2484 2484
 #define X264_PART_P8X8 0x010  /* Analyze p16x8, p8x16 and p8x8 */
2485 2485
 #define X264_PART_P4X4 0x020  /* Analyze p8x4, p4x8, p4x4 */
2486 2486
 #define X264_PART_B8X8 0x100  /* Analyze b16x8, b8x16 and b8x8 */
2487
-#endif
2488 2487
 
2489 2488
     /**
2490 2489
      * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)
2491 2490
      * - encoding: Set by user.
2492 2491
      * - decoding: unused
2493 2492
      */
2494
-    int directpred;
2493
+    attribute_deprecated int directpred;
2494
+#endif
2495 2495
 
2496 2496
     /**
2497 2497
      * Audio cutoff bandwidth (0 means "automatic")
... ...
@@ -63,6 +63,7 @@ typedef struct X264Context {
63 63
     char *deblock;
64 64
     float cplxblur;
65 65
     char *partitions;
66
+    int direct_pred;
66 67
 } X264Context;
67 68
 
68 69
 static void X264_log(void *p, int level, const char *fmt, va_list args)
... ...
@@ -208,8 +209,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
208 208
 
209 209
     x4->params.b_deblocking_filter         = avctx->flags & CODEC_FLAG_LOOP_FILTER;
210 210
 
211
-    x4->params.analyse.i_direct_mv_pred  = avctx->directpred;
212
-
213 211
     if (avctx->me_method == ME_EPZS)
214 212
         x4->params.analyse.i_me_method = X264_ME_DIA;
215 213
     else if (avctx->me_method == ME_HEX)
... ...
@@ -307,6 +306,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
307 307
         x4->params.i_deblocking_filter_beta    = avctx->deblockbeta;
308 308
     if (avctx->complexityblur >= 0)
309 309
         x4->params.rc.f_complexity_blur        = avctx->complexityblur;
310
+    if (avctx->directpred >= 0)
311
+        x4->params.analyse.i_direct_mv_pred    = avctx->directpred;
310 312
     if (avctx->partitions) {
311 313
         if (avctx->partitions & X264_PART_I4X4)
312 314
             x4->params.analyse.inter |= X264_ANALYSE_I4x4;
... ...
@@ -386,6 +387,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
386 386
         x4->params.b_aud                      = x4->aud;
387 387
     if (x4->mbtree >= 0)
388 388
         x4->params.rc.b_mb_tree               = x4->mbtree;
389
+    if (x4->direct_pred >= 0)
390
+        x4->params.analyse.i_direct_mv_pred   = x4->direct_pred;
389 391
 
390 392
     if (x4->fastfirstpass)
391 393
         x264_param_apply_fastfirstpass(&x4->params);
... ...
@@ -488,6 +491,11 @@ static const AVOption options[] = {
488 488
     { "cplxblur",      "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT,  {-1 }, -1, FLT_MAX, VE},
489 489
     { "partitions",    "A comma-separated list of partitions to consider. "
490 490
                        "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE},
491
+    { "direct-pred",   "Direct MV prediction mode",                       OFFSET(direct_pred),   FF_OPT_TYPE_INT,    {-1 }, -1, INT_MAX, VE, "direct-pred" },
492
+    { "none",          NULL,      0,    FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_NONE },     0, 0, VE, "direct-pred" },
493
+    { "spatial",       NULL,      0,    FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_SPATIAL },  0, 0, VE, "direct-pred" },
494
+    { "temporal",      NULL,      0,    FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" },
495
+    { "auto",          NULL,      0,    FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_AUTO },     0, 0, VE, "direct-pred" },
491 496
     { NULL },
492 497
 };
493 498
 
... ...
@@ -402,8 +402,8 @@ static const AVOption options[]={
402 402
 {"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E},
403 403
 #endif
404 404
 {"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
405
-{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = 2 }, INT_MIN, INT_MAX, V|E},
406 405
 #if FF_API_X264_GLOBAL_OPTS
406
+{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E},
407 407
 {"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"},
408 408
 {"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"},
409 409
 {"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"},
... ...
@@ -353,7 +353,6 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
353 353
             codec->qblur = av_int2dbl(avio_rb64(pb));
354 354
             codec->max_qdiff = avio_rb32(pb);
355 355
             codec->refs = avio_rb32(pb);
356
-            codec->directpred = avio_rb32(pb);
357 356
             break;
358 357
         case AVMEDIA_TYPE_AUDIO:
359 358
             codec->sample_rate = avio_rb32(pb);
... ...
@@ -165,7 +165,6 @@ static int ffm_write_header(AVFormatContext *s)
165 165
             avio_wb64(pb, av_dbl2int(codec->qblur));
166 166
             avio_wb32(pb, codec->max_qdiff);
167 167
             avio_wb32(pb, codec->refs);
168
-            avio_wb32(pb, codec->directpred);
169 168
             break;
170 169
         case AVMEDIA_TYPE_AUDIO:
171 170
             avio_wb32(pb, codec->sample_rate);
... ...
@@ -1,3 +1,3 @@
1
-6d6db9474c5c10621bff51f20984797b *./tests/data/lavf/lavf.ffm
1
+bf46c0b53fc318d0a60fa9bf446b2e4f *./tests/data/lavf/lavf.ffm
2 2
 376832 ./tests/data/lavf/lavf.ffm
3 3
 ./tests/data/lavf/lavf.ffm CRC=0xf361ed74