1 /*****************************************************************************
2 * spu_decoder.c : spu decoder thread
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: spu_decoder.c,v 1.13 2002/03/15 18:20:27 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <string.h> /* memcpy(), memset() */
30 #include <videolan/vlc.h>
33 # include <unistd.h> /* getpid() */
36 #ifdef WIN32 /* getpid() for win32 is located in process.h */
41 #include "video_output.h"
43 #include "stream_control.h"
44 #include "input_ext-dec.h"
46 #include "spu_decoder.h"
48 /*****************************************************************************
50 *****************************************************************************/
51 static int decoder_Probe ( u8 * );
52 static int decoder_Run ( decoder_config_t * );
53 static int InitThread ( spudec_thread_t * );
54 static void EndThread ( spudec_thread_t * );
56 static int SyncPacket ( spudec_thread_t * );
57 static void ParsePacket ( spudec_thread_t * );
58 static int ParseControlSequences( spudec_thread_t *, subpicture_t * );
59 static int ParseRLE ( spudec_thread_t *, subpicture_t *, u8 * );
60 static void RenderSPU ( const vout_thread_t *, picture_t *,
61 const subpicture_t * );
63 /*****************************************************************************
65 *****************************************************************************/
66 void _M( spudec_getfunctions )( function_list_t * p_function_list )
68 p_function_list->functions.dec.pf_probe = decoder_Probe;
69 p_function_list->functions.dec.pf_run = decoder_Run;
72 /*****************************************************************************
73 * Build configuration tree.
74 *****************************************************************************/
79 SET_DESCRIPTION( "DVD subtitles decoder module" )
80 ADD_CAPABILITY( DECODER, 50 )
84 _M( spudec_getfunctions )( &p_module->p_functions->dec );
87 MODULE_DEACTIVATE_START
88 MODULE_DEACTIVATE_STOP
90 /*****************************************************************************
91 * decoder_Probe: probe the decoder and return score
92 *****************************************************************************
93 * Tries to launch a decoder and return score so that the interface is able
95 *****************************************************************************/
96 static int decoder_Probe( u8 *pi_type )
98 return ( *pi_type == DVD_SPU_ES ) ? 0 : -1;
101 /*****************************************************************************
102 * decoder_Run: this function is called just after the thread is created
103 *****************************************************************************/
104 static int decoder_Run( decoder_config_t * p_config )
106 spudec_thread_t * p_spudec;
108 intf_WarnMsg( 3, "spudec: thread launched. Initializing ..." );
110 /* Allocate the memory needed to store the thread's structure */
111 p_spudec = (spudec_thread_t *)malloc( sizeof(spudec_thread_t) );
113 if ( p_spudec == NULL )
115 intf_ErrMsg( "spudec error: not enough memory "
116 "for spudec_CreateThread() to create the new thread" );
117 DecoderError( p_config->p_decoder_fifo );
122 * Initialize the thread properties
124 p_spudec->p_config = p_config;
126 p_spudec->p_fifo = p_config->p_decoder_fifo;
129 * Initialize thread and free configuration
131 p_spudec->p_fifo->b_error = InitThread( p_spudec );
134 * Main loop - it is not executed if an error occured during
137 while( (!p_spudec->p_fifo->b_die) && (!p_spudec->p_fifo->b_error) )
139 if( !SyncPacket( p_spudec ) )
141 ParsePacket( p_spudec );
148 if( p_spudec->p_fifo->b_error )
150 DecoderError( p_spudec->p_fifo );
154 EndThread( p_spudec );
156 if( p_spudec->p_fifo->b_error )
165 /* following functions are local */
167 /*****************************************************************************
168 * InitThread: initialize spu decoder thread
169 *****************************************************************************
170 * This function is called from RunThread and performs the second step of the
171 * initialization. It returns 0 on success. Note that the thread's flag are not
172 * modified inside this function.
173 *****************************************************************************/
174 static int InitThread( spudec_thread_t *p_spudec )
176 /* Find an available video output */
177 vlc_mutex_lock( &p_vout_bank->lock );
179 while( p_vout_bank->i_count == 0 )
181 vlc_mutex_unlock( &p_vout_bank->lock );
183 if( p_spudec->p_fifo->b_die || p_spudec->p_fifo->b_error )
188 msleep( VOUT_OUTMEM_SLEEP );
189 vlc_mutex_lock( &p_vout_bank->lock );
192 /* Take the first video output FIXME: take the best one */
193 p_spudec->p_vout = p_vout_bank->pp_vout[ 0 ];
194 vlc_mutex_unlock( &p_vout_bank->lock );
195 InitBitstream( &p_spudec->bit_stream,
196 p_spudec->p_config->p_decoder_fifo, NULL, NULL );
198 /* Mark thread as running and return */
202 /*****************************************************************************
203 * EndThread: thread destruction
204 *****************************************************************************
205 * This function is called when the thread ends after a sucessful
207 *****************************************************************************/
208 static void EndThread( spudec_thread_t *p_spudec )
213 /*****************************************************************************
214 * SyncPacket: get in sync with the stream
215 *****************************************************************************
216 * This function makes a few sanity checks and returns 0 if it looks like we
217 * are at the beginning of a subpicture packet.
218 *****************************************************************************/
219 static int SyncPacket( spudec_thread_t *p_spudec )
221 /* Re-align the buffer on an 8-bit boundary */
222 RealignBits( &p_spudec->bit_stream );
224 /* The total SPU packet size, often bigger than a PS packet */
225 p_spudec->i_spu_size = GetBits( &p_spudec->bit_stream, 16 );
227 /* The RLE stuff size (remove 4 because we just read 32 bits) */
228 p_spudec->i_rle_size = ShowBits( &p_spudec->bit_stream, 16 ) - 4;
230 /* If the values we got are a bit strange, skip packet */
231 if( !p_spudec->i_spu_size
232 || ( p_spudec->i_rle_size >= p_spudec->i_spu_size ) )
237 RemoveBits( &p_spudec->bit_stream, 16 );
242 /*****************************************************************************
243 * ParsePacket: parse an SPU packet and send it to the video output
244 *****************************************************************************
245 * This function parses the SPU packet and, if valid, sends it to the
247 *****************************************************************************/
248 static void ParsePacket( spudec_thread_t *p_spudec )
250 subpicture_t * p_spu;
252 unsigned int i_offset;
254 intf_WarnMsg( 3, "spudec: trying to gather a 0x%.2x long subtitle",
255 p_spudec->i_spu_size );
257 /* We cannot display a subpicture with no date */
258 if( p_spudec->p_fifo->p_first->i_pts == 0 )
260 intf_WarnMsg( 3, "spudec error: subtitle without a date" );
264 /* Allocate the subpicture internal data. */
265 p_spu = vout_CreateSubPicture( p_spudec->p_vout, MEMORY_SUBPICTURE,
266 sizeof( struct subpicture_sys_s )
267 + p_spudec->i_rle_size * 4 );
268 /* Rationale for the "p_spudec->i_rle_size * 4": we are going to
269 * expand the RLE stuff so that we won't need to read nibbles later
270 * on. This will speed things up a lot. Plus, we'll only need to do
271 * this stupid interlacing stuff once. */
278 /* Fill the p_spu structure */
279 p_spu->pf_render = RenderSPU;
280 p_spu->p_sys->p_data = (void*)p_spu->p_sys
281 + sizeof( struct subpicture_sys_s );
282 p_spu->p_sys->b_palette = 0;
284 /* Get display time now. If we do it later, we may miss the PTS. */
285 p_spu->p_sys->i_pts = p_spudec->p_fifo->p_first->i_pts;
287 /* Allocate the temporary buffer we will parse */
288 p_src = malloc( p_spudec->i_rle_size );
292 intf_ErrMsg( "spudec error: could not allocate p_src" );
293 vout_DestroySubPicture( p_spudec->p_vout, p_spu );
299 i_offset + SPU_CHUNK_SIZE < p_spudec->i_rle_size;
300 i_offset += SPU_CHUNK_SIZE )
302 GetChunk( &p_spudec->bit_stream, p_src + i_offset, SPU_CHUNK_SIZE );
304 /* Abort subtitle parsing if we were requested to stop */
305 if( p_spudec->p_fifo->b_die )
308 vout_DestroySubPicture( p_spudec->p_vout, p_spu );
313 GetChunk( &p_spudec->bit_stream, p_src + i_offset,
314 p_spudec->i_rle_size - i_offset );
317 /* Dump the subtitle info */
318 intf_WarnHexDump( 5, p_spu->p_sys->p_data, p_spudec->i_rle_size );
321 /* Getting the control part */
322 if( ParseControlSequences( p_spudec, p_spu ) )
324 /* There was a parse error, delete the subpicture */
326 vout_DestroySubPicture( p_spudec->p_vout, p_spu );
330 /* At this point, no more GetBit() command is needed, so we have all
331 * the data we need to tell whether the subtitle is valid. Thus we
332 * try to display it and we ignore b_die. */
334 if( ParseRLE( p_spudec, p_spu, p_src ) )
336 /* There was a parse error, delete the subpicture */
338 vout_DestroySubPicture( p_spudec->p_vout, p_spu );
342 intf_WarnMsg( 3, "spudec: total size: 0x%x, RLE offsets: 0x%x 0x%x",
343 p_spudec->i_spu_size,
344 p_spu->p_sys->pi_offset[0], p_spu->p_sys->pi_offset[1] );
346 /* SPU is finished - we can ask the video output to display it */
347 vout_DisplaySubPicture( p_spudec->p_vout, p_spu );
353 /*****************************************************************************
354 * ParseControlSequences: parse all SPU control sequences
355 *****************************************************************************
356 * This is the most important part in SPU decoding. We get dates, palette
357 * information, coordinates, and so on. For more information on the
358 * subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
359 *****************************************************************************/
360 static int ParseControlSequences( spudec_thread_t *p_spudec,
361 subpicture_t * p_spu )
363 /* Our current index in the SPU packet */
364 int i_index = p_spudec->i_rle_size + 4;
366 /* The next start-of-control-sequence index and the previous one */
367 int i_next_seq, i_cur_seq;
369 /* Command time and date */
377 /* XXX: temporary variables */
378 boolean_t b_force_display = 0;
380 /* Initialize the structure */
381 p_spu->i_start = p_spu->i_stop = 0;
382 p_spu->b_ephemer = 0;
386 /* Get the control sequence date */
387 i_date = GetBits( &p_spudec->bit_stream, 16 );
391 i_next_seq = GetBits( &p_spudec->bit_stream, 16 );
393 /* Skip what we just read */
398 i_command = GetBits( &p_spudec->bit_stream, 8 );
403 case SPU_CMD_FORCE_DISPLAY:
405 /* 00 (force displaying) */
406 p_spu->i_start = p_spu->p_sys->i_pts + ( i_date * 11000 );
411 /* Convert the dates in seconds to PTS values */
412 case SPU_CMD_START_DISPLAY:
414 /* 01 (start displaying) */
415 p_spu->i_start = p_spu->p_sys->i_pts + ( i_date * 11000 );
419 case SPU_CMD_STOP_DISPLAY:
421 /* 02 (stop displaying) */
422 p_spu->i_stop = p_spu->p_sys->i_pts + ( i_date * 11000 );
426 case SPU_CMD_SET_PALETTE:
428 /* 03xxxx (palette) */
429 if( p_spudec->p_config->p_demux_data )
431 p_spu->p_sys->b_palette = 1;
432 for( i = 0; i < 4 ; i++ )
434 pi_color = (u8*)p_spudec->p_config->p_demux_data
435 + 4 * GetBits( &p_spudec->bit_stream, 4 );
436 p_spu->p_sys->pi_yuv[3-i][0] = pi_color[2];
437 p_spu->p_sys->pi_yuv[3-i][1] = pi_color[0];
438 p_spu->p_sys->pi_yuv[3-i][2] = pi_color[1];
443 RemoveBits( &p_spudec->bit_stream, 16 );
449 case SPU_CMD_SET_ALPHACHANNEL:
451 /* 04xxxx (alpha channel) */
452 for( i = 0; i < 4 ; i++ )
454 p_spu->p_sys->pi_alpha[3-i]
455 = GetBits( &p_spudec->bit_stream, 4 );
461 case SPU_CMD_SET_COORDINATES:
463 /* 05xxxyyyxxxyyy (coordinates) */
464 p_spu->i_x = GetBits( &p_spudec->bit_stream, 12 );
465 p_spu->i_width = GetBits( &p_spudec->bit_stream, 12 )
468 p_spu->i_y = GetBits( &p_spudec->bit_stream, 12 );
469 p_spu->i_height = GetBits( &p_spudec->bit_stream, 12 )
476 case SPU_CMD_SET_OFFSETS:
478 /* 06xxxxyyyy (byte offsets) */
479 p_spu->p_sys->pi_offset[0] =
480 GetBits( &p_spudec->bit_stream, 16 ) - 4;
482 p_spu->p_sys->pi_offset[1] =
483 GetBits( &p_spudec->bit_stream, 16 ) - 4;
496 /* xx (unknown command) */
497 intf_ErrMsg( "spudec error: unknown command 0x%.2x",
502 /* We need to check for quit commands here */
503 if( p_spudec->p_fifo->b_die )
508 } while( i_command != SPU_CMD_END );
510 } while( i_index == i_next_seq );
512 /* Check that the next sequence index matches the current one */
513 if( i_next_seq != i_cur_seq )
515 intf_ErrMsg( "spudec error: index mismatch (0x%.4x != 0x%.4x)",
516 i_next_seq, i_cur_seq );
520 if( i_index > p_spudec->i_spu_size )
522 intf_ErrMsg( "spudec error: uh-oh, we went too far (0x%.4x > 0x%.4x)",
523 i_index, p_spudec->i_spu_size );
527 if( !p_spu->i_start )
529 intf_ErrMsg( "spudec error: no `start display' command" );
534 /* This subtitle will live for 5 seconds or until the next subtitle */
535 p_spu->i_stop = p_spu->i_start + 500 * 11000;
536 p_spu->b_ephemer = 1;
539 /* Get rid of padding bytes */
540 switch( p_spudec->i_spu_size - i_index )
542 /* Zero or one padding byte, quite usual */
544 RemoveBits( &p_spudec->bit_stream, 8 );
549 /* More than one padding byte - this is very strange, but
550 * we can deal with it */
552 intf_WarnMsg( 2, "spudec warning: %i padding bytes, we usually "
553 "get 0 or 1 of them",
554 p_spudec->i_spu_size - i_index );
556 while( i_index < p_spudec->i_spu_size )
558 RemoveBits( &p_spudec->bit_stream, 8 );
565 if( b_force_display )
567 intf_ErrMsg( "spudec: \"force display\" command" );
568 intf_ErrMsg( "spudec: send mail to <sam@zoy.org> if you "
569 "want to help debugging this" );
572 /* Successfully parsed ! */
576 /*****************************************************************************
577 * ParseRLE: parse the RLE part of the subtitle
578 *****************************************************************************
579 * This part parses the subtitle graphical data and stores it in a more
580 * convenient structure for later decoding. For more information on the
581 * subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
582 *****************************************************************************/
583 static int ParseRLE( spudec_thread_t *p_spudec,
584 subpicture_t * p_spu, u8 * p_src )
588 unsigned int i_width = p_spu->i_width;
589 unsigned int i_height = p_spu->i_height;
590 unsigned int i_x, i_y;
592 u16 *p_dest = (u16 *)p_spu->p_sys->p_data;
594 /* The subtitles are interlaced, we need two offsets */
595 unsigned int i_id = 0; /* Start on the even SPU layer */
596 unsigned int pi_table[ 2 ];
597 unsigned int *pi_offset;
599 boolean_t b_empty_top = 1,
601 unsigned int i_skipped_top = 0,
602 i_skipped_bottom = 0;
604 /* Colormap statistics */
606 int stats[4]; stats[0] = stats[1] = stats[2] = stats[3] = 0;
608 pi_table[ 0 ] = p_spu->p_sys->pi_offset[ 0 ] << 1;
609 pi_table[ 1 ] = p_spu->p_sys->pi_offset[ 1 ] << 1;
611 for( i_y = 0 ; i_y < i_height ; i_y++ )
613 pi_offset = pi_table + i_id;
615 for( i_x = 0 ; i_x < i_width ; i_x += i_code >> 2 )
617 i_code = AddNibble( 0, p_src, pi_offset );
621 i_code = AddNibble( i_code, p_src, pi_offset );
625 i_code = AddNibble( i_code, p_src, pi_offset );
629 i_code = AddNibble( i_code, p_src, pi_offset );
631 if( i_code < 0x0100 )
633 /* If the 14 first bits are set to 0, then it's a
634 * new line. We emulate it. */
635 if( i_code < 0x0004 )
637 i_code |= ( i_width - i_x ) << 2;
641 /* We have a boo boo ! */
642 intf_ErrMsg( "spudec error: unknown RLE code "
651 if( ( (i_code >> 2) + i_x + i_y * i_width ) > i_height * i_width )
653 intf_ErrMsg( "spudec error: out of bounds, %i at (%i,%i) is "
655 i_code >> 2, i_x, i_y, i_width, i_height );
659 /* Try to find the border color */
660 if( p_spu->p_sys->pi_alpha[ i_code & 0x3 ] != 0x00 )
662 i_border = i_code & 0x3;
663 stats[i_border] += i_code >> 2;
666 if( (i_code >> 2) == i_width
667 && p_spu->p_sys->pi_alpha[ i_code & 0x3 ] == 0x00 )
671 /* This is a blank top line, we skip it */
676 /* We can't be sure the current lines will be skipped,
677 * so we store the code just in case. */
686 /* We got a valid code, store it */
689 /* Valid code means no blank line */
692 i_skipped_bottom = 0;
696 /* Check that we didn't go too far */
699 intf_ErrMsg( "spudec error: i_x overflowed, %i > %i",
704 /* Byte-align the stream */
705 if( *pi_offset & 0x1 )
714 /* We shouldn't get any padding bytes */
717 intf_ErrMsg( "spudec: padding bytes found in RLE sequence" );
718 intf_ErrMsg( "spudec: send mail to <sam@zoy.org> if you "
719 "want to help debugging this" );
721 /* Skip them just in case */
722 while( i_y < i_height )
724 *p_dest++ = i_width << 2;
731 intf_WarnMsg( 3, "spudec: valid subtitle, size: %ix%i, position: %i,%i",
732 p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
734 /* Crop if necessary */
735 if( i_skipped_top || i_skipped_bottom )
737 p_spu->i_y += i_skipped_top;
738 p_spu->i_height -= i_skipped_top + i_skipped_bottom;
740 intf_WarnMsg( 3, "spudec: cropped to: %ix%i, position: %i,%i",
741 p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
744 /* Handle color if no palette was found */
745 if( !p_spu->p_sys->b_palette )
747 int i, i_inner = -1, i_shade = -1;
749 /* Set the border color */
750 p_spu->p_sys->pi_yuv[i_border][0] = 0x00;
751 p_spu->p_sys->pi_yuv[i_border][1] = 0x80;
752 p_spu->p_sys->pi_yuv[i_border][2] = 0x80;
755 /* Find the inner colors */
756 for( i = 0 ; i < 4 && i_inner == -1 ; i++ )
764 for( ; i < 4 && i_shade == -1 ; i++ )
768 if( stats[i] > stats[i_inner] )
780 /* Set the inner color */
783 p_spu->p_sys->pi_yuv[i_inner][0] = 0xff;
784 p_spu->p_sys->pi_yuv[i_inner][1] = 0x80;
785 p_spu->p_sys->pi_yuv[i_inner][2] = 0x80;
788 /* Set the anti-aliasing color */
791 p_spu->p_sys->pi_yuv[i_shade][0] = 0x80;
792 p_spu->p_sys->pi_yuv[i_shade][1] = 0x80;
793 p_spu->p_sys->pi_yuv[i_shade][2] = 0x80;
796 intf_WarnMsg( 3, "spudec: using custom palette (border %i, inner %i, "
797 "shade %i)", i_border, i_inner, i_shade );
803 /*****************************************************************************
804 * RenderSPU: draw an SPU on a picture
805 *****************************************************************************
806 * This is a fast implementation of the subpicture drawing code. The data
807 * has been preprocessed once, so we don't need to parse the RLE buffer again
808 * and again. Most sanity checks are already done so that this routine can be
809 * as fast as possible.
810 *****************************************************************************/
811 static void RenderSPU( const vout_thread_t *p_vout, picture_t *p_pic,
812 const subpicture_t *p_spu )
814 /* Common variables */
817 u16 *p_source = (u16 *)p_spu->p_sys->p_data;
823 int i_xscale, i_yscale, i_width, i_height, i_ytmp, i_yreal, i_ynext;
825 switch( p_vout->output.i_chroma )
827 /* I420 target, no scaling */
832 p_dest = p_pic->p->p_pixels + p_spu->i_x + p_spu->i_width
833 + p_vout->output.i_width * ( p_spu->i_y + p_spu->i_height );
835 /* Draw until we reach the bottom of the subtitle */
836 for( i_y = p_spu->i_height * p_vout->output.i_width ;
838 i_y -= p_vout->output.i_width )
840 /* Draw until we reach the end of the line */
841 for( i_x = p_spu->i_width ; i_x ; )
843 /* Get the RLE part, then draw the line */
844 i_color = *p_source & 0x3;
846 switch( p_spu->p_sys->pi_alpha[ i_color ] )
849 i_x -= *p_source++ >> 2;
853 i_len = *p_source++ >> 2;
854 memset( p_dest - i_x - i_y,
855 p_spu->p_sys->pi_yuv[i_color][0], i_len );
860 /* FIXME: we should do transparency */
861 i_len = *p_source++ >> 2;
862 memset( p_dest - i_x - i_y,
863 p_spu->p_sys->pi_yuv[i_color][0], i_len );
872 /* RV16 target, scaling */
875 /* FIXME: get this from the DVD */
876 p_clut16[0] = 0xaaaa; p_clut16[1] = 0xffff;
877 p_clut16[2] = 0x8888; p_clut16[3] = 0x0000;
879 i_xscale = ( p_vout->output.i_width << 6 ) / p_vout->render.i_width;
880 i_yscale = ( p_vout->output.i_height << 6 ) / p_vout->render.i_height;
882 i_width = p_spu->i_width * i_xscale;
883 i_height = p_spu->i_height * i_yscale;
885 p_dest = p_pic->p->p_pixels + ( i_width >> 6 ) * 2
886 /* Add the picture coordinates and the SPU coordinates */
887 + ( (p_spu->i_x * i_xscale) >> 6 ) * 2
888 + ( (p_spu->i_y * i_yscale) >> 6 ) * p_vout->output.i_width * 2;
890 /* Draw until we reach the bottom of the subtitle */
891 for( i_y = 0 ; i_y < i_height ; )
896 /* Check whether we need to draw one line or more than one */
897 if( i_ytmp + 1 >= ( i_y >> 6 ) )
899 /* Just one line : we precalculate i_y >> 6 */
900 i_yreal = p_vout->output.i_width * 2 * i_ytmp;
902 /* Draw until we reach the end of the line */
903 for( i_x = i_width ; i_x ; )
905 /* Get the RLE part, then draw the line */
906 i_color = *p_source & 0x3;
908 switch( p_spu->p_sys->pi_alpha[ i_color ] )
911 i_x -= i_xscale * ( *p_source++ >> 2 );
915 i_len = i_xscale * ( *p_source++ >> 2 );
916 memset( p_dest - 2 * ( i_x >> 6 ) + i_yreal,
918 2 * ( ( i_len >> 6 ) + 1 ) );
923 /* FIXME: we should do transparency */
924 i_len = i_xscale * ( *p_source++ >> 2 );
925 memset( p_dest - 2 * ( i_x >> 6 ) + i_yreal,
927 2 * ( ( i_len >> 6 ) + 1 ) );
936 i_yreal = p_vout->output.i_width * 2 * i_ytmp;
937 i_ynext = p_vout->output.i_width * 2 * i_y >> 6;
939 /* Draw until we reach the end of the line */
940 for( i_x = i_width ; i_x ; )
942 /* Get the RLE part, then draw as many lines as needed */
943 i_color = *p_source & 0x3;
945 switch( p_spu->p_sys->pi_alpha[ i_color ] )
948 i_x -= i_xscale * ( *p_source++ >> 2 );
952 i_len = i_xscale * ( *p_source++ >> 2 );
953 for( i_ytmp = i_yreal ; i_ytmp < i_ynext ;
954 i_ytmp += p_vout->output.i_width * 2 )
956 memset( p_dest - 2 * ( i_x >> 6 ) + i_ytmp,
958 2 * ( ( i_len >> 6 ) + 1 ) );
964 /* FIXME: we should do transparency */
965 i_len = i_xscale * ( *p_source++ >> 2 );
966 for( i_ytmp = i_yreal ; i_ytmp < i_ynext ;
967 i_ytmp += p_vout->output.i_width * 2 )
969 memset( p_dest - 2 * ( i_x >> 6 ) + i_ytmp,
971 2 * ( ( i_len >> 6 ) + 1 ) );
983 intf_ErrMsg( "vout error: unknown chroma, can't render SPU" );