Ticket #1389: vobsub.patch

File vobsub.patch, 2.7 KB (added by robm@…, 16 years ago)

Kludgy workaround to demonstrate a possible fix

  • vobsub.c

     
    285285    unsigned char *packet;
    286286    unsigned int packet_reserve;
    287287    unsigned int packet_size;
     288   
     289    unsigned int last_pts;
     290    int last_pts_diff;
    288291} mpeg_t;
    289292
    290293static mpeg_t *mpeg_open(const char *filename)
     
    293296    int err = res == NULL;
    294297    if (!err) {
    295298        res->pts            = 0;
     299        res->last_pts       = 0;
     300        res->last_pts_diff  = INT_MAX;
    296301        res->aid            = -1;
    297302        res->packet         = NULL;
    298303        res->packet_size    = 0;
     
    416421                } else
    417422                    mpeg->pts = ((buf[0] & 0x0e) << 29 | buf[1] << 22 | (buf[2] & 0xfe) << 14
    418423                        | buf[3] << 7 | (buf[4] >> 1));
     424                if (mpeg->last_pts > 0) {
     425                    mpeg->last_pts_diff = mpeg->pts - mpeg->last_pts;
     426                }
     427                mp_msg(MSGT_VOBSUB, MSGL_DBG3, "mpeg_run: pts=%d diff=%d \n", mpeg->pts, mpeg->last_pts_diff);
     428                mpeg->last_pts = mpeg->pts;
    419429            } else /* if ((pts_flags & 0xc0) == 0xc0) */ {
    420430                /* what's this? */
    421431                /* abort(); */
     
    10261036                                            last_pts_diff = pkt->pts100 - mpg->pts;
    10271037                                        else
    10281038                                            pkt->pts100 = mpg->pts;
     1039                                       
     1040                                        /* KLUGE: arbitrary pts difference
     1041                                            to merge packets */
     1042                                        if (mpg->last_pts_diff < 10000) {
     1043                                            packet_t *last = queue->packets + queue->current_index-1;
     1044                                            mp_msg(MSGT_VOBSUB, MSGL_DBG3, "vobsub_open: new pts probably belongs to last chunk. pts=%d last=%d \n", pkt->pts100, last->pts100);
     1045                                            pkt->pts100 = last->pts100;
     1046                                        }
     1047
    10291048                                        /* FIXME: should not use mpg_sub internal informations, make a copy */
    10301049                                        pkt->data = mpg->packet;
    10311050                                        pkt->size = mpg->packet_size;
     1051                                        mp_msg(MSGT_VOBSUB, MSGL_DBG3, "vobsub_open: adding packet.  pos=%lx size=%d pts100=%d \n", pos, pkt->size, pkt->pts100);
    10321052                                        mpg->packet = NULL;
    10331053                                        mpg->packet_reserve = 0;
    10341054                                        mpg->packet_size = 0;