[FFmpeg-devel] [PATCH] libavcodec interface to no_mbtree option of libx264
Erik Slagter
erik
Sun Dec 6 15:33:21 CET 2009
On zo, 2009-12-06 at 13:23 +0000, Loren Merritt wrote:
> On Sun, 6 Dec 2009, Erik Slagter wrote:
>
> > +#define CODEC_FLAG2_NO_MBTREE 0x00040000 ///< Do not use macroblock tree ratecontrol (x264 only)
>
> I don't think flags shouldn't never be negative.
Point taken. I do not assume that this approach will not make you happier?
Index: libavcodec/options.c
===================================================================
--- libavcodec/options.c (revision 20746)
+++ libavcodec/options.c (working copy)
@@ -391,6 +391,7 @@
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
+{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MBTREE, INT_MIN, INT_MAX, V|E, "flags2"},
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|E|D, "channel_layout"},
{"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (revision 20746)
+++ libavcodec/avcodec.h (working copy)
@@ -580,6 +580,7 @@
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
+#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
Index: libavcodec/libx264.c
===================================================================
--- libavcodec/libx264.c (revision 20746)
+++ libavcodec/libx264.c (working copy)
@@ -227,7 +227,7 @@
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
- x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
+ x4->params.analyse.b_weighted_bipred = !!(avctx->flags2 & CODEC_FLAG2_WPRED);
x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
if (avctx->me_method == ME_EPZS)
@@ -266,6 +266,7 @@
} else
x4->params.rc.f_vbv_buffer_init = 0.9;
+ x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
Index: ffpresets/libx264-lossless_slow.ffpreset
===================================================================
--- ffpresets/libx264-lossless_slow.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_slow.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=2
directpred=1
-flags2=+dct8x8+fastpskip
+flags2=+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-lossless_max.ffpreset
===================================================================
--- ffpresets/libx264-lossless_max.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_max.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=16
directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip
+flags2=+mixed_refs+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-ipod320.ffpreset
===================================================================
--- ffpresets/libx264-ipod320.ffpreset (revision 20746)
+++ ffpresets/libx264-ipod320.ffpreset (working copy)
@@ -1,6 +1,6 @@
coder=0
bf=0
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
level=13
maxrate=768000
bufsize=3000000
Index: ffpresets/libx264-baseline.ffpreset
===================================================================
--- ffpresets/libx264-baseline.ffpreset (revision 20746)
+++ ffpresets/libx264-baseline.ffpreset (working copy)
@@ -1,4 +1,4 @@
coder=0
bf=0
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
wpredp=0
Index: ffpresets/libx264-slowfirstpass.ffpreset
===================================================================
--- ffpresets/libx264-slowfirstpass.ffpreset (revision 20746)
+++ ffpresets/libx264-slowfirstpass.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=1
directpred=3
trellis=0
-flags2=+wpred+dct8x8+fastpskip
+flags2=+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-default.ffpreset
===================================================================
--- ffpresets/libx264-default.ffpreset (revision 20746)
+++ ffpresets/libx264-default.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=3
directpred=1
trellis=1
-flags2=+mixed_refs+wpred+dct8x8+fastpskip
+flags2=+mixed_refs+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-lossless_fast.ffpreset
===================================================================
--- ffpresets/libx264-lossless_fast.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_fast.ffpreset (working copy)
@@ -15,6 +15,6 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
wpredp=0
Index: ffpresets/libx264-main.ffpreset
===================================================================
--- ffpresets/libx264-main.ffpreset (revision 20746)
+++ ffpresets/libx264-main.ffpreset (working copy)
@@ -1 +1 @@
-flags2=-dct8x8
+flags2=-dct8x8+mbtree
Index: ffpresets/libx264-max.ffpreset
===================================================================
--- ffpresets/libx264-max.ffpreset (revision 20746)
+++ ffpresets/libx264-max.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=16
directpred=3
trellis=2
-flags2=+wpred+mixed_refs+dct8x8-fastpskip
+flags2=+wpred+mixed_refs+dct8x8-fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-ipod640.ffpreset
===================================================================
--- ffpresets/libx264-ipod640.ffpreset (revision 20746)
+++ ffpresets/libx264-ipod640.ffpreset (working copy)
@@ -1,7 +1,7 @@
coder=0
bf=0
refs=1
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
level=30
maxrate=10000000
bufsize=10000000
Index: ffpresets/libx264-normal.ffpreset
===================================================================
--- ffpresets/libx264-normal.ffpreset (revision 20746)
+++ ffpresets/libx264-normal.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=2
directpred=3
trellis=0
-flags2=+wpred+dct8x8+fastpskip
+flags2=+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-fastfirstpass.ffpreset
===================================================================
--- ffpresets/libx264-fastfirstpass.ffpreset (revision 20746)
+++ ffpresets/libx264-fastfirstpass.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=1
directpred=3
trellis=0
-flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip
+flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-lossless_ultrafast.ffpreset
===================================================================
--- ffpresets/libx264-lossless_ultrafast.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_ultrafast.ffpreset (working copy)
@@ -15,5 +15,5 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
Index: ffpresets/libx264-lossless_slower.ffpreset
===================================================================
--- ffpresets/libx264-lossless_slower.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_slower.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=4
directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip
+flags2=+mixed_refs+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-lossless_medium.ffpreset
===================================================================
--- ffpresets/libx264-lossless_medium.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_medium.ffpreset (working copy)
@@ -15,6 +15,6 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-hq.ffpreset
===================================================================
--- ffpresets/libx264-hq.ffpreset (revision 20746)
+++ ffpresets/libx264-hq.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=4
directpred=3
trellis=1
-flags2=+wpred+mixed_refs+dct8x8+fastpskip
+flags2=+wpred+mixed_refs+dct8x8+fastpskip+mbtree
wpredp=2
-------------- next part --------------
Index: libavcodec/options.c
===================================================================
--- libavcodec/options.c (revision 20746)
+++ libavcodec/options.c (working copy)
@@ -391,6 +391,7 @@
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
+{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MBTREE, INT_MIN, INT_MAX, V|E, "flags2"},
{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|E|D, "channel_layout"},
{"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
Index: libavcodec/avcodec.h
===================================================================
--- libavcodec/avcodec.h (revision 20746)
+++ libavcodec/avcodec.h (working copy)
@@ -580,6 +580,7 @@
#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer.
#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible
+#define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only)
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
Index: libavcodec/libx264.c
===================================================================
--- libavcodec/libx264.c (revision 20746)
+++ libavcodec/libx264.c (working copy)
@@ -227,7 +227,7 @@
x4->params.analyse.i_direct_mv_pred = avctx->directpred;
- x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
+ x4->params.analyse.b_weighted_bipred = !!(avctx->flags2 & CODEC_FLAG2_WPRED);
x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
if (avctx->me_method == ME_EPZS)
@@ -266,6 +266,7 @@
} else
x4->params.rc.f_vbv_buffer_init = 0.9;
+ x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
x4->params.rc.f_ip_factor = 1 / fabs(avctx->i_quant_factor);
x4->params.rc.f_pb_factor = avctx->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
Index: ffpresets/libx264-lossless_slow.ffpreset
===================================================================
--- ffpresets/libx264-lossless_slow.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_slow.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=2
directpred=1
-flags2=+dct8x8+fastpskip
+flags2=+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-lossless_max.ffpreset
===================================================================
--- ffpresets/libx264-lossless_max.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_max.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=16
directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip
+flags2=+mixed_refs+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-ipod320.ffpreset
===================================================================
--- ffpresets/libx264-ipod320.ffpreset (revision 20746)
+++ ffpresets/libx264-ipod320.ffpreset (working copy)
@@ -1,6 +1,6 @@
coder=0
bf=0
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
level=13
maxrate=768000
bufsize=3000000
Index: ffpresets/libx264-baseline.ffpreset
===================================================================
--- ffpresets/libx264-baseline.ffpreset (revision 20746)
+++ ffpresets/libx264-baseline.ffpreset (working copy)
@@ -1,4 +1,4 @@
coder=0
bf=0
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
wpredp=0
Index: ffpresets/libx264-slowfirstpass.ffpreset
===================================================================
--- ffpresets/libx264-slowfirstpass.ffpreset (revision 20746)
+++ ffpresets/libx264-slowfirstpass.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=1
directpred=3
trellis=0
-flags2=+wpred+dct8x8+fastpskip
+flags2=+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-default.ffpreset
===================================================================
--- ffpresets/libx264-default.ffpreset (revision 20746)
+++ ffpresets/libx264-default.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=3
directpred=1
trellis=1
-flags2=+mixed_refs+wpred+dct8x8+fastpskip
+flags2=+mixed_refs+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-lossless_fast.ffpreset
===================================================================
--- ffpresets/libx264-lossless_fast.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_fast.ffpreset (working copy)
@@ -15,6 +15,6 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
wpredp=0
Index: ffpresets/libx264-main.ffpreset
===================================================================
--- ffpresets/libx264-main.ffpreset (revision 20746)
+++ ffpresets/libx264-main.ffpreset (working copy)
@@ -1 +1 @@
-flags2=-dct8x8
+flags2=-dct8x8+mbtree
Index: ffpresets/libx264-max.ffpreset
===================================================================
--- ffpresets/libx264-max.ffpreset (revision 20746)
+++ ffpresets/libx264-max.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=16
directpred=3
trellis=2
-flags2=+wpred+mixed_refs+dct8x8-fastpskip
+flags2=+wpred+mixed_refs+dct8x8-fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-ipod640.ffpreset
===================================================================
--- ffpresets/libx264-ipod640.ffpreset (revision 20746)
+++ ffpresets/libx264-ipod640.ffpreset (working copy)
@@ -1,7 +1,7 @@
coder=0
bf=0
refs=1
-flags2=-wpred-dct8x8
+flags2=-wpred-dct8x8+mbtree
level=30
maxrate=10000000
bufsize=10000000
Index: ffpresets/libx264-normal.ffpreset
===================================================================
--- ffpresets/libx264-normal.ffpreset (revision 20746)
+++ ffpresets/libx264-normal.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=2
directpred=3
trellis=0
-flags2=+wpred+dct8x8+fastpskip
+flags2=+wpred+dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-fastfirstpass.ffpreset
===================================================================
--- ffpresets/libx264-fastfirstpass.ffpreset (revision 20746)
+++ ffpresets/libx264-fastfirstpass.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=1
directpred=3
trellis=0
-flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip
+flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip+mbtree
wpredp=2
Index: ffpresets/libx264-lossless_ultrafast.ffpreset
===================================================================
--- ffpresets/libx264-lossless_ultrafast.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_ultrafast.ffpreset (working copy)
@@ -15,5 +15,5 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
Index: ffpresets/libx264-lossless_slower.ffpreset
===================================================================
--- ffpresets/libx264-lossless_slower.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_slower.ffpreset (working copy)
@@ -16,6 +16,6 @@
qdiff=4
refs=4
directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip
+flags2=+mixed_refs+dct8x8+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-lossless_medium.ffpreset
===================================================================
--- ffpresets/libx264-lossless_medium.ffpreset (revision 20746)
+++ ffpresets/libx264-lossless_medium.ffpreset (working copy)
@@ -15,6 +15,6 @@
qmax=51
qdiff=4
directpred=1
-flags2=+fastpskip
+flags2=+fastpskip+mbtree
cqp=0
wpredp=2
Index: ffpresets/libx264-hq.ffpreset
===================================================================
--- ffpresets/libx264-hq.ffpreset (revision 20746)
+++ ffpresets/libx264-hq.ffpreset (working copy)
@@ -18,5 +18,5 @@
refs=4
directpred=3
trellis=1
-flags2=+wpred+mixed_refs+dct8x8+fastpskip
+flags2=+wpred+mixed_refs+dct8x8+fastpskip+mbtree
wpredp=2
More information about the ffmpeg-devel
mailing list