• Home
  • Raw
  • Download

Lines Matching refs:chctx

86     IMCChannel chctx[2];  member
218 q->chctx[j].decoder_reset = 1; in imc_decode_init()
221 q->chctx[j].old_floor[i] = 1.0; in imc_decode_init()
224 q->chctx[j].last_fft_im[i] = 0; in imc_decode_init()
454 static int bit_allocation(IMCContext *q, IMCChannel *chctx, in bit_allocation() argument
474 highest = FFMAX(highest, chctx->flcoeffs1[i]); in bit_allocation()
477 if (chctx->flcoeffs5[i] <= 0) { in bit_allocation()
478 av_log(q->avctx, AV_LOG_ERROR, "flcoeffs5 %f invalid\n", chctx->flcoeffs5[i]); in bit_allocation()
481 chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]); in bit_allocation()
483 chctx->flcoeffs4[BANDS - 1] = limit; in bit_allocation()
489 if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i]) in bit_allocation()
492 if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i]) in bit_allocation()
495 if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i]) in bit_allocation()
501 chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag]; in bit_allocation()
505 chctx->flcoeffs4[0] = limit; in bit_allocation()
506 chctx->flcoeffs4[1] = limit; in bit_allocation()
507 chctx->flcoeffs4[2] = limit; in bit_allocation()
508 chctx->flcoeffs4[3] = limit; in bit_allocation()
512 iacc += chctx->bandWidthT[i]; in bit_allocation()
513 summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; in bit_allocation()
519 chctx->bandWidthT[BANDS - 1] = 0; in bit_allocation()
532 cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6); in bit_allocation()
534 chctx->bitsBandT[j] = cwlen; in bit_allocation()
535 summer += chctx->bandWidthT[j] * cwlen; in bit_allocation()
538 iacc += chctx->bandWidthT[j]; in bit_allocation()
555 chctx->CWlengthT[j] = chctx->bitsBandT[i]; in bit_allocation()
560 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 in bit_allocation()
561 … : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); in bit_allocation()
582 if (++chctx->bitsBandT[found_indx] == 6) in bit_allocation()
586 chctx->CWlengthT[j]++; in bit_allocation()
594 … workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585) in bit_allocation()
616 if (!--chctx->bitsBandT[low_indx]) in bit_allocation()
620 if (chctx->CWlengthT[j] > 0) { in bit_allocation()
621 chctx->CWlengthT[j]--; in bit_allocation()
630 static void imc_get_skip_coeff(IMCContext *q, IMCChannel *chctx) in imc_get_skip_coeff() argument
634 memset(chctx->skipFlagBits, 0, sizeof(chctx->skipFlagBits)); in imc_get_skip_coeff()
635 memset(chctx->skipFlagCount, 0, sizeof(chctx->skipFlagCount)); in imc_get_skip_coeff()
637 if (!chctx->bandFlagsBuf[i] || !chctx->bandWidthT[i]) in imc_get_skip_coeff()
640 if (!chctx->skipFlagRaw[i]) { in imc_get_skip_coeff()
641 chctx->skipFlagBits[i] = band_tab[i + 1] - band_tab[i]; in imc_get_skip_coeff()
644 chctx->skipFlags[j] = get_bits1(&q->gb); in imc_get_skip_coeff()
645 if (chctx->skipFlags[j]) in imc_get_skip_coeff()
646 chctx->skipFlagCount[i]++; in imc_get_skip_coeff()
651 chctx->skipFlagBits[i]++; in imc_get_skip_coeff()
652 chctx->skipFlags[j] = 1; in imc_get_skip_coeff()
653 chctx->skipFlags[j + 1] = 1; in imc_get_skip_coeff()
654 chctx->skipFlagCount[i] += 2; in imc_get_skip_coeff()
657 chctx->skipFlagBits[i] += 2; in imc_get_skip_coeff()
658 chctx->skipFlags[j] = 0; in imc_get_skip_coeff()
659 chctx->skipFlags[j + 1] = 1; in imc_get_skip_coeff()
660 chctx->skipFlagCount[i]++; in imc_get_skip_coeff()
662 chctx->skipFlagBits[i] += 3; in imc_get_skip_coeff()
663 chctx->skipFlags[j + 1] = 0; in imc_get_skip_coeff()
665 chctx->skipFlags[j] = 1; in imc_get_skip_coeff()
666 chctx->skipFlagCount[i]++; in imc_get_skip_coeff()
668 chctx->skipFlags[j] = 0; in imc_get_skip_coeff()
675 chctx->skipFlagBits[i]++; in imc_get_skip_coeff()
676 if ((chctx->skipFlags[j] = get_bits1(&q->gb))) in imc_get_skip_coeff()
677 chctx->skipFlagCount[i]++; in imc_get_skip_coeff()
686 static void imc_adjust_bit_allocation(IMCContext *q, IMCChannel *chctx, in imc_adjust_bit_allocation() argument
696 workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20 in imc_adjust_bit_allocation()
697 … : (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415); in imc_adjust_bit_allocation()
715 if (++(chctx->bitsBandT[found_indx]) == 6) in imc_adjust_bit_allocation()
719 if (!chctx->skipFlags[j] && (chctx->CWlengthT[j] < 6)) { in imc_adjust_bit_allocation()
720 chctx->CWlengthT[j]++; in imc_adjust_bit_allocation()
728 static void imc_imdct256(IMCContext *q, IMCChannel *chctx, int channels) in imc_imdct256() argument
737 q->samples[i].re = -(q->pre_coef1[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) - in imc_imdct256()
738 (q->pre_coef2[i] * chctx->CWdecoded[i * 2]); in imc_imdct256()
739 q->samples[i].im = (q->pre_coef2[i] * chctx->CWdecoded[COEFFS - 1 - i * 2]) - in imc_imdct256()
740 (q->pre_coef1[i] * chctx->CWdecoded[i * 2]); in imc_imdct256()
751 *dst1 = (q->mdct_sine_window[COEFFS - 1 - i * 2] * chctx->last_fft_im[i]) in imc_imdct256()
753 *dst2 = (q->mdct_sine_window[i * 2] * chctx->last_fft_im[i]) in imc_imdct256()
757 chctx->last_fft_im[i] = im; in imc_imdct256()
761 static int inverse_quant_coeff(IMCContext *q, IMCChannel *chctx, in inverse_quant_coeff() argument
770 chctx->CWdecoded[j] = 0; in inverse_quant_coeff()
771 cw_len = chctx->CWlengthT[j]; in inverse_quant_coeff()
773 if (cw_len <= 0 || chctx->skipFlags[j]) in inverse_quant_coeff()
779 if (chctx->codewords[j] >= max_size || chctx->codewords[j] < 0) in inverse_quant_coeff()
784 if (chctx->codewords[j] >= middle_value) in inverse_quant_coeff()
785chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 8] * chctx->flcoeffs6[i]; in inverse_quant_coeff()
787chctx->CWdecoded[j] = -quantizer[max_size - chctx->codewords[j] - 8 - 1] * chctx->flcoeffs6[i]; in inverse_quant_coeff()
789 … quantizer = imc_quantizer1[((stream_format_code & 2) >> 1) | (chctx->bandFlagsBuf[i] << 1)]; in inverse_quant_coeff()
790 if (chctx->codewords[j] >= middle_value) in inverse_quant_coeff()
791chctx->CWdecoded[j] = quantizer[chctx->codewords[j] - 1] * chctx->flcoeffs6[i]; in inverse_quant_coeff()
793chctx->CWdecoded[j] = -quantizer[max_size - 2 - chctx->codewords[j]] * chctx->flcoeffs6[i]; in inverse_quant_coeff()
802 IMCContext *q, IMCChannel *chctx) in imc_get_coeffs() argument
807 if (!chctx->sumLenArr[i]) in imc_get_coeffs()
809 if (chctx->bandFlagsBuf[i] || chctx->bandWidthT[i]) { in imc_get_coeffs()
811 cw_len = chctx->CWlengthT[j]; in imc_get_coeffs()
814 if (cw_len && (!chctx->bandFlagsBuf[i] || !chctx->skipFlags[j])) { in imc_get_coeffs()
823 chctx->codewords[j] = cw; in imc_get_coeffs()
829 static void imc_refine_bit_allocation(IMCContext *q, IMCChannel *chctx) in imc_refine_bit_allocation() argument
835 chctx->sumLenArr[i] = 0; in imc_refine_bit_allocation()
836 chctx->skipFlagRaw[i] = 0; in imc_refine_bit_allocation()
838 chctx->sumLenArr[i] += chctx->CWlengthT[j]; in imc_refine_bit_allocation()
839 if (chctx->bandFlagsBuf[i]) in imc_refine_bit_allocation()
840 …if (((int)((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] >… in imc_refine_bit_allocation()
841 chctx->skipFlagRaw[i] = 1; in imc_refine_bit_allocation()
844 imc_get_skip_coeff(q, chctx); in imc_refine_bit_allocation()
847 chctx->flcoeffs6[i] = chctx->flcoeffs1[i]; in imc_refine_bit_allocation()
849 if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) { in imc_refine_bit_allocation()
850 chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] / in imc_refine_bit_allocation()
851 … q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])]; in imc_refine_bit_allocation()
859 if (chctx->bandFlagsBuf[i]) { in imc_refine_bit_allocation()
861 if (chctx->skipFlags[j]) { in imc_refine_bit_allocation()
862 summer += chctx->CWlengthT[j]; in imc_refine_bit_allocation()
863 chctx->CWlengthT[j] = 0; in imc_refine_bit_allocation()
866 bits += chctx->skipFlagBits[i]; in imc_refine_bit_allocation()
867 summer -= chctx->skipFlagBits[i]; in imc_refine_bit_allocation()
870 imc_adjust_bit_allocation(q, chctx, summer); in imc_refine_bit_allocation()
880 IMCChannel *chctx = q->chctx + ch; in imc_decode_block() local
893 chctx->decoder_reset = 1; in imc_decode_block()
895 if (chctx->decoder_reset) { in imc_decode_block()
897 chctx->old_floor[i] = 1.0; in imc_decode_block()
899 chctx->CWdecoded[i] = 0; in imc_decode_block()
900 chctx->decoder_reset = 0; in imc_decode_block()
905 imc_read_level_coeffs_raw(q, stream_format_code, chctx->levlCoeffBuf); in imc_decode_block()
907 imc_read_level_coeffs(q, stream_format_code, chctx->levlCoeffBuf); in imc_decode_block()
910 imc_decode_level_coefficients_raw(q, chctx->levlCoeffBuf, in imc_decode_block()
911 chctx->flcoeffs1, chctx->flcoeffs2); in imc_decode_block()
913 imc_decode_level_coefficients(q, chctx->levlCoeffBuf, in imc_decode_block()
914 chctx->flcoeffs1, chctx->flcoeffs2); in imc_decode_block()
916 imc_decode_level_coefficients2(q, chctx->levlCoeffBuf, chctx->old_floor, in imc_decode_block()
917 chctx->flcoeffs1, chctx->flcoeffs2); in imc_decode_block()
920 if(chctx->flcoeffs1[i] > INT_MAX) { in imc_decode_block()
926 memcpy(chctx->old_floor, chctx->flcoeffs1, 32 * sizeof(float)); in imc_decode_block()
931 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i]; in imc_decode_block()
932 chctx->bandFlagsBuf[i] = 0; in imc_decode_block()
933 chctx->flcoeffs3[i] = chctx->flcoeffs2[i] * 2; in imc_decode_block()
934 chctx->flcoeffs5[i] = 1.0; in imc_decode_block()
938 if (chctx->levlCoeffBuf[i] == 16) { in imc_decode_block()
939 chctx->bandWidthT[i] = 0; in imc_decode_block()
942 chctx->bandWidthT[i] = band_tab[i + 1] - band_tab[i]; in imc_decode_block()
945 memset(chctx->bandFlagsBuf, 0, BANDS * sizeof(int)); in imc_decode_block()
947 if (chctx->bandWidthT[i]) in imc_decode_block()
948 chctx->bandFlagsBuf[i] = get_bits1(&q->gb); in imc_decode_block()
950 imc_calculate_coeffs(q, chctx->flcoeffs1, chctx->flcoeffs2, in imc_decode_block()
951 chctx->bandWidthT, chctx->flcoeffs3, in imc_decode_block()
952 chctx->flcoeffs5); in imc_decode_block()
960 chctx->bitsBandT[0] = 5; in imc_decode_block()
961 chctx->CWlengthT[0] = 5; in imc_decode_block()
962 chctx->CWlengthT[1] = 5; in imc_decode_block()
963 chctx->CWlengthT[2] = 5; in imc_decode_block()
968 bits = (chctx->levlCoeffBuf[i] == 16) ? 0 : 5; in imc_decode_block()
969 chctx->bitsBandT[i] = bits; in imc_decode_block()
971 chctx->CWlengthT[j] = bits; in imc_decode_block()
977 bitscount += !!chctx->bandWidthT[BANDS - 1]; in imc_decode_block()
982 if ((ret = bit_allocation(q, chctx, stream_format_code, in imc_decode_block()
986 chctx->decoder_reset = 1; in imc_decode_block()
992 chctx->skipFlags[i] = 0; in imc_decode_block()
994 imc_refine_bit_allocation(q, chctx); in imc_decode_block()
998 chctx->sumLenArr[i] = 0; in imc_decode_block()
1001 if (!chctx->skipFlags[j]) in imc_decode_block()
1002 chctx->sumLenArr[i] += chctx->CWlengthT[j]; in imc_decode_block()
1005 memset(chctx->codewords, 0, sizeof(chctx->codewords)); in imc_decode_block()
1007 imc_get_coeffs(avctx, q, chctx); in imc_decode_block()
1009 if (inverse_quant_coeff(q, chctx, stream_format_code) < 0) { in imc_decode_block()
1011 chctx->decoder_reset = 1; in imc_decode_block()
1015 memset(chctx->skipFlags, 0, sizeof(chctx->skipFlags)); in imc_decode_block()
1017 imc_imdct256(q, chctx, avctx->channels); in imc_decode_block()
1082 q->chctx[0].decoder_reset = in flush()
1083 q->chctx[1].decoder_reset = 1; in flush()