- }
- case 1: { /* 2 channels */
- int hassize;
- int isnotcompressed;
- int readsamplesize;
-
- int wasted_bytes;
-
- uint8_t interlacing_shift;
- uint8_t interlacing_leftweight;
-
- /* 2^result = something to do with output waiting.
- * perhaps matters if we read > 1 frame in a pass?
- */
- get_bits(&alac->gb, 4);
-
- get_bits(&alac->gb, 12); /* unknown, skip 12 bits */
-
- hassize = get_bits(&alac->gb, 1); /* the output sample size is stored soon */
-
- wasted_bytes = get_bits(&alac->gb, 2); /* unknown ? */
-
- isnotcompressed = get_bits(&alac->gb, 1); /* whether the frame is compressed */
-
- if (hassize) {
- /* now read the number of samples,
- * as a 32bit integer */
- outputsamples = get_bits(&alac->gb, 32);
- *outputsize = outputsamples * alac->bytespersample;
- }
-
- readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + 1;
-
- if (!isnotcompressed) {
- /* compressed */
- int16_t predictor_coef_table_a[32];
- int predictor_coef_num_a;
- int prediction_type_a;
- int prediction_quantitization_a;
- int ricemodifier_a;
-
- int16_t predictor_coef_table_b[32];
- int predictor_coef_num_b;
- int prediction_type_b;
- int prediction_quantitization_b;
- int ricemodifier_b;
-
- int i;
-
- interlacing_shift = get_bits(&alac->gb, 8);
- interlacing_leftweight = get_bits(&alac->gb, 8);
-
- /******** channel 1 ***********/
- prediction_type_a = get_bits(&alac->gb, 4);
- prediction_quantitization_a = get_bits(&alac->gb, 4);
-
- ricemodifier_a = get_bits(&alac->gb, 3);
- predictor_coef_num_a = get_bits(&alac->gb, 5);
-
- /* read the predictor table */
- for (i = 0; i < predictor_coef_num_a; i++) {
- predictor_coef_table_a[i] = (int16_t)get_bits(&alac->gb, 16);
- }
-
- /******** channel 2 *********/
- prediction_type_b = get_bits(&alac->gb, 4);
- prediction_quantitization_b = get_bits(&alac->gb, 4);
-
- ricemodifier_b = get_bits(&alac->gb, 3);
- predictor_coef_num_b = get_bits(&alac->gb, 5);
-
- /* read the predictor table */
- for (i = 0; i < predictor_coef_num_b; i++) {
- predictor_coef_table_b[i] = (int16_t)get_bits(&alac->gb, 16);
- }
-
- /*********************/
- if (wasted_bytes) {
- /* see mono case */
- av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n");
- }
-
- /* channel 1 */
- bastardized_rice_decompress(alac,
- alac->predicterror_buffer_a,
- outputsamples,
- readsamplesize,
- alac->setinfo_rice_initialhistory,
- alac->setinfo_rice_kmodifier,
- ricemodifier_a * alac->setinfo_rice_historymult / 4,
- (1 << alac->setinfo_rice_kmodifier) - 1);
-
- if (prediction_type_a == 0) {
- /* adaptive fir */
- predictor_decompress_fir_adapt(alac->predicterror_buffer_a,
- alac->outputsamples_buffer_a,
- outputsamples,
- readsamplesize,
- predictor_coef_table_a,
- predictor_coef_num_a,
- prediction_quantitization_a);
- } else {
- /* see mono case */
- av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_a);
- }
-
- /* channel 2 */
- bastardized_rice_decompress(alac,
- alac->predicterror_buffer_b,
- outputsamples,
- readsamplesize,
- alac->setinfo_rice_initialhistory,
- alac->setinfo_rice_kmodifier,
- ricemodifier_b * alac->setinfo_rice_historymult / 4,
- (1 << alac->setinfo_rice_kmodifier) - 1);
-
- if (prediction_type_b == 0) {
- /* adaptive fir */
- predictor_decompress_fir_adapt(alac->predicterror_buffer_b,
- alac->outputsamples_buffer_b,
- outputsamples,
- readsamplesize,
- predictor_coef_table_b,
- predictor_coef_num_b,
- prediction_quantitization_b);
- } else {
- av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type_b);
- }