Commit 84c4714f authored by Vittorio Giovara's avatar Vittorio Giovara

lavc: Move brd_scale to codec private options

This option is only used by mpegvideoenc,
It is a very codec-specific option, so deprecate the global variant.
Set proper limits to the maximum allowed values.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent 0e6c8532
...@@ -1958,12 +1958,11 @@ typedef struct AVCodecContext { ...@@ -1958,12 +1958,11 @@ typedef struct AVCodecContext {
*/ */
int bidir_refine; int bidir_refine;
/** #if FF_API_PRIVATE_OPT
* /** @deprecated use encoder private options instead */
* - encoding: Set by user. attribute_deprecated
* - decoding: unused
*/
int brd_scale; int brd_scale;
#endif
/** /**
* minimum GOP size * minimum GOP size
......
...@@ -444,6 +444,7 @@ typedef struct MpegEncContext { ...@@ -444,6 +444,7 @@ typedef struct MpegEncContext {
int top_field_first; int top_field_first;
int concealment_motion_vectors; int concealment_motion_vectors;
int q_scale_type; int q_scale_type;
int brd_scale;
int intra_vlc_format; int intra_vlc_format;
int alternate_scan; int alternate_scan;
int repeat_first_field; int repeat_first_field;
...@@ -577,6 +578,7 @@ typedef struct MpegEncContext { ...@@ -577,6 +578,7 @@ typedef struct MpegEncContext {
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \ {"b_strategy", "Strategy to choose between I/P/B-frames", FF_MPV_OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, FF_MPV_OPT_FLAGS }, \
{"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"b_sensitivity", "Adjust sensitivity of b_frame_strategy 1", FF_MPV_OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.i64 = 40 }, 1, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"brd_scale", "Downscale frames for dynamic B-frame decision", FF_MPV_OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 3, FF_MPV_OPT_FLAGS }, \
extern const AVOption ff_mpv_generic_options[]; extern const AVOption ff_mpv_generic_options[];
......
...@@ -876,6 +876,13 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -876,6 +876,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
FF_ENABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->brd_scale)
s->brd_scale = avctx->brd_scale;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (s->b_frame_strategy == 2) { if (s->b_frame_strategy == 2) {
for (i = 0; i < s->max_b_frames + 2; i++) { for (i = 0; i < s->max_b_frames + 2; i++) {
s->tmp_frames[i] = av_frame_alloc(); s->tmp_frames[i] = av_frame_alloc();
...@@ -883,8 +890,8 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -883,8 +890,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P; s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P;
s->tmp_frames[i]->width = s->width >> avctx->brd_scale; s->tmp_frames[i]->width = s->width >> s->brd_scale;
s->tmp_frames[i]->height = s->height >> avctx->brd_scale; s->tmp_frames[i]->height = s->height >> s->brd_scale;
ret = av_frame_get_buffer(s->tmp_frames[i], 32); ret = av_frame_get_buffer(s->tmp_frames[i], 32);
if (ret < 0) if (ret < 0)
...@@ -1182,7 +1189,7 @@ static int estimate_best_b_count(MpegEncContext *s) ...@@ -1182,7 +1189,7 @@ static int estimate_best_b_count(MpegEncContext *s)
{ {
AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id); AVCodec *codec = avcodec_find_encoder(s->avctx->codec_id);
AVCodecContext *c = avcodec_alloc_context3(NULL); AVCodecContext *c = avcodec_alloc_context3(NULL);
const int scale = s->avctx->brd_scale; const int scale = s->brd_scale;
int i, j, out_size, p_lambda, b_lambda, lambda2; int i, j, out_size, p_lambda, b_lambda, lambda2;
int64_t best_rd = INT64_MAX; int64_t best_rd = INT64_MAX;
int best_b_count = -1; int best_b_count = -1;
......
...@@ -383,7 +383,9 @@ static const AVOption avcodec_options[] = { ...@@ -383,7 +383,9 @@ static const AVOption avcodec_options[] = {
{"nokey" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"nokey" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"all" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, {"all" , NULL, 0, AV_OPT_TYPE_CONST, {.i64 = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"},
{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E}, {"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.i64 = 1 }, 0, 4, V|E},
#if FF_API_PRIVATE_OPT
{"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E}, {"brd_scale", "downscale frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, 10, V|E},
#endif
{"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E}, {"keyint_min", "minimum interval between IDR-frames (x264)", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.i64 = 25 }, INT_MIN, INT_MAX, V|E},
{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E}, {"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.i64 = 1 }, INT_MIN, INT_MAX, V|E},
{"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"chromaoffset", "chroma QP offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment