]> git.sesse.net Git - vlc/commitdiff
* modules/codec/libmpeg2.c: added code to handle 3:2 pulldown.
authorGildas Bazin <gbazin@videolan.org>
Wed, 26 Mar 2003 22:56:39 +0000 (22:56 +0000)
committerGildas Bazin <gbazin@videolan.org>
Wed, 26 Mar 2003 22:56:39 +0000 (22:56 +0000)
modules/codec/libmpeg2.c

index 61d565f651ddce1c26a320be8f8fa4284faf91a5..875cf0d4be4ff57b1d546654f3d9afd2938840ee 100755 (executable)
@@ -2,7 +2,7 @@
  * libmpeg2.c: mpeg2 video decoder module making use of libmpeg2.\r
  *****************************************************************************\r
  * Copyright (C) 1999-2001 VideoLAN\r
- * $Id: libmpeg2.c,v 1.4 2003/03/25 23:06:49 gbazin Exp $\r
+ * $Id: libmpeg2.c,v 1.5 2003/03/26 22:56:39 gbazin Exp $\r
  *\r
  * Authors: Gildas Bazin <gbazin@netcourrier.com>\r
  *\r
@@ -266,6 +266,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
                 if( p_dec->p_info->display_picture->flags & PIC_FLAG_PTS )\r
                 {\r
                     p_dec->i_pts = p_pic->date;\r
+                    p_dec->i_period_remainder = 0;\r
                 }\r
                 else\r
                 {\r
@@ -280,6 +281,23 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
                 vout_DatePicture( p_dec->p_vout, p_pic, p_dec->i_pts );\r
 \r
                 vout_DisplayPicture( p_dec->p_vout, p_pic );\r
+\r
+                /* Handle pulldown by adding some delay to the pts of the next\r
+                 * picture. */\r
+                if( p_dec->p_info->display_picture->nb_fields > 2 )\r
+                {\r
+                    int i_repeat_fields =\r
+                        p_dec->p_info->display_picture->nb_fields - 2;\r
+\r
+                    p_dec->i_pts += ( (p_dec->p_info->sequence->frame_period +\r
+                                       p_dec->i_period_remainder)\r
+                                      / 27 / 2 * i_repeat_fields );\r
+                    p_dec->i_period_remainder =\r
+                        p_dec->p_info->sequence->frame_period +\r
+                        p_dec->i_period_remainder -\r
+                        ( p_dec->p_info->sequence->frame_period +\r
+                          p_dec->i_period_remainder ) / 27 / 2 * 27 * 2;\r
+                }\r
             }\r
             break;\r
 \r