helix-aac.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * Squeezelite - lightweight headless squeezebox emulator
  3. *
  4. * (c) Adrian Smith 2012-2015, triode1@btinternet.com
  5. * Ralph Irving 2015-2017, ralph_irving@hotmail.com
  6. * Philippe, philippe_44@outlook.com
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #include "squeezelite.h"
  23. #include <aacdec.h>
  24. // AAC_MAX_SAMPLES is the number of samples for one channel
  25. #define FRAME_BUF (AAC_MAX_NSAMPS*2)
  26. #if BYTES_PER_FRAME == 4
  27. #define ALIGN(n) (n)
  28. #else
  29. #define ALIGN(n) (n << 8)
  30. #endif
  31. #define WRAPBUF_LEN 2048
  32. static unsigned rates[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
  33. struct chunk_table {
  34. u32_t sample, offset;
  35. };
  36. struct helixaac {
  37. HAACDecoder hAac;
  38. u8_t type;
  39. u8_t *write_buf;
  40. // following used for mp4 only
  41. u32_t consume;
  42. u32_t pos;
  43. u32_t sample;
  44. u32_t nextchunk;
  45. void *stsc;
  46. u32_t skip;
  47. u64_t samples;
  48. u64_t sttssamples;
  49. bool empty;
  50. struct chunk_table *chunkinfo;
  51. #if !LINKALL
  52. #endif
  53. };
  54. static struct helixaac *a;
  55. extern log_level loglevel;
  56. extern struct buffer *streambuf;
  57. extern struct buffer *outputbuf;
  58. extern struct streamstate stream;
  59. extern struct outputstate output;
  60. extern struct decodestate decode;
  61. extern struct processstate process;
  62. #define LOCK_S mutex_lock(streambuf->mutex)
  63. #define UNLOCK_S mutex_unlock(streambuf->mutex)
  64. #define LOCK_O mutex_lock(outputbuf->mutex)
  65. #define UNLOCK_O mutex_unlock(outputbuf->mutex)
  66. #if PROCESS
  67. #define LOCK_O_direct if (decode.direct) mutex_lock(outputbuf->mutex)
  68. #define UNLOCK_O_direct if (decode.direct) mutex_unlock(outputbuf->mutex)
  69. #define IF_DIRECT(x) if (decode.direct) { x }
  70. #define IF_PROCESS(x) if (!decode.direct) { x }
  71. #else
  72. #define LOCK_O_direct mutex_lock(outputbuf->mutex)
  73. #define UNLOCK_O_direct mutex_unlock(outputbuf->mutex)
  74. #define IF_DIRECT(x) { x }
  75. #define IF_PROCESS(x)
  76. #endif
  77. #if LINKALL
  78. #define HAAC(h, fn, ...) (AAC ## fn)(__VA_ARGS__)
  79. #else
  80. #define HAAC(h, fn, ...) (h)->AAC##fn(__VA_ARGS__)
  81. #endif
  82. // minimal code for mp4 file parsing to extract audio config and find media data
  83. // adapted from faad2/common/mp4ff
  84. u32_t mp4_desc_length(u8_t **buf) {
  85. u8_t b;
  86. u8_t num_bytes = 0;
  87. u32_t length = 0;
  88. do {
  89. b = **buf;
  90. *buf += 1;
  91. num_bytes++;
  92. length = (length << 7) | (b & 0x7f);
  93. } while ((b & 0x80) && num_bytes < 4);
  94. return length;
  95. }
  96. // read mp4 header to extract config data
  97. static int read_mp4_header(unsigned long *samplerate_p, unsigned char *channels_p) {
  98. size_t bytes = min(_buf_used(streambuf), _buf_cont_read(streambuf));
  99. char type[5];
  100. u32_t len;
  101. while (bytes >= 8) {
  102. // count trak to find the first playable one
  103. static unsigned trak, play;
  104. u32_t consume;
  105. len = unpackN((u32_t *)streambuf->readp);
  106. memcpy(type, streambuf->readp + 4, 4);
  107. type[4] = '\0';
  108. if (!strcmp(type, "moov")) {
  109. trak = 0;
  110. play = 0;
  111. }
  112. if (!strcmp(type, "trak")) {
  113. trak++;
  114. }
  115. // extract audio config from within esds and pass to DecInit2
  116. if (!strcmp(type, "esds") && bytes > len) {
  117. u8_t *ptr = streambuf->readp + 12;
  118. AACFrameInfo info;
  119. if (*ptr++ == 0x03) {
  120. mp4_desc_length(&ptr);
  121. ptr += 4;
  122. } else {
  123. ptr += 3;
  124. }
  125. mp4_desc_length(&ptr);
  126. ptr += 13;
  127. if (*ptr++ != 0x05) {
  128. LOG_WARN("error parsing esds");
  129. return -1;
  130. }
  131. mp4_desc_length(&ptr);
  132. info.profile = *ptr >> 3;
  133. info.sampRateCore = (*ptr++ & 0x07) << 1;
  134. info.sampRateCore |= (*ptr >> 7) & 0x01;
  135. info.sampRateCore = rates[info.sampRateCore];
  136. info.nChans = *ptr >> 3;
  137. *channels_p = info.nChans;
  138. *samplerate_p = info.sampRateCore;
  139. HAAC(a, SetRawBlockParams, a->hAac, 0, &info);
  140. LOG_DEBUG("playable aac track: %u (p:%x, r:%d, c:%d)", trak, info.profile, info.sampRateCore, info.nChans);
  141. play = trak;
  142. }
  143. // extract the total number of samples from stts
  144. if (!strcmp(type, "stts") && bytes > len) {
  145. u32_t i;
  146. u8_t *ptr = streambuf->readp + 12;
  147. u32_t entries = unpackN((u32_t *)ptr);
  148. ptr += 4;
  149. for (i = 0; i < entries; ++i) {
  150. u32_t count = unpackN((u32_t *)ptr);
  151. u32_t size = unpackN((u32_t *)(ptr + 4));
  152. a->sttssamples += count * size;
  153. ptr += 8;
  154. }
  155. LOG_DEBUG("total number of samples contained in stts: " FMT_u64, a->sttssamples);
  156. }
  157. // stash sample to chunk info, assume it comes before stco
  158. if (!strcmp(type, "stsc") && bytes > len && !a->chunkinfo) {
  159. a->stsc = malloc(len - 12);
  160. if (a->stsc == NULL) {
  161. LOG_WARN("malloc fail");
  162. return -1;
  163. }
  164. memcpy(a->stsc, streambuf->readp + 12, len - 12);
  165. }
  166. // build offsets table from stco and stored stsc
  167. if (!strcmp(type, "stco") && bytes > len && play == trak) {
  168. u32_t i;
  169. // extract chunk offsets
  170. u8_t *ptr = streambuf->readp + 12;
  171. u32_t entries = unpackN((u32_t *)ptr);
  172. ptr += 4;
  173. a->chunkinfo = malloc(sizeof(struct chunk_table) * (entries + 1));
  174. if (a->chunkinfo == NULL) {
  175. LOG_WARN("malloc fail");
  176. return -1;
  177. }
  178. for (i = 0; i < entries; ++i) {
  179. a->chunkinfo[i].offset = unpackN((u32_t *)ptr);
  180. a->chunkinfo[i].sample = 0;
  181. ptr += 4;
  182. }
  183. a->chunkinfo[i].sample = 0;
  184. a->chunkinfo[i].offset = 0;
  185. // fill in first sample id for each chunk from stored stsc
  186. if (a->stsc) {
  187. u32_t stsc_entries = unpackN((u32_t *)a->stsc);
  188. u32_t sample = 0;
  189. u32_t last = 0, last_samples = 0;
  190. u8_t *ptr = (u8_t *)a->stsc + 4;
  191. while (stsc_entries--) {
  192. u32_t first = unpackN((u32_t *)ptr);
  193. u32_t samples = unpackN((u32_t *)(ptr + 4));
  194. if (last) {
  195. for (i = last - 1; i < first - 1; ++i) {
  196. a->chunkinfo[i].sample = sample;
  197. sample += last_samples;
  198. }
  199. }
  200. if (stsc_entries == 0) {
  201. for (i = first - 1; i < entries; ++i) {
  202. a->chunkinfo[i].sample = sample;
  203. sample += samples;
  204. }
  205. }
  206. last = first;
  207. last_samples = samples;
  208. ptr += 12;
  209. }
  210. free(a->stsc);
  211. a->stsc = NULL;
  212. }
  213. }
  214. // found media data, advance to start of first chunk and return
  215. if (!strcmp(type, "mdat")) {
  216. _buf_inc_readp(streambuf, 8);
  217. a->pos += 8;
  218. bytes -= 8;
  219. if (play) {
  220. LOG_DEBUG("type: mdat len: %u pos: %u", len, a->pos);
  221. if (a->chunkinfo && a->chunkinfo[0].offset > a->pos) {
  222. u32_t skip = a->chunkinfo[0].offset - a->pos;
  223. LOG_DEBUG("skipping: %u", skip);
  224. if (skip <= bytes) {
  225. _buf_inc_readp(streambuf, skip);
  226. a->pos += skip;
  227. } else {
  228. a->consume = skip;
  229. }
  230. }
  231. a->sample = a->nextchunk = 1;
  232. return 1;
  233. } else {
  234. LOG_DEBUG("type: mdat len: %u, no playable track found", len);
  235. return -1;
  236. }
  237. }
  238. // parse key-value atoms within ilst ---- entries to get encoder padding within iTunSMPB entry for gapless
  239. if (!strcmp(type, "----") && bytes > len) {
  240. u8_t *ptr = streambuf->readp + 8;
  241. u32_t remain = len - 8, size;
  242. if (!memcmp(ptr + 4, "mean", 4) && (size = unpackN((u32_t *)ptr)) < remain) {
  243. ptr += size; remain -= size;
  244. }
  245. if (!memcmp(ptr + 4, "name", 4) && (size = unpackN((u32_t *)ptr)) < remain && !memcmp(ptr + 12, "iTunSMPB", 8)) {
  246. ptr += size; remain -= size;
  247. }
  248. if (!memcmp(ptr + 4, "data", 4) && remain > 16 + 48) {
  249. // data is stored as hex strings: 0 start end samples
  250. u32_t b, c; u64_t d;
  251. if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b, &b, &c, &d) == 4) {
  252. LOG_DEBUG("iTunSMPB start: %u end: %u samples: " FMT_u64, b, c, d);
  253. if (a->sttssamples && a->sttssamples < b + c + d) {
  254. LOG_DEBUG("reducing samples as stts count is less");
  255. d = a->sttssamples - (b + c);
  256. }
  257. a->skip = b;
  258. a->samples = d;
  259. }
  260. }
  261. }
  262. // default to consuming entire box
  263. consume = len;
  264. // read into these boxes so reduce consume
  265. if (!strcmp(type, "moov") || !strcmp(type, "trak") || !strcmp(type, "mdia") || !strcmp(type, "minf") || !strcmp(type, "stbl") ||
  266. !strcmp(type, "udta") || !strcmp(type, "ilst")) {
  267. consume = 8;
  268. }
  269. // special cases which mix mix data in the enclosing box which we want to read into
  270. if (!strcmp(type, "stsd")) consume = 16;
  271. if (!strcmp(type, "mp4a")) consume = 36;
  272. if (!strcmp(type, "meta")) consume = 12;
  273. // consume rest of box if it has been parsed (all in the buffer) or is not one we want to parse
  274. if (bytes >= consume) {
  275. LOG_DEBUG("type: %s len: %u consume: %u", type, len, consume);
  276. _buf_inc_readp(streambuf, consume);
  277. a->pos += consume;
  278. bytes -= consume;
  279. } else if ( !(!strcmp(type, "esds") || !strcmp(type, "stts") || !strcmp(type, "stsc") ||
  280. !strcmp(type, "stco") || !strcmp(type, "----")) ) {
  281. LOG_DEBUG("type: %s len: %u consume: %u - partial consume: %u", type, len, consume, bytes);
  282. _buf_inc_readp(streambuf, bytes);
  283. a->pos += bytes;
  284. a->consume = consume - bytes;
  285. break;
  286. } else {
  287. break;
  288. }
  289. }
  290. return 0;
  291. }
  292. static decode_state helixaac_decode(void) {
  293. size_t bytes_total, bytes_wrap;
  294. int res, bytes;
  295. static AACFrameInfo info;
  296. ISAMPLE_T *iptr;
  297. u8_t *sptr;
  298. bool endstream;
  299. frames_t frames;
  300. LOCK_S;
  301. bytes_total = _buf_used(streambuf);
  302. bytes_wrap = min(bytes_total, _buf_cont_read(streambuf));
  303. if (stream.state <= DISCONNECT && !bytes_total) {
  304. UNLOCK_S;
  305. return DECODE_COMPLETE;
  306. }
  307. if (a->consume) {
  308. u32_t consume = min(a->consume, bytes_wrap);
  309. LOG_DEBUG("consume: %u of %u", consume, a->consume);
  310. _buf_inc_readp(streambuf, consume);
  311. a->pos += consume;
  312. a->consume -= consume;
  313. UNLOCK_S;
  314. return DECODE_RUNNING;
  315. }
  316. if (decode.new_stream) {
  317. int found = 0;
  318. static unsigned char channels;
  319. static unsigned long samplerate;
  320. if (a->type == '2') {
  321. // adts stream - seek for header
  322. long n = AACFindSyncWord(streambuf->readp, bytes_wrap);
  323. LOG_DEBUG("Sync search in %d bytes %d", bytes_wrap, n);
  324. if (n >= 0) {
  325. u8_t *p = streambuf->readp + n;
  326. int bytes = bytes_wrap - n;
  327. if (!HAAC(a, Decode, a->hAac, &p, &bytes, (short*) a->write_buf)) {
  328. HAAC(a, GetLastFrameInfo, a->hAac, &info);
  329. channels = info.nChans;
  330. samplerate = info.sampRateOut;
  331. found = 1;
  332. } else if (n == 0) n++;
  333. HAAC(a, FlushCodec, a->hAac);
  334. bytes_total -= n;
  335. bytes_wrap -= n;
  336. _buf_inc_readp(streambuf, n);
  337. } else {
  338. found = -1;
  339. }
  340. } else {
  341. // mp4 - read header
  342. found = read_mp4_header(&samplerate, &channels);
  343. }
  344. if (found == 1) {
  345. LOG_INFO("samplerate: %u channels: %u", samplerate, channels);
  346. bytes_total = _buf_used(streambuf);
  347. bytes_wrap = min(bytes_total, _buf_cont_read(streambuf));
  348. LOCK_O;
  349. LOG_INFO("setting track_start");
  350. output.next_sample_rate = decode_newstream(samplerate, output.supported_rates);
  351. IF_DSD( output.next_fmt = PCM; )
  352. output.track_start = outputbuf->writep;
  353. if (output.fade_mode) _checkfade(true);
  354. decode.new_stream = false;
  355. UNLOCK_O;
  356. } else if (found == -1) {
  357. LOG_WARN("error reading stream header");
  358. UNLOCK_S;
  359. return DECODE_ERROR;
  360. } else {
  361. // not finished header parsing come back next time
  362. UNLOCK_S;
  363. LOG_INFO("header not found yet");
  364. return DECODE_RUNNING;
  365. }
  366. }
  367. if (bytes_wrap < WRAPBUF_LEN && bytes_total > WRAPBUF_LEN) {
  368. // make a local copy of frames which may have wrapped round the end of streambuf
  369. static u8_t buf[WRAPBUF_LEN];
  370. memcpy(buf, streambuf->readp, bytes_wrap);
  371. memcpy(buf + bytes_wrap, streambuf->buf, WRAPBUF_LEN - bytes_wrap);
  372. sptr = buf;
  373. bytes = bytes_wrap = WRAPBUF_LEN;
  374. } else {
  375. sptr = streambuf->readp;
  376. bytes = bytes_wrap;
  377. }
  378. // decode function changes iptr, so can't use streambuf->readp (same for bytes)
  379. res = HAAC(a, Decode, a->hAac, &sptr, &bytes, (short*) a->write_buf);
  380. if (res < 0) {
  381. LOG_WARN("AAC decode error %d", res);
  382. }
  383. HAAC(a, GetLastFrameInfo, a->hAac, &info);
  384. iptr = (ISAMPLE_T *) a->write_buf;
  385. bytes = bytes_wrap - bytes;
  386. endstream = false;
  387. // mp4 end of chunk - skip to next offset
  388. if (a->chunkinfo && a->chunkinfo[a->nextchunk].offset && a->sample++ == a->chunkinfo[a->nextchunk].sample) {
  389. if (a->chunkinfo[a->nextchunk].offset > a->pos) {
  390. u32_t skip = a->chunkinfo[a->nextchunk].offset - a->pos;
  391. if (skip != bytes) {
  392. LOG_DEBUG("skipping to next chunk pos: %u consumed: %u != skip: %u", a->pos, bytes, skip);
  393. }
  394. if (bytes_total >= skip) {
  395. _buf_inc_readp(streambuf, skip);
  396. a->pos += skip;
  397. } else {
  398. a->consume = skip;
  399. }
  400. a->nextchunk++;
  401. } else {
  402. LOG_ERROR("error: need to skip backwards!");
  403. endstream = true;
  404. }
  405. // adts and mp4 when not at end of chunk
  406. } else if (bytes > 0) {
  407. _buf_inc_readp(streambuf, bytes);
  408. a->pos += bytes;
  409. // error which doesn't advance streambuf - end
  410. } else {
  411. endstream = true;
  412. }
  413. UNLOCK_S;
  414. if (endstream) {
  415. LOG_WARN("unable to decode further");
  416. return DECODE_ERROR;
  417. }
  418. if (!info.outputSamps) {
  419. a->empty = true;
  420. return DECODE_RUNNING;
  421. }
  422. frames = info.outputSamps / info.nChans;
  423. if (a->skip) {
  424. u32_t skip;
  425. if (a->empty) {
  426. a->empty = false;
  427. a->skip -= frames;
  428. LOG_DEBUG("gapless: first frame empty, skipped %u frames at start", frames);
  429. }
  430. skip = min(frames, a->skip);
  431. LOG_DEBUG("gapless: skipping %u frames at start", skip);
  432. frames -= skip;
  433. a->skip -= skip;
  434. iptr += skip * info.nChans;
  435. }
  436. if (a->samples) {
  437. if (a->samples < frames) {
  438. LOG_DEBUG("gapless: trimming %u frames from end", frames - a->samples);
  439. frames = (frames_t)a->samples;
  440. }
  441. a->samples -= frames;
  442. }
  443. LOG_SDEBUG("write %u frames", frames);
  444. LOCK_O_direct;
  445. while (frames > 0) {
  446. frames_t f;
  447. frames_t count;
  448. ISAMPLE_T *optr;
  449. IF_DIRECT(
  450. f = _buf_cont_write(outputbuf) / BYTES_PER_FRAME;
  451. optr = (ISAMPLE_T *)outputbuf->writep;
  452. );
  453. IF_PROCESS(
  454. f = process.max_in_frames;
  455. optr = (ISAMPLE_T *)process.inbuf;
  456. );
  457. f = min(f, frames);
  458. count = f;
  459. if (info.nChans == 2) {
  460. #if BYTES_PER_FRAME == 4
  461. memcpy(optr, iptr, count * BYTES_PER_FRAME);
  462. iptr += count * 2;
  463. #else
  464. while (count--) {
  465. *optr++ = *iptr++ << 8;
  466. *optr++ = *iptr++ << 8;
  467. }
  468. #endif
  469. } else if (info.nChans == 1) {
  470. while (count--) {
  471. *optr++ = ALIGN(*iptr);
  472. *optr++ = ALIGN(*iptr++);
  473. }
  474. } else {
  475. LOG_WARN("unsupported number of channels");
  476. }
  477. frames -= f;
  478. IF_DIRECT(
  479. _buf_inc_writep(outputbuf, f * BYTES_PER_FRAME);
  480. );
  481. IF_PROCESS(
  482. process.in_frames = f;
  483. if (frames) LOG_ERROR("unhandled case");
  484. );
  485. }
  486. UNLOCK_O_direct;
  487. return DECODE_RUNNING;
  488. }
  489. static void helixaac_open(u8_t size, u8_t rate, u8_t chan, u8_t endianness) {
  490. LOG_INFO("opening %s stream", size == '2' ? "adts" : "mp4");
  491. a->type = size;
  492. a->pos = a->consume = a->sample = a->nextchunk = 0;
  493. if (a->chunkinfo) {
  494. free(a->chunkinfo);
  495. }
  496. if (a->stsc) {
  497. free(a->stsc);
  498. }
  499. a->chunkinfo = NULL;
  500. a->stsc = NULL;
  501. a->skip = 0;
  502. a->samples = 0;
  503. a->sttssamples = 0;
  504. a->empty = false;
  505. if (a->hAac) {
  506. HAAC(a, FlushCodec, a->hAac);
  507. } else {
  508. a->hAac = HAAC(a, InitDecoder);
  509. a->write_buf = malloc(FRAME_BUF * BYTES_PER_FRAME);
  510. }
  511. }
  512. static void helixaac_close(void) {
  513. HAAC(a, FreeDecoder, a->hAac);
  514. a->hAac = NULL;
  515. if (a->chunkinfo) {
  516. free(a->chunkinfo);
  517. a->chunkinfo = NULL;
  518. }
  519. if (a->stsc) {
  520. free(a->stsc);
  521. a->stsc = NULL;
  522. }
  523. free(a->write_buf);
  524. }
  525. static bool load_helixaac() {
  526. #if !LINKALL
  527. void *handle = dlopen(LIBHELIX-AAC, RTLD_NOW);
  528. char *err;
  529. if (!handle) {
  530. LOG_INFO("dlerror: %s", dlerror());
  531. return false;
  532. }
  533. // load symbols here
  534. if ((err = dlerror()) != NULL) {
  535. LOG_INFO("dlerror: %s", err);
  536. return false;
  537. }
  538. LOG_INFO("loaded "LIBHELIX-AAC"");
  539. #endif
  540. return true;
  541. }
  542. struct codec *register_helixaac(void) {
  543. static struct codec ret = {
  544. 'a', // id
  545. "aac", // types
  546. WRAPBUF_LEN, // min read
  547. 20480, // min space
  548. helixaac_open, // open
  549. helixaac_close, // close
  550. helixaac_decode, // decode
  551. };
  552. a = malloc(sizeof(struct helixaac));
  553. if (!a) {
  554. return NULL;
  555. }
  556. a->hAac = NULL;
  557. a->chunkinfo = NULL;
  558. a->stsc = NULL;
  559. if (!load_helixaac()) {
  560. return NULL;
  561. }
  562. LOG_INFO("using helix-aac to decode aac");
  563. return &ret;
  564. }