Lines Matching defs:alac
26 * @see http://crazney.net/programs/itunes/alac.html
30 * the end of an 'alac' stsd atom and has the following format:
33 * 32bit tag ("alac")
111 static void bastardized_rice_decompress(ALACContext *alac,
135 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
161 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
165 av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count);
355 ALACContext *alac = avctx->priv_data;
366 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
368 channels = get_bits(&alac->gb, 3) + 1;
377 skip_bits(&alac->gb, 4);
379 skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */
382 hassize = get_bits1(&alac->gb);
384 alac->extra_bits = get_bits(&alac->gb, 2) << 3;
387 isnotcompressed = get_bits1(&alac->gb);
391 outputsamples = get_bits_long(&alac->gb, 32);
392 if(outputsamples > alac->setinfo_max_samples_per_frame){
393 av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
397 outputsamples = alac->setinfo_max_samples_per_frame;
404 alac->frame.nb_samples = outputsamples;
405 if ((ret = avctx->get_buffer(avctx, &alac->frame)) < 0) {
410 readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1;
424 interlacing_shift = get_bits(&alac->gb, 8);
425 interlacing_leftweight = get_bits(&alac->gb, 8);
428 prediction_type[ch] = get_bits(&alac->gb, 4);
429 prediction_quantitization[ch] = get_bits(&alac->gb, 4);
431 ricemodifier[ch] = get_bits(&alac->gb, 3);
432 predictor_coef_num[ch] = get_bits(&alac->gb, 5);
436 predictor_coef_table[ch][i] = (int16_t)get_bits(&alac->gb, 16);
439 if (alac->extra_bits) {
442 alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits);
446 bastardized_rice_decompress(alac,
447 alac->predicterror_buffer[ch],
450 alac->setinfo_rice_initialhistory,
451 alac->setinfo_rice_kmodifier,
452 ricemodifier[ch] * alac->setinfo_rice_historymult / 4,
453 (1 << alac->setinfo_rice_kmodifier) - 1);
464 predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],
465 alac->predicterror_buffer[ch],
472 predictor_decompress_fir_adapt(alac->predicterror_buffer[ch],
473 alac->outputsamples_buffer[ch],
483 alac->outputsamples_buffer[ch][i] = get_sbits_long(&alac->gb,
484 alac->setinfo_sample_size);
487 alac->extra_bits = 0;
491 if (get_bits(&alac->gb, 3) != 7)
495 decorrelate_stereo(alac->outputsamples_buffer, outputsamples,
499 if (alac->extra_bits) {
500 append_extra_bits(alac->outputsamples_buffer, alac->extra_bits_buffer,
501 alac->extra_bits, alac->numchannels, outputsamples);
504 switch(alac->setinfo_sample_size) {
507 interleave_stereo_16(alac->outputsamples_buffer,
508 (int16_t *)alac->frame.data[0], outputsamples);
510 int16_t *outbuffer = (int16_t *)alac->frame.data[0];
512 outbuffer[i] = alac->outputsamples_buffer[0][i];
518 interleave_stereo_24(alac->outputsamples_buffer,
519 (int32_t *)alac->frame.data[0], outputsamples);
521 int32_t *outbuffer = (int32_t *)alac->frame.data[0];
523 outbuffer[i] = alac->outputsamples_buffer[0][i] << 8;
528 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
529 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
532 *(AVFrame *)data = alac->frame;
539 ALACContext *alac = avctx->priv_data;
542 for (ch = 0; ch < alac->numchannels; ch++) {
543 av_freep(&alac->predicterror_buffer[ch]);
544 av_freep(&alac->outputsamples_buffer[ch]);
545 av_freep(&alac->extra_bits_buffer[ch]);
551 static int allocate_buffers(ALACContext *alac)
554 for (ch = 0; ch < alac->numchannels; ch++) {
555 int buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t);
557 FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[ch],
560 FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[ch],
563 FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch],
568 alac_decode_close(alac->avctx);
572 static int alac_set_info(ALACContext *alac)
574 const unsigned char *ptr = alac->avctx->extradata;
577 ptr += 4; /* alac */
581 av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
586 alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
588 alac->setinfo_sample_size = *ptr++;
589 alac->setinfo_rice_historymult = *ptr++;
590 alac->setinfo_rice_initialhistory = *ptr++;
591 alac->setinfo_rice_kmodifier = *ptr++;
592 alac->numchannels = *ptr++;
604 ALACContext *alac = avctx->priv_data;
605 alac->avctx = avctx;
608 if (alac->avctx->extradata_size < ALAC_EXTRADATA_SIZE) {
609 av_log(avctx, AV_LOG_ERROR, "alac: extradata is too small\n");
612 if (alac_set_info(alac)) {
613 av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
617 switch (alac->setinfo_sample_size) {
623 alac->setinfo_sample_size);
627 if (alac->numchannels < 1) {
629 alac->numchannels = avctx->channels;
631 if (alac->numchannels > MAX_CHANNELS)
632 alac->numchannels = avctx->channels;
634 avctx->channels = alac->numchannels;
642 if ((ret = allocate_buffers(alac)) < 0) {
647 avcodec_get_frame_defaults(&alac->frame);
648 avctx->coded_frame = &alac->frame;
654 .name = "alac",