Revision b7effd4e libavformat/gxf.c

View differences:

libavformat/gxf.c
39 39
 * \return 0 if header not found or contains invalid data, 1 otherwise
40 40
 */
41 41
static int parse_packet_header(AVIOContext *pb, GXFPktType *type, int *length) {
42
    if (get_be32(pb))
42
    if (avio_rb32(pb))
43 43
        return 0;
44
    if (get_byte(pb) != 1)
44
    if (avio_r8(pb) != 1)
45 45
        return 0;
46
    *type = get_byte(pb);
47
    *length = get_be32(pb);
46
    *type = avio_r8(pb);
47
    *length = avio_rb32(pb);
48 48
    if ((*length >> 24) || *length < 16)
49 49
        return 0;
50 50
    *length -= 16;
51
    if (get_be32(pb))
51
    if (avio_rb32(pb))
52 52
        return 0;
53
    if (get_byte(pb) != 0xe1)
53
    if (avio_r8(pb) != 0xe1)
54 54
        return 0;
55
    if (get_byte(pb) != 0xe2)
55
    if (avio_r8(pb) != 0xe2)
56 56
        return 0;
57 57
    return 1;
58 58
}
......
161 161
    si->first_field = AV_NOPTS_VALUE;
162 162
    si->last_field = AV_NOPTS_VALUE;
