]> git.sesse.net Git - vlc/blobdiff - modules/demux/ogg.c
macosx: retain window level across a fullscreen session
[vlc] / modules / demux / ogg.c
index 098ba7fc2e57e23ec5860468a106d0d1918fc455..e659b9cb00841d35a42f10dadc910fc9ad626273 100644 (file)
@@ -105,7 +105,6 @@ typedef struct
     } sh;
 } stream_header_t;
 
-#define OGG_BLOCK_SIZE 4096
 
 /* Some defines from OggDS */
 #define PACKET_TYPE_HEADER   0x01
@@ -470,9 +469,9 @@ static int Ogg_ReadPage( demux_t *p_demux, ogg_page *p_oggpage )
 
     while( ogg_sync_pageout( &p_ogg->oy, p_oggpage ) != 1 )
     {
-        p_buffer = ogg_sync_buffer( &p_ogg->oy, OGG_BLOCK_SIZE );
+        p_buffer = ogg_sync_buffer( &p_ogg->oy, OGGSEEK_BYTES_TO_READ );
 
-        i_read = stream_Read( p_demux->s, p_buffer, OGG_BLOCK_SIZE );
+        i_read = stream_Read( p_demux->s, p_buffer, OGGSEEK_BYTES_TO_READ );
         if( i_read <= 0 )
             return VLC_EGENERIC;
 
@@ -501,7 +500,7 @@ static void Ogg_UpdatePCR( logical_stream_t *p_stream,
               ( iframe << p_stream->i_granule_shift );
 
             p_stream->i_pcr = ( iframe + pframe - p_stream->i_keyframe_offset )
-             * INT64_C(1000000) / p_stream->f_rate;
+              * INT64_C(1000000) / p_stream->f_rate;
         }
         else if( p_stream->fmt.i_codec == VLC_CODEC_DIRAC )
         {
@@ -629,6 +628,7 @@ static void Ogg_DecodePacket( demux_t *p_demux,
             }
             else
             {
+#warning Memory leak
                 p_stream->i_headers = 0;
                 p_stream->p_headers = NULL;
                 free( p_org );
@@ -978,12 +978,12 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                 }
                 /* Check for Dirac header */
                 else if( ( oggpacket.bytes >= 5 &&
-                          ! memcmp( oggpacket.packet, "BBCD\x00", 5 ) ) ||
-                        ( oggpacket.bytes >= 9 &&
-                          ! memcmp( oggpacket.packet, "KW-DIRAC\x00", 9 ) ) )
-               {
-                   if( Ogg_ReadDiracHeader( p_stream, &oggpacket ) )
-                       msg_Dbg( p_demux, "found dirac header" );
+                           ! memcmp( oggpacket.packet, "BBCD\x00", 5 ) ) ||
+                         ( oggpacket.bytes >= 9 &&
+                           ! memcmp( oggpacket.packet, "KW-DIRAC\x00", 9 ) ) )
+                {
+                    if( Ogg_ReadDiracHeader( p_stream, &oggpacket ) )
+                        msg_Dbg( p_demux, "found dirac header" );
                     else
                     {
                         msg_Warn( p_demux, "found dirac header isn't decodable" );
@@ -1140,7 +1140,7 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                     }
                 }
                 else if( (*oggpacket.packet & PACKET_TYPE_BITS ) == PACKET_TYPE_HEADER &&
-                         oggpacket.bytes >= 56+1 )
+                         oggpacket.bytes >= 44+1 )
                 {
                     stream_header_t tmp;
                     stream_header_t *st = &tmp;
@@ -1155,7 +1155,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                     st->bits_per_sample = GetWLE( &oggpacket.packet[1+40] ); // (padding 2)
 
                     /* Check for video header (new format) */
-                    if( !strncmp( st->streamtype, "video", 5 ) )
+                    if( !strncmp( st->streamtype, "video", 5 ) &&
+                        oggpacket.bytes >= 52+1 )
                     {
                         st->sh.video.width = GetDWLE( &oggpacket.packet[1+44] );
                         st->sh.video.height = GetDWLE( &oggpacket.packet[1+48] );
@@ -1188,7 +1189,8 @@ static int Ogg_FindLogicalStreams( demux_t *p_demux )
                                  p_stream->fmt.video.i_bits_per_pixel );
                     }
                     /* Check for audio header (new format) */
-                    else if( !strncmp( st->streamtype, "audio", 5 ) )
+                    else if( !strncmp( st->streamtype, "audio", 5 ) &&
+                             oggpacket.bytes >= 56+1 )
                     {
                         char p_buffer[5];
                         int i_extra_size;
@@ -1835,7 +1837,7 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this,
 
             p_stream->b_force_backup = 1;
         }
-        else if( !strncmp(content_type_string, "audio/x-speex", 14) )
+        else if( !strncmp(content_type_string, "audio/x-speex", 13) )
         {
             p_stream->fmt.i_cat = AUDIO_ES;
             p_stream->fmt.i_codec = VLC_CODEC_SPEEX;
@@ -1849,14 +1851,14 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *p_this,
 
             p_stream->b_force_backup = 1;
         }
-        else if( !strncmp(content_type_string, "video/x-xvid", 14) )
+        else if( !strncmp(content_type_string, "video/x-xvid", 12) )
         {
             p_stream->fmt.i_cat = VIDEO_ES;
             p_stream->fmt.i_codec = VLC_FOURCC( 'x','v','i','d' );
 
             p_stream->b_force_backup = 1;
         }
-        else if( !strncmp(content_type_string, "video/mpeg", 14) )
+        else if( !strncmp(content_type_string, "video/mpeg", 10) )
         {
             /* n.b. MPEG streams are unsupported right now */
             p_stream->fmt.i_cat = VIDEO_ES;