[FFmpeg-devel] [PATCH] Obey configure updates for OGG, Matroska, and MOV parsers.

dalecurtis at chromium.org dalecurtis at chromium.org
Tue Apr 10 19:54:57 CEST 2012


From: Dale Curtis <dalecurtis at chromium.org>

Uses #if checks to remove code paths which are invalid or unused
depending on configure options.

Signed-off-by: Dale Curtis <dalecurtis at chromium.org>
---
 libavformat/matroskadec.c |   34 +++++++++++++++++++++++-----------
 libavformat/mov.c         |    4 ++++
 libavformat/oggdec.c      |   10 ++++++++++
 3 files changed, 37 insertions(+), 11 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 6d7401b..b90addf 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -35,13 +35,17 @@
 /* For ff_codec_get_id(). */
 #include "riff.h"
 #include "isom.h"
+#if CONFIG_SIPR_DECODER
 #include "rm.h"
+#endif
 #include "matroska.h"
 #include "libavcodec/mpeg4audio.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avstring.h"
+#if HAVE_LZO1X_999_COMPRESS
 #include "libavutil/lzo.h"
+#endif
 #include "libavutil/dict.h"
 #if CONFIG_ZLIB
 #include <zlib.h>
@@ -1012,6 +1016,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
     switch (encodings[0].compression.algo) {
     case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
         return encodings[0].compression.settings.size;
+#if HAVE_LZO1X_999_COMPRESS
     case MATROSKA_TRACK_ENCODING_COMP_LZO:
         do {
             olen = pkt_size *= 3;
@@ -1022,6 +1027,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
             goto failed;
         pkt_size -= olen;
         break;
+#endif
 #if CONFIG_ZLIB
     case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
         z_stream zstream = {0};
@@ -1463,14 +1469,17 @@ static int matroska_read_header(AVFormatContext *s)
                    "Multiple combined encodings not supported");
         } else if (encodings_list->nb_elem == 1) {
             if (encodings[0].type ||
-                (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
+                (encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP
 #if CONFIG_ZLIB
-                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
+                 && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB
 #endif
 #if CONFIG_BZLIB
-                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
+                 && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB
 #endif
-                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO)) {
+#if HAVE_LZO1X_999_COMPRESS
+                 && encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO
+#endif
+                )) {
                 encodings[0].scope = 0;
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Unsupported encoding type");
@@ -1581,8 +1590,10 @@ static int matroska_read_header(AVFormatContext *s)
         } else if (codec_id == CODEC_ID_RA_144) {
             track->audio.out_samplerate = 8000;
             track->audio.channels = 1;
-        } else if (codec_id == CODEC_ID_RA_288 || codec_id == CODEC_ID_COOK ||
-                   codec_id == CODEC_ID_ATRAC3 || codec_id == CODEC_ID_SIPR) {
+        } else if ((CONFIG_RA_288_DECODER && codec_id == CODEC_ID_RA_288) ||
+                   (CONFIG_COOK_DECODER && codec_id == CODEC_ID_COOK) ||
+                   (CONFIG_ATRAC3_DECODER && codec_id == CODEC_ID_ATRAC3) ||
+                   (CONFIG_SIPR_DECODER && codec_id == CODEC_ID_SIPR)) {
             int flavor;
             ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
                           0, NULL, NULL, NULL, NULL);
@@ -1920,11 +1931,12 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
 
     if (res == 0) {
         for (n = 0; n < laces; n++) {
-            if ((st->codec->codec_id == CODEC_ID_RA_288 ||
-                 st->codec->codec_id == CODEC_ID_COOK ||
-                 st->codec->codec_id == CODEC_ID_SIPR ||
-                 st->codec->codec_id == CODEC_ID_ATRAC3) &&
-                 st->codec->block_align && track->audio.sub_packet_size) {
+            if (((CONFIG_RA_288_DECODER && st->codec->codec_id == CODEC_ID_RA_288) ||
+                 (CONFIG_COOK_DECODER && st->codec->codec_id == CODEC_ID_COOK) ||
+                 (CONFIG_ATRAC3_DECODER && st->codec->codec_id == CODEC_ID_ATRAC3) ||
+                 (CONFIG_SIPR_DECODER && st->codec->codec_id == CODEC_ID_SIPR)) &&
+                st->codec->block_align && track->audio.sub_packet_size) {
+
                 int a = st->codec->block_align;
                 int sps = track->audio.sub_packet_size;
                 int cfs = track->audio.coded_framesize;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index b4ff1df..81ce03f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -570,6 +570,7 @@ static int mov_read_esds(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return ff_mov_read_esds(c->fc, pb, atom);
 }
 
+#if CONFIG_AC3_DEMUXER
 static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     AVStream *st;
@@ -593,6 +594,7 @@ static int mov_read_dac3(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 
     return 0;
 }
+#endif
 
 static int mov_read_chan(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
@@ -2594,7 +2596,9 @@ static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('u','d','t','a'), mov_read_default },
 { MKTAG('w','a','v','e'), mov_read_wave },
 { MKTAG('e','s','d','s'), mov_read_esds },
+#if CONFIG_AC3_DEMUXER
 { MKTAG('d','a','c','3'), mov_read_dac3 }, /* AC-3 info */
+#endif
 { MKTAG('w','i','d','e'), mov_read_wide }, /* place holder */
 { MKTAG('w','f','e','x'), mov_read_wfex },
 { MKTAG('c','m','o','v'), mov_read_cmov },
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index bdd2c5b..731d7f2 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -39,14 +39,24 @@
 
 static const struct ogg_codec * const ogg_codecs[] = {
     &ff_skeleton_codec,
+#if CONFIG_DIRAC_DEMUXER
     &ff_dirac_codec,
+#endif
+#if CONFIG_LIBSPEEX
     &ff_speex_codec,
+#endif
     &ff_vorbis_codec,
     &ff_theora_codec,
+#if CONFIG_FLAC_DEMUXER
     &ff_flac_codec,
+#endif
     &ff_celt_codec,
+#if CONFIG_DIRAC_DEMUXER
     &ff_old_dirac_codec,
+#endif
+#if CONFIG_FLAC_DEMUXER
     &ff_old_flac_codec,
+#endif
     &ff_ogm_video_codec,
     &ff_ogm_audio_codec,
     &ff_ogm_text_codec,
-- 
1.7.7.3



More information about the ffmpeg-devel mailing list