[libav-commits] avf: introduce nobuffer option

Luca Barbato git at libav.org
Sun Jul 29 08:11:25 CEST 2012


Module: libav
Branch: master
Commit: 681ed0009905a088aae2a5caf2308d89aaa80562

Author:    Luca Barbato <lu_zero at gentoo.org>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Thu Jul 26 16:35:12 2012 -0700

avf: introduce nobuffer option

Useful in cases where a significant analyzeduration is
still needed, while minimizing buffering before output.

An example is processing low-latency streams where all
media types won't necessarily come in if the
analyzeduration is small.

Additional changes by Josh Allmann <joshua.allmann at gmail.com>

Signed-off-by: Anton Khirnov <anton at khirnov.net>

---

 doc/APIchanges              |    3 +++
 libavformat/avformat.h      |    1 +
 libavformat/options_table.h |    1 +
 libavformat/utils.c         |   11 ++++++++---
 libavformat/version.h       |    4 ++--
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 8770b6d..058fab6 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-07-xx - xxxxxxx - lavf 54.13.0 - avformat.h
+  Add AVFMT_FLAG_NOBUFFER for low latency use cases.
+
 2012-07-xx - xxxxxxx - lavfi 3.0.0 - avfilter.h
   Add avfilter_unref_bufferp().
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index e292206..7c97ada 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -887,6 +887,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_IGNDTS       0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
 #define AVFMT_FLAG_NOFILLIN     0x0010 ///< Do not infer any values from other values, just return what is stored in the container
 #define AVFMT_FLAG_NOPARSE      0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
+#define AVFMT_FLAG_NOBUFFER     0x0040 ///< Do not buffer frames when possible
 #define AVFMT_FLAG_CUSTOM_IO    0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
 #define AVFMT_FLAG_DISCARD_CORRUPT  0x0100 ///< Discard frames marked corrupted
 
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 58f3dcf..f3384ca 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -40,6 +40,7 @@ static const AVOption options[]={
 {"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
 {"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
 {"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"},
+{"nobuffer", "reduce the latency introduced by optional buffering", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4ec70b7..149913c 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2383,9 +2383,14 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
             break;
         }
 
-        pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end);
-        if ((ret = av_dup_packet(pkt)) < 0)
-            goto find_stream_info_err;
+        if (ic->flags & AVFMT_FLAG_NOBUFFER) {
+            pkt = &pkt1;
+        } else {
+            pkt = add_to_pktbuf(&ic->packet_buffer, &pkt1,
+                                &ic->packet_buffer_end);
+            if ((ret = av_dup_packet(pkt)) < 0)
+                goto find_stream_info_err;
+        }
 
         read_size += pkt->size;
 
diff --git a/libavformat/version.h b/libavformat/version.h
index de6da52..6b7ada8 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 12
-#define LIBAVFORMAT_VERSION_MICRO  1
+#define LIBAVFORMAT_VERSION_MINOR 13
+#define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \



More information about the libav-commits mailing list