summaryrefslogtreecommitdiff
path: root/libavformat/riffdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavformat/riffdec.c')
-rw-r--r--libavformat/riffdec.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 88e2229a77..edaf146d1c 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -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 */