Do not access the encoder options, since it makes no sense when the AVStream codec context is not the encoding context.
Unified · Split
| @@ -341,6 +341,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 340 unmodified lines | |||
| 341 | lpcm_id = LPCM_ID; | 341 | lpcm_id = LPCM_ID; |
| 342 | 342 | ||
| 343 | for (i = 0; i < ctx->nb_streams; i++) { | 343 | for (i = 0; i < ctx->nb_streams; i++) { |
| 344 | AVCPBProperties *props; | ||
| 345 | |||
| 344 | st = ctx->streams[i]; | 346 | st = ctx->streams[i]; |
| 345 | stream = av_mallocz(sizeof(StreamInfo)); | 347 | stream = av_mallocz(sizeof(StreamInfo)); |
| 346 | if (!stream) | 348 | if (!stream) |
| @@ -383,8 +385,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 36 unmodified lines | |||
| 383 | stream->id = h264_id++; | 385 | stream->id = h264_id++; |
| 384 | else | 386 | else |
| 385 | stream->id = mpv_id++; | 387 | stream->id = mpv_id++; |
| 386 | if (st->codec->rc_buffer_size) | 388 | |
| 387 | stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8; | 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; | ||
| 388 | else { | 392 | else { |
| 389 | av_log(ctx, AV_LOG_WARNING, | 393 | av_log(ctx, AV_LOG_WARNING, |
| 390 | "VBV buffer size not set, muxing may fail\n"); | 394 | "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 | |||
| 408 | audio_bitrate = 0; | 412 | audio_bitrate = 0; |
| 409 | video_bitrate = 0; | 413 | video_bitrate = 0; |
| 410 | for (i = 0; i < ctx->nb_streams; i++) { | 414 | for (i = 0; i < ctx->nb_streams; i++) { |
| 415 | AVCPBProperties *props; | ||
| 411 | int codec_rate; | 416 | int codec_rate; |
| 412 | st = ctx->streams[i]; | 417 | st = ctx->streams[i]; |
| 413 | stream = (StreamInfo *)st->priv_data; | 418 | stream = (StreamInfo *)st->priv_data; |
| 414 | 419 | ||
| 415 | if (st->codec->rc_max_rate || | 420 | props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL); |
| 416 | st->codec->codec_type == AVMEDIA_TYPE_VIDEO) | 421 | if (props) |
| 417 | codec_rate = st->codec->rc_max_rate; | 422 | codec_rate = props->max_bitrate; |
| 418 | else | 423 | else |
| 419 | codec_rate = st->codec->bit_rate; | 424 | codec_rate = st->codec->bit_rate; |
| 420 | 425 | ||