const char **buf, uint32_t *len)
{
struct aac_afh_context *c = afh_context;
- int32_t ss;
+ uint32_t ss;
size_t offset;
int ret;
if (ret < 0)
return ret;
offset = c->fpos;
- ss = mp4_get_sample_size(c->mp4, chunk_num);
- if (ss <= 0)
- return -E_MP4_BAD_SAMPLE;
+ ret = mp4_get_sample_size(c->mp4, chunk_num, &ss);
+ if (ret < 0)
+ return ret;
assert(ss + offset <= c->mapsize);
*buf = c->map + offset;
*len = ss;
return 1;
}
-int32_t mp4_get_sample_size(const struct mp4 *f, int sample)
+int mp4_get_sample_size(const struct mp4 *f, uint32_t sample, uint32_t *result)
{
const struct mp4_track *t = &f->track;
+ if (sample >= t->stsz_sample_count)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
if (t->stsz_sample_size != 0)
- return t->stsz_sample_size;
- return t->stsz_table[sample];
+ *result = t->stsz_sample_size;
+ else
+ *result = t->stsz_table[sample];
+ return 1;
}
uint32_t mp4_get_sample_rate(const struct mp4 *f)
int mp4_set_sample_position(struct mp4 *f, uint32_t sample);
int mp4_open_read(const struct mp4_callback *cb, struct mp4 **result);
void mp4_close(struct mp4 *f);
-int32_t mp4_get_sample_size(const struct mp4 *f, int sample);
+int mp4_get_sample_size(const struct mp4 *f, uint32_t sample, uint32_t *result);
uint32_t mp4_get_sample_rate(const struct mp4 *f);
uint32_t mp4_get_channel_count(const struct mp4 * f);
int32_t mp4_num_samples(const struct mp4 *f);