Used video_format_ScaleCropAr in scale.c/swscale.c
[vlc.git] / modules / video_filter / scale.c
index e2c3da8..66384db 100644 (file)
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include "vlc_filter.h"
-
-/*****************************************************************************
- * filter_sys_t : filter descriptor
- *****************************************************************************/
-struct filter_sys_t
-{
-    es_format_t fmt_in;
-    es_format_t fmt_out;
-};
+#include <vlc_filter.h>
 
 /****************************************************************************
  * Local prototypes
  ****************************************************************************/
 static int  OpenFilter ( vlc_object_t * );
-static void CloseFilter( vlc_object_t * );
-
 static picture_t *Filter( filter_t *, picture_t * );
 
 /*****************************************************************************
@@ -57,7 +46,7 @@ static picture_t *Filter( filter_t *, picture_t * );
 vlc_module_begin ()
     set_description( N_("Video scaling filter") )
     set_capability( "video filter2", 10 )
-    set_callbacks( OpenFilter, CloseFilter )
+    set_callbacks( OpenFilter, NULL )
 vlc_module_end ()
 
 /*****************************************************************************
@@ -66,7 +55,6 @@ vlc_module_end ()
 static int OpenFilter( vlc_object_t *p_this )
 {
     filter_t *p_filter = (filter_t*)p_this;
-    filter_sys_t *p_sys;
 
     if( ( p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVP &&
           p_filter->fmt_in.video.i_chroma != VLC_CODEC_YUVA &&
@@ -79,11 +67,7 @@ static int OpenFilter( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    /* Allocate the memory needed to store the decoder's structure */
-    if( ( p_filter->p_sys = p_sys =
-          (filter_sys_t *)malloc(sizeof(filter_sys_t)) ) == NULL )
-        return VLC_ENOMEM;
-
+    video_format_ScaleCropAr( &p_filter->fmt_out.video, &p_filter->fmt_in.video );
     p_filter->pf_video_filter = Filter;
 
     msg_Dbg( p_filter, "%ix%i -> %ix%i", p_filter->fmt_in.video.i_width,
@@ -93,17 +77,6 @@ static int OpenFilter( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
-/*****************************************************************************
- * CloseFilter: clean up the filter
- *****************************************************************************/
-static void CloseFilter( vlc_object_t *p_this )
-{
-    filter_t *p_filter = (filter_t*)p_this;
-    filter_sys_t *p_sys = p_filter->p_sys;
-
-    free( p_sys );
-}
-
 /****************************************************************************
  * Filter: the whole thing
  ****************************************************************************/
@@ -122,6 +95,8 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
         (p_filter->fmt_out.video.i_width == 0) )
         return NULL;
 
+    video_format_ScaleCropAr( &p_filter->fmt_out.video, &p_filter->fmt_in.video );
+
     /* Request output picture */
     p_pic_dst = filter_NewPicture( p_filter );
     if( !p_pic_dst )