Merge commit '66a68ddd1ac376b24db8695058bc8fc28f5bada6'

* commit '66a68ddd1ac376b24db8695058bc8fc28f5bada6':
  lavc: make rc_buffer_aggressivity/rc_initial_cplx into private options of mpegvideo encoders

Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/89/head
Michael Niedermayer 10 years ago
commit fc67d937cc
  1. 12
      libavcodec/avcodec.h
  2. 6
      libavcodec/mpegvideo.h
  3. 4
      libavcodec/mpegvideo_enc.c
  4. 8
      libavcodec/options_table.h
  5. 10
      libavcodec/ratecontrol.c

@ -2321,14 +2321,16 @@ typedef struct AVCodecContext {
*/
int rc_min_rate;
float rc_buffer_aggressivity;
#if FF_API_MPV_OPT
/**
* initial complexity for pass1 ratecontrol
* - encoding: Set by user.
* - decoding: unused
* @deprecated use encoder private options instead
*/
attribute_deprecated
float rc_buffer_aggressivity;
attribute_deprecated
float rc_initial_cplx;
#endif
/**
* Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.

@ -659,6 +659,8 @@ typedef struct MpegEncContext {
float rc_qsquish;
float rc_qmod_amp;
int rc_qmod_freq;
float rc_initial_cplx;
float rc_buffer_aggressivity;
char *rc_eq;
@ -715,7 +717,9 @@ typedef struct MpegEncContext {
"defined in the section 'Expression Evaluation', the following functions are available: " \
"bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \
"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \
FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS },
FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = 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}, \
extern const AVOption ff_mpv_generic_options[];

@ -958,6 +958,10 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->rc_qmod_amp = avctx->rc_qmod_amp;
if (avctx->rc_qmod_freq)
s->rc_qmod_freq = avctx->rc_qmod_freq;
if (avctx->rc_buffer_aggressivity != 1.0)
s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity;
if (avctx->rc_initial_cplx != 0.0)
s->rc_initial_cplx = avctx->rc_initial_cplx;
if (avctx->rc_eq) {
av_freep(&s->rc_eq);

@ -187,10 +187,14 @@ static const AVOption avcodec_options[] = {
{"minrate", "minimum bitrate (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise.",
OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|A|E},
{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, A|V|E},
{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
#if FF_API_MPV_OPT
{"rc_buf_aggressivity", "deprecated, use encoder private options instead", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E},
#endif
{"i_qfactor", "QP factor between P- and I-frames", OFFSET(i_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E},
{"i_qoffset", "QP offset between P- and I-frames", OFFSET(i_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, -FLT_MAX, FLT_MAX, V|E},
{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
#if FF_API_MPV_OPT
{"rc_init_cplx", "deprecated, use encoder private options instead", OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E},
#endif
{"dct", "DCT algorithm", OFFSET(dct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E, "dct"},
{"auto", "autoselect a good one (default)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, "dct"},
{"fastint", "fast integer", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, "dct"},

@ -250,9 +250,9 @@ av_cold int ff_rate_control_init(MpegEncContext *s)
return -1;
}
/* init stuff with the user specified complexity */
if (s->avctx->rc_initial_cplx) {
if (s->rc_initial_cplx) {
for (i = 0; i < 60 * 30; i++) {
double bits = s->avctx->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num;
double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num;
RateControlEntry rce;
if (i % ((s->gop_size + 3) / 4) == 0)
@ -533,7 +533,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
d = 1.0;
else if (d < 0.0001)
d = 0.0001;
q *= pow(d, 1.0 / s->avctx->rc_buffer_aggressivity);
q *= pow(d, 1.0 / s->rc_buffer_aggressivity);
q_limit = bits2qp(rce,
FFMAX((min_rate - buffer_size + rcc->buffer_index) *
@ -553,7 +553,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
d = 1.0;
else if (d < 0.0001)
d = 0.0001;
q /= pow(d, 1.0 / s->avctx->rc_buffer_aggressivity);
q /= pow(d, 1.0 / s->rc_buffer_aggressivity);
q_limit = bits2qp(rce,
FFMAX(rcc->buffer_index *
@ -569,7 +569,7 @@ static double modify_qscale(MpegEncContext *s, RateControlEntry *rce,
}
av_dlog(s, "q:%f max:%f min:%f size:%f index:%f agr:%f\n",
q, max_rate, min_rate, buffer_size, rcc->buffer_index,
s->avctx->rc_buffer_aggressivity);
s->rc_buffer_aggressivity);
if (s->rc_qsquish == 0.0 || qmin == qmax) {
if (q < qmin)
q = qmin;

Loading…
Cancel
Save