mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-05-15 01:08:30 +00:00
ogg: convert to new channel layout API
Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com> Signed-off-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
f81417a6d2
commit
5b51e6771c
5 changed files with 11 additions and 10 deletions
|
@ -64,7 +64,7 @@ static int celt_header(AVFormatContext *s, int idx)
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_CELT;
|
st->codecpar->codec_id = AV_CODEC_ID_CELT;
|
||||||
st->codecpar->sample_rate = sample_rate;
|
st->codecpar->sample_rate = sample_rate;
|
||||||
st->codecpar->channels = nb_channels;
|
st->codecpar->ch_layout.nb_channels = nb_channels;
|
||||||
if (sample_rate)
|
if (sample_rate)
|
||||||
avpriv_set_pts_info(st, 64, 1, sample_rate);
|
avpriv_set_pts_info(st, 64, 1, sample_rate);
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ ogm_header(AVFormatContext *s, int idx)
|
||||||
st->codecpar->height = bytestream2_get_le32(&p);
|
st->codecpar->height = bytestream2_get_le32(&p);
|
||||||
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
|
avpriv_set_pts_info(st, 64, time_unit, spu * 10000000);
|
||||||
} else {
|
} else {
|
||||||
st->codecpar->channels = bytestream2_get_le16(&p);
|
st->codecpar->ch_layout.nb_channels = bytestream2_get_le16(&p);
|
||||||
bytestream2_skip(&p, 2); /* block_align */
|
bytestream2_skip(&p, 2); /* block_align */
|
||||||
st->codecpar->bit_rate = bytestream2_get_le32(&p) * 8;
|
st->codecpar->bit_rate = bytestream2_get_le32(&p) * 8;
|
||||||
st->codecpar->sample_rate = spu * 10000000 / time_unit;
|
st->codecpar->sample_rate = spu * 10000000 / time_unit;
|
||||||
|
@ -160,7 +160,7 @@ ogm_dshow_header(AVFormatContext *s, int idx)
|
||||||
|
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124));
|
st->codecpar->codec_id = ff_codec_get_id(ff_codec_wav_tags, AV_RL16(p + 124));
|
||||||
st->codecpar->channels = AV_RL16(p + 126);
|
st->codecpar->ch_layout.nb_channels = AV_RL16(p + 126);
|
||||||
st->codecpar->sample_rate = AV_RL32(p + 128);
|
st->codecpar->sample_rate = AV_RL32(p + 128);
|
||||||
st->codecpar->bit_rate = AV_RL32(p + 132) * 8;
|
st->codecpar->bit_rate = AV_RL32(p + 132) * 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ static int opus_header(AVFormatContext *avf, int idx)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_OPUS;
|
st->codecpar->codec_id = AV_CODEC_ID_OPUS;
|
||||||
st->codecpar->channels = AV_RL8(packet + 9);
|
st->codecpar->ch_layout.nb_channels = AV_RL8(packet + 9);
|
||||||
|
|
||||||
priv->pre_skip = AV_RL16(packet + 10);
|
priv->pre_skip = AV_RL16(packet + 10);
|
||||||
st->codecpar->initial_padding = priv->pre_skip;
|
st->codecpar->initial_padding = priv->pre_skip;
|
||||||
|
|
|
@ -60,6 +60,7 @@ static int speex_header(AVFormatContext *s, int idx) {
|
||||||
|
|
||||||
if (spxp->seq == 0) {
|
if (spxp->seq == 0) {
|
||||||
int frames_per_packet;
|
int frames_per_packet;
|
||||||
|
int channels;
|
||||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_SPEEX;
|
st->codecpar->codec_id = AV_CODEC_ID_SPEEX;
|
||||||
|
|
||||||
|
@ -73,13 +74,12 @@ static int speex_header(AVFormatContext *s, int idx) {
|
||||||
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate);
|
av_log(s, AV_LOG_ERROR, "Invalid sample rate %d\n", st->codecpar->sample_rate);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
st->codecpar->channels = AV_RL32(p + 48);
|
channels = AV_RL32(p + 48);
|
||||||
if (st->codecpar->channels < 1 || st->codecpar->channels > 2) {
|
if (channels < 1 || channels > 2) {
|
||||||
av_log(s, AV_LOG_ERROR, "invalid channel count. Speex must be mono or stereo.\n");
|
av_log(s, AV_LOG_ERROR, "invalid channel count. Speex must be mono or stereo.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
st->codecpar->channel_layout = st->codecpar->channels == 1 ? AV_CH_LAYOUT_MONO :
|
av_channel_layout_default(&st->codecpar->ch_layout, channels);
|
||||||
AV_CH_LAYOUT_STEREO;
|
|
||||||
|
|
||||||
spxp->packet_size = AV_RL32(p + 56);
|
spxp->packet_size = AV_RL32(p + 56);
|
||||||
frames_per_packet = AV_RL32(p + 64);
|
frames_per_packet = AV_RL32(p + 64);
|
||||||
|
|
|
@ -336,11 +336,12 @@ static int vorbis_header(AVFormatContext *s, int idx)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
channels = bytestream_get_byte(&p);
|
channels = bytestream_get_byte(&p);
|
||||||
if (st->codecpar->channels && channels != st->codecpar->channels) {
|
if (st->codecpar->ch_layout.nb_channels &&
|
||||||
|
channels != st->codecpar->ch_layout.nb_channels) {
|
||||||
av_log(s, AV_LOG_ERROR, "Channel change is not supported\n");
|
av_log(s, AV_LOG_ERROR, "Channel change is not supported\n");
|
||||||
return AVERROR_PATCHWELCOME;
|
return AVERROR_PATCHWELCOME;
|
||||||
}
|
}
|
||||||
st->codecpar->channels = channels;
|
st->codecpar->ch_layout.nb_channels = channels;
|
||||||
srate = bytestream_get_le32(&p);
|
srate = bytestream_get_le32(&p);
|
||||||
p += 4; // skip maximum bitrate
|
p += 4; // skip maximum bitrate
|
||||||
st->codecpar->bit_rate = bytestream_get_le32(&p); // nominal bitrate
|
st->codecpar->bit_rate = bytestream_get_le32(&p); // nominal bitrate
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue