[FFmpeg-devel] [PATCH] play aiff without common tag

Reimar Döffinger Reimar.Doeffinger
Mon Jun 25 17:51:59 CEST 2007


Hello,
attached patch fixes
http://samples.mplayerhq.hu/AIFF/invalid_nocommon.aiff.
While according to the specification says this file invalid I think it
is preferable to support it anyway, esp. because leaving values
uninitialized and even causing a division by zero is really bad anyway
(and it even leaves e.g. MPlayer thinking this is a video file...).

Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/aiff.c
===================================================================
--- libavformat/aiff.c	(revision 9424)
+++ libavformat/aiff.c	(working copy)
@@ -108,7 +108,6 @@
     if (size & 1)
         size++;
 
-    codec->codec_type = CODEC_TYPE_AUDIO;
     codec->channels = get_be16(pb);
     num_frames = get_be32(pb);
     codec->bits_per_sample = get_be16(pb);
@@ -138,12 +137,6 @@
     if (!codec->codec_id)
         return AVERROR_INVALIDDATA;
 
-    /* Block align needs to be computed in all cases, as the definition
-     * is specific to applications -> here we use the WAVE format definition */
-    codec->block_align = (codec->bits_per_sample * codec->channels) >> 3;
-
-    codec->bit_rate = codec->sample_rate * (codec->block_align << 3);
-
     /* Chunk is over */
     if (size)
         url_fseek(pb, size, SEEK_CUR);
@@ -312,6 +305,11 @@
     st = av_new_stream(s, 0);
     if (!st)
         return AVERROR_NOMEM;
+    st->codec->codec_type = CODEC_TYPE_AUDIO;
+    st->codec->codec_id = CODEC_ID_PCM_S16BE;
+    st->codec->bits_per_sample = 16;
+    st->codec->sample_rate = 11025;
+    st->codec->channels = 2;
 
     while (filesize > 0) {
         /* parse different chunks */
@@ -365,6 +363,11 @@
     return AVERROR_INVALIDDATA;
 
 got_sound:
+    /* Block align needs to be computed in all cases, as the definition
+     * is specific to applications -> here we use the WAVE format definition */
+    st->codec->block_align = (st->codec->bits_per_sample * st->codec->channels) >> 3;
+    st->codec->bit_rate = st->codec->sample_rate * (st->codec->block_align << 3);
+
     /* Now positioned, get the sound data start and end */
     if (st->nb_frames)
         s->file_size = st->nb_frames * st->codec->block_align;



More information about the ffmpeg-devel mailing list