From 28fdd7c6cb2ba98934aa2e2ed66d0d396268a1e0 Mon Sep 17 00:00:00 2001 From: Vittorio Giovara Date: Fri, 31 Mar 2017 17:45:53 +0200 Subject: [PATCH] mvdec: convert to new channel layout API Signed-off-by: Vittorio Giovara Signed-off-by: James Almer --- libavformat/mvdec.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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; }