comparison matroskadec.c @ 6461:c12416642843 libavformat

matroskadec: allow uint and float elements with length = 0
author aurel
date Sun, 05 Sep 2010 21:37:40 +0000
parents 9ba950e0e021
children 4f3cb203b378
comparison
equal deleted inserted replaced
6460:e29a553aa1fc 6461:c12416642843
581 */ 581 */
582 static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num) 582 static int ebml_read_uint(ByteIOContext *pb, int size, uint64_t *num)
583 { 583 {
584 int n = 0; 584 int n = 0;
585 585
586 if (size < 1 || size > 8) 586 if (size > 8)
587 return AVERROR_INVALIDDATA; 587 return AVERROR_INVALIDDATA;
588 588
589 /* big-endian ordering; build up number */ 589 /* big-endian ordering; build up number */
590 *num = 0; 590 *num = 0;
591 while (n++ < size) 591 while (n++ < size)
598 * Read the next element as a float. 598 * Read the next element as a float.
599 * 0 is success, < 0 is failure. 599 * 0 is success, < 0 is failure.
600 */ 600 */
601 static int ebml_read_float(ByteIOContext *pb, int size, double *num) 601 static int ebml_read_float(ByteIOContext *pb, int size, double *num)
602 { 602 {
603 if (size == 4) { 603 if (size == 0) {
604 *num = 0;
605 } else if (size == 4) {
604 *num= av_int2flt(get_be32(pb)); 606 *num= av_int2flt(get_be32(pb));
605 } else if(size==8){ 607 } else if(size==8){
606 *num= av_int2dbl(get_be64(pb)); 608 *num= av_int2dbl(get_be64(pb));
607 } else 609 } else
608 return AVERROR_INVALIDDATA; 610 return AVERROR_INVALIDDATA;