* transform.c : transform image plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: transform.c,v 1.9 2002/04/19 13:56:11 sam Exp $
+ * $Id: transform.c,v 1.16 2002/07/20 18:01:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
-#include <videolan/vlc.h>
-
-#include "video.h"
-#include "video_output.h"
+#include <vlc/vlc.h>
+#include <vlc/vout.h>
#include "filter_common.h"
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
+#define TYPE_TEXT N_("Transform type")
+#define TYPE_LONGTEXT N_("One of '90', '180', '270', 'hflip' and 'vflip'")
+
+static char *type_list[] = { "90", "180", "270", "hflip", "vflip", NULL };
+
MODULE_CONFIG_START
+ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
+ADD_STRING_FROM_LIST("transform-type", "90", type_list, NULL, TYPE_TEXT, TYPE_LONGTEXT)
MODULE_CONFIG_STOP
MODULE_INIT_START
SET_DESCRIPTION( _("image transformation module") )
/* Capability score set to 0 because we don't want to be spawned
* as a video output unless explicitly requested to */
- ADD_CAPABILITY( VOUT, 0 )
+ ADD_CAPABILITY( VOUT_FILTER, 0 )
ADD_SHORTCUT( "transform" )
MODULE_INIT_STOP
* This structure is part of the video output thread descriptor.
* It describes the Transform specific properties of an output thread.
*****************************************************************************/
-typedef struct vout_sys_s
+struct vout_sys_t
{
int i_mode;
- boolean_t b_rotation;
- struct vout_thread_s *p_vout;
-
-} vout_sys_t;
+ vlc_bool_t b_rotation;
+ vout_thread_t *p_vout;
+};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static int vout_Create ( struct vout_thread_s * );
-static int vout_Init ( struct vout_thread_s * );
-static void vout_End ( struct vout_thread_s * );
-static void vout_Destroy ( struct vout_thread_s * );
-static int vout_Manage ( struct vout_thread_s * );
-static void vout_Render ( struct vout_thread_s *, struct picture_s * );
-static void vout_Display ( struct vout_thread_s *, struct picture_s * );
+static int vout_Create ( vout_thread_t * );
+static int vout_Init ( vout_thread_t * );
+static void vout_End ( vout_thread_t * );
+static void vout_Destroy ( vout_thread_t * );
+static int vout_Manage ( vout_thread_t * );
+static void vout_Render ( vout_thread_t *, picture_t * );
+static void vout_Display ( vout_thread_t *, picture_t * );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
*****************************************************************************/
static int vout_Create( vout_thread_t *p_vout )
{
- char *psz_method, *psz_method_tmp;
+ char *psz_method;
/* Allocate structure */
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
{
- intf_ErrMsg( "error: %s", strerror(ENOMEM) );
+ msg_Err( p_vout, "out of memory" );
return( 1 );
}
/* Look what method was requested */
- if( !(psz_method = psz_method_tmp
- = config_GetPszVariable( "filter" )) )
- {
- intf_ErrMsg( "vout error: configuration variable %s empty",
- "filter" );
- return( 1 );
- }
-
- while( *psz_method && *psz_method != ':' )
- {
- psz_method++;
- }
+ psz_method = config_GetPsz( p_vout, "transform-type" );
- if( !strcmp( psz_method, ":hflip" ) )
- {
- p_vout->p_sys->i_mode = TRANSFORM_MODE_HFLIP;
- p_vout->p_sys->b_rotation = 0;
- }
- else if( !strcmp( psz_method, ":vflip" ) )
- {
- p_vout->p_sys->i_mode = TRANSFORM_MODE_VFLIP;
- p_vout->p_sys->b_rotation = 0;
- }
- else if( !strcmp( psz_method, ":90" ) )
+ if( psz_method == NULL )
{
+ msg_Err( p_vout, "configuration variable %s empty", "transform-type" );
+ msg_Err( p_vout, "no valid transform mode provided, using '90'" );
p_vout->p_sys->i_mode = TRANSFORM_MODE_90;
p_vout->p_sys->b_rotation = 1;
}
- else if( !strcmp( psz_method, ":180" ) )
- {
- p_vout->p_sys->i_mode = TRANSFORM_MODE_180;
- p_vout->p_sys->b_rotation = 0;
- }
- else if( !strcmp( psz_method, ":270" ) )
- {
- p_vout->p_sys->i_mode = TRANSFORM_MODE_270;
- p_vout->p_sys->b_rotation = 1;
- }
else
{
- intf_ErrMsg( "filter error: no valid transform mode provided, "
- "using transform:90" );
- p_vout->p_sys->i_mode = TRANSFORM_MODE_90;
- p_vout->p_sys->b_rotation = 1;
- }
-
- free( psz_method_tmp );
+ if( !strcmp( psz_method, "hflip" ) )
+ {
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_HFLIP;
+ p_vout->p_sys->b_rotation = 0;
+ }
+ else if( !strcmp( psz_method, "vflip" ) )
+ {
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_VFLIP;
+ p_vout->p_sys->b_rotation = 0;
+ }
+ else if( !strcmp( psz_method, "90" ) )
+ {
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_90;
+ p_vout->p_sys->b_rotation = 1;
+ }
+ else if( !strcmp( psz_method, "180" ) )
+ {
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_180;
+ p_vout->p_sys->b_rotation = 0;
+ }
+ else if( !strcmp( psz_method, "270" ) )
+ {
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_270;
+ p_vout->p_sys->b_rotation = 1;
+ }
+ else
+ {
+ msg_Err( p_vout, "no valid transform mode provided, using '90'" );
+ p_vout->p_sys->i_mode = TRANSFORM_MODE_90;
+ p_vout->p_sys->b_rotation = 1;
+ }
+ free( psz_method );
+ }
+
return( 0 );
}
static int vout_Init( vout_thread_t *p_vout )
{
int i_index;
- char *psz_filter;
picture_t *p_pic;
I_OUTPUTPICTURES = 0;
p_vout->output.i_aspect = p_vout->render.i_aspect;
/* Try to open the real video output */
- psz_filter = config_GetPszVariable( "filter" );
- config_PutPszVariable( "filter", NULL );
-
- intf_WarnMsg( 1, "filter: spawning the real video output" );
+ msg_Dbg( p_vout, "spawning the real video output" );
if( p_vout->p_sys->b_rotation )
{
p_vout->p_sys->p_vout =
- vout_CreateThread( NULL,
+ vout_CreateThread( p_vout,
p_vout->render.i_height, p_vout->render.i_width,
p_vout->render.i_chroma,
(u64)VOUT_ASPECT_FACTOR * (u64)VOUT_ASPECT_FACTOR
else
{
p_vout->p_sys->p_vout =
- vout_CreateThread( NULL,
+ vout_CreateThread( p_vout,
p_vout->render.i_width, p_vout->render.i_height,
p_vout->render.i_chroma, p_vout->render.i_aspect );
}
- config_PutPszVariable( "filter", psz_filter );
- if( psz_filter ) free( psz_filter );
-
/* Everything failed */
if( p_vout->p_sys->p_vout == NULL )
{
- intf_ErrMsg( "filter error: can't open vout, aborting" );
+ msg_Err( p_vout, "cannot open vout, aborting" );
return( 0 );
}
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->p_data );
+ free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
}
}
*****************************************************************************/
static void vout_Destroy( vout_thread_t *p_vout )
{
- vout_DestroyThread( p_vout->p_sys->p_vout, NULL );
+ vout_DestroyThread( p_vout->p_sys->p_vout );
free( p_vout->p_sys );
}
for( ; p_in < p_in_end ; )
{
p_in_end -= p_pic->p[i_index].i_pitch;
- FAST_MEMCPY( p_out, p_in_end, p_pic->p[i_index].i_pitch );
+ p_vout->p_vlc->pf_memcpy( p_out, p_in_end,
+ p_pic->p[i_index].i_pitch );
p_out += p_pic->p[i_index].i_pitch;
}
}
{
;
}
-