summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rbcodec/codecs/aac.c28
-rw-r--r--lib/rbcodec/codecs/libm4a/m4a.c26
-rw-r--r--lib/rbcodec/codecs/libm4a/m4a.h14
3 files changed, 34 insertions, 34 deletions
diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c
index 11a84cfa24..15c75708e1 100644
--- a/lib/rbcodec/codecs/aac.c
+++ b/lib/rbcodec/codecs/aac.c
@@ -28,7 +28,7 @@
28CODEC_HEADER 28CODEC_HEADER
29 29
30/* The maximum buffer size handled by faad. 12 bytes are required by libfaad 30/* The maximum buffer size handled by faad. 12 bytes are required by libfaad
31 * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered 31 * as headroom (see libfaad/bits.c). FAAD_BYTE_BUFFER_SIZE bytes are buffered
32 * for each frame. */ 32 * for each frame. */
33#define FAAD_BYTE_BUFFER_SIZE (2048-12) 33#define FAAD_BYTE_BUFFER_SIZE (2048-12)
34 34
@@ -62,7 +62,7 @@ enum codec_status codec_run(void)
62 int framelength; 62 int framelength;
63 int lead_trim = 0; 63 int lead_trim = 0;
64 unsigned int frame_samples; 64 unsigned int frame_samples;
65 unsigned int i; 65 uint32_t i;
66 unsigned char* buffer; 66 unsigned char* buffer;
67 NeAACDecFrameInfo frame_info; 67 NeAACDecFrameInfo frame_info;
68 NeAACDecHandle decoder; 68 NeAACDecHandle decoder;
@@ -129,7 +129,7 @@ enum codec_status codec_run(void)
129#endif 129#endif
130 130
131 i = 0; 131 i = 0;
132 132
133 if (param) { 133 if (param) {
134 elapsed_time = param; 134 elapsed_time = param;
135 action = CODEC_ACTION_SEEK_TIME; 135 action = CODEC_ACTION_SEEK_TIME;
@@ -138,7 +138,7 @@ enum codec_status codec_run(void)
138 * upsampling files the resulting sound_samples_done must be expanded 138 * upsampling files the resulting sound_samples_done must be expanded
139 * by a factor of 2. This is done via using sbr_fac. */ 139 * by a factor of 2. This is done via using sbr_fac. */
140 if (m4a_seek_raw(&demux_res, &input_stream, file_offset, 140 if (m4a_seek_raw(&demux_res, &input_stream, file_offset,
141 &sound_samples_done, (int*) &i, &seek_idx)) { 141 &sound_samples_done, &i, &seek_idx)) {
142 sound_samples_done *= sbr_fac; 142 sound_samples_done *= sbr_fac;
143 } else { 143 } else {
144 sound_samples_done = 0; 144 sound_samples_done = 0;
@@ -151,8 +151,8 @@ enum codec_status codec_run(void)
151 } 151 }
152 152
153 ci->set_elapsed(elapsed_time); 153 ci->set_elapsed(elapsed_time);
154 154
155 if (i == 0) 155 if (i == 0)
156 { 156 {
157 lead_trim = ci->id3->lead_trim; 157 lead_trim = ci->id3->lead_trim;
158 } 158 }
@@ -168,17 +168,17 @@ enum codec_status codec_run(void)
168 /* Deal with any pending seek requests */ 168 /* Deal with any pending seek requests */
169 if (action == CODEC_ACTION_SEEK_TIME) { 169 if (action == CODEC_ACTION_SEEK_TIME) {
170 /* Seek to the desired time position. Important: When seeking in SBR 170 /* Seek to the desired time position. Important: When seeking in SBR
171 * upsampling files the seek_time must be divided by 2 when calling 171 * upsampling files the seek_time must be divided by 2 when calling
172 * m4a_seek and the resulting sound_samples_done must be expanded 172 * m4a_seek and the resulting sound_samples_done must be expanded
173 * by a factor 2. This is done via using sbr_fac. */ 173 * by a factor 2. This is done via using sbr_fac. */
174 if (m4a_seek(&demux_res, &input_stream, 174 if (m4a_seek(&demux_res, &input_stream,
175 (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL, 175 (uint64_t) param * ci->id3->frequency / sbr_fac / 1000ULL,
176 &sound_samples_done, (int*) &i, &seek_idx)) { 176 &sound_samples_done, &i, &seek_idx)) {
177 sound_samples_done *= sbr_fac; 177 sound_samples_done *= sbr_fac;
178 elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency; 178 elapsed_time = sound_samples_done * 1000LL / ci->id3->frequency;
179 ci->set_elapsed(elapsed_time); 179 ci->set_elapsed(elapsed_time);
180 180
181 if (i == 0) 181 if (i == 0)
182 { 182 {
183 lead_trim = ci->id3->lead_trim; 183 lead_trim = ci->id3->lead_trim;
184 } 184 }
@@ -190,9 +190,9 @@ enum codec_status codec_run(void)
190 action = CODEC_ACTION_NULL; 190 action = CODEC_ACTION_NULL;
191 191
192 /* There can be gaps between chunks, so skip ahead if needed. It 192 /* There can be gaps between chunks, so skip ahead if needed. It
193 * doesn't seem to happen much, but it probably means that a 193 * doesn't seem to happen much, but it probably means that a
194 * "proper" file can have chunks out of order. Why one would want 194 * "proper" file can have chunks out of order. Why one would want
195 * that an good question (but files with gaps do exist, so who 195 * that an good question (but files with gaps do exist, so who
196 * knows?), so we don't support that - for now, at least. 196 * knows?), so we don't support that - for now, at least.
197 */ 197 */
198 file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx); 198 file_offset = m4a_check_sample_offset(&demux_res, i, &seek_idx);
@@ -219,7 +219,7 @@ enum codec_status codec_run(void)
219 219
220 /* Output the audio */ 220 /* Output the audio */
221 ci->yield(); 221 ci->yield();
222 222
223 frame_samples = frame_info.samples >> 1; 223 frame_samples = frame_info.samples >> 1;
224 224
225 if (empty_first_frame) 225 if (empty_first_frame)
@@ -238,7 +238,7 @@ enum codec_status codec_run(void)
238 238
239 /* Gather number of samples for the decoded frame. */ 239 /* Gather number of samples for the decoded frame. */
240 framelength = frame_samples - lead_trim; 240 framelength = frame_samples - lead_trim;
241 241
242 if (i == demux_res.num_sample_byte_sizes - 1) 242 if (i == demux_res.num_sample_byte_sizes - 1)
243 { 243 {
244 // Size of the last frame 244 // Size of the last frame
diff --git a/lib/rbcodec/codecs/libm4a/m4a.c b/lib/rbcodec/codecs/libm4a/m4a.c
index 6adc58dab0..295c39c5ff 100644
--- a/lib/rbcodec/codecs/libm4a/m4a.c
+++ b/lib/rbcodec/codecs/libm4a/m4a.c
@@ -114,10 +114,10 @@ void stream_create(stream_t *stream,struct codec_api* ci)
114 114
115/* Check if there is a dedicated byte position contained for the given frame. 115/* Check if there is a dedicated byte position contained for the given frame.
116 * Return this byte position in case of success or return -1. This allows to 116 * Return this byte position in case of success or return -1. This allows to
117 * skip empty samples. 117 * skip empty samples.
118 * During standard playback the search result (index i) will always increase. 118 * During standard playback the search result (index i) will always increase.
119 * Therefor we save this index and let the caller set this value again as start 119 * Therefor we save this index and let the caller set this value again as start
120 * index when calling m4a_check_sample_offset() for the next frame. This 120 * index when calling m4a_check_sample_offset() for the next frame. This
121 * reduces the overall loop count significantly. */ 121 * reduces the overall loop count significantly. */
122int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start) 122int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start)
123{ 123{
@@ -139,9 +139,9 @@ int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *st
139 139
140/* Seek to desired sound sample location. Return 1 on success (and modify 140/* Seek to desired sound sample location. Return 1 on success (and modify
141 * sound_samples_done and current_sample), 0 if failed. */ 141 * sound_samples_done and current_sample), 0 if failed. */
142unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream, 142unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
143 uint64_t sound_sample_loc, uint64_t* sound_samples_done, 143 uint64_t sound_sample_loc, uint64_t* sound_samples_done,
144 int* current_sample, int* lookup_table_idx) 144 uint32_t* current_sample, uint32_t* lookup_table_idx)
145{ 145{
146 uint32_t i, sample_i; 146 uint32_t i, sample_i;
147 uint32_t time, time_cnt, time_dur; 147 uint32_t time, time_cnt, time_dur;
@@ -257,7 +257,7 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
257 * 1) the lookup_table array contains the file offset for the first sample 257 * 1) the lookup_table array contains the file offset for the first sample
258 * of each chunk. 258 * of each chunk.
259 * 259 *
260 * 2) the time_to_sample array contains the duration (in sound samples) 260 * 2) the time_to_sample array contains the duration (in sound samples)
261 * of each sample of data. 261 * of each sample of data.
262 * 262 *
263 * Locate the chunk containing location (using lookup_table), find the first 263 * Locate the chunk containing location (using lookup_table), find the first
@@ -265,8 +265,8 @@ unsigned int m4a_seek(demux_res_t* demux_res, stream_t* stream,
265 * calculate the sound_samples_done value. 265 * calculate the sound_samples_done value.
266 */ 266 */
267unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream, 267unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream,
268 uint32_t file_loc, uint64_t* sound_samples_done, 268 uint32_t file_loc, uint64_t* sound_samples_done,
269 int* current_sample, int* lookup_table_idx) 269 uint32_t* current_sample, uint32_t* lookup_table_idx)
270{ 270{
271 uint32_t i; 271 uint32_t i;
272 uint32_t chunk_sample = 0; 272 uint32_t chunk_sample = 0;
@@ -276,7 +276,7 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream,
276 uint32_t tmp_cnt; 276 uint32_t tmp_cnt;
277 uint32_t new_pos; 277 uint32_t new_pos;
278 278
279 /* We know the desired byte offset, search for the chunk right before. 279 /* We know the desired byte offset, search for the chunk right before.
280 * Return the associated sample to this chunk as chunk_sample. */ 280 * Return the associated sample to this chunk as chunk_sample. */
281 for (i=0; i < demux_res->num_lookup_table; ++i) 281 for (i=0; i < demux_res->num_lookup_table; ++i)
282 { 282 {
@@ -287,7 +287,7 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream,
287 *lookup_table_idx = i; 287 *lookup_table_idx = i;
288 chunk_sample = demux_res->lookup_table[i].sample; 288 chunk_sample = demux_res->lookup_table[i].sample;
289 new_pos = demux_res->lookup_table[i].offset; 289 new_pos = demux_res->lookup_table[i].offset;
290 290
291 /* Get sound sample offset. */ 291 /* Get sound sample offset. */
292 i = 0; 292 i = 0;
293 time_to_sample_t *tab2 = demux_res->time_to_sample; 293 time_to_sample_t *tab2 = demux_res->time_to_sample;
@@ -306,12 +306,12 @@ unsigned int m4a_seek_raw(demux_res_t* demux_res, stream_t* stream,
306 } 306 }
307 307
308 /* Go to the new file position. */ 308 /* Go to the new file position. */
309 if (stream->ci->seek_buffer(new_pos)) 309 if (stream->ci->seek_buffer(new_pos))
310 { 310 {
311 *sound_samples_done = new_sound_sample; 311 *sound_samples_done = new_sound_sample;
312 *current_sample = chunk_sample; 312 *current_sample = chunk_sample;
313 return 1; 313 return 1;
314 } 314 }
315 315
316 return 0; 316 return 0;
317} 317}
diff --git a/lib/rbcodec/codecs/libm4a/m4a.h b/lib/rbcodec/codecs/libm4a/m4a.h
index bcc32f53bb..7120f8b4c6 100644
--- a/lib/rbcodec/codecs/libm4a/m4a.h
+++ b/lib/rbcodec/codecs/libm4a/m4a.h
@@ -45,13 +45,13 @@ typedef struct {
45 45
46typedef uint32_t fourcc_t; 46typedef uint32_t fourcc_t;
47 47
48typedef struct 48typedef struct
49{ 49{
50 uint32_t first_chunk; 50 uint32_t first_chunk;
51 uint32_t num_samples; 51 uint32_t num_samples;
52} sample_to_chunk_t; 52} sample_to_chunk_t;
53 53
54typedef struct 54typedef struct
55{ 55{
56 uint32_t sample_count; 56 uint32_t sample_count;
57 uint32_t sample_duration; 57 uint32_t sample_duration;
@@ -73,10 +73,10 @@ typedef struct
73 73
74 int32_t sample_to_chunk_offset; 74 int32_t sample_to_chunk_offset;
75 uint32_t num_sample_to_chunks; 75 uint32_t num_sample_to_chunks;
76 76
77 sample_offset_t *lookup_table; 77 sample_offset_t *lookup_table;
78 uint32_t num_lookup_table; 78 uint32_t num_lookup_table;
79 79
80 time_to_sample_t *time_to_sample; 80 time_to_sample_t *time_to_sample;
81 uint32_t num_time_to_samples; 81 uint32_t num_time_to_samples;
82 82
@@ -130,10 +130,10 @@ int stream_eof(stream_t *stream);
130void stream_create(stream_t *stream,struct codec_api* ci); 130void stream_create(stream_t *stream,struct codec_api* ci);
131unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample); 131unsigned int get_sample_offset(demux_res_t *demux_res, uint32_t sample);
132unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream, 132unsigned int m4a_seek (demux_res_t* demux_res, stream_t* stream,
133 uint64_t sound_sample_loc, uint64_t* sound_samples_done, 133 uint64_t sound_sample_loc, uint64_t* sound_samples_done,
134 int* current_sample, int* lookup_table_idx); 134 uint32_t* current_sample, uint32_t* lookup_table_idx);
135unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream, 135unsigned int m4a_seek_raw (demux_res_t* demux_res, stream_t* stream,
136 uint32_t file_loc, uint64_t* sound_samples_done, int* current_sample, int* lookup_table_idx); 136 uint32_t file_loc, uint64_t* sound_samples_done, uint32_t* current_sample, uint32_t* lookup_table_idx);
137int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start); 137int m4a_check_sample_offset(demux_res_t *demux_res, uint32_t frame, uint32_t *start);
138 138
139#endif /* STREAM_H */ 139#endif /* STREAM_H */