[2/2] movenc: Deprecate the global RTP hinting flag, use a private AVOption instead

Message ID 1306332296-13566-2-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö May 25, 2011, 2:04 p.m.
Instead of -fflags rtphint, set -movflags rtphint instead.
---
 libavformat/avformat.h |    4 +++-
 libavformat/movenc.c   |   12 +++++++++++-
 libavformat/movenc.h   |    4 ++++
 libavformat/options.c  |    4 +++-
 libavformat/version.h  |    3 +++
 5 files changed, 24 insertions(+), 3 deletions(-)

Comments

Anton Khirnov May 25, 2011, 2:33 p.m. | #1
On Wed, 25 May 2011 17:04:56 +0300, Martin Storsjö <martin@martin.st> wrote:
> Instead of -fflags rtphint, set -movflags rtphint instead.
> ---
>  libavformat/avformat.h |    4 +++-
>  libavformat/movenc.c   |   12 +++++++++++-
>  libavformat/movenc.h   |    4 ++++
>  libavformat/options.c  |    4 +++-
>  libavformat/version.h  |    3 +++
>  5 files changed, 24 insertions(+), 3 deletions(-)
> 

Both patches look fine to me.

--
Anton Khirnov

Patch

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3d4cc68..fab9609 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -718,7 +718,9 @@  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_RTP_HINT     0x0040 ///< Add RTP hinting to the output file
+#if FF_API_FLAG_RTP_HINT
+#define AVFMT_FLAG_RTP_HINT     0x0040 ///< Deprecated, use the -movflags rtphint muxer specific AVOption instead
+#endif
 
     int loop_input;
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 550b957..2b6539d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -38,6 +38,8 @@ 
 #include <assert.h>
 
 static const AVOption options[] = {
+    { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+    { "rtphint", "Add RTP hint tracks", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { NULL },
 };
 
@@ -2124,7 +2126,15 @@  static int mov_write_header(AVFormatContext *s)
     if (mov->mode & (MODE_MOV|MODE_IPOD) && s->nb_chapters)
         mov->chapter_track = mov->nb_streams++;
 
+#if FF_API_FLAG_RTP_HINT
     if (s->flags & AVFMT_FLAG_RTP_HINT) {
+        av_log(s, AV_LOG_WARNING, "The RTP_HINT flag is deprecated, enable it "
+                                  "via the -movflags rtphint muxer option "
+                                  "instead.\n");
+        mov->flags |= FF_MOV_FLAG_RTP_HINT;
+    }
+#endif
+    if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
         /* Add hint tracks for each audio and video stream */
         hint_track = mov->nb_streams;
         for (i = 0; i < s->nb_streams; i++) {
@@ -2220,7 +2230,7 @@  static int mov_write_header(AVFormatContext *s)
     if (mov->chapter_track)
         mov_create_chapter_track(s, mov->chapter_track);
 
-    if (s->flags & AVFMT_FLAG_RTP_HINT) {
+    if (mov->flags & FF_MOV_FLAG_RTP_HINT) {
         /* Initialize the hint tracks for each audio and video stream */
         for (i = 0; i < s->nb_streams; i++) {
             AVStream *st = s->streams[i];
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 6e2b5b7..69b6621 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -109,8 +109,12 @@  typedef struct MOVMuxContext {
     int64_t mdat_pos;
     uint64_t mdat_size;
     MOVTrack *tracks;
+
+    int flags;
 } MOVMuxContext;
 
+#define FF_MOV_FLAG_RTP_HINT 1
+
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
 
 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index);
diff --git a/libavformat/options.c b/libavformat/options.c
index 22807c3..97a398e 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -49,7 +49,9 @@  static const AVOption options[]={
 {"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"},
 {"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"},
 {"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"},
-{"rtphint", "add rtp hinting", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"},
+#if FF_API_FLAG_RTP_HINT
+{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"},
+#endif
 {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D},
diff --git a/libavformat/version.h b/libavformat/version.h
index 63f4191..e43c98e 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -68,5 +68,8 @@ 
 #ifndef FF_API_SDP_CREATE
 #define FF_API_SDP_CREATE              (LIBAVFORMAT_VERSION_MAJOR < 54)
 #endif
+#ifndef FF_API_FLAG_RTP_HINT
+#define FF_API_FLAG_RTP_HINT           (LIBAVFORMAT_VERSION_MAJOR < 54)
+#endif
 
 #endif /* AVFORMAT_VERSION_H */