From: Vittorio Giovara <vittorio.giov...@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com>
Signed-off-by: Anton Khirnov <an...@khirnov.net>
Signed-off-by: James Almer <jamr...@gmail.com>
---
 libavformat/flvdec.c | 15 +++++----------
 libavformat/flvenc.c | 10 +++++-----
 2 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index b9e36b3ff1..cb24b1cc26 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -629,10 +629,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
                     } else if (!strcmp(key, "audiosamplesize") && apar) {
                         apar->bits_per_coded_sample = num_val;
                     } else if (!strcmp(key, "stereo") && apar) {
-                        apar->channels       = num_val + 1;
-                        apar->channel_layout = apar->channels == 2 ?
-                                               AV_CH_LAYOUT_STEREO :
-                                               AV_CH_LAYOUT_MONO;
+                        av_channel_layout_default(&apar->ch_layout, num_val + 
1);
                     } else if (!strcmp(key, "width") && vpar) {
                         vpar->width = num_val;
                     } else if (!strcmp(key, "height") && vpar) {
@@ -1202,12 +1199,10 @@ retry_duration:
         sample_rate = 44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >>
                                 FLV_AUDIO_SAMPLERATE_OFFSET) >> 3;
         bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8;
-        if (!st->codecpar->channels || !st->codecpar->sample_rate ||
+        if (!av_channel_layout_check(&st->codecpar->ch_layout) ||
+            !st->codecpar->sample_rate ||
             !st->codecpar->bits_per_coded_sample) {
-            st->codecpar->channels              = channels;
-            st->codecpar->channel_layout        = channels == 1
-                                               ? AV_CH_LAYOUT_MONO
-                                               : AV_CH_LAYOUT_STEREO;
+            av_channel_layout_default(&st->codecpar->ch_layout, channels);
             st->codecpar->sample_rate           = sample_rate;
             st->codecpar->bits_per_coded_sample = bits_per_coded_sample;
         }
@@ -1217,7 +1212,7 @@ retry_duration:
             flv->last_sample_rate =
             sample_rate           = st->codecpar->sample_rate;
             flv->last_channels    =
-            channels              = st->codecpar->channels;
+            channels              = st->codecpar->ch_layout.nb_channels;
         } else {
             AVCodecParameters *par = avcodec_parameters_alloc();
             if (!par) {
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 66c530a2ff..429732297d 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -138,7 +138,7 @@ static int get_audio_flags(AVFormatContext *s, 
AVCodecParameters *par)
                    "FLV only supports wideband (16kHz) Speex audio\n");
             return AVERROR(EINVAL);
         }
-        if (par->channels != 1) {
+        if (par->ch_layout.nb_channels != 1) {
             av_log(s, AV_LOG_ERROR, "FLV only supports mono Speex audio\n");
             return AVERROR(EINVAL);
         }
@@ -178,7 +178,7 @@ error:
         }
     }
 
-    if (par->channels > 1)
+    if (par->ch_layout.nb_channels > 1)
         flags |= FLV_STEREO;
 
     switch (par->codec_id) {
@@ -342,7 +342,7 @@ static void write_metadata(AVFormatContext *s, unsigned int 
ts)
         put_amf_double(pb, flv->audio_par->codec_id == AV_CODEC_ID_PCM_U8 ? 8 
: 16);
 
         put_amf_string(pb, "stereo");
-        put_amf_bool(pb, flv->audio_par->channels == 2);
+        put_amf_bool(pb, flv->audio_par->ch_layout.nb_channels == 2);
 
         put_amf_string(pb, "audiocodecid");
         put_amf_double(pb, flv->audio_par->codec_tag);
@@ -507,8 +507,8 @@ static void flv_write_codec_header(AVFormatContext* s, 
AVCodecParameters* par, i
             if (!par->extradata_size && (flv->flags & 
FLV_AAC_SEQ_HEADER_DETECT)) {
                 PutBitContext pbc;
                 int samplerate_index;
-                int channels = flv->audio_par->channels
-                        - (flv->audio_par->channels == 8 ? 1 : 0);
+                int channels = flv->audio_par->ch_layout.nb_channels
+                        - (flv->audio_par->ch_layout.nb_channels == 8 ? 1 : 0);
                 uint8_t data[2];
 
                 for (samplerate_index = 0; samplerate_index < 16;
-- 
2.34.1

_______________________________________________
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