Ticket #1853: mplayer-1.1-vobsub-ts.patch

File mplayer-1.1-vobsub-ts.patch, 1.6 KB (added by daniel.pielmeier@…, 14 years ago)

Patch: Do not write idx entries for pts differences smaller than a millisecond

  • sub/vobsub.c

    old new  
    12801280        unsigned char buffer[2048];
    12811281        unsigned char *p;
    12821282        int remain = 2048;
    1283         /* Do not output twice a line with the same timestamp, this
    1284            breaks Windows' Vobsub */
    1285         if (vob->fidx && (!last_pts_set || last_pts != pts)) {
    1286             static unsigned int last_h = 9999, last_m = 9999, last_s = 9999, last_ms = 9999;
     1283        /* Only output timestamps which differ more than one millisecond */
     1284        if (!last_pts_set)
     1285            last_pts = -1;
     1286        double pts_diff = pts - last_pts;
     1287        double abs_pts_diff = pts_diff < 0 ? -pts_diff : pts_diff;
     1288        if (vob->fidx && abs_pts_diff > 0.001) {
    12871289            unsigned int h, m, ms;
    12881290            double s;
    12891291            s = pts;
     
    12941296            ms = (s - (unsigned int) s) * 1000;
    12951297            if (ms >= 1000)     /* prevent overflows or bad float stuff */
    12961298                ms = 0;
    1297             if (h != last_h || m != last_m || (unsigned int) s != last_s || ms != last_ms) {
    1298                 fprintf(vob->fidx, "timestamp: %02u:%02u:%02u:%03u, filepos: %09lx\n",
    1299                         h, m, (unsigned int) s, ms, ftell(vob->fsub));
    1300                 last_h = h;
    1301                 last_m = m;
    1302                 last_s = (unsigned int) s;
    1303                 last_ms = ms;
    1304             }
     1299            fprintf(vob->fidx, "timestamp: %02u:%02u:%02u:%03u, filepos: %09lx\n",
     1300                    h, m, (unsigned int) s, ms, ftell(vob->fsub));
    13051301        }
    13061302        last_pts = pts;
    13071303        last_pts_set = 1;