Revision f59d8ff8 libavformat/mpegts.c

View differences:

libavformat/mpegts.c
1316 1316
        if (c < 0)
1317 1317
            return -1;
1318 1318
        if (c == 0x47) {
1319
            url_fseek(pb, -1, SEEK_CUR);
1319
            avio_seek(pb, -1, SEEK_CUR);
1320 1320
            return 0;
1321 1321
        }
1322 1322
    }
......
1338 1338
        /* check paquet sync byte */
1339 1339
        if (buf[0] != 0x47) {
1340 1340
            /* find a new packet start */
1341
            url_fseek(pb, -TS_PACKET_SIZE, SEEK_CUR);
1341
            avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR);
1342 1342
            if (mpegts_resync(s) < 0)
1343 1343
                return AVERROR(EAGAIN);
1344 1344
            else
......
1468 1468
        /* normal demux */
1469 1469

  
1470 1470
        /* first do a scaning to get all the services */
1471
        if (url_fseek(pb, pos, SEEK_SET) < 0)
1471
        if (avio_seek(pb, pos, SEEK_SET) < 0)
1472 1472
            av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n");
1473 1473

  
1474 1474
        mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);
......
1533 1533
#endif
1534 1534
    }
1535 1535

  
1536
    url_fseek(pb, pos, SEEK_SET);
1536
    avio_seek(pb, pos, SEEK_SET);
1537 1537
    return 0;
1538 1538
 fail:
1539 1539
    return -1;
......
1564 1564
            /* we read the next PCR (XXX: optimize it by using a bigger buffer */
1565 1565
            pos = url_ftell(s->pb);
1566 1566
            for(i = 0; i < MAX_PACKET_READAHEAD; i++) {
1567
                url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
1567
                avio_seek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET);
1568 1568
                avio_read(s->pb, pcr_buf, 12);
1569 1569
                if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
1570 1570
                    /* XXX: not precise enough */
......
1573 1573
                    break;
1574 1574
                }
1575 1575
            }
1576
            url_fseek(s->pb, pos, SEEK_SET);
1576
            avio_seek(s->pb, pos, SEEK_SET);
1577 1577
            /* no next PCR found: we use previous increment */
1578 1578
            ts->cur_pcr = pcr_h * 300 + pcr_l;
1579 1579
        }
......
1649 1649
    pos = ((*ppos  + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47;
1650 1650
    if (find_next) {
1651 1651
        for(;;) {
1652
            url_fseek(s->pb, pos, SEEK_SET);
1652
            avio_seek(s->pb, pos, SEEK_SET);
1653 1653
            if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
1654 1654
                return AV_NOPTS_VALUE;
1655 1655
            if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
......
1663 1663
            pos -= ts->raw_packet_size;
1664 1664
            if (pos < 0)
1665 1665
                return AV_NOPTS_VALUE;
1666
            url_fseek(s->pb, pos, SEEK_SET);
1666
            avio_seek(s->pb, pos, SEEK_SET);
1667 1667
            if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
1668 1668
                return AV_NOPTS_VALUE;
1669 1669
            if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
......
1774 1774
    pos= url_ftell(s->pb);
1775 1775

  
1776 1776
    for(;;) {
1777
        url_fseek(s->pb, pos, SEEK_SET);
1777
        avio_seek(s->pb, pos, SEEK_SET);
1778 1778
        if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE)
1779 1779
            return -1;
1780 1780
//        pid = AV_RB16(buf + 1) & 0x1fff;
1781 1781
        if(buf[1] & 0x40) break;
1782 1782
        pos += ts->raw_packet_size;
1783 1783
    }
1784
    url_fseek(s->pb, pos, SEEK_SET);
1784
    avio_seek(s->pb, pos, SEEK_SET);
1785 1785

  
1786 1786
    return 0;
1787 1787
}

Also available in: Unified diff