- return NULL;
- ret = para_fread(inbuf, *len, 1, infile);
- if (ret != *len)
- return NULL;
-// PARA_DEBUG_LOG("ret: %d, inbuf[0]: %lx - %lx\n", ret, (long unsigned) inbuf[0],
-// (long unsigned) inbuf[4]);
- return (char *)inbuf;
+ goto out;
+ taginfo = aac_get_taginfo(umap, numbytes);
+ handle = aac_open();
+ ret = -E_AAC_AFH_INIT;
+ if (NeAACDecInit(handle, umap + skip, decoder_len, &rate, &channels))
+ goto out;
+ if (!channels)
+ goto out;
+ PARA_DEBUG_LOG("rate: %lu, channels: %d\n", rate, channels);
+ ret = -E_MP4ASC;
+ if (NeAACDecAudioSpecificConfig(umap + skip, numbytes - skip, &mp4ASC))
+ goto out;
+ if (!mp4ASC.samplingFrequency)
+ goto out;
+ ret = aac_compute_chunk_table(afhi, umap, numbytes);
+ if (ret < 0)
+ goto out;
+ skip = ret;
+ ret = aac_set_chunk_tv(afhi, &mp4ASC, &afhi->seconds_total);
+ if (ret < 0)
+ goto out;
+ ret = aac_find_entry_point(umap + skip, numbytes - skip, &skip);
+ if (ret < 0)
+ goto out;
+ afhi->chunk_table[0] = ret;
+ for (i = 1; i<= afhi->chunks_total; i++)
+ afhi->chunk_table[i] += ret;
+ afhi->channels = channels;
+ afhi->frequency = rate;
+ ret = (afhi->chunk_table[afhi->chunks_total] - afhi->chunk_table[0]) * 8; /* bits */
+ ret += (channels * afhi->seconds_total * 500); /* avoid rounding error */
+ afhi->bitrate = ret / (channels * afhi->seconds_total * 1000);
+ afhi->info_string = make_message("%s:\n%s",
+ status_item_list[SI_AUDIO_FILE_INFO],
+ taginfo);
+ free(taginfo);
+ tv_scale(20, &afhi->chunk_tv, &afhi->eof_tv);
+ ret = 1;
+out:
+ if (handle)
+ NeAACDecClose(handle);
+ return ret;