[libav-devel] [PATCH 3/3] mmf: Restructure (de)muxer to avoid unnecessary ifdefs

Diego Biurrun diego at biurrun.de
Wed Jun 11 15:08:13 CEST 2014


---
 libavformat/mmf.c | 46 ++++++++++++++++++++++------------------------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/libavformat/mmf.c b/libavformat/mmf.c
index 61f1d7a..29224c0 100644
--- a/libavformat/mmf.c
+++ b/libavformat/mmf.c
@@ -33,13 +33,6 @@ typedef struct {
 
 static const int mmf_rates[] = { 4000, 8000, 11025, 22050, 44100 };
 
-static int mmf_rate(int code)
-{
-    if ((code < 0) || (code > 4))
-        return -1;
-    return mmf_rates[code];
-}
-
 #if CONFIG_MMF_MUXER
 static int mmf_rate_code(int rate)
 {
@@ -171,8 +164,29 @@ static int mmf_write_trailer(AVFormatContext *s)
     }
     return 0;
 }
+
+AVOutputFormat ff_mmf_muxer = {
+    .name           = "mmf",
+    .long_name      = NULL_IF_CONFIG_SMALL("Yamaha SMAF"),
+    .mime_type      = "application/vnd.smaf",
+    .extensions     = "mmf",
+    .priv_data_size = sizeof(MMFContext),
+    .audio_codec    = AV_CODEC_ID_ADPCM_YAMAHA,
+    .video_codec    = AV_CODEC_ID_NONE,
+    .write_header   = mmf_write_header,
+    .write_packet   = mmf_write_packet,
+    .write_trailer  = mmf_write_trailer,
+};
 #endif /* CONFIG_MMF_MUXER */
 
+#if CONFIG_MMF_DEMUXER
+static int mmf_rate(int code)
+{
+    if ((code < 0) || (code > 4))
+        return -1;
+    return mmf_rates[code];
+}
+
 static int mmf_probe(AVProbeData *p)
 {
     /* check file header */
@@ -300,7 +314,6 @@ static int mmf_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-#if CONFIG_MMF_DEMUXER
 AVInputFormat ff_mmf_demuxer = {
     .name           = "mmf",
     .long_name      = NULL_IF_CONFIG_SMALL("Yamaha SMAF"),
@@ -310,19 +323,4 @@ AVInputFormat ff_mmf_demuxer = {
     .read_packet    = mmf_read_packet,
     .read_seek      = ff_pcm_read_seek,
 };
-#endif
-
-#if CONFIG_MMF_MUXER
-AVOutputFormat ff_mmf_muxer = {
-    .name           = "mmf",
-    .long_name      = NULL_IF_CONFIG_SMALL("Yamaha SMAF"),
-    .mime_type      = "application/vnd.smaf",
-    .extensions     = "mmf",
-    .priv_data_size = sizeof(MMFContext),
-    .audio_codec    = AV_CODEC_ID_ADPCM_YAMAHA,
-    .video_codec    = AV_CODEC_ID_NONE,
-    .write_header   = mmf_write_header,
-    .write_packet   = mmf_write_packet,
-    .write_trailer  = mmf_write_trailer,
-};
-#endif
+#endif /* CONFIG_MMF_DEMUXER */
-- 
1.8.3.2



More information about the libav-devel mailing list