X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=aac_common.c;h=9edeb1c580b589229dec4aba14f0113c86d01bb2;hp=16109b9500c08e97c8ece63cc8aa51819b3921bd;hb=eda995d5da0a91ab0c4fa6c3d30c5bcdf69d2828;hpb=55f0f9461990455656bef7a36b0f963e3d676653 diff --git a/aac_common.c b/aac_common.c index 16109b95..9edeb1c5 100644 --- a/aac_common.c +++ b/aac_common.c @@ -57,6 +57,7 @@ int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip) if (*p != 5) continue; i++; + p = buf + i; decoder_length = aac_read_decoder_length(p, &description_len); PARA_INFO_LOG("decoder length: %d\n", decoder_length); i += description_len; @@ -73,23 +74,49 @@ unsigned aac_read_int32(unsigned char *buf) } -int find_stco(unsigned char *buf, unsigned buflen, int *skip) +int aac_find_entry(unsigned char *buf, unsigned buflen, int *skip) { int i, ret; - for (i = 0; i + 16 < buflen; i++) { + for (i = 0; i + 20 < buflen; i++) { unsigned char *p = buf + i; if (p[0] != 's' || p[1] != 't' || p[2] != 'c' || p[3] != 'o') continue; PARA_INFO_LOG("found stco@%d\n", i); - i += 8; - ret = aac_read_int32(buf + i); + i += 12; + ret = aac_read_int32(buf + i); /* first offset */ i += 4; PARA_INFO_LOG("num entries: %d\n", ret); *skip = i; return ret; } + PARA_WARNING_LOG("stco not found, buflen: %d\n", buflen); + return -E_STCO; +} + +int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip) +{ + int i; + + for (i = 0; i + 16 < buflen; i++) { + unsigned char *p = buf + i; + unsigned sample_count, sample_size; + + if (p[0] != 's' || p[1] != 't' || p[2] != 's' || p[3] != 'z') + continue; + PARA_INFO_LOG("found stsz@%d\n", i); + i += 8; + sample_size = aac_read_int32(buf + i); + PARA_INFO_LOG("sample size: %d\n", sample_size); + i += 4; + sample_count = aac_read_int32(buf + i); + i += 4; + PARA_INFO_LOG("sample count: %d\n", sample_count); + *skip = i; + return sample_count; + } + PARA_WARNING_LOG("stsz not found, buflen: %d\n", buflen); return -E_STCO; }