mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-08 10:11:04 +08:00
wavdec: RIFX file format support
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:

committed by
Michael Niedermayer

parent
e8714f6f93
commit
00d7555f34
@@ -80,23 +80,37 @@ static void parse_waveformatex(AVIOContext *pb, AVCodecContext *c)
|
||||
}
|
||||
}
|
||||
|
||||
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
|
||||
/* "big_endian" values are needed for RIFX file format */
|
||||
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size, int big_endian)
|
||||
{
|
||||
int id;
|
||||
|
||||
if (size < 14)
|
||||
avpriv_request_sample(codec, "wav header size < 14");
|
||||
|
||||
id = avio_rl16(pb);
|
||||
codec->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
codec->channels = avio_rl16(pb);
|
||||
codec->sample_rate = avio_rl32(pb);
|
||||
codec->bit_rate = avio_rl32(pb) * 8;
|
||||
codec->block_align = avio_rl16(pb);
|
||||
if (!big_endian) {
|
||||
id = avio_rl16(pb);
|
||||
codec->channels = avio_rl16(pb);
|
||||
codec->sample_rate = avio_rl32(pb);
|
||||
codec->bit_rate = avio_rl32(pb) * 8;
|
||||
codec->block_align = avio_rl16(pb);
|
||||
} else {
|
||||
id = avio_rb16(pb);
|
||||
codec->channels = avio_rb16(pb);
|
||||
codec->sample_rate = avio_rb32(pb);
|
||||
codec->bit_rate = avio_rb32(pb) * 8;
|
||||
codec->block_align = avio_rb16(pb);
|
||||
}
|
||||
if (size == 14) { /* We're dealing with plain vanilla WAVEFORMAT */
|
||||
codec->bits_per_coded_sample = 8;
|
||||
} else
|
||||
codec->bits_per_coded_sample = avio_rl16(pb);
|
||||
} else {
|
||||
if (!big_endian) {
|
||||
codec->bits_per_coded_sample = avio_rl16(pb);
|
||||
} else {
|
||||
codec->bits_per_coded_sample = avio_rb16(pb);
|
||||
}
|
||||
}
|
||||
if (id == 0xFFFE) {
|
||||
codec->codec_tag = 0;
|
||||
} else {
|
||||
@@ -106,6 +120,10 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
|
||||
}
|
||||
if (size >= 18) { /* We're obviously dealing with WAVEFORMATEX */
|
||||
int cbSize = avio_rl16(pb); /* cbSize */
|
||||
if (big_endian) {
|
||||
avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files\n");
|
||||
return AVERROR_PATCHWELCOME;
|
||||
}
|
||||
size -= 18;
|
||||
cbSize = FFMIN(size, cbSize);
|
||||
if (cbSize >= 22 && id == 0xfffe) { /* WAVEFORMATEXTENSIBLE */
|
||||
|
Reference in New Issue
Block a user