diff mbox series

[FFmpeg-devel,107/281] mvdec: convert to new channel layout API

Message ID 20220113015612.448-19-jamrial@gmail.com
State Accepted
Commit 28fdd7c6cb2ba98934aa2e2ed66d0d396268a1e0
Headers show
Series New channel layout API | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 fail Make fate failed
andriy/make_ppc success Make finished
andriy/make_fate_ppc fail Make fate failed

Commit Message

James Almer Jan. 13, 2022, 1:56 a.m. UTC
From: Vittorio Giovara <vittorio.giovara@gmail.com>

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/mvdec.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/mvdec.c b/libavformat/mvdec.c
index 4f233aff5f..b37fe2ce69 100644
--- a/libavformat/mvdec.c
+++ b/libavformat/mvdec.c
@@ -111,9 +111,7 @@  static int set_channels(AVFormatContext *avctx, AVStream *st, int channels)
         av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid.\n", channels);
         return AVERROR_INVALIDDATA;
     }
-    st->codecpar->channels       = channels;
-    st->codecpar->channel_layout = (st->codecpar->channels == 1) ? AV_CH_LAYOUT_MONO
-                                                                 : AV_CH_LAYOUT_STEREO;
+    av_channel_layout_default(&st->codecpar->ch_layout, channels);
     return 0;
 }
 
@@ -283,7 +281,7 @@  static void read_index(AVIOContext *pb, AVStream *st)
             return ;
         av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME);
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
-            timestamp += size / (st->codecpar->channels * 2LL);
+            timestamp += size / (st->codecpar->ch_layout.nb_channels * 2LL);
         } else {
             timestamp++;
         }
@@ -402,7 +400,7 @@  static int mv_read_header(AVFormatContext *avctx)
             avio_skip(pb, 8);
             if (ast) {
                 av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME);
-                timestamp += asize / (ast->codecpar->channels * (uint64_t)bytes_per_sample);
+                timestamp += asize / (ast->codecpar->ch_layout.nb_channels * (uint64_t)bytes_per_sample);
             }
             av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
         }
@@ -439,7 +437,7 @@  static int mv_read_header(AVFormatContext *avctx)
                                       ast->codecpar->bits_per_coded_sample);
                 ast->codecpar->codec_id = AV_CODEC_ID_NONE;
             }
-            if (ast->codecpar->channels <= 0) {
+            if (ast->codecpar->ch_layout.nb_channels <= 0) {
                 av_log(avctx, AV_LOG_ERROR, "No valid channel count found.\n");
                 return AVERROR_INVALIDDATA;
             }