Revision b7effd4e libavformat/mpeg.c

View differences:

libavformat/mpeg.c
113 113

  
114 114
    m->sofdec = -1;
115 115
    do {
116
        v = get_byte(s->pb);
116
        v = avio_r8(s->pb);
117 117
        m->header_state = m->header_state << 8 | v;
118 118
        m->sofdec++;
119 119
    } while (v == sofdec[i] && i++ < 6);
......
128 128
{
129 129
    uint8_t buf[5];
130 130

  
131
    buf[0] = c<0 ? get_byte(pb) : c;
132
    get_buffer(pb, buf+1, 4);
131
    buf[0] = c<0 ? avio_r8(pb) : c;
132
    avio_read(pb, buf+1, 4);
133 133

  
134 134
    return ff_parse_pes_pts(buf);
135 135
}
......
145 145
    while (n > 0) {
146 146
        if (url_feof(pb))
147 147
            break;
148
        v = get_byte(pb);
148
        v = avio_r8(pb);
149 149
        n--;
150 150
        if (state == 0x000001) {
151 151
            state = ((state << 8) | v) & 0xffffff;
......
176 176
    if (pos < 0)
177 177
        pos = 0;
178 178
    url_fseek(pb, pos, SEEK_SET);
179
    get_byte(pb);
179
    avio_r8(pb);
180 180

  
181 181
    pos = pos_start;
182 182
    for(;;) {
......
186 186
            goto the_end;
187 187
        }
188 188
        url_fseek(pb, pos, SEEK_SET);
189
        start_code = get_be32(pb);
189
        start_code = avio_rb32(pb);
190 190
        if ((start_code & 0xffffff00) == 0x100)
191 191
            break;
192 192
    }
......
206 206
{
207 207
    int psm_length, ps_info_length, es_map_length;
208 208

  
209
    psm_length = get_be16(pb);
210
    get_byte(pb);
211
    get_byte(pb);
212
    ps_info_length = get_be16(pb);
209
    psm_length = avio_rb16(pb);
210
    avio_r8(pb);
211
    avio_r8(pb);
212
    ps_info_length = avio_rb16(pb);
213 213

  
214 214
    /* skip program_stream_info */
215 215
    url_fskip(pb, ps_info_length);
216
    es_map_length = get_be16(pb);
216
    es_map_length = avio_rb16(pb);
217 217

  
218 218
    /* at least one es available? */
219 219
    while (es_map_length >= 4){
220
        unsigned char type      = get_byte(pb);
221
        unsigned char es_id     = get_byte(pb);
222
        uint16_t es_info_length = get_be16(pb);
220
        unsigned char type      = avio_r8(pb);
221
        unsigned char es_id     = avio_r8(pb);
222
        uint16_t es_info_length = avio_rb16(pb);
223 223
        /* remember mapping from stream id to stream type */
224 224
        m->psm_es_type[es_id] = type;
225 225
        /* skip program_stream_info */
226 226
        url_fskip(pb, es_info_length);
227 227
        es_map_length -= 4 + es_info_length;
228 228
    }
229
    get_be32(pb); /* crc32 */
229
    avio_rb32(pb); /* crc32 */
230 230
    return 2 + psm_length;
231 231
}
232 232

  
......
264 264
    if (startcode == SYSTEM_HEADER_START_CODE)
265 265
        goto redo;
266 266
    if (startcode == PADDING_STREAM) {
267
        url_fskip(s->pb, get_be16(s->pb));
267
        url_fskip(s->pb, avio_rb16(s->pb));
268 268
        goto redo;
269 269
    }
270 270
    if (startcode == PRIVATE_STREAM_2) {
271
        len = get_be16(s->pb);
271
        len = avio_rb16(s->pb);
272 272
        if (!m->sofdec) {
273 273
            while (len-- >= 6) {
274
                if (get_byte(s->pb) == 'S') {
274
                if (avio_r8(s->pb) == 'S') {
275 275
                    uint8_t buf[5];
276
                    get_buffer(s->pb, buf, sizeof(buf));
276
                    avio_read(s->pb, buf, sizeof(buf));
277 277
                    m->sofdec = !memcmp(buf, "ofdec", 5);
278 278
                    len -= sizeof(buf);
279 279
                    break;
......
297 297
    if (ppos) {
298 298
        *ppos = url_ftell(s->pb) - 4;
299 299
    }
300
    len = get_be16(s->pb);
300
    len = avio_rb16(s->pb);
301 301
    pts =
302 302
    dts = AV_NOPTS_VALUE;
303 303
    /* stuffing */
304 304
    for(;;) {
305 305
        if (len < 1)
306 306
            goto error_redo;
307
        c = get_byte(s->pb);
307
        c = avio_r8(s->pb);
308 308
        len--;
309 309
        /* XXX: for mpeg1, should test only bit 7 */
310 310
        if (c != 0xff)
......
312 312
    }
313 313
    if ((c & 0xc0) == 0x40) {
314 314
        /* buffer scale & size */
315
        get_byte(s->pb);
316
        c = get_byte(s->pb);
315
        avio_r8(s->pb);
316
        c = avio_r8(s->pb);
317 317
        len -= 2;
318 318
    }
319 319
    if ((c & 0xe0) == 0x20) {
......
331 331
            goto redo;
332 332
        }
333 333
#endif
334
        flags = get_byte(s->pb);
335
        header_len = get_byte(s->pb);
334
        flags = avio_r8(s->pb);
335
        header_len = avio_r8(s->pb);
336 336
        len -= 2;
337 337
        if (header_len > len)
338 338
            goto error_redo;
......
350 350
            av_log(s, AV_LOG_WARNING, "Further flags set but no bytes left\n");
351 351
        }
352 352
        if (flags & 0x01) { /* PES extension */
353
            pes_ext = get_byte(s->pb);
353
            pes_ext = avio_r8(s->pb);
354 354
            header_len--;
355 355
            /* Skip PES private data, program packet sequence counter and P-STD buffer */
356 356
            skip = (pes_ext >> 4) & 0xb;
......
363 363
            header_len -= skip;
364 364

  
365 365
            if (pes_ext & 0x01) { /* PES extension 2 */
366
                ext2_len = get_byte(s->pb);
366
                ext2_len = avio_r8(s->pb);
367 367
                header_len--;
368 368
                if ((ext2_len & 0x7f) > 0) {
369
                    id_ext = get_byte(s->pb);
369
                    id_ext = avio_r8(s->pb);
370 370
                    if ((id_ext & 0x80) == 0)
371 371
                        startcode = ((startcode & 0xff) << 8) | id_ext;
372 372
                    header_len--;
......
381 381
        goto redo;
382 382

  
383 383
    if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
384
        startcode = get_byte(s->pb);
384
        startcode = avio_r8(s->pb);
385 385
        len--;
386 386
        if (startcode >= 0x80 && startcode <= 0xcf) {
387 387
            /* audio: skip header */
388
            get_byte(s->pb);
389
            get_byte(s->pb);
390
            get_byte(s->pb);
388
            avio_r8(s->pb);
389
            avio_r8(s->pb);
390
            avio_r8(s->pb);
391 391
            len -= 3;
392 392
            if (startcode >= 0xb0 && startcode <= 0xbf) {
393 393
                /* MLP/TrueHD audio has a 4-byte header */
394
                get_byte(s->pb);
394
                avio_r8(s->pb);
395 395
                len--;
396 396
            }
397 397
        }
......
432 432
        return len;
433 433

  
434 434
    if(startcode == 0x1bd) {
435
        dvdaudio_substream_type = get_byte(s->pb);
435
        dvdaudio_substream_type = avio_r8(s->pb);
436 436
        url_fskip(s->pb, 3);
437 437
        len -= 4;
438 438
    }
......
474 474
    } else if (startcode >= 0x1e0 && startcode <= 0x1ef) {
475 475
        static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 };
476 476
        unsigned char buf[8];
477
        get_buffer(s->pb, buf, 8);
477
        avio_read(s->pb, buf, 8);
478 478
        url_fseek(s->pb, -8, SEEK_CUR);
479 479
        if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1))
480 480
            codec_id = CODEC_ID_CAVS;
......
547 547
           audio data */
548 548
        if (len <= 3)
549 549
            goto skip;
550
        get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
551
        b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
552
        get_byte(s->pb); /* dynamic range control (0x80 = off) */
550
        avio_r8(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */
551
        b1 = avio_r8(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */
552
        avio_r8(s->pb); /* dynamic range control (0x80 = off) */
553 553
        len -= 3;
554 554
        freq = (b1 >> 4) & 3;
555 555
        st->codec->sample_rate = lpcm_freq_tab[freq];
......
564 564
            return AVERROR(EINVAL);
565 565
    }
566 566
    av_new_packet(pkt, len);
567
    get_buffer(s->pb, pkt->data, pkt->size);
567
    avio_read(s->pb, pkt->data, pkt->size);
568 568
    pkt->pts = pts;
569 569
    pkt->dts = dts;
570 570
    pkt->pos = dummy_pos;

Also available in: Unified diff