Browse code

Merge commit '8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca'

* commit '8bcadaacc2b8dc3c5d6569835a5ca20e62d3efca':
mpegenc: use the CPB props side data

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>

Hendrik Leppkes authored on 2015/12/17 21:55:39
Showing 1 changed files
... ...
@@ -338,6 +338,8 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
338 338
     lpcm_id = LPCM_ID;
339 339
 
340 340
     for (i = 0; i < ctx->nb_streams; i++) {
341
+        AVCPBProperties *props;
342
+
341 343
         st     = ctx->streams[i];
342 344
         stream = av_mallocz(sizeof(StreamInfo));
343 345
         if (!stream)
... ...
@@ -389,8 +391,10 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
389 389
                 stream->id = h264_id++;
390 390
             else
391 391
                 stream->id = mpv_id++;
392
-            if (st->codec->rc_buffer_size)
393
-                stream->max_buffer_size = 6 * 1024 + st->codec->rc_buffer_size / 8;
392
+
393
+            props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL);
394
+            if (props && props->buffer_size)
395
+                stream->max_buffer_size = 6 * 1024 + props->buffer_size / 8;
394 396
             else {
395 397
                 av_log(ctx, AV_LOG_WARNING,
396 398
                        "VBV buffer size not set, using default size of 130KB\n"
... ...
@@ -422,13 +426,14 @@ static av_cold int mpeg_mux_init(AVFormatContext *ctx)
422 422
     audio_bitrate = 0;
423 423
     video_bitrate = 0;
424 424
     for (i = 0; i < ctx->nb_streams; i++) {
425
+        AVCPBProperties *props;
425 426
         int codec_rate;
426 427
         st     = ctx->streams[i];
427 428
         stream = (StreamInfo *)st->priv_data;
428 429
 
429
-        if (st->codec->rc_max_rate ||
430
-            st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
431
-            codec_rate = st->codec->rc_max_rate;
430
+        props = (AVCPBProperties*)av_stream_get_side_data(st, AV_PKT_DATA_CPB_PROPERTIES, NULL);
431
+        if (props)
432
+            codec_rate = props->max_bitrate;
432 433
         else
433 434
             codec_rate = st->codec->bit_rate;
434 435