[FFmpeg-cvslog] h263/p encoder: add 'obmc' private option.
Anton Khirnov
git at videolan.org
Thu Sep 1 00:03:08 CEST 2011
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sat Aug 27 10:16:14 2011 +0200| [0d904de89ded7502c7a18a12e27c3e6dff5d1fdf] | committer: Anton Khirnov
h263/p encoder: add 'obmc' private option.
Deprecate CODEC_FLAG_OBMC
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0d904de89ded7502c7a18a12e27c3e6dff5d1fdf
---
libavcodec/avcodec.h | 2 +-
libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++++++-------
libavcodec/options.c | 2 ++
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 993ed78..c22c98f 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -606,8 +606,8 @@ typedef struct RcOverride{
#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon.
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC
-#endif
#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC
+#endif
#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter
#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000
#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 447431d..9623bb8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -337,12 +337,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
|| (s->flags&CODEC_FLAG_QP_RD))
&& !s->fixed_qscale;
- s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
#if FF_API_MPEGVIDEO_GLOBAL_OPTS
s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
s->q_scale_type= !!(s->flags2 & CODEC_FLAG2_NON_LINEAR_QUANT);
+ s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
#endif
if(avctx->rc_max_rate && !avctx->rc_buffer_size){
@@ -396,10 +396,12 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
return -1;
}
+#endif
if(s->quarter_sample && s->codec_id != CODEC_ID_MPEG4){
av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n");
@@ -598,7 +600,6 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
return -1;
}
s->out_format = FMT_H263;
- s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
avctx->delay=0;
s->low_delay=1;
break;
@@ -614,7 +615,6 @@ av_cold int MPV_encode_init(AVCodecContext *avctx)
#endif
s->h263_aic= (avctx->flags & CODEC_FLAG_AC_PRED) ? 1:0;
s->modified_quant= s->h263_aic;
- s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
@@ -3783,6 +3783,20 @@ int dct_quantize_c(MpegEncContext *s,
return last_non_zero;
}
+#define OFFSET(x) offsetof(MpegEncContext, x)
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
+static const AVOption h263_options[] = {
+ { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
+ { NULL },
+};
+
+static const AVClass h263_class = {
+ .class_name = "H.263 encoder",
+ .item_name = av_default_item_name,
+ .option = h263_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_h263_encoder = {
.name = "h263",
.type = AVMEDIA_TYPE_VIDEO,
@@ -3793,19 +3807,19 @@ AVCodec ff_h263_encoder = {
.close = MPV_encode_end,
.pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
.long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
+ .priv_class = &h263_class,
};
-#define OFFSET(x) offsetof(MpegEncContext, x)
-#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
-static const AVOption options[] = {
+static const AVOption h263p_options[] = {
{ "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
+ { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },
{ NULL },
};
static const AVClass h263p_class = {
.class_name = "H.263p encoder",
.item_name = av_default_item_name,
- .option = options,
+ .option = h263p_options,
.version = LIBAVUTIL_VERSION_INT,
};
diff --git a/libavcodec/options.c b/libavcodec/options.c
index fb1fb17..8ac3d95 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -75,7 +75,9 @@ static const AVOption options[]={
{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E},
{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"},
{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"},
+#if FF_API_MPEGVIDEO_GLOBAL_OPTS
{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_OBMC }, INT_MIN, INT_MAX, V|E, "flags"},
+#endif
{"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"},
{"loop", "use loop filter", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"},
{"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"},
More information about the ffmpeg-cvslog
mailing list