[FFmpeg-devel] [PATCH 1/5] avformat: add codec_time_base

Michael Niedermayer michaelni at gmx.at
Wed Jun 18 21:35:02 CEST 2014


This is unambigously the codec timebase, while AVStream.time_base
changes its meaning when avpriv_set_pts_info() is called

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/avformat.h |    8 ++++++++
 libavformat/mux.c      |    1 +
 2 files changed, 9 insertions(+)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index a2cea10..50508cc 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1065,6 +1065,14 @@ typedef struct AVStream {
      */
     int inject_global_side_data;
 
+    /**
+     * Internal copy of the codec timebase.
+     * This is used instead of AVStream.time_base in muxers because
+     * AVStream.time_base has multiple meanings depending on if the use is
+     * before or after avpriv_set_pts_info()
+     */
+    AVRational codec_time_base;
+
 } AVStream;
 
 AVRational av_stream_get_r_frame_rate(const AVStream *s);
diff --git a/libavformat/mux.c b/libavformat/mux.c
index afdeca1..d90f133 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -248,6 +248,7 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
     for (i = 0; i < s->nb_streams; i++) {
         st    = s->streams[i];
         codec = st->codec;
+        st->codec_time_base = codec->time_base;
 
 #if FF_API_LAVF_CODEC_TB
 FF_DISABLE_DEPRECATION_WARNINGS
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list