1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-01-24 13:56:33 +02:00

libshine: convert to new channel layout API

Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
Anton Khirnov 2019-06-04 17:48:08 +02:00 committed by James Almer
parent e869c06ef5
commit ffdf7269a5

View File

@ -44,7 +44,7 @@ static av_cold int libshine_encode_init(AVCodecContext *avctx)
{
SHINEContext *s = avctx->priv_data;
if (avctx->channels <= 0 || avctx->channels > 2){
if (avctx->ch_layout.nb_channels <= 0 || avctx->ch_layout.nb_channels > 2){
av_log(avctx, AV_LOG_ERROR, "only mono or stereo is supported\n");
return AVERROR(EINVAL);
}
@ -52,9 +52,9 @@ static av_cold int libshine_encode_init(AVCodecContext *avctx)
shine_set_config_mpeg_defaults(&s->config.mpeg);
if (avctx->bit_rate)
s->config.mpeg.bitr = avctx->bit_rate / 1000;
s->config.mpeg.mode = avctx->channels == 2 ? STEREO : MONO;
s->config.mpeg.mode = avctx->ch_layout.nb_channels == 2 ? STEREO : MONO;
s->config.wave.samplerate = avctx->sample_rate;
s->config.wave.channels = avctx->channels == 2 ? PCM_STEREO : PCM_MONO;
s->config.wave.channels = avctx->ch_layout.nb_channels == 2 ? PCM_STEREO : PCM_MONO;
if (shine_check_config(s->config.wave.samplerate, s->config.mpeg.bitr) < 0) {
av_log(avctx, AV_LOG_ERROR, "invalid configuration\n");
return AVERROR(EINVAL);
@ -144,8 +144,14 @@ const AVCodec ff_libshine_encoder = {
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16P,
AV_SAMPLE_FMT_NONE },
.supported_samplerates = libshine_sample_rates,
#if FF_API_OLD_CHANNEL_LAYOUT
.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO,
0 },
#endif
.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO,
AV_CHANNEL_LAYOUT_STEREO,
{ 0 },
},
.wrapper_name = "libshine",
};