Revision 8baa6614

View differences:

libavformat/4xm.c
75 75
    float fps;
76 76
} FourxmDemuxContext;
77 77

  
78
static float get_le_float(unsigned char *buffer)
79
{
80
    float f;
81
    unsigned char *float_buffer = (unsigned char *)&f;
82

  
83
#ifdef WORDS_BIGENDIAN
84
    float_buffer[0] = buffer[3];
85
    float_buffer[1] = buffer[2];
86
    float_buffer[2] = buffer[1];
87
    float_buffer[3] = buffer[0];
88
#else
89
    float_buffer[0] = buffer[0];
90
    float_buffer[1] = buffer[1];
91
    float_buffer[2] = buffer[2];
92
    float_buffer[3] = buffer[3];
93
#endif
94

  
95
    return f;
96
}
97

  
98 78
static int fourxm_probe(AVProbeData *p)
99 79
{
100 80
    if (p->buf_size < 12)
......
147 127
        size = LE_32(&header[i + 4]);
148 128

  
149 129
        if (fourcc_tag == std__TAG) {
150
            fourxm->fps = get_le_float(&header[i + 12]);
130
            fourxm->fps = av_int2flt(LE_32(&header[i + 12]));
151 131
        } else if (fourcc_tag == vtrk_TAG) {
152 132
            /* check that there is enough data */
153 133
            if (size != vtrk_SIZE) {
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