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 | 341 | lpcm_id = LPCM_ID; |
| 342 | 342 | |
| 343 | 343 | for (i = 0; i < ctx->nb_streams; i++) { |
| 344 | + AVCPBProperties *props; | |
| 345 | + | |
| 344 | 346 | st = ctx->streams[i]; |
| 345 | 347 | stream = av_mallocz(sizeof(StreamInfo)); |
| 346 | 348 | if (!stream) |
| @@ -383,8 +385,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx) · 36 unmodified lines | ||
| 383 | 385 | stream->id = h264_id++; |
| 384 | 386 | else |
| 385 | 387 | 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; | |
| 388 | 392 | else { |
| 389 | 393 | av_log(ctx, AV_LOG_WARNING, |
| 390 | 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 | 412 | audio_bitrate = 0; |
| 409 | 413 | video_bitrate = 0; |
| 410 | 414 | for (i = 0; i < ctx->nb_streams; i++) { |
| 415 | + AVCPBProperties *props; | |
| 411 | 416 | int codec_rate; |
| 412 | 417 | st = ctx->streams[i]; |
| 413 | 418 | stream = (StreamInfo *)st->priv_data; |
| 414 | 419 | |
| 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; | |
| 418 | 423 | else |
| 419 | 424 | codec_rate = st->codec->bit_rate; |
| 420 | 425 | |