Lines Matching defs:ape
158 APEContext *ape = s->priv_data;
166 ape->junklength = avio_tell(pb);
172 ape->fileversion = avio_rl16(pb);
174 if (ape->fileversion < APE_MIN_VERSION || ape->fileversion > APE_MAX_VERSION) {
176 ape->fileversion / 1000, (ape->fileversion % 1000) / 10);
180 if (ape->fileversion >= 3980) {
181 ape->padding1 = avio_rl16(pb);
182 ape->descriptorlength = avio_rl32(pb);
183 ape->headerlength = avio_rl32(pb);
184 ape->seektablelength = avio_rl32(pb);
185 ape->wavheaderlength = avio_rl32(pb);
186 ape->audiodatalength = avio_rl32(pb);
187 ape->audiodatalength_high = avio_rl32(pb);
188 ape->wavtaillength = avio_rl32(pb);
189 avio_read(pb, ape->md5, 16);
193 if (ape->descriptorlength > 52)
194 avio_skip(pb, ape->descriptorlength - 52);
197 ape->compressiontype = avio_rl16(pb);
198 ape->formatflags = avio_rl16(pb);
199 ape->blocksperframe = avio_rl32(pb);
200 ape->finalframeblocks = avio_rl32(pb);
201 ape->totalframes = avio_rl32(pb);
202 ape->bps = avio_rl16(pb);
203 ape->channels = avio_rl16(pb);
204 ape->samplerate = avio_rl32(pb);
206 ape->descriptorlength = 0;
207 ape->headerlength = 32;
209 ape->compressiontype = avio_rl16(pb);
210 ape->formatflags = avio_rl16(pb);
211 ape->channels = avio_rl16(pb);
212 ape->samplerate = avio_rl32(pb);
213 ape->wavheaderlength = avio_rl32(pb);
214 ape->wavtaillength = avio_rl32(pb);
215 ape->totalframes = avio_rl32(pb);
216 ape->finalframeblocks = avio_rl32(pb);
218 if (ape->formatflags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) {
220 ape->headerlength += 4;
223 if (ape->formatflags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) {
224 ape->seektablelength = avio_rl32(pb);
225 ape->headerlength += 4;
226 ape->seektablelength *= sizeof(int32_t);
228 ape->seektablelength = ape->totalframes * sizeof(int32_t);
230 if (ape->formatflags & MAC_FORMAT_FLAG_8_BIT)
231 ape->bps = 8;
232 else if (ape->formatflags & MAC_FORMAT_FLAG_24_BIT)
233 ape->bps = 24;
235 ape->bps = 16;
237 if (ape->fileversion >= 3950)
238 ape->blocksperframe = 73728 * 4;
239 else if (ape->fileversion >= 3900 || (ape->fileversion >= 3800 && ape->compressiontype >= 4000))
240 ape->blocksperframe = 73728;
242 ape->blocksperframe = 9216;
245 if (!(ape->formatflags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER))
246 avio_skip(pb, ape->wavheaderlength);
249 if(!ape->totalframes){
253 if(ape->totalframes > UINT_MAX / sizeof(APEFrame)){
255 ape->totalframes);
258 if (ape->seektablelength && (ape->seektablelength / sizeof(*ape->seektable)) < ape->totalframes) {
261 ape->seektablelength / sizeof(*ape->seektable), ape->totalframes);
264 ape->frames = av_malloc(ape->totalframes * sizeof(APEFrame));
265 if(!ape->frames)
267 ape->firstframe = ape->junklength + ape->descriptorlength + ape->headerlength + ape->seektablelength + ape->wavheaderlength;
268 ape->currentframe = 0;
271 ape->totalsamples = ape->finalframeblocks;
272 if (ape->totalframes > 1)
273 ape->totalsamples += ape->blocksperframe * (ape->totalframes - 1);
275 if (ape->seektablelength > 0) {
276 ape->seektable = av_malloc(ape->seektablelength);
277 if (!ape->seektable)
279 for (i = 0; i < ape->seektablelength / sizeof(uint32_t); i++)
280 ape->seektable[i] = avio_rl32(pb);
283 ape->frames[0].pos = ape->firstframe;
284 ape->frames[0].nblocks = ape->blocksperframe;
285 ape->frames[0].skip = 0;
286 for (i = 1; i < ape->totalframes; i++) {
287 ape->frames[i].pos = ape->seektable[i] + ape->junklength;
288 ape->frames[i].nblocks = ape->blocksperframe;
289 ape->frames[i - 1].size = ape->frames[i].pos - ape->frames[i - 1].pos;
290 ape->frames[i].skip = (ape->frames[i].pos - ape->frames[0].pos) & 3;
292 ape->frames[ape->totalframes - 1].size = ape->finalframeblocks * 4;
293 ape->frames[ape->totalframes - 1].nblocks = ape->finalframeblocks;
295 for (i = 0; i < ape->totalframes; i++) {
296 if(ape->frames[i].skip){
297 ape->frames[i].pos -= ape->frames[i].skip;
298 ape->frames[i].size += ape->frames[i].skip;
300 ape->frames[i].size = (ape->frames[i].size + 3) & ~3;
304 ape_dumpinfo(s, ape);
313 ape->fileversion / 1000, (ape->fileversion % 1000) / 10,
314 ape->compressiontype);
321 total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
326 st->codec->channels = ape->channels;
327 st->codec->sample_rate = ape->samplerate;
328 st->codec->bits_per_coded_sample = ape->bps;
331 st->nb_frames = ape->totalframes;
334 avpriv_set_pts_info(st, 64, MAC_SUBFRAME_SIZE, ape->samplerate);
338 AV_WL16(st->codec->extradata + 0, ape->fileversion);
339 AV_WL16(st->codec->extradata + 2, ape->compressiontype);
340 AV_WL16(st->codec->extradata + 4, ape->formatflags);
343 for (i = 0; i < ape->totalframes; i++) {
344 ape->frames[i].pts = pts;
345 av_add_index_entry(st, ape->frames[i].pos, ape->frames[i].pts, 0, 0, AVINDEX_KEYFRAME);
346 pts += ape->blocksperframe / MAC_SUBFRAME_SIZE;
356 APEContext *ape = s->priv_data;
361 if (ape->currentframe > ape->totalframes)
364 avio_seek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET);
367 if (ape->currentframe == (ape->totalframes - 1))
368 nblocks = ape->finalframeblocks;
370 nblocks = ape->blocksperframe;
372 if (av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size) < 0)
376 AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip);
377 ret = avio_read(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size);
379 pkt->pts = ape->frames[ape->currentframe].pts;
386 ape->currentframe++;
393 APEContext *ape = s->priv_data;
395 av_freep(&ape->frames);
396 av_freep(&ape->seektable);
403 APEContext *ape = s->priv_data;
409 ape->currentframe = index;
414 .name = "ape",
422 .extensions = "ape,apl,mac"