Lines Matching defs:chctx

88     IMCChannel chctx[2];
222 q->chctx[j].decoder_reset = 1;
225 q->chctx[j].old_floor[i] = 1.0;
228 q->chctx[j].last_fft_im[i] = 0;
456 static int bit_allocation(IMCContext *q, IMCChannel *chctx,
476 highest = FFMAX(highest, chctx->flcoeffs1[i]);
479 if (chctx->flcoeffs5[i] <= 0) {
480 av_log(q->avctx, AV_LOG_ERROR, "flcoeffs5 %f invalid\n", chctx->flcoeffs5[i]);
483 chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
485 chctx->flcoeffs4[BANDS - 1] = limit;
491 if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
494 if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
497 if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
503 chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
507 chctx->flcoeffs4[0] = limit;
508 chctx->flcoeffs4[1] = limit;
509 chctx->flcoeffs4[2] = limit;
510 chctx->flcoeffs4[3] = limit;
514 iacc += chctx->bandWidthT[i];
515 summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
521 chctx->bandWidthT[BANDS - 1] = 0;
534 cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
536 chctx->bitsBandT[j] = cwlen;
537 summer += chctx->bandWidthT[j] * cwlen;
540 iacc += chctx->bandWidthT[j];
557 chctx->CWlengthT[j] = chctx->bitsBandT[i];
562 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
563 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
584 if (++chctx->bitsBandT[found_indx] == 6)
588 chctx->CWlengthT[j]++;
596 workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
618 if (!--chctx->bitsBandT[low_indx])
622 if (chctx->CWlengthT[j] > 0) {
623 chctx->CWlengthT[j]--;
632 static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx)
636 memset(chctx->skipFlagBits, 0, sizeof(chctx->skipFlagBits));
637 memset(chctx->skipFlagCount, 0, sizeof(chctx->skipFlagCount));
639 if (!chctx->bandFlagsBuf[i] || !chctx->bandWidthT[i])
642 if (!chctx->skipFlagRaw[i]) {
643 chctx->skipFlagBits[i] = band_tab[i + 1] - band_tab[i];
646 chctx->skipFlags[j] = get_bits1(&q->gb);
647 if (chctx->skipFlags[j])
648 chctx->skipFlagCount[i]++;
653 chctx->skipFlagBits[i]++;
654 chctx->skipFlags[j] = 1;
655 chctx->skipFlags[j + 1] = 1;
656 chctx->skipFlagCount[i] += 2;
659 chctx->skipFlagBits[i] += 2;
660 chctx->skipFlags[j] = 0;
661 chctx->skipFlags[j + 1] = 1;
662 chctx->skipFlagCount[i]++;
664 chctx->skipFlagBits[i] += 3;
665 chctx->skipFlags[j + 1] = 0;
667 chctx->skipFlags[j] = 1;
668 chctx->skipFlagCount[i]++;
670 chctx->skipFlags[j] = 0;
677 chctx->skipFlagBits[i]++;
678 if ((chctx->skipFlags[j] = get_bits1(&q->gb)))
679 chctx->skipFlagCount[i]++;
688 static void imc_adjust_bit_allocation(IMCContext *q, IMCChannel *chctx,
698 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
699 : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
717 if (++(chctx->bitsBandT[found_indx]) == 6)
721 if (!chctx->skipFlags[j] && (chctx->CWlengthT[j] < 6)) {
722 chctx->CWlengthT[j]++;
730 static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels)
739 q->samples[i].re = -(q->pre_coef1[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) -
740 (q->pre_coef2[i] * chctx->CWdecoded[i * 2]);
741 q->samples[i].im = (q->pre_coef2[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) -
742 (q->pre_coef1[i] * chctx->CWdecoded[i * 2]);
753 *dst1 = (q->mdct_sine_window[COEFFS - 1 - i * 2] * chctx->last_fft_im[i])
755 *dst2 = (q->mdct_sine_window[i * 2] * chctx->last_fft_im[i])
759 chctx->last_fft_im[i] = im;
763 static int inverse_quant_coeff(IMCContext *q, IMCChannel *chctx,
772 chctx->CWdecoded[j] = 0;
773 cw_len = chctx->CWlengthT[j];
775 if (cw_len <= 0 || chctx->skipFlags[j])
781 if (chctx->codewords[j] >= max_size || chctx->codewords[j] < 0)
786 if (chctx->codewords[j] >= middle_value)
787 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 8] * chctx->flcoeffs6[i];
789 chctx->CWdecoded[j] = -quantizer[max_size - chctx->codewords[j] - 8 - 1] * chctx->flcoeffs6[i];
791 quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (chctx->bandFlagsBuf[i] << 1)];
792 if (chctx->codewords[j] >= middle_value)
793 chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 1] * chctx->flcoeffs6[i];
795 chctx->CWdecoded[j] = -quantizer[max_size - 2 - chctx->codewords[j]] * chctx->flcoeffs6[i];
804 IMCContext *q, IMCChannel *chctx)
809 if (!chctx->sumLenArr[i])
811 if (chctx->bandFlagsBuf[i] || chctx->bandWidthT[i]) {
813 cw_len = chctx->CWlengthT[j];
816 if (cw_len && (!chctx->bandFlagsBuf[i] || !chctx->skipFlags[j])) {
825 chctx->codewords[j] = cw;
831 static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx)
837 chctx->sumLenArr[i] = 0;
838 chctx->skipFlagRaw[i] = 0;
840 chctx->sumLenArr[i] += chctx->CWlengthT[j];
841 if (chctx->bandFlagsBuf[i])
842 if (((int)((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] > 0))
843 chctx->skipFlagRaw[i] = 1;
846 imc_get_skip_coeff(q, chctx);
849 chctx->flcoeffs6[i] = chctx->flcoeffs1[i];
851 if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) {
852 chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] /
853 q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])];
861 if (chctx->bandFlagsBuf[i]) {
863 if (chctx->skipFlags[j]) {
864 summer += chctx->CWlengthT[j];
865 chctx->CWlengthT[j] = 0;
868 summer -= chctx->skipFlagBits[i];
871 imc_adjust_bit_allocation(q, chctx, summer);
881 IMCChannel *chctx = q->chctx + ch;
894 chctx->decoder_reset = 1;
896 if (chctx->decoder_reset) {
898 chctx->old_floor[i] = 1.0;
900 chctx->CWdecoded[i] = 0;
901 chctx->decoder_reset = 0;
906 imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf);
908 imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf);
911 imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf,
912 chctx->flcoeffs1, chctx->flcoeffs2);
914 imc_decode_level_coefficients(q, chctx->levlCoeffBuf,
915 chctx->flcoeffs1, chctx->flcoeffs2);
917 imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor,
918 chctx->flcoeffs1, chctx->flcoeffs2);
921 if(chctx->flcoeffs1[i] > INT_MAX) {
927 memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float));
931 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
932 chctx->bandFlagsBuf[i] = 0;
933 chctx->flcoeffs3[i] = chctx->flcoeffs2[i] * 2;
934 chctx->flcoeffs5[i] = 1.0;
938 if (chctx->levlCoeffBuf[i] == 16) {
939 chctx->bandWidthT[i] = 0;
941 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i];
944 memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int));
946 if (chctx->bandWidthT[i])
947 chctx->bandFlagsBuf[i] = get_bits1(&q->gb);
949 imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2,
950 chctx->bandWidthT, chctx->flcoeffs3,
951 chctx->flcoeffs5);
959 chctx->bitsBandT[0] = 5;
960 chctx->CWlengthT[0] = 5;
961 chctx->CWlengthT[1] = 5;
962 chctx->CWlengthT[2] = 5;
967 bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5;
968 chctx->bitsBandT[i] = bits;
970 chctx->CWlengthT[j] = bits;
976 bitscount += !!chctx->bandWidthT[BANDS - 1];
981 if ((ret = bit_allocation(q, chctx, stream_format_code,
985 chctx->decoder_reset = 1;
991 chctx->skipFlags[i] = 0;
993 imc_refine_bit_allocation(q, chctx);
997 chctx->sumLenArr[i] = 0;
1000 if (!chctx->skipFlags[j])
1001 chctx->sumLenArr[i] += chctx->CWlengthT[j];
1004 memset(chctx->codewords, 0, sizeof(chctx->codewords));
1006 imc_get_coeffs(avctx, q, chctx);
1008 if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) {
1010 chctx->decoder_reset = 1;
1014 memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags));
1016 imc_imdct256(q, chctx, avctx->ch_layout.nb_channels);
1080 q->chctx[0].decoder_reset =
1081 q->chctx[1].decoder_reset = 1;