- fix a bug in UnalignedShowBits that makes some _heavy_ unaligned streams
authorArnaud de Bossoreille de Ribou <bozo@videolan.org>
Mon, 7 May 2001 13:52:39 +0000 (13:52 +0000)
committerArnaud de Bossoreille de Ribou <bozo@videolan.org>
Mon, 7 May 2001 13:52:39 +0000 (13:52 +0000)
    not wotk correctly (for instance VLS' generated TS streams)

src/input/input_ext-dec.c

index 7be8abb..fad6f21 100644 (file)
@@ -2,7 +2,7 @@
  * input_ext-dec.c: services to the decoders
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ext-dec.c,v 1.14 2001/04/28 03:36:25 sam Exp $
+ * $Id: input_ext-dec.c,v 1.15 2001/05/07 13:52:39 bozo Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -181,13 +181,20 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
                      * of the packet in a temporary buffer, and we'll see
                      * later. */
                     int     i;
+                    /* number of bytes to trash from the last payload */
+                    int     j;
+
                     p_bit_stream->i_showbits_buffer = 0;
 
+                    /* is this initialization really usefull ? -- bozo */
+                    j = sizeof(WORD_TYPE);
+
                     for( i = 0; i < sizeof(WORD_TYPE) ; i++ )
                     {
                         if( p_bit_stream->p_byte >= p_bit_stream->p_end )
                         {
                             p_bit_stream->pf_next_data_packet( p_bit_stream );
+                            j = sizeof(WORD_TYPE) - i;
                         }
                         ((byte_t *)&p_bit_stream->i_showbits_buffer)[i] =
                             * p_bit_stream->p_byte;
@@ -195,7 +202,7 @@ u32 UnalignedShowBits( bit_stream_t * p_bit_stream, unsigned int i_bits )
                     }
 
                     /* This is kind of kludgy. */
-                    p_bit_stream->p_data->p_payload_start += sizeof(WORD_TYPE);
+                    p_bit_stream->p_data->p_payload_start += j;
                     p_bit_stream->p_byte =
                         (byte_t *)&p_bit_stream->i_showbits_buffer;
                     p_bit_stream->p_end =