diff options
Diffstat (limited to 'apps/codecs/libm4a')
-rw-r--r-- | apps/codecs/libm4a/m4a.c | 11 | ||||
-rw-r--r-- | apps/codecs/libm4a/m4a.h | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/apps/codecs/libm4a/m4a.c b/apps/codecs/libm4a/m4a.c index 836cdafda3..84144ea76c 100644 --- a/apps/codecs/libm4a/m4a.c +++ b/apps/codecs/libm4a/m4a.c | |||
@@ -124,10 +124,14 @@ void stream_create(stream_t *stream,struct codec_api* ci) | |||
124 | 124 | ||
125 | /* Check if there is a dedicated byte position contained for the given frame. | 125 | /* Check if there is a dedicated byte position contained for the given frame. |
126 | * Return this byte position in case of success or return -1. This allows to | 126 | * Return this byte position in case of success or return -1. This allows to |
127 | * skip empty samples. */ | 127 | * skip empty samples. |
128 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame) | 128 | * During standard playback the search result (index i) will always increase. |
129 | * Therefor we save this index and let the caller set this value again as start | ||
130 | * index when calling m4a_check_sample_offset() for the next frame. This | ||
131 | * reduces the overall loop count significantly. */ | ||
132 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) | ||
129 | { | 133 | { |
130 | uint32_t i = 0; | 134 | uint32_t i = *start; |
131 | for (i=0; i<demux_res->num_lookup_table; ++i) | 135 | for (i=0; i<demux_res->num_lookup_table; ++i) |
132 | { | 136 | { |
133 | if (demux_res->lookup_table[i].sample > frame || | 137 | if (demux_res->lookup_table[i].sample > frame || |
@@ -136,6 +140,7 @@ int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame) | |||
136 | if (demux_res->lookup_table[i].sample == frame) | 140 | if (demux_res->lookup_table[i].sample == frame) |
137 | break; | 141 | break; |
138 | } | 142 | } |
143 | *start = i; | ||
139 | return demux_res->lookup_table[i].offset; | 144 | return demux_res->lookup_table[i].offset; |
140 | } | 145 | } |
141 | 146 | ||
diff --git a/apps/codecs/libm4a/m4a.h b/apps/codecs/libm4a/m4a.h index e49d14b832..da5401dba4 100644 --- a/apps/codecs/libm4a/m4a.h +++ b/apps/codecs/libm4a/m4a.h | |||
@@ -137,6 +137,6 @@ unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, | |||
137 | int* current_sample); | 137 | int* current_sample); |
138 | unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, | 138 | unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, |
139 | uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); | 139 | uint32_t file_loc, uint32_t* sound_samples_done, int* current_sample); |
140 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame); | 140 | int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); |
141 | 141 | ||
142 | #endif /* STREAM_H */ | 142 | #endif /* STREAM_H */ |