Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 83e5dd93 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Working state

parent 0e0a0f32
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!100Resolve "Kara length"
Ce commit fait partie de la requête de fusion !100. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
......@@ -33,8 +33,12 @@ uint32_t be_uint32_t(const uint8_t bytes[], size_t n);
uint64_t be_uint64_t(const uint8_t bytes[], size_t n);
/* Same as `be_uint64_t` but for Big-endian doubles.
Restriction: n <= 8 */
double be_double_t(const uint8_t bytes[], size_t n);
Restriction: bytes must be of length 8. */
double be_double_t(const uint8_t bytes[]);
/* Same as `be_double_t` but for floats. Restriction: bytes must
be of length 4. */
float be_float_t(const uint8_t bytes[]);
/* Trim the string `str` of the char `c` from the right and the left.
The string may not be null terminated.
......
......@@ -33,16 +33,15 @@ be_uint32_t(const uint8_t bytes[], size_t n)
return res;
}
double
be_double_t(const uint8_t bytes[], size_t n)
float
be_float_t(const uint8_t bytes[])
{
union {
uint8_t _bytes[8];
double _double;
} res;
for (size_t i = 0; i < n; ++i)
res._bytes[i] = bytes[n - i - 1] & 0xff;
return res._double;
uint32_t _uint;
float _float;
} ret;
ret._uint = be_uint32_t(bytes, 4);
return ret._float;
}
uint64_t
......@@ -54,6 +53,17 @@ be_uint64_t(const uint8_t bytes[], size_t n)
return res;
}
double
be_double_t(const uint8_t bytes[])
{
union {
uint64_t _uint;
double _double;
} ret;
ret._uint = be_uint64_t(bytes, 8);
return ret._double;
}
char *
trim(char *str, size_t len, char c)
{
......
......@@ -150,7 +150,12 @@ mkv_read_float(struct bufferfd *bf, double *res)
if (bufferfd_bytes(bf, data_len, data) < 0)
return -1;
*res = be_double_t(data, data_len);
if (data_len == 8)
*res = be_double_t(data);
else if (data_len == 4)
*res = (double) be_float_t(data);
else
return -1;
}
return n + (ssize_t) data_len;
......@@ -545,6 +550,7 @@ kara_read_segment_info(struct bufferfd *bf, double *len)
if (eid == EBML_MKV_SEG_DURATION) {
if ((n = mkv_read_float(bf, len)) < 0)
return -1;
printf("%ld\n", n);
}
else if (eid == EBML_MKV_SEG_TS_SCALE) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter