#include "common.h"
#include "threads.h"
#include "mtime.h"
+#include "plugins.h"
#include "intf_msg.h"
#include "debug.h" /* ASSERT */
#include "input_netlist.h"
#include "decoder_fifo.h"
+#include "video.h"
+#include "video_output.h"
+
#include "spu_decoder.h"
/*
static void ErrorThread ( spudec_thread_t *p_spudec );
static void EndThread ( spudec_thread_t *p_spudec );
+#define GetWord( i ) \
+ i = GetByte( &p_spudec->bit_stream ) << 8; \
+ i += GetByte( &p_spudec->bit_stream ); \
+ i_index += 2;
+
/*****************************************************************************
* spudec_CreateThread: create a spu decoder thread
*****************************************************************************/
p_spudec->bit_stream.fifo.buffer = 0;
p_spudec->bit_stream.fifo.i_available = 0;
+ /* Get the video output informations */
+ p_spudec->p_vout = p_input->p_vout;
+
/* Spawn the spu decoder thread */
if ( vlc_thread_create(&p_spudec->thread_id, "spu decoder",
(vlc_thread_func_t)RunThread, (void *)p_spudec) )
* Main loop - it is not executed if an error occured during
* initialization
*/
- vlc_mutex_lock( &p_spudec->fifo.data_lock );
while( (!p_spudec->b_die) && (!p_spudec->b_error) )
{
- /* Trash all received PES packets */
+ int i_spu_id;
+ int i_packet_size;
+ int i_rle_size;
+ int i_index;
+ int i_pes_size;
+ boolean_t b_finished;
+ unsigned char * p_spu_data;
+ subpicture_t * p_spu;
+
while( !DECODER_FIFO_ISEMPTY(p_spudec->fifo) )
{
- input_NetlistFreePES( p_spudec->bit_stream.p_input, DECODER_FIFO_START(p_spudec->fifo) );
- DECODER_FIFO_INCSTART( p_spudec->fifo );
+ printf( "*** tracking next SPU PES\n" );
+ do
+ {
+ i_spu_id = GetByte( &p_spudec->bit_stream );
+ }
+ while( (i_spu_id & 0xe0) != 0x20 );
+ i_pes_size = DECODER_FIFO_START(p_spudec->fifo)->i_pes_size;
+ printf( "got it. size = 0x%.4x\n", i_pes_size );
+
+ printf( "SPU id: 0x%.2x\n", i_spu_id );
+
+ i_index = 0;
+
+ GetWord( i_packet_size );
+ printf( "total size: 0x%.4x\n", i_packet_size );
+
+ GetWord( i_rle_size );
+ printf( "RLE size: 0x%.4x\n", i_rle_size );
+
+ /* we already read 4 bytes for the total size and the RLE size */
+
+ p_spu = vout_CreateSubPicture( p_spudec->p_vout,
+ DVD_SUBPICTURE, i_rle_size );
+ p_spu_data = p_spu->p_data;
+
+ if( (i_rle_size < i_packet_size)
+ && ((i_spu_id & 0xe0) == 0x20) )
+ {
+ printf( "doing RLE stuff (%i bytes)\n", i_rle_size );
+ printf( "index/size %i/%i\n", i_index, i_pes_size );
+ while( i_index++ <i_rle_size )
+ {
+ //*p_spu_data++ = GetByte( &p_spudec->bit_stream );
+ if (i_index == i_pes_size) printf ("\n **** \n");
+ /* kludge ??? */
+ if (i_index == i_pes_size) printf( "%.2x", *p_spu_data++ = GetByte( &p_spudec->bit_stream ) );
+ printf( "%.2x", *p_spu_data++ = GetByte( &p_spudec->bit_stream ) );
+ }
+ printf( "\nindex/size %i/%i\n", i_index, i_pes_size );
+ //printf( "\n" );
+
+ b_finished = 0;
+ printf( "control stuff\n" );
+ do
+ {
+ unsigned char i_cmd;
+ unsigned int i_word;
+
+ GetWord( i_word );
+ printf( "date: 0x%.4x\n", i_word );
+
+ GetWord( i_word );
+ printf( " next: 0x%.4x (i-5: %.4x)\n", i_word, i_index-5 );
+ b_finished = (i_index - 5 >= i_word );
+
+ do
+ {
+ i_cmd = GetByte( &p_spudec->bit_stream );
+ i_index++;
+
+ switch(i_cmd)
+ {
+ case 0x00:
+ printf( " 00 (display now)\n" );
+ break;
+ case 0x01:
+ printf( " 01 (start displaying)\n" );
+ break;
+ case 0x02:
+ printf( " 02 (stop displaying)\n" );
+ break;
+ case 0x03:
+ GetWord( i_word );
+ printf( " 03 (palette) - %.4x\n", i_word );
+ break;
+ case 0x04:
+ GetWord( i_word );
+ printf( " 04 (alpha channel) - %.4x\n", i_word );
+ break;
+ case 0x05:
+ GetWord( i_word );
+ printf( " 05 (coordinates) - %.4x", i_word );
+ GetWord( i_word );
+ printf( "%.4x", i_word );
+ GetWord( i_word );
+ printf( "%.4x\n", i_word );
+ break;
+ case 0x06:
+ GetWord( i_word );
+ printf( " 06 (byte offsets) - %.4x", i_word );
+ GetWord( i_word );
+ printf( "%.4x\n", i_word );
+ break;
+ case 0xff:
+ printf( " ff (end)\n" );
+ break;
+ default:
+ printf( " %.2x (unknown command)\n", i_cmd );
+ break;
+ }
+
+ }
+ while( i_cmd != 0xff );
+
+ }
+ while( !b_finished );
+ printf( "control stuff finished\n" );
+ printf( "*** end of PES !\n\n" );
+ }
+ else
+ {
+ printf( "*** invalid PES !\n\n" );
+ /* trash the PES packet */
+ /*vlc_mutex_lock( &p_spudec->fifo.data_lock );
+ input_NetlistFreePES( p_spudec->bit_stream.p_input,
+ DECODER_FIFO_START(p_spudec->fifo) );
+ DECODER_FIFO_INCSTART( p_spudec->fifo );
+ vlc_mutex_unlock( &p_spudec->fifo.data_lock );*/
+ }
+
}
/* Waiting for the input thread to put new PES packets in the fifo */
+ printf( "decoder fifo is empty\n" );
vlc_cond_wait( &p_spudec->fifo.data_wait, &p_spudec->fifo.data_lock );
}
- vlc_mutex_unlock( &p_spudec->fifo.data_lock );
/*
* Error loop