PR #24502 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24502
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24502.patch

# Summary of changes

Cleanup and add failure check.



>From fb425a66f431a7be916bd3ff297a4ad3d858df51 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 15 Sep 2026 13:07:57 +0800
Subject: [PATCH 1/3] avfilter/vf_yadif_videotoolbox: drop the empty exit label

---
 libavfilter/vf_yadif_videotoolbox.m | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_yadif_videotoolbox.m 
b/libavfilter/vf_yadif_videotoolbox.m
index f8eb0c6bfa..b014985997 100644
--- a/libavfilter/vf_yadif_videotoolbox.m
+++ b/libavfilter/vf_yadif_videotoolbox.m
@@ -124,7 +124,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
         channels = comp->step / pixel_size;
         if (pixel_size > 2 || channels > 2) {
             av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", 
y->csp->name);
-            goto exit;
+            return;
         }
         switch (pixel_size) {
         case 1:
@@ -135,7 +135,7 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
             break;
         default:
             av_log(ctx, AV_LOG_ERROR, "Unsupported pixel format: %s\n", 
y->csp->name);
-            goto exit;
+            return;
         }
         av_log(ctx, AV_LOG_TRACE,
                "Deinterlacing plane %d: pixel_size: %d channels: %d\n",
@@ -165,9 +165,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
     if (y->current_field == YADIF_FIELD_END) {
         y->current_field = YADIF_FIELD_NORMAL;
     }
-
-exit:
-    return;
 }
 
 static av_cold void do_uninit(AVFilterContext *ctx) 
API_AVAILABLE(macos(10.11), ios(8.0))
-- 
2.52.0


>From c5e78b30981774cae0a2c6debbad3d1baed542b7 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 15 Sep 2026 16:18:37 +0800
Subject: [PATCH 2/3] avfilter/vf_yadif_videotoolbox: stop on Metal texture
 creation failure

---
 libavfilter/vf_yadif_videotoolbox.m | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavfilter/vf_yadif_videotoolbox.m 
b/libavfilter/vf_yadif_videotoolbox.m
index b014985997..11a801dc0e 100644
--- a/libavfilter/vf_yadif_videotoolbox.m
+++ b/libavfilter/vf_yadif_videotoolbox.m
@@ -146,6 +146,15 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
         next = ff_metal_texture_from_pixbuf(ctx, s->textureCache, 
(CVPixelBufferRef)y->next->data[3], i, format);
         dest = ff_metal_texture_from_pixbuf(ctx, s->textureCache, 
(CVPixelBufferRef)dst->data[3], i, format);
 
+        if (!prev || !cur || !next || !dest) {
+            av_log(ctx, AV_LOG_ERROR, "Failed to create Metal texture for 
plane %d\n", i);
+            if (prev) CFRelease(prev);
+            if (cur)  CFRelease(cur);
+            if (next) CFRelease(next);
+            if (dest) CFRelease(dest);
+            return;
+        }
+
         tex_prev = CVMetalTextureGetTexture(prev);
         tex_cur  = CVMetalTextureGetTexture(cur);
         tex_next = CVMetalTextureGetTexture(next);
-- 
2.52.0


>From e346ce6dea334ce1d1cf0687c17db79cd2b0fd0f Mon Sep 17 00:00:00 2001
From: Zhao Zhili <[email protected]>
Date: Tue, 15 Sep 2026 16:49:30 +0800
Subject: [PATCH 3/3] avfilter/vf_yadif_videotoolbox: scope the loop counter to
 the for loop

---
 libavfilter/vf_yadif_videotoolbox.m | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavfilter/vf_yadif_videotoolbox.m 
b/libavfilter/vf_yadif_videotoolbox.m
index 11a801dc0e..9f09947cc2 100644
--- a/libavfilter/vf_yadif_videotoolbox.m
+++ b/libavfilter/vf_yadif_videotoolbox.m
@@ -105,9 +105,8 @@ static void filter(AVFilterContext *ctx, AVFrame *dst,
 {
     YADIFVTContext *s = ctx->priv;
     YADIFContext *y = &s->yadif;
-    int i;
 
-    for (i = 0; i < y->csp->nb_components; i++) {
+    for (int i = 0; i < y->csp->nb_components; i++) {
         int pixel_size, channels;
         const AVComponentDescriptor *comp = &y->csp->comp[i];
         CVMetalTextureRef prev, cur, next, dest;
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to