[FFmpeg-cvslog] LAVFAPI: demuxer specific options.

Michael Niedermayer git at videolan.org
Sat Apr 30 22:08:52 CEST 2011


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Apr 30 21:35:48 2011 +0200| [492026209b9b58eaf6d2ea56423f6b1e1a8a76a5] | committer: Michael Niedermayer

LAVFAPI: demuxer specific options.
(someone please add doxy)
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavformat/avformat.h |    5 +++++
 libavformat/utils.c    |   24 ++++++++++++++++++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 28b0574..db48a57 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -423,6 +423,8 @@ typedef struct AVInputFormat {
     const AVMetadataConv *metadata_conv;
 #endif
 
+    const AVClass *priv_class; ///< AVClass for the private context
+
     /* private fields */
     struct AVInputFormat *next;
 } AVInputFormat;
@@ -726,6 +728,7 @@ typedef struct AVFormatContext {
 #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_RTP_HINT     0x0040 ///< Add RTP hinting to the output file
 #define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
+#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted)
 
     int loop_input;
 
@@ -1040,6 +1043,8 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
                        int buf_size,
                        AVFormatParameters *ap);
 
+int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap);
+
 /**
  * Allocate an AVFormatContext.
  * avformat_free_context() can be used to free the context and everything
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 493c563..7f82d2d 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -429,6 +429,10 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
             err = AVERROR(ENOMEM);
             goto fail;
         }
+        if (fmt->priv_class) {
+            *(const AVClass**)ic->priv_data= fmt->priv_class;
+            av_opt_set_defaults(ic->priv_data);
+        }
     } else {
         ic->priv_data = NULL;
     }
@@ -437,13 +441,13 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
     if (ic->pb)
         ff_id3v2_read(ic, ID3v2_DEFAULT_MAGIC);
 
-    if (ic->iformat->read_header) {
+    if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && ic->iformat->read_header) {
         err = ic->iformat->read_header(ic, ap);
         if (err < 0)
             goto fail;
     }
 
-    if (pb && !ic->data_offset)
+    if (!(ic->flags&AVFMT_FLAG_PRIV_OPT) && pb && !ic->data_offset)
         ic->data_offset = avio_tell(ic->pb);
 
     ic->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE;
@@ -470,6 +474,22 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
     return err;
 }
 
+int av_demuxer_open(AVFormatContext *ic, AVFormatParameters *ap){
+    int err;
+
+    if (ic->iformat->read_header) {
+        err = ic->iformat->read_header(ic, ap);
+        if (err < 0)
+            return err;
+    }
+
+    if (ic->pb && !ic->data_offset)
+        ic->data_offset = avio_tell(ic->pb);
+
+    return 0;
+}
+
+
 /** size of probe buffer, for guessing file type from file contents */
 #define PROBE_BUF_MIN 2048
 #define PROBE_BUF_MAX (1<<20)



More information about the ffmpeg-cvslog mailing list