opencv: check the image conversion worked
authorSteve Lhomme <robux4@ycbcr.xyz>
Thu, 18 Jul 2024 07:27:00 +0000 (09:27 +0200)
committerSebastian Ramacher <sramacher@debian.org>
Tue, 14 Jan 2025 22:09:47 +0000 (23:09 +0100)
Otherwise we release the output picture that would have been used and returned.

(cherry picked from commit 19813291fcfb31ddd91a2e4d0f1d37ad3239d300) (rebased)
rebased:
- p_filter->p_sys is p_sys on 4.0
Signed-off-by: Steve Lhomme <robux4@ycbcr.xyz>
Gbp-Pq: Name 0019-opencv-check-the-image-conversion-worked.patch

modules/video_filter/opencv_wrapper.c

index 5da26a17101c694b91c381887c127dba1cd46c70..2d5966ba122391a1393d9b2471dfd2b3151a8688 100644 (file)
@@ -444,9 +444,16 @@ static picture_t* Filter( filter_t* p_filter, picture_t* p_pic )
                         p_filter->p_sys->p_proc_image,
                         &(p_filter->p_sys->p_proc_image->format),
                         &fmt_out );
-
-            picture_CopyPixels( p_outpic, p_outpic_tmp );
-            CopyInfoAndRelease( p_outpic, p_outpic_tmp );
+            if (unlikely(!p_outpic_tmp))
+            {
+                picture_Release(p_outpic);
+                p_outpic = NULL;
+            }
+            else
+            {
+                picture_CopyPixels( p_outpic, p_outpic_tmp );
+                CopyInfoAndRelease( p_outpic, p_outpic_tmp );
+            }
         } else if( p_filter->p_sys->i_internal_chroma == CINPUT ) {
             picture_CopyPixels( p_outpic, p_filter->p_sys->p_proc_image );
             picture_CopyProperties( p_outpic, p_filter->p_sys->p_proc_image );