* modules/codec/mpeg_video/*: Support for Slice-I (aka intra slice refresh)
authorChristophe Massiot <massiot@videolan.org>
Tue, 4 Feb 2003 11:51:21 +0000 (11:51 +0000)
committerChristophe Massiot <massiot@videolan.org>
Tue, 4 Feb 2003 11:51:21 +0000 (11:51 +0000)
  streams.

modules/codec/mpeg_video/headers.c
modules/codec/mpeg_video/parser.h

index 983dec7..cbe8876 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_headers.c : headers parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: headers.c,v 1.9 2003/01/30 02:16:09 gbazin Exp $
+ * $Id: headers.c,v 1.10 2003/02/04 11:51:21 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          St├ęphane Borel <stef@via.ecp.fr>
@@ -57,6 +57,7 @@ static void CopyrightExtension( vpar_thread_t * p_vpar );
  * Standard variables
  */
 
+
 /*****************************************************************************
  * pi_default_intra_quant : default quantization matrix
  *****************************************************************************/
@@ -311,6 +312,7 @@ static void SequenceHeader( vpar_thread_t * p_vpar )
 
     int i_aspect;
 
+    p_vpar->sequence.b_after_sequence_header = 1;
     p_vpar->sequence.i_width = GetBits( &p_vpar->bit_stream, 12 );
     p_vpar->sequence.i_height = GetBits( &p_vpar->bit_stream, 12 );
     i_aspect = GetBits( &p_vpar->bit_stream, 4 );
@@ -618,8 +620,43 @@ static void PictureHeader( vpar_thread_t * p_vpar )
     /* Extension and User data. */
     ExtensionAndUserData( p_vpar );
 
+#define P_picture p_vpar->picture.p_picture
     p_vpar->pc_pictures[p_vpar->picture.i_coding_type]++;
 
+    if ( p_vpar->picture.i_coding_type != I_CODING_TYPE
+          && p_vpar->sequence.b_after_sequence_header
+          && p_vpar->sequence.p_backward == NULL )
+    {
+        /* Intra-slice refresh. */
+        while( ( P_picture = vout_CreatePicture( p_vpar->p_vout,
+                                 1, 0, 0 ) ) == NULL )
+        {
+            if( p_vpar->p_fifo->b_die || p_vpar->p_fifo->b_error )
+            {
+                return;
+            }
+            msleep( VOUT_OUTMEM_SLEEP );
+        }
+
+        P_picture->i_matrix_coefficients = p_vpar->sequence.i_matrix_coefficients;
+        memset( P_picture->p[0].p_pixels, 0,
+                p_vpar->sequence.i_height * p_vpar->sequence.i_width );
+
+        memset( P_picture->p[1].p_pixels, 0x80,
+                p_vpar->sequence.i_height * p_vpar->sequence.i_width
+                 >> (p_vpar->sequence.b_chroma_h_subsampled
+                      + p_vpar->sequence.b_chroma_v_subsampled) );
+
+        memset( P_picture->p[2].p_pixels, 0x80,
+                p_vpar->sequence.i_height * p_vpar->sequence.i_width
+                 >> (p_vpar->sequence.b_chroma_h_subsampled
+                      + p_vpar->sequence.b_chroma_v_subsampled) );
+
+        /* Update the reference pointers. */
+        ReferenceUpdate( p_vpar, I_CODING_TYPE, P_picture );
+    }
+    p_vpar->sequence.b_after_sequence_header = 0;
+
     if( p_vpar->picture.i_current_structure )
     {
         if ( (i_structure == FRAME_STRUCTURE ||
@@ -766,7 +803,6 @@ static void PictureHeader( vpar_thread_t * p_vpar )
     /* OK, now we are sure we will decode the picture. */
     p_vpar->pc_decoded_pictures[p_vpar->picture.i_coding_type]++;
 
-#define P_picture p_vpar->picture.p_picture
     p_vpar->picture.b_error = 0;
 
     if( !p_vpar->picture.i_current_structure )
index 25fc108..ddb7156 100644 (file)
@@ -2,7 +2,7 @@
  * parser.h : video parser thread
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: parser.h,v 1.2 2002/08/07 00:29:36 sam Exp $
+ * $Id: parser.h,v 1.3 2003/02/04 11:51:21 massiot Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Jean-Marc Dressler <polux@via.ecp.fr>
@@ -133,6 +133,8 @@ typedef struct sequence_s
     int                 i_current_rate;
     vlc_bool_t          b_expect_discontinuity; /* reset the frame predictors
                                                  * after the current frame   */
+    vlc_bool_t          b_after_sequence_header; /* is it the next frame after
+                                                  * the sequence header ?    */
 
     /* Copyright extension */
     vlc_bool_t          b_copyright_flag;     /* Whether the following