aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/aiff.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-06-25 21:31:33 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2007-06-25 21:31:33 +0000
commit620d1d787863644912cd8ec8bb8b5e0bcd2c4e3a (patch)
tree1dd202acdc86f50a5c9c374ef6c41578ecc391b1 /libavformat/aiff.c
parent05d00e953f4cc08273fbb5f795f4fdc307140108 (diff)
downloadffmpeg-620d1d787863644912cd8ec8bb8b5e0bcd2c4e3a.tar.gz
support files with COMM chunk after SSND, fix invalid_nocommon.aiff which is spec compliant
Originally committed as revision 9428 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/aiff.c')
-rw-r--r--libavformat/aiff.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libavformat/aiff.c b/libavformat/aiff.c
index af06badd2d..da011ca0bc 100644
--- a/libavformat/aiff.c
+++ b/libavformat/aiff.c
@@ -289,7 +289,8 @@ static int aiff_probe(AVProbeData *p)
static int aiff_read_header(AVFormatContext *s,
AVFormatParameters *ap)
{
- int size, filesize, offset;
+ int size, filesize;
+ offset_t offset = 0;
uint32_t tag;
unsigned version = AIFF_C_VERSION1;
ByteIOContext *pb = &s->pb;
@@ -327,6 +328,8 @@ static int aiff_read_header(AVFormatContext *s,
st->nb_frames = get_aiff_header (pb, st->codec, size, version);
if (st->nb_frames < 0)
return st->nb_frames;
+ if (offset > 0) // COMM is after SSND
+ goto got_sound;
break;
case MKTAG('F', 'V', 'E', 'R'): /* Version chunk */
@@ -352,7 +355,15 @@ static int aiff_read_header(AVFormatContext *s,
case MKTAG('S', 'S', 'N', 'D'): /* Sampled sound chunk */
get_be32(pb); /* Block align... don't care */
offset = get_be32(pb); /* Offset of sound data */
- goto got_sound;
+ offset += url_ftell(pb); /* Compute absolute data offset */
+ if (st->codec->codec_id) /* Assume COMM already parsed */
+ goto got_sound;
+ if (url_is_streamed(pb)) {
+ av_log(s, AV_LOG_ERROR, "file is not seekable\n");
+ return -1;
+ }
+ url_fskip(pb, size - 8);
+ break;
default: /* Jump */
if (size & 1) /* Always even aligned */
@@ -374,7 +385,7 @@ got_sound:
st->duration = st->nb_frames;
/* Position the stream at the first block */
- url_fskip(pb, offset);
+ url_fseek(pb, offset, SEEK_SET);
return 0;
}