]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/croppadd.c
swscale: pass/calculate sar-info, should fix #7437
[vlc] / modules / video_filter / croppadd.c
index b2c3d2250c573a3a3de3b5a3494e5f1f8aadb6ff..bff97f86c7715e53c2d9abacc1ed73f731b3469c 100644 (file)
@@ -32,8 +32,7 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_vout.h>
-#include "vlc_filter.h"
+#include <vlc_filter.h>
 #include "filter_picture.h"
 
 /****************************************************************************
@@ -75,31 +74,35 @@ static picture_t *Filter( filter_t *, picture_t * );
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( N_("Video scaling filter") );
-    set_capability( "video filter2", 0 );
-    set_callbacks( OpenFilter, CloseFilter );
-
-    set_section( N_("Crop"), NULL );
-        add_integer_with_range( CFG_PREFIX "croptop", 0, 0, INT_MAX, NULL,
-                                CROPTOP_TEXT, CROPTOP_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "cropbottom", 0, 0, INT_MAX, NULL,
-                                CROPBOTTOM_TEXT, CROPBOTTOM_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "cropleft", 0, 0, INT_MAX, NULL,
-                                CROPLEFT_TEXT, CROPLEFT_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "cropright", 0, 0, INT_MAX, NULL,
-                                CROPRIGHT_TEXT, CROPRIGHT_LONGTEXT, false );
-
-    set_section( N_("Padd"), NULL );
-        add_integer_with_range( CFG_PREFIX "paddtop", 0, 0, INT_MAX, NULL,
-                                PADDTOP_TEXT, PADDTOP_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "paddbottom", 0, 0, INT_MAX, NULL,
-                                PADDBOTTOM_TEXT, PADDBOTTOM_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "paddleft", 0, 0, INT_MAX, NULL,
-                                PADDLEFT_TEXT, PADDLEFT_LONGTEXT, false );
-        add_integer_with_range( CFG_PREFIX "paddright", 0, 0, INT_MAX, NULL,
-                                PADDRIGHT_TEXT, PADDRIGHT_LONGTEXT, false );
-vlc_module_end();
+vlc_module_begin ()
+    set_shortname( N_("Cropadd") )
+    set_description( N_("Video scaling filter") )
+    set_capability( "video filter2", 0 )
+    set_callbacks( OpenFilter, CloseFilter )
+
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VFILTER );
+
+    set_section( N_("Crop"), NULL )
+        add_integer_with_range( CFG_PREFIX "croptop", 0, 0, INT_MAX,
+                                CROPTOP_TEXT, CROPTOP_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "cropbottom", 0, 0, INT_MAX,
+                                CROPBOTTOM_TEXT, CROPBOTTOM_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "cropleft", 0, 0, INT_MAX,
+                                CROPLEFT_TEXT, CROPLEFT_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "cropright", 0, 0, INT_MAX,
+                                CROPRIGHT_TEXT, CROPRIGHT_LONGTEXT, false )
+
+    set_section( N_("Padd"), NULL )
+        add_integer_with_range( CFG_PREFIX "paddtop", 0, 0, INT_MAX,
+                                PADDTOP_TEXT, PADDTOP_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "paddbottom", 0, 0, INT_MAX,
+                                PADDBOTTOM_TEXT, PADDBOTTOM_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "paddleft", 0, 0, INT_MAX,
+                                PADDLEFT_TEXT, PADDLEFT_LONGTEXT, false )
+        add_integer_with_range( CFG_PREFIX "paddright", 0, 0, INT_MAX,
+                                PADDRIGHT_TEXT, PADDRIGHT_LONGTEXT, false )
+vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
     "croptop", "cropbottom", "cropleft", "cropright",
@@ -187,6 +190,9 @@ static int OpenFilter( vlc_object_t *p_this )
              p_filter->fmt_out.video.i_width,
              p_filter->fmt_out.video.i_height );
 
+    p_filter->fmt_out.video.i_sar_num = p_filter->fmt_in.video.i_sar_num * p_filter->fmt_out.video.i_visible_height;
+    p_filter->fmt_out.video.i_sar_den = p_filter->fmt_in.video.i_sar_den * p_filter->fmt_out.video.i_visible_width;
+
     return VLC_SUCCESS;
 }
 
@@ -215,12 +221,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
     if( !p_pic ) return NULL;
 
     /* Request output picture */
-    p_outpic = p_filter->pf_vout_buffer_new( p_filter );
+    p_outpic = filter_NewPicture( p_filter );
     if( !p_outpic )
     {
-        msg_Warn( p_filter, "can't get output picture" );
-        if( p_pic->pf_release )
-            p_pic->pf_release( p_pic );
+        picture_Release( p_pic );
         return NULL;
     }
 
@@ -265,7 +269,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         p_in += i_ycrop * p_plane->i_pitch;
 
         /* Padd on the top */
-        vlc_memset( p_out, i_padd_color, i_ypadd * p_outplane->i_pitch );
+        memset( p_out, i_padd_color, i_ypadd * p_outplane->i_pitch );
         p_out += i_ypadd * p_outplane->i_pitch;
 
         int i_line;
@@ -278,17 +282,17 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             p_in += i_xcrop * i_pixel_pitch;
 
             /* Padd on the left */
-            vlc_memset( p_out, i_padd_color, i_xpadd * i_pixel_pitch );
+            memset( p_out, i_padd_color, i_xpadd * i_pixel_pitch );
             p_out += i_xpadd * i_pixel_pitch;
 
             /* Copy the image and crop on the right */
-            vlc_memcpy( p_out, p_in, i_width * i_pixel_pitch );
+            memcpy( p_out, p_in, i_width * i_pixel_pitch );
             p_out += i_width * i_pixel_pitch;
             p_in += i_width * i_pixel_pitch;
 
             /* Padd on the right */
-            vlc_memset( p_out, i_padd_color,
-                        ( i_outwidth - i_width ) * i_pixel_pitch );
+            memset( p_out, i_padd_color,
+                        ( i_outwidth - i_xpadd - i_width ) * i_pixel_pitch );
 
             /* Got to begining of the next line */
             p_in = p_in_next;
@@ -296,7 +300,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         }
 
         /* Padd on the bottom */
-        vlc_memset( p_out, i_padd_color,
+        memset( p_out, i_padd_color,
                  ( i_outheight - i_ypadd - i_height ) * p_outplane->i_pitch );
     }