Commit 530c1441 authored by Anton Khirnov's avatar Anton Khirnov

lavc: make lmax/lmin into private options of mpegvideo encoders

parent 15ec053c
...@@ -2183,19 +2183,19 @@ typedef struct AVCodecContext { ...@@ -2183,19 +2183,19 @@ typedef struct AVCodecContext {
*/ */
int context_model; int context_model;
#if FF_API_MPV_OPT
/** /**
* minimum Lagrange multipler * @deprecated use encoder private options instead
* - encoding: Set by user.
* - decoding: unused
*/ */
attribute_deprecated
int lmin; int lmin;
/** /**
* maximum Lagrange multipler * @deprecated use encoder private options instead
* - encoding: Set by user.
* - decoding: unused
*/ */
attribute_deprecated
int lmax; int lmax;
#endif
/** /**
* frame skip threshold * frame skip threshold
......
...@@ -640,6 +640,7 @@ typedef struct MpegEncContext { ...@@ -640,6 +640,7 @@ typedef struct MpegEncContext {
float rc_initial_cplx; float rc_initial_cplx;
float rc_buffer_aggressivity; float rc_buffer_aggressivity;
float border_masking; float border_masking;
int lmin, lmax;
char *rc_eq; char *rc_eq;
...@@ -700,6 +701,8 @@ typedef struct MpegEncContext { ...@@ -700,6 +701,8 @@ typedef struct MpegEncContext {
{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ {"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ {"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \ {"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \
extern const AVOption ff_mpv_generic_options[]; extern const AVOption ff_mpv_generic_options[];
......
...@@ -834,6 +834,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) ...@@ -834,6 +834,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity; s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity;
if (avctx->rc_initial_cplx != 0.0) if (avctx->rc_initial_cplx != 0.0)
s->rc_initial_cplx = avctx->rc_initial_cplx; s->rc_initial_cplx = avctx->rc_initial_cplx;
if (avctx->lmin)
s->lmin = avctx->lmin;
if (avctx->lmax)
s->lmax = avctx->lmax;
if (avctx->rc_eq) { if (avctx->rc_eq) {
av_freep(&s->rc_eq); av_freep(&s->rc_eq);
...@@ -1621,7 +1625,7 @@ vbv_retry: ...@@ -1621,7 +1625,7 @@ vbv_retry:
int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use; int max_size = rcc->buffer_index * avctx->rc_max_available_vbv_use;
if (put_bits_count(&s->pb) > max_size && if (put_bits_count(&s->pb) > max_size &&
s->lambda < s->avctx->lmax) { s->lambda < s->lmax) {
s->next_lambda = FFMAX(s->lambda + 1, s->lambda * s->next_lambda = FFMAX(s->lambda + 1, s->lambda *
(s->qscale + 1) / s->qscale); (s->qscale + 1) / s->qscale);
if (s->adaptive_quant) { if (s->adaptive_quant) {
......
...@@ -310,8 +310,10 @@ static const AVOption avcodec_options[] = { ...@@ -310,8 +310,10 @@ static const AVOption avcodec_options[] = {
{"rd", "use best rate distortion", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"}, {"rd", "use best rate distortion", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"},
{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"lmin", "minimum Lagrange factor (VBR)", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, #if FF_API_MPV_OPT
{"lmax", "maximum Lagrange factor (VBR)", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, {"lmin", "deprecated, use encoder private options instead", OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
{"lmax", "deprecated, use encoder private options instead", OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|E},
#endif
{"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"}, {"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, V|A|E|D, "flags2"},
......
...@@ -460,8 +460,8 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl ...@@ -460,8 +460,8 @@ static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, doubl
*/ */
static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type) static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type)
{ {
int qmin = s->avctx->lmin; int qmin = s->lmin;
int qmax = s->avctx->lmax; int qmax = s->lmax;
assert(qmin <= qmax); assert(qmin <= qmax);
......
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