Revision a2704c97 libavformat/asfdec.c

View differences:

libavformat/asfdec.c
160 160
static void get_tag(AVFormatContext *s, const char *key, int type, int len)
161 161
{
162 162
    char *value;
163
    int64_t off = url_ftell(s->pb);
163
    int64_t off = avio_tell(s->pb);
164 164

  
165 165
    if ((unsigned)len >= (UINT_MAX - 1)/2)
166 166
        return;
......
226 226
        return AVERROR(EINVAL);
227 227
    }
228 228

  
229
    pos1 = url_ftell(pb);
229
    pos1 = avio_tell(pb);
230 230

  
231 231
    st = av_new_stream(s, 0);
232 232
    if (!st)
......
301 301
            st->need_parsing = AVSTREAM_PARSE_FULL;
302 302
        }
303 303
        /* We have to init the frame size at some point .... */
304
        pos2 = url_ftell(pb);
304
        pos2 = avio_tell(pb);
305 305
        if (size >= (pos2 + 8 - pos1 + 24)) {
306 306
            asf_st->ds_span = avio_r8(pb);
307 307
            asf_st->ds_packet_size = avio_rl16(pb);
......
338 338
                break;
339 339
        }
340 340
    } else if (type == AVMEDIA_TYPE_VIDEO &&
341
            size - (url_ftell(pb) - pos1 + 24) >= 51) {
341
            size - (avio_tell(pb) - pos1 + 24) >= 51) {
342 342
        avio_rl32(pb);
343 343
        avio_rl32(pb);
344 344
        avio_r8(pb);
......
387 387
        if(st->codec->codec_id == CODEC_ID_H264)
388 388
            st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
389 389
    }
390
    pos2 = url_ftell(pb);
390
    pos2 = avio_tell(pb);
391 391
    avio_seek(pb, size - (pos2 - pos1 + 24), SEEK_CUR);
392 392

  
393 393
    return 0;
......
595 595
    avio_r8(pb);
596 596
    memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
597 597
    for(;;) {
598
        uint64_t gpos= url_ftell(pb);
598
        uint64_t gpos= avio_tell(pb);
599 599
        ff_get_guid(pb, &g);
600 600
        gsize = avio_rl64(pb);
601 601
        av_dlog(s, "%08"PRIx64": ", gpos);
602 602
        print_guid(&g);
603 603
        av_dlog(s, "  size=0x%"PRIx64"\n", gsize);
604 604
        if (!ff_guidcmp(&g, &ff_asf_data_header)) {
605
            asf->data_object_offset = url_ftell(pb);
605
            asf->data_object_offset = avio_tell(pb);
606 606
            // if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
607 607
            if (!(asf->hdr.flags & 0x01) && gsize >= 100) {
608 608
                asf->data_object_size = gsize - 24;
......
652 652
                }
653 653
            }
654 654
        }
655
        if(url_ftell(pb) != gpos + gsize)
656
            av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize);
655
        if(avio_tell(pb) != gpos + gsize)
656
            av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", avio_tell(pb)-gpos, gsize);
657 657
        avio_seek(pb, gpos + gsize, SEEK_SET);
658 658
    }
659 659
    ff_get_guid(pb, &g);
......
662 662
    avio_r8(pb);
663 663
    if (url_feof(pb))
664 664
        return -1;
665
    asf->data_offset = url_ftell(pb);
665
    asf->data_offset = avio_tell(pb);
666 666
    asf->packet_size_left = 0;
667 667

  
668 668

  
......
726 726
    // if we do not know packet size, allow skipping up to 32 kB
727 727
    off= 32768;
728 728
    if (s->packet_size > 0)
729
        off= (url_ftell(pb) - s->data_offset) % s->packet_size + 3;
729
        off= (avio_tell(pb) - s->data_offset) % s->packet_size + 3;
730 730

  
731 731
    c=d=e=-1;
732 732
    while(off-- > 0){
......
746 746
        if (url_ferror(pb) == AVERROR(EAGAIN))
747 747
            return AVERROR(EAGAIN);
748 748
        if (!url_feof(pb))
749
            av_log(s, AV_LOG_ERROR, "ff asf bad header %x  at:%"PRId64"\n", c, url_ftell(pb));
749
            av_log(s, AV_LOG_ERROR, "ff asf bad header %x  at:%"PRId64"\n", c, avio_tell(pb));
750 750
    }
751 751
    if ((c & 0x8f) == 0x82) {
752 752
        if (d || e) {
......
770 770

  
771 771
    //the following checks prevent overflows and infinite loops
772 772
    if(!packet_length || packet_length >= (1U<<29)){
773
        av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, url_ftell(pb));
773
        av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, avio_tell(pb));
774 774
        return -1;
775 775
    }
776 776
    if(padsize >= packet_length){
777
        av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, url_ftell(pb));
777
        av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
778 778
        return -1;
779 779
    }
780 780

  
......
892 892
            || asf->packet_segments < 1) {
893 893
            //asf->packet_size_left <= asf->packet_padsize) {
894 894
            int ret = asf->packet_size_left + asf->packet_padsize;
895
            //printf("PacketLeftSize:%d  Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, url_ftell(pb));
895
            //printf("PacketLeftSize:%d  Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, avio_tell(pb));
896 896
            assert(ret>=0);
897 897
            /* fail safe */
898 898
            avio_seek(pb, ret, SEEK_CUR);
899 899

  
900
            asf->packet_pos= url_ftell(pb);
900
            asf->packet_pos= avio_tell(pb);
901 901
            if (asf->data_object_size != (uint64_t)-1 &&
902 902
                (asf->packet_pos - asf->data_object_offset >= asf->data_object_size))
903 903
                return AVERROR_EOF; /* Do not exceed the size of the data object */
......
1185 1185
{
1186 1186
    ff_asf_guid g;
1187 1187
    ASFContext *asf = s->priv_data;
1188
    int64_t current_pos= url_ftell(s->pb);
1188
    int64_t current_pos= avio_tell(s->pb);
1189 1189
    int i;
1190 1190

  
1191 1191
    avio_seek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET);
......
1268 1268
    //    avio_seek(s->pb, pos, SEEK_SET);
1269 1269
    //    key_pos = pos;
1270 1270
    //     for(i=0;i<16;i++){
1271
    //         pos = url_ftell(s->pb);
1271
    //         pos = avio_tell(s->pb);
1272 1272
    //         if (av_read_frame(s, &pkt) < 0){
1273 1273
    //             av_log(s, AV_LOG_INFO, "seek failed\n");
1274 1274
    //             return -1;

Also available in: Unified diff