History

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.

Anton Khirnov committed 11 years ago

Commit 8bcadaa1 parent 5845a821 file · +10 −5Browse files

Unified · Split

libavformat/mpegenc.c+10−5
@@ -341,6 +341,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 340 unmodified lines
341341 lpcm_id = LPCM_ID;
342342
343343 for (i = 0; i < ctx->nb_streams; i++) {
344+ AVCPBProperties *props;
345+
344346 st = ctx->streams[i];
345347 stream = av_mallocz(sizeof(StreamInfo));
346348 if (!stream)
@@ -383,8 +385,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 36 unmodified lines
383385 stream->id = h264_id++;
384386 else
385387 stream->id = mpv_id++;
386− if (st->codec->rc_buffer_size)
387− stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8;
388+
389+ props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL);
390+ if (props && props->buffer_size)
391+ stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8;
388392 else {
389393 av_log(ctx, AV_LOG_WARNING,
390394 "VBV buffer size not set, muxing may fail\n");
@@ -408,13 +412,14 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 17 unmodified lines
408412 audio_bitrate = 0;
409413 video_bitrate = 0;
410414 for (i = 0; i < ctx->nb_streams; i++) {
415+ AVCPBProperties *props;
411416 int codec_rate;
412417 st = ctx->streams[i];
413418 stream = (StreamInfo *)st->priv_data;
414419
415− if (st->codec->rc_max_rate ||
416− st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
417− codec_rate = st->codec->rc_max_rate;
420+ props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL);
421+ if (props)
422+ codec_rate = props->max_bitrate;
418423 else
419424 codec_rate = st->codec->bit_rate;
420425

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t