diff options
author | Jai Menon <realityman@gmx.net> | 2008-05-09 11:25:27 +0000 |
---|---|---|
committer | Robert Swain <robert.swain@gmail.com> | 2008-05-09 11:25:27 +0000 |
commit | 86b2d47fc0475797d21fcc868fb0f675c9d96ba8 (patch) | |
tree | e671d9a9aee867c3999fd648c173004ae1450bd7 | |
parent | c38e75fc52159a5369ff0516ce55d0cbddbdc18f (diff) | |
download | ffmpeg-86b2d47fc0475797d21fcc868fb0f675c9d96ba8.tar.gz |
IFF stereo support
Patch by Jai Menon ( realityman gmx net )
Originally committed as revision 13097 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/iff.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libavformat/iff.c b/libavformat/iff.c index f6fd4e9ee0..39fc6d8efe 100644 --- a/libavformat/iff.c +++ b/libavformat/iff.c @@ -60,6 +60,19 @@ typedef struct { uint32_t audio_frame_count; } IffDemuxContext; + +static void interleave_stereo(const uint8_t *src, uint8_t *dest, int size) +{ + uint8_t *end = dest + size; + size = size>>1; + + while(dest < end) { + *dest++ = *src; + *dest++ = *(src+size); + src++; + } +} + static int iff_probe(AVProbeData *p) { const uint8_t *d = p->buf; @@ -152,7 +165,20 @@ static int iff_read_packet(AVFormatContext *s, if(iff->sent_bytes > iff->body_size) return AVERROR(EIO); - ret = av_get_packet(pb, pkt, PACKET_SIZE); + + if(s->streams[0]->codec->channels == 2) { + uint8_t sample_buffer[PACKET_SIZE]; + + ret = get_buffer(pb, sample_buffer, PACKET_SIZE); + if(av_new_packet(pkt, PACKET_SIZE) < 0) { + av_log(s, AV_LOG_ERROR, "iff: cannot allocate packet \n"); + return AVERROR(ENOMEM); + } + interleave_stereo(sample_buffer, pkt->data, PACKET_SIZE); + } + else { + ret = av_get_packet(pb, pkt, PACKET_SIZE); + } if(iff->sent_bytes == 0) pkt->flags |= PKT_FLAG_KEY; |