]> git.sesse.net Git - vlc/commitdiff
. suppression d'une variable inutile que j'avais laiss�e trainer
authorSam Hocevar <sam@videolan.org>
Mon, 20 Mar 2000 07:50:55 +0000 (07:50 +0000)
committerSam Hocevar <sam@videolan.org>
Mon, 20 Mar 2000 07:50:55 +0000 (07:50 +0000)
  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.

include/input.h
include/spu_decoder.h
include/video.h
src/input/input.c
src/spu_decoder/spu_decoder.c
src/video_output/video_output.c

index 970eae75c978a4791d98f7dbb29894e3cf2cf42a..07c231ad2df67db2d9bd5d7f42b3cb7b9665d97c 100644 (file)
@@ -76,7 +76,6 @@ typedef struct pes_packet_s
 
     /* Demultiplexer environment */
     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_save;           /* temporary buffer */
 
index dfc7309e017c762a6f188bbe06b7d5e47dc0b4f7..ea007ac38e7456484e09aca74f29657373dd114b 100644 (file)
@@ -47,6 +47,7 @@ typedef struct spudec_thread_s
      */
     unsigned int        total_bits_read;
     /* ... */
+    vout_thread_t *     p_vout;          /* needed to create the spu objects */
 
 } spudec_thread_t;
 
index da9ef0e26fba50a039585f7c9b4d70c77c750cb4..f2355e2da8639fbb4208c8c95cf788a8209e26ab 100644 (file)
@@ -156,7 +156,7 @@ typedef struct subpicture_s
 
 /* Subpicture type */
 #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 */
 
 /* Subpicture status */
index 7d6ccf487d5af6475bf1c934dcf295c2d8cb1631..191a83d19c1da505beaf56a33574f8ed69e59565 100644 (file)
@@ -1000,9 +1000,6 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
             if( !p_last_pes )
                 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 */
             p_pes->b_random_access = p_es_descriptor->b_random;
             p_es_descriptor->b_random = 0;
index 19e8fdfc8849e0268cb7760ee9b09ab9d9357fa4..64cb436b5c34ad0bfe9367483d61d6145d574f1a 100644 (file)
@@ -38,6 +38,7 @@
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
+#include "plugins.h"
 
 #include "intf_msg.h"
 #include "debug.h"                                                 /* ASSERT */
@@ -46,6 +47,9 @@
 #include "input_netlist.h"
 #include "decoder_fifo.h"
 
+#include "video.h"
+#include "video_output.h"
+
 #include "spu_decoder.h"
 
 /*
@@ -56,6 +60,11 @@ static void     RunThread           ( spudec_thread_t *p_spudec );
 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
  *****************************************************************************/
@@ -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.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) )
@@ -188,19 +200,144 @@ static void RunThread( spudec_thread_t *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
index dc27549ca21bedadd89273ad51bea4a4cfb82fe7..3e520ec8d6ea6dba1809a526bc076e6fe2b2bfcc 100644 (file)
@@ -406,6 +406,9 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
         case TEXT_SUBPICTURE:                             /* text subpicture */
             p_free_subpic->p_data = malloc( i_size + 1 );
             break;
+        case DVD_SUBPICTURE:                          /* DVD subpicture unit */
+            p_free_subpic->p_data = malloc( i_size );
+            break;
 #ifdef DEBUG
         default:
             intf_DbgMsg("error: unknown subpicture type %d\n", i_type );
@@ -415,7 +418,7 @@ subpicture_t *vout_CreateSubPicture( vout_thread_t *p_vout, int i_type,
         }
 
         if( p_free_subpic->p_data != NULL )
-        {                    /* Copy subpicture informations, set some default values */
+        {           /* Copy subpicture informations, set some default values */
             p_free_subpic->i_type                      = i_type;
             p_free_subpic->i_status                    = RESERVED_SUBPICTURE;
             p_free_subpic->i_size                      = i_size;