]> git.sesse.net Git - vlc/blob - modules/codec/spudec/parse.c
* src/video_output/vout_subpictures.c : New OSD channels
[vlc] / modules / codec / spudec / parse.c
1 /*****************************************************************************
2  * parse.c: SPU parser
3  *****************************************************************************
4  * Copyright (C) 2000-2001 VideoLAN
5  * $Id$
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *          Laurent Aimar <fenrir@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include <vlc/vlc.h>
29 #include <vlc/vout.h>
30 #include <vlc/decoder.h>
31
32 #include "spudec.h"
33
34 /*****************************************************************************
35  * Local prototypes.
36  *****************************************************************************/
37 static int  ParseControlSeq  ( decoder_t *, subpicture_t * );
38 static int  ParseRLE         ( decoder_t *, subpicture_t * );
39
40 static void DestroySPU       ( subpicture_t * );
41
42 static void UpdateSPU        ( subpicture_t *, vlc_object_t * );
43 static int  CropCallback     ( vlc_object_t *, char const *,
44                                vlc_value_t, vlc_value_t, void * );
45
46 /*****************************************************************************
47  * AddNibble: read a nibble from a source packet and add it to our integer.
48  *****************************************************************************/
49 static inline unsigned int AddNibble( unsigned int i_code,
50                                       uint8_t *p_src, int *pi_index )
51 {
52     if( *pi_index & 0x1 )
53     {
54         return( i_code << 4 | ( p_src[(*pi_index)++ >> 1] & 0xf ) );
55     }
56     else
57     {
58         return( i_code << 4 | p_src[(*pi_index)++ >> 1] >> 4 );
59     }
60 }
61
62 /*****************************************************************************
63  * ParsePacket: parse an SPU packet and send it to the video output
64  *****************************************************************************
65  * This function parses the SPU packet and, if valid, sends it to the
66  * video output.
67  *****************************************************************************/
68 void E_(ParsePacket)( decoder_t *p_dec)
69 {
70     decoder_sys_t *p_sys = p_dec->p_sys;
71
72     subpicture_t  *p_spu;
73     int           i_spu_channel;
74
75     /* Allocate the subpicture internal data. */
76     p_spu = vout_CreateSubPicture( p_sys->p_vout, p_sys->i_subpic_channel,
77                                    MEMORY_SUBPICTURE );
78     if( p_spu == NULL )
79     {
80         return;
81     }
82
83     /* Rationale for the "p_spudec->i_rle_size * 4": we are going to
84      * expand the RLE stuff so that we won't need to read nibbles later
85      * on. This will speed things up a lot. Plus, we'll only need to do
86      * this stupid interlacing stuff once. */
87     p_spu->p_sys = malloc( sizeof( subpicture_sys_t ) + 4*p_sys->i_rle_size );
88
89     /* Fill the p_spu structure */
90     vlc_mutex_init( p_dec, &p_spu->p_sys->lock );
91
92     p_spu->pf_render = E_(RenderSPU);
93     p_spu->pf_destroy = DestroySPU;
94     p_spu->p_sys->p_data = (uint8_t*)p_spu->p_sys + sizeof( subpicture_sys_t );
95     p_spu->p_sys->b_palette = VLC_FALSE;
96
97     p_spu->p_sys->pi_alpha[0] = 0x00;
98     p_spu->p_sys->pi_alpha[1] = 0x0f;
99     p_spu->p_sys->pi_alpha[2] = 0x0f;
100     p_spu->p_sys->pi_alpha[3] = 0x0f;
101
102     p_spu->p_sys->b_crop = VLC_FALSE;
103
104     /* Get display time now. If we do it later, we may miss the PTS. */
105     p_spu->p_sys->i_pts = p_sys->i_pts;
106
107     /* Attach to our input thread */
108     p_spu->p_sys->p_input = vlc_object_find( p_dec,
109                                              VLC_OBJECT_INPUT, FIND_PARENT );
110     if( p_spu->p_sys->p_input )
111     {
112         vlc_value_t val;
113
114         if( !var_Get( p_spu->p_sys->p_input, "highlight-mutex", &val ) )
115         {
116             vlc_mutex_t *p_mutex = val.p_address;
117
118             vlc_mutex_lock( p_mutex );
119             UpdateSPU( p_spu, VLC_OBJECT(p_spu->p_sys->p_input) );
120
121             var_AddCallback( p_spu->p_sys->p_input,
122                              "highlight", CropCallback, p_spu );
123             vlc_mutex_unlock( p_mutex );
124         }
125     }
126
127     /* Getting the control part */
128     if( ParseControlSeq( p_dec, p_spu ) )
129     {
130         /* There was a parse error, delete the subpicture */
131         vout_DestroySubPicture( p_sys->p_vout, p_spu );
132         return;
133     }
134
135      /* We try to display it */
136     if( ParseRLE( p_dec, p_spu ) )
137     {
138         /* There was a parse error, delete the subpicture */
139         vout_DestroySubPicture( p_sys->p_vout, p_spu );
140         return;
141     }
142
143     msg_Dbg( p_dec, "total size: 0x%x, RLE offsets: 0x%x 0x%x",
144              p_sys->i_spu_size,
145              p_spu->p_sys->pi_offset[0], p_spu->p_sys->pi_offset[1] );
146
147     /* SPU is finished - we can ask the video output to display it */
148     vout_DisplaySubPicture( p_sys->p_vout, p_spu );
149
150     /* TODO: do stuff! */
151 }
152
153 /*****************************************************************************
154  * ParseControlSeq: parse all SPU control sequences
155  *****************************************************************************
156  * This is the most important part in SPU decoding. We get dates, palette
157  * information, coordinates, and so on. For more information on the
158  * subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
159  *****************************************************************************/
160 static int ParseControlSeq( decoder_t *p_dec, subpicture_t * p_spu )
161 {
162     decoder_sys_t *p_sys = p_dec->p_sys;
163
164     /* Our current index in the SPU packet */
165     unsigned int i_index = p_sys->i_rle_size + 4;
166
167     /* The next start-of-control-sequence index and the previous one */
168     unsigned int i_next_seq = 0, i_cur_seq = 0;
169
170     /* Command and date */
171     uint8_t i_command = SPU_CMD_END;
172     mtime_t date = 0;
173
174     unsigned int i, pi_alpha[4];
175
176     /* Initialize the structure */
177     p_spu->i_start = p_spu->i_stop = 0;
178     p_spu->b_ephemer = VLC_FALSE;
179
180     do
181     {
182         if( (int)i_index >= p_sys->i_spu_size + 1 )
183         {
184             /* sanity
185              * XXX only on test by loop as p_sys->buffer is bigger than needed
186              * to avoid checking at each access
187              */
188             break;
189         }
190
191         /* If we just read a command sequence, read the next one;
192          * otherwise, go on with the commands of the current sequence. */
193         if( i_command == SPU_CMD_END )
194         {
195             /* Get the control sequence date */
196             date = (mtime_t)GetWBE( &p_sys->buffer[i_index] ) * 11000;
197             /* FIXME How to access i_rate
198                     * p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
199             */
200
201             /* Next offset */
202             i_cur_seq = i_index;
203             i_next_seq = GetWBE( &p_sys->buffer[i_index+2] );
204
205             /* Skip what we just read */
206             i_index += 4;
207         }
208
209         i_command = p_sys->buffer[i_index++];
210
211         switch( i_command )
212         {
213         case SPU_CMD_FORCE_DISPLAY: /* 00 (force displaying) */
214             p_spu->i_start = p_spu->p_sys->i_pts + date;
215             p_spu->b_ephemer = VLC_TRUE;
216             break;
217
218         /* Convert the dates in seconds to PTS values */
219         case SPU_CMD_START_DISPLAY: /* 01 (start displaying) */
220             p_spu->i_start = p_spu->p_sys->i_pts + date;
221             break;
222
223         case SPU_CMD_STOP_DISPLAY: /* 02 (stop displaying) */
224             p_spu->i_stop = p_spu->p_sys->i_pts + date;
225             break;
226
227         case SPU_CMD_SET_PALETTE:
228
229             /* 03xxxx (palette) */
230             if( p_dec->fmt_in.subs.spu.palette[0] == 0xBeeF )
231             {
232                 unsigned int idx[4];
233
234                 p_spu->p_sys->b_palette = VLC_TRUE;
235
236                 idx[0] = (p_sys->buffer[i_index+0]>>4)&0x0f;
237                 idx[1] = (p_sys->buffer[i_index+0])&0x0f;
238                 idx[2] = (p_sys->buffer[i_index+1]>>4)&0x0f;
239                 idx[3] = (p_sys->buffer[i_index+1])&0x0f;
240
241                 for( i = 0; i < 4 ; i++ )
242                 {
243                     uint32_t i_color = p_dec->fmt_in.subs.spu.palette[1+idx[i]];
244
245                     /* FIXME: this job should be done sooner */
246                     p_spu->p_sys->pi_yuv[3-i][0] = (i_color>>16) & 0xff;
247                     p_spu->p_sys->pi_yuv[3-i][1] = (i_color>>0) & 0xff;
248                     p_spu->p_sys->pi_yuv[3-i][2] = (i_color>>8) & 0xff;
249                 }
250             }
251             i_index += 2;
252
253             break;
254
255         case SPU_CMD_SET_ALPHACHANNEL: /* 04xxxx (alpha channel) */
256             pi_alpha[3] = (p_sys->buffer[i_index+0]>>4)&0x0f;
257             pi_alpha[2] = (p_sys->buffer[i_index+0])&0x0f;
258             pi_alpha[1] = (p_sys->buffer[i_index+1]>>4)&0x0f;
259             pi_alpha[0] = (p_sys->buffer[i_index+1])&0x0f;
260
261             /* Ignore blank alpha palette. Sometimes spurious blank
262              * alpha palettes are present - dunno why. */
263             if( pi_alpha[0] | pi_alpha[1] | pi_alpha[2] | pi_alpha[3] )
264             {
265                 p_spu->p_sys->pi_alpha[0] = pi_alpha[0];
266                 p_spu->p_sys->pi_alpha[1] = pi_alpha[1];
267                 p_spu->p_sys->pi_alpha[2] = pi_alpha[2];
268                 p_spu->p_sys->pi_alpha[3] = pi_alpha[3];
269             }
270             else
271             {
272                 msg_Warn( p_dec, "ignoring blank alpha palette" );
273             }
274
275             i_index += 2;
276             break;
277
278         case SPU_CMD_SET_COORDINATES: /* 05xxxyyyxxxyyy (coordinates) */
279             p_spu->i_x = (p_sys->buffer[i_index+0]<<4)|
280                          ((p_sys->buffer[i_index+1]>>4)&0x0f);
281             p_spu->i_width = (((p_sys->buffer[i_index+1]&0x0f)<<8)|
282                               p_sys->buffer[i_index+2]) - p_spu->i_x + 1;
283
284             p_spu->i_y = (p_sys->buffer[i_index+3]<<4)|
285                          ((p_sys->buffer[i_index+4]>>4)&0x0f);
286             p_spu->i_height = (((p_sys->buffer[i_index+4]&0x0f)<<8)|
287                               p_sys->buffer[i_index+5]) - p_spu->i_y + 1;
288             
289             i_index += 6;
290             break;
291
292         case SPU_CMD_SET_OFFSETS: /* 06xxxxyyyy (byte offsets) */
293             p_spu->p_sys->pi_offset[0] = GetWBE(&p_sys->buffer[i_index+0]) - 4;
294             p_spu->p_sys->pi_offset[1] = GetWBE(&p_sys->buffer[i_index+2]) - 4;
295             i_index += 4;
296             break;
297
298         case SPU_CMD_END: /* ff (end) */
299             break;
300
301         default: /* xx (unknown command) */
302             msg_Warn( p_dec, "unknown command 0x%.2x", i_command );
303             return VLC_EGENERIC;
304         }
305
306         /* We need to check for quit commands here */
307         if( p_dec->b_die )
308         {
309             return VLC_EGENERIC;
310         }
311
312     } while( i_command != SPU_CMD_END || i_index == i_next_seq );
313
314     /* Check that the next sequence index matches the current one */
315     if( i_next_seq != i_cur_seq )
316     {
317         msg_Err( p_dec, "index mismatch (0x%.4x != 0x%.4x)",
318                  i_next_seq, i_cur_seq );
319         return VLC_EGENERIC;
320     }
321
322     if( (int)i_index > p_sys->i_spu_size )
323     {
324         msg_Err( p_dec, "uh-oh, we went too far (0x%.4x > 0x%.4x)",
325                  i_index, p_sys->i_spu_size );
326         return VLC_EGENERIC;
327     }
328
329     if( !p_spu->i_start )
330     {
331         msg_Err( p_dec, "no `start display' command" );
332     }
333
334     if( p_spu->i_stop <= p_spu->i_start && !p_spu->b_ephemer )
335     {
336         /* This subtitle will live for 5 seconds or until the next subtitle */
337         p_spu->i_stop = p_spu->i_start + (mtime_t)500 * 11000;
338         /* FIXME how to access i_rate ?
339                         * p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
340         */
341         p_spu->b_ephemer = VLC_TRUE;
342     }
343
344     /* Get rid of padding bytes */
345     if( p_sys->i_spu_size > (int)i_index + 1 )
346     {
347         /* Zero or one padding byte, are quite usual
348          * More than one padding byte - this is very strange, but
349          * we can deal with it */
350         msg_Warn( p_dec, "%i padding bytes, we usually get 0 or 1 of them",
351                   p_sys->i_spu_size - i_index );
352     }
353
354     /* Successfully parsed ! */
355     return VLC_SUCCESS;
356 }
357
358 /*****************************************************************************
359  * ParseRLE: parse the RLE part of the subtitle
360  *****************************************************************************
361  * This part parses the subtitle graphical data and stores it in a more
362  * convenient structure for later decoding. For more information on the
363  * subtitles format, see http://sam.zoy.org/doc/dvd/subtitles/index.html
364  *****************************************************************************/
365 static int ParseRLE( decoder_t *p_dec, subpicture_t * p_spu )
366 {
367     decoder_sys_t *p_sys = p_dec->p_sys;
368     uint8_t       *p_src = &p_sys->buffer[4];
369
370     unsigned int i_code;
371
372     unsigned int i_width = p_spu->i_width;
373     unsigned int i_height = p_spu->i_height;
374     unsigned int i_x, i_y;
375
376     uint16_t *p_dest = (uint16_t *)p_spu->p_sys->p_data;
377
378     /* The subtitles are interlaced, we need two offsets */
379     unsigned int  i_id = 0;                   /* Start on the even SPU layer */
380     unsigned int  pi_table[ 2 ];
381     unsigned int *pi_offset;
382
383 #if 0 /* cropping */
384     vlc_bool_t b_empty_top = VLC_TRUE,
385                b_empty_bottom = VLC_FALSE;
386     unsigned int i_skipped_top = 0,
387                  i_skipped_bottom = 0;
388 #endif
389
390     /* Colormap statistics */
391     int i_border = -1;
392     int stats[4]; stats[0] = stats[1] = stats[2] = stats[3] = 0;
393
394     pi_table[ 0 ] = p_spu->p_sys->pi_offset[ 0 ] << 1;
395     pi_table[ 1 ] = p_spu->p_sys->pi_offset[ 1 ] << 1;
396
397     for( i_y = 0 ; i_y < i_height ; i_y++ )
398     {
399         pi_offset = pi_table + i_id;
400
401         for( i_x = 0 ; i_x < i_width ; i_x += i_code >> 2 )
402         {
403             i_code = AddNibble( 0, p_src, pi_offset );
404
405             if( i_code < 0x04 )
406             {
407                 i_code = AddNibble( i_code, p_src, pi_offset );
408
409                 if( i_code < 0x10 )
410                 {
411                     i_code = AddNibble( i_code, p_src, pi_offset );
412
413                     if( i_code < 0x040 )
414                     {
415                         i_code = AddNibble( i_code, p_src, pi_offset );
416
417                         if( i_code < 0x0100 )
418                         {
419                             /* If the 14 first bits are set to 0, then it's a
420                              * new line. We emulate it. */
421                             if( i_code < 0x0004 )
422                             {
423                                 i_code |= ( i_width - i_x ) << 2;
424                             }
425                             else
426                             {
427                                 /* We have a boo boo ! */
428                                 msg_Err( p_dec, "unknown RLE code "
429                                          "0x%.4x", i_code );
430                                 return VLC_EGENERIC;
431                             }
432                         }
433                     }
434                 }
435             }
436
437             if( ( (i_code >> 2) + i_x + i_y * i_width ) > i_height * i_width )
438             {
439                 msg_Err( p_dec,
440                          "out of bounds, %i at (%i,%i) is out of %ix%i",
441                          i_code >> 2, i_x, i_y, i_width, i_height );
442                 return VLC_EGENERIC;
443             }
444
445             /* Try to find the border color */
446             if( p_spu->p_sys->pi_alpha[ i_code & 0x3 ] != 0x00 )
447             {
448                 i_border = i_code & 0x3;
449                 stats[i_border] += i_code >> 2;
450             }
451
452 #if 0 /* cropping */
453             if( (i_code >> 2) == i_width
454                  && p_spu->p_sys->pi_alpha[ i_code & 0x3 ] == 0x00 )
455             {
456                 if( b_empty_top )
457                 {
458                     /* This is a blank top line, we skip it */
459                     i_skipped_top++;
460                 }
461                 else
462                 {
463                     /* We can't be sure the current lines will be skipped,
464                      * so we store the code just in case. */
465                     *p_dest++ = i_code;
466
467                     b_empty_bottom = VLC_TRUE;
468                     i_skipped_bottom++;
469                 }
470             }
471             else
472             {
473                 /* We got a valid code, store it */
474                 *p_dest++ = i_code;
475
476                 /* Valid code means no blank line */
477                 b_empty_top = VLC_FALSE;
478                 b_empty_bottom = VLC_FALSE;
479                 i_skipped_bottom = 0;
480             }
481 #else
482             *p_dest++ = i_code;
483 #endif
484         }
485
486         /* Check that we didn't go too far */
487         if( i_x > i_width )
488         {
489             msg_Err( p_dec, "i_x overflowed, %i > %i",
490                      i_x, i_width );
491             return VLC_EGENERIC;
492         }
493
494         /* Byte-align the stream */
495         if( *pi_offset & 0x1 )
496         {
497             (*pi_offset)++;
498         }
499
500         /* Swap fields */
501         i_id = ~i_id & 0x1;
502     }
503
504     /* We shouldn't get any padding bytes */
505     if( i_y < i_height )
506     {
507         msg_Err( p_dec, "padding bytes found in RLE sequence" );
508         msg_Err( p_dec, "send mail to <sam@zoy.org> if you "
509                         "want to help debugging this" );
510
511         /* Skip them just in case */
512         while( i_y < i_height )
513         {
514             *p_dest++ = i_width << 2;
515             i_y++;
516         }
517
518         return VLC_EGENERIC;
519     }
520
521     msg_Dbg( p_dec, "valid subtitle, size: %ix%i, position: %i,%i",
522              p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
523
524 #if 0 /* cropping */
525     /* Crop if necessary */
526     if( i_skipped_top || i_skipped_bottom )
527     {
528         p_spu->i_y += i_skipped_top;
529         p_spu->i_height -= i_skipped_top + i_skipped_bottom;
530
531         msg_Dbg( p_spudec->p_fifo, "cropped to: %ix%i, position: %i,%i",
532                  p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
533     }
534 #endif
535
536     /* Handle color if no palette was found */
537     if( !p_spu->p_sys->b_palette )
538     {
539         int i, i_inner = -1, i_shade = -1;
540
541         /* Set the border color */
542         p_spu->p_sys->pi_yuv[i_border][0] = 0x00;
543         p_spu->p_sys->pi_yuv[i_border][1] = 0x80;
544         p_spu->p_sys->pi_yuv[i_border][2] = 0x80;
545         stats[i_border] = 0;
546
547         /* Find the inner colors */
548         for( i = 0 ; i < 4 && i_inner == -1 ; i++ )
549         {
550             if( stats[i] )
551             {
552                 i_inner = i;
553             }
554         }
555
556         for(       ; i < 4 && i_shade == -1 ; i++ )
557         {
558             if( stats[i] )
559             {
560                 if( stats[i] > stats[i_inner] )
561                 {
562                     i_shade = i_inner;
563                     i_inner = i;
564                 }
565                 else
566                 {
567                     i_shade = i;
568                 }
569             }
570         }
571
572         /* Set the inner color */
573         if( i_inner != -1 )
574         {
575             p_spu->p_sys->pi_yuv[i_inner][0] = 0xff;
576             p_spu->p_sys->pi_yuv[i_inner][1] = 0x80;
577             p_spu->p_sys->pi_yuv[i_inner][2] = 0x80;
578         }
579
580         /* Set the anti-aliasing color */
581         if( i_shade != -1 )
582         {
583             p_spu->p_sys->pi_yuv[i_shade][0] = 0x80;
584             p_spu->p_sys->pi_yuv[i_shade][1] = 0x80;
585             p_spu->p_sys->pi_yuv[i_shade][2] = 0x80;
586         }
587
588         msg_Dbg( p_dec,
589                  "using custom palette (border %i, inner %i, shade %i)",
590                  i_border, i_inner, i_shade );
591     }
592
593     return VLC_SUCCESS;
594 }
595
596 /*****************************************************************************
597  * DestroySPU: subpicture destructor
598  *****************************************************************************/
599 static void DestroySPU( subpicture_t *p_spu )
600 {
601     if( p_spu->p_sys->p_input )
602     {
603         /* Detach from our input thread */
604         var_DelCallback( p_spu->p_sys->p_input, "highlight",
605                          CropCallback, p_spu );
606         vlc_object_release( p_spu->p_sys->p_input );
607     }
608
609     vlc_mutex_destroy( &p_spu->p_sys->lock );
610     free( p_spu->p_sys );
611 }
612
613 /*****************************************************************************
614  * UpdateSPU: update subpicture settings
615  *****************************************************************************
616  * This function is called from CropCallback and at initialization time, to
617  * retrieve crop information from the input.
618  *****************************************************************************/
619 static void UpdateSPU( subpicture_t *p_spu, vlc_object_t *p_object )
620 {
621     vlc_value_t val;
622
623     if( var_Get( p_object, "highlight", &val ) )
624     {
625         return;
626     }
627
628     p_spu->p_sys->b_crop = val.b_bool;
629     if( !p_spu->p_sys->b_crop )
630     {
631         return;
632     }
633
634     var_Get( p_object, "x-start", &val );
635     p_spu->p_sys->i_x_start = val.i_int;
636     var_Get( p_object, "y-start", &val );
637     p_spu->p_sys->i_y_start = val.i_int;
638     var_Get( p_object, "x-end", &val );
639     p_spu->p_sys->i_x_end = val.i_int;
640     var_Get( p_object, "y-end", &val );
641     p_spu->p_sys->i_y_end = val.i_int;
642
643 #if 0
644     if( var_Get( p_object, "color", &val ) == VLC_SUCCESS )
645     {
646         p_spu->p_sys->pi_color[0] = ((uint8_t *)val.p_address)[0];
647         p_spu->p_sys->pi_color[1] = ((uint8_t *)val.p_address)[1];
648         p_spu->p_sys->pi_color[2] = ((uint8_t *)val.p_address)[2];
649         p_spu->p_sys->pi_color[3] = ((uint8_t *)val.p_address)[3];
650     }
651 #endif
652
653     if( var_Get( p_object, "contrast", &val ) == VLC_SUCCESS )
654     {
655         p_spu->p_sys->pi_alpha[0] = ((uint8_t *)val.p_address)[0];
656         p_spu->p_sys->pi_alpha[1] = ((uint8_t *)val.p_address)[1];
657         p_spu->p_sys->pi_alpha[2] = ((uint8_t *)val.p_address)[2];
658         p_spu->p_sys->pi_alpha[3] = ((uint8_t *)val.p_address)[3];
659     }
660 }
661
662 /*****************************************************************************
663  * CropCallback: called when the highlight properties are changed
664  *****************************************************************************
665  * This callback is called from the input thread when we need cropping
666  *****************************************************************************/
667 static int CropCallback( vlc_object_t *p_object, char const *psz_var,
668                          vlc_value_t oldval, vlc_value_t newval, void *p_data )
669 {
670     UpdateSPU( (subpicture_t *)p_data, p_object );
671
672     return VLC_SUCCESS;
673 }
674