Update of /cvsroot/freevo/fred
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11096

Modified Files:
        misc.h remux.cc 
Log Message:
- bugfix in PTS correction (use separate offset for each pid)
- added timestamps to debug output


Index: remux.cc
===================================================================
RCS file: /cvsroot/freevo/fred/remux.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** remux.cc    23 Apr 2005 16:10:12 -0000      1.4
--- remux.cc    25 Apr 2005 13:05:35 -0000      1.5
***************
*** 27,30 ****
--- 27,31 ----
   */
  
+ #include <map>
  #include <stdlib.h>
  #include <inttypes.h>
***************
*** 422,427 ****
  #define IPACKS 2048
  
! // 90000 is a wild guess! 90000 == 1 second
! #define PTS_SPARE      90000LL
  
  // Start codes:
--- 423,428 ----
  #define IPACKS 2048
  
! // 22500 is a wild guess! 90000 == 1 second
! #define PTS_SPARE      22500LL
  
  // Start codes:
***************
*** 455,460 ****
    int ccCounter;
    cRepacker *repacker;
!   long long int fPTS;
!   long long int lastNewPTS;
    long long int newPTS;
    static uint8_t headr[];
--- 456,461 ----
    int ccCounter;
    cRepacker *repacker;
!   std::map< uint8_t, long long int > cid2fPTS;
!   std::map< uint8_t, long long int > cid2lastNewPTS;
    long long int newPTS;
    static uint8_t headr[];
***************
*** 494,499 ****
       printD( LOG_ERROR, "Not enough memory for ts_transform\n");
  
-   fPTS = 0;
-   lastNewPTS = 0;
    newPTS = 0;
  
--- 495,498 ----
***************
*** 717,720 ****
--- 716,724 ----
         case PRIVATE_STREAM1:
  
+ //     printD( LOG_DEBUG_REMUX, "mpeg=%d found=%d cid=0x%02X flag2=0x%02X  
%02X %02X %02X %02X %02X\n", 
+ //             mpeg, found, cid, flag2,
+ //             Buf[0], Buf[1], Buf[2], Buf[3], Buf[4]
+ //             );
+ 
              if (mpeg == 2 && found == 9) {
                 write_ipack(&flag1, 1);
***************
*** 735,759 ****
                                   );
  
!             // erstmalig Korrekturwert setzen, welcher von den PTS abgezogen 
wird.
!             if (fPTS == 0) {
!               fPTS = PTS - PTS_SPARE;
              }
  
!             newPTS = PTS - fPTS;
              if (newPTS < 0) {
                // newPTS = 0;
!               newPTS = lastNewPTS+10;  // do not set this to zero ==> breaks 
video if pts is damaged
              }
  
!             lastNewPTS = newPTS;
  
!             //        printf("cid=%02X  PTS=%llu  newPTS=%lld  
lastNewPTS=%lld  testCnt=%lld\n",
!             //               cid, PTS, newPTS, lastNewPTS, testCnt);
              //        printf("PTS: c=%d  Count=%d  found=%d flag1=%02X  
flag2=%02X  hlength=%d\n",
              //               c, Count, found, flag1, flag2, hlength );
  
              //        printf("c=%d  Count=%d  found=%d\n", c, Count, found);
!             //        printf("PTS korrigiert!  newPTS = %lld = %llX\n", 
newPTS, newPTS);
!             // neue PTS setzen
              unsigned char x;
              x = (0x21 | ((newPTS >> 30) & 0x07));
--- 739,764 ----
                                   );
  
!             // set initially correction value for each cid
!             if (cid2fPTS.find( cid ) == cid2fPTS.end()) {
!               cid2fPTS[ cid ] = PTS - PTS_SPARE;
              }
  
!             newPTS = PTS - cid2fPTS[ cid ];
              if (newPTS < 0) {
                // newPTS = 0;
!               newPTS = cid2lastNewPTS[ cid ] + 10;  // do not set this to 
zero ==> breaks video if pts is damaged
              }
  
!             cid2lastNewPTS[ cid ] = newPTS;
  
!             //        printD( LOG_DEBUG_REMUX, "cid=%02X  PTS=%llu  
newPTS=%lld  lastNewPTS=%lld\n",
!             //                cid, PTS, newPTS, cid2lastNewPTS[ cid ] );
              //        printf("PTS: c=%d  Count=%d  found=%d flag1=%02X  
flag2=%02X  hlength=%d\n",
              //               c, Count, found, flag1, flag2, hlength );
  
              //        printf("c=%d  Count=%d  found=%d\n", c, Count, found);
!             //        printf("PTS changed!  newPTS = %lld = %llX\n", newPTS, 
newPTS);
! 
!             // set new PTS
              unsigned char x;
              x = (0x21 | ((newPTS >> 30) & 0x07));
***************
*** 776,784 ****
                                     (((unsigned long long)(Buf[18])) >> 1)
                                     );
!               long long int newDTS = DTS - fPTS;
                if (newDTS < 0) {
                  newDTS = 0;
                }
!               //        printf("DTS korrigiert!  newDTS = %lld = %llX\n", 
newDTS, newDTS);
                // neue DTS setzen
                unsigned char x;
--- 781,789 ----
                                     (((unsigned long long)(Buf[18])) >> 1)
                                     );
!               long long int newDTS = DTS - cid2fPTS[ cid ];
                if (newDTS < 0) {
                  newDTS = 0;
                }
!               //        printf("DTS changed!  newDTS = %lld = %llX\n", 
newDTS, newDTS);
                // neue DTS setzen
                unsigned char x;

Index: misc.h
===================================================================
RCS file: /cvsroot/freevo/fred/misc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** misc.h      23 Apr 2005 16:10:11 -0000      1.2
--- misc.h      25 Apr 2005 13:05:34 -0000      1.3
***************
*** 30,33 ****
--- 30,36 ----
  #include <utility>
  
+ #include <sys/time.h>
+ #include <time.h>
+ 
  
  #define FN_CONFIG_FILE     "config"
***************
*** 58,63 ****
    do {                                                             \
      if(::debug_level >= verbose){                                  \
!       static char buf[8192];                                       \
!       snprintf(buf, 8192, "%12s:%04d (%s): " fmt, __FILE__, __LINE__, 
__FUNCTION__, ##args); \
        std::cout << buf;                                            \
      }                                                              \
--- 61,74 ----
    do {                                                             \
      if(::debug_level >= verbose){                                  \
!       struct timeval tv;                                           \
!       gettimeofday( &tv, NULL );                                   \
!       struct tm *curtime;                                          \
!       time_t now = time(NULL);                                     \
!       curtime = localtime( &now );                                 \
!       static char buf[8192];                                          \
!       snprintf(buf, 8192, "%02d:%02d:%02d.%03d %12s:%04d (%s): " fmt, \
!                curtime->tm_hour, curtime->tm_min,                     \
!                curtime->tm_sec, ((int)tv.tv_usec / 1000),             \
!              __FILE__, __LINE__, __FUNCTION__, ##args);             \
        std::cout << buf;                                            \
      }                                                              \



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to