61 #define ALAC_EXTRADATA_SIZE 36 
  109                             int nb_samples, 
int bps, 
int rice_history_mult)
 
  113     int sign_modifier = 0;
 
  115     for (i = 0; i < nb_samples; i++) {
 
  123         k = 
av_log2((history >> 9) + 3);
 
  128         output_buffer[i] = (x >> 1) ^ -(x & 1);
 
  134             history +=         x * rice_history_mult -
 
  135                        ((history * rice_history_mult) >> 9);
 
  138         if ((history < 128) && (i + 1 < nb_samples)) {
 
  142             k = 7 - 
av_log2(history) + ((history + 16) >> 6);
 
  146             if (block_size > 0) {
 
  147                 if (block_size >= nb_samples - i) {
 
  149                            "invalid zero block size of %d %d %d\n", block_size,
 
  151                     block_size = nb_samples - i - 1;
 
  153                 memset(&output_buffer[i + 1], 0,
 
  154                        block_size * 
sizeof(*output_buffer));
 
  157             if (block_size <= 0xffff)
 
  171                            int nb_samples, 
int bps, int16_t *lpc_coefs,
 
  172                            int lpc_order, 
int lpc_quant)
 
  178     *buffer_out = *error_buffer;
 
  184         memcpy(&buffer_out[1], &error_buffer[1],
 
  185                (nb_samples - 1) * 
sizeof(*buffer_out));
 
  189     if (lpc_order == 31) {
 
  191         for (i = 1; i < nb_samples; i++) {
 
  192             buffer_out[i] = 
sign_extend(buffer_out[i - 1] + error_buffer[i],
 
  199     for (i = 1; i <= lpc_order && i < nb_samples; i++)
 
  200         buffer_out[i] = 
sign_extend(buffer_out[i - 1] + error_buffer[i], bps);
 
  204     for (; i < nb_samples; i++) {
 
  207         int error_val = error_buffer[i];
 
  212         for (j = 0; j < lpc_order; j++)
 
  213             val += (pred[j] - d) * lpc_coefs[j];
 
  214         val = (val + (1 << (lpc_quant - 1))) >> lpc_quant;
 
  215         val += d + error_val;
 
  221             for (j = 0; j < lpc_order && error_val * error_sign > 0; j++) {
 
  225                 lpc_coefs[j] -= sign;
 
  227                 error_val -= (val >> lpc_quant) * (j + 1);
 
  234                                int decorr_shift, 
int decorr_left_weight)
 
  238     for (i = 0; i < nb_samples; i++) {
 
  244         a -= (b * decorr_left_weight) >> decorr_shift;
 
  257     for (ch = 0; ch < channels; ch++)
 
  258         for (i = 0; i < nb_samples; i++)
 
  259             buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i];
 
  266     int has_size, 
bps, is_compressed, decorr_shift, decorr_left_weight, 
ret;
 
  267     uint32_t output_samples;
 
  301     } 
else if (output_samples != alac->
nb_samples) {
 
  308         for (ch = 0; ch < channels; ch++)
 
  313         int16_t lpc_coefs[2][32];
 
  315         int prediction_type[2];
 
  317         int rice_history_mult[2];
 
  322         for (ch = 0; ch < channels; ch++) {
 
  325             rice_history_mult[ch] = 
get_bits(&alac->
gb, 3);
 
  332             for (i = lpc_order[ch] - 1; i >= 0; i--)
 
  340                 for (ch = 0; ch < channels; ch++)
 
  344         for (ch = 0; ch < channels; ch++) {
 
  352             if (prediction_type[ch] == 15) {
 
  363             } 
else if (prediction_type[ch] > 0) {
 
  365                        prediction_type[ch]);
 
  369                            bps, lpc_coefs[ch], lpc_order[ch], lpc_quant[ch]);
 
  376             for (ch = 0; ch < channels; ch++) {
 
  383         decorr_left_weight = 0;
 
  391     if (channels == 2 && decorr_left_weight) {
 
  393                            decorr_shift, decorr_left_weight);
 
  404         for (ch = 0; ch < channels; ch++) {
 
  405             int16_t *outbuffer = (int16_t *)frame->
extended_data[ch_index + ch];
 
  411         for (ch = 0; ch < channels; ch++) {
 
  420             int16_t *outbuffer = ((int16_t *)frame->
extended_data[0]) + ch_index;
 
  422                 for (ch = 0; ch < channels; ch++)
 
  424                 outbuffer += alac->
channels - channels;
 
  431                 for (ch = 0; ch < channels; ch++)
 
  433                 outbuffer += alac->
channels - channels;
 
  440                 for (ch = 0; ch < channels; ch++)
 
  442                 outbuffer += alac->
channels - channels;
 
  453                              int *got_frame_ptr, 
AVPacket *avpkt)
 
  459     int ch, 
ret, got_end;
 
  478         channels = (element == 
TYPE_CPE) ? 2 : 1;
 
  479         if (ch + channels > alac->
channels ||
 
  533                          buf_size, buf_alloc_fail);
 
  538                              buf_size, buf_alloc_fail);
 
  542                          buf_size, buf_alloc_fail);
 
  563                "max samples per frame invalid: %"PRIu32
"\n",
 
  571     alac->
rice_limit           = bytestream2_get_byteu(&gb);
 
  572     alac->
channels             = bytestream2_get_byteu(&gb);
 
  573     bytestream2_get_be16u(&gb); 
 
  574     bytestream2_get_be32u(&gb); 
 
  575     bytestream2_get_be32u(&gb); 
 
  576     bytestream2_get_be32u(&gb); 
 
  642     { 
"extra_bits_bug", 
"Force non-standard decoding process",
 
  666     .priv_class     = &alac_class