Lines Matching +full:2 +full:- +full:49
1 // SPDX-License-Identifier: GPL-2.0
12 #include <media/v4l2-vp9.h>
46 { 55, 27, 12, 153, 203, 218, 26, 27, 49 }, /*left = d207*/
47 { 53, 49, 21, 110, 116, 168, 59, 80, 76 }, /*left = d63 */
72 { 64, 19, 37, 156, 66, 138, 49, 95, 133 }, /*left = dc */
80 { 45, 26, 28, 129, 45, 129, 49, 147, 123 }, /*left = d63 */
92 { 37, 49, 25, 129, 168, 164, 41, 54, 148 }, /*left = tm */
99 { 49, 30, 35, 141, 70, 168, 82, 40, 115 }, /*left = d117*/
120 { 49, 50, 35, 144, 95, 205, 63, 78, 59 }, /*left = d135*/
131 /* 8x8 -> 4x4 */
136 /* 16x16 -> 8x8 */
141 /* 32x32 -> 16x16 */
146 /* 64x64 -> 32x32 */
147 { 174, 35, 49 }, /* a/l both not split */
163 { 116, 12, 64, 120, 140, 125, 49, 115, 121 }, /* y = d63 */
187 { 84, 49, 136 },
198 { 2, 44, 76 },
201 { /* Coeff Band 2 */
222 { 2, 39, 75 },
247 { 2, 68, 118 },
251 { /* Coeff Band 2 */
278 { 61, 49, 166 },
288 { 214, 49, 220 },
298 { 49, 111, 192 },
300 { 2, 49, 87 },
303 { /* Coeff Band 2 */
308 { 2, 42, 81 },
333 { 2, 20, 47 },
353 { /* Coeff Band 2 */
357 { 2, 72, 131 },
365 { 2, 73, 133 },
407 { /* Coeff Band 2 */
411 { 2, 73, 114 },
418 { 2, 93, 148 },
454 { 2, 61, 95 },
457 { /* Coeff Band 2 */
504 { 49, 107, 178 },
509 { /* Coeff Band 2 */
514 { 2, 51, 89 },
537 { 2, 70, 124 },
557 { 2, 53, 84 },
559 { /* Coeff Band 2 */
570 { 2, 107, 172 },
578 { 2, 107, 172 },
613 { /* Coeff Band 2 */
617 { 2, 59, 89 },
624 { 2, 75, 117 },
663 { /* Coeff Band 2 */
666 { 2, 88, 144 },
684 { 1, 28, 49 },
689 { 2, 137, 192 },
712 { 2, 49, 76 },
715 { /* Coeff Band 2 */
765 { /* Coeff Band 2 */
776 { 2, 97, 159 },
816 { 2, 32, 55 },
819 { /* Coeff Band 2 */
830 { 2, 71, 112 },
840 { 1, 30, 49 },
845 { 2, 150, 194 },
867 { 10, 49, 61 },
869 { /* Coeff Band 2 */
880 { 2, 86, 140 },
921 { /* Coeff Band 2 */
926 { 2, 44, 65 },
938 { 49, 186, 223 },
947 { 2, 136, 180 },
950 { 1, 29, 49 },
971 { /* Coeff Band 2 */
975 { 2, 65, 125 },
990 { 2, 115, 180 },
1010 { 2, 173, 34 },
1045 { 83, 5, 42, 156, 111, 152, 26, 49, 152 } /* y = d135 */,
1053 /* 8x8 -> 4x4 */
1058 /* 16x16 -> 8x8 */
1063 /* 32x32 -> 16x16 */
1068 /* 64x64 -> 32x32 */
1109 #define DIV_INV(d) ((u32)(((1ULL << 32) + ((d) - 1)) / (d))) in fastdiv()
1116 DIV_INV(2), DIV_INV(3), DIV_INV(4), DIV_INV(5), in fastdiv()
1121 DIVS_INV(40, 41, 42, 43, 44, 45, 46, 47, 48, 49), in fastdiv()
1151 if (WARN_ON(divisor - 2 >= ARRAY_SIZE(inv))) in fastdiv()
1154 return ((u64)dividend * inv[divisor - 2]) >> 32; in fastdiv()
1160 if (v > 2 * m) in inv_recenter_nonneg()
1164 return m - ((v + 1) >> 1); in inv_recenter_nonneg()
1179 1 + inv_recenter_nonneg(delta, prob - 1) : in update_prob()
1180 255 - inv_recenter_nonneg(delta, 255 - prob); in update_prob()
1183 /* Counterpart to 6.3.2 tx_mode_probs() */
1189 for (i = 0; i < ARRAY_SIZE(probs->tx8); i++) { in update_tx_probs()
1190 u8 *p8x8 = probs->tx8[i]; in update_tx_probs()
1191 u8 *p16x16 = probs->tx16[i]; in update_tx_probs()
1192 u8 *p32x32 = probs->tx32[i]; in update_tx_probs()
1193 const u8 *d8x8 = deltas->tx8[i]; in update_tx_probs()
1194 const u8 *d16x16 = deltas->tx16[i]; in update_tx_probs()
1195 const u8 *d32x32 = deltas->tx32[i]; in update_tx_probs()
1202 p32x32[2] = update_prob(d32x32[2], p32x32[2]); in update_tx_probs()
1229 for (i = 0; i < ARRAY_SIZE(probs->coef); i++) { in update_coef_probs()
1230 for (j = 0; j < ARRAY_SIZE(probs->coef[0]); j++) in update_coef_probs()
1231 for (k = 0; k < ARRAY_SIZE(probs->coef[0][0]); k++) in update_coef_probs()
1232 update_coeff(deltas->coef[i][j][k], probs->coef[i][j][k]); in update_coef_probs()
1234 if (deltas->tx_mode == i) in update_coef_probs()
1245 for (i = 0; i < ARRAY_SIZE(probs->skip); i++) in update_skip_probs()
1246 probs->skip[i] = update_prob(deltas->skip[i], probs->skip[i]); in update_skip_probs()
1255 for (i = 0; i < ARRAY_SIZE(probs->inter_mode); i++) { in update_inter_mode_probs()
1256 u8 *p = probs->inter_mode[i]; in update_inter_mode_probs()
1257 const u8 *d = deltas->inter_mode[i]; in update_inter_mode_probs()
1261 p[2] = update_prob(d[2], p[2]); in update_inter_mode_probs()
1271 for (i = 0; i < ARRAY_SIZE(probs->interp_filter); i++) { in update_interp_filter_probs()
1272 u8 *p = probs->interp_filter[i]; in update_interp_filter_probs()
1273 const u8 *d = deltas->interp_filter[i]; in update_interp_filter_probs()
1286 for (i = 0; i < ARRAY_SIZE(probs->is_inter); i++) in update_is_inter_probs()
1287 probs->is_inter[i] = update_prob(deltas->is_inter[i], probs->is_inter[i]); in update_is_inter_probs()
1301 for (i = 0; i < ARRAY_SIZE(probs->comp_mode); i++) in update_frame_reference_mode_probs()
1302 probs->comp_mode[i] = update_prob(deltas->comp_mode[i], in update_frame_reference_mode_probs()
1303 probs->comp_mode[i]); in update_frame_reference_mode_probs()
1306 for (i = 0; i < ARRAY_SIZE(probs->single_ref); i++) { in update_frame_reference_mode_probs()
1307 u8 *p = probs->single_ref[i]; in update_frame_reference_mode_probs()
1308 const u8 *d = deltas->single_ref[i]; in update_frame_reference_mode_probs()
1315 for (i = 0; i < ARRAY_SIZE(probs->comp_ref); i++) in update_frame_reference_mode_probs()
1316 probs->comp_ref[i] = update_prob(deltas->comp_ref[i], probs->comp_ref[i]); in update_frame_reference_mode_probs()
1325 for (i = 0; i < ARRAY_SIZE(probs->y_mode); i++) in update_y_mode_probs()
1326 for (j = 0; j < ARRAY_SIZE(probs->y_mode[0]); ++j) in update_y_mode_probs()
1327 probs->y_mode[i][j] = in update_y_mode_probs()
1328 update_prob(deltas->y_mode[i][j], probs->y_mode[i][j]); in update_y_mode_probs()
1339 u8 *p = probs->partition[i * 4 + j]; in update_partition_probs()
1340 const u8 *d = deltas->partition[i * 4 + j]; in update_partition_probs()
1344 p[2] = update_prob(d[2], p[2]); in update_partition_probs()
1361 u8 *p = probs->mv.joint; in update_mv_probs()
1362 const u8 *d = deltas->mv.joint; in update_mv_probs()
1367 p[2] = update_mv_prob(d[2], p[2]); in update_mv_probs()
1369 for (i = 0; i < ARRAY_SIZE(probs->mv.sign); i++) { in update_mv_probs()
1370 p = probs->mv.sign; in update_mv_probs()
1371 d = deltas->mv.sign; in update_mv_probs()
1374 p = probs->mv.classes[i]; in update_mv_probs()
1375 d = deltas->mv.classes[i]; in update_mv_probs()
1376 for (j = 0; j < ARRAY_SIZE(probs->mv.classes[0]); j++) in update_mv_probs()
1379 p = probs->mv.class0_bit; in update_mv_probs()
1380 d = deltas->mv.class0_bit; in update_mv_probs()
1383 p = probs->mv.bits[i]; in update_mv_probs()
1384 d = deltas->mv.bits[i]; in update_mv_probs()
1385 for (j = 0; j < ARRAY_SIZE(probs->mv.bits[0]); j++) in update_mv_probs()
1388 for (j = 0; j < ARRAY_SIZE(probs->mv.class0_fr[0]); j++) { in update_mv_probs()
1389 p = probs->mv.class0_fr[i][j]; in update_mv_probs()
1390 d = deltas->mv.class0_fr[i][j]; in update_mv_probs()
1394 p[2] = update_mv_prob(d[2], p[2]); in update_mv_probs()
1397 p = probs->mv.fr[i]; in update_mv_probs()
1398 d = deltas->mv.fr[i]; in update_mv_probs()
1399 for (j = 0; j < ARRAY_SIZE(probs->mv.fr[i]); j++) in update_mv_probs()
1402 if (dec_params->flags & V4L2_VP9_FRAME_FLAG_ALLOW_HIGH_PREC_MV) { in update_mv_probs()
1403 p = probs->mv.class0_hp; in update_mv_probs()
1404 d = deltas->mv.class0_hp; in update_mv_probs()
1407 p = probs->mv.hp; in update_mv_probs()
1408 d = deltas->mv.hp; in update_mv_probs()
1419 if (deltas->tx_mode == V4L2_VP9_TX_MODE_SELECT) in v4l2_vp9_fw_update_probs()
1426 if (dec_params->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME || in v4l2_vp9_fw_update_probs()
1427 dec_params->flags & V4L2_VP9_FRAME_FLAG_INTRA_ONLY) in v4l2_vp9_fw_update_probs()
1432 if (dec_params->interpolation_filter == V4L2_VP9_INTERP_FILTER_SWITCHABLE) in v4l2_vp9_fw_update_probs()
1437 update_frame_reference_mode_probs(dec_params->reference_mode, probs, deltas); in v4l2_vp9_fw_update_probs()
1452 u8 fctx_idx = dec_params->frame_context_idx; in v4l2_vp9_reset_frame_ctx()
1454 if (dec_params->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME || in v4l2_vp9_reset_frame_ctx()
1455 dec_params->flags & V4L2_VP9_FRAME_FLAG_INTRA_ONLY || in v4l2_vp9_reset_frame_ctx()
1456 dec_params->flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT) { in v4l2_vp9_reset_frame_ctx()
1464 if (dec_params->flags & V4L2_VP9_FRAME_FLAG_KEY_FRAME || in v4l2_vp9_reset_frame_ctx()
1465 dec_params->flags & V4L2_VP9_FRAME_FLAG_ERROR_RESILIENT || in v4l2_vp9_reset_frame_ctx()
1466 dec_params->reset_frame_context == V4L2_VP9_RESET_FRAME_CTX_ALL) in v4l2_vp9_reset_frame_ctx()
1471 else if (dec_params->reset_frame_context == V4L2_VP9_RESET_FRAME_CTX_SPEC) in v4l2_vp9_reset_frame_ctx()
1502 * Round2(pre_prob * (256 - factor) + prob * factor, 8) in merge_prob()
1503 * Round2(pre_prob * 256 + (prob - pre_prob) * factor, 8) in merge_prob()
1504 * (pre_prob * 256 >> 8) + (((prob - pre_prob) * factor + 128) >> 8) in merge_prob()
1506 return pre_prob + (((prob - pre_prob) * factor + 128) >> 8); in merge_prob()
1514 /* 8.4.2 Merge probs process */
1518 * It turns out that in all cases the recursive calls boil down to a short-ish series
1522 * ---------
1523 * merge_probs(small_token_tree, 2):
1524 * merge_prob(p[1], c[0], c[1] + c[2])
1525 * merge_prob(p[2], c[1], c[2])
1528 * ---------
1534 * ---------
1536 * merge_prob(p[0], c[2], c[1] + c[0] + c[3])
1538 * merge_prob(p[2], c[1], c[3])
1541 * ---------
1545 * merge_prob(p[2], c[1], c[2] + ... + c[8])
1546 * merge_prob(p[3], c[2] + c[4] + c[5], c[3] + c[8] + c[6] + c[7])
1547 * merge_prob(p[4], c[2], c[4] + c[5])
1554 * ---------
1559 * merge_prob(p[0], c[0], c[1] + c[2] + c[3])
1560 * merge_prob(p[1], c[1], c[2] + c[3])
1561 * merge_prob(p[2], c[2], c[3])
1564 * ---------
1567 * merge_prob(p[0], c[0], c[1] + c[2])
1568 * merge_prob(p[1], c[1], c[2])
1571 * ---------
1574 * merge_prob(p[1], c[1], c[2] + ... + c[10])
1575 * merge_prob(p[2], c[2] + c[3], c[4] + ... + c[10])
1576 * merge_prob(p[3], c[2], c[3])
1587 p[1] = merge_prob(p[1], c[0], c[1] + c[2], count_sat, update_factor); in merge_probs_variant_a()
1588 p[2] = merge_prob(p[2], c[1], c[2], count_sat, update_factor); in merge_probs_variant_a()
1598 p[0] = noncoef_merge_prob(p[0], c[2], c[1] + c[0] + c[3]); in merge_probs_variant_c()
1600 p[2] = noncoef_merge_prob(p[2], c[1], c[3]); in merge_probs_variant_c()
1607 sum = c[1] + c[2] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9]; in merge_probs_variant_d()
1610 sum -= c[9]; in merge_probs_variant_d()
1612 sum -= c[1]; in merge_probs_variant_d()
1613 p[2] = noncoef_merge_prob(p[2], c[1], sum); in merge_probs_variant_d()
1614 s2 = c[2] + c[4] + c[5]; in merge_probs_variant_d()
1615 sum -= s2; in merge_probs_variant_d()
1617 s2 -= c[2]; in merge_probs_variant_d()
1618 p[4] = noncoef_merge_prob(p[4], c[2], s2); in merge_probs_variant_d()
1620 sum -= c[3]; in merge_probs_variant_d()
1622 sum -= c[8]; in merge_probs_variant_d()
1629 p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2] + c[3]); in merge_probs_variant_e()
1630 p[1] = noncoef_merge_prob(p[1], c[1], c[2] + c[3]); in merge_probs_variant_e()
1631 p[2] = noncoef_merge_prob(p[2], c[2], c[3]); in merge_probs_variant_e()
1636 p[0] = noncoef_merge_prob(p[0], c[0], c[1] + c[2]); in merge_probs_variant_f()
1637 p[1] = noncoef_merge_prob(p[1], c[1], c[2]); in merge_probs_variant_f()
1644 sum = c[1] + c[2] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9] + c[10]; in merge_probs_variant_g()
1646 sum -= c[1]; in merge_probs_variant_g()
1648 sum -= c[2] + c[3]; in merge_probs_variant_g()
1649 p[2] = noncoef_merge_prob(p[2], c[2] + c[3], sum); in merge_probs_variant_g()
1650 p[3] = noncoef_merge_prob(p[3], c[2], c[3]); in merge_probs_variant_g()
1651 sum -= c[4] + c[5]; in merge_probs_variant_g()
1654 sum -= c[6]; in merge_probs_variant_g()
1679 for (l = 0; l < ARRAY_SIZE(probs->coef[0][0][0]); l++) { in _adapt_coeff()
1681 u8 *p = probs->coef[i][j][k][l][m]; in _adapt_coeff()
1682 const u32 counts_more_coefs[2] = { in _adapt_coeff()
1683 *counts->eob[i][j][k][l][m][1], in _adapt_coeff()
1684 *counts->eob[i][j][k][l][m][0] - *counts->eob[i][j][k][l][m][1], in _adapt_coeff()
1687 adapt_probs_variant_a_coef(p, *counts->coeff[i][j][k][l][m], uf); in _adapt_coeff()
1699 for (i = 0; i < ARRAY_SIZE(probs->coef); i++) in _adapt_coef_probs()
1700 for (j = 0; j < ARRAY_SIZE(probs->coef[0]); j++) in _adapt_coef_probs()
1701 for (k = 0; k < ARRAY_SIZE(probs->coef[0][0]); k++) in _adapt_coef_probs()
1753 static inline u8 adapt_prob(u8 prob, const u32 counts[2]) in adapt_prob() argument
1766 for (i = 0; i < ARRAY_SIZE(probs->is_inter); i++) in v4l2_vp9_adapt_noncoef_probs()
1767 probs->is_inter[i] = adapt_prob(probs->is_inter[i], (*counts->intra_inter)[i]); in v4l2_vp9_adapt_noncoef_probs()
1769 for (i = 0; i < ARRAY_SIZE(probs->comp_mode); i++) in v4l2_vp9_adapt_noncoef_probs()
1770 probs->comp_mode[i] = adapt_prob(probs->comp_mode[i], (*counts->comp)[i]); in v4l2_vp9_adapt_noncoef_probs()
1772 for (i = 0; i < ARRAY_SIZE(probs->comp_ref); i++) in v4l2_vp9_adapt_noncoef_probs()
1773 probs->comp_ref[i] = adapt_prob(probs->comp_ref[i], (*counts->comp_ref)[i]); in v4l2_vp9_adapt_noncoef_probs()
1776 for (i = 0; i < ARRAY_SIZE(probs->single_ref); i++) in v4l2_vp9_adapt_noncoef_probs()
1777 for (j = 0; j < ARRAY_SIZE(probs->single_ref[0]); j++) in v4l2_vp9_adapt_noncoef_probs()
1778 probs->single_ref[i][j] = adapt_prob(probs->single_ref[i][j], in v4l2_vp9_adapt_noncoef_probs()
1779 (*counts->single_ref)[i][j]); in v4l2_vp9_adapt_noncoef_probs()
1781 for (i = 0; i < ARRAY_SIZE(probs->inter_mode); i++) in v4l2_vp9_adapt_noncoef_probs()
1782 adapt_probs_variant_c(probs->inter_mode[i], (*counts->mv_mode)[i]); in v4l2_vp9_adapt_noncoef_probs()
1784 for (i = 0; i < ARRAY_SIZE(probs->y_mode); i++) in v4l2_vp9_adapt_noncoef_probs()
1785 adapt_probs_variant_d(probs->y_mode[i], (*counts->y_mode)[i]); in v4l2_vp9_adapt_noncoef_probs()
1787 for (i = 0; i < ARRAY_SIZE(probs->uv_mode); i++) in v4l2_vp9_adapt_noncoef_probs()
1788 adapt_probs_variant_d(probs->uv_mode[i], (*counts->uv_mode)[i]); in v4l2_vp9_adapt_noncoef_probs()
1790 for (i = 0; i < ARRAY_SIZE(probs->partition); i++) in v4l2_vp9_adapt_noncoef_probs()
1791 adapt_probs_variant_e(probs->partition[i], (*counts->partition)[i]); in v4l2_vp9_adapt_noncoef_probs()
1793 for (i = 0; i < ARRAY_SIZE(probs->skip); i++) in v4l2_vp9_adapt_noncoef_probs()
1794 probs->skip[i] = adapt_prob(probs->skip[i], (*counts->skip)[i]); in v4l2_vp9_adapt_noncoef_probs()
1797 for (i = 0; i < ARRAY_SIZE(probs->interp_filter); i++) in v4l2_vp9_adapt_noncoef_probs()
1798 adapt_probs_variant_f(probs->interp_filter[i], (*counts->filter)[i]); in v4l2_vp9_adapt_noncoef_probs()
1801 for (i = 0; i < ARRAY_SIZE(probs->tx8); i++) { in v4l2_vp9_adapt_noncoef_probs()
1802 adapt_probs_variant_b(probs->tx8[i], (*counts->tx8p)[i]); in v4l2_vp9_adapt_noncoef_probs()
1803 adapt_probs_variant_f(probs->tx16[i], (*counts->tx16p)[i]); in v4l2_vp9_adapt_noncoef_probs()
1804 adapt_probs_variant_e(probs->tx32[i], (*counts->tx32p)[i]); in v4l2_vp9_adapt_noncoef_probs()
1807 adapt_probs_variant_e(probs->mv.joint, *counts->mv_joint); in v4l2_vp9_adapt_noncoef_probs()
1809 for (i = 0; i < ARRAY_SIZE(probs->mv.sign); i++) { in v4l2_vp9_adapt_noncoef_probs()
1810 probs->mv.sign[i] = adapt_prob(probs->mv.sign[i], (*counts->sign)[i]); in v4l2_vp9_adapt_noncoef_probs()
1812 adapt_probs_variant_g(probs->mv.classes[i], (*counts->classes)[i]); in v4l2_vp9_adapt_noncoef_probs()
1814 probs->mv.class0_bit[i] = adapt_prob(probs->mv.class0_bit[i], (*counts->class0)[i]); in v4l2_vp9_adapt_noncoef_probs()
1816 for (j = 0; j < ARRAY_SIZE(probs->mv.bits[0]); j++) in v4l2_vp9_adapt_noncoef_probs()
1817 probs->mv.bits[i][j] = adapt_prob(probs->mv.bits[i][j], in v4l2_vp9_adapt_noncoef_probs()
1818 (*counts->bits)[i][j]); in v4l2_vp9_adapt_noncoef_probs()
1820 for (j = 0; j < ARRAY_SIZE(probs->mv.class0_fr[0]); j++) in v4l2_vp9_adapt_noncoef_probs()
1821 adapt_probs_variant_e(probs->mv.class0_fr[i][j], in v4l2_vp9_adapt_noncoef_probs()
1822 (*counts->class0_fp)[i][j]); in v4l2_vp9_adapt_noncoef_probs()
1824 adapt_probs_variant_e(probs->mv.fr[i], (*counts->fp)[i]); in v4l2_vp9_adapt_noncoef_probs()
1829 probs->mv.class0_hp[i] = adapt_prob(probs->mv.class0_hp[i], in v4l2_vp9_adapt_noncoef_probs()
1830 (*counts->class0_hp)[i]); in v4l2_vp9_adapt_noncoef_probs()
1832 probs->mv.hp[i] = adapt_prob(probs->mv.hp[i], (*counts->hp)[i]); in v4l2_vp9_adapt_noncoef_probs()