]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - aac_afh.c
server: Convert com_mvatt() to lopsub.
[paraslash.git] / aac_afh.c
index e94f5b421f848c02eca86a5061fa46878b07e587..1c7fd706f0a7c9fe8c9d4d8db43846be18a9304d 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -15,6 +15,7 @@
 
 #include "para.h"
 #include "error.h"
+#include "portable_io.h"
 #include "afh.h"
 #include "string.h"
 #include "aac.h"
@@ -32,12 +33,12 @@ static int aac_find_stsz(char *buf, size_t buflen, off_t *skip)
                        continue;
                PARA_DEBUG_LOG("found stsz@%d\n", i);
                i += 8;
-               sample_size = aac_read_int32(buf + i);
-               PARA_DEBUG_LOG("sample size: %d\n", sample_size);
+               sample_size = read_u32_be(buf + i);
+               PARA_DEBUG_LOG("sample size: %u\n", sample_size);
                i += 4;
-               sample_count = aac_read_int32(buf + i);
+               sample_count = read_u32_be(buf + i);
                i += 4;
-               PARA_DEBUG_LOG("sample count: %d\n", sample_count);
+               PARA_DEBUG_LOG("sample count: %u\n", sample_count);
                *skip = i;
                return sample_count;
        }
@@ -51,8 +52,7 @@ static int atom_cmp(const char *buf1, const char *buf2)
 
 static int read_atom_header(char *buf, uint64_t *subsize, char type[5])
 {
-       int i;
-       uint64_t size = aac_read_int32(buf);
+       uint64_t size = read_u32_be(buf);
 
        memcpy(type, buf + 4, 4);
        type[4] = '\0';
@@ -64,8 +64,7 @@ static int read_atom_header(char *buf, uint64_t *subsize, char type[5])
        }
        buf += 4;
        size = 0;
-       for (i = 0; i < 8; i++)
-               size |= ((uint64_t)buf[i]) << ((7 - i) * 8);
+       size = read_u64_be(buf);
        *subsize = size;
        return 16;
 }
@@ -168,7 +167,7 @@ static ssize_t aac_compute_chunk_table(struct afh_info *afhi,
        for (i = 1; i <= afhi->chunks_total; i++) {
                if (skip + 4 > numbytes)
                        break;
-               sum += aac_read_int32(map + skip);
+               sum += read_u32_be(map + skip);
                afhi->chunk_table[i] = sum;
                skip += 4;
 //             if (i < 10 || i + 10 > afhi->chunks_total)