Mercurial > libavformat.hg
comparison riff.c @ 1738:67e4f8b8f2df libavformat
add waveformatextensible support
author | bcoudurier |
---|---|
date | Thu, 25 Jan 2007 21:56:06 +0000 |
parents | 8b062c65fe0d |
children | 15462a5de747 |
comparison
equal
deleted
inserted
replaced
1737:8d3489fa8a92 | 1738:67e4f8b8f2df |
---|---|
420 codec->block_align = get_le16(pb); | 420 codec->block_align = get_le16(pb); |
421 if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */ | 421 if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */ |
422 codec->bits_per_sample = 8; | 422 codec->bits_per_sample = 8; |
423 }else | 423 }else |
424 codec->bits_per_sample = get_le16(pb); | 424 codec->bits_per_sample = get_le16(pb); |
425 codec->codec_id = wav_codec_get_id(id, codec->bits_per_sample); | 425 if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */ |
426 | 426 int cbSize = get_le16(pb); /* cbSize */ |
427 if (size > 16) { /* We're obviously dealing with WAVEFORMATEX */ | 427 size -= 18; |
428 codec->extradata_size = get_le16(pb); | 428 cbSize = FFMIN(size, cbSize); |
429 if (codec->extradata_size > 0) { | 429 if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */ |
430 if (codec->extradata_size > size - 18) | 430 codec->bits_per_sample = get_le16(pb); |
431 codec->extradata_size = size - 18; | 431 get_le32(pb); /* dwChannelMask */ |
432 id = get_le32(pb); /* 4 first bytes of GUID */ | |
433 url_fskip(pb, 12); /* skip end of GUID */ | |
434 cbSize -= 22; | |
435 size -= 22; | |
436 } | |
437 codec->extradata_size = cbSize; | |
438 if (cbSize > 0) { | |
432 codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); | 439 codec->extradata = av_mallocz(codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
433 get_buffer(pb, codec->extradata, codec->extradata_size); | 440 get_buffer(pb, codec->extradata, codec->extradata_size); |
434 } else | 441 size -= cbSize; |
435 codec->extradata_size = 0; | 442 } |
436 | 443 |
437 /* It is possible for the chunk to contain garbage at the end */ | 444 /* It is possible for the chunk to contain garbage at the end */ |
438 if (size - codec->extradata_size - 18 > 0) | 445 if (size > 0) |
439 url_fskip(pb, size - codec->extradata_size - 18); | 446 url_fskip(pb, size); |
440 } | 447 } |
448 codec->codec_id = wav_codec_get_id(id, codec->bits_per_sample); | |
441 } | 449 } |
442 | 450 |
443 | 451 |
444 int wav_codec_get_id(unsigned int tag, int bps) | 452 int wav_codec_get_id(unsigned int tag, int bps) |
445 { | 453 { |