Revision 8baa6614 libavformat/matroska.c

View differences:

libavformat/matroska.c
609 609
        return res;
610 610
    size = rlength;
611 611

  
612
    if (size != 4 && size != 8 && size != 10) {
612
    if (size == 4) {
613
        *num= av_int2flt(get_be32(pb));
614
    } else if(size==8){
615
        *num= av_int2dbl(get_be64(pb));
616
    } else if(size==10){
617
        av_log(matroska->ctx, AV_LOG_ERROR,
618
               "FIXME! 10-byte floats unimplemented\n");
619
        return AVERROR_UNKNOWN;
620
    } else{
613 621
        offset_t pos = url_ftell(pb);
614 622
        av_log(matroska->ctx, AV_LOG_ERROR,
615 623
               "Invalid float element size %d at position %llu (0x%llx)\n",
616 624
               size, pos, pos);
617 625
        return AVERROR_INVALIDDATA;
618 626
    }
619
    if (size == 10) {
620
        av_log(matroska->ctx, AV_LOG_ERROR,
621
               "FIXME! 10-byte floats unimplemented\n");
622
        return AVERROR_UNKNOWN;
623
    }
624

  
625
    if (size == 4) {
626
        float f;
627

  
628
        while (size-- > 0)
629
#ifdef WORDS_BIGENDIAN
630
            ((uint8_t *) &f)[3 - size] = get_byte(pb);
631
#else
632
            ((uint8_t *) &f)[size] = get_byte(pb);
633
#endif
634

  
635
        *num = f;
636
    } else {
637
        double d;
638

  
639
        while (size-- > 0)
640
#ifdef WORDS_BIGENDIAN
641
            ((uint8_t *) &d)[7 - size] = get_byte(pb);
642
#else
643
            ((uint8_t *) &d)[size] = get_byte(pb);
644
#endif
645

  
646
        *num = d;
647
    }
648 627

  
649 628
    return 0;
650 629
}

Also available in: Unified diff