/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <vlc/vlc.h>
-#include <vlc/vout.h>
-#include <vlc/decoder.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_vout.h>
+#include <vlc_codec.h>
+#include <vlc_input.h>
#include "spudec.h"
* This function parses the SPU packet and, if valid, sends it to the
* video output.
*****************************************************************************/
-subpicture_t * E_(ParsePacket)( decoder_t *p_dec )
+subpicture_t * ParsePacket( decoder_t *p_dec )
{
decoder_sys_t *p_sys = p_dec->p_sys;
subpicture_data_t *p_spu_data;
* this stupid interlacing stuff once. */
p_spu_data = malloc( sizeof(subpicture_data_t) + 4 * p_sys->i_rle_size );
p_spu_data->p_data = (uint8_t *)p_spu_data + sizeof(subpicture_data_t);
- p_spu_data->b_palette = VLC_FALSE;
- p_spu_data->b_auto_crop = VLC_FALSE;
+ p_spu_data->b_palette = false;
+ p_spu_data->b_auto_crop = false;
p_spu_data->i_y_top_offset = 0;
p_spu_data->i_y_bottom_offset = 0;
return NULL;
}
+#ifdef DEBUG_SPUDEC
msg_Dbg( p_dec, "total size: 0x%x, RLE offsets: 0x%x 0x%x",
p_sys->i_spu_size,
p_spu_data->pi_offset[0], p_spu_data->pi_offset[1] );
+#endif
Render( p_dec, p_spu, p_spu_data );
free( p_spu_data );
uint8_t i_command = SPU_CMD_END;
mtime_t date = 0;
- unsigned int i, pi_alpha[4];
+ if( !p_spu || !p_spu_data )
+ return VLC_EGENERIC;
/* Initialize the structure */
p_spu->i_start = p_spu->i_stop = 0;
- p_spu->b_ephemer = VLC_FALSE;
+ p_spu->b_ephemer = false;
for( i_index = 4 + p_sys->i_rle_size; i_index < p_sys->i_spu_size ; )
{
/* Get the control sequence date */
date = (mtime_t)GetWBE( &p_sys->buffer[i_index] ) * 11000;
- /* FIXME How to access i_rate
- * p_spudec->bit_stream.p_pes->i_rate / DEFAULT_RATE;
- */
+ if( p_sys->i_rate )
+ date = date * p_sys->i_rate / INPUT_RATE_DEFAULT;
/* Next offset */
i_cur_seq = i_index;
{
case SPU_CMD_FORCE_DISPLAY: /* 00 (force displaying) */
p_spu->i_start = p_spu_data->i_pts + date;
- p_spu->b_ephemer = VLC_TRUE;
+ p_spu->b_ephemer = true;
i_index += 1;
break;
break;
case SPU_CMD_SET_PALETTE:
-
/* 03xxxx (palette) */
if( i_index + 3 > p_sys->i_spu_size )
{
if( p_dec->fmt_in.subs.spu.palette[0] == 0xBeeF )
{
unsigned int idx[4];
+ int i;
- p_spu_data->b_palette = VLC_TRUE;
+ p_spu_data->b_palette = true;
idx[0] = (p_sys->buffer[i_index+1]>>4)&0x0f;
idx[1] = (p_sys->buffer[i_index+1])&0x0f;
return VLC_EGENERIC;
}
- pi_alpha[3] = (p_sys->buffer[i_index+1]>>4)&0x0f;
- pi_alpha[2] = (p_sys->buffer[i_index+1])&0x0f;
- pi_alpha[1] = (p_sys->buffer[i_index+2]>>4)&0x0f;
- pi_alpha[0] = (p_sys->buffer[i_index+2])&0x0f;
-
- /* Ignore blank alpha palette. Sometimes spurious blank
- * alpha palettes are present - dunno why. */
- if( pi_alpha[0] | pi_alpha[1] | pi_alpha[2] | pi_alpha[3] )
- {
- p_spu_data->pi_alpha[0] = pi_alpha[0];
- p_spu_data->pi_alpha[1] = pi_alpha[1];
- p_spu_data->pi_alpha[2] = pi_alpha[2];
- p_spu_data->pi_alpha[3] = pi_alpha[3];
- }
- else
- {
- msg_Warn( p_dec, "ignoring blank alpha palette" );
- }
+ p_spu_data->pi_alpha[3] = (p_sys->buffer[i_index+1]>>4)&0x0f;
+ p_spu_data->pi_alpha[2] = (p_sys->buffer[i_index+1])&0x0f;
+ p_spu_data->pi_alpha[1] = (p_sys->buffer[i_index+2]>>4)&0x0f;
+ p_spu_data->pi_alpha[0] = (p_sys->buffer[i_index+2])&0x0f;
i_index += 3;
break;
/* Auto crop fullscreen subtitles */
if( p_spu->i_height > 250 )
- p_spu_data->b_auto_crop = VLC_TRUE;
+ p_spu_data->b_auto_crop = true;
i_index += 7;
break;
}
/* We need to check for quit commands here */
- if( p_dec->b_die )
+ if( !vlc_object_alive (p_dec) )
{
return VLC_EGENERIC;
}
if( !p_spu->i_start )
{
msg_Err( p_dec, "no `start display' command" );
+ return VLC_EGENERIC;
}
if( p_spu->i_stop <= p_spu->i_start && !p_spu->b_ephemer )
{
/* This subtitle will live for 5 seconds or until the next subtitle */
p_spu->i_stop = p_spu->i_start + (mtime_t)500 * 11000;
- p_spu->b_ephemer = VLC_TRUE;
+ p_spu->b_ephemer = true;
}
/* Get rid of padding bytes */
unsigned int *pi_offset;
/* Cropping */
- vlc_bool_t b_empty_top = VLC_TRUE;
+ bool b_empty_top = true;
unsigned int i_skipped_top = 0, i_skipped_bottom = 0;
unsigned int i_transparent_code = 0;
}
else
{
- p_spu_data->b_auto_crop = VLC_FALSE;
+ p_spu_data->b_auto_crop = false;
}
}
*p_dest++ = i_code;
/* Valid code means no blank line */
- b_empty_top = VLC_FALSE;
+ b_empty_top = false;
i_skipped_bottom = 0;
}
}
return VLC_EGENERIC;
}
+#ifdef DEBUG_SPUDEC
msg_Dbg( p_dec, "valid subtitle, size: %ix%i, position: %i,%i",
p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
+#endif
/* Crop if necessary */
if( i_skipped_top || i_skipped_bottom )
{
+#ifdef DEBUG_SPUDEC
int i_y = p_spu->i_y + i_skipped_top;
int i_height = p_spu->i_height - (i_skipped_top + i_skipped_bottom);
-
+#endif
p_spu_data->i_y_top_offset = i_skipped_top;
p_spu_data->i_y_bottom_offset = i_skipped_bottom;
+#ifdef DEBUG_SPUDEC
msg_Dbg( p_dec, "cropped to: %ix%i, position: %i,%i",
p_spu->i_width, i_height, p_spu->i_x, i_y );
+#endif
}
/* Handle color if no palette was found */
p_spu_data->pi_yuv[i_shade][2] = 0x80;
}
+#ifdef DEBUG_SPUDEC
msg_Dbg( p_dec, "using custom palette (border %i, inner %i, shade %i)",
i_border, i_inner, i_shade );
+#endif
}
return VLC_SUCCESS;