Lines Matching defs:alac
23 * @file libavcodec/alac.c
28 * http://crazney.net/programs/itunes/alac.html
32 * the end of an 'alac' stsd atom and has the following format:
34 * bytes 4-7 atom type ('alac', not the 'alac' tag from start of stsd)
39 * 32bit tag (=alac)
89 static void allocate_buffers(ALACContext *alac)
93 alac->predicterror_buffer[chan] =
94 av_malloc(alac->setinfo_max_samples_per_frame * 4);
96 alac->outputsamples_buffer[chan] =
97 av_malloc(alac->setinfo_max_samples_per_frame * 4);
101 static int alac_set_info(ALACContext *alac)
103 const unsigned char *ptr = alac->avctx->extradata;
106 ptr += 4; /* alac */
110 av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
115 alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
117 alac->setinfo_sample_size = *ptr++;
118 if (alac->setinfo_sample_size > 32) {
119 av_log(alac->avctx, AV_LOG_ERROR, "setinfo_sample_size too large\n");
122 alac->setinfo_rice_historymult = *ptr++;
123 alac->setinfo_rice_initialhistory = *ptr++;
124 alac->setinfo_rice_kmodifier = *ptr++;
131 allocate_buffers(alac);
163 static void bastardized_rice_decompress(ALACContext *alac,
187 x= decode_scalar(&alac->gb, k, rice_kmodifier, readsamplesize);
213 block_size= decode_scalar(&alac->gb, k, rice_kmodifier, 16);
217 av_log(alac->avctx, AV_LOG_ERROR, "invalid zero block size of %d %d %d\n", block_size, output_size, output_count);
409 ALACContext *alac = avctx->priv_data;
425 if (!alac->context_initialized) {
426 if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
427 av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
431 if (alac_set_info(alac)) {
432 av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
435 alac->context_initialized = 1;
438 init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
440 channels = get_bits(&alac->gb, 3) + 1;
450 skip_bits(&alac->gb, 4);
452 skip_bits(&alac->gb, 12); /* unknown, skip 12 bits */
455 hassize = get_bits1(&alac->gb);
457 wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
460 isnotcompressed = get_bits1(&alac->gb);
464 outputsamples = get_bits_long(&alac->gb, 32);
465 if(outputsamples > alac->setinfo_max_samples_per_frame){
466 av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
470 outputsamples = alac->setinfo_max_samples_per_frame;
472 if(outputsamples > *outputsize / alac->bytespersample){
477 *outputsize = outputsamples * alac->bytespersample;
478 readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1;
493 interlacing_shift = get_bits(&alac->gb, 8);
494 interlacing_leftweight = get_bits(&alac->gb, 8);
497 prediction_type[chan] = get_bits(&alac->gb, 4);
498 prediction_quantitization[chan] = get_bits(&alac->gb, 4);
500 ricemodifier[chan] = get_bits(&alac->gb, 3);
501 predictor_coef_num[chan] = get_bits(&alac->gb, 5);
505 predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
512 bastardized_rice_decompress(alac,
513 alac->predicterror_buffer[chan],
516 alac->setinfo_rice_initialhistory,
517 alac->setinfo_rice_kmodifier,
518 ricemodifier[chan] * alac->setinfo_rice_historymult / 4,
519 (1 << alac->setinfo_rice_kmodifier) - 1);
523 predictor_decompress_fir_adapt(alac->predicterror_buffer[chan],
524 alac->outputsamples_buffer[chan],
547 audiobits = get_bits_long(&alac->gb, alac->setinfo_sample_size);
548 audiobits = extend_sign32(audiobits, alac->setinfo_sample_size);
550 alac->outputsamples_buffer[chan][i] = audiobits;
556 if (get_bits(&alac->gb, 3) != 7)
559 switch(alac->setinfo_sample_size) {
562 reconstruct_stereo_16(alac->outputsamples_buffer,
564 alac->numchannels,
571 int16_t sample = alac->outputsamples_buffer[0][i];
572 ((int16_t*)outbuffer)[i * alac->numchannels] = sample;
581 av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
587 if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
588 av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
595 ALACContext *alac = avctx->priv_data;
596 alac->avctx = avctx;
597 alac->context_initialized = 0;
599 alac->numchannels = alac->avctx->channels;
600 alac->bytespersample = 2 * alac->numchannels;
608 ALACContext *alac = avctx->priv_data;
612 av_free(alac->predicterror_buffer[chan]);
613 av_free(alac->outputsamples_buffer[chan]);
620 "alac",