[FFmpeg-cvslog] avformat/nutenc: add mode that omits the index

Michael Niedermayer git at videolan.org
Thu May 29 04:12:29 CEST 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 29 03:32:44 2014 +0200| [82beb46e65e5f820b187355bf757725c22a59c45] | committer: Michael Niedermayer

avformat/nutenc: add mode that omits the index

When the index is not written, several data tables become unneeded,
reducing memory and cpu requirements.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 doc/muxers.texi      |    2 ++
 libavformat/nut.h    |    1 +
 libavformat/nutenc.c |    5 ++++-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index c1cf186..ce9d110 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -717,6 +717,8 @@ Change the syncpoint usage in nut:
 @item @var{timestamped} extend the syncpoint with a wallclock field.
 @end table
 The @var{none} and @var{timestamped} flags are experimental.
+ at item -write_index @var{bool}
+Write index at the end, the default is to write an index.
 @end table
 
 @example
diff --git a/libavformat/nut.h b/libavformat/nut.h
index d7a462e..943081c 100644
--- a/libavformat/nut.h
+++ b/libavformat/nut.h
@@ -106,6 +106,7 @@ typedef struct NUTContext {
     AVRational *time_base;
     struct AVTreeNode *syncpoints;
     int sp_count;
+    int write_index;
     int64_t max_pts;
     AVRational *max_pts_tb;
 #define NUT_BROADCAST 1 // use extended syncpoints
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
index 74ba1e8..0bed15a 100644
--- a/libavformat/nutenc.c
+++ b/libavformat/nutenc.c
@@ -1019,6 +1019,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
         put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
 
+        if (nut->write_index) {
         if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0)
             return ret;
 
@@ -1032,6 +1033,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
                 for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++)
                     nus->keyframe_pts[j] = AV_NOPTS_VALUE;
         }
+        }
     }
     av_assert0(nus->last_pts != AV_NOPTS_VALUE);
 
@@ -1157,7 +1159,7 @@ static int nut_write_trailer(AVFormatContext *s)
         write_headers(s, bc);
 
     ret = avio_open_dyn_buf(&dyn_bc);
-    if (ret >= 0 && nut->sp_count) {
+    if (ret >= 0 && nut->sp_count && nut->write_index) {
         write_index(nut, dyn_bc);
         put_packet(nut, bc, dyn_bc, 1, INDEX_STARTCODE);
     }
@@ -1180,6 +1182,7 @@ static const AVOption options[] = {
     { "default",     "",                                                0,             AV_OPT_TYPE_CONST, {.i64 = 0},             INT_MIN, INT_MAX, E, "syncpoints" },
     { "none",        "Disable syncpoints, low overhead and unseekable", 0,             AV_OPT_TYPE_CONST, {.i64 = NUT_PIPE},      INT_MIN, INT_MAX, E, "syncpoints" },
     { "timestamped", "Extend syncpoints with a wallclock timestamp",    0,             AV_OPT_TYPE_CONST, {.i64 = NUT_BROADCAST}, INT_MIN, INT_MAX, E, "syncpoints" },
+    { "write_index", "Write index",                               OFFSET(write_index), AV_OPT_TYPE_INT,   {.i64 = 1},                   0,       1, E, },
     { NULL },
 };
 



More information about the ffmpeg-cvslog mailing list