Commit 3b8adcbd authored by Sam Hocevar's avatar Sam Hocevar

. suppression d'une variable inutile que j'avais laiss�e trainer

  au pr�c�dent commit.
 . d�but du d�codeur de sous-titres. Pour le moment il ne fait que
  parser le flux comme un cochon, c'est tout.
parent b17f6aad
...@@ -76,7 +76,6 @@ typedef struct pes_packet_s ...@@ -76,7 +76,6 @@ typedef struct pes_packet_s
/* Demultiplexer environment */ /* Demultiplexer environment */
boolean_t b_discard_payload; /* is the packet messed up ? */ boolean_t b_discard_payload; /* is the packet messed up ? */
boolean_t b_already_parsed; /* was it already parsed ? */
byte_t * p_pes_header; /* pointer to the PES header */ byte_t * p_pes_header; /* pointer to the PES header */
byte_t * p_pes_header_save; /* temporary buffer */ byte_t * p_pes_header_save; /* temporary buffer */
......
...@@ -47,6 +47,7 @@ typedef struct spudec_thread_s ...@@ -47,6 +47,7 @@ typedef struct spudec_thread_s
*/ */
unsigned int total_bits_read; unsigned int total_bits_read;
/* ... */ /* ... */
vout_thread_t * p_vout; /* needed to create the spu objects */
} spudec_thread_t; } spudec_thread_t;
......
...@@ -156,7 +156,7 @@ typedef struct subpicture_s ...@@ -156,7 +156,7 @@ typedef struct subpicture_s
/* Subpicture type */ /* Subpicture type */
#define EMPTY_SUBPICTURE 0 /* subtitle slot is empty and available */ #define EMPTY_SUBPICTURE 0 /* subtitle slot is empty and available */
#define RLE_SUBPICTURE 100 /* RLE encoded subtitle */ #define DVD_SUBPICTURE 100 /* DVD subpicture unit */
#define TEXT_SUBPICTURE 200 /* single line text */ #define TEXT_SUBPICTURE 200 /* single line text */
/* Subpicture status */ /* Subpicture status */
......
...@@ -1000,9 +1000,6 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input, ...@@ -1000,9 +1000,6 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
if( !p_last_pes ) if( !p_last_pes )
p_pes->b_data_loss = 1; p_pes->b_data_loss = 1;
/* Tell the Demux we haven't yet parsed this PES */
p_pes->b_already_parsed = 0;
/* Read the b_random_access flag status and then reinit it */ /* Read the b_random_access flag status and then reinit it */
p_pes->b_random_access = p_es_descriptor->b_random; p_pes->b_random_access = p_es_descriptor->b_random;
p_es_descriptor->b_random = 0; p_es_descriptor->b_random = 0;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "common.h" #include "common.h"
#include "threads.h" #include "threads.h"
#include "mtime.h" #include "mtime.h"
#include "plugins.h"
#include "intf_msg.h" #include "intf_msg.h"
#include "debug.h" /* ASSERT */ #include "debug.h" /* ASSERT */
...@@ -46,6 +47,9 @@ ...@@ -46,6 +47,9 @@
#include "input_netlist.h" #include "input_netlist.h"
#include "decoder_fifo.h" #include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "spu_decoder.h" #include "spu_decoder.h"
/* /*
...@@ -56,6 +60,11 @@ static void RunThread ( spudec_thread_t *p_spudec ); ...@@ -56,6 +60,11 @@ static void RunThread ( spudec_thread_t *p_spudec );
static void ErrorThread ( spudec_thread_t *p_spudec ); static void ErrorThread ( spudec_thread_t *p_spudec );
static void EndThread ( 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 * spudec_CreateThread: create a spu decoder thread
*****************************************************************************/ *****************************************************************************/
...@@ -93,6 +102,9 @@ spudec_thread_t * spudec_CreateThread( input_thread_t * p_input ) ...@@ -93,6 +102,9 @@ spudec_thread_t * spudec_CreateThread( input_thread_t * p_input )
p_spudec->bit_stream.fifo.buffer = 0; p_spudec->bit_stream.fifo.buffer = 0;
p_spudec->bit_stream.fifo.i_available = 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 */ /* Spawn the spu decoder thread */
if ( vlc_thread_create(&p_spudec->thread_id, "spu decoder", if ( vlc_thread_create(&p_spudec->thread_id, "spu decoder",
(vlc_thread_func_t)RunThread, (void *)p_spudec) ) (vlc_thread_func_t)RunThread, (void *)p_spudec) )
...@@ -188,19 +200,144 @@ static void RunThread( spudec_thread_t *p_spudec ) ...@@ -188,19 +200,144 @@ static void RunThread( spudec_thread_t *p_spudec )
* Main loop - it is not executed if an error occured during * Main loop - it is not executed if an error occured during
* initialization * initialization
*/ */
vlc_mutex_lock( &p_spudec->fifo.data_lock );
while( (!p_spudec->b_die) && (!p_spudec->b_error) ) 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) ) while( !DECODER_FIFO_ISEMPTY(p_spudec->fifo) )
{ {
input_NetlistFreePES( p_spudec->bit_stream.p_input, DECODER_FIFO_START(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 ); 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 */ /* 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_cond_wait( &p_spudec->fifo.data_wait, &p_spudec->fifo.data_lock );
} }
vlc_mutex_unlock( &p_spudec->fifo.data_lock );
/* /*
* Error loop * Error loop
......
...@@ -406,6 +406,9 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type, ...@@ -406,6 +406,9 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
case TEXT_SUBPICTURE: /* text subpicture */ case TEXT_SUBPICTURE: /* text subpicture */
p_free_subpic->p_data = malloc( i_size + 1 ); p_free_subpic->p_data = malloc( i_size + 1 );
break; break;
case DVD_SUBPICTURE: /* DVD subpicture unit */
p_free_subpic->p_data = malloc( i_size );
break;
#ifdef DEBUG #ifdef DEBUG
default: default:
intf_DbgMsg("error: unknown subpicture type %d\n", i_type ); intf_DbgMsg("error: unknown subpicture type %d\n", i_type );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment