From: Andre Noll Date: Mon, 9 Aug 2021 17:10:46 +0000 (+0200) Subject: mp4: Simplify and rename mp4ff_read_sample_getsize(). X-Git-Tag: v0.7.1~7^2~131 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=81076a42be18b3027ef1b5d665cd9ceda1d06319;p=paraslash.git mp4: Simplify and rename mp4ff_read_sample_getsize(). The new code is much shorter. It is equivalent because the single caller only checks whether the return value is less or equal then zero, and does not use the return value in this case. --- diff --git a/aac_afh.c b/aac_afh.c index 5b5fd47e..c2daf5b5 100644 --- a/aac_afh.c +++ b/aac_afh.c @@ -118,7 +118,7 @@ static int aac_afh_get_chunk(uint32_t chunk_num, void *afh_context, assert(chunk_num <= INT_MAX); mp4ff_set_sample_position(c->mp4ff, c->track, chunk_num); offset = c->fpos; - ss = mp4ff_read_sample_getsize(c->mp4ff, c->track, chunk_num); + ss = mp4ff_get_sample_size(c->mp4ff, c->track, chunk_num); if (ss <= 0) return -E_MP4FF_BAD_SAMPLE; assert(ss + offset <= c->mapsize); diff --git a/mp4.c b/mp4.c index 761eb375..7bef0d75 100644 --- a/mp4.c +++ b/mp4.c @@ -1509,28 +1509,13 @@ void mp4ff_set_sample_position(mp4ff_t *f, const int32_t track, mp4ff_set_position(f, offset); } -static int32_t mp4ff_audio_frame_size(const mp4ff_t * f, const int32_t track, - const int32_t sample) +int32_t mp4ff_get_sample_size(const mp4ff_t *f, int track, int sample) { - int32_t bytes; - const mp4ff_track_t *p_track = f->track[track]; - - if (p_track->stsz_sample_size) { - bytes = p_track->stsz_sample_size; - } else { - bytes = p_track->stsz_table[sample]; - } + const mp4ff_track_t *t = f->track[track]; - return bytes; -} - -int32_t mp4ff_read_sample_getsize(mp4ff_t * f, const int track, - const int sample) -{ - int32_t temp = mp4ff_audio_frame_size(f, track, sample); - if (temp < 0) - temp = 0; - return temp; + if (t->stsz_sample_size != 0) + return t->stsz_sample_size; + return t->stsz_table[sample]; } uint32_t mp4ff_get_sample_rate(const mp4ff_t * f, const int32_t track) diff --git a/mp4.h b/mp4.h index 43874a03..2cf3071f 100644 --- a/mp4.h +++ b/mp4.h @@ -105,7 +105,7 @@ void mp4ff_get_decoder_config(const mp4ff_t *f, const int track, unsigned char** ppBuf, unsigned int* pBufSize); mp4ff_t *mp4ff_open_read(mp4ff_callback_t *f); void mp4ff_close(mp4ff_t *f); -int32_t mp4ff_read_sample_getsize(mp4ff_t *f, const int track, const int sample); +int32_t mp4ff_get_sample_size(const mp4ff_t *f, int track, int sample); uint32_t mp4ff_get_sample_rate(const mp4ff_t *f, const int32_t track); uint32_t mp4ff_get_channel_count(const mp4ff_t * f,const int32_t track); int32_t mp4ff_num_samples(const mp4ff_t *f, const int track);