Revision e63a3628 libavformat/avidec.c

View differences:

libavformat/avidec.c
107 107
    int i;
108 108

  
109 109
    /* check RIFF header */
110
    get_buffer(pb, header, 4);
111
    avi->riff_end = get_le32(pb);   /* RIFF chunk size */
110
    avio_read(pb, header, 4);
111
    avi->riff_end = avio_rl32(pb);  /* RIFF chunk size */
112 112
    avi->riff_end += url_ftell(pb); /* RIFF chunk end */
113
    get_buffer(pb, header+4, 4);
113
    avio_read(pb, header+4, 4);
114 114

  
115 115
    for(i=0; avi_headers[i][0]; i++)
116 116
        if(!memcmp(header, avi_headers[i], 8))
......
127 127
static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){
128 128
    AVIContext *avi = s->priv_data;
129 129
    AVIOContext *pb = s->pb;
130
    int longs_pre_entry= get_le16(pb);
131
    int index_sub_type = get_byte(pb);
132
    int index_type     = get_byte(pb);
133
    int entries_in_use = get_le32(pb);
134
    int chunk_id       = get_le32(pb);
135
    int64_t base       = get_le64(pb);
130
    int longs_pre_entry= avio_rl16(pb);
131
    int index_sub_type = avio_r8(pb);
132
    int index_type     = avio_r8(pb);
133
    int entries_in_use = avio_rl32(pb);
134
    int chunk_id       = avio_rl32(pb);
135
    int64_t base       = avio_rl64(pb);
136 136
    int stream_id= 10*((chunk_id&0xFF) - '0') + (((chunk_id>>8)&0xFF) - '0');
137 137
    AVStream *st;
138 138
    AVIStream *ast;
......
153 153
    if(index_sub_type)
154 154
        return -1;
155 155

  
156
    get_le32(pb);
156
    avio_rl32(pb);
157 157

  
158 158
    if(index_type && longs_pre_entry != 2)
159 159
        return -1;
......
170 170

  
171 171
    for(i=0; i<entries_in_use; i++){
172 172
        if(index_type){
173
            int64_t pos= get_le32(pb) + base - 8;
174
            int len    = get_le32(pb);
173
            int64_t pos= avio_rl32(pb) + base - 8;
174
            int len    = avio_rl32(pb);
175 175
            int key= len >= 0;
176 176
            len &= 0x7FFFFFFF;
177 177

  
......
191 191
        }else{
192 192
            int64_t offset, pos;
193 193
            int duration;
194
            offset = get_le64(pb);
195
            get_le32(pb);       /* size */
196
            duration = get_le32(pb);
194
            offset = avio_rl64(pb);
195
            avio_rl32(pb);       /* size */
196
            duration = avio_rl32(pb);
197 197

  
198 198
            if(url_feof(pb))
199 199
                return -1;
......
256 256
    value = av_malloc(size+1);
257 257
    if (!value)
258 258
        return -1;
259
    get_buffer(pb, value, size);
259
    avio_read(pb, value, size);
260 260
    value[size]=0;
261 261

  
262 262
    AV_WL32(key, tag);
......
268 268
static void avi_read_info(AVFormatContext *s, uint64_t end)
269 269
{
270 270
    while (url_ftell(s->pb) < end) {
271
        uint32_t tag  = get_le32(s->pb);
272
        uint32_t size = get_le32(s->pb);
271
        uint32_t tag  = avio_rl32(s->pb);
272
        uint32_t size = avio_rl32(s->pb);
273 273
        avi_read_tag(s, NULL, tag, size);
274 274
    }
275 275
}
......
299 299
static void avi_read_nikon(AVFormatContext *s, uint64_t end)
300 300
{
301 301
    while (url_ftell(s->pb) < end) {
302
        uint32_t tag  = get_le32(s->pb);
303
        uint32_t size = get_le32(s->pb);
302
        uint32_t tag  = avio_rl32(s->pb);
303
        uint32_t size = avio_rl32(s->pb);
304 304
        switch (tag) {
305 305
        case MKTAG('n', 'c', 't', 'g'): {  /* Nikon Tags */
306 306
            uint64_t tag_end = url_ftell(s->pb) + size;
307 307
            while (url_ftell(s->pb) < tag_end) {
308
                uint16_t tag  = get_le16(s->pb);
309
                uint16_t size = get_le16(s->pb);
308
                uint16_t tag  = avio_rl16(s->pb);
309
                uint16_t size = avio_rl16(s->pb);
310 310
                const char *name = NULL;
311 311
                char buffer[64] = {0};
312
                size -= get_buffer(s->pb, buffer,
312
                size -= avio_read(s->pb, buffer,
313 313
                                   FFMIN(size, sizeof(buffer)-1));
314 314
                switch (tag) {
315 315
                case 0x03:  name = "maker";  break;
......
362 362
    for(;;) {
363 363
        if (url_feof(pb))
364 364
            goto fail;
365
        tag = get_le32(pb);
366
        size = get_le32(pb);
365
        tag = avio_rl32(pb);
366
        size = avio_rl32(pb);
367 367

  
368 368
        print_tag("tag", tag, size);
369 369

  
......
371 371
        case MKTAG('L', 'I', 'S', 'T'):
372 372
            list_end = url_ftell(pb) + size;
373 373
            /* Ignored, except at start of video packets. */
374
            tag1 = get_le32(pb);
374
            tag1 = avio_rl32(pb);
375 375

  
376 376
            print_tag("list", tag1, 0);
377 377

  
......
391 391
        case MKTAG('I', 'D', 'I', 'T'): {
392 392
            unsigned char date[64] = {0};
393 393
            size += (size & 1);
394
            size -= get_buffer(pb, date, FFMIN(size, sizeof(date)-1));
394
            size -= avio_read(pb, date, FFMIN(size, sizeof(date)-1));
395 395
            url_fskip(pb, size);
396 396
            avi_metadata_creation_time(&s->metadata, date);
397 397
            break;
......
405 405
        case MKTAG('a', 'v', 'i', 'h'):
406 406
            /* AVI header */
407 407
            /* using frame_period is bad idea */
408
            frame_period = get_le32(pb);
409
            bit_rate = get_le32(pb) * 8;
410
            get_le32(pb);
411
            avi->non_interleaved |= get_le32(pb) & AVIF_MUSTUSEINDEX;
408
            frame_period = avio_rl32(pb);
409
            bit_rate = avio_rl32(pb) * 8;
410
            avio_rl32(pb);
411
            avi->non_interleaved |= avio_rl32(pb) & AVIF_MUSTUSEINDEX;
412 412

  
413 413
            url_fskip(pb, 2 * 4);
414
            get_le32(pb);
415
            get_le32(pb);
416
            avih_width=get_le32(pb);
417
            avih_height=get_le32(pb);
414
            avio_rl32(pb);
415
            avio_rl32(pb);
416
            avih_width=avio_rl32(pb);
417
            avih_height=avio_rl32(pb);
418 418

  
419 419
            url_fskip(pb, size - 10 * 4);
420 420
            break;
421 421
        case MKTAG('s', 't', 'r', 'h'):
422 422
            /* stream header */
423 423

  
424
            tag1 = get_le32(pb);
425
            handler = get_le32(pb); /* codec tag */
424
            tag1 = avio_rl32(pb);
425
            handler = avio_rl32(pb); /* codec tag */
426 426

  
427 427
            if(tag1 == MKTAG('p', 'a', 'd', 's')){
428 428
                url_fskip(pb, size - 8);
......
470 470
                }
471 471
                s->streams[0]->priv_data = ast;
472 472
                url_fskip(pb, 3 * 4);
473
                ast->scale = get_le32(pb);
474
                ast->rate = get_le32(pb);
473
                ast->scale = avio_rl32(pb);
474
                ast->rate = avio_rl32(pb);
475 475
                url_fskip(pb, 4);  /* start time */
476 476

  
477
                dv_dur = get_le32(pb);
477
                dv_dur = avio_rl32(pb);
478 478
                if (ast->scale > 0 && ast->rate > 0 && dv_dur > 0) {
479 479
                    dv_dur *= AV_TIME_BASE;
480 480
                    s->duration = av_rescale(dv_dur, ast->scale, ast->rate);
......
492 492
            assert(stream_index < s->nb_streams);
493 493
            st->codec->stream_codec_tag= handler;
494 494

  
495
            get_le32(pb); /* flags */
496
            get_le16(pb); /* priority */
497
            get_le16(pb); /* language */
498
            get_le32(pb); /* initial frame */
499
            ast->scale = get_le32(pb);
500
            ast->rate = get_le32(pb);
495
            avio_rl32(pb); /* flags */
496
            avio_rl16(pb); /* priority */
497
            avio_rl16(pb); /* language */
498
            avio_rl32(pb); /* initial frame */
499
            ast->scale = avio_rl32(pb);
500
            ast->rate = avio_rl32(pb);
501 501
            if(!(ast->scale && ast->rate)){
502 502
                av_log(s, AV_LOG_WARNING, "scale/rate is %u/%u which is invalid. (This file has been generated by broken software.)\n", ast->scale, ast->rate);
503 503
                if(frame_period){
......
510 510
            }
511 511
            av_set_pts_info(st, 64, ast->scale, ast->rate);
512 512

  
513
            ast->cum_len=get_le32(pb); /* start */
514
            st->nb_frames = get_le32(pb);
513
            ast->cum_len=avio_rl32(pb); /* start */
514
            st->nb_frames = avio_rl32(pb);
515 515

  
516 516
            st->start_time = 0;
517
            get_le32(pb); /* buffer size */
518
            get_le32(pb); /* quality */
519
            ast->sample_size = get_le32(pb); /* sample ssize */
517
            avio_rl32(pb); /* buffer size */
518
            avio_rl32(pb); /* quality */
519
            ast->sample_size = avio_rl32(pb); /* sample ssize */
520 520
            ast->cum_len *= FFMAX(1, ast->sample_size);
521 521
//            av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
522 522

  
......
579 579
                            st->codec->extradata_size= 0;
580 580
                            return AVERROR(ENOMEM);
581 581
                        }
582
                        get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
582
                        avio_read(pb, st->codec->extradata, st->codec->extradata_size);
583 583
                    }
584 584

  
585 585
                    if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
586
                        get_byte(pb);
586
                        avio_r8(pb);
587 587

  
588 588
                    /* Extract palette from extradata if bpp <= 8. */
589 589
                    /* This code assumes that extradata contains only palette. */
......
675 675
                AVRational active, active_aspect;
676 676

  
677 677
                st = s->streams[stream_index];
678
                get_le32(pb);
679
                get_le32(pb);
680
                get_le32(pb);
681
                get_le32(pb);
682
                get_le32(pb);
683

  
684
                active_aspect.den= get_le16(pb);
685
                active_aspect.num= get_le16(pb);
686
                active.num       = get_le32(pb);
687
                active.den       = get_le32(pb);
688
                get_le32(pb); //nbFieldsPerFrame
678
                avio_rl32(pb);
679
                avio_rl32(pb);
680
                avio_rl32(pb);
681
                avio_rl32(pb);
682
                avio_rl32(pb);
683

  
684
                active_aspect.den= avio_rl16(pb);
685
                active_aspect.num= avio_rl16(pb);
686
                active.num       = avio_rl32(pb);
687
                active.den       = avio_rl32(pb);
688
                avio_rl32(pb); //nbFieldsPerFrame
689 689

  
690 690
                if(active_aspect.num && active_aspect.den && active.num && active.den){
691 691
                    st->sample_aspect_ratio= av_div_q(active_aspect, active);
......
756 756
                                              pkt->size - 7,
757 757
                                              0, NULL, NULL, NULL, NULL);
758 758
        AVProbeData pd;
759
        unsigned int desc_len = get_le32(pb);
759
        unsigned int desc_len = avio_rl32(pb);
760 760

  
761 761
        if (desc_len > pb->buf_end - pb->buf_ptr)
762 762
            goto error;
......
766 766
        if (*desc)
767 767
            av_metadata_set2(&st->metadata, "title", desc, 0);
768 768

  
769
        get_le16(pb);   /* flags? */
770
        get_le32(pb);   /* data size */
769
        avio_rl16(pb);   /* flags? */
770
        avio_rl32(pb);   /* data size */
771 771

  
772 772
        pd = (AVProbeData) { .buf = pb->buf_ptr, .buf_size = pb->buf_end - pb->buf_ptr };
773 773
        if (!(sub_demuxer = av_probe_input_format2(&pd, 1, &score)))
......
994 994

  
995 995
        for(j=0; j<7; j++)
996 996
            d[j]= d[j+1];
997
        d[7]= get_byte(pb);
997
        d[7]= avio_r8(pb);
998 998

  
999 999
        size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
1000 1000

  
......
1065 1065
            }
1066 1066

  
1067 1067
            if (d[2] == 'p' && d[3] == 'c' && size<=4*256+4) {
1068
                int k = get_byte(pb);
1069
                int last = (k + get_byte(pb) - 1) & 0xFF;
1068
                int k = avio_r8(pb);
1069
                int last = (k + avio_r8(pb) - 1) & 0xFF;
1070 1070

  
1071
                get_le16(pb); //flags
1071
                avio_rl16(pb); //flags
1072 1072

  
1073 1073
                for (; k <= last; k++)
1074
                    ast->pal[k] = get_be32(pb)>>8;// b + (g << 8) + (r << 16);
1074
                    ast->pal[k] = avio_rb32(pb)>>8;// b + (g << 8) + (r << 16);
1075 1075
                ast->has_pal= 1;
1076 1076
                goto resync;
1077 1077
            } else if(   ((ast->prefix_count<5 || sync+9 > i) && d[2]<128 && d[3]<128) ||
......
1123 1123

  
1124 1124
    /* Read the entries and sort them in each stream component. */
1125 1125
    for(i = 0; i < nb_index_entries; i++) {
1126
        tag = get_le32(pb);
1127
        flags = get_le32(pb);
1128
        pos = get_le32(pb);
1129
        len = get_le32(pb);
1126
        tag = avio_rl32(pb);
1127
        flags = avio_rl32(pb);
1128
        pos = avio_rl32(pb);
1129
        len = avio_rl32(pb);
1130 1130
#if defined(DEBUG_SEEK)
1131 1131
        av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
1132 1132
               i, tag, flags, pos, len);
......
1175 1175
        if(n >= 2){
1176 1176
            int64_t pos= st->index_entries[0].pos;
1177 1177
            url_fseek(s->pb, pos + 4, SEEK_SET);
1178
            size= get_le32(s->pb);
1178
            size= avio_rl32(s->pb);
1179 1179
            if(pos + size > st->index_entries[1].pos)
1180 1180
                last_start= INT64_MAX;
1181 1181
        }
......
1205 1205
    for(;;) {
1206 1206
        if (url_feof(pb))
1207 1207
            break;
1208
        tag = get_le32(pb);
1209
        size = get_le32(pb);
1208
        tag = avio_rl32(pb);
1209
        size = avio_rl32(pb);
1210 1210
#ifdef DEBUG_SEEK
1211 1211
        printf("tag=%c%c%c%c size=0x%x\n",
1212 1212
               tag & 0xff,

Also available in: Unified diff