aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/iff.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-09-07 15:28:07 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-09-22 14:11:34 -0400
commit1993c6849cf93f90066e4490c1547e2db845050c (patch)
tree6c757f1d06676daaf7bf59085a22aa256eeb41cd /libavformat/iff.c
parentfda459cee7a4227c34dfbc5dca1427c00d0d792e (diff)
downloadffmpeg-1993c6849cf93f90066e4490c1547e2db845050c.tar.gz
8svx/iff: fix decoding of compressed stereo 8svx files.
Make the iff demuxer send the whole audio chunk to the decoder as a single packet and move stereo interleaving from the iff demuxer to the decoder. Based on a patch by Stefano Sabatini. git.videolan.org/ffmpeg.git commit e280a4da2ae6fd44f0079358ecc5aa08e388a5ed
Diffstat (limited to 'libavformat/iff.c')
-rw-r--r--libavformat/iff.c45
1 files changed, 5 insertions, 40 deletions
diff --git a/libavformat/iff.c b/libavformat/iff.c
index f388ca9e32..8f309b95dd 100644
--- a/libavformat/iff.c
+++ b/libavformat/iff.c
@@ -59,8 +59,6 @@
#define RIGHT 4
#define STEREO 6
-#define PACKET_SIZE 1024
-
typedef enum {
COMP_NONE,
COMP_FIB,
@@ -76,22 +74,9 @@ typedef struct {
uint64_t body_pos;
uint32_t body_size;
uint32_t sent_bytes;
- 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++;
- }
-}
-
/* Metadata string read */
static int get_metadata(AVFormatContext *s,
const char *const tag,
@@ -278,40 +263,20 @@ static int iff_read_packet(AVFormatContext *s,
{
IffDemuxContext *iff = s->priv_data;
AVIOContext *pb = s->pb;
- AVStream *st = s->streams[0];
int ret;
if(iff->sent_bytes >= iff->body_size)
- return AVERROR(EIO);
-
- if(st->codec->channels == 2) {
- uint8_t sample_buffer[PACKET_SIZE];
+ return AVERROR_EOF;
- ret = avio_read(pb, sample_buffer, PACKET_SIZE);
- if(av_new_packet(pkt, PACKET_SIZE) < 0) {
- av_log(s, AV_LOG_ERROR, "cannot allocate packet\n");
- return AVERROR(ENOMEM);
- }
- interleave_stereo(sample_buffer, pkt->data, PACKET_SIZE);
- } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- ret = av_get_packet(pb, pkt, iff->body_size);
- } else {
- ret = av_get_packet(pb, pkt, PACKET_SIZE);
- }
+ ret = av_get_packet(pb, pkt, iff->body_size);
+ if (ret < 0)
+ return ret;
if(iff->sent_bytes == 0)
pkt->flags |= AV_PKT_FLAG_KEY;
+ iff->sent_bytes = iff->body_size;
- if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- iff->sent_bytes += PACKET_SIZE;
- } else {
- iff->sent_bytes = iff->body_size;
- }
pkt->stream_index = 0;
- if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- pkt->pts = iff->audio_frame_count;
- iff->audio_frame_count += ret / st->codec->channels;
- }
return ret;
}