| 987 | } |
| 988 | |
| 989 | static av_cold void init_bitstream_params(TwinContext *tctx) |
| 990 | { |
| 991 | const ModeTab *mtab = tctx->mtab; |
| 992 | int n_ch = tctx->avctx->channels; |
| 993 | int total_fr_bits = tctx->avctx->bit_rate*mtab->size/ |
| 994 | tctx->avctx->sample_rate; |
| 995 | |
| 996 | int lsp_bits_per_block = n_ch*(mtab->lsp_bit0 + mtab->lsp_bit1 + |
| 997 | mtab->lsp_split*mtab->lsp_bit2); |
| 998 | |
| 999 | int ppc_bits = n_ch*(mtab->pgain_bit + mtab->ppc_shape_bit + |
| 1000 | mtab->ppc_period_bit); |
| 1001 | |
| 1002 | int bsize_no_main_cb[3]; |
| 1003 | int bse_bits[3]; |
| 1004 | int i; |
| 1005 | enum FrameType frametype; |
| 1006 | |
| 1007 | for (i = 0; i < 3; i++) |
| 1008 | // +1 for history usage switch |
| 1009 | bse_bits[i] = n_ch * |
| 1010 | (mtab->fmode[i].bark_n_coef * mtab->fmode[i].bark_n_bit + 1); |
| 1011 | |
| 1012 | bsize_no_main_cb[2] = bse_bits[2] + lsp_bits_per_block + ppc_bits + |
| 1013 | WINDOW_TYPE_BITS + n_ch*GAIN_BITS; |
| 1014 | |
| 1015 | for (i = 0; i < 2; i++) |
| 1016 | bsize_no_main_cb[i] = |
| 1017 | lsp_bits_per_block + n_ch*GAIN_BITS + WINDOW_TYPE_BITS + |
| 1018 | mtab->fmode[i].sub*(bse_bits[i] + n_ch*SUB_GAIN_BITS); |
| 1019 | |
| 1020 | // The remaining bits are all used for the main spectrum coefficients |
| 1021 | for (i = 0; i < 4; i++) { |
| 1022 | int bit_size; |
| 1023 | int vect_size; |
| 1024 | int rounded_up, rounded_down, num_rounded_down, num_rounded_up; |
| 1025 | if (i == 3) { |
| 1026 | bit_size = n_ch * mtab->ppc_shape_bit; |
| 1027 | vect_size = n_ch * mtab->ppc_shape_len; |
| 1028 | } else { |
| 1029 | bit_size = total_fr_bits - bsize_no_main_cb[i]; |
| 1030 | vect_size = n_ch * mtab->size; |
| 1031 | } |
| 1032 | |
| 1033 | tctx->n_div[i] = (bit_size + 13) / 14; |
| 1034 | |
| 1035 | rounded_up = (bit_size + tctx->n_div[i] - 1)/tctx->n_div[i]; |
| 1036 | rounded_down = (bit_size )/tctx->n_div[i]; |
| 1037 | num_rounded_down = rounded_up * tctx->n_div[i] - bit_size; |
| 1038 | num_rounded_up = tctx->n_div[i] - num_rounded_down; |
| 1039 | tctx->bits_main_spec[0][i][0] = (rounded_up + 1)/2; |
| 1040 | tctx->bits_main_spec[1][i][0] = (rounded_up )/2; |
| 1041 | tctx->bits_main_spec[0][i][1] = (rounded_down + 1)/2; |
| 1042 | tctx->bits_main_spec[1][i][1] = (rounded_down )/2; |
| 1043 | tctx->bits_main_spec_change[i] = num_rounded_up; |
| 1044 | |
| 1045 | rounded_up = (vect_size + tctx->n_div[i] - 1)/tctx->n_div[i]; |
| 1046 | rounded_down = (vect_size )/tctx->n_div[i]; |
no test coverage detected