Revision e63a3628

View differences:

libavformat/4xm.c
54 54
#define strk_SIZE 0x28
55 55

  
56 56
#define GET_LIST_HEADER() \
57
    fourcc_tag = get_le32(pb); \
58
    size = get_le32(pb); \
57
    fourcc_tag = avio_rl32(pb); \
58
    size = avio_rl32(pb); \
59 59
    if (fourcc_tag != LIST_TAG) \
60 60
        return AVERROR_INVALIDDATA; \
61
    fourcc_tag = get_le32(pb);
61
    fourcc_tag = avio_rl32(pb);
62 62

  
63 63
typedef struct AudioTrack {
64 64
    int sample_rate;
......
118 118
    header = av_malloc(header_size);
119 119
    if (!header)
120 120
        return AVERROR(ENOMEM);
121
    if (get_buffer(pb, header, header_size) != header_size){
121
    if (avio_read(pb, header, header_size) != header_size){
122 122
        av_free(header);
123 123
        return AVERROR(EIO);
124 124
    }
......
255 255

  
256 256
    while (!packet_read) {
257 257

  
258
        if ((ret = get_buffer(s->pb, header, 8)) < 0)
258
        if ((ret = avio_read(s->pb, header, 8)) < 0)
259 259
            return ret;
260 260
        fourcc_tag = AV_RL32(&header[0]);
261 261
        size = AV_RL32(&header[4]);
......
268 268
            fourxm->video_pts ++;
269 269

  
270 270
            /* skip the LIST-* tag and move on to the next fourcc */
271
            get_le32(pb);
271
            avio_rl32(pb);
272 272
            break;
273 273

  
274 274
        case ifrm_TAG:
......
285 285
            pkt->pts = fourxm->video_pts;
286 286
            pkt->pos = url_ftell(s->pb);
287 287
            memcpy(pkt->data, header, 8);
288
            ret = get_buffer(s->pb, &pkt->data[8], size);
288
            ret = avio_read(s->pb, &pkt->data[8], size);
289 289

  
290 290
            if (ret < 0){
291 291
                av_free_packet(pkt);
......
294 294
            break;
295 295

  
296 296
        case snd__TAG:
297
            track_number = get_le32(pb);
298
            out_size= get_le32(pb);
297
            track_number = avio_rl32(pb);
298
            out_size= avio_rl32(pb);
299 299
            size-=8;
300 300

  
301 301
            if (track_number < fourxm->track_count && fourxm->tracks[track_number].channels>0) {
libavformat/aea.c
63 63

  
64 64
    /* Parse the amount of channels and skip to pos 2048(0x800) */
65 65
    url_fskip(s->pb, 264);
66
    st->codec->channels = get_byte(s->pb);
66
    st->codec->channels = avio_r8(s->pb);
67 67
    url_fskip(s->pb, 1783);
68 68

  
69 69

  
libavformat/aiffdec.c
54 54
    if (url_feof(pb))
55 55
        return AVERROR(EIO);
56 56

  
57
    *tag = get_le32(pb);
58
    size = get_be32(pb);
57
    *tag = avio_rl32(pb);
58
    size = avio_rb32(pb);
59 59

  
60 60
    if (size < 0)
61 61
        size = 0x7fffffff;
......
74 74
        return;
75 75
    }
76 76

  
77
    res = get_buffer(s->pb, str, size);
77
    res = avio_read(s->pb, str, size);
78 78
    if (res < 0)
79 79
        return;
80 80

  
......
93 93
    if (size & 1)
94 94
        size++;
95 95
    codec->codec_type = AVMEDIA_TYPE_AUDIO;
96
    codec->channels = get_be16(pb);
97
    num_frames = get_be32(pb);
98
    codec->bits_per_coded_sample = get_be16(pb);
96
    codec->channels = avio_rb16(pb);
97
    num_frames = avio_rb32(pb);
98
    codec->bits_per_coded_sample = avio_rb16(pb);
99 99

  
100
    get_buffer(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
100
    avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
101 101
    sample_rate = av_ext2dbl(ext);          /* 80 bits BE IEEE extended float */
102 102
    codec->sample_rate = sample_rate;
103 103
    size -= 18;
104 104

  
105 105
    /* Got an AIFF-C? */
106 106
    if (version == AIFF_C_VERSION1) {
107
        codec->codec_tag = get_le32(pb);
107
        codec->codec_tag = avio_rl32(pb);
108 108
        codec->codec_id  = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
109 109

  
110 110
        switch (codec->codec_id) {
......
187 187
        return AVERROR_INVALIDDATA;
188 188

  
189 189
    /* AIFF data type */
190
    tag = get_le32(pb);
190
    tag = avio_rl32(pb);
191 191
    if (tag == MKTAG('A', 'I', 'F', 'F'))       /* Got an AIFF file */
192 192
        version = AIFF;
193 193
    else if (tag != MKTAG('A', 'I', 'F', 'C'))  /* An AIFF-C file then */
......
217 217
                goto got_sound;
218 218
            break;
219 219
        case MKTAG('F', 'V', 'E', 'R'):     /* Version chunk */
220
            version = get_be32(pb);
220
            version = avio_rb32(pb);
221 221
            break;
222 222
        case MKTAG('N', 'A', 'M', 'E'):     /* Sample name chunk */
223 223
            get_meta(s, "title"    , size);
......
233 233
            break;
234 234
        case MKTAG('S', 'S', 'N', 'D'):     /* Sampled sound chunk */
235 235
            aiff->data_end = url_ftell(pb) + size;
236
            offset = get_be32(pb);      /* Offset of sound data */
237
            get_be32(pb);               /* BlockSize... don't care */
236
            offset = avio_rb32(pb);      /* Offset of sound data */
237
            avio_rb32(pb);               /* BlockSize... don't care */
238 238
            offset += url_ftell(pb);    /* Compute absolute data offset */
239 239
            if (st->codec->block_align)    /* Assume COMM already parsed */
240 240
                goto got_sound;
......
251 251
            if (!st->codec->extradata)
252 252
                return AVERROR(ENOMEM);
253 253
            st->codec->extradata_size = size;
254
            get_buffer(pb, st->codec->extradata, size);
254
            avio_read(pb, st->codec->extradata, size);
255 255
            break;
256 256
        default: /* Jump */
257 257
            if (size & 1)   /* Always even aligned */
libavformat/amr.c
82 82
    AVStream *st;
83 83
    uint8_t header[9];
84 84

  
85
    get_buffer(pb, header, 6);
85
    avio_read(pb, header, 6);
86 86

  
87 87
    st = av_new_stream(s, 0);
88 88
    if (!st)
......
91 91
    }
92 92
    if(memcmp(header,AMR_header,6)!=0)
93 93
    {
94
        get_buffer(pb, header+6, 3);
94
        avio_read(pb, header+6, 3);
95 95
        if(memcmp(header,AMRWB_header,9)!=0)
96 96
        {
97 97
            return -1;
......
128 128
    }
129 129

  
130 130
//FIXME this is wrong, this should rather be in a AVParset
131
    toc=get_byte(s->pb);
131
    toc=avio_r8(s->pb);
132 132
    mode = (toc >> 3) & 0x0F;
133 133

  
134 134
    if (enc->codec_id == CODEC_ID_AMR_NB)
......
157 157
    pkt->pos= url_ftell(s->pb);
158 158
    pkt->data[0]=toc;
159 159
    pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320;
160
    read = get_buffer(s->pb, pkt->data+1, size-1);
160
    read = avio_read(s->pb, pkt->data+1, size-1);
161 161

  
162 162
    if (read != size-1)
163 163
    {
libavformat/anm.c
84 84
    int i, ret;
85 85

  
86 86
    url_fskip(pb, 4); /* magic number */
87
    if (get_le16(pb) != MAX_PAGES) {
87
    if (avio_rl16(pb) != MAX_PAGES) {
88 88
        av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
89 89
        return AVERROR_INVALIDDATA;
90 90
    }
91 91

  
92
    anm->nb_pages   = get_le16(pb);
93
    anm->nb_records = get_le32(pb);
92
    anm->nb_pages   = avio_rl16(pb);
93
    anm->nb_records = avio_rl32(pb);
94 94
    url_fskip(pb, 2); /* max records per page */
95
    anm->page_table_offset = get_le16(pb);
96
    if (get_le32(pb) != ANIM_TAG)
95
    anm->page_table_offset = avio_rl16(pb);
96
    if (avio_rl32(pb) != ANIM_TAG)
97 97
        return AVERROR_INVALIDDATA;
98 98

  
99 99
    /* video stream */
......
103 103
    st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
104 104
    st->codec->codec_id   = CODEC_ID_ANM;
105 105
    st->codec->codec_tag  = 0; /* no fourcc */
106
    st->codec->width      = get_le16(pb);
107
    st->codec->height     = get_le16(pb);
108
    if (get_byte(pb) != 0)
106
    st->codec->width      = avio_rl16(pb);
107
    st->codec->height     = avio_rl16(pb);
108
    if (avio_r8(pb) != 0)
109 109
        goto invalid;
110 110
    url_fskip(pb, 1); /* frame rate multiplier info */
111 111

  
112 112
    /* ignore last delta record (used for looping) */
113
    if (get_byte(pb))  /* has_last_delta */
113
    if (avio_r8(pb))  /* has_last_delta */
114 114
        anm->nb_records = FFMAX(anm->nb_records - 1, 0);
115 115

  
116 116
    url_fskip(pb, 1); /* last_delta_valid */
117 117

  
118
    if (get_byte(pb) != 0)
118
    if (avio_r8(pb) != 0)
119 119
        goto invalid;
120 120

  
121
    if (get_byte(pb) != 1)
121
    if (avio_r8(pb) != 1)
122 122
        goto invalid;
123 123

  
124 124
    url_fskip(pb, 1); /* other recs per frame */
125 125

  
126
    if (get_byte(pb) != 1)
126
    if (avio_r8(pb) != 1)
127 127
        goto invalid;
128 128

  
129 129
    url_fskip(pb, 32); /* record_types */
130
    st->nb_frames = get_le32(pb);
131
    av_set_pts_info(st, 64, 1, get_le16(pb));
130
    st->nb_frames = avio_rl32(pb);
131
    av_set_pts_info(st, 64, 1, avio_rl16(pb));
132 132
    url_fskip(pb, 58);
133 133

  
134 134
    /* color cycling and palette data */
......
138 138
        ret = AVERROR(ENOMEM);
139 139
        goto close_and_return;
140 140
    }
141
    ret = get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
141
    ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
142 142
    if (ret < 0)
143 143
        goto close_and_return;
144 144

  
......
149 149

  
150 150
    for (i = 0; i < MAX_PAGES; i++) {
151 151
        Page *p = &anm->pt[i];
152
        p->base_record = get_le16(pb);
153
        p->nb_records  = get_le16(pb);
154
        p->size        = get_le16(pb);
152
        p->base_record = avio_rl16(pb);
153
        p->nb_records  = avio_rl16(pb);
154
        p->size        = avio_rl16(pb);
155 155
    }
156 156

  
157 157
    /* find page of first frame */
......
211 211
    tmp = url_ftell(pb);
212 212
    url_fseek(pb, anm->page_table_offset + MAX_PAGES*6 + (anm->page<<16) +
213 213
              8 + anm->record * 2, SEEK_SET);
214
    record_size = get_le16(pb);
214
    record_size = avio_rl16(pb);
215 215
    url_fseek(pb, tmp, SEEK_SET);
216 216

  
217 217
    /* fetch record */
libavformat/apc.c
35 35
    AVIOContext *pb = s->pb;
36 36
    AVStream *st;
37 37

  
38
    get_le32(pb); /* CRYO */
39
    get_le32(pb); /* _APC */
40
    get_le32(pb); /* 1.20 */
38
    avio_rl32(pb); /* CRYO */
39
    avio_rl32(pb); /* _APC */
40
    avio_rl32(pb); /* 1.20 */
41 41

  
42 42
    st = av_new_stream(s, 0);
43 43
    if (!st)
......
46 46
    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
47 47
    st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
48 48

  
49
    get_le32(pb); /* number of samples */
50
    st->codec->sample_rate = get_le32(pb);
49
    avio_rl32(pb); /* number of samples */
50
    st->codec->sample_rate = avio_rl32(pb);
51 51

  
52 52
    st->codec->extradata_size = 2 * 4;
53 53
    st->codec->extradata = av_malloc(st->codec->extradata_size +
......
56 56
        return AVERROR(ENOMEM);
57 57

  
58 58
    /* initial predictor values for adpcm decoder */
59
    get_buffer(pb, st->codec->extradata, 2 * 4);
59
    avio_read(pb, st->codec->extradata, 2 * 4);
60 60

  
61 61
    st->codec->channels = 1;
62
    if (get_le32(pb))
62
    if (avio_rl32(pb))
63 63
        st->codec->channels = 2;
64 64

  
65 65
    st->codec->bits_per_coded_sample = 4;
libavformat/ape.c
162 162
    /* TODO: Skip any leading junk such as id3v2 tags */
163 163
    ape->junklength = 0;
164 164

  
165
    tag = get_le32(pb);
165
    tag = avio_rl32(pb);
166 166
    if (tag != MKTAG('M', 'A', 'C', ' '))
167 167
        return -1;
168 168

  
169
    ape->fileversion = get_le16(pb);
169
    ape->fileversion = avio_rl16(pb);
170 170

  
171 171
    if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
172 172
        av_log(s, AV_LOG_ERROR, "Unsupported file version - %d.%02d\n", ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
......
174 174
    }
175 175

  
176 176
    if (ape->fileversion >= 3980) {
177
        ape->padding1             = get_le16(pb);
178
        ape->descriptorlength     = get_le32(pb);
179
        ape->headerlength         = get_le32(pb);
180
        ape->seektablelength      = get_le32(pb);
181
        ape->wavheaderlength      = get_le32(pb);
182
        ape->audiodatalength      = get_le32(pb);
183
        ape->audiodatalength_high = get_le32(pb);
184
        ape->wavtaillength        = get_le32(pb);
185
        get_buffer(pb, ape->md5, 16);
177
        ape->padding1             = avio_rl16(pb);
178
        ape->descriptorlength     = avio_rl32(pb);
179
        ape->headerlength         = avio_rl32(pb);
180
        ape->seektablelength      = avio_rl32(pb);
181
        ape->wavheaderlength      = avio_rl32(pb);
182
        ape->audiodatalength      = avio_rl32(pb);
183
        ape->audiodatalength_high = avio_rl32(pb);
184
        ape->wavtaillength        = avio_rl32(pb);
185
        avio_read(pb, ape->md5, 16);
186 186

  
187 187
        /* Skip any unknown bytes at the end of the descriptor.
188 188
           This is for future compatibility */
......
190 190
            url_fseek(pb, ape->descriptorlength - 52, SEEK_CUR);
191 191

  
192 192
        /* Read header data */
193
        ape->compressiontype      = get_le16(pb);
194
        ape->formatflags          = get_le16(pb);
195
        ape->blocksperframe       = get_le32(pb);
196
        ape->finalframeblocks     = get_le32(pb);
197
        ape->totalframes          = get_le32(pb);
198
        ape->bps                  = get_le16(pb);
199
        ape->channels             = get_le16(pb);
200
        ape->samplerate           = get_le32(pb);
193
        ape->compressiontype      = avio_rl16(pb);
194
        ape->formatflags          = avio_rl16(pb);
195
        ape->blocksperframe       = avio_rl32(pb);
196
        ape->finalframeblocks     = avio_rl32(pb);
197
        ape->totalframes          = avio_rl32(pb);
198
        ape->bps                  = avio_rl16(pb);
199
        ape->channels             = avio_rl16(pb);
200
        ape->samplerate           = avio_rl32(pb);
201 201
    } else {
202 202
        ape->descriptorlength = 0;
203 203
        ape->headerlength = 32;
204 204

  
205
        ape->compressiontype      = get_le16(pb);
206
        ape->formatflags          = get_le16(pb);
207
        ape->channels             = get_le16(pb);
208
        ape->samplerate           = get_le32(pb);
209
        ape->wavheaderlength      = get_le32(pb);
210
        ape->wavtaillength        = get_le32(pb);
211
        ape->totalframes          = get_le32(pb);
212
        ape->finalframeblocks     = get_le32(pb);
205
        ape->compressiontype      = avio_rl16(pb);
206
        ape->formatflags          = avio_rl16(pb);
207
        ape->channels             = avio_rl16(pb);
208
        ape->samplerate           = avio_rl32(pb);
209
        ape->wavheaderlength      = avio_rl32(pb);
210
        ape->wavtaillength        = avio_rl32(pb);
211
        ape->totalframes          = avio_rl32(pb);
212
        ape->finalframeblocks     = avio_rl32(pb);
213 213

  
214 214
        if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
215 215
            url_fseek(pb, 4, SEEK_CUR); /* Skip the peak level */
......
217 217
        }
218 218

  
219 219
        if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
220
            ape->seektablelength = get_le32(pb);
220
            ape->seektablelength = avio_rl32(pb);
221 221
            ape->headerlength += 4;
222 222
            ape->seektablelength *= sizeof(int32_t);
223 223
        } else
......
260 260
    if (ape->seektablelength > 0) {
261 261
        ape->seektable = av_malloc(ape->seektablelength);
262 262
        for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
263
            ape->seektable[i] = get_le32(pb);
263
            ape->seektable[i] = avio_rl32(pb);
264 264
    }
265 265

  
266 266
    ape->frames[0].pos     = ape->firstframe;
......
355 355

  
356 356
    AV_WL32(pkt->data    , nblocks);
357 357
    AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
358
    ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
358
    ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
359 359

  
360 360
    pkt->pts = ape->frames[ape->currentframe].pts;
361 361
    pkt->stream_index = 0;
libavformat/apetag.c
38 38
    uint32_t size, flags;
39 39
    int i, c;
40 40

  
41
    size = get_le32(pb);  /* field size */
42
    flags = get_le32(pb); /* field flags */
41
    size = avio_rl32(pb);  /* field size */
42
    flags = avio_rl32(pb); /* field flags */
43 43
    for (i = 0; i < sizeof(key) - 1; i++) {
44
        c = get_byte(pb);
44
        c = avio_r8(pb);
45 45
        if (c < 0x20 || c > 0x7E)
46 46
            break;
47 47
        else
......
57 57
    value = av_malloc(size+1);
58 58
    if (!value)
59 59
        return AVERROR(ENOMEM);
60
    get_buffer(pb, value, size);
60
    avio_read(pb, value, size);
61 61
    value[size] = 0;
62 62
    av_metadata_set2(&s->metadata, key, value, AV_METADATA_DONT_STRDUP_VAL);
63 63
    return 0;
......
76 76

  
77 77
    url_fseek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET);
78 78

  
79
    get_buffer(pb, buf, 8);    /* APETAGEX */
79
    avio_read(pb, buf, 8);     /* APETAGEX */
80 80
    if (strncmp(buf, "APETAGEX", 8)) {
81 81
        return;
82 82
    }
83 83

  
84
    val = get_le32(pb);        /* APE tag version */
84
    val = avio_rl32(pb);       /* APE tag version */
85 85
    if (val > APE_TAG_VERSION) {
86 86
        av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION);
87 87
        return;
88 88
    }
89 89

  
90
    tag_bytes = get_le32(pb);  /* tag size */
90
    tag_bytes = avio_rl32(pb); /* tag size */
91 91
    if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) {
92 92
        av_log(s, AV_LOG_ERROR, "Tag size is way too big\n");
93 93
        return;
94 94
    }
95 95

  
96
    fields = get_le32(pb);     /* number of fields */
96
    fields = avio_rl32(pb);    /* number of fields */
97 97
    if (fields > 65536) {
98 98
        av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
99 99
        return;
100 100
    }
101 101

  
102
    val = get_le32(pb);        /* flags */
102
    val = avio_rl32(pb);       /* flags */
103 103
    if (val & APE_TAG_FLAG_IS_HEADER) {
104 104
        av_log(s, AV_LOG_ERROR, "APE Tag is a header\n");
105 105
        return;
libavformat/asfdec.c
135 135
void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
136 136
{
137 137
    assert(sizeof(*g) == 16);
138
    get_buffer(s, *g, sizeof(*g));
138
    avio_read(s, *g, sizeof(*g));
139 139
}
140 140

  
141 141
static int asf_probe(AVProbeData *pd)
......
149 149

  
150 150
static int get_value(AVIOContext *pb, int type){
151 151
    switch(type){
152
        case 2: return get_le32(pb);
153
        case 3: return get_le32(pb);
154
        case 4: return get_le64(pb);
155
        case 5: return get_le16(pb);
152
        case 2: return avio_rl32(pb);
153
        case 3: return avio_rl32(pb);
154
        case 4: return avio_rl64(pb);
155
        case 5: return avio_rl16(pb);
156 156
        default:return INT_MIN;
157 157
    }
158 158
}
......
190 190
    AVIOContext *pb = s->pb;
191 191

  
192 192
    ff_get_guid(pb, &asf->hdr.guid);
193
    asf->hdr.file_size          = get_le64(pb);
194
    asf->hdr.create_time        = get_le64(pb);
195
    get_le64(pb);                               /* number of packets */
196
    asf->hdr.play_time          = get_le64(pb);
197
    asf->hdr.send_time          = get_le64(pb);
198
    asf->hdr.preroll            = get_le32(pb);
199
    asf->hdr.ignore             = get_le32(pb);
200
    asf->hdr.flags              = get_le32(pb);
201
    asf->hdr.min_pktsize        = get_le32(pb);
202
    asf->hdr.max_pktsize        = get_le32(pb);
203
    asf->hdr.max_bitrate        = get_le32(pb);
193
    asf->hdr.file_size          = avio_rl64(pb);
194
    asf->hdr.create_time        = avio_rl64(pb);
195
    avio_rl64(pb);                               /* number of packets */
196
    asf->hdr.play_time          = avio_rl64(pb);
197
    asf->hdr.send_time          = avio_rl64(pb);
198
    asf->hdr.preroll            = avio_rl32(pb);
199
    asf->hdr.ignore             = avio_rl32(pb);
200
    asf->hdr.flags              = avio_rl32(pb);
201
    asf->hdr.min_pktsize        = avio_rl32(pb);
202
    asf->hdr.max_pktsize        = avio_rl32(pb);
203
    asf->hdr.max_bitrate        = avio_rl32(pb);
204 204
    s->packet_size = asf->hdr.max_pktsize;
205 205

  
206 206
    return 0;
......
262 262
        return -1;
263 263
    }
264 264
    ff_get_guid(pb, &g);
265
    total_size = get_le64(pb);
266
    type_specific_size = get_le32(pb);
267
    get_le32(pb);
268
    st->id = get_le16(pb) & 0x7f; /* stream id */
265
    total_size = avio_rl64(pb);
266
    type_specific_size = avio_rl32(pb);
267
    avio_rl32(pb);
268
    st->id = avio_rl16(pb) & 0x7f; /* stream id */
269 269
    // mapping of asf ID to AV stream ID;
270 270
    asf->asfid2avid[st->id] = s->nb_streams - 1;
271 271

  
272
    get_le32(pb);
272
    avio_rl32(pb);
273 273

  
274 274
    if (test_for_ext_stream_audio) {
275 275
        ff_get_guid(pb, &g);
......
277 277
            type = AVMEDIA_TYPE_AUDIO;
278 278
            is_dvr_ms_audio=1;
279 279
            ff_get_guid(pb, &g);
280
            get_le32(pb);
281
            get_le32(pb);
282
            get_le32(pb);
280
            avio_rl32(pb);
281
            avio_rl32(pb);
282
            avio_rl32(pb);
283 283
            ff_get_guid(pb, &g);
284
            get_le32(pb);
284
            avio_rl32(pb);
285 285
        }
286 286
    }
287 287

  
......
302 302
        /* We have to init the frame size at some point .... */
303 303
        pos2 = url_ftell(pb);
304 304
        if (size >= (pos2 + 8 - pos1 + 24)) {
305
            asf_st->ds_span = get_byte(pb);
306
            asf_st->ds_packet_size = get_le16(pb);
307
            asf_st->ds_chunk_size = get_le16(pb);
308
            get_le16(pb); //ds_data_size
309
            get_byte(pb); //ds_silence_data
305
            asf_st->ds_span = avio_r8(pb);
306
            asf_st->ds_packet_size = avio_rl16(pb);
307
            asf_st->ds_chunk_size = avio_rl16(pb);
308
            avio_rl16(pb); //ds_data_size
309
            avio_r8(pb);   //ds_silence_data
310 310
        }
311 311
        //printf("Descrambling: ps:%d cs:%d ds:%d s:%d  sd:%d\n",
312 312
        //       asf_st->ds_packet_size, asf_st->ds_chunk_size,
......
338 338
        }
339 339
    } else if (type == AVMEDIA_TYPE_VIDEO &&
340 340
            size - (url_ftell(pb) - pos1 + 24) >= 51) {
341
        get_le32(pb);
342
        get_le32(pb);
343
        get_byte(pb);
344
        get_le16(pb);        /* size */
345
        sizeX= get_le32(pb); /* size */
346
        st->codec->width = get_le32(pb);
347
        st->codec->height = get_le32(pb);
341
        avio_rl32(pb);
342
        avio_rl32(pb);
343
        avio_r8(pb);
344
        avio_rl16(pb);        /* size */
345
        sizeX= avio_rl32(pb); /* size */
346
        st->codec->width = avio_rl32(pb);
347
        st->codec->height = avio_rl32(pb);
348 348
        /* not available for asf */
349
        get_le16(pb); /* panes */
350
        st->codec->bits_per_coded_sample = get_le16(pb); /* depth */
351
        tag1 = get_le32(pb);
349
        avio_rl16(pb); /* panes */
350
        st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
351
        tag1 = avio_rl32(pb);
352 352
        url_fskip(pb, 20);
353 353
        //                av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
354 354
        if (sizeX > 40) {
355 355
            st->codec->extradata_size = sizeX - 40;
356 356
            st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
357
            get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
357
            avio_read(pb, st->codec->extradata, st->codec->extradata_size);
358 358
        }
359 359

  
360 360
        /* Extract palette from extradata if bpp <= 8 */
......
401 401
    uint32_t ext_d, leak_rate, stream_num;
402 402
    unsigned int stream_languageid_index;
403 403

  
404
    get_le64(pb); // starttime
405
    get_le64(pb); // endtime
406
    leak_rate = get_le32(pb); // leak-datarate
407
    get_le32(pb); // bucket-datasize
408
    get_le32(pb); // init-bucket-fullness
409
    get_le32(pb); // alt-leak-datarate
410
    get_le32(pb); // alt-bucket-datasize
411
    get_le32(pb); // alt-init-bucket-fullness
412
    get_le32(pb); // max-object-size
413
    get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
414
    stream_num = get_le16(pb); // stream-num
415

  
416
    stream_languageid_index = get_le16(pb); // stream-language-id-index
404
    avio_rl64(pb); // starttime
405
    avio_rl64(pb); // endtime
406
    leak_rate = avio_rl32(pb); // leak-datarate
407
    avio_rl32(pb); // bucket-datasize
408
    avio_rl32(pb); // init-bucket-fullness
409
    avio_rl32(pb); // alt-leak-datarate
410
    avio_rl32(pb); // alt-bucket-datasize
411
    avio_rl32(pb); // alt-init-bucket-fullness
412
    avio_rl32(pb); // max-object-size
413
    avio_rl32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved)
414
    stream_num = avio_rl16(pb); // stream-num
415

  
416
    stream_languageid_index = avio_rl16(pb); // stream-language-id-index
417 417
    if (stream_num < 128)
418 418
        asf->streams[stream_num].stream_language_index = stream_languageid_index;
419 419

  
420
    get_le64(pb); // avg frametime in 100ns units
421
    stream_ct = get_le16(pb); //stream-name-count
422
    payload_ext_ct = get_le16(pb); //payload-extension-system-count
420
    avio_rl64(pb); // avg frametime in 100ns units
421
    stream_ct = avio_rl16(pb); //stream-name-count
422
    payload_ext_ct = avio_rl16(pb); //payload-extension-system-count
423 423

  
424 424
    if (stream_num < 128)
425 425
        asf->stream_bitrates[stream_num] = leak_rate;
426 426

  
427 427
    for (i=0; i<stream_ct; i++){
428
        get_le16(pb);
429
        ext_len = get_le16(pb);
428
        avio_rl16(pb);
429
        ext_len = avio_rl16(pb);
430 430
        url_fseek(pb, ext_len, SEEK_CUR);
431 431
    }
432 432

  
433 433
    for (i=0; i<payload_ext_ct; i++){
434 434
        ff_get_guid(pb, &g);
435
        ext_d=get_le16(pb);
436
        ext_len=get_le32(pb);
435
        ext_d=avio_rl16(pb);
436
        ext_len=avio_rl32(pb);
437 437
        url_fseek(pb, ext_len, SEEK_CUR);
438 438
    }
439 439

  
......
445 445
    AVIOContext *pb = s->pb;
446 446
    int len1, len2, len3, len4, len5;
447 447

  
448
    len1 = get_le16(pb);
449
    len2 = get_le16(pb);
450
    len3 = get_le16(pb);
451
    len4 = get_le16(pb);
452
    len5 = get_le16(pb);
448
    len1 = avio_rl16(pb);
449
    len2 = avio_rl16(pb);
450
    len3 = avio_rl16(pb);
451
    len4 = avio_rl16(pb);
452
    len5 = avio_rl16(pb);
453 453
    get_tag(s, "title"    , 0, len1);
454 454
    get_tag(s, "author"   , 0, len2);
455 455
    get_tag(s, "copyright", 0, len3);
......
465 465
    ASFContext *asf = s->priv_data;
466 466
    int desc_count, i, ret;
467 467

  
468
    desc_count = get_le16(pb);
468
    desc_count = avio_rl16(pb);
469 469
    for(i=0;i<desc_count;i++) {
470 470
        int name_len,value_type,value_len;
471 471
        char name[1024];
472 472

  
473
        name_len = get_le16(pb);
473
        name_len = avio_rl16(pb);
474 474
        if (name_len%2)     // must be even, broken lavf versions wrote len-1
475 475
            name_len += 1;
476 476
        if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
477 477
            url_fskip(pb, name_len - ret);
478
        value_type = get_le16(pb);
479
        value_len  = get_le16(pb);
478
        value_type = avio_rl16(pb);
479
        value_len  = avio_rl16(pb);
480 480
        if (!value_type && value_len%2)
481 481
            value_len += 1;
482 482
        /**
......
499 499
    AVIOContext *pb = s->pb;
500 500
    ASFContext *asf = s->priv_data;
501 501
    int j, ret;
502
    int stream_count = get_le16(pb);
502
    int stream_count = avio_rl16(pb);
503 503
    for(j = 0; j < stream_count; j++) {
504 504
        char lang[6];
505
        unsigned int lang_len = get_byte(pb);
505
        unsigned int lang_len = avio_r8(pb);
506 506
        if ((ret = avio_get_str16le(pb, lang_len, lang, sizeof(lang))) < lang_len)
507 507
            url_fskip(pb, lang_len - ret);
508 508
        if (j < 128)
......
518 518
    ASFContext *asf = s->priv_data;
519 519
    int n, stream_num, name_len, value_len, value_type, value_num;
520 520
    int ret, i;
521
    n = get_le16(pb);
521
    n = avio_rl16(pb);
522 522

  
523 523
    for(i=0;i<n;i++) {
524 524
        char name[1024];
525 525

  
526
        get_le16(pb); //lang_list_index
527
        stream_num= get_le16(pb);
528
        name_len=   get_le16(pb);
529
        value_type= get_le16(pb);
530
        value_len=  get_le32(pb);
526
        avio_rl16(pb); //lang_list_index
527
        stream_num= avio_rl16(pb);
528
        name_len=   avio_rl16(pb);
529
        value_type= avio_rl16(pb);
530
        value_len=  avio_rl32(pb);
531 531

  
532 532
        if ((ret = avio_get_str16le(pb, name_len, name, sizeof(name))) < name_len)
533 533
            url_fskip(pb, name_len - ret);
534 534
        //av_log(s, AV_LOG_ERROR, "%d %d %d %d %d <%s>\n", i, stream_num, name_len, value_type, value_len, name);
535
        value_num= get_le16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
535
        value_num= avio_rl16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere
536 536
        url_fskip(pb, value_len - 2);
537 537

  
538 538
        if(stream_num<128){
......
550 550
    int i, count, name_len, ret;
551 551
    char name[1024];
552 552

  
553
    get_le64(pb);            // reserved 16 bytes
554
    get_le64(pb);            // ...
555
    count = get_le32(pb);    // markers count
556
    get_le16(pb);            // reserved 2 bytes
557
    name_len = get_le16(pb); // name length
553
    avio_rl64(pb);            // reserved 16 bytes
554
    avio_rl64(pb);            // ...
555
    count = avio_rl32(pb);    // markers count
556
    avio_rl16(pb);            // reserved 2 bytes
557
    name_len = avio_rl16(pb); // name length
558 558
    for(i=0;i<name_len;i++){
559
        get_byte(pb); // skip the name
559
        avio_r8(pb); // skip the name
560 560
    }
561 561

  
562 562
    for(i=0;i<count;i++){
563 563
        int64_t pres_time;
564 564
        int name_len;
565 565

  
566
        get_le64(pb);             // offset, 8 bytes
567
        pres_time = get_le64(pb); // presentation time
568
        get_le16(pb);             // entry length
569
        get_le32(pb);             // send time
570
        get_le32(pb);             // flags
571
        name_len = get_le32(pb);  // name length
566
        avio_rl64(pb);             // offset, 8 bytes
567
        pres_time = avio_rl64(pb); // presentation time
568
        avio_rl16(pb);             // entry length
569
        avio_rl32(pb);             // send time
570
        avio_rl32(pb);             // flags
571
        name_len = avio_rl32(pb);  // name length
572 572
        if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len)
573 573
            url_fskip(pb, name_len - ret);
574 574
        ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name );
......
588 588
    ff_get_guid(pb, &g);
589 589
    if (ff_guidcmp(&g, &ff_asf_header))
590 590
        return -1;
591
    get_le64(pb);
592
    get_le32(pb);
593
    get_byte(pb);
594
    get_byte(pb);
591
    avio_rl64(pb);
592
    avio_rl32(pb);
593
    avio_r8(pb);
594
    avio_r8(pb);
595 595
    memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid));
596 596
    for(;;) {
597 597
        uint64_t gpos= url_ftell(pb);
598 598
        ff_get_guid(pb, &g);
599
        gsize = get_le64(pb);
599
        gsize = avio_rl64(pb);
600 600
        av_dlog(s, "%08"PRIx64": ", gpos);
601 601
        print_guid(&g);
602 602
        av_dlog(s, "  size=0x%"PRIx64"\n", gsize);
......
633 633
        } else if (!ff_guidcmp(&g, &ff_asf_head1_guid)) {
634 634
            int v1, v2;
635 635
            ff_get_guid(pb, &g);
636
            v1 = get_le32(pb);
637
            v2 = get_le16(pb);
636
            v1 = avio_rl32(pb);
637
            v2 = avio_rl16(pb);
638 638
            continue;
639 639
        } else if (!ff_guidcmp(&g, &ff_asf_marker_header)) {
640 640
            asf_read_marker(s, gsize);
......
656 656
        url_fseek(pb, gpos + gsize, SEEK_SET);
657 657
    }
658 658
    ff_get_guid(pb, &g);
659
    get_le64(pb);
660
    get_byte(pb);
661
    get_byte(pb);
659
    avio_rl64(pb);
660
    avio_r8(pb);
661
    avio_r8(pb);
662 662
    if (url_feof(pb))
663 663
        return -1;
664 664
    asf->data_offset = url_ftell(pb);
......
703 703
#define DO_2BITS(bits, var, defval) \
704 704
    switch (bits & 3) \
705 705
    { \
706
    case 3: var = get_le32(pb); rsize += 4; break; \
707
    case 2: var = get_le16(pb); rsize += 2; break; \
708
    case 1: var = get_byte(pb); rsize++; break; \
706
    case 3: var = avio_rl32(pb); rsize += 4; break; \
707
    case 2: var = avio_rl16(pb); rsize += 2; break; \
708
    case 1: var = avio_r8(pb);   rsize++; break; \
709 709
    default: var = defval; break; \
710 710
    }
711 711

  
......
730 730
    c=d=e=-1;
731 731
    while(off-- > 0){
732 732
        c=d; d=e;
733
        e= get_byte(pb);
733
        e= avio_r8(pb);
734 734
        if(c == 0x82 && !d && !e)
735 735
            break;
736 736
    }
......
753 753
                av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
754 754
            return -1;
755 755
        }
756
        c= get_byte(pb);
757
        d= get_byte(pb);
756
        c= avio_r8(pb);
757
        d= avio_r8(pb);
758 758
        rsize+=3;
759 759
    }else{
760 760
        url_fseek(pb, -1, SEEK_CUR); //FIXME
......
777 777
        return -1;
778 778
    }
779 779

  
780
    asf->packet_timestamp = get_le32(pb);
781
    get_le16(pb); /* duration */
780
    asf->packet_timestamp = avio_rl32(pb);
781
    avio_rl16(pb); /* duration */
782 782
    // rsize has at least 11 bytes which have to be present
783 783

  
784 784
    if (asf->packet_flags & 0x01) {
785
        asf->packet_segsizetype = get_byte(pb); rsize++;
785
        asf->packet_segsizetype = avio_r8(pb); rsize++;
786 786
        asf->packet_segments = asf->packet_segsizetype & 0x3f;
787 787
    } else {
788 788
        asf->packet_segments = 1;
......
803 803
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){
804 804
    ASFContext *asf = s->priv_data;
805 805
    int rsize = 1;
806
    int num = get_byte(pb);
806
    int num = avio_r8(pb);
807 807
    int64_t ts0, ts1;
808 808

  
809 809
    asf->packet_segments--;
......
815 815
    DO_2BITS(asf->packet_property, asf->packet_replic_size, 0);
816 816
//printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size);
817 817
    if (asf->packet_replic_size >= 8) {
818
        asf->packet_obj_size = get_le32(pb);
818
        asf->packet_obj_size = avio_rl32(pb);
819 819
        if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){
820 820
            av_log(s, AV_LOG_ERROR, "packet_obj_size invalid\n");
821 821
            return -1;
822 822
        }
823
        asf->packet_frag_timestamp = get_le32(pb); // timestamp
823
        asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
824 824
        if(asf->packet_replic_size >= 8+38+4){
825 825
//            for(i=0; i<asf->packet_replic_size-8; i++)
826
//                av_log(s, AV_LOG_DEBUG, "%02X ",get_byte(pb));
826
//                av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb));
827 827
//            av_log(s, AV_LOG_DEBUG, "\n");
828 828
            url_fskip(pb, 10);
829
            ts0= get_le64(pb);
830
            ts1= get_le64(pb);
829
            ts0= avio_rl64(pb);
830
            ts1= avio_rl64(pb);
831 831
            url_fskip(pb, 12);
832
            get_le32(pb);
832
            avio_rl32(pb);
833 833
            url_fskip(pb, asf->packet_replic_size - 8 - 38 - 4);
834 834
            if(ts0!= -1) asf->packet_frag_timestamp= ts0/10000;
835 835
            else         asf->packet_frag_timestamp= AV_NOPTS_VALUE;
......
842 842
        asf->packet_frag_offset = 0;
843 843
        asf->packet_frag_timestamp = asf->packet_timestamp;
844 844

  
845
        asf->packet_time_delta = get_byte(pb);
845
        asf->packet_time_delta = avio_r8(pb);
846 846
        rsize++;
847 847
    }else if(asf->packet_replic_size!=0){
848 848
        av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size);
......
927 927
            // frag_offset is here used as the beginning timestamp
928 928
            asf->packet_frag_timestamp = asf->packet_time_start;
929 929
            asf->packet_time_start += asf->packet_time_delta;
930
            asf->packet_obj_size = asf->packet_frag_size = get_byte(pb);
930
            asf->packet_obj_size = asf->packet_frag_size = avio_r8(pb);
931 931
            asf->packet_size_left--;
932 932
            asf->packet_multi_size--;
933 933
            if (asf->packet_multi_size < asf->packet_obj_size)
......
987 987
            continue;
988 988
        }
989 989

  
990
        ret = get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset,
990
        ret = avio_read(pb, asf_st->pkt.data + asf->packet_frag_offset,
991 991
                         asf->packet_frag_size);
992 992
        if (ret != asf->packet_frag_size) {
993 993
            if (ret < 0 || asf->packet_frag_offset + ret == 0)
......
1193 1193
    /* the data object can be followed by other top-level objects,
1194 1194
       skip them until the simple index object is reached */
1195 1195
    while (ff_guidcmp(&g, &index_guid)) {
1196
        int64_t gsize= get_le64(s->pb);
1196
        int64_t gsize= avio_rl64(s->pb);
1197 1197
        if (gsize < 24 || url_feof(s->pb)) {
1198 1198
            url_fseek(s->pb, current_pos, SEEK_SET);
1199 1199
            return;
......
1205 1205
    {
1206 1206
        int64_t itime, last_pos=-1;
1207 1207
        int pct, ict;
1208
        int64_t av_unused gsize= get_le64(s->pb);
1208
        int64_t av_unused gsize= avio_rl64(s->pb);
1209 1209
        ff_get_guid(s->pb, &g);
1210
        itime=get_le64(s->pb);
1211
        pct=get_le32(s->pb);
1212
        ict=get_le32(s->pb);
1210
        itime=avio_rl64(s->pb);
1211
        pct=avio_rl32(s->pb);
1212
        ict=avio_rl32(s->pb);
1213 1213
        av_log(s, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict);
1214 1214

  
1215 1215
        for (i=0;i<ict;i++){
1216
            int pktnum=get_le32(s->pb);
1217
            int pktct =get_le16(s->pb);
1216
            int pktnum=avio_rl32(s->pb);
1217
            int pktct =avio_rl16(s->pb);
1218 1218
            int64_t pos      = s->data_offset + s->packet_size*(int64_t)pktnum;
1219 1219
            int64_t index_pts= av_rescale(itime, i, 10000);
1220 1220

  
libavformat/au.c
127 127
    AVStream *st;
128 128

  
129 129
    /* check ".snd" header */
130
    tag = get_le32(pb);
130
    tag = avio_rl32(pb);
131 131
    if (tag != MKTAG('.', 's', 'n', 'd'))
132 132
        return -1;
133
    size = get_be32(pb); /* header size */
134
    get_be32(pb); /* data size */
133
    size = avio_rb32(pb); /* header size */
134
    avio_rb32(pb); /* data size */
135 135

  
136
    id = get_be32(pb);
137
    rate = get_be32(pb);
138
    channels = get_be32(pb);
136
    id = avio_rb32(pb);
137
    rate = avio_rb32(pb);
138
    channels = avio_rb32(pb);
139 139

  
140 140
    codec = ff_codec_get_id(codec_au_tags, id);
141 141

  
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,
libavformat/avio.h
378 378
                  int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
379 379
                  int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
380 380
                  int64_t (*seek)(void *opaque, int64_t offset, int whence));
381

  
382
/**
383
 * @defgroup old_avio_funcs Old put_/get_*() functions
384
 * @deprecated use the avio_ -prefixed functions instead.
385
 * @{
386
 */
387
attribute_deprecated int          get_buffer(AVIOContext *s, unsigned char *buf, int size);
388
attribute_deprecated int          get_byte(AVIOContext *s);
389
attribute_deprecated unsigned int get_le16(AVIOContext *s);
390
attribute_deprecated unsigned int get_le24(AVIOContext *s);
391
attribute_deprecated unsigned int get_le32(AVIOContext *s);
392
attribute_deprecated uint64_t     get_le64(AVIOContext *s);
393
attribute_deprecated unsigned int get_be16(AVIOContext *s);
394
attribute_deprecated unsigned int get_be24(AVIOContext *s);
395
attribute_deprecated unsigned int get_be32(AVIOContext *s);
396
attribute_deprecated uint64_t     get_be64(AVIOContext *s);
397
/**
398
 * @}
399
 */
381 400
#endif
382 401

  
383 402
AVIOContext *avio_alloc_context(
......
477 496
 * Read size bytes from AVIOContext into buf.
478 497
 * @return number of bytes read or AVERROR
479 498
 */
480
int get_buffer(AVIOContext *s, unsigned char *buf, int size);
499
int avio_read(AVIOContext *s, unsigned char *buf, int size);
481 500

  
482 501
/**
483 502
 * Read size bytes from AVIOContext into buf.
......
489 508

  
490 509
/** @note return 0 if EOF, so you cannot use it if EOF handling is
491 510
    necessary */
492
int get_byte(AVIOContext *s);
493
unsigned int get_le24(AVIOContext *s);
494
unsigned int get_le32(AVIOContext *s);
495
uint64_t get_le64(AVIOContext *s);
496
unsigned int get_le16(AVIOContext *s);
511
int          avio_r8  (AVIOContext *s);
512
unsigned int avio_rl16(AVIOContext *s);
513
unsigned int avio_rl24(AVIOContext *s);
514
unsigned int avio_rl32(AVIOContext *s);
515
uint64_t     avio_rl64(AVIOContext *s);
497 516

  
498 517
/**
499 518
 * Read a UTF-16 string from pb and convert it to UTF-8.
......
505 524
int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
506 525

  
507 526
char *get_strz(AVIOContext *s, char *buf, int maxlen);
508
unsigned int get_be16(AVIOContext *s);
509
unsigned int get_be24(AVIOContext *s);
510
unsigned int get_be32(AVIOContext *s);
511
uint64_t get_be64(AVIOContext *s);
527
unsigned int avio_rb16(AVIOContext *s);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff