ByteIOContext *pb = &s->pb;
AVStream *st;
ASFStream *asf_st;
- int size, i, bps;
+ int size, i;
INT64 gsize;
av_set_pts_info(s, 32, 1, 1000); /* 32 bit pts in ms */
asf->packet_size = asf->hdr.max_pktsize;
asf->nb_packets = asf->hdr.packets_count;
} else if (!memcmp(&g, &stream_header, sizeof(GUID))) {
- int type, id, total_size;
+ int type, total_size;
unsigned int tag1;
INT64 pos1, pos2;
st->codec.codec_type = type;
st->codec.frame_rate = 1000000; // us
if (type == CODEC_TYPE_AUDIO) {
- id = get_le16(pb);
- st->codec.codec_tag = id;
- st->codec.channels = get_le16(pb);
- st->codec.sample_rate = get_le32(pb);
- st->codec.bit_rate = get_le32(pb) * 8;
- st->codec.block_align = get_le16(pb); /* block align */
- bps = get_le16(pb); /* bits per sample */
- st->codec.codec_id = wav_codec_get_id(id, bps);
- size = get_le16(pb);
- if (size > 0) {
- st->extra_data = av_mallocz(size);
- get_buffer(pb, st->extra_data, size);
- st->extra_data_size = size;
- }
+ get_wav_header(pb, &st->codec, 1);
/* We have to init the frame size at some point .... */
pos2 = url_ftell(pb);
if (gsize > (pos2 + 8 - pos1 + 24)) {
ByteIOContext *pb = &s->pb;
UINT32 tag, tag1;
int codec_type, stream_index, size, frame_period, bit_rate;
- int i, bps;
+ int i;
AVStream *st;
/* check RIFF header */
url_fskip(pb, size - 5 * 4);
break;
case CODEC_TYPE_AUDIO:
- tag1 = get_le16(pb);
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_tag = tag1;
-#ifdef DEBUG
- printf("audio: 0x%x\n", tag1);
-#endif
- st->codec.channels = get_le16(pb);
- st->codec.sample_rate = get_le32(pb);
- st->codec.bit_rate = get_le32(pb) * 8;
- get_le16(pb); /* block align */
- bps = get_le16(pb);
- st->codec.codec_id = wav_codec_get_id(tag1, bps);
- url_fskip(pb, size - 4 * 4);
+ get_wav_header(pb, &st->codec, (size >= 18));
break;
default:
url_fskip(pb, size);
/*
* WAV encoder and decoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
{ CODEC_ID_PCM_MULAW, 0x07 },
{ CODEC_ID_ADPCM_MS, 0x02 },
{ CODEC_ID_ADPCM_IMA_WAV, 0x11 },
+ { CODEC_ID_WMAV1, 0x160 },
+ { CODEC_ID_WMAV2, 0x161 },
{ 0, 0 },
};
return hdrsize;
}
+void get_wav_header(ByteIOContext *pb, AVCodecContext *codec,
+ int has_extra_data)
+{
+ int id, bps, size;
+
+ id = get_le16(pb);
+ codec->codec_type = CODEC_TYPE_AUDIO;
+ codec->codec_tag = id;
+ codec->fourcc = id;
+ codec->channels = get_le16(pb);
+ codec->sample_rate = get_le32(pb);
+ codec->bit_rate = get_le32(pb) * 8;
+ codec->block_align = get_le16(pb);
+ bps = get_le16(pb); /* bits per sample */
+ codec->codec_id = wav_codec_get_id(id, bps);
+ if (has_extra_data) {
+ size = get_le16(pb);
+ if (size > 0) {
+ codec->extradata = av_mallocz(size);
+ get_buffer(pb, codec->extradata, size);
+ codec->extradata_size = size;
+ }
+ }
+}
+
+
int wav_codec_get_id(unsigned int tag, int bps)
{
int id;
int size;
unsigned int tag;
ByteIOContext *pb = &s->pb;
- unsigned int id, channels, rate, bit_rate, extra_size, bps;
- unsigned int blkalign;
AVStream *st;
/* check RIFF header */
size = find_tag(pb, MKTAG('f', 'm', 't', ' '));
if (size < 0)
return -1;
- id = get_le16(pb);
- channels = get_le16(pb);
- rate = get_le32(pb);
- bit_rate = get_le32(pb) * 8;
- blkalign = get_le16(pb); /* block align */
- bps = get_le16(pb); /* bits per sample */
- if (size >= 18) {
- /* wav_extra_size */
- extra_size = get_le16(pb);
- /* skip unused data */
- url_fseek(pb, size - 18, SEEK_CUR);
- }
-
- size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
- if (size < 0)
- return -1;
-
- /* now we are ready: build format streams */
st = av_new_stream(s, 0);
if (!st)
return AVERROR_NOMEM;
- st->codec.codec_type = CODEC_TYPE_AUDIO;
- st->codec.codec_tag = id;
- st->codec.codec_id = wav_codec_get_id(id, bps);
- st->codec.channels = channels;
- st->codec.sample_rate = rate;
- st->codec.block_align = blkalign;
+ get_wav_header(pb, &st->codec, (size >= 18));
+
+ size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
+ if (size < 0)
+ return -1;
return 0;
}