1
Support - (fb2k) / Re: Foobar Crashing on Startup
Last post by kilikilimanjaro -Thanks for the help!
Apple Music then reads such file but treats it as 16-bit.Oh, btw, the 24-bit sowt file from earlier (atest-aifc-and-alac-sources) is also treated as 16-bit and comes longer and heavily distorted.
As for ffmpeg, it is easier to conclude that ffmpeg does wrong things, when it writes files it cannot read.I can make it produce correct 24-bit aif file, in the sense that sndfile-convert can read and convert it properly. To do that I added the mapping between S24LE codec and "sowt" tag in libavformat/aiff.c:
{ AV_CODEC_ID_PCM_S16BE, MKTAG('t','w','o','s') },Apple Music then reads such file but treats it as 16-bit. Without additional modifications ffmpeg also treats it at 16-bit.
{ AV_CODEC_ID_PCM_S16LE, MKTAG('s','o','w','t') },
+ { AV_CODEC_ID_PCM_S24LE, MKTAG('s','o','w','t') },
{ AV_CODEC_ID_ADPCM_IMA_QT, MKTAG('i','m','a','4') },
{ AV_CODEC_ID_QDMC, MKTAG('Q','D','M','C') },
const AVCodecTag ff_codec_aiff_tags[] = {This is handled in libavformat/aiffdec.c:
{ AV_CODEC_ID_PCM_S16BE, MKTAG('N','O','N','E') },
{ AV_CODEC_ID_PCM_S8, MKTAG('N','O','N','E') },
{ AV_CODEC_ID_PCM_U8, MKTAG('r','a','w',' ') },
{ AV_CODEC_ID_PCM_S24BE, MKTAG('N','O','N','E') },
{ AV_CODEC_ID_PCM_S32BE, MKTAG('N','O','N','E') },
...
{ AV_CODEC_ID_PCM_S16LE, MKTAG('s','o','w','t') },
{ AV_CODEC_ID_PCM_S24LE, MKTAG('s','o','w','t') }, // <--- added by me
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag); // <--- AFor files with "NONE" it will first (A) find S16BE codec regardless of the actual bit-depth, because S16BE is the first entry with "NONE" in the map. Then (B) it will get proper S__BE codec based on the actual bit-depth field from the file.
...
if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample); // <--- B
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);