[FFmpeg-devel] [PATCH] avformat: add AVFMT_FULLREAD for standalone subtitles formats

Clément Bœsch u at pkh.me
Thu Oct 23 23:45:19 CEST 2014


---
Requested by wm4, who is concerned about opening a thousands of
subtitles files at once.

I'm a bit concerned about the fact that the avio is not closed until
later.
---
 doc/APIchanges               | 5 +++++
 libavformat/aqtitledec.c     | 1 +
 libavformat/assdec.c         | 1 +
 libavformat/avformat.h       | 4 +++-
 libavformat/jacosubdec.c     | 1 +
 libavformat/lrcdec.c         | 3 ++-
 libavformat/microdvddec.c    | 1 +
 libavformat/mpl2dec.c        | 1 +
 libavformat/mpsubdec.c       | 1 +
 libavformat/pjsdec.c         | 1 +
 libavformat/realtextdec.c    | 1 +
 libavformat/samidec.c        | 1 +
 libavformat/srtdec.c         | 1 +
 libavformat/subviewer1dec.c  | 1 +
 libavformat/subviewerdec.c   | 1 +
 libavformat/tedcaptionsdec.c | 1 +
 libavformat/version.h        | 2 +-
 libavformat/vplayerdec.c     | 1 +
 libavformat/webvttdec.c      | 1 +
 19 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index ec9fe06..7ee9c3a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,11 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2014-10-xx - xxxxxxx - lavc 56.11.100 - avformat.h
+  Add AVFMT_FULLREAD to indicates demuxer that after opening no further
+  accesses to the avio API are made (in other term, not reading the file
+  anymore). This is typically used for standalone subtitles files.
+
 2014-10-xx - xxxxxxx - lavc 56.5.0 - avcodec.h
   Replace AVCodecContext.time_base used for decoding
   with AVCodecContext.framerate.
diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c
index 9508766..a0a7391 100644
--- a/libavformat/aqtitledec.c
+++ b/libavformat/aqtitledec.c
@@ -145,4 +145,5 @@ AVInputFormat ff_aqtitle_demuxer = {
     .read_close     = aqt_read_close,
     .extensions     = "aqt",
     .priv_class     = &aqt_class,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/assdec.c b/libavformat/assdec.c
index ccbf4c0..bf7d7e4 100644
--- a/libavformat/assdec.c
+++ b/libavformat/assdec.c
@@ -184,4 +184,5 @@ AVInputFormat ff_ass_demuxer = {
     .read_packet    = ass_read_packet,
     .read_close     = ass_read_close,
     .read_seek2     = ass_read_seek,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index f21a1d6..c162cfb 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -445,6 +445,7 @@ typedef struct AVProbeData {
                                         */
 
 #define AVFMT_SEEK_TO_PTS   0x4000000 /**< Seeking is based on PTS */
+#define AVFMT_FULLREAD      0x8000000 /**< Demuxer will read the full file at opening and will not do any other file access later */
 
 /**
  * @addtogroup lavf_encoding
@@ -577,7 +578,8 @@ typedef struct AVInputFormat {
     /**
      * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
      * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
-     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
+     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS,
+     * AVFMT_FULLREAD.
      */
     int flags;
 
diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 9a28870..783fc1c 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -268,4 +268,5 @@ AVInputFormat ff_jacosub_demuxer = {
     .read_packet    = jacosub_read_packet,
     .read_seek2     = jacosub_read_seek,
     .read_close     = jacosub_read_close,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/lrcdec.c b/libavformat/lrcdec.c
index df61853..23856d7 100644
--- a/libavformat/lrcdec.c
+++ b/libavformat/lrcdec.c
@@ -244,5 +244,6 @@ AVInputFormat ff_lrc_demuxer = {
     .read_header    = lrc_read_header,
     .read_packet    = lrc_read_packet,
     .read_close     = lrc_read_close,
-    .read_seek2     = lrc_read_seek
+    .read_seek2     = lrc_read_seek,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
index ce3433c..6a5ba08 100644
--- a/libavformat/microdvddec.c
+++ b/libavformat/microdvddec.c
@@ -200,4 +200,5 @@ AVInputFormat ff_microdvd_demuxer = {
     .read_seek2     = microdvd_read_seek,
     .read_close     = microdvd_read_close,
     .priv_class     = &microdvd_class,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/mpl2dec.c b/libavformat/mpl2dec.c
index 260b7be..02291d5 100644
--- a/libavformat/mpl2dec.c
+++ b/libavformat/mpl2dec.c
@@ -143,4 +143,5 @@ AVInputFormat ff_mpl2_demuxer = {
     .read_seek2     = mpl2_read_seek,
     .read_close     = mpl2_read_close,
     .extensions     = "txt,mpl2",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/mpsubdec.c b/libavformat/mpsubdec.c
index eddc594..1bf9160 100644
--- a/libavformat/mpsubdec.c
+++ b/libavformat/mpsubdec.c
@@ -141,4 +141,5 @@ AVInputFormat ff_mpsub_demuxer = {
     .read_seek2     = mpsub_read_seek,
     .read_close     = mpsub_read_close,
     .extensions     = "sub",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/pjsdec.c b/libavformat/pjsdec.c
index 5129b70..c6447ee 100644
--- a/libavformat/pjsdec.c
+++ b/libavformat/pjsdec.c
@@ -135,4 +135,5 @@ AVInputFormat ff_pjs_demuxer = {
     .read_seek2     = pjs_read_seek,
     .read_close     = pjs_read_close,
     .extensions     = "pjs",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/realtextdec.c b/libavformat/realtextdec.c
index 19af108..5c93190 100644
--- a/libavformat/realtextdec.c
+++ b/libavformat/realtextdec.c
@@ -153,4 +153,5 @@ AVInputFormat ff_realtext_demuxer = {
     .read_seek2     = realtext_read_seek,
     .read_close     = realtext_read_close,
     .extensions     = "rt",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/samidec.c b/libavformat/samidec.c
index 4dbf2cf..fecec1d 100644
--- a/libavformat/samidec.c
+++ b/libavformat/samidec.c
@@ -137,4 +137,5 @@ AVInputFormat ff_sami_demuxer = {
     .read_seek2     = sami_read_seek,
     .read_close     = sami_read_close,
     .extensions     = "smi,sami",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c
index 02d75f1..5b602a5 100644
--- a/libavformat/srtdec.c
+++ b/libavformat/srtdec.c
@@ -171,4 +171,5 @@ AVInputFormat ff_srt_demuxer = {
     .read_packet = srt_read_packet,
     .read_seek2  = srt_read_seek,
     .read_close  = srt_read_close,
+    .flags       = AVFMT_FULLREAD,
 };
diff --git a/libavformat/subviewer1dec.c b/libavformat/subviewer1dec.c
index 6b38533..f7b14e3 100644
--- a/libavformat/subviewer1dec.c
+++ b/libavformat/subviewer1dec.c
@@ -121,4 +121,5 @@ AVInputFormat ff_subviewer1_demuxer = {
     .read_seek2     = subviewer1_read_seek,
     .read_close     = subviewer1_read_close,
     .extensions     = "sub",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/subviewerdec.c b/libavformat/subviewerdec.c
index f1b0fdf..3b62abc 100644
--- a/libavformat/subviewerdec.c
+++ b/libavformat/subviewerdec.c
@@ -191,4 +191,5 @@ AVInputFormat ff_subviewer_demuxer = {
     .read_seek2     = subviewer_read_seek,
     .read_close     = subviewer_read_close,
     .extensions     = "sub",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c
index 68063fa..494e356 100644
--- a/libavformat/tedcaptionsdec.c
+++ b/libavformat/tedcaptionsdec.c
@@ -363,4 +363,5 @@ AVInputFormat ff_tedcaptions_demuxer = {
     .read_close     = tedcaptions_read_close,
     .read_probe     = tedcaptions_read_probe,
     .read_seek2     = tedcaptions_read_seek,
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/version.h b/libavformat/version.h
index f54f445..af49ffa 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
-#define LIBAVFORMAT_VERSION_MINOR  10
+#define LIBAVFORMAT_VERSION_MINOR  11
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/libavformat/vplayerdec.c b/libavformat/vplayerdec.c
index 619ccfd..18473ff 100644
--- a/libavformat/vplayerdec.c
+++ b/libavformat/vplayerdec.c
@@ -125,4 +125,5 @@ AVInputFormat ff_vplayer_demuxer = {
     .read_seek2     = vplayer_read_seek,
     .read_close     = vplayer_read_close,
     .extensions     = "txt",
+    .flags          = AVFMT_FULLREAD,
 };
diff --git a/libavformat/webvttdec.c b/libavformat/webvttdec.c
index e457e8f..ddcc6f1 100644
--- a/libavformat/webvttdec.c
+++ b/libavformat/webvttdec.c
@@ -220,4 +220,5 @@ AVInputFormat ff_webvtt_demuxer = {
     .read_close     = webvtt_read_close,
     .extensions     = "vtt",
     .priv_class     = &webvtt_demuxer_class,
+    .flags          = AVFMT_FULLREAD,
 };
-- 
2.1.2



More information about the ffmpeg-devel mailing list