- ret = (numbytes - ret) * 8;
- ret += (afhi->channels * afhi->seconds_total * 500); /* avoid rounding error */
- afhi->bitrate = ret / (afhi->channels * afhi->seconds_total * 1000);
- return 1;
-}
-
-/*
- * Init m4a file and write some tech data to given pointers.
- */
-static int aac_get_file_info(char *map, size_t numbytes, __a_unused int fd,
- struct afh_info *afhi)
-{
- size_t skip;
- ssize_t ret;
- unsigned long rate = 0, decoder_len;
- unsigned char channels = 0;
- mp4AudioSpecificConfig mp4ASC;
- NeAACDecHandle handle = NULL;
-
- ret = aac_find_esds(map, numbytes, &skip, &decoder_len);
- if (ret < 0)
- goto out;
- aac_get_taginfo(map, numbytes, afhi);
- handle = aac_open();
- ret = -E_AAC_AFH_INIT;
- if (NeAACDecInit(handle, (unsigned char *)map + skip, decoder_len,
- &rate, &channels))
- goto out;
- if (!channels)
- goto out;
- afhi->channels = channels;
- afhi->frequency = rate;
- PARA_DEBUG_LOG("rate: %lu, channels: %d\n", rate, channels);
- ret = -E_MP4ASC;
- if (NeAACDecAudioSpecificConfig((unsigned char *)map + skip,
- numbytes - skip, &mp4ASC))
- goto out;
- if (!mp4ASC.samplingFrequency)
- goto out;
- ret = aac_compute_chunk_info(afhi, map, numbytes, &mp4ASC);
- if (ret < 0)
- goto out;
- ret = 1;
-out:
- if (handle)
- NeAACDecClose(handle);
- return ret;
-}
-
-static int aac_rewrite_tags(const char *map, size_t mapsize,
- struct taginfo *tags, int fd, const char *filename)
-{
- MP4FileHandle h;
- const MP4Tags *mdata;
- int ret = write_all(fd, map, mapsize);