]> git.sesse.net Git - vlc/blobdiff - modules/codec/libmpeg2.c
* include/vlc_block_helper.h: small bugfix to block_FindStartcodeFromOffset().
[vlc] / modules / codec / libmpeg2.c
index e827145668241cedd2b5b9fd751363cfae2b4a38..be775ebf4edbaee699524747fbee4d31ddfd4a23 100755 (executable)
@@ -2,7 +2,7 @@
  * libmpeg2.c: mpeg2 video decoder module making use of libmpeg2.
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: libmpeg2.c,v 1.34 2003/11/22 23:39:14 fenrir Exp $
+ * $Id: libmpeg2.c,v 1.37 2003/12/07 12:11:13 gbazin Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -178,8 +178,9 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                 return NULL;
             }
 
-            if( p_block->b_discontinuity && p_sys->p_synchro
-                && p_sys->p_info->sequence->width != (unsigned)-1 )
+            if( p_block->b_discontinuity && p_sys->p_synchro &&
+                p_sys->p_info->sequence &&
+                p_sys->p_info->sequence->width != (unsigned)-1 )
             {
                 vout_SynchroReset( p_sys->p_synchro );
                 if( p_sys->p_info->current_fbuf != NULL
@@ -232,6 +233,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
             if( p_dec->fmt_in.video.i_aspect )
             {
                 p_sys->i_aspect = p_dec->fmt_in.video.i_aspect;
+                if( p_sys->i_aspect <= AR_221_1_PICTURE )
                 switch( p_sys->i_aspect )
                 {
                 case AR_3_4_PICTURE:
@@ -244,7 +246,6 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                     p_sys->i_aspect = VOUT_ASPECT_FACTOR * 221 / 100;
                     break;
                 case AR_SQUARE_PICTURE:
-                default:
                     p_sys->i_aspect = VOUT_ASPECT_FACTOR *
                                    p_sys->p_info->sequence->width /
                                    p_sys->p_info->sequence->height;
@@ -287,7 +288,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
             /* For some reason, libmpeg2 will put this pic twice in
              * discard_picture. This can be considered a bug in libmpeg2. */
-            //vout_LinkPicture( p_sys->p_vout, p_pic );
+            p_dec->pf_picture_link( p_dec, p_pic );
 
             if( p_sys->p_synchro )
             {
@@ -376,6 +377,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
 
         case STATE_END:
         case STATE_SLICE:
+            p_pic = NULL;
             if( p_sys->p_info->display_fbuf
                 && p_sys->p_info->display_fbuf->id )
             {
@@ -396,17 +398,16 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                     p_sys->p_picture_to_destroy = NULL;
                     p_pic->date = 0;
                 }
-           return p_pic; /* FIXME */
             }
 
             if( p_sys->p_info->discard_fbuf &&
                 p_sys->p_info->discard_fbuf->id )
             {
-               //p_pic = (picture_t *)p_sys->p_info->discard_fbuf->id;
-                //vout_UnlinkPicture( p_sys->p_vout, p_pic );
+                p_dec->pf_picture_unlink( p_dec,
+                                          p_sys->p_info->discard_fbuf->id );
             }
 
-           //return p_pic; /* FIXME */
+           if( p_pic ) return p_pic;
 
             break;
 
@@ -420,7 +421,7 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                ( ( p_sys->p_info->current_picture->flags &
                   PIC_MASK_CODING_TYPE) != B_CODING_TYPE ) )
             {
-                vout_SynchroReset( p_sys->p_synchro );
+                if( p_sys->p_synchro ) vout_SynchroReset( p_sys->p_synchro );
             }
             mpeg2_skip( p_sys->p_mpeg2dec, 1 );
             p_sys->b_skip = 1;
@@ -431,6 +432,10 @@ static picture_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block )
                 p_sys->b_garbage_pic = 1;
                 p_pic = p_sys->p_info->current_fbuf->id;
             }
+            else if( !p_sys->p_info->sequence )
+            {
+                break;
+            }
             else
             {
                 if( (p_pic = GetNewPicture( p_dec, buf )) == NULL )
@@ -512,7 +517,7 @@ static picture_t *GetNewPicture( decoder_t *p_dec, uint8_t **pp_buf )
     p_pic->i_nb_fields = p_sys->p_info->current_picture != NULL ?
         p_sys->p_info->current_picture->nb_fields : 2;
 
-    //vout_LinkPicture( p_sys->p_vout, p_pic );
+    p_dec->pf_picture_link( p_dec, p_pic );
 
     pp_buf[0] = p_pic->p[0].p_pixels;
     pp_buf[1] = p_pic->p[1].p_pixels;