[FFmpeg-devel] [PATCH] avformat/riffenc: don't force WAVEFORMATEXTENSIBLE for flt/dbl LPCM
Gyan Doshi
ffmpeg at gyani.pro
Thu Dec 21 09:14:04 EET 2023
2c2a167ca7 forced WAVEFORMATEXTENSIBLE for all LPCM streams with greater
than 16 bits per sample. However, WAVEFORMATEX allows IEEE Float samples
or any depth where raw depth == coded depth, see Remarks section at
https://learn.microsoft.com/en-us/windows/win32/api/mmreg/ns-mmreg-waveformatex
and samples M1F1-float32-AFsp, M1F1-float64-AFsp at
https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/Samples.html
There are hardware devices and likely software players requiring float samples
that fail to qualify files with WAVEFORMATEXTENSIBLE headers.
---
libavformat/riffenc.c | 2 +-
tests/ref/acodec/pcm-f32le | 4 ++--
tests/ref/acodec/pcm-f64le | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libavformat/riffenc.c b/libavformat/riffenc.c
index 3325419b94..8accb69541 100644
--- a/libavformat/riffenc.c
+++ b/libavformat/riffenc.c
@@ -81,7 +81,7 @@ int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb,
av_channel_layout_compare(&par->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO)) ||
par->sample_rate > 48000 ||
par->codec_id == AV_CODEC_ID_EAC3 || par->codec_id == AV_CODEC_ID_DFPWM ||
- av_get_bits_per_sample(par->codec_id) > 16;
+ (av_get_bits_per_sample(par->codec_id) > 16 && par->codec_tag != 0x0003);
if (waveformatextensible)
avio_wl16(pb, 0xfffe);
diff --git a/tests/ref/acodec/pcm-f32le b/tests/ref/acodec/pcm-f32le
index c0fdd70cd2..c63a2c4b70 100644
--- a/tests/ref/acodec/pcm-f32le
+++ b/tests/ref/acodec/pcm-f32le
@@ -1,4 +1,4 @@
-653d82a64b7bd96ac193e105e9f92d4c *tests/data/fate/acodec-pcm-f32le.wav
-2116880 tests/data/fate/acodec-pcm-f32le.wav
+03ae40a19deacaca6e0c4ec08dd35956 *tests/data/fate/acodec-pcm-f32le.wav
+2116858 tests/data/fate/acodec-pcm-f32le.wav
95e54b261530a1bcf6de6fe3b21dc5f6 *tests/data/fate/acodec-pcm-f32le.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
diff --git a/tests/ref/acodec/pcm-f64le b/tests/ref/acodec/pcm-f64le
index 5c90e7bbbd..894d593ac1 100644
--- a/tests/ref/acodec/pcm-f64le
+++ b/tests/ref/acodec/pcm-f64le
@@ -1,4 +1,4 @@
-48b4cd378f47a50dc902aa03cc8280ed *tests/data/fate/acodec-pcm-f64le.wav
-4233680 tests/data/fate/acodec-pcm-f64le.wav
+69ffdb079600c53a00c5b0119b586a98 *tests/data/fate/acodec-pcm-f64le.wav
+4233658 tests/data/fate/acodec-pcm-f64le.wav
95e54b261530a1bcf6de6fe3b21dc5f6 *tests/data/fate/acodec-pcm-f64le.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
--
2.39.1
More information about the ffmpeg-devel
mailing list