From c5dd0bc4ca977924825a74080ff1c294dda01427 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 22 Aug 2011 07:55:34 +0200 Subject: [PATCH] libx264: add 'weightp' private option. Deprecate corresponding global option. --- libavcodec/avcodec.h | 4 ++-- libavcodec/libx264.c | 11 ++++++++++- libavcodec/options.c | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 77544e3..414b150 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2712,6 +2712,7 @@ typedef struct AVCodecContext { */ int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); +#if FF_API_X264_GLOBAL_OPTS /** * explicit P-frame weighted prediction analysis method * 0: off @@ -2720,9 +2721,8 @@ typedef struct AVCodecContext { * - encoding: Set by user. * - decoding: unused */ - int weighted_p_pred; + attribute_deprecated int weighted_p_pred; -#if FF_API_X264_GLOBAL_OPTS /** * AQ mode * 0: Disabled diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 72033b9..435f228 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -48,6 +48,7 @@ typedef struct X264Context { float psy_rd; float psy_trellis; int rc_lookahead; + int weightp; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -225,7 +226,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_direct_mv_pred = avctx->directpred; 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) x4->params.analyse.i_me_method = X264_ME_DIA; @@ -318,6 +318,8 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.f_psy_trellis = avctx->psy_trellis; if (avctx->rc_lookahead >= 0) x4->params.rc.i_lookahead = avctx->rc_lookahead; + if (avctx->weighted_p_pred >= 0) + x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; #endif if (x4->aq_mode >= 0) @@ -330,6 +332,9 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.f_psy_trellis = x4->psy_trellis; if (x4->rc_lookahead >= 0) x4->params.rc.i_lookahead = x4->rc_lookahead; + if (x4->weightp >= 0) + x4->params.analyse.i_weighted_pred = x4->weightp; + if (x4->fastfirstpass) @@ -414,6 +419,10 @@ static const AVOption options[] = { { "pdy_rd", "Psy RD strength.", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, { "psy_trellis", "Psy trellis strength", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, { "rc_lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, + { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "simple", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, { NULL }, }; diff --git a/libavcodec/options.c b/libavcodec/options.c index 00a4376..6d40ef0 100644 --- a/libavcodec/options.c +++ b/libavcodec/options.c @@ -141,7 +141,9 @@ static const AVOption options[]={ {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, {"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, -{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, +#if FF_API_X264_GLOBAL_OPTS +{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, +#endif {"ps", "rtp payload size in bytes", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, {"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -- 2.7.4