From 0e6c8532215790bbe560a9eea4f3cc82bb55cf92 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Wed, 9 Sep 2015 04:18:26 +0200 Subject: lavc: Move b_frame_strategy and b_sensitivity to codec private options The b_frame_strategy option is only used by mpegvideoenc, qsv, x264, and xavs, while b_sensitivity is only used by mpegvideoenc. These are very codec-specific options, so deprecate the global variants. Set proper limits to the maximum allowed values. Signed-off-by: Vittorio Giovara --- libavcodec/mpegvideo_enc.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'libavcodec/mpegvideo_enc.c') diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 34e008f66d..585631232f 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -525,10 +525,19 @@ FF_ENABLE_DEPRECATION_WARNINGS return -1; } - if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { +#if FF_API_PRIVATE_OPT +FF_DISABLE_DEPRECATION_WARNINGS + if (avctx->b_frame_strategy) + s->b_frame_strategy = avctx->b_frame_strategy; + if (avctx->b_sensitivity != 40) + s->b_sensitivity = avctx->b_sensitivity; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + + if (s->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { av_log(avctx, AV_LOG_INFO, "notice: b_frame_strategy only affects the first pass\n"); - avctx->b_frame_strategy = 0; + s->b_frame_strategy = 0; } i = av_gcd(avctx->time_base.den, avctx->time_base.num); @@ -867,7 +876,7 @@ FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif - if (avctx->b_frame_strategy == 2) { + if (s->b_frame_strategy == 2) { for (i = 0; i < s->max_b_frames + 2; i++) { s->tmp_frames[i] = av_frame_alloc(); if (!s->tmp_frames[i]) @@ -1302,7 +1311,7 @@ static int select_input_picture(MpegEncContext *s) s->reordered_input_picture[0]->f->coded_picture_number = s->coded_picture_number++; } else { - int b_frames; + int b_frames = 0; if (s->avctx->frame_skip_threshold || s->avctx->frame_skip_factor) { if (s->picture_in_gop_number < s->gop_size && @@ -1333,11 +1342,11 @@ static int select_input_picture(MpegEncContext *s) } } - if (s->avctx->b_frame_strategy == 0) { + if (s->b_frame_strategy == 0) { b_frames = s->max_b_frames; while (b_frames && !s->input_picture[b_frames]) b_frames--; - } else if (s->avctx->b_frame_strategy == 1) { + } else if (s->b_frame_strategy == 1) { for (i = 1; i < s->max_b_frames + 1; i++) { if (s->input_picture[i] && s->input_picture[i]->b_frame_score == 0) { @@ -1351,7 +1360,7 @@ static int select_input_picture(MpegEncContext *s) for (i = 0; i < s->max_b_frames + 1; i++) { if (!s->input_picture[i] || s->input_picture[i]->b_frame_score - 1 > - s->mb_num / s->avctx->b_sensitivity) + s->mb_num / s->b_sensitivity) break; } @@ -1361,11 +1370,8 @@ static int select_input_picture(MpegEncContext *s) for (i = 0; i < b_frames + 1; i++) { s->input_picture[i]->b_frame_score = 0; } - } else if (s->avctx->b_frame_strategy == 2) { + } else if (s->b_frame_strategy == 2) { b_frames = estimate_best_b_count(s); - } else { - av_log(s->avctx, AV_LOG_ERROR, "illegal b frame strategy\n"); - b_frames = 0; } emms_c(); -- cgit v1.2.3