* transform.c : transform image plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: transform.c,v 1.1 2001/12/19 03:50:22 sam Exp $
+ * $Id: transform.c,v 1.16 2002/07/20 18:01:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#define MODULE_NAME filter_transform
-#include "modules_inner.h"
-
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
-
#include <errno.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
-#include "common.h" /* boolean_t, byte_t */
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
-
-#include "video.h"
-#include "video_output.h"
+#include <vlc/vlc.h>
+#include <vlc/vout.h>
#include "filter_common.h"
-#include "modules.h"
-#include "modules_export.h"
-
#define TRANSFORM_MODE_HFLIP 1
#define TRANSFORM_MODE_VFLIP 2
#define TRANSFORM_MODE_90 3
/*****************************************************************************
* 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_WINDOW( "Configuration for transform module" )
- ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
+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
- p_module->i_capabilities = MODULE_CAPABILITY_NULL
- | MODULE_CAPABILITY_VOUT;
- p_module->psz_longname = "image transformation module";
+ 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_FILTER, 0 )
+ ADD_SHORTCUT( "transform" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
* 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_Probe ( probedata_t *p_data );
-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_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 void vout_getfunctions( function_list_t * p_function_list )
{
- p_function_list->pf_probe = vout_Probe;
p_function_list->functions.vout.pf_create = vout_Create;
p_function_list->functions.vout.pf_init = vout_Init;
p_function_list->functions.vout.pf_end = vout_End;
p_function_list->functions.vout.pf_destroy = vout_Destroy;
p_function_list->functions.vout.pf_manage = vout_Manage;
+ p_function_list->functions.vout.pf_render = vout_Render;
p_function_list->functions.vout.pf_display = vout_Display;
- p_function_list->functions.vout.pf_setpalette = NULL;
-}
-
-/*****************************************************************************
- * intf_Probe: return a score
- *****************************************************************************/
-static int vout_Probe( probedata_t *p_data )
-{
- if( TestMethod( VOUT_FILTER_VAR, "transform" ) )
- {
- return( 999 );
- }
-
- /* If we weren't asked to filter, don't filter. */
- return( 0 );
}
/*****************************************************************************
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 */
- psz_method = main_GetPszVariable( VOUT_FILTER_VAR, "" );
+ psz_method = config_GetPsz( p_vout, "transform-type" );
- while( *psz_method && *psz_method != ':' )
- {
- psz_method++;
- }
-
- 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;
- }
+ 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;
/* Initialize the output structure */
- switch( p_vout->render.i_chroma )
- {
- case YUV_420_PICTURE:
- p_vout->output.i_chroma = p_vout->render.i_chroma;
- p_vout->output.i_width = p_vout->render.i_width;
- p_vout->output.i_height = p_vout->render.i_height;
- p_vout->output.i_aspect = p_vout->render.i_aspect;
- break;
-
- default:
- return( 0 ); /* unknown chroma */
- break;
- }
+ p_vout->output.i_chroma = p_vout->render.i_chroma;
+ p_vout->output.i_width = p_vout->render.i_width;
+ p_vout->output.i_height = p_vout->render.i_height;
+ p_vout->output.i_aspect = p_vout->render.i_aspect;
/* Try to open the real video output */
- psz_filter = main_GetPszVariable( VOUT_FILTER_VAR, "" );
- main_PutPszVariable( VOUT_FILTER_VAR, "" );
-
- 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 );
}
/* 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 );
}
- main_PutPszVariable( VOUT_FILTER_VAR, psz_filter );
-
ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
return( 0 );
for( i_index = I_OUTPUTPICTURES ; i_index ; )
{
i_index--;
- free( PP_OUTPUTPICTURE[ i_index ]->planes[ 0 ].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 );
}
}
/*****************************************************************************
- * vout_Display: displays previously rendered output
+ * vout_Render: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to Transform image, waits
* until it is displayed and switch the two rendering buffers, preparing next
* frame.
*****************************************************************************/
-static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
{
picture_t *p_outpic;
int i_index;
msleep( VOUT_OUTMEM_SLEEP );
}
- vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, mdate() + 50000 );
+ vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
switch( p_vout->p_sys->i_mode )
case TRANSFORM_MODE_90:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- int i_line_bytes = p_pic->planes[ i_index ].i_line_bytes;
+ int i_pitch = p_pic->p[i_index].i_pitch;
- pixel_data_t *p_in = p_pic->planes[ i_index ].p_data;
+ u8 *p_in = p_pic->p[i_index].p_pixels;
- pixel_data_t *p_out = p_outpic->planes[ i_index ].p_data;
- pixel_data_t *p_out_end = p_out
- + p_outpic->planes[ i_index ].i_bytes;
+ u8 *p_out = p_outpic->p[i_index].p_pixels;
+ u8 *p_out_end = p_out + p_outpic->p[i_index].i_lines
+ * p_outpic->p[i_index].i_pitch;
for( ; p_out < p_out_end ; )
{
- pixel_data_t *p_line_end;
+ u8 *p_line_end;
- p_line_end = p_in + p_pic->planes[ i_index ].i_bytes;
+ p_line_end = p_in + p_pic->p[i_index].i_lines
+ * p_pic->p[i_index].i_pitch;
for( ; p_in < p_line_end ; )
{
- p_line_end -= i_line_bytes;
+ p_line_end -= i_pitch;
*(--p_out_end) = *p_line_end;
}
case TRANSFORM_MODE_180:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- pixel_data_t *p_in = p_pic->planes[ i_index ].p_data;
- pixel_data_t *p_in_end = p_in + p_pic->planes[ i_index ].i_bytes;
+ u8 *p_in = p_pic->p[i_index].p_pixels;
+ u8 *p_in_end = p_in + p_pic->p[i_index].i_lines
+ * p_pic->p[i_index].i_pitch;
- pixel_data_t *p_out = p_outpic->planes[ i_index ].p_data;
+ u8 *p_out = p_outpic->p[i_index].p_pixels;
for( ; p_in < p_in_end ; )
{
case TRANSFORM_MODE_270:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- int i_line_bytes = p_pic->planes[ i_index ].i_line_bytes;
+ int i_pitch = p_pic->p[i_index].i_pitch;
- pixel_data_t *p_in = p_pic->planes[ i_index ].p_data;
+ u8 *p_in = p_pic->p[i_index].p_pixels;
- pixel_data_t *p_out = p_outpic->planes[ i_index ].p_data;
- pixel_data_t *p_out_end = p_out
- + p_outpic->planes[ i_index ].i_bytes;
+ u8 *p_out = p_outpic->p[i_index].p_pixels;
+ u8 *p_out_end = p_out + p_outpic->p[i_index].i_lines
+ * p_outpic->p[i_index].i_pitch;
for( ; p_out < p_out_end ; )
{
- pixel_data_t *p_in_end;
+ u8 *p_in_end;
- p_in_end = p_in + p_pic->planes[ i_index ].i_bytes;
+ p_in_end = p_in + p_pic->p[i_index].i_lines
+ * p_pic->p[i_index].i_pitch;
for( ; p_in < p_in_end ; )
{
- p_in_end -= i_line_bytes;
+ p_in_end -= i_pitch;
*p_out++ = *p_in_end;
}
case TRANSFORM_MODE_VFLIP:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- pixel_data_t *p_in = p_pic->planes[ i_index ].p_data;
- pixel_data_t *p_in_end = p_in + p_pic->planes[ i_index ].i_bytes;
+ u8 *p_in = p_pic->p[i_index].p_pixels;
+ u8 *p_in_end = p_in + p_pic->p[i_index].i_lines
+ * p_pic->p[i_index].i_pitch;
- pixel_data_t *p_out = p_outpic->planes[ i_index ].p_data;
+ u8 *p_out = p_outpic->p[i_index].p_pixels;
for( ; p_in < p_in_end ; )
{
- p_in_end -= p_pic->planes[ i_index ].i_line_bytes;
- p_main->fast_memcpy( p_out, p_in_end,
- p_pic->planes[ i_index ].i_line_bytes );
- p_out += p_pic->planes[ i_index ].i_line_bytes;
+ 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;
}
}
break;
case TRANSFORM_MODE_HFLIP:
for( i_index = 0 ; i_index < p_pic->i_planes ; i_index++ )
{
- pixel_data_t *p_in = p_pic->planes[ i_index ].p_data;
- pixel_data_t *p_in_end = p_in + p_pic->planes[ i_index ].i_bytes;
+ u8 *p_in = p_pic->p[i_index].p_pixels;
+ u8 *p_in_end = p_in + p_pic->p[i_index].i_lines
+ * p_pic->p[i_index].i_pitch;
- pixel_data_t *p_out = p_outpic->planes[ i_index ].p_data;
+ u8 *p_out = p_outpic->p[i_index].p_pixels;
for( ; p_in < p_in_end ; )
{
- pixel_data_t *p_line_end = p_in
- + p_pic->planes[ i_index ].i_line_bytes;
+ u8 *p_line_end = p_in + p_pic->p[i_index].i_pitch;
for( ; p_in < p_line_end ; )
{
*p_out++ = *(--p_line_end);
}
- p_in += p_pic->planes[ i_index ].i_line_bytes;
+ p_in += p_pic->p[i_index].i_pitch;
}
}
break;
vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
}
+/*****************************************************************************
+ * vout_Display: displays previously rendered output
+ *****************************************************************************
+ * This function send the currently rendered image to Invert image, waits
+ * until it is displayed and switch the two rendering buffers, preparing next
+ * frame.
+ *****************************************************************************/
+static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
+{
+ ;
+}