]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Simplify and rename mp4ff_read_sample_getsize().
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 9 Aug 2021 17:10:46 +0000 (19:10 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
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.

aac_afh.c
mp4.c
mp4.h

index 5b5fd47ef3e23d330386a794b049e78256321120..c2daf5b533ca881990963618fbd2c488468f58ce 100644 (file)
--- 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 761eb375a615942175d3aa2a247aa5a12f1fda3d..7bef0d756edf746319380c670a6710a9654ed281 100644 (file)
--- 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 43874a03566468f7f0fead4a0aa167763ede7707..2cf3071fa6bb64301e38b48680409cddbe38181a 100644 (file)
--- 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);