5 NeAACDecHandle aac_open(void)
7 NeAACDecHandle h = NeAACDecOpen();
8 NeAACDecConfigurationPtr c = NeAACDecGetCurrentConfiguration(h);
10 c->defObjectType = LC;
11 c->outputFormat = FAAD_FMT_16BIT;
13 NeAACDecSetConfiguration(h, c);
17 static int aac_read_decoder_length(unsigned char *buf, int *description_len)
26 length = (length << 7) | (b & 0x7F);
28 ((b & 0x80) && numBytes < 4);
29 *description_len = numBytes;
33 int aac_find_esds(unsigned char *buf, unsigned buflen, int *skip)
37 for (i = 0; i + 4 < buflen; i++) {
38 unsigned char *p = buf + i;
39 int decoder_length, description_len;
41 if (p[0] != 'e' || p[1] != 's' || p[2] != 'd' || p[3] != 's')
45 PARA_INFO_LOG("found esds@%d, next: %x\n", i, *p);
51 PARA_INFO_LOG("next: %x\n", *p);
56 PARA_INFO_LOG("next: %x\n", *p);
61 decoder_length = aac_read_decoder_length(p, &description_len);
62 PARA_INFO_LOG("decoder length: %d\n", decoder_length);
65 return decoder_length;
70 unsigned aac_read_int32(unsigned char *buf)
72 uint8_t *d = (uint8_t*)buf;
73 return (d[0] << 24) | (d[1] << 16) | (d[2] << 8) | d[3];
77 int aac_find_entry(unsigned char *buf, unsigned buflen, int *skip)
81 for (i = 0; i + 20 < buflen; i++) {
82 unsigned char *p = buf + i;
84 if (p[0] != 's' || p[1] != 't' || p[2] != 'c' || p[3] != 'o')
86 PARA_INFO_LOG("found stco@%d\n", i);
88 ret = aac_read_int32(buf + i); /* first offset */
90 PARA_INFO_LOG("num entries: %d\n", ret);
94 PARA_WARNING_LOG("stco not found, buflen: %d\n", buflen);
98 int aac_find_stsz(unsigned char *buf, unsigned buflen, unsigned *skip)
102 for (i = 0; i + 16 < buflen; i++) {
103 unsigned char *p = buf + i;
104 unsigned sample_count, sample_size;
106 if (p[0] != 's' || p[1] != 't' || p[2] != 's' || p[3] != 'z')
108 PARA_INFO_LOG("found stsz@%d\n", i);
110 sample_size = aac_read_int32(buf + i);
111 PARA_INFO_LOG("sample size: %d\n", sample_size);
113 sample_count = aac_read_int32(buf + i);
115 PARA_INFO_LOG("sample count: %d\n", sample_count);
119 PARA_WARNING_LOG("stsz not found, buflen: %d\n", buflen);