diff mbox

[FFmpeg-devel,1/1] cuviddec: Add capability check for maximum macroblock count

Message ID 20190503081111.7516-1-rgadkari@nvidia.com
State Accepted
Commit 80155795bb433fe588a957be9fb96a0a2608a00f
Headers show

Commit Message

Ruta Gadkari May 3, 2019, 8:11 a.m. UTC
Cuvid supports clips with a limit on maximum number of macroblocks.
This check was missing after cuvidGetDecoderCaps API call allowing
unsupported clips to proceed.
Added the missing check, same as the one in hwaccel nvdec implementation.
---
 libavcodec/cuviddec.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Timo Rothenpieler May 8, 2019, 10:08 a.m. UTC | #1
applied
diff mbox

Patch

diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
index d59d1faf9e..acee78cf2c 100644
--- a/libavcodec/cuviddec.c
+++ b/libavcodec/cuviddec.c
@@ -805,6 +805,12 @@  static int cuvid_test_capabilities(AVCodecContext *avctx,
         return AVERROR(EINVAL);
     }
 
+    if ((probed_width * probed_height) / 256 > caps->nMaxMBCount) {
+        av_log(avctx, AV_LOG_ERROR, "Video macroblock count %d exceeds maximum of %d\n",
+               (int)(probed_width * probed_height) / 256, caps->nMaxMBCount);
+        return AVERROR(EINVAL);
+    }
+
     return 0;
 }