For FFmpeg 0.7 branch: Treat AV_SAMPLE_FMT_NONE as S16 for encoders.

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@gmx.de>
This commit is contained in:
Reimar Döffinger 2011-07-26 21:58:10 +02:00
parent 0a48a67e57
commit dcf1830a15

View File

@ -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;