This field is used for exporting an encoding value to library users,
and it is valid only for mpeg12video. It should not be global,
so make it available only throught the appropriate AVOption.

Signed-off-by: Vittorio Giovara <[email protected]>
---
I am undecided whether this should be exported with a side data
or if this is so codec specific that an exported option is enough.
Opinions?
Vittorio

 libavcodec/avcodec.h       | 8 ++++----
 libavcodec/mpeg12enc.c     | 5 ++++-
 libavcodec/mpegvideo.h     | 1 +
 libavcodec/mpegvideo_enc.c | 5 +++++
 libavcodec/version.h       | 3 +++
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8c635d7..ae32995 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2859,13 +2859,13 @@ typedef struct AVCodecContext {
     int error_rate;
 #endif
 
+#if FF_API_VBVDELAY_EXP
     /**
-     * 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.
+     * @deprecated use the exported AVOption instead
      */
+    attribute_deprecated
     uint64_t vbv_delay;
+#endif
 
 #if FF_API_SIDEDATA_ONLY_PKT
     /**
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 6171678..b67e549 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1050,7 +1050,10 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
     { "drop_frame_timecode", "Timecode is in drop frame format.",             \
       OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, \
     { "scan_offset",         "Reserve space for SVCD scan offset user data.", \
-      OFFSET(scan_offset),         AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
+      OFFSET(scan_offset),         AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, \
+    { "vbv_delay",           "Output option containing the VBV delay coded in 
the last frame (in periods of a 27 MHz clock).", \
+      OFFSET(vbv_delay),           AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 0, \
+      VE | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, \
 
 static const AVOption mpeg1_options[] = {
     COMMON_OPTS
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 52c6f91..323808c 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -431,6 +431,7 @@ typedef struct MpegEncContext {
     int gop_picture_number;  ///< index of the first picture of a GOP based on 
fake_pic_num & mpeg1 specific
     int last_mv_dir;         ///< last mv_dir, used for b frame encoding
     uint8_t *vbv_delay_ptr;  ///< pointer to vbv_delay in the bitstream
+    uint64_t vbv_delay;      ///< VBV delay coded in the last frame (in 
periods of a 27 MHz clock)
 
     /* MPEG-2-specific - I wished not to have to support this mess. */
     int progressive_sequence;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 862d07f..b9a43a8 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1761,7 +1761,12 @@ vbv_retry:
             s->vbv_delay_ptr[1]  = vbv_delay >> 5;
             s->vbv_delay_ptr[2] &= 0x07;
             s->vbv_delay_ptr[2] |= vbv_delay << 3;
+            s->vbv_delay         = vbv_delay * 300;
+#if FF_API_VBVDELAY_EXP
+FF_DISABLE_DEPRECATION_WARNINGS
             avctx->vbv_delay     = vbv_delay * 300;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
         }
         s->total_bits     += s->frame_bits;
         avctx->frame_bits  = s->frame_bits;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index ecd6e1d..8b4ac74 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -165,5 +165,8 @@
 #ifndef FF_API_SIDEDATA_ONLY_PKT
 #define FF_API_SIDEDATA_ONLY_PKT (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_VBVDELAY_EXP
+#define FF_API_VBVDELAY_EXP      (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
-- 
1.9.5 (Apple Git-50.3)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to