···2828CODEC_HEADER
29293030/* The maximum buffer size handled by faad. 12 bytes are required by libfaad
3131- * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered
3131+ * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered
3232 * for each frame. */
3333#define FAAD_BYTE_BUFFER_SIZE (2048-12)
3434···6262 int framelength;
6363 int lead_trim = 0;
6464 unsigned int frame_samples;
6565- unsigned int i;
6565+ uint32_t i;
6666 unsigned char* buffer;
6767 NeAACDecFrameInfo frame_info;
6868 NeAACDecHandle decoder;
···129129#endif
130130131131 i = 0;
132132-132132+133133 if (param) {
134134 elapsed_time = param;
135135 action = CODEC_ACTION_SEEK_TIME;
···138138 * upsampling files the resulting sound_samples_done must be expanded
139139 * by a factor of 2. This is done via using sbr_fac. */
140140 if (m4a_seek_raw(&demux_res, &input_stream, file_offset,
141141- &sound_samples_done, (int*) &i, &seek_idx)) {
141141+ &sound_samples_done, &i, &seek_idx)) {
142142 sound_samples_done *= sbr_fac;
143143 } else {
144144 sound_samples_done = 0;
···151151 }
152152153153 ci->set_elapsed(elapsed_time);
154154-155155- if (i == 0)
154154+155155+ if (i == 0)
156156 {
157157 lead_trim = ci->id3->lead_trim;
158158 }
···168168 /* Deal with any pending seek requests */
169169 if (action == CODEC_ACTION_SEEK_TIME) {
170170 /* Seek to the desired time position. Important: When seeking in SBR
171171- * upsampling files the seek_time must be divided by 2 when calling
172172- * m4a_seek and the resulting sound_samples_done must be expanded
171171+ * upsampling files the seek_time must be divided by 2 when calling
172172+ * m4a_seek and the resulting sound_samples_done must be expanded
173173 * by a factor 2. This is done via using sbr_fac. */
174174 if (m4a_seek(&demux_res, &input_stream,
175175 (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL,
176176- &sound_samples_done, (int*) &i, &seek_idx)) {
176176+ &sound_samples_done, &i, &seek_idx)) {
177177 sound_samples_done *= sbr_fac;
178178 elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency;
179179 ci->set_elapsed(elapsed_time);
180180181181- if (i == 0)
181181+ if (i == 0)
182182 {
183183 lead_trim = ci->id3->lead_trim;
184184 }
···190190 action = CODEC_ACTION_NULL;
191191192192 /* There can be gaps between chunks, so skip ahead if needed. It
193193- * doesn't seem to happen much, but it probably means that a
193193+ * doesn't seem to happen much, but it probably means that a
194194 * "proper" file can have chunks out of order. Why one would want
195195- * that an good question (but files with gaps do exist, so who
195195+ * that an good question (but files with gaps do exist, so who
196196 * knows?), so we don't support that - for now, at least.
197197 */
198198 file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx);
···219219220220 /* Output the audio */
221221 ci->yield();
222222-222222+223223 frame_samples = frame_info.samples >> 1;
224224225225 if (empty_first_frame)
···238238239239 /* Gather number of samples for the decoded frame. */
240240 framelength = frame_samples - lead_trim;
241241-241241+242242 if (i == demux_res.num_sample_byte_sizes - 1)
243243 {
244244 // Size of the last frame
+13-13
lib/rbcodec/codecs/libm4a/m4a.c
···114114115115/* Check if there is a dedicated byte position contained for the given frame.
116116 * Return this byte position in case of success or return -1. This allows to
117117- * skip empty samples.
118118- * During standard playback the search result (index i) will always increase.
117117+ * skip empty samples.
118118+ * During standard playback the search result (index i) will always increase.
119119 * Therefor we save this index and let the caller set this value again as start
120120- * index when calling m4a_check_sample_offset() for the next frame. This
120120+ * index when calling m4a_check_sample_offset() for the next frame. This
121121 * reduces the overall loop count significantly. */
122122int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
123123{
···139139140140/* Seek to desired sound sample location. Return 1 on success (and modify
141141 * sound_samples_done and current_sample), 0 if failed. */
142142-unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
143143- uint64_t sound_sample_loc, uint64_t* sound_samples_done,
144144- int* current_sample, int* lookup_table_idx)
142142+unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
143143+ uint64_t sound_sample_loc, uint64_t* sound_samples_done,
144144+ uint32_t* current_sample, uint32_t* lookup_table_idx)
145145{
146146 uint32_t i, sample_i;
147147 uint32_t time, time_cnt, time_dur;
···257257 * 1) the lookup_table array contains the file offset for the first sample
258258 * of each chunk.
259259 *
260260- * 2) the time_to_sample array contains the duration (in sound samples)
260260+ * 2) the time_to_sample array contains the duration (in sound samples)
261261 * of each sample of data.
262262 *
263263 * Locate the chunk containing location (using lookup_table), find the first
···265265 * calculate the sound_samples_done value.
266266 */
267267unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream,
268268- uint32_t file_loc, uint64_t* sound_samples_done,
269269- int* current_sample, int* lookup_table_idx)
268268+ uint32_t file_loc, uint64_t* sound_samples_done,
269269+ uint32_t* current_sample, uint32_t* lookup_table_idx)
270270{
271271 uint32_t i;
272272 uint32_t chunk_sample = 0;
···276276 uint32_t tmp_cnt;
277277 uint32_t new_pos;
278278279279- /* We know the desired byte offset, search for the chunk right before.
279279+ /* We know the desired byte offset, search for the chunk right before.
280280 * Return the associated sample to this chunk as chunk_sample. */
281281 for (i=0; i < demux_res->num_lookup_table; ++i)
282282 {
···287287 *lookup_table_idx = i;
288288 chunk_sample = demux_res->lookup_table[i].sample;
289289 new_pos = demux_res->lookup_table[i].offset;
290290-290290+291291 /* Get sound sample offset. */
292292 i = 0;
293293 time_to_sample_t *tab2 = demux_res->time_to_sample;
···306306 }
307307308308 /* Go to the new file position. */
309309- if (stream->ci->seek_buffer(new_pos))
309309+ if (stream->ci->seek_buffer(new_pos))
310310 {
311311 *sound_samples_done = new_sound_sample;
312312 *current_sample = chunk_sample;
313313 return 1;
314314- }
314314+ }
315315316316 return 0;
317317}