diff mbox series

[FFmpeg-devel,v2,2/3] avfilter/vf_bwdif_cuda: consider chroma subsampling when enforcing minimum dimensions

Message ID 0101018c1d9bdaae-9d0e0673-0c35-4fe1-a981-98b365e78430-000000@us-west-2.amazonses.com
State New
Headers show
Series consider chroma subsampling for bwdif (including CUDA and Vulkan) | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Cosmin Stejerean Nov. 30, 2023, 12:23 a.m. UTC
From: Cosmin Stejerean <cosmin@cosmin.at>

Signed-off-by: Cosmin Stejerean <cosmin@cosmin.at>
---
 libavfilter/vf_bwdif_cuda.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/vf_bwdif_cuda.c b/libavfilter/vf_bwdif_cuda.c
index a5ecfbadb6..7d9bf861b7 100644
--- a/libavfilter/vf_bwdif_cuda.c
+++ b/libavfilter/vf_bwdif_cuda.c
@@ -296,13 +296,20 @@  static int config_output(AVFilterLink *link)
         link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate,
                                     (AVRational){2, 1});
 
-    if (link->w < 3 || link->h < 3) {
-        av_log(ctx, AV_LOG_ERROR, "Video of less than 3 columns or lines is not supported\n");
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(output_frames->sw_format);
+
+    int h = link->h;
+    int w = link->w;
+    int h_chroma = AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
+    int w_chroma = AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
+
+    if (w < 3 || w_chroma < 3 || h < 3 || h_chroma < 3) {
+        av_log(ctx, AV_LOG_ERROR, "Video with planes less than 3 columns or lines is not supported\n");
         ret = AVERROR(EINVAL);
         goto exit;
     }
 
-    y->csp = av_pix_fmt_desc_get(output_frames->sw_format);
+    y->csp = desc;
     y->filter = filter;
 
     ret = CHECK_CU(cu->cuCtxPushCurrent(s->hwctx->cuda_ctx));