Commit 8b09b55d authored by Sam Hocevar's avatar Sam Hocevar

* ./modules/access/dvdplay/access.c: activated button highlighting.

  * ./modules/codec/spudec/parse.c: implemented subtitle cropping and
    temporarily disabled subtitle cropping.
  * ./modules/codec/spudec/render.c: split RenderSPU into chroma-specific
    functions.
parent 2401b662
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.56 2002/07/23 00:39:16 sam Exp $
* $Id: video.h,v 1.57 2002/11/06 18:07:57 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -166,7 +166,6 @@ struct subpicture_t
/* Type and flags - should NOT be modified except by the vout thread */
int i_type; /* type */
int i_status; /* flags */
int i_size; /* data size */
subpicture_t * p_next; /* next subtitle to be displayed */
/* Date properties */
......@@ -199,13 +198,13 @@ struct subpicture_t
} type;
#endif
/* The subpicture rendering routine */
void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
/* The subpicture rendering and destruction routines */
void ( *pf_render ) ( vout_thread_t *, picture_t *, const subpicture_t * );
void ( *pf_destroy ) ( subpicture_t * );
/* Private data - the subtitle plugin might want to put stuff here to
* keep track of the subpicture */
subpicture_sys_t *p_sys; /* subpicture data */
void *p_sys_orig; /* pointer before memalign */
};
/* Subpicture type */
......@@ -216,5 +215,4 @@ struct subpicture_t
#define FREE_SUBPICTURE 0 /* free and not allocated */
#define RESERVED_SUBPICTURE 1 /* allocated and reserved */
#define READY_SUBPICTURE 2 /* ready for display */
#define DESTROYED_SUBPICTURE 3 /* allocated but not used anymore */
......@@ -5,7 +5,7 @@
* thread, and destroy a previously opened video output thread.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video_output.h,v 1.84 2002/10/17 16:03:18 sam Exp $
* $Id: video_output.h,v 1.85 2002/11/06 18:07:57 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -158,7 +158,7 @@ VLC_EXPORT( void, vout_PlacePicture, ( vout_thread_t *, int, int, i
picture_t * vout_RenderPicture ( vout_thread_t *, picture_t *,
subpicture_t * );
VLC_EXPORT( subpicture_t *, vout_CreateSubPicture, ( vout_thread_t *, int, int ) );
VLC_EXPORT( subpicture_t *, vout_CreateSubPicture, ( vout_thread_t *, int ) );
VLC_EXPORT( void, vout_DestroySubPicture, ( vout_thread_t *, subpicture_t * ) );
VLC_EXPORT( void, vout_DisplaySubPicture, ( vout_thread_t *, subpicture_t * ) );
......
......@@ -2,7 +2,7 @@
* access.c: access capabilities for dvdplay plugin.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: access.c,v 1.4 2002/10/26 15:24:19 gbazin Exp $
* $Id: access.c,v 1.5 2002/11/06 18:07:57 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -87,7 +87,7 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
p_dvd = malloc( sizeof(dvd_data_t) );
if( p_dvd == NULL )
{
msg_Err( p_input, "dvdplay error: out of memory" );
msg_Err( p_input, "out of memory" );
return -1;
}
......@@ -114,7 +114,7 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
if( p_dvd->vmg == NULL )
{
msg_Err( p_input, "dvdplay error: can't open source" );
msg_Err( p_input, "cannot open %s", psz_source );
free( p_dvd );
return -1;
}
......@@ -184,6 +184,18 @@ int E_(OpenDVD) ( vlc_object_t *p_this )
p_input->psz_demux = "dvdplay";
/* FIXME: we might lose variables here */
var_Create( p_input, "x-start", VLC_VAR_INTEGER );
var_Create( p_input, "y-start", VLC_VAR_INTEGER );
var_Create( p_input, "x-end", VLC_VAR_INTEGER );
var_Create( p_input, "y-end", VLC_VAR_INTEGER );
var_Create( p_input, "color", VLC_VAR_ADDRESS );
var_Create( p_input, "contrast", VLC_VAR_ADDRESS );
var_Create( p_input, "highlight", VLC_VAR_BOOL );
var_Create( p_input, "highlight-mutex", VLC_VAR_MUTEX );
return 0;
}
......@@ -195,6 +207,17 @@ void E_(CloseDVD) ( vlc_object_t *p_this )
input_thread_t * p_input = (input_thread_t *)p_this;
dvd_data_t * p_dvd = (dvd_data_t *)p_input->p_access_data;
var_Destroy( p_input, "highlight-mutex" );
var_Destroy( p_input, "highlight" );
var_Destroy( p_input, "x-start" );
var_Destroy( p_input, "x-end" );
var_Destroy( p_input, "y-start" );
var_Destroy( p_input, "y-end" );
var_Destroy( p_input, "color" );
var_Destroy( p_input, "contrast" );
/* close libdvdplay */
dvdplay_close( p_dvd->vmg );
......@@ -350,6 +373,7 @@ static void pf_vmg_callback( void* p_args, dvdplay_event_t event )
{
input_thread_t * p_input;
dvd_data_t * p_dvd;
vlc_value_t val;
int i;
p_input = (input_thread_t*)p_args;
......@@ -407,11 +431,38 @@ static void pf_vmg_callback( void* p_args, dvdplay_event_t event )
case COMPLETE_VIDEO:
break;
case NEW_HIGHLIGHT:
if( var_Get( p_input, "highlight-mutex", &val ) == VLC_SUCCESS )
{
vlc_mutex_t *p_mutex = val.p_address;
vlc_mutex_lock( p_mutex );
/* Retrieve the highlight from dvdplay */
dvdplay_highlight( p_dvd->vmg, &p_dvd->hli );
/* Fill our internal variables with this data */
val.i_int = p_dvd->hli.i_x_start;
var_Set( p_input, "x-start", val );
val.i_int = p_dvd->hli.i_y_start;
var_Set( p_input, "y-start", val );
val.i_int = p_dvd->hli.i_x_end;
var_Set( p_input, "x-end", val );
val.i_int = p_dvd->hli.i_y_end;
var_Set( p_input, "y-end", val );
val.p_address = (void *)p_dvd->hli.pi_color;
var_Set( p_input, "color", val );
val.p_address = (void *)p_dvd->hli.pi_contrast;
var_Set( p_input, "contrast", val );
/* Tell the SPU decoder that there's a new highlight */
val.b_bool = VLC_TRUE;
var_Set( p_input, "highlight", val );
vlc_mutex_unlock( p_mutex );
}
break;
default:
msg_Err( p_input, "unknown event from libdvdplay (%d)",
event );
msg_Err( p_input, "unknown event from libdvdplay (%d)", event );
}
return;
......@@ -494,3 +545,4 @@ static int dvdNewPGC( input_thread_t * p_input )
return 0;
}
......@@ -2,7 +2,7 @@
* dvd.h: structure of the dvdplay plugin
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd.h,v 1.1 2002/08/04 17:23:42 sam Exp $
* $Id: dvd.h,v 1.2 2002/11/06 18:07:57 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -56,6 +56,7 @@ typedef struct
dvdplay_event_t event;
dvdplay_ctrl_t control;
dvdplay_highlight_t hli;
} dvd_data_t;
......@@ -2,7 +2,7 @@
* intf.c: interface for DVD video manager
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: intf.c,v 1.2 2002/10/17 16:03:18 sam Exp $
* $Id: intf.c,v 1.3 2002/11/06 18:07:57 sam Exp $
*
* Authors: Stphane Borel <stef@via.ecp.fr>
*
......@@ -33,6 +33,7 @@
#include "stream_control.h"
#include "input_ext-intf.h"
#include "input_ext-dec.h"
#include "dvd.h"
......@@ -190,10 +191,6 @@ static void RunIntf( intf_thread_t *p_intf )
p_intf->p_sys->b_move = VLC_FALSE;
}
msg_Dbg( p_intf, "send button coordinates: %dx%d",
p_intf->p_sys->control.mouse.i_x,
p_intf->p_sys->control.mouse.i_y );
/* we can safely interact with libdvdplay
* with the stream lock */
vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
......@@ -343,7 +340,6 @@ int dvdIntfStillTime( intf_thread_t *p_intf, int i_sec )
#endif
vlc_mutex_unlock( &p_intf->change_lock );
return 0;
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* parse.c: SPU parser
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: parse.c,v 1.3 2002/10/31 09:40:26 gbazin Exp $
* $Id: parse.c,v 1.4 2002/11/06 18:07:57 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -44,14 +44,20 @@
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int ParseControlSequences( spudec_thread_t *, subpicture_t * );
static int ParseRLE ( spudec_thread_t *, subpicture_t *, u8 * );
static int ParseControlSeq ( spudec_thread_t *, subpicture_t * );
static int ParseRLE ( spudec_thread_t *, subpicture_t *, uint8_t * );
static void DestroySPU ( subpicture_t * );
static void UpdateSPU ( subpicture_t *, vlc_object_t * );
static int CropCallback ( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* AddNibble: read a nibble from a source packet and add it to our integer.
*****************************************************************************/
static inline unsigned int AddNibble( unsigned int i_code,
u8 *p_src, int *pi_index )
uint8_t *p_src, int *pi_index )
{
if( *pi_index & 0x1 )
{
......@@ -101,7 +107,7 @@ int E_(SyncPacket)( spudec_thread_t *p_spudec )
void E_(ParsePacket)( spudec_thread_t *p_spudec )
{
subpicture_t * p_spu;
u8 * p_src;
uint8_t * p_src;
unsigned int i_offset;
mtime_t i_pts;
......@@ -117,22 +123,32 @@ void E_(ParsePacket)( spudec_thread_t *p_spudec )
}
/* Allocate the subpicture internal data. */
p_spu = vout_CreateSubPicture( p_spudec->p_vout, MEMORY_SUBPICTURE,
sizeof( subpicture_sys_t )
+ p_spudec->i_rle_size * 4 );
p_spu = vout_CreateSubPicture( p_spudec->p_vout, MEMORY_SUBPICTURE );
if( p_spu == NULL )
{
return;
}
/* Rationale for the "p_spudec->i_rle_size * 4": we are going to
* expand the RLE stuff so that we won't need to read nibbles later
* on. This will speed things up a lot. Plus, we'll only need to do
* this stupid interlacing stuff once. */
p_spu->p_sys = malloc( sizeof( subpicture_sys_t )
+ p_spudec->i_rle_size * 4 );
if( p_spu == NULL )
if( p_spu->p_sys == NULL )
{
vout_DestroySubPicture( p_spudec->p_vout, p_spu );
return;
}
/* Fill the p_spu structure */
vlc_mutex_init( p_spudec->p_fifo, &p_spu->p_sys->lock );
p_spu->pf_render = E_(RenderSPU);
p_spu->p_sys->p_data = (u8*)p_spu->p_sys + sizeof( subpicture_sys_t );
p_spu->pf_destroy = DestroySPU;
p_spu->p_sys->p_data = (uint8_t*)p_spu->p_sys + sizeof( subpicture_sys_t );
p_spu->p_sys->b_palette = VLC_FALSE;
p_spu->p_sys->pi_alpha[0] = 0x00;
......@@ -140,9 +156,30 @@ void E_(ParsePacket)( spudec_thread_t *p_spudec )
p_spu->p_sys->pi_alpha[2] = 0x0f;
p_spu->p_sys->pi_alpha[3] = 0x0f;
p_spu->p_sys->b_crop = VLC_FALSE;
/* Get display time now. If we do it later, we may miss the PTS. */
p_spu->p_sys->i_pts = i_pts;
/* Attach to our input thread */
p_spu->p_sys->p_input = vlc_object_find( p_spudec->p_fifo,
VLC_OBJECT_INPUT, FIND_PARENT );
if( p_spu->p_sys->p_input )
{
vlc_value_t val;
if( !var_Get( p_spu->p_sys->p_input, "highlight-mutex", &val ) )
{
vlc_mutex_t *p_mutex = val.p_address;
vlc_mutex_lock( p_mutex );
UpdateSPU( p_spu, VLC_OBJECT(p_spu->p_sys->p_input) );
var_AddCallback( p_spu->p_sys->p_input,
"highlight", CropCallback, p_spu );
vlc_mutex_unlock( p_mutex );
}
}
/* Allocate the temporary buffer we will parse */
p_src = malloc( p_spudec->i_rle_size );
......@@ -176,7 +213,7 @@ void E_(ParsePacket)( spudec_thread_t *p_spudec )
#endif
/* Getting the control part */
if( ParseControlSequences( p_spudec, p_spu ) )
if( ParseControlSeq( p_spudec, p_spu ) )
{
/* There was a parse error, delete the subpicture */
free( p_src );
......@@ -203,18 +240,20 @@ void E_(ParsePacket)( spudec_thread_t *p_spudec )
/* SPU is finished - we can ask the video output to display it */
vout_DisplaySubPicture( p_spudec->p_vout, p_spu );
/* TODO: do stuff! */
/* Clean up */
free( p_src );
}
/*****************************************************************************
* ParseControlSequences: parse all SPU control sequences
* ParseControlSeq: parse all SPU control sequences
*****************************************************************************
* This is the most important part in SPU decoding. We get dates, palette
* information, coordinates, and so on. For more information on the
* subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
*****************************************************************************/
static int ParseControlSequences( spudec_thread_t *p_spudec,
static int ParseControlSeq( spudec_thread_t *p_spudec,
subpicture_t * p_spu )
{
/* Our current index in the SPU packet */
......@@ -224,7 +263,7 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
int i_next_seq = 0, i_cur_seq = 0;
/* Command and date */
u8 i_command = SPU_CMD_END;
uint8_t i_command = SPU_CMD_END;
mtime_t date = 0;
int i, pi_alpha[4];
......@@ -275,12 +314,12 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
if( p_spudec->p_fifo->p_demux_data
&& *(int*)p_spudec->p_fifo->p_demux_data == 0xBeeF )
{
u32 i_color;
uint32_t i_color;
p_spu->p_sys->b_palette = VLC_TRUE;
for( i = 0; i < 4 ; i++ )
{
i_color = ((u32*)((char*)p_spudec->p_fifo->
i_color = ((uint32_t*)((char*)p_spudec->p_fifo->
p_demux_data + sizeof(int)))[
GetBits(&p_spudec->bit_stream, 4) ];
......@@ -431,7 +470,7 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
* subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
*****************************************************************************/
static int ParseRLE( spudec_thread_t *p_spudec,
subpicture_t * p_spu, u8 * p_src )
subpicture_t * p_spu, uint8_t * p_src )
{
unsigned int i_code;
......@@ -439,17 +478,19 @@ static int ParseRLE( spudec_thread_t *p_spudec,
unsigned int i_height = p_spu->i_height;
unsigned int i_x, i_y;
u16 *p_dest = (u16 *)p_spu->p_sys->p_data;
uint16_t *p_dest = (uint16_t *)p_spu->p_sys->p_data;
/* The subtitles are interlaced, we need two offsets */
unsigned int i_id = 0; /* Start on the even SPU layer */
unsigned int pi_table[ 2 ];
unsigned int *pi_offset;
#if 0 /* cropping */
vlc_bool_t b_empty_top = VLC_TRUE,
b_empty_bottom = VLC_FALSE;
unsigned int i_skipped_top = 0,
i_skipped_bottom = 0;
#endif
/* Colormap statistics */
int i_border = -1;
......@@ -513,6 +554,7 @@ static int ParseRLE( spudec_thread_t *p_spudec,
stats[i_border] += i_code >> 2;
}
#if 0 /* cropping */
if( (i_code >> 2) == i_width
&& p_spu->p_sys->pi_alpha[ i_code & 0x3 ] == 0x00 )
{
......@@ -541,6 +583,9 @@ static int ParseRLE( spudec_thread_t *p_spudec,
b_empty_bottom = VLC_FALSE;
i_skipped_bottom = 0;
}
#else
*p_dest++ = i_code;
#endif
}
/* Check that we didn't go too far */
......@@ -581,6 +626,7 @@ static int ParseRLE( spudec_thread_t *p_spudec,
msg_Dbg( p_spudec->p_fifo, "valid subtitle, size: %ix%i, position: %i,%i",
p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
#if 0 /* cropping */
/* Crop if necessary */
if( i_skipped_top || i_skipped_bottom )
{
......@@ -590,6 +636,7 @@ static int ParseRLE( spudec_thread_t *p_spudec,
msg_Dbg( p_spudec->p_fifo, "cropped to: %ix%i, position: %i,%i",
p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
}
#endif
/* Handle color if no palette was found */
if( !p_spu->p_sys->b_palette )
......@@ -651,3 +698,82 @@ static int ParseRLE( spudec_thread_t *p_spudec,
return VLC_SUCCESS;
}
/*****************************************************************************
* DestroySPU: subpicture destructor
*****************************************************************************/
static void DestroySPU( subpicture_t *p_spu )
{
if( p_spu->p_sys->p_input )
{
/* Detach from our input thread */
var_DelCallback( p_spu->p_sys->p_input, "highlight",
CropCallback, p_spu );
vlc_object_release( p_spu->p_sys->p_input );
}
vlc_mutex_destroy( &p_spu->p_sys->lock );
free( p_spu->p_sys );
}
/*****************************************************************************
* UpdateSPU: update subpicture settings
*****************************************************************************
* This function is called from CropCallback and at initialization time, to
* retrieve crop information from the input.
*****************************************************************************/
static void UpdateSPU( subpicture_t *p_spu, vlc_object_t *p_object )
{
vlc_value_t val;
if( var_Get( p_object, "highlight", &val ) )
{
return;
}
p_spu->p_sys->b_crop = val.b_bool;
if( !p_spu->p_sys->b_crop )
{
return;
}
var_Get( p_object, "x-start", &val );
p_spu->p_sys->i_x_start = val.i_int;
var_Get( p_object, "y-start", &val );
p_spu->p_sys->i_y_start = val.i_int;
var_Get( p_object, "x-end", &val );
p_spu->p_sys->i_x_end = val.i_int;
var_Get( p_object, "y-end", &val );
p_spu->p_sys->i_y_end = val.i_int;
#if 0
if( var_Get( p_object, "color", &val ) == VLC_SUCCESS )
{
p_spu->p_sys->pi_color[0] = ((uint8_t *)val.p_address)[0];
p_spu->p_sys->pi_color[1] = ((uint8_t *)val.p_address)[1];
p_spu->p_sys->pi_color[2] = ((uint8_t *)val.p_address)[2];
p_spu->p_sys->pi_color[3] = ((uint8_t *)val.p_address)[3];
}
#endif
if( var_Get( p_object, "contrast", &val ) == VLC_SUCCESS )
{
p_spu->p_sys->pi_alpha[0] = ((uint8_t *)val.p_address)[0];
p_spu->p_sys->pi_alpha[1] = ((uint8_t *)val.p_address)[1];
p_spu->p_sys->pi_alpha[2] = ((uint8_t *)val.p_address)[2];
p_spu->p_sys->pi_alpha[3] = ((uint8_t *)val.p_address)[3];
}
}
/*****************************************************************************
* CropCallback: called when the highlight properties are changed
*****************************************************************************
* This callback is called from the input thread when we need cropping
*****************************************************************************/
static int CropCallback( vlc_object_t *p_object, char const *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
UpdateSPU( (subpicture_t *)p_data, p_object );
return VLC_SUCCESS;
}
......@@ -2,7 +2,7 @@
* render.c : SPU renderer
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: render.c,v 1.2 2002/09/30 18:30:26 titer Exp $
* $Id: render.c,v 1.3 2002/11/06 18:07:57 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Rudolf Cornelissen <rag.cornelissen@inter.nl.net>
......@@ -43,6 +43,18 @@
#include "spudec.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static void RenderI420( vout_thread_t *, picture_t *, const subpicture_t *,
vlc_bool_t );
static void RenderRV16( vout_thread_t *, picture_t *, const subpicture_t *,
vlc_bool_t );
static void RenderRV32( vout_thread_t *, picture_t *, const subpicture_t *,
vlc_bool_t );
static void RenderYUY2( vout_thread_t *, picture_t *, const subpicture_t *,
vlc_bool_t );
/*****************************************************************************
* RenderSPU: draw an SPU on a picture
*****************************************************************************
......@@ -53,10 +65,44 @@
*****************************************************************************/
void E_(RenderSPU)( vout_thread_t *p_vout, picture_t *p_pic,
const subpicture_t *p_spu )
{
switch( p_vout->output.i_chroma )
{
/* I420 target, no scaling */
case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('I','Y','U','V'):
case VLC_FOURCC('Y','V','1','2'):
RenderI420( p_vout, p_pic, p_spu, p_spu->p_sys->b_crop );
break;
/* RV16 target, scaling */
case VLC_FOURCC('R','V','1','6'):
RenderRV16( p_vout, p_pic, p_spu, p_spu->p_sys->b_crop );
break;
/* RV32 target, scaling */
case VLC_FOURCC('R','V','2','4'):
case VLC_FOURCC('R','V','3','2'):
RenderRV32( p_vout, p_pic, p_spu, p_spu->p_sys->b_crop );
break;
/* NVidia overlay, no scaling */
case VLC_FOURCC('Y','U','Y','2'):
RenderYUY2( p_vout, p_pic, p_spu, p_spu->p_sys->b_crop );
break;
default:
msg_Err( p_vout, "unknown chroma, can't render SPU" );
break;
}
}
/* Following functions are local */
static void RenderI420( vout_thread_t *p_vout, picture_t *p_pic,
const subpicture_t *p_spu, vlc_bool_t b_crop )
{
/* Common variables */
u16 p_clut16[4];
u32 p_clut32[4];
u8 *p_dest;
u8 *p_destptr;
u16 *p_source = (u16 *)p_spu->p_sys->p_data;
......@@ -64,33 +110,37 @@ void E_(RenderSPU)( vout_thread_t *p_vout, picture_t *p_pic,
int i_x, i_y;
int i_len, i_color;
u16 i_colprecomp, i_destalpha;
u8 i_cnt;
/* RGB-specific */
int i_xscale, i_yscale, i_width, i_height, i_ytmp, i_yreal, i_ynext;
switch( p_vout->output.i_chroma )
{
/* I420 target, no scaling */
case VLC_FOURCC('I','4','2','0'):
case VLC_FOURCC('I','Y','U','V'):
case VLC_FOURCC('Y','V','1','2'):
/* Crop-specific */
int i_x_start, i_y_start, i_x_end, i_y_end;
p_dest = p_pic->Y_PIXELS + p_spu->i_x + p_spu->i_width
+ p_pic->Y_PITCH * ( p_spu->i_y + p_spu->i_height );
i_x_start = p_spu->i_width - p_spu->p_sys->i_x_end;
i_y_start = p_pic->Y_PITCH * (p_spu->i_height - p_spu->p_sys->i_y_end );
i_x_end = p_spu->i_width - p_spu->p_sys->i_x_start;
i_y_end = p_pic->Y_PITCH * (p_spu->i_height - p_spu->p_sys->i_y_start );
/* Draw until we reach the bottom of the subtitle */
for( i_y = p_spu->i_height * p_pic->Y_PITCH ;
i_y ;
i_y -= p_pic->Y_PITCH )
{
/* Draw until we reach the end of the line */
for( i_x = p_spu->i_width ; i_x ; )
for( i_x = p_spu->i_width ; i_x ; i_x -= i_len )
{
/* Get the RLE part, then draw the line */
i_color = *p_source & 0x3;
i_len = *p_source++ >> 2;
if( b_crop
&& ( i_x < i_x_start || i_x > i_x_end
|| i_y < i_y_start || i_y > i_y_end ) )
{
continue;
}