fix #1404 (asf demuxer)
authorRafaël Carré <funman@videolan.org>
Tue, 4 Mar 2008 16:23:03 +0000 (17:23 +0100)
committerRafaël Carré <funman@videolan.org>
Tue, 4 Mar 2008 16:23:03 +0000 (17:23 +0100)
in some files, we don't have to skip the last padding bytes

modules/demux/asf/asf.c

index 199dfc4..7771a59 100644 (file)
@@ -439,7 +439,7 @@ static int DemuxPacket( demux_t *p_demux )
     i_packet_send_time = GetDWLE( p_peek + i_skip ); i_skip += 4;
     i_packet_duration  = GetWLE( p_peek + i_skip ); i_skip += 2;
 
-    i_packet_size_left = i_packet_length - i_packet_padding_length;
+    i_packet_size_left = i_packet_length;
 
     if( b_packet_multiple_payload )
     {
@@ -520,7 +520,8 @@ static int DemuxPacket( demux_t *p_demux )
         }
         else
         {
-            i_payload_data_length = i_packet_length - i_skip;
+            i_payload_data_length = i_packet_length -
+                                    i_packet_padding_length - i_skip;
         }
 
         if( i_payload_data_length < 0 || i_payload_data_length > i_packet_size_left )
@@ -623,8 +624,13 @@ static int DemuxPacket( demux_t *p_demux )
 
     if( i_packet_size_left > 0 )
     {
-        msg_Warn( p_demux, "Didn't read %d bytes in the packet",
-                            i_packet_size_left );
+        if( i_packet_size_left > i_packet_padding_length )
+            msg_Warn( p_demux, "Didn't read %d bytes in the packet",
+                            i_packet_size_left - i_packet_padding_length );
+        else if( i_packet_size_left < i_packet_padding_length )
+            msg_Warn( p_demux, "Read %d too much bytes in the packet",
+                            i_packet_padding_length - i_packet_size_left );
+
         if( stream_Read( p_demux->s, NULL, i_packet_size_left )
                                                          < i_packet_size_left )
         {
@@ -633,14 +639,6 @@ static int DemuxPacket( demux_t *p_demux )
         }
     }
 
-    if( i_packet_padding_length > 0 )
-        if( stream_Read( p_demux->s, NULL, i_packet_padding_length )
-                                                    < i_packet_padding_length )
-        {
-            msg_Err( p_demux, "cannot skip padding data, EOF ?" );
-            return 0;
-        }
-
     return 1;
 
 loop_error_recovery: