[FFmpeg-devel] [PATCH] For FFmpeg 0.7 branch: Treat AV_SAMPLE_FMT_NONE as S16 for encoders.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Jul 26 21:59:44 CEST 2011


This fixes compatibility with e.g. pcm_a52 ALSA plugin which in
previous versions never set sample_fmt.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
---
 libavcodec/utils.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 028a3a1..b61fb75 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -585,6 +585,8 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
     if (avctx->codec->encode) {
         int i;
         if (avctx->codec->sample_fmts) {
+            if (avctx->sample_fmt == AV_SAMPLE_FMT_NONE)
+                avctx->sample_fmt = AV_SAMPLE_FMT_S16;
             for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
                 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
                     break;
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list