diff options
author | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-11-30 12:19:36 -0500 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-12-07 11:27:42 -0500 |
commit | 16216b713f9a21865cc07993961cf5d0ece24916 (patch) | |
tree | 9c377726ecbf0f1cc9c77ce60d054f159760ecea | |
parent | be00ec832c519427cd92218abac77dafdc1d5487 (diff) | |
download | ffmpeg-streaming-16216b713f9a21865cc07993961cf5d0ece24916.zip ffmpeg-streaming-16216b713f9a21865cc07993961cf5d0ece24916.tar.gz |
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: Vittorio Giovara <vittorio.giovara@gmail.com>
-rw-r--r-- | libavcodec/aacenc.c | 12 | ||||
-rw-r--r-- | libavcodec/avcodec.h | 17 | ||||
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 15 | ||||
-rw-r--r-- | libavcodec/options_table.h | 2 | ||||
-rw-r--r-- | libavcodec/version.h | 3 |
5 files changed, 37 insertions, 12 deletions
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 00261c0..c247c5b 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -510,6 +510,7 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ChannelElement *cpe; int i, ch, w, g, chans, tag, start_ch, ret; int chan_el_counter[4]; + int frame_bits; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; if (s->last_frame == 2) @@ -577,8 +578,6 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } do { - int frame_bits; - init_put_bits(&s->pb, avpkt->data, avpkt->size); 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, put_bits(&s->pb, 3, TYPE_END); 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 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 = FFMIN(s->lambda, 65536.f); } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index dd78be2..30a8ddb 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2437,22 +2437,29 @@ typedef struct AVCodecContext { /* This doesn't take account of any particular */ /* headers inside the transmitted RTP payload. */ +#if FF_API_STAT_BITS /* statistics, used for 2-pass encoding */ + attribute_deprecated int mv_bits; + attribute_deprecated int header_bits; + attribute_deprecated int i_tex_bits; + attribute_deprecated int p_tex_bits; + attribute_deprecated int i_count; + attribute_deprecated int p_count; + attribute_deprecated int skip_count; + attribute_deprecated int misc_bits; - /** - * number of bits used for the previously encoded frame - * - encoding: Set by libavcodec. - * - decoding: unused - */ + /** @deprecated this field is unused */ + attribute_deprecated int frame_bits; +#endif /** * pass1 encoding statistics output buffer diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4e97f4d..6f58585 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1659,6 +1659,8 @@ vbv_retry: if (encode_picture(s, s->picture_number) < 0) return -1; +#if FF_API_STAT_BITS +FF_DISABLE_DEPRECATION_WARNINGS avctx->header_bits = s->header_bits; avctx->mv_bits = s->mv_bits; avctx->misc_bits = s->misc_bits; @@ -1668,6 +1670,8 @@ vbv_retry: // FIXME f/b_count in avctx avctx->p_count = s->mb_num - s->i_count - s->skip_count; avctx->skip_count = s->skip_count; +FF_ENABLE_DEPRECATION_WARNINGS +#endif frame_end(s); @@ -1727,9 +1731,9 @@ vbv_retry: } if (s->avctx->flags & AV_CODEC_FLAG_PASS1) - assert(avctx->header_bits + avctx->mv_bits + avctx->misc_bits + - avctx->i_tex_bits + avctx->p_tex_bits == - put_bits_count(&s->pb)); + assert(put_bits_count(&s->pb) == s->header_bits + s->mv_bits + + s->misc_bits + s->i_tex_bits + + s->p_tex_bits); flush_put_bits(&s->pb); s->frame_bits = put_bits_count(&s->pb); @@ -1811,7 +1815,12 @@ FF_ENABLE_DEPRECATION_WARNINGS #endif } s->total_bits += s->frame_bits; +#if FF_API_STAT_BITS +FF_DISABLE_DEPRECATION_WARNINGS avctx->frame_bits = s->frame_bits; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + pkt->pts = s->current_picture.f->pts; if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index ba0cfea..91b2bef 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -121,6 +121,7 @@ static const AVOption avcodec_options[] = { #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}, {"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}, {"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}, @@ -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}, {"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}, +#endif {"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"}, {"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index c18d4cf..811cd10 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -186,5 +186,8 @@ #ifndef FF_API_CODER_TYPE #define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_STAT_BITS +#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ |