[FFmpeg-devel] [PATCH 4/5] avutil/channel_layout: add av_channel_layout_retype()

James Almer jamrial at gmail.com
Sat Feb 3 15:24:33 EET 2024


On 2/3/2024 7:38 AM, Anton Khirnov wrote:
> Quoting James Almer (2024-02-02 13:56:31)
>> I wrote a function like this some time ago, but i lost the patch by
>> accident during a migration.
>>
>> The way i approached it was making the return codes reflect if the
>> conversion was lossless or not, as in, custom -> native is lossless only
>> if channels have no custom names (and possible only if the ids are
>> within UINT64_MAX and in order).
> 
>> Anything to Unspec is always lossy, etc.
> 
> Unless the source is custom with every channel unknown.

True, and Unspec -> Custom is possible by doing the inverse.

> 
>> Custom -> Ambi: Possible only if it contains ambi channels. Lossless.
>> Custom -> Native: Possible only if has no ambi channels and all ids < 64
>> and in order. Lossy if it has custom names, otherwise lossless.
>> Ambi -> Custom: Lossless.
>> Ambi -> Native: Not possible.
>> Native -> Custom: Lossless.
>> Native -> Ambi: Not possible.
>> Any -> Unspec: Possible but lossy.
>>
>> So 0 for lossless, 1 for lossy, ENOSYS for not possible.
> 
> That sounds good to me.
> 
> Might also have a flags argument that forces lossless, and for future
> extensions.

Agree.


More information about the ffmpeg-devel mailing list