sierravmd: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
committed by
James Almer
parent
87e092348b
commit
cd5b4d4ba7
@@ -134,6 +134,7 @@ static int vmd_read_header(AVFormatContext *s)
|
|||||||
/* if sample rate is 0, assume no audio */
|
/* if sample rate is 0, assume no audio */
|
||||||
vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]);
|
vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]);
|
||||||
if (vmd->sample_rate) {
|
if (vmd->sample_rate) {
|
||||||
|
int channels;
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
@@ -150,24 +151,22 @@ static int vmd_read_header(AVFormatContext *s)
|
|||||||
st->codecpar->bits_per_coded_sample = 8;
|
st->codecpar->bits_per_coded_sample = 8;
|
||||||
}
|
}
|
||||||
if (vmd->vmd_header[811] & 0x80) {
|
if (vmd->vmd_header[811] & 0x80) {
|
||||||
st->codecpar->channels = 2;
|
channels = 2;
|
||||||
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
|
|
||||||
} else if (vmd->vmd_header[811] & 0x2) {
|
} else if (vmd->vmd_header[811] & 0x2) {
|
||||||
/* Shivers 2 stereo audio */
|
/* Shivers 2 stereo audio */
|
||||||
/* Frame length is for 1 channel */
|
/* Frame length is for 1 channel */
|
||||||
st->codecpar->channels = 2;
|
channels = 2;
|
||||||
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
|
|
||||||
st->codecpar->block_align = st->codecpar->block_align << 1;
|
st->codecpar->block_align = st->codecpar->block_align << 1;
|
||||||
} else {
|
} else {
|
||||||
st->codecpar->channels = 1;
|
channels = 1;
|
||||||
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
|
|
||||||
}
|
}
|
||||||
|
av_channel_layout_default(&st->codecpar->ch_layout, channels);
|
||||||
st->codecpar->bit_rate = st->codecpar->sample_rate *
|
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 */
|
/* calculate pts */
|
||||||
num = st->codecpar->block_align;
|
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);
|
av_reduce(&num, &den, num, den, (1UL<<31)-1);
|
||||||
if (vst)
|
if (vst)
|
||||||
avpriv_set_pts_info(vst, 33, num, den);
|
avpriv_set_pts_info(vst, 33, num, den);
|
||||||
|
Reference in New Issue
Block a user