Commit 28fdd7c6 authored by Vittorio Giovara's avatar Vittorio Giovara Committed by James Almer

mvdec: convert to new channel layout API

Signed-off-by: 's avatarVittorio Giovara <vittorio.giovara@gmail.com>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 6bc5485c
...@@ -111,9 +111,7 @@ static int set_channels(AVFormatContext *avctx, AVStream *st, int channels) ...@@ -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); av_log(avctx, AV_LOG_ERROR, "Channel count %d invalid.\n", channels);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
st->codecpar->channels = channels; av_channel_layout_default(&st->codecpar->ch_layout, channels);
st->codecpar->channel_layout = (st->codecpar->channels == 1) ? AV_CH_LAYOUT_MONO
: AV_CH_LAYOUT_STEREO;
return 0; return 0;
} }
...@@ -283,7 +281,7 @@ static void read_index(AVIOContext *pb, AVStream *st) ...@@ -283,7 +281,7 @@ static void read_index(AVIOContext *pb, AVStream *st)
return ; return ;
av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME); av_add_index_entry(st, pos, timestamp, size, 0, AVINDEX_KEYFRAME);
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
timestamp += size / (st->codecpar->channels * 2LL); timestamp += size / (st->codecpar->ch_layout.nb_channels * 2LL);
} else { } else {
timestamp++; timestamp++;
} }
...@@ -402,7 +400,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -402,7 +400,7 @@ static int mv_read_header(AVFormatContext *avctx)
avio_skip(pb, 8); avio_skip(pb, 8);
if (ast) { if (ast) {
av_add_index_entry(ast, pos, timestamp, asize, 0, AVINDEX_KEYFRAME); 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); av_add_index_entry(vst, pos + asize, i, vsize, 0, AVINDEX_KEYFRAME);
} }
...@@ -439,7 +437,7 @@ static int mv_read_header(AVFormatContext *avctx) ...@@ -439,7 +437,7 @@ static int mv_read_header(AVFormatContext *avctx)
ast->codecpar->bits_per_coded_sample); ast->codecpar->bits_per_coded_sample);
ast->codecpar->codec_id = AV_CODEC_ID_NONE; 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"); av_log(avctx, AV_LOG_ERROR, "No valid channel count found.\n");
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment