diff options
author | Anton Khirnov <anton@khirnov.net> | 2015-10-04 12:27:10 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2015-12-06 10:26:13 +0100 |
commit | 8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca (patch) | |
tree | f1a1f210e80db694894a9c8d98ea8e2c783d3570 /libavformat | |
parent | 5845a8273e4694e0254ad728970b82bb64fd8bc0 (diff) | |
download | ffmpeg-streaming-8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca.zip ffmpeg-streaming-8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca.tar.gz |
mpegenc: use the CPB props side data
Do not access the encoder options, since it makes no sense when the
AVStream codec context is not the encoding context.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mpegenc.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 33eaefd..ac5a83c 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -341,6 +341,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) lpcm_id = LPCM_ID; for (i = 0; i < ctx->nb_streams; i++) { + AVCPBProperties *props; + st = ctx->streams[i]; stream = av_mallocz(sizeof(StreamInfo)); if (!stream) @@ -383,8 +385,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) stream->id = h264_id++; else stream->id = mpv_id++; - if (st->codec->rc_buffer_size) - stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8; + + props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + if (props && props->buffer_size) + stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8; else { av_log(ctx, AV_LOG_WARNING, "VBV buffer size not set, muxing may fail\n"); @@ -408,13 +412,14 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) audio_bitrate = 0; video_bitrate = 0; for (i = 0; i < ctx->nb_streams; i++) { + AVCPBProperties *props; int codec_rate; st = ctx->streams[i]; stream = (StreamInfo *)st->priv_data; - if (st->codec->rc_max_rate || - st->codec->codec_type == AVMEDIA_TYPE_VIDEO) - codec_rate = st->codec->rc_max_rate; + props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); + if (props) + codec_rate = props->max_bitrate; else codec_rate = st->codec->bit_rate; |