Commit 2085fb08 authored by Antoine Cellerier's avatar Antoine Cellerier

Factorize some code in the filters.

parent b6dc08db
...@@ -410,16 +410,7 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic ) ...@@ -410,16 +410,7 @@ static picture_t *FilterPlanar( filter_t *p_filter, picture_t *p_pic )
#undef WRITE_UV #undef WRITE_UV
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
/***************************************************************************** /*****************************************************************************
...@@ -652,16 +643,7 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) ...@@ -652,16 +643,7 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
#undef WRITE_UV #undef WRITE_UV
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
static int AdjustCallback( vlc_object_t *p_this, char const *psz_var, static int AdjustCallback( vlc_object_t *p_this, char const *psz_var,
......
...@@ -228,14 +228,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -228,14 +228,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
p_out_v++; p_out_v++;
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
/**************************************************************************** /****************************************************************************
* Local prototypes * Local prototypes
...@@ -187,13 +188,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -187,13 +188,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
( i_outheight - i_ypadd - i_height ) * p_outplane->i_pitch ); ( i_outheight - i_ypadd - i_height ) * p_outplane->i_pitch );
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "vlc_image.h" #include "vlc_image.h"
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -216,16 +217,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -216,16 +217,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
/* Here */ /* Here */
FilterErase( p_filter, p_pic, p_outpic ); FilterErase( p_filter, p_pic, p_outpic );
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -250,16 +250,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -250,16 +250,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
return NULL; return NULL;
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
static inline uint8_t crop( int a ) static inline uint8_t crop( int a )
......
...@@ -86,7 +86,7 @@ static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma, ...@@ -86,7 +86,7 @@ static inline int GetPackedYuvOffsets( vlc_fourcc_t i_chroma,
/***************************************************************************** /*****************************************************************************
* *
*****************************************************************************/ *****************************************************************************/
static inline picture_t *CopyMetaAndRelease( picture_t *p_outpic, picture_t *p_inpic ) static inline picture_t *CopyInfoAndRelease( picture_t *p_outpic, picture_t *p_inpic )
{ {
p_outpic->date = p_inpic->date; p_outpic->date = p_inpic->date;
p_outpic->b_force = p_inpic->b_force; p_outpic->b_force = p_inpic->b_force;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
#include <math.h> /* exp(), sqrt() */ #include <math.h> /* exp(), sqrt() */
...@@ -377,14 +378,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -377,14 +378,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -263,16 +263,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -263,16 +263,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
break; break;
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -203,14 +203,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -203,14 +203,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -181,14 +182,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -181,14 +182,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <vlc_sout.h> #include <vlc_sout.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include <vlc_filter.h> #include <vlc_filter.h>
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local protypes * Local protypes
...@@ -129,17 +130,6 @@ static void Destroy( vlc_object_t *p_this ) ...@@ -129,17 +130,6 @@ static void Destroy( vlc_object_t *p_this )
free( p_filter->p_sys ); free( p_filter->p_sys );
} }
#define RELEASE( pic ) \
if( pic ->pf_release ) \
pic ->pf_release( pic );
#define INITPIC( dst, src ) \
dst ->date = src ->date; \
dst ->b_force = src ->b_force; \
dst ->i_nb_fields = src ->i_nb_fields; \
dst ->b_progressive = src->b_progressive; \
dst ->b_top_field_first = src ->b_top_field_first;
/***************************************************************************** /*****************************************************************************
* Filter * Filter
*****************************************************************************/ *****************************************************************************/
...@@ -154,10 +144,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -154,10 +144,10 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
if( !p_outpic ) if( !p_outpic )
{ {
msg_Warn( p_filter, "can't get output picture" ); msg_Warn( p_filter, "can't get output picture" );
RELEASE( p_pic ); if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return NULL; return NULL;
} }
INITPIC( p_outpic, p_pic );
if( !p_sys->pp_planes ) if( !p_sys->pp_planes )
{ {
...@@ -178,8 +168,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -178,8 +168,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
RenderBlur( p_sys, p_pic, p_outpic ); RenderBlur( p_sys, p_pic, p_outpic );
Copy( p_filter, p_outpic ); Copy( p_filter, p_outpic );
RELEASE( p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
return p_outpic;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -171,14 +172,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -171,14 +172,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "vlc_filter.h" #include "vlc_filter.h"
#include "vlc_image.h" #include "vlc_image.h"
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -252,14 +253,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -252,14 +253,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
p_filter->p_sys->v += 1; p_filter->p_sys->v += 1;
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include <vlc_filter.h> #include <vlc_filter.h>
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -203,14 +204,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -203,14 +204,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
...@@ -283,7 +283,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -283,7 +283,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
return CopyMetaAndRelease( p_outpic, p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
} }
/***************************************************************************** /*****************************************************************************
...@@ -385,7 +385,7 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic ) ...@@ -385,7 +385,7 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
} }
} }
return CopyMetaAndRelease( p_outpic, p_pic ); return CopyInfoAndRelease( p_outpic, p_pic );
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
#include <assert.h> #include <assert.h>
...@@ -126,16 +127,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -126,16 +127,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
FilterSeamCarving( p_filter, p_pic, p_outpic ); FilterSeamCarving( p_filter, p_pic, p_outpic );
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
static inline int my_min3( int a, int b, int c ); static inline int my_min3( int a, int b, int c );
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
#define SIG_TEXT N_("Sharpen strength (0-2)") #define SIG_TEXT N_("Sharpen strength (0-2)")
#define SIG_LONGTEXT N_("Set the Sharpen strength, between 0 and 2. Defaults to 0.05.") #define SIG_LONGTEXT N_("Set the Sharpen strength, between 0 and 2. Defaults to 0.05.")
...@@ -101,7 +102,7 @@ inline static int32_t clip( int32_t a ) ...@@ -101,7 +102,7 @@ inline static int32_t clip( int32_t a )
static void init_precalc_table(filter_sys_t *p_filter) static void init_precalc_table(filter_sys_t *p_filter)
{ {
float sigma = p_filter->f_sigma; float sigma = p_filter->f_sigma;
for(int i = 0; i < 512; ++i) for(int i = 0; i < 512; ++i)
{ {
p_filter->tab_precalc[i] = (i - 256) * sigma; p_filter->tab_precalc[i] = (i - 256) * sigma;
...@@ -237,16 +238,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -237,16 +238,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
p_outpic->p[V_PLANE].i_lines * p_outpic->p[V_PLANE].i_pitch ); p_outpic->p[V_PLANE].i_lines * p_outpic->p[V_PLANE].i_pitch );
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
static int SharpenCallback( vlc_object_t *p_this, char const *psz_var, static int SharpenCallback( vlc_object_t *p_this, char const *psz_var,
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <vlc_vout.h> #include <vlc_vout.h>
#include "vlc_filter.h" #include "vlc_filter.h"
#include "filter_picture.h"
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -193,14 +194,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic ) ...@@ -193,14 +194,5 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
} }
} }
p_outpic->date = p_pic->date; return CopyInfoAndRelease( p_outpic, p_pic );
p_outpic->b_force = p_pic->b_force;
p_outpic->i_nb_fields = p_pic->i_nb_fields;
p_outpic->b_progressive = p_pic->b_progressive;
p_outpic->b_top_field_first = p_pic->b_top_field_first;
if( p_pic->pf_release )
p_pic->pf_release( p_pic );
return p_outpic;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment