Commit 16216b71 authored by Vittorio Giovara's avatar Vittorio Giovara

lavc: Drop exporting 2-pass encoding stats

These variables are coming from mpegvideoenc where are supposedly used
as bit counters on various frame properties. However their use is
unclear as they lack documentation, are available only from a very small
subset of encoders, and they are hardly used in the wild. Also frame_bits
in aacenc is employed in a similar way.

Remove this functionality from AVCodecContex, these variable are mostly
frame properties, and too few encoders support setting them with anything
useful.
Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
parent be00ec83
...@@ -510,6 +510,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -510,6 +510,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
ChannelElement *cpe; ChannelElement *cpe;
int i, ch, w, g, chans, tag, start_ch, ret; int i, ch, w, g, chans, tag, start_ch, ret;
int chan_el_counter[4]; int chan_el_counter[4];
int frame_bits;
FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
if (s->last_frame == 2) if (s->last_frame == 2)
...@@ -577,8 +578,6 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -577,8 +578,6 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
} }
do { do {
int frame_bits;
init_put_bits(&s->pb, avpkt->data, avpkt->size); init_put_bits(&s->pb, avpkt->data, avpkt->size);
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT))
...@@ -651,11 +650,16 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ...@@ -651,11 +650,16 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
put_bits(&s->pb, 3, TYPE_END); put_bits(&s->pb, 3, TYPE_END);
flush_put_bits(&s->pb); flush_put_bits(&s->pb);
avctx->frame_bits = put_bits_count(&s->pb); frame_bits = put_bits_count(&s->pb);
#if FF_API_STAT_BITS
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_bits = frame_bits;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
// rate control stuff // rate control stuff
if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) { if (!(avctx->flags & AV_CODEC_FLAG_QSCALE)) {
float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / avctx->frame_bits; float ratio = avctx->bit_rate * 1024.0f / avctx->sample_rate / frame_bits;
s->lambda *= ratio; s->lambda *= ratio;
s->lambda = FFMIN(s->lambda, 65536.f); s->lambda = FFMIN(s->lambda, 65536.f);
} }
......
...@@ -2437,22 +2437,29 @@ typedef struct AVCodecContext { ...@@ -2437,22 +2437,29 @@ typedef struct AVCodecContext {
/* This doesn't take account of any particular */ /* This doesn't take account of any particular */
/* headers inside the transmitted RTP payload. */ /* headers inside the transmitted RTP payload. */
#if FF_API_STAT_BITS
/* statistics, used for 2-pass encoding */ /* statistics, used for 2-pass encoding */
attribute_deprecated
int mv_bits; int mv_bits;
attribute_deprecated
int header_bits; int header_bits;
attribute_deprecated
int i_tex_bits; int i_tex_bits;
attribute_deprecated
int p_tex_bits; int p_tex_bits;
attribute_deprecated
int i_count; int i_count;
attribute_deprecated
int p_count; int p_count;
attribute_deprecated
int skip_count; int skip_count;
attribute_deprecated
int misc_bits; int misc_bits;
/** /** @deprecated this field is unused */
* number of bits used for the previously encoded frame attribute_deprecated
* - encoding: Set by libavcodec.
* - decoding: unused
*/
int frame_bits; int frame_bits;
#endif
/** /**
* pass1 encoding statistics output buffer * pass1 encoding statistics output buffer
......
...@@ -1659,6 +1659,8 @@ vbv_retry: ...@@ -1659,6 +1659,8 @@ vbv_retry:
if (encode_picture(s, s->picture_number) < 0) if (encode_picture(s, s->picture_number) < 0)
return -1; return -1;
#if FF_API_STAT_BITS
FF_DISABLE_DEPRECATION_WARNINGS
avctx->header_bits = s->header_bits; avctx->header_bits = s->header_bits;
avctx->mv_bits = s->mv_bits; avctx->mv_bits = s->mv_bits;
avctx->misc_bits = s->misc_bits; avctx->misc_bits = s->misc_bits;
...@@ -1668,6 +1670,8 @@ vbv_retry: ...@@ -1668,6 +1670,8 @@ vbv_retry:
// FIXME f/b_count in avctx // FIXME f/b_count in avctx
avctx->p_count = s->mb_num - s->i_count - s->skip_count; avctx->p_count = s->mb_num - s->i_count - s->skip_count;
avctx->skip_count = s->skip_count; avctx->skip_count = s->skip_count;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
frame_end(s); frame_end(s);
...@@ -1727,9 +1731,9 @@ vbv_retry: ...@@ -1727,9 +1731,9 @@ vbv_retry:
} }
if (s->avctx->flags & AV_CODEC_FLAG_PASS1) if (s->avctx->flags & AV_CODEC_FLAG_PASS1)
assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + assert(put_bits_count(&s->pb) == s->header_bits + s->mv_bits +
avctx->i_tex_bits + avctx->p_tex_bits == s->misc_bits + s->i_tex_bits +
put_bits_count(&s->pb)); s->p_tex_bits);
flush_put_bits(&s->pb); flush_put_bits(&s->pb);
s->frame_bits = put_bits_count(&s->pb); s->frame_bits = put_bits_count(&s->pb);
...@@ -1811,7 +1815,12 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -1811,7 +1815,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
#endif #endif
} }
s->total_bits += s->frame_bits; s->total_bits += s->frame_bits;
#if FF_API_STAT_BITS
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_bits = s->frame_bits; avctx->frame_bits = s->frame_bits;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->pts = s->current_picture.f->pts; pkt->pts = s->current_picture.f->pts;
if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) {
......
...@@ -121,6 +121,7 @@ static const AVOption avcodec_options[] = { ...@@ -121,6 +121,7 @@ static const AVOption avcodec_options[] = {
#endif #endif
{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E}, {"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, V|E},
{"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E}, {"ps", "RTP payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX, V|E},
#if FF_API_STAT_BITS
{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"i_tex_bits", NULL, OFFSET(i_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"i_tex_bits", NULL, OFFSET(i_tex_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
...@@ -130,6 +131,7 @@ static const AVOption avcodec_options[] = { ...@@ -130,6 +131,7 @@ static const AVOption avcodec_options[] = {
{"skip_count", NULL, OFFSET(skip_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"skip_count", NULL, OFFSET(skip_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"misc_bits", NULL, OFFSET(misc_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"misc_bits", NULL, OFFSET(misc_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"frame_bits", NULL, OFFSET(frame_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"frame_bits", NULL, OFFSET(frame_bits), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
#endif
{"codec_tag", NULL, OFFSET(codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"codec_tag", NULL, OFFSET(codec_tag), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, {"bug", "work around not autodetected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
{"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, {"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"},
......
...@@ -186,5 +186,8 @@ ...@@ -186,5 +186,8 @@
#ifndef FF_API_CODER_TYPE #ifndef FF_API_CODER_TYPE
#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59) #define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59)
#endif #endif
#ifndef FF_API_STAT_BITS
#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */
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