38 | 38 |
void *stsc;
|
39 | 39 |
u32_t skip;
|
40 | 40 |
u64_t samples;
|
|
41 |
u64_t sttssamples;
|
41 | 42 |
bool empty;
|
42 | 43 |
struct chunk_table *chunkinfo;
|
43 | 44 |
// faad symbols to be dynamically loaded
|
|
140 | 141 |
LOG_DEBUG("playable aac track: %u", trak);
|
141 | 142 |
play = trak;
|
142 | 143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
// extract the total number of samples from stts
|
|
147 |
if (!strcmp(type, "stts") && bytes > len) {
|
|
148 |
u32_t i;
|
|
149 |
u8_t *ptr = streambuf->readp + 12;
|
|
150 |
u32_t entries = unpackN((u32_t *)ptr);
|
|
151 |
ptr += 4;
|
|
152 |
for (i = 0; i < entries; ++i) {
|
|
153 |
u32_t count = unpackN((u32_t *)ptr);
|
|
154 |
u32_t size = unpackN((u32_t *)(ptr + 4));
|
|
155 |
a->sttssamples += count * size;
|
|
156 |
ptr += 8;
|
|
157 |
}
|
|
158 |
LOG_DEBUG("total number of samples contained in stts: " FMT_u64, a->sttssamples);
|
143 | 159 |
}
|
144 | 160 |
|
145 | 161 |
// stash sample to chunk info, assume it comes before stco
|
|
241 | 257 |
u32_t b, c; u64_t d;
|
242 | 258 |
if (sscanf((const char *)(ptr + 16), "%x %x %x " FMT_x64, &b, &b, &c, &d) == 4) {
|
243 | 259 |
LOG_DEBUG("iTunSMPB start: %u end: %u samples: " FMT_u64, b, c, d);
|
|
260 |
if (a->sttssamples && a->sttssamples < b + c + d) {
|
|
261 |
LOG_DEBUG("reducing samples as stts count is less");
|
|
262 |
d = a->sttssamples - (b + c);
|
|
263 |
}
|
244 | 264 |
a->skip = b;
|
245 | 265 |
a->samples = d;
|
246 | 266 |
}
|
|
266 | 286 |
_buf_inc_readp(streambuf, consume);
|
267 | 287 |
a->pos += consume;
|
268 | 288 |
bytes -= consume;
|
269 | |
} else if (!(!strcmp(type, "esds") || !strcmp(type, "stsc") || !strcmp(type, "stco"))) {
|
|
289 |
} else if ( !(!strcmp(type, "esds") || !strcmp(type, "stts") || !strcmp(type, "stsc") ||
|
|
290 |
!strcmp(type, "stco") || !strcmp(type, "----")) ) {
|
270 | 291 |
LOG_DEBUG("type: %s len: %u consume: %u - partial consume: %u", type, len, consume, bytes);
|
271 | 292 |
_buf_inc_readp(streambuf, bytes);
|
272 | 293 |
a->pos += bytes;
|
|
521 | 542 |
a->stsc = NULL;
|
522 | 543 |
a->skip = 0;
|
523 | 544 |
a->samples = 0;
|
|
545 |
a->sttssamples = 0;
|
524 | 546 |
a->empty = false;
|
525 | 547 |
|
526 | 548 |
if (a->hAac) {
|