163 163
    while (*len >= 2) {
164
        GXFMatTag tag = get_byte(pb);
165
        int tlen = get_byte(pb);
164
        GXFMatTag tag = avio_r8(pb);
165
        int tlen = avio_r8(pb);
166 166
        *len -= 2;
167 167
        if (tlen > *len)
168 168
            return;
169 169
        *len -= tlen;
170 170
        if (tlen == 4) {
171
            uint32_t value = get_be32(pb);
171
            uint32_t value = avio_rb32(pb);
172 172
            if (tag == MAT_FIRST_FIELD)
173 173
                si->first_field = value;
174 174
            else if (tag == MAT_LAST_FIELD)
......
210 210
    si->frames_per_second = (AVRational){0, 0};
211 211
    si->fields_per_frame = 0;
212 212
    while (*len >= 2) {
213
        GXFTrackTag tag = get_byte(pb);
214
        int tlen = get_byte(pb);
213
        GXFTrackTag tag = avio_r8(pb);
214
        int tlen = avio_r8(pb);
215 215
        *len -= 2;
216 216
        if (tlen > *len)
217 217
            return;
218 218
        *len -= tlen;
219 219
        if (tlen == 4) {
220
            uint32_t value = get_be32(pb);
220
            uint32_t value = avio_rb32(pb);
221 221
            if (tag == TRACK_FPS)
222 222
                si->frames_per_second = fps_tag2avr(value);
223 223
            else if (tag == TRACK_FPF && (value == 1 || value == 2))
......
233 233
static void gxf_read_index(AVFormatContext *s, int pkt_len) {
234 234
    AVIOContext *pb = s->pb;
235 235
    AVStream *st = s->streams[0];
236
    uint32_t fields_per_map = get_le32(pb);
237
    uint32_t map_cnt = get_le32(pb);
236
    uint32_t fields_per_map = avio_rl32(pb);
237
    uint32_t map_cnt = avio_rl32(pb);
238 238
    int i;
239 239
    pkt_len -= 8;
240 240
    if (s->flags & AVFMT_FLAG_IGNIDX) {
......
253 253
    pkt_len -= 4 * map_cnt;
254 254
    av_add_index_entry(st, 0, 0, 0, 0, 0);
255 255
    for (i = 0; i < map_cnt; i++)
256
        av_add_index_entry(st, (uint64_t)get_le32(pb) * 1024,
256
        av_add_index_entry(st, (uint64_t)avio_rl32(pb) * 1024,
257 257
                           i * (uint64_t)fields_per_map + 1, 0, 0, 0);
258 258
    url_fskip(pb, pkt_len);
259 259
}
......
271 271
        return 0;
272 272
    }
273 273
    map_len -= 2;
274
    if (get_byte(pb) != 0x0e0 || get_byte(pb) != 0xff) {
274
    if (avio_r8(pb) != 0x0e0 || avio_r8(pb) != 0xff) {
275 275
        av_log(s, AV_LOG_ERROR, "unknown version or invalid map preamble\n");
276 276
        return 0;
277 277
    }
278 278
    map_len -= 2;
279
    len = get_be16(pb); // length of material data section
279
    len = avio_rb16(pb); // length of material data section
280 280
    if (len > map_len) {
281 281
        av_log(s, AV_LOG_ERROR, "material data longer than map data\n");
282 282
        return 0;
......
285 285
    gxf_material_tags(pb, &len, &si);
286 286
    url_fskip(pb, len);
287 287
    map_len -= 2;
288
    len = get_be16(pb); // length of track description
288
    len = avio_rb16(pb); // length of track description
289 289
    if (len > map_len) {
290 290
        av_log(s, AV_LOG_ERROR, "track description longer than map data\n");
291 291
        return 0;
......
296 296
        AVStream *st;
297 297
        int idx;
298 298
        len -= 4;
299
        track_type = get_byte(pb);
300
        track_id = get_byte(pb);
301
        track_len = get_be16(pb);
299
        track_type = avio_r8(pb);
300
        track_id = avio_r8(pb);
301
        track_len = avio_rb16(pb);
302 302
        len -= track_len;
303 303
        gxf_track_tags(pb, &track_len, &si);
304 304
        url_fskip(pb, track_len);
......
344 344
            len -= 0x39;
345 345
            url_fskip(pb, 5); // preamble
346 346
            url_fskip(pb, 0x30); // payload description
347
            fps = fps_umf2avr(get_le32(pb));
347
            fps = fps_umf2avr(avio_rl32(pb));
348 348
            if (!main_timebase.num || !main_timebase.den) {
349 349
                // this may not always be correct, but simply the best we can get
350 350
                main_timebase.num = fps.den;
......
370 370
    { \
371 371
        if (!max_interval-- || url_feof(pb)) \
372 372
            goto out; \
373
        tmp = tmp << 8 | get_byte(pb); \
373
        tmp = tmp << 8 | avio_r8(pb); \
374 374
    }
375 375

  
376 376
/**
......
389 389
    int len;
390 390
    AVIOContext *pb = s->pb;
391 391
    GXFPktType type;
392
    tmp = get_be32(pb);
392
    tmp = avio_rb32(pb);
393 393
start:
394 394
    while (tmp)
395 395
        READ_ONE();
......
404 404
            goto out;
405 405
        goto start;
406 406
    }
407
    get_byte(pb);
408
    cur_track = get_byte(pb);
409
    cur_timestamp = get_be32(pb);
407
    avio_r8(pb);
408
    cur_track = avio_r8(pb);
409
    cur_timestamp = avio_rb32(pb);
410 410
    last_found_pos = url_ftell(pb) - 16 - 6;
411 411
    if ((track >= 0 && track != cur_track) || (timestamp >= 0 && timestamp > cur_timestamp)) {
412 412
        if (url_fseek(pb, last_pos, SEEK_SET) >= 0)
......
445 445
            continue;
446 446
        }
447 447
        pkt_len -= 16;
448
        track_type = get_byte(pb);
449
        track_id = get_byte(pb);
448
        track_type = avio_r8(pb);
449
        track_id = avio_r8(pb);
450 450
        stream_index = get_sindex(s, track_id, track_type);
451 451
        if (stream_index < 0)
452 452
            return stream_index;
453 453
        st = s->streams[stream_index];
454
        field_nr = get_be32(pb);
455
        field_info = get_be32(pb);
456
        get_be32(pb); // "timeline" field number
457
        get_byte(pb); // flags
458
        get_byte(pb); // reserved
454
        field_nr = avio_rb32(pb);
455
        field_info = avio_rb32(pb);
456
        avio_rb32(pb); // "timeline" field number
457
        avio_r8(pb); // flags
458
        avio_r8(pb); // reserved
459 459
        if (st->codec->codec_id == CODEC_ID_PCM_S24LE ||
460 460
            st->codec->codec_id == CODEC_ID_PCM_S16LE) {
461 461
            int first = field_info >> 16;

Also available in: Unified diff