comparison matroska.c @ 824:779b1e87b865 libavformat

more non portable float parsing code ...
author michael
date Tue, 19 Jul 2005 15:32:43 +0000
parents feca73904e67
children 91dcb9da9be6
comparison
equal deleted inserted replaced
823:e8b4454b997d 824:779b1e87b865
607 if ((res = ebml_read_element_id(matroska, id, NULL)) < 0 || 607 if ((res = ebml_read_element_id(matroska, id, NULL)) < 0 ||
608 (res = ebml_read_element_length(matroska, &rlength)) < 0) 608 (res = ebml_read_element_length(matroska, &rlength)) < 0)
609 return res; 609 return res;
610 size = rlength; 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 offset_t pos = url_ftell(pb); 621 offset_t pos = url_ftell(pb);
614 av_log(matroska->ctx, AV_LOG_ERROR, 622 av_log(matroska->ctx, AV_LOG_ERROR,
615 "Invalid float element size %d at position %llu (0x%llx)\n", 623 "Invalid float element size %d at position %llu (0x%llx)\n",
616 size, pos, pos); 624 size, pos, pos);
617 return AVERROR_INVALIDDATA; 625 return AVERROR_INVALIDDATA;
618 }
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 } 626 }
648 627
649 return 0; 628 return 0;
650 } 629 }
651 630