diff mbox series

[FFmpeg-devel] avformat/wavdec: change ch_layout used av_channel_layout_default.

Message ID 20240508092453.97376-1-hiccupzhu@gmail.com
State New
Headers show
Series [FFmpeg-devel] avformat/wavdec: change ch_layout used av_channel_layout_default. | expand

Commit Message

Hiccup Zhu May 8, 2024, 9:24 a.m. UTC
Signed-off-by: shiqizhu <hiccupzhu@gmail.com>
---
 libavformat/wavdec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Marton Balint May 8, 2024, 7:41 p.m. UTC | #1
On Wed, 8 May 2024, shiqizhu wrote:

> Signed-off-by: shiqizhu <hiccupzhu@gmail.com>
> ---
> libavformat/wavdec.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index 00856a5eca..9060796c81 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -233,8 +233,7 @@ static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream *st)
>         avio_skip(pb, 3);
>     }
>     av_channel_layout_uninit(&st->codecpar->ch_layout);
> -    st->codecpar->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
> -    st->codecpar->ch_layout.nb_channels = channels;
> +    av_channel_layout_default(&st->codecpar->ch_layout, channels);

Why do you assume that the default layout is suitable here? A demuxer 
should not guess the channel layout, if the format does not provide any 
information about it.

Regards,
Marton
diff mbox series

Patch

diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 00856a5eca..9060796c81 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -233,8 +233,7 @@  static int wav_parse_xma2_tag(AVFormatContext *s, int64_t size, AVStream *st)
         avio_skip(pb, 3);
     }
     av_channel_layout_uninit(&st->codecpar->ch_layout);
-    st->codecpar->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
-    st->codecpar->ch_layout.nb_channels = channels;
+    av_channel_layout_default(&st->codecpar->ch_layout, channels);
 
     if (st->codecpar->ch_layout.nb_channels <= 0 || st->codecpar->sample_rate <= 0)
         return AVERROR_INVALIDDATA;