[FFmpeg-devel] [PATCH]Do not try to decode g726 stereo streams

Carl Eugen Hoyos cehoyos at ag.or.at
Fri Jul 12 18:40:11 CEST 2013


On Friday 12 July 2013 06:32:58 pm Paul B Mahol wrote:
> On 7/12/13, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:
> > Hi!
> >
> > Our g726 decoder only supports mono, if the demuxer set stereo, 
> > decoding will not succeed.
> >
> > Please comment, Carl Eugen
>
> EINVAL is wrong error code.

Is attached patch better?

Thank you, Carl Eugen
-------------- next part --------------
diff --git a/libavcodec/g726.c b/libavcodec/g726.c
index 7884f36..152eecb 100644
--- a/libavcodec/g726.c
+++ b/libavcodec/g726.c
@@ -319,7 +319,7 @@ static av_cold int g726_encode_init(AVCodecContext *avctx)
 
     if(avctx->channels != 1){
         av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n");
-        return AVERROR(EINVAL);
+        return AVERROR_PATCHWELCOME;
     }
 
     if (avctx->bit_rate)
@@ -401,6 +401,10 @@ static av_cold int g726_decode_init(AVCodecContext *avctx)
 {
     G726Context* c = avctx->priv_data;
 
+    if(avctx->channels > 1){
+        avpriv_request_sample(avctx, "G.726 != mono");
+        return AVERROR_PATCHWELCOME;
+    }
     avctx->channels       = 1;
     avctx->channel_layout = AV_CH_LAYOUT_MONO;
 


More information about the ffmpeg-devel mailing list