avformat/riffenc: don't force WAVEFORMATEXTENSIBLE for flt/dbl LPCM

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.
This commit is contained in:
Gyan Doshi 2023-12-21 10:45:58 +05:30
parent 56ca0f2918
commit c1340f3439
5 changed files with 59 additions and 59 deletions

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -1,53 +1,53 @@
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668344 size: 4096
ret: 0 st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668322 size: 4096
ret: 0 st: 0 flags:0 ts: 0.788345
ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278208 size: 4096
ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278186 size: 4096
ret: 0 st: 0 flags:1 ts:-0.317506
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts: 2.576668
ret: 0 st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909128 size: 4096
ret: 0 st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909106 size: 4096
ret: 0 st:-1 flags:1 ts: 1.470835
ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518992 size: 4096
ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518970 size: 4096
ret: 0 st: 0 flags:0 ts: 0.365011
ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128856 size: 4096
ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128834 size: 4096
ret: 0 st: 0 flags:1 ts:-0.740839
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759776 size: 4096
ret: 0 st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759754 size: 4096
ret: 0 st:-1 flags:1 ts: 1.047503
ret: 0 st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369640 size: 4096
ret: 0 st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369618 size: 4096
ret: 0 st: 0 flags:0 ts:-0.058322
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 2.835828
ret: 0 st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000560 size: 4096
ret: 0 st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000538 size: 4096
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610424 size: 4096
ret: 0 st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610402 size: 4096
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220288 size: 4096
ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220266 size: 4096
ret: 0 st: 0 flags:0 ts:-0.481655
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 2.412494
ret: 0 st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851208 size: 4096
ret: 0 st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851186 size: 4096
ret: 0 st:-1 flags:0 ts: 1.306672
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461072 size: 4096
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461050 size: 4096
ret: 0 st:-1 flags:1 ts: 0.200839
ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 70936 size: 4096
ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 70914 size: 4096
ret: 0 st: 0 flags:0 ts:-0.904989
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 1.989184
ret: 0 st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701864 size: 4096
ret: 0 st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701842 size: 4096
ret: 0 st:-1 flags:0 ts: 0.883340
ret: 0 st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311720 size: 4096
ret: 0 st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311698 size: 4096
ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:0 ts: 2.671678
ret: 0 st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942648 size: 4096
ret: 0 st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942626 size: 4096
ret: 0 st: 0 flags:1 ts: 1.565850
ret: 0 st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552512 size: 4096
ret: 0 st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552490 size: 4096
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162368 size: 4096
ret: 0 st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162346 size: 4096
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096

View File

@ -1,53 +1,53 @@
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336608 size: 4096
ret: 0 st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336586 size: 4096
ret: 0 st: 0 flags:0 ts: 0.788345
ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556336 size: 4096
ret: 0 st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556314 size: 4096
ret: 0 st: 0 flags:1 ts:-0.317506
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts: 2.576668
ret: 0 st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818176 size: 4096
ret: 0 st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818154 size: 4096
ret: 0 st:-1 flags:1 ts: 1.470835
ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037904 size: 4096
ret: 0 st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037882 size: 4096
ret: 0 st: 0 flags:0 ts: 0.365011
ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257632 size: 4096
ret: 0 st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257610 size: 4096
ret: 0 st: 0 flags:1 ts:-0.740839
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st:-1 flags:0 ts: 2.153336
ret: 0 st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519472 size: 4096
ret: 0 st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519450 size: 4096
ret: 0 st:-1 flags:1 ts: 1.047503
ret: 0 st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739200 size: 4096
ret: 0 st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739178 size: 4096
ret: 0 st: 0 flags:0 ts:-0.058322
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 2.835828
ret: 0 st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2001040 size: 4096
ret: 0 st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2001018 size: 4096
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220768 size: 4096
ret: 0 st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220746 size: 4096
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440496 size: 4096
ret: 0 st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440474 size: 4096
ret: 0 st: 0 flags:0 ts:-0.481655
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 2.412494
ret: 0 st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702336 size: 4096
ret: 0 st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702314 size: 4096
ret: 0 st:-1 flags:0 ts: 1.306672
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922064 size: 4096
ret: 0 st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922042 size: 4096
ret: 0 st:-1 flags:1 ts: 0.200839
ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141792 size: 4096
ret: 0 st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141770 size: 4096
ret: 0 st: 0 flags:0 ts:-0.904989
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:1 ts: 1.989184
ret: 0 st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403648 size: 4096
ret: 0 st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403626 size: 4096
ret: 0 st:-1 flags:0 ts: 0.883340
ret: 0 st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623360 size: 4096
ret: 0 st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623338 size: 4096
ret: 0 st:-1 flags:1 ts:-0.222493
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096
ret: 0 st: 0 flags:0 ts: 2.671678
ret: 0 st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885216 size: 4096
ret: 0 st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885194 size: 4096
ret: 0 st: 0 flags:1 ts: 1.565850
ret: 0 st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104944 size: 4096
ret: 0 st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104922 size: 4096
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324656 size: 4096
ret: 0 st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324634 size: 4096
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 80 size: 4096
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 58 size: 4096