* modules/codec/libmpeg2.c: fixed pts handling.
authorGildas Bazin <gbazin@videolan.org>
Tue, 25 Feb 2003 21:09:34 +0000 (21:09 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 25 Feb 2003 21:09:34 +0000 (21:09 +0000)
modules/codec/libmpeg2.c

index cf67490..e59ba62 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.1 2003/02/25 17:15:32 gbazin Exp $\r
+ * $Id: libmpeg2.c,v 1.2 2003/02/25 21:09:34 gbazin Exp $\r
  *\r
  * Authors: Gildas Bazin <gbazin@netcourrier.com>\r
  *\r
@@ -51,6 +51,8 @@ typedef struct dec_thread_t
     decoder_fifo_t   *p_fifo;                  /* stores the PES stream data */\r
     pes_packet_t     *p_pes;                  /* current PES we are decoding */\r
     mtime_t          i_pts;\r
+    mtime_t          i_previous_pts;\r
+    mtime_t          i_current_pts;\r
 \r
     /*\r
      * Output properties\r
@@ -118,6 +120,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
     p_dec->p_mpeg2dec = NULL;\r
     p_dec->p_info     = NULL;\r
     p_dec->i_pts      = 0;\r
+    p_dec->i_current_pts  = 0;\r
+    p_dec->i_previous_pts = 0;\r
 \r
     /* Initialize decoder */\r
     p_dec->p_mpeg2dec = mpeg2_init();\r
@@ -152,7 +156,9 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
                 if( p_dec->p_pes->i_pts )\r
                 {\r
                     mpeg2_pts( p_dec->p_mpeg2dec,\r
-                               p_dec->p_pes->i_pts * 9 / 100 );\r
+                               (uint32_t)p_dec->p_pes->i_pts );\r
+                    p_dec->i_previous_pts = p_dec->i_current_pts;\r
+                    p_dec->i_current_pts = p_dec->p_pes->i_pts;\r
                 }\r
                 p_data = p_dec->p_pes->p_first;\r
             }\r
@@ -205,7 +211,9 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
           break;\r
 \r
         case STATE_END:\r
+#if 0\r
             msg_Err( p_dec->p_fifo, "STATE_END" );\r
+#endif\r
         case STATE_SLICE:\r
 #if 0\r
             msg_Err( p_dec->p_fifo, "STATE_SLICE: %i",\r
@@ -219,9 +227,9 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
 \r
                 if( p_dec->p_info->display_picture->flags & PIC_FLAG_PTS )\r
                 {\r
-                    p_dec->i_pts =\r
-                        ((mtime_t)p_dec->p_info->display_picture->pts)\r
-                        * 100 / 9;\r
+                    p_dec->i_pts = ( p_dec->p_info->display_picture->pts ==\r
+                                     (uint32_t)p_dec->i_current_pts ) ?\r
+                        p_dec->i_current_pts : p_dec->i_previous_pts;\r
                 }\r
                 else\r
                 {\r