On Wed, 22 May 2024, Lynne via ffmpeg-devel wrote:

On 21/05/2024 23:33, Hendrik Leppkes wrote:
 On Tue, May 21, 2024 at 9:52 PM Lynne via ffmpeg-devel
 <ffmpeg-devel@ffmpeg.org> wrote:


 It should be the case here, we shouldn't need reordering as NATIVE just
 lets you specify what order the elements appear in the bitstream.

 NATIVE means "the FFmpeg native ordering", not "bitstream order".
 CUSTOM lets you specify an arbitrary order but requires metadata to
 that effect, but it makes it particularly hard to map to any standard
 when playing or transcoding, so some efforts to try to unify it into a
 NATIVE format is always appreciated if possible.

Right, I forgot about that, thanks.
Amended in my git repo to use Marton's code.



ret = av_channel_layout_custom_init(&ac->oc[1].ch_layout, nb_channels);
if (ret < 0)
    return ret;

for (int i = 0; i < nb_channels; i++) {
    AVChannelCustom *cm = &ac->oc[1].ch_layout.u.map[i];
    cm->id = usac_ch_pos_to_av[get_bits(gb, 5)]; /* bsOutputChannelPos */
    if (cm->id)
        cm->id = AV_CHAN_UNKNOWN;

if (cm->id == AV_CHAN_NONE)
    cm->id = AV_CHAN_UNKNOWN;

}

ret = av_channel_layout_retype(&ac->oc[1].ch_layout,
                               AV_CHANNEL_ORDER_NATIVE,
                               AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL);

You can simply pass 0 instead of AV_CHANNEL_ORDER_NATIVE as the order parameter, because AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL automatically uses the canonical order and ignores the order parameter.

if (ret < 0)
    return ret;

av_channel_layout_copy(&avctx->ch_layout, &ac->oc[1].ch_layout);

Missing error check.

Thanks,
Marton
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to