Add AIFF-C subformats for twos,in24,in32,42ni,23ni#916
Conversation
Added new option --force-aiff-c-format=FORMAT
| ; /* nothing to do, we already default to big-endian */ | ||
| } | ||
| else { | ||
| flac__utils_printf(stderr, 1, "%s: ERROR: can't handle AIFF-C compression type \"%c%c%c%c\"\n", e->inbasefilename, (char)(xx>>24), (char)((xx>>16)&8), (char)((xx>>8)&8), (char)(xx&8)); |
There was a problem hiding this comment.
This & 8 seems to be a very old bug, all the way from the original implementation in 2005 (commit 15acb69).
It would print either a NUL character or a BS (backspace) character.
I added get_printable_char() to avoid printing garbage characters to the terminal or log file, as this could potentially be exploited in some way wit, e.g. unicode right-to-left override or escape sequence.
| if(!generate_unsigned_raw(fn, channels, bits_per_sample/8, nsamples[samples])) | ||
| return 1; | ||
| if(bits_per_sample <= 24) { | ||
| /* unsigned 32 bps raw does not work */ |
There was a problem hiding this comment.
The raw unsigned test fails for 32 bits per sample. Note that I increased it to 32 and the max value tested was only up to 24 before.
| : Instruct the decoder to output an AIFF-C file with format NONE and | ||
| sowt respectively. | ||
|
|
||
| **\--force-aiff-c-format**={none\|sowt\|twos\|in24\|42ni\|in32\|23ni} |
There was a problem hiding this comment.
Other format types would be 'raw ', but seems to be very rarely used.
'in16'/'61ni' is another one for 16-bit audio, which seems to be used only internally in CoreAudio, but very rarely in actual AIFF-C files.
|
raw is 8-bit signed. Easily produced with |
I had it initially, but decided to not include it, due to it being rare, and its endianess is ambigious beyond 8 bits. You have to have both encode and decode support, otherwise foreign metadata is not able to restore the original file back. |
But I realized now this contradicts the findings here: https://hydrogenaudio.org/index.php/topic,127436.25.html If flac is going to support 'raw ', it should be unsigned then, to atleast keep in sync with afconvert. I can push another commit with these changes. The problem then becomes if there is ever a need to support both signed and unsigned for 'raw '. If so that means flac must store some additional metadata, since there is nothing itself in the AIFF-C format (and flac's foreign metadata of it) that can recover the signedness of the audio. |
|
1: you are right I was dumb, 2: what about ... something that does the bit depth for the user?
Thanks for arresting thoughtless swiney me being too dumb to think twice. raw is 8-bit unsigned like WAVE 8-bit (but unlike the traditional AIFF which like AU/SND writes 8-bit as signed). .
Also, what is the capitalization in the AIFF files? |
Yes, it is a good idea. I was more thinking of a =le and =be syntax, since it is not obvious what =ni and =in stands for.
But then what if you want 'twos' instead of 'NONE'? And 'raw ' for 8 bit, or if you don't want 'raw '. Seems we need some kind of profile mapping for this, e.g. a list of preferred AIFC compression types and what bits they should be used for. (There's also 'in16'/'61ni' for 16-bits, but I don't want to promote or make flac legitimate its usage further.)
Only 'NONE' is upper-case, everything else is (supposedly) lower-case. |
|
Uh-oh, stop press. According to https://developer.apple.com/documentation/avfaudio/avaudiocommonformat/pcmformatint16 QuickTime doc does not cite endianness for these. It does for twos and sowt. Of course when https://developer.apple.com/standards/qtff-2001.pdf was issued, endianness would default to Big. But now there is a source saying native. Also here is how ffmpeg mishandled little-endian in24 in .mov. Of course AIFC lacks the QuickTime format's endianness atom: https://trac.ffmpeg.org/ticket/1881 This found by asking AI engines to get a pseudo-confirmation on what is supposed to be right about 8-bit ... this was a byproduct. |
An interesting point. When ffmpeg does a codec copy, does it also retain the 'enda' chunk? So you could for example have two .mov files with 'in24', and 'enda' specified as little-endian in one and big-endian in the other. A plain codec copy would copy the data as-is, but one file would for sure be interpreted wrongly in most (if not all) players and software. Unless ffmpeg switches from 'in24' to '42ni' for one file? The main purpose of doing this in flac is to increase interoperability with existing tools (e.g. sox, ffmpeg, libsndfile), and if they all agree that 'in24' is big-endian and '42ni' is little-endian, then that problem is solved, as it has already become the de facto standard way to write AIFF-C files. |
Added new option --force-aiff-c-format=FORMAT