struct aac_afh_context *c = afh_context;
int32_t ss;
size_t offset;
+ int ret;
- assert(chunk_num <= INT_MAX);
- mp4_set_sample_position(c->mp4, c->track, chunk_num);
+ ret = mp4_set_sample_position(c->mp4, c->track, chunk_num);
+ if (ret < 0)
+ return ret;
offset = c->fpos;
ss = mp4_get_sample_size(c->mp4, c->track, chunk_num);
if (ss <= 0)
#include <regex.h>
#include "para.h"
+#include "error.h"
#include "portable_io.h"
#include "string.h"
#include "mp4.h"
*chunk_sample = 0;
*chunk = 1;
- if (f->track[track] == NULL) {
- return -1;
- }
total_entries = f->track[track]->stsc_entry_count;
if (t->stsz_sample_size)
return (sample - chunk_sample) * t->stsz_sample_size;
- if (sample >= t->stsz_sample_count)
- return 0; /* error */
for (i = chunk_sample, total = 0; i < sample; i++)
total += t->stsz_table[i];
return total;
return f->track[track]->is_audio;
}
-void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample)
+int mp4_set_sample_position(struct mp4 *f, uint32_t track, int32_t sample)
{
+ const struct mp4_track *t = f->track[track];
int32_t offset, chunk, chunk_sample;
+ if (sample >= t->stsz_sample_count || track >= f->total_tracks)
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
chunk_of_sample(f, track, sample, &chunk_sample, &chunk);
offset = chunk_to_offset(f, track, chunk)
+ sample_range_size(f, track, chunk_sample, sample);
set_position(f, offset);
+ return 1;
}
int32_t mp4_get_sample_size(const struct mp4 *f, int track, int sample)
struct mp4; /* opaque */
-void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample);
+int mp4_set_sample_position(struct mp4 *f, uint32_t track, int32_t sample);
int32_t mp4_get_total_tracks(const struct mp4 *f);
bool mp4_is_audio_track(const struct mp4 *f, int32_t track);
struct mp4 *mp4_open_read(const struct mp4_callback *cb);