Commit 75dd79c4 authored by Antoine Cellerier's avatar Antoine Cellerier

* picture.c : slightly cleaner picture_t freeing

 * mosaic.c : add a switch to keep aspect ratio when resizing
parent ab171ce9
...@@ -59,6 +59,7 @@ struct filter_sys_t ...@@ -59,6 +59,7 @@ struct filter_sys_t
picture_t *p_pic; picture_t *p_pic;
int i_pos; /* mosaic positioning method */ int i_pos; /* mosaic positioning method */
int i_ar; /* do we keep aspect ratio ? */
int i_width, i_height; /* mosaic height and width */ int i_width, i_height; /* mosaic height and width */
int i_cols, i_rows; /* mosaic rows and cols */ int i_cols, i_rows; /* mosaic rows and cols */
int i_xoffset, i_yoffset; /* top left corner offset */ int i_xoffset, i_yoffset; /* top left corner offset */
...@@ -84,6 +85,7 @@ struct filter_sys_t ...@@ -84,6 +85,7 @@ struct filter_sys_t
#define POS_TEXT N_("Mosaic positioning method") #define POS_TEXT N_("Mosaic positioning method")
#define ROWS_TEXT N_("Mosaic number of rows") #define ROWS_TEXT N_("Mosaic number of rows")
#define COLS_TEXT N_("Mosaic number of columns") #define COLS_TEXT N_("Mosaic number of columns")
#define AR_TEXT N_("Keep aspect ratio when resizing")
static int pi_pos_values[] = { 0, 1 }; static int pi_pos_values[] = { 0, 1 };
static char * ppsz_pos_descriptions[] = static char * ppsz_pos_descriptions[] =
...@@ -110,6 +112,7 @@ vlc_module_begin(); ...@@ -110,6 +112,7 @@ vlc_module_begin();
change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
add_integer( "mosaic-rows", 2, NULL, ROWS_TEXT, ROWS_TEXT, VLC_FALSE ); add_integer( "mosaic-rows", 2, NULL, ROWS_TEXT, ROWS_TEXT, VLC_FALSE );
add_integer( "mosaic-cols", 2, NULL, COLS_TEXT, COLS_TEXT, VLC_FALSE ); add_integer( "mosaic-cols", 2, NULL, COLS_TEXT, COLS_TEXT, VLC_FALSE );
add_bool( "mosaic-keep-aspect-ratio", 0, NULL, AR_TEXT, AR_TEXT, VLC_FALSE );
vlc_module_end(); vlc_module_end();
...@@ -153,6 +156,8 @@ static int CreateFilter( vlc_object_t *p_this ) ...@@ -153,6 +156,8 @@ static int CreateFilter( vlc_object_t *p_this )
p_sys->i_pos = config_GetInt( p_filter, "mosaic-position" ); p_sys->i_pos = config_GetInt( p_filter, "mosaic-position" );
if( p_sys->i_pos > 1 || p_sys->i_pos < 0 ) p_sys->i_pos = 0; if( p_sys->i_pos > 1 || p_sys->i_pos < 0 ) p_sys->i_pos = 0;
p_sys->i_ar = config_GetInt( p_filter, "mosaic-keep-aspect-ratio" );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -262,6 +267,17 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) ...@@ -262,6 +267,17 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A'); fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
fmt_out.i_width = fmt_in.i_width *( p_sys->i_width / p_sys->i_cols ) / fmt_in.i_width; fmt_out.i_width = fmt_in.i_width *( p_sys->i_width / p_sys->i_cols ) / fmt_in.i_width;
fmt_out.i_height = fmt_in.i_height*( p_sys->i_height / p_sys->i_rows ) / fmt_in.i_height; fmt_out.i_height = fmt_in.i_height*( p_sys->i_height / p_sys->i_rows ) / fmt_in.i_height;
if( p_sys->i_ar ) /* keep aspect ratio */
{
if( (float)fmt_out.i_width/(float)fmt_out.i_height
> (float)fmt_in.i_width/(float)fmt_in.i_height )
{
fmt_out.i_width = ( fmt_out.i_height * fmt_in.i_width ) / fmt_in.i_height ;
} else {
fmt_out.i_height = ( fmt_out.i_width * fmt_in.i_height ) / fmt_in.i_width ;
}
}
fmt_out.i_visible_width = fmt_out.i_width; fmt_out.i_visible_width = fmt_out.i_width;
fmt_out.i_visible_height = fmt_out.i_height; fmt_out.i_visible_height = fmt_out.i_height;
......
...@@ -230,13 +230,11 @@ static void Close ( vlc_object_t *p_this ) ...@@ -230,13 +230,11 @@ static void Close ( vlc_object_t *p_this )
if( i_flag == 1 ){ if( i_flag == 1 ){
vlc_mutex_unlock( &p_picture_vout->lock ); vlc_mutex_unlock( &p_picture_vout->lock );
fprintf( stderr, "this wasn't the last picture\n");
} else { } else {
free( p_picture_vout->p_pic ); free( p_picture_vout->p_pic );
vlc_mutex_unlock( &p_picture_vout->lock ); vlc_mutex_unlock( &p_picture_vout->lock );
vlc_mutex_destroy( &p_picture_vout->lock ); vlc_mutex_destroy( &p_picture_vout->lock );
var_Destroy( p_libvlc, "p_picture_vout" ); var_Destroy( p_libvlc, "p_picture_vout" );
fprintf( stderr, "this was the last picture\n");
} }
free( p_vout->p_sys ); free( p_vout->p_sys );
...@@ -267,13 +265,10 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -267,13 +265,10 @@ static void Display( vout_thread_t *p_vout, picture_t *p_pic )
dest : p_picture_pout->p_pic[p_vout->p_sys.i_picture_pos]->p_picture dest : p_picture_pout->p_pic[p_vout->p_sys.i_picture_pos]->p_picture
*/ */
vlc_mutex_lock( &p_picture_vout->lock ); vlc_mutex_lock( &p_picture_vout->lock );
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture ) if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture )
{ {
// FIXME !!! if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->p_data_orig )
//nfprintf( stderr, "i_type : %i ( MEMORY_PICTURE == %i)\n", p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->i_type, MEMORY_PICTURE );
if( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos].p_picture->i_type == 200 /* MEMORY_PICTURE*/)
{ {
free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos] free( p_picture_vout->p_pic[p_vout->p_sys->i_picture_pos]
.p_picture->p_data_orig ); .p_picture->p_data_orig );
......
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