]> git.sesse.net Git - vlc/blobdiff - modules/codec/theora.c
Fix email address
[vlc] / modules / codec / theora.c
index 3806d9eaaf9ec3d19c4ddfbdf61c9a15905251a1..fb543a73495258f6e9aa9c61dec41d5f85f64903 100644 (file)
@@ -315,6 +315,21 @@ static int ProcessHeaders( decoder_t *p_dec )
              p_sys->ti.frame_width, p_sys->ti.frame_height,
              p_sys->ti.offset_x, p_sys->ti.offset_y );
 
+    /* Sanity check that seems necessary for some corrupted files */
+    if( p_sys->ti.width < p_sys->ti.frame_width ||
+        p_sys->ti.height < p_sys->ti.frame_height )
+    {
+        msg_Warn( p_dec, "trying to correct invalid theora header "
+                  "(frame size (%dx%d) is smaller than frame content (%d,%d))",
+                  p_sys->ti.width, p_sys->ti.height,
+                  p_sys->ti.frame_width, p_sys->ti.frame_height );
+
+        if( p_sys->ti.width < p_sys->ti.frame_width )
+            p_sys->ti.width = p_sys->ti.frame_width;
+        if( p_sys->ti.height < p_sys->ti.frame_height )
+            p_sys->ti.height = p_sys->ti.frame_height;
+    }
+
     /* The next packet in order is the comments header */
     oggpacket.b_o_s = 0;
     oggpacket.bytes = *(p_extra++) << 8;
@@ -386,7 +401,7 @@ static void *ProcessPacket( decoder_t *p_dec, ogg_packet *p_oggpacket,
     block_t *p_block = *pp_block;
     void *p_buf;
 
-    if( ( p_block->i_flags & BLOCK_FLAG_DISCONTINUITY ) != 0 )
+    if( ( p_block->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) != 0 )
     {
         /* Don't send the the first packet after a discontinuity to
          * theora_decode, otherwise we get purple/green display artifacts
@@ -442,7 +457,9 @@ static picture_t *DecodePacket( decoder_t *p_dec, ogg_packet *p_oggpacket )
 
     theora_decode_packetin( &p_sys->td, p_oggpacket );
 
-    if( theora_packet_iskeyframe( p_oggpacket ) == 1 )
+    /* Check for keyframe */
+    if( !(p_oggpacket->packet[0] & 0x80) /* data packet */ &&
+        !(p_oggpacket->packet[0] & 0x40) /* intra frame */ )
         p_sys->b_decoded_first_keyframe = VLC_TRUE;
 
     /* If we haven't seen a single keyframe yet, don't let Theora decode
@@ -543,7 +560,8 @@ static void theora_CopyPicture( decoder_t *p_dec, picture_t *p_pic,
 
         for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; i_line++ )
         {
-            p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_width );
+            p_dec->p_vlc->pf_memcpy( p_dst, p_src + i_src_xoffset,
+                                     i_plane ? yuv->uv_width : yuv->y_width );
             p_src += i_src_stride;
             p_dst += i_dst_stride;
         }