struct afh_info *afhi)
{
int ret;
- int32_t rv;
struct aac_afh_context *c;
uint64_t milliseconds;
const char *buf;
if (ret < 0)
return ret;
- ret = -E_MP4_BAD_SAMPLERATE;
- rv = mp4_get_sample_rate(c->mp4);
- if (rv <= 0)
- goto close;
- afhi->frequency = rv;
-
+ afhi->frequency = mp4_get_sample_rate(c->mp4);
+ assert(afhi->frequency > 0);
afhi->channels = mp4_get_channel_count(c->mp4);
assert(afhi->channels > 0);
+ afhi->chunks_total = mp4_num_samples(c->mp4);
+ assert(afhi->chunks_total > 0);
- ret = -E_MP4_BAD_SAMPLE_COUNT;
- rv = mp4_num_samples(c->mp4);
- if (rv <= 0)
- goto close;
- afhi->chunks_total = rv;
afhi->max_chunk_size = 0;
for (n = 0; n < afhi->chunks_total; n++) {
if (aac_afh_get_chunk(n, c, &buf, &len) < 0)
afhi->bitrate = 8 * numbytes / afhi->seconds_total / 1000;
aac_afh_get_taginfo(c->mp4, &afhi->tags);
ret = 1;
-close:
aac_afh_close(c);
return ret;
}
ret = -E_MP4_TRACK;
if (f->track.channel_count == 0)
goto fail;
+ ret = -E_MP4_BAD_SAMPLERATE;
+ if (f->track.sample_rate == 0)
+ goto fail;
*result = f;
return 1;
fail:
int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result)
{
- return open_file(cb, false, result);
+ struct mp4 *f;
+ int ret;
+
+ *result = NULL;
+ ret = open_file(cb, false, &f);
+ if (ret < 0)
+ return ret;
+ ret = -E_MP4_BAD_SAMPLE_COUNT;
+ if (f->track.stsz_sample_count == 0)
+ goto fail;
+ *result = f;
+ return 1;
+fail:
+ mp4_close(f);
+ return ret;
}
void mp4_close(struct mp4 *f)