[FFmpeg-devel] [PATCH] Pass VBV delay to the calling application via ctx

Christophe Massiot massiot
Thu Feb 10 16:38:03 CET 2011


VBV delay is useful for T-STD compliance in some TS muxers. It is
certainly possible to retrieve it by parsing the output of FFmpeg, but
getting it from the context makes it simpler and less error-prone.

This version exports a uint64_t based on the periods of a 27 MHz clock.
---
 doc/APIchanges             |    3 +++
 libavcodec/avcodec.h       |    7 +++++++
 libavcodec/mpegvideo_enc.c |    1 +
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index e7cd1c1..7a4957c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2009-03-08
 
 API changes, most recent first:
 
+2011-02-10 - xxxxxxx - lavc 52.110.0 - vbv_delay
+  Add vbv_delay field to AVCodecContext
+
 2011-02-08 - xxxxxxx - lavf 52.98.0 - av_probe_input_buffer
   Add av_probe_input_buffer() to avformat.h for probing format from a
   ByteIOContext.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 09f0a12..5b33427 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2845,6 +2845,13 @@ typedef struct AVCodecContext {
     int64_t pts_correction_last_pts;       /// PTS of the last frame
     int64_t pts_correction_last_dts;       /// DTS of the last frame
 
+    /**
+     * VBV delay coded in the last frame (in periods of a 27 MHz clock).
+     * Used for compliant TS muxing.
+     * - encoding: Set by libavcodec.
+     * - decoding: unused.
+     */
+    uint64_t vbv_delay;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 6167a9b..a7f1608 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1381,6 +1381,7 @@ vbv_retry:
             s->vbv_delay_ptr[1]  = vbv_delay>>5;
             s->vbv_delay_ptr[2] &= 0x07;
             s->vbv_delay_ptr[2] |= vbv_delay<<3;
+            avctx->vbv_delay = vbv_delay*300;
         }
         s->total_bits += s->frame_bits;
         avctx->frame_bits  = s->frame_bits;
-- 
1.7.1




More information about the ffmpeg-devel mailing list