[MPlayer-cvslog] r24481 - trunk/libmpdemux/demux_ty.c

reimar subversion at mplayerhq.hu
Fri Sep 14 19:39:48 CEST 2007


Author: reimar
Date: Fri Sep 14 19:39:48 2007
New Revision: 24481

Log:
Fix completely broken get_ty_pts (it's an ordinary MPEG timestamp)


Modified:
   trunk/libmpdemux/demux_ty.c

Modified: trunk/libmpdemux/demux_ty.c
==============================================================================
--- trunk/libmpdemux/demux_ty.c	(original)
+++ trunk/libmpdemux/demux_ty.c	Fri Sep 14 19:39:48 2007
@@ -45,6 +45,7 @@
 #include "stheader.h"
 #include "sub_cc.h"
 #include "libavutil/avstring.h"
+#include "libavutil/intreadwrite.h"
 
 extern void skip_audio_frame( sh_audio_t *sh_audio );
 extern int sub_justify;
@@ -354,21 +355,16 @@ static int IsValidAudioPacket( int size,
 
 static float get_ty_pts( unsigned char *buf )
 {
-   float result = 0;
-   unsigned char temp;
-
-   temp = ( buf[ 0 ] & 0xE ) >> 1;
-   result = ( (float) temp ) * ( (float) ( 1L << 30 ) ) / ( (float)PTS_KHZ );
-   temp = buf[ 1 ];
-   result += ( (float) temp ) * ( (float) ( 1L << 22 ) ) / ( (float)PTS_KHZ );
-   temp = ( buf[ 2 ] & 0xFE ) >> 1;
-   result += ( (float) temp ) * ( (float) ( 1L << 15 ) ) / ( (float)PTS_KHZ );
-   temp = buf[ 3 ];
-   result += ( (float) temp ) * ( (float) ( 1L << 7 ) ) / ( (float)PTS_KHZ );
-   temp = ( buf[ 4 ] & 0xFE ) >> 1;
-   result += ( (float) temp ) / ( (float)PTS_MHZ );
+  int a = buf[0] & 0xe;
+  int b = AV_RB16(buf + 1);
+  int c = AV_RB16(buf + 3);
+  uint64_t pts;
 
-   return result;
+  if (!(1 & a & b & c)) // invalid MPEG timestamp
+    return 0;
+  a >>= 1; b >>= 1; c >>= 1;
+  pts = (((uint64_t)a) << 30) | (b << 15) | c;
+  return (float)pts / PTS_KHZ;
 }
 
 static void demux_ty_AddToAudioBuffer( TiVoInfo *tivo, unsigned char *buffer, 



More information about the MPlayer-cvslog mailing list