[vlc-devel] [PATCH 2/2] chroma: i420_nv12 allocate the copy_cache_t directly

Steve Lhomme robux4 at ycbcr.xyz
Thu May 2 11:36:30 CEST 2019


No need for an intermediate structure
---
 modules/video_chroma/i420_nv12.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)

diff --git a/modules/video_chroma/i420_nv12.c b/modules/video_chroma/i420_nv12.c
index 53e1364adf..83f17ec37e 100644
--- a/modules/video_chroma/i420_nv12.c
+++ b/modules/video_chroma/i420_nv12.c
@@ -34,11 +34,6 @@
 #include <vlc_picture.h>
 #include "copy.h"
 
-typedef struct
-{
-    copy_cache_t cache;
-} filter_sys_t;
-
 #define GET_PITCHES( pic ) { \
     pic->p[Y_PLANE].i_pitch, \
     pic->p[U_PLANE].i_pitch, \
@@ -57,7 +52,7 @@ typedef struct
 static void I420_NV12( filter_t *p_filter, picture_t *p_src,
                                            picture_t *p_dst )
 {
-    filter_sys_t *p_sys = p_filter->p_sys;
+    copy_cache_t *p_sys = p_filter->p_sys;
     p_dst->format.i_x_offset = p_src->format.i_x_offset;
     p_dst->format.i_y_offset = p_src->format.i_y_offset;
     const size_t pitches[] = GET_PITCHES( p_src );
@@ -65,7 +60,7 @@ static void I420_NV12( filter_t *p_filter, picture_t *p_src,
 
     Copy420_P_to_SP( p_dst, planes, pitches,
                      p_src->format.i_y_offset + p_src->format.i_visible_height,
-                     &p_sys->cache );
+                     p_sys );
 }
 
 /*****************************************************************************
@@ -81,7 +76,7 @@ static void YV12_NV12( filter_t *p_filter, picture_t *p_src,
 static void NV12_I420( filter_t *p_filter, picture_t *p_src,
                                            picture_t *p_dst )
 {
-    filter_sys_t *p_sys = p_filter->p_sys;
+    copy_cache_t *p_sys = p_filter->p_sys;
     p_dst->format.i_x_offset = p_src->format.i_x_offset;
     p_dst->format.i_y_offset = p_src->format.i_y_offset;
     const size_t pitches[] = GET_PITCHES( p_src );
@@ -89,7 +84,7 @@ static void NV12_I420( filter_t *p_filter, picture_t *p_src,
 
     Copy420_SP_to_P( p_dst, planes, pitches,
                      p_src->format.i_y_offset + p_src->format.i_visible_height,
-                     &p_sys->cache );
+                     p_sys );
 }
 
 static void NV12_YV12( filter_t *p_filter, picture_t *p_src,
@@ -102,7 +97,7 @@ static void NV12_YV12( filter_t *p_filter, picture_t *p_src,
 static void I42010B_P010( filter_t *p_filter, picture_t *p_src,
                                               picture_t *p_dst )
 {
-    filter_sys_t *p_sys = p_filter->p_sys;
+    copy_cache_t *p_sys = p_filter->p_sys;
     p_dst->format.i_x_offset = p_src->format.i_x_offset;
     p_dst->format.i_y_offset = p_src->format.i_y_offset;
     const size_t pitches[] = GET_PITCHES( p_src );
@@ -110,13 +105,13 @@ static void I42010B_P010( filter_t *p_filter, picture_t *p_src,
 
     Copy420_16_P_to_SP( p_dst, planes, pitches,
                         p_src->format.i_y_offset + p_src->format.i_visible_height,
-                        -6, &p_sys->cache );
+                        -6, p_sys );
 }
 
 static void P010_I42010B( filter_t *p_filter, picture_t *p_src,
                                               picture_t *p_dst )
 {
-    filter_sys_t *p_sys = p_filter->p_sys;
+    copy_cache_t *p_sys = p_filter->p_sys;
     p_dst->format.i_x_offset = p_src->format.i_x_offset;
     p_dst->format.i_y_offset = p_src->format.i_y_offset;
     const size_t pitches[] = GET_PITCHES( p_src );
@@ -124,7 +119,7 @@ static void P010_I42010B( filter_t *p_filter, picture_t *p_src,
 
     Copy420_16_SP_to_P( p_dst, planes, pitches,
                         p_src->format.i_y_offset + p_src->format.i_visible_height,
-                        6, &p_sys->cache );
+                        6, p_sys );
 }
 
 /* Following functions are local */
@@ -209,12 +204,12 @@ static int Create( vlc_object_t *p_this )
             return -1;
     }
 
-    filter_sys_t *p_sys = vlc_obj_malloc( VLC_OBJECT( p_filter ),
+    copy_cache_t *p_sys = vlc_obj_malloc( VLC_OBJECT( p_filter ),
                                           sizeof(*p_sys) );
     if (!p_sys)
          return VLC_ENOMEM;
 
-    if( CopyInitCache( &p_sys->cache, ( p_filter->fmt_in.video.i_x_offset +
+    if( CopyInitCache( p_sys, ( p_filter->fmt_in.video.i_x_offset +
                        p_filter->fmt_in.video.i_visible_width ) * pixel_bytes ) )
         return VLC_ENOMEM;
 
@@ -226,8 +221,8 @@ static int Create( vlc_object_t *p_this )
 static void Delete(vlc_object_t *p_this)
 {
     filter_t *p_filter = (filter_t *)p_this;
-    filter_sys_t *p_sys = p_filter->p_sys;
-    CopyCleanCache( &p_sys->cache );
+    copy_cache_t *p_sys = p_filter->p_sys;
+    CopyCleanCache( p_sys );
 }
 
 /*****************************************************************************
-- 
2.17.1



More information about the vlc-devel mailing list