libvorbis: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
committed by
James Almer
parent
53bf0ed544
commit
e5d4941c40
@ -112,7 +112,9 @@ static int oggvorbis_decode_init(AVCodecContext *avccontext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
avccontext->channels = context->vi.channels;
|
av_channel_layout_uninit(&avccontext->ch_layout);
|
||||||
|
avccontext->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;
|
||||||
|
avccontext->ch_layout.nb_channels = context->vi.channels;
|
||||||
avccontext->sample_rate = context->vi.rate;
|
avccontext->sample_rate = context->vi.rate;
|
||||||
avccontext->sample_fmt = AV_SAMPLE_FMT_S16;
|
avccontext->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
avccontext->time_base= (AVRational){1, avccontext->sample_rate};
|
avccontext->time_base= (AVRational){1, avccontext->sample_rate};
|
||||||
|
@ -96,6 +96,7 @@ static int vorbis_error_to_averror(int ov_err)
|
|||||||
static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
|
static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
|
||||||
{
|
{
|
||||||
LibvorbisEncContext *s = avctx->priv_data;
|
LibvorbisEncContext *s = avctx->priv_data;
|
||||||
|
int channels = avctx->ch_layout.nb_channels;
|
||||||
double cfreq;
|
double cfreq;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
|
|||||||
/* default to 3 if the user did not set quality or bitrate */
|
/* default to 3 if the user did not set quality or bitrate */
|
||||||
if (!(avctx->flags & AV_CODEC_FLAG_QSCALE))
|
if (!(avctx->flags & AV_CODEC_FLAG_QSCALE))
|
||||||
q = 3.0;
|
q = 3.0;
|
||||||
if ((ret = vorbis_encode_setup_vbr(vi, avctx->channels,
|
if ((ret = vorbis_encode_setup_vbr(vi, channels,
|
||||||
avctx->sample_rate,
|
avctx->sample_rate,
|
||||||
q / 10.0)))
|
q / 10.0)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -117,7 +118,7 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
|
|||||||
int maxrate = avctx->rc_max_rate > 0 ? avctx->rc_max_rate : -1;
|
int maxrate = avctx->rc_max_rate > 0 ? avctx->rc_max_rate : -1;
|
||||||
|
|
||||||
/* average bitrate */
|
/* average bitrate */
|
||||||
if ((ret = vorbis_encode_setup_managed(vi, avctx->channels,
|
if ((ret = vorbis_encode_setup_managed(vi, channels,
|
||||||
avctx->sample_rate, maxrate,
|
avctx->sample_rate, maxrate,
|
||||||
avctx->bit_rate, minrate)))
|
avctx->bit_rate, minrate)))
|
||||||
goto error;
|
goto error;
|
||||||
@ -141,32 +142,31 @@ static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avctx->channels == 3 &&
|
if ((channels == 3 &&
|
||||||
avctx->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) ||
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND)) ||
|
||||||
avctx->channels == 4 &&
|
(channels == 4 &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_2_2 &&
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_2) &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_QUAD ||
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD)) ||
|
||||||
avctx->channels == 5 &&
|
(channels == 5 &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_5POINT0 &&
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0) &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_5POINT0_BACK ||
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK)) ||
|
||||||
avctx->channels == 6 &&
|
(channels == 6 &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_5POINT1 &&
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1) &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_5POINT1_BACK ||
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK)) ||
|
||||||
avctx->channels == 7 &&
|
(channels == 7 &&
|
||||||
avctx->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) ||
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1)) ||
|
||||||
avctx->channels == 8 &&
|
(channels == 8 &&
|
||||||
avctx->channel_layout != AV_CH_LAYOUT_7POINT1) {
|
av_channel_layout_compare(&avctx->ch_layout, &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1))) {
|
||||||
if (avctx->channel_layout) {
|
if (avctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
|
||||||
char name[32];
|
char name[32];
|
||||||
av_get_channel_layout_string(name, sizeof(name), avctx->channels,
|
av_channel_layout_describe(&avctx->ch_layout, name, sizeof(name));
|
||||||
avctx->channel_layout);
|
|
||||||
av_log(avctx, AV_LOG_ERROR, "%s not supported by Vorbis: "
|
av_log(avctx, AV_LOG_ERROR, "%s not supported by Vorbis: "
|
||||||
"output stream will have incorrect "
|
"output stream will have incorrect "
|
||||||
"channel layout.\n", name);
|
"channel layout.\n", name);
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The encoder "
|
av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The encoder "
|
||||||
"will use Vorbis channel layout for "
|
"will use Vorbis channel layout for "
|
||||||
"%d channels.\n", avctx->channels);
|
"%d channels.\n", channels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user