Revision b7effd4e libavformat/aviobuf.c

View differences:

libavformat/aviobuf.c
298 298
{
299 299
    avio_put_str(s, str);
300 300
}
301

  
302
#define GET(name, type) \
303
    type get_be ##name(AVIOContext *s) \
304
{\
305
    return avio_rb ##name(s);\
306
}\
307
    type get_le ##name(AVIOContext *s) \
308
{\
309
    return avio_rl ##name(s);\
310
}
311

  
312
GET(16, unsigned int)
313
GET(24, unsigned int)
314
GET(32, unsigned int)
315
GET(64, uint64_t)
316

  
317
#undef GET
318

  
319
int get_byte(AVIOContext *s)
320
{
321
   return avio_r8(s);
322
}
323
int get_buffer(AVIOContext *s, unsigned char *buf, int size)
324
{
325
    return avio_read(s, buf, size);
326
}
301 327
#endif
302 328

  
303 329
int avio_put_str(AVIOContext *s, const char *str)
......
457 483
}
458 484

  
459 485
/* XXX: put an inline version */
460
int get_byte(AVIOContext *s)
486
int avio_r8(AVIOContext *s)
461 487
{
462 488
    if (s->buf_ptr >= s->buf_end)
463 489
        fill_buffer(s);
......
475 501
    return URL_EOF;
476 502
}
477 503

  
478
int get_buffer(AVIOContext *s, unsigned char *buf, int size)
504
int avio_read(AVIOContext *s, unsigned char *buf, int size)
479 505
{
480 506
    int len, size1;
481 507

  
......
545 571
    return len;
546 572
}
547 573

  
548
unsigned int get_le16(AVIOContext *s)
574
unsigned int avio_rl16(AVIOContext *s)
549 575
{
550 576
    unsigned int val;
551
    val = get_byte(s);
552
    val |= get_byte(s) << 8;
577
    val = avio_r8(s);
578
    val |= avio_r8(s) << 8;
553 579
    return val;
554 580
}
555 581

  
556
unsigned int get_le24(AVIOContext *s)
582
unsigned int avio_rl24(AVIOContext *s)
557 583
{
558 584
    unsigned int val;
559
    val = get_le16(s);
560
    val |= get_byte(s) << 16;
585
    val = avio_rl16(s);
586
    val |= avio_r8(s) << 16;
561 587
    return val;
562 588
}
563 589

  
564
unsigned int get_le32(AVIOContext *s)
590
unsigned int avio_rl32(AVIOContext *s)
565 591
{
566 592
    unsigned int val;
567
    val = get_le16(s);
568
    val |= get_le16(s) << 16;
593
    val = avio_rl16(s);
594
    val |= avio_rl16(s) << 16;
569 595
    return val;
570 596
}
571 597

  
572
uint64_t get_le64(AVIOContext *s)
598
uint64_t avio_rl64(AVIOContext *s)
573 599
{
574 600
    uint64_t val;
575
    val = (uint64_t)get_le32(s);
576
    val |= (uint64_t)get_le32(s) << 32;
601
    val = (uint64_t)avio_rl32(s);
602
    val |= (uint64_t)avio_rl32(s) << 32;
577 603
    return val;
578 604
}
579 605

  
580
unsigned int get_be16(AVIOContext *s)
606
unsigned int avio_rb16(AVIOContext *s)
581 607
{
582 608
    unsigned int val;
583
    val = get_byte(s) << 8;
584
    val |= get_byte(s);
609
    val = avio_r8(s) << 8;
610
    val |= avio_r8(s);
585 611
    return val;
586 612
}
587 613

  
588
unsigned int get_be24(AVIOContext *s)
614
unsigned int avio_rb24(AVIOContext *s)
589 615
{
590 616
    unsigned int val;
591
    val = get_be16(s) << 8;
592
    val |= get_byte(s);
617
    val = avio_rb16(s) << 8;
618
    val |= avio_r8(s);
593 619
    return val;
594 620
}
595
unsigned int get_be32(AVIOContext *s)
621
unsigned int avio_rb32(AVIOContext *s)
596 622
{
597 623
    unsigned int val;
598
    val = get_be16(s) << 16;
599
    val |= get_be16(s);
624
    val = avio_rb16(s) << 16;
625
    val |= avio_rb16(s);
600 626
    return val;
601 627
}
602 628

  
......
605 631
    int i = 0;
606 632
    char c;
607 633

  
608
    while ((c = get_byte(s))) {
634
    while ((c = avio_r8(s))) {
609 635
        if (i < maxlen-1)
610 636
            buf[i++] = c;
611 637
    }
......
621 647
    char c;
622 648

  
623 649
    do {
624
        c = get_byte(s);
650
        c = avio_r8(s);
625 651
        if (c && i < maxlen-1)
626 652
            buf[i++] = c;
627 653
    } while (c != '\n' && c);
......
647 673
    return ret;\
648 674
}\
649 675

  
650
GET_STR16(le, get_le16)
651
GET_STR16(be, get_be16)
676
GET_STR16(le, avio_rl16)
677
GET_STR16(be, avio_rb16)
652 678

  
653 679
#undef GET_STR16
654 680

  
655
uint64_t get_be64(AVIOContext *s)
681
uint64_t avio_rb64(AVIOContext *s)
656 682
{
657 683
    uint64_t val;
658
    val = (uint64_t)get_be32(s) << 32;
659
    val |= (uint64_t)get_be32(s);
684
    val = (uint64_t)avio_rb32(s) << 32;
685
    val |= (uint64_t)avio_rb32(s);
660 686
    return val;
661 687
}
662 688

  
......
665 691
    int tmp;
666 692

  
667 693
    do{
668
        tmp = get_byte(bc);
694
        tmp = avio_r8(bc);
669 695
        val= (val<<7) + (tmp&127);
670 696
    }while(tmp&128);
671 697
    return val;

Also available in: Unified diff