[FFmpeg-cvslog] lavf: add field for how duration is estimated

Michael Bradshaw git at videolan.org
Mon Jun 18 09:58:38 CEST 2012


ffmpeg | branch: master | Michael Bradshaw <mbradshaw at sorensonmedia.com> | Sun Jun 17 22:20:09 2012 -0700| [2243f0d0783922054d10497fc1d6f6fb376f05ff] | committer: Nicolas George

lavf: add field for how duration is estimated

Signed-off-by: Michael Bradshaw <mbradshaw at sorensonmedia.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2243f0d0783922054d10497fc1d6f6fb376f05ff
---

 libavformat/avformat.h |   17 +++++++++++++++++
 libavformat/options.c  |    5 +++++
 libavformat/utils.c    |    3 +++
 libavformat/version.h  |    4 ++--
 4 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 19441f8..8650b08 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1099,8 +1099,25 @@ typedef struct AVFormatContext {
     int raw_packet_buffer_remaining_size;
 
     int avio_flags;
+
+    /**
+     * The duration field can be estimated through various ways, and this field can be used
+     * to know how the duration was estimated.
+     */
+    enum {
+        AVFMT_DURATION_FROM_PTS,    ///< duration accurately estimated from PTSes
+        AVFMT_DURATION_FROM_STREAM, ///< duration estimated from a stream with a known duration
+        AVFMT_DURATION_FROM_BITRATE ///< duration estimated from bitrate (less accurate)
+    } duration_estimation_method;
 } AVFormatContext;
 
+/**
+ * Returns the method used to set ctx->duration.
+ *
+ * @return AVFMT_DURATION_FROM_PTS, AVFMT_DURATION_FROM_STREAM, or AVFMT_DURATION_FROM_BITRATE.
+ */
+int av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx);
+
 typedef struct AVPacketList {
     AVPacket pkt;
     struct AVPacketList *next;
diff --git a/libavformat/options.c b/libavformat/options.c
index 832d058..b1e8b0d 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -104,6 +104,11 @@ AVFormatContext *avformat_alloc_context(void)
     return ic;
 }
 
+int av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx)
+{
+    return ctx->duration_estimation_method;
+}
+
 const AVClass *avformat_get_class(void)
 {
     return &av_format_context_class;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6ac1292..284cb9f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2228,14 +2228,17 @@ static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
         file_size && ic->pb->seekable) {
         /* get accurate estimate from the PTSes */
         estimate_timings_from_pts(ic, old_offset);
+        ic->duration_estimation_method = AVFMT_DURATION_FROM_PTS;
     } else if (has_duration(ic)) {
         /* at least one component has timings - we use them for all
            the components */
         fill_all_stream_timings(ic);
+        ic->duration_estimation_method = AVFMT_DURATION_FROM_STREAM;
     } else {
         av_log(ic, AV_LOG_WARNING, "Estimating duration from bitrate, this may be inaccurate\n");
         /* less precise: use bitrate info */
         estimate_timings_from_bit_rate(ic);
+        ic->duration_estimation_method = AVFMT_DURATION_FROM_BITRATE;
     }
     update_stream_timings(ic);
 
diff --git a/libavformat/version.h b/libavformat/version.h
index 7042990..cca6c1a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 54
-#define LIBAVFORMAT_VERSION_MINOR  6
-#define LIBAVFORMAT_VERSION_MICRO 101
+#define LIBAVFORMAT_VERSION_MINOR  7
+#define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list