mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-26 01:02:33 +00:00
avcodec/utils: Check bits_per_raw_sample on video encoder open
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
parent
13f266b50c
commit
0869ff7e9d
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user