[FFmpeg-devel] [PATCH]Warn if vorbis files with wrong channel layout are encoded
Stefano Sabatini
stefano.sabatini-lala at poste.it
Thu Apr 14 22:54:58 CEST 2011
On date Thursday 2011-04-14 21:18:44 +0200, Carl Eugen Hoyos encoded:
> Hi!
>
> I'm going to commit if nobody objects, but I'd be happy if somebody from the
> language police comments. (I prefer AV_LOG_ERROR because the resulting streams
> are mostly unusable.)
>
> Carl Eugen
> diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
> index 9324b28..acbaa8c 100644
> --- a/libavcodec/libvorbis.c
> +++ b/libavcodec/libvorbis.c
> @@ -96,6 +96,32 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco
> vorbis_encode_ctl(vi, OV_ECTL_IBLOCK_SET, &context->iblock);
> }
>
> + if (avccontext->channels == 3 &&
> + avccontext->channel_layout != (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) ||
> + avccontext->channels == 4 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_2_2 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_QUAD ||
> + avccontext->channels == 5 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_5POINT0 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_5POINT0_BACK ||
> + avccontext->channels == 6 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_5POINT1 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_5POINT1_BACK ||
> + avccontext->channels == 7 &&
> + avccontext->channel_layout != (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) ||
> + avccontext->channels == 8 &&
> + avccontext->channel_layout != AV_CH_LAYOUT_7POINT1) {
> + if (avccontext->channel_layout) {
> + av_log(avccontext, AV_LOG_ERROR, "Channel layout not supported by Vorbis, "
> + "output stream will have incorrect "
> + "channel layout.\n");
And while at it also tell which is the problematic channel layout (see
libavutil/audioconvert.h:av_get_channel_layout_string()):
Channel layout '%s' not supported by Vorbis...
Also maybe more precise:
Channel layout '%s' and number of channels '%d' combination not supported by Vorbis...
Also it is quite weird to log with AV_LOG_ERROR if the error is not
issued immediately, maybe it would be better to move the check
directly in the setup function.
> + } else {
> + av_log(avccontext, AV_LOG_WARNING, "No channel layout specified. The encoder "
> + "will use Vorbis channel layout for "
> + "%d channels.\n", avccontext->channels);
> + }
> + }
> +
> return vorbis_encode_setup_init(vi);
> }
--
FFmpeg = Freak and Fantastic Most Problematic Eager God
More information about the ffmpeg-devel
mailing list