[1/2] movenc: Add an AVClass for setting muxer specific options

Message ID 1306332296-13566-1-git-send-email-martin@martin.st
State Committed
Commit 91e3a25ef6de2efcbea38ec0f6ffd3f8785962a2
Headers show

Commit Message

Martin Storsjö May 25, 2011, 2:04 p.m.
---
Changed to only use one single AVClass, since all the muxers
have the same options anyway, as suggested by Anton.

 libavformat/movenc.c |   18 ++++++++++++++++++
 libavformat/movenc.h |    1 +
 2 files changed, 19 insertions(+), 0 deletions(-)

Comments

Gil Pedersen May 25, 2011, 4:08 p.m. | #1
On 25/05/2011, at 16.04, Martin Storsjö wrote:

> Changed to only use one single AVClass, since all the muxers
> have the same options anyway, as suggested by Anton.

Won't this make "ffmpeg -h" display the exact same AVOptions 5 times?

/Gil
Martin Storsjö May 25, 2011, 4:12 p.m. | #2
On Wed, 25 May 2011, Gil Pedersen wrote:

> On 25/05/2011, at 16.04, Martin Storsjö wrote:
> 
> > Changed to only use one single AVClass, since all the muxers
> > have the same options anyway, as suggested by Anton.
> 
> Won't this make "ffmpeg -h" display the exact same AVOptions 5 times?

Yes, that's right. That's not much different from how it was in the 
previous patch iteration though, where it was manually added to 6 
different muxers, and the options are relevant to at least 4 of them, as 
we discussed earlier.

// Martin

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 52c775a..550b957 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -32,10 +32,22 @@ 
 #include "libavcodec/put_bits.h"
 #include "internal.h"
 #include "libavutil/avstring.h"
+#include "libavutil/opt.h"
 
 #undef NDEBUG
 #include <assert.h>
 
+static const AVOption options[] = {
+    { NULL },
+};
+
+static const AVClass mov_muxer_class = {
+    .class_name = "MOV/3GP/MP4/3G2 muxer",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 //FIXME support 64 bit variant with wide placeholders
 static int64_t updateSize(AVIOContext *pb, int64_t pos)
 {
@@ -2285,6 +2297,7 @@  AVOutputFormat ff_mov_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_TGP_MUXER
@@ -2301,6 +2314,7 @@  AVOutputFormat ff_tgp_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_MP4_MUXER
@@ -2317,6 +2331,7 @@  AVOutputFormat ff_mp4_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_PSP_MUXER
@@ -2333,6 +2348,7 @@  AVOutputFormat ff_psp_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_TG2_MUXER
@@ -2349,6 +2365,7 @@  AVOutputFormat ff_tg2_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
 #if CONFIG_IPOD_MUXER
@@ -2365,5 +2382,6 @@  AVOutputFormat ff_ipod_muxer = {
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
     .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0},
+    .priv_class = &mov_muxer_class,
 };
 #endif
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 0cc1eb8..6e2b5b7 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -101,6 +101,7 @@  typedef struct MOVIndex {
 } MOVTrack;
 
 typedef struct MOVMuxContext {
+    const AVClass *av_class;
     int     mode;
     int64_t time;
     int     nb_streams;