[FFmpeg-cvslog] avcodec/utils: Check bits_per_raw_sample on video encoder open

Michael Niedermayer git at videolan.org
Thu Jan 7 02:01:50 CET 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Thu Jan  7 00:48:22 2016 +0100| [0869ff7e9d17cdcfbed65a8f25ce27002ec9b974] | committer: Michael Niedermayer

avcodec/utils: Check bits_per_raw_sample on video encoder open

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0869ff7e9d17cdcfbed65a8f25ce27002ec9b974
---

 libavcodec/utils.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4b4aea0..63439bb 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);



More information about the ffmpeg-cvslog mailing list