[FFmpeg-devel] [PATCH 144/281] sierravmd: convert to new channel layout API

James Almer jamrial at gmail.com
Thu Jan 13 03:58:01 EET 2022


From: Vittorio Giovara <vittorio.giovara at gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/sierravmd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index e35faae50d..d110457ec9 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -134,6 +134,7 @@ static int vmd_read_header(AVFormatContext *s)
     /* if sample rate is 0, assume no audio */
     vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]);
     if (vmd->sample_rate) {
+        int channels;
         st = avformat_new_stream(s, NULL);
         if (!st)
             return AVERROR(ENOMEM);
@@ -150,24 +151,22 @@ static int vmd_read_header(AVFormatContext *s)
             st->codecpar->bits_per_coded_sample = 8;
         }
         if (vmd->vmd_header[811] & 0x80) {
-            st->codecpar->channels       = 2;
-            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+            channels = 2;
         } else if (vmd->vmd_header[811] & 0x2) {
             /* Shivers 2 stereo audio */
             /* Frame length is for 1 channel */
-            st->codecpar->channels       = 2;
-            st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+            channels        = 2;
             st->codecpar->block_align = st->codecpar->block_align << 1;
         } else {
-            st->codecpar->channels       = 1;
-            st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
+            channels = 1;
         }
+        av_channel_layout_default(&st->codecpar->ch_layout, channels);
         st->codecpar->bit_rate = st->codecpar->sample_rate *
-            st->codecpar->bits_per_coded_sample * st->codecpar->channels;
+            st->codecpar->bits_per_coded_sample * channels;
 
         /* calculate pts */
         num = st->codecpar->block_align;
-        den = st->codecpar->sample_rate * st->codecpar->channels;
+        den = st->codecpar->sample_rate * channels;
         av_reduce(&num, &den, num, den, (1UL<<31)-1);
         if (vst)
             avpriv_set_pts_info(vst, 33, num, den);
-- 
2.34.1



More information about the ffmpeg-devel mailing list