[FFmpeg-devel] [PATCH] libavcodec/mpegaudio_parser.c: differentiate MPEG audio dual mono

Scott Theisen scott.the.elm at gmail.com
Sat Nov 30 09:38:54 EET 2024


On 11/25/24 00:42, Anton Khirnov wrote:
> Quoting Scott Theisen (2024-11-14 05:37:49)
>> @@ -85,7 +85,13 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
>>                       if (s->header_count > header_threshold) {
>>                           avctx->sample_rate= sr;
>>                           av_channel_layout_uninit(&avctx->ch_layout);
>> -                        av_channel_layout_default(&avctx->ch_layout, channels);
>> +                        if (dual_mono) {
>> +                            av_channel_layout_custom_init(&avctx->ch_layout, 2);
> This can fail - the return code should be checked.
>

It can only fail if av_calloc() fails to allocate 48 bytes.  Should it 
return buf_size or just use the default order?
```
if (dual_mono && (av_channel_layout_custom_init(&avctx->ch_layout, 2) == 
0)) {
     avctx->ch_layout.u.map[0].id = AV_CHAN_FRONT_CENTER;
     avctx->ch_layout.u.map[1].id = AV_CHAN_FRONT_CENTER;
} else {
     av_channel_layout_default(&avctx->ch_layout, channels);
}
```

Regards,

Scott Theisen


More information about the ffmpeg-devel mailing list