summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-07 00:48:22 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-07 02:00:34 +0100
commit0869ff7e9d17cdcfbed65a8f25ce27002ec9b974 (patch)
tree88dbd83c04b0bb8e9966257322f7c77765c1b9e1 /libavcodec
parent13f266b50cc7554028d22480b7e4383968e64a63 (diff)
avcodec/utils: Check bits_per_raw_sample on video encoder open
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/utils.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4b4aea02bd..63439bb892 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1168,6 +1168,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
{
int ret = 0;
AVDictionary *tmp = NULL;
+ const AVPixFmtDescriptor *pixdesc;
if (avcodec_is_open(avctx))
return 0;
@@ -1453,6 +1454,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
goto free_and_end;
}
if(avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
+ pixdesc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ if ( avctx->bits_per_raw_sample < 0
+ || (avctx->bits_per_raw_sample > 8 && pixdesc->comp[0].depth <= 8)) {
+ av_log(avctx, AV_LOG_WARNING, "Specified bit depth %d not possible with the specified pixel formats depth %d\n",
+ avctx->bits_per_raw_sample, pixdesc->comp[0].depth);
+ avctx->bits_per_raw_sample = pixdesc->comp[0].depth;
+ }
if (avctx->width <= 0 || avctx->height <= 0) {
av_log(avctx, AV_LOG_ERROR, "dimensions not set\n");
ret = AVERROR(EINVAL);