diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-09-06 21:35:18 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-09-06 21:35:18 +0200 |
commit | 2fd49019210a9fbe430b1b94ff7a2f98a6d0fed1 (patch) | |
tree | 15a45d423407f9a2c2cafd290915e3756f4fab94 /libavcodec/libx264.c | |
parent | ff5e1b0b7a975fc84137381dd15dcc5a5ff21a78 (diff) | |
parent | 7042337673ee75300a6f668fbcf3074213b06977 (diff) | |
download | ffmpeg-2fd49019210a9fbe430b1b94ff7a2f98a6d0fed1.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
libx264: add 'cplxblur' private option
libx264: add 'deblock' private option
libx264: add 'b-bias' private option
libx264: fix setting some options.
libx264: remove useless assignment
ac3dec: avoid pointless alloc and indirection for input_buffer
mpeg12: cosmetics: reformat as K&R
Conflicts:
libavcodec/libx264.c
libavcodec/mpeg12.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libx264.c')
-rw-r--r-- | libavcodec/libx264.c | 77 |
1 files changed, 54 insertions, 23 deletions
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index d9a99f3d85..b6d2da8be1 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -57,12 +57,15 @@ typedef struct X264Context { int weightb; int ssim; int intra_refresh; + int b_bias; int b_pyramid; int mixed_refs; int dct8x8; int fast_pskip; int aud; int mbtree; + char *deblock; + float cplxblur; } X264Context; static void X264_log(void *p, int level, const char *fmt, va_list args) @@ -232,39 +235,26 @@ static void check_default_settings(AVCodecContext *avctx) } \ } while (0); +#define PARSE_X264_OPT(name, var)\ + if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\ + av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\ + return AVERROR(EINVAL);\ + } + static av_cold int X264_init(AVCodecContext *avctx) { X264Context *x4 = avctx->priv_data; - x4->sei_size = 0; x264_param_default(&x4->params); - x4->params.i_keyint_max = avctx->gop_size; - - x4->params.i_bframe = avctx->max_b_frames; x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC; x4->params.i_bframe_adaptive = avctx->b_frame_strategy; - x4->params.i_bframe_bias = avctx->bframebias; x4->params.i_keyint_min = avctx->keyint_min; if (x4->params.i_keyint_min > x4->params.i_keyint_max) x4->params.i_keyint_min = x4->params.i_keyint_max; - x4->params.i_scenecut_threshold = avctx->scenechange_threshold; - x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER; - x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha; - x4->params.i_deblocking_filter_beta = avctx->deblockbeta; - - x4->params.rc.i_qp_min = avctx->qmin; - x4->params.rc.i_qp_max = avctx->qmax; - x4->params.rc.i_qp_step = avctx->max_qdiff; - - x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */ - x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */ - x4->params.rc.f_complexity_blur = avctx->complexityblur; - - x4->params.i_frame_reference = avctx->refs; x4->params.analyse.inter = 0; if (avctx->partitions) { @@ -389,6 +379,14 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.i_lookahead = avctx->rc_lookahead; if (avctx->weighted_p_pred >= 0) x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred; + if (avctx->bframebias) + x4->params.i_bframe_bias = avctx->bframebias; + if (avctx->deblockalpha) + x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha; + if (avctx->deblockbeta) + x4->params.i_deblocking_filter_beta = avctx->deblockbeta; + if (avctx->complexityblur >= 0) + x4->params.rc.f_complexity_blur = avctx->complexityblur; x4->params.analyse.b_ssim = avctx->flags2 & CODEC_FLAG2_SSIM; x4->params.b_intra_refresh = avctx->flags2 & CODEC_FLAG2_INTRA_REFRESH; x4->params.i_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE; @@ -401,14 +399,31 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.b_mb_tree = !!(avctx->flags2 & CODEC_FLAG2_MBTREE); #endif + if (avctx->gop_size >= 0) + x4->params.i_keyint_max = avctx->gop_size; + if (avctx->max_b_frames >= 0) + x4->params.i_bframe = avctx->max_b_frames; + if (avctx->scenechange_threshold >= 0) + x4->params.i_scenecut_threshold = avctx->scenechange_threshold; + if (avctx->qmin >= 0) + x4->params.rc.i_qp_min = avctx->qmin; + if (avctx->qmax >= 0) + x4->params.rc.i_qp_max = avctx->qmax; + if (avctx->max_qdiff >= 0) + x4->params.rc.i_qp_step = avctx->max_qdiff; + if (avctx->qblur >= 0) + x4->params.rc.f_qblur = avctx->qblur; /* temporally blur quants */ + if (avctx->qcompress >= 0) + x4->params.rc.f_qcompress = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */ + if (avctx->refs >= 0) + x4->params.i_frame_reference = avctx->refs; + if (x4->aq_mode >= 0) x4->params.rc.i_aq_mode = x4->aq_mode; if (x4->aq_strength >= 0) x4->params.rc.f_aq_strength = x4->aq_strength; - if (x4->psy_rd && x264_param_parse(&x4->params, "psy-rd", x4->psy_rd) < 0) { - av_log(avctx, AV_LOG_ERROR, "Error parsing option 'psy-rd' with value '%s'.\n", x4->psy_rd); - return AVERROR(EINVAL); - } + PARSE_X264_OPT("psy-rd", psy_rd); + PARSE_X264_OPT("deblock", deblock); if (x4->psy >= 0) x4->params.analyse.b_psy = x4->psy; if (x4->rc_lookahead >= 0) @@ -417,11 +432,15 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.analyse.i_weighted_pred = x4->weightp; if (x4->weightb >= 0) x4->params.analyse.b_weighted_bipred = x4->weightb; + if (x4->cplxblur >= 0) + x4->params.rc.f_complexity_blur = x4->cplxblur; if (x4->ssim >= 0) x4->params.analyse.b_ssim = x4->ssim; if (x4->intra_refresh >= 0) x4->params.b_intra_refresh = x4->intra_refresh; + if (x4->b_bias != INT_MIN) + x4->params.i_bframe_bias = x4->b_bias; if (x4->b_pyramid >= 0) x4->params.i_bframe_pyramid = x4->b_pyramid; if (x4->mixed_refs >= 0) @@ -527,6 +546,7 @@ static const AVOption options[] = { { "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" }, { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" }, { "strict", "Strictly hierarchical pyramid", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" }, @@ -536,6 +556,8 @@ static const AVOption options[] = { { "fast-pskip", NULL, OFFSET(fast_pskip), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, { "aud", "Use access unit delimiters.", OFFSET(aud), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "deblock", "Loop filter parameters, in <alpha:beta> form.", OFFSET(deblock), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, { NULL }, }; @@ -548,6 +570,15 @@ static const AVClass class = { static const AVCodecDefault x264_defaults[] = { { "b", "0" }, + { "bf", "-1" }, + { "g", "-1" }, + { "qmin", "-1" }, + { "qmax", "-1" }, + { "qdiff", "-1" }, + { "qblur", "-1" }, + { "qcomp", "-1" }, + { "refs", "-1" }, + { "sc_threshold", "-1" }, { "threads", AV_STRINGIFY(X264_THREADS_AUTO) }, { NULL }, }; |