summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2023-09-01 13:55:48 -0300
committerJames Almer <jamrial@gmail.com>2023-09-06 10:27:44 -0300
commit8e972b13a97604d570ef26e8ac46767191d74f6f (patch)
tree6857a2bec14c736ac2f81842b3d78e5ec935f775
parentb6627a57f415b550dc3f13f99f84840096455cad (diff)
avformat/demux: propagate the internal decoder's bitrate properties
Muxers may access this information through cpb properties within the stream's side data. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavformat/demux.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libavformat/demux.c b/libavformat/demux.c
index b218f64574..fcd5daf699 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2974,6 +2974,23 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
ret = add_coded_side_data(st, sti->avctx);
if (ret < 0)
goto find_stream_info_err;
+
+ if (sti->avctx->rc_buffer_size > 0 || sti->avctx->rc_max_rate > 0 ||
+ sti->avctx->rc_min_rate) {
+ size_t cpb_size;
+ AVCPBProperties *props = av_cpb_properties_alloc(&cpb_size);
+ if (props) {
+ if (sti->avctx->rc_buffer_size > 0)
+ props->buffer_size = sti->avctx->rc_buffer_size;
+ if (sti->avctx->rc_min_rate > 0)
+ props->min_bitrate = sti->avctx->rc_min_rate;
+ if (sti->avctx->rc_max_rate > 0)
+ props->max_bitrate = sti->avctx->rc_max_rate;
+ if (av_stream_add_side_data(st, AV_PKT_DATA_CPB_PROPERTIES,
+ (uint8_t *)props, cpb_size))
+ av_free(props);
+ }
+ }
}
sti->avctx_inited = 0;