aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2011-02-09 10:52:33 -0500
committerMichael Niedermayer <michaelni@gmx.at>2011-02-11 02:54:08 +0100
commit7ade06cc2eeb1f9521fd70098b2ae03064a91120 (patch)
tree2da8ac774a0b732da200419122338aaea5271dd0 /libavcodec
parent6ff532b95d57444270696112f85b468f7fe5d422 (diff)
downloadffmpeg-7ade06cc2eeb1f9521fd70098b2ae03064a91120.tar.gz
check sample_fmt in avcodec_open
check AVCodecContext->sample_fmt against AVCodec->sample_fmts[] to ensure that the encoder supports the specified sample format. Error out if it doesn't. Previously, it would continue and output garbage. Fixes issue 2587. (cherry picked from commit 2cfa2d925808e6cc6fb7a7c133b7cb7622afd37e)
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 04f511fc75..404bf47215 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -551,6 +551,16 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
avctx->codec->max_lowres);
goto free_and_end;
}
+ if (avctx->codec->sample_fmts && avctx->codec->encode) {
+ int i;
+ for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+ if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
+ break;
+ if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
+ av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
+ goto free_and_end;
+ }
+ }
avctx->pts_correction_num_faulty_pts =
avctx->pts_correction_num_faulty_dts = 0;