35 #define VP9_SYNCCODE 0x498342
148 #define MAX_SEGMENT 8
207 unsigned coef[4][2][2][6][6][3];
208 unsigned eob[4][2][2][6][6][2];
256 { 16, 16 }, { 16, 8 }, { 8, 16 }, { 8, 8 }, { 8, 4 }, { 4, 8 },
257 { 4, 4 }, { 4, 2 }, { 2, 4 }, { 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 },
259 { 8, 8 }, { 8, 4 }, { 4, 8 }, { 4, 4 }, { 4, 2 }, { 2, 4 },
260 { 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 },
326 s->
cols = (w + 7) >> 3;
327 s->
rows = (h + 7) >> 3;
329 #define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
406 return v > 2 * m ? v : v & 1 ? m - ((v + 1) >> 1) : m + (v >> 1);
412 static const int inv_map_table[254] = {
413 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
414 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
415 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
416 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
417 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
418 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
419 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
420 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
421 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
422 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
423 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
424 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
425 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
426 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
427 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
428 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
429 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
430 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
471 int c, i, j, k, l,
m,
n, w, h, max, size2, res, sharp;
600 for (i = 0; i < 4; i++)
603 for (i = 0; i < 2; i++)
622 for (i = 0; i < 7; i++)
626 for (i = 0; i < 3; i++)
635 "Reference segmap (temp=%d,update=%d) enabled on size-change!\n",
642 for (i = 0; i < 8; i++) {
661 int qyac, qydc, quvac, quvdc, lflvl, sh;
671 qydc = av_clip_uintp2(qyac + s->
ydc_qdelta, 8);
674 qyac = av_clip_uintp2(qyac, 8);
692 av_clip_uintp2(lflvl + (s->
lf_delta.
ref[0] << sh), 6);
693 for (j = 1; j < 4; j++) {
711 for (max = 0; (s->
sb_cols >> max) >= 4; max++) ;
712 max =
FFMAX(0, max - 1);
747 if (size2 > size - (data2 - data)) {
776 for (i = 0; i < 2; i++)
779 for (i = 0; i < 2; i++)
780 for (j = 0; j < 2; j++)
784 for (i = 0; i < 2; i++)
785 for (j = 0; j < 3; j++)
793 for (i = 0; i < 4; i++) {
796 for (j = 0; j < 2; j++)
797 for (k = 0; k < 2; k++)
798 for (l = 0; l < 6; l++)
799 for (m = 0; m < 6; m++) {
802 if (m >= 3 && l == 0)
804 for (n = 0; n < 3; n++) {
814 for (j = 0; j < 2; j++)
815 for (k = 0; k < 2; k++)
816 for (l = 0; l < 6; l++)
817 for (m = 0; m < 6; m++) {
831 for (i = 0; i < 3; i++)
835 for (i = 0; i < 7; i++)
836 for (j = 0; j < 3; j++)
842 for (i = 0; i < 4; i++)
843 for (j = 0; j < 2; j++)
848 for (i = 0; i < 4; i++)
857 for (i = 0; i < 5; i++)
866 for (i = 0; i < 5; i++) {
877 for (i = 0; i < 5; i++)
883 for (i = 0; i < 4; i++)
884 for (j = 0; j < 9; j++)
889 for (i = 0; i < 4; i++)
890 for (j = 0; j < 4; j++)
891 for (k = 0; k < 3; k++)
897 for (i = 0; i < 3; i++)
901 for (i = 0; i < 2; i++) {
905 for (j = 0; j < 10; j++)
913 for (j = 0; j < 10; j++)
919 for (i = 0; i < 2; i++) {
920 for (j = 0; j < 2; j++)
921 for (k = 0; k < 3; k++)
926 for (j = 0; j < 3; j++)
933 for (i = 0; i < 2; i++) {
945 return (data2 - data) + size2;
956 VP56mv *pmv,
int ref,
int z,
int idx,
int sb)
958 static const int8_t mv_ref_blk_off[
N_BS_SIZES][8][2] = {
959 [
BS_64x64] = {{ 3, -1 }, { -1, 3 }, { 4, -1 }, { -1, 4 },
960 { -1, -1 }, { 0, -1 }, { -1, 0 }, { 6, -1 }},
961 [
BS_64x32] = {{ 0, -1 }, { -1, 0 }, { 4, -1 }, { -1, 2 },
962 { -1, -1 }, { 0, -3 }, { -3, 0 }, { 2, -1 }},
963 [
BS_32x64] = {{ -1, 0 }, { 0, -1 }, { -1, 4 }, { 2, -1 },
964 { -1, -1 }, { -3, 0 }, { 0, -3 }, { -1, 2 }},
965 [
BS_32x32] = {{ 1, -1 }, { -1, 1 }, { 2, -1 }, { -1, 2 },
966 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
967 [
BS_32x16] = {{ 0, -1 }, { -1, 0 }, { 2, -1 }, { -1, -1 },
968 { -1, 1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
969 [
BS_16x32] = {{ -1, 0 }, { 0, -1 }, { -1, 2 }, { -1, -1 },
970 { 1, -1 }, { -3, 0 }, { 0, -3 }, { -3, -3 }},
971 [
BS_16x16] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, 1 },
972 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
973 [
BS_16x8] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, -1 },
974 { 0, -2 }, { -2, 0 }, { -2, -1 }, { -1, -2 }},
975 [
BS_8x16] = {{ -1, 0 }, { 0, -1 }, { -1, 1 }, { -1, -1 },
976 { -2, 0 }, { 0, -2 }, { -1, -2 }, { -2, -1 }},
977 [
BS_8x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
978 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
979 [
BS_8x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
980 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
981 [
BS_4x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
982 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
983 [
BS_4x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
984 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
987 int row = s->
row, col = s->
col, row7 = s->
row7;
988 const int8_t (*p)[2] = mv_ref_blk_off[b->
bs];
989 #define INVALID_MV 0x80008000U
993 #define RETURN_DIRECT_MV(mv) \
995 uint32_t m = AV_RN32A(&mv); \
999 } else if (mem == INVALID_MV) { \
1001 } else if (m != mem) { \
1008 if (sb == 2 || sb == 1) {
1010 }
else if (sb == 3) {
1016 #define RETURN_MV(mv) \
1021 clamp_mv(&tmp, &mv, s); \
1022 m = AV_RN32A(&tmp); \
1026 } else if (mem == INVALID_MV) { \
1028 } else if (m != mem) { \
1033 uint32_t m = AV_RN32A(&mv); \
1035 clamp_mv(pmv, &mv, s); \
1037 } else if (mem == INVALID_MV) { \
1039 } else if (m != mem) { \
1040 clamp_mv(pmv, &mv, s); \
1048 if (mv->
ref[0] == ref) {
1050 }
else if (mv->
ref[1] == ref) {
1056 if (mv->
ref[0] == ref) {
1058 }
else if (mv->
ref[1] == ref) {
1068 for (; i < 8; i++) {
1069 int c = p[i][0] + col,
r = p[i][1] + row;
1074 if (mv->
ref[0] == ref) {
1076 }
else if (mv->
ref[1] == ref) {
1088 if (mv->
ref[0] == ref) {
1090 }
else if (mv->
ref[1] == ref) {
1095 #define RETURN_SCALE_MV(mv, scale) \
1098 VP56mv mv_temp = { -mv.x, -mv.y }; \
1099 RETURN_MV(mv_temp); \
1106 for (i = 0; i < 8; i++) {
1107 int c = p[i][0] + col,
r = p[i][1] + row;
1112 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1115 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1129 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1132 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1143 #undef RETURN_SCALE_MV
1157 for (n = 0, m = 0; m <
c; m++) {
1183 n = (n << 3) | (bit << 1);
1196 return sign ? -(n + 1) : (n + 1);
1211 mode ==
NEWMV ? -1 : sb);
1213 if ((mode ==
NEWMV || sb == -1) &&
1228 if (mode ==
NEWMV) {
1242 mode ==
NEWMV ? -1 : sb);
1243 if ((mode ==
NEWMV || sb == -1) &&
1258 if (mode ==
NEWMV) {
1283 int v16 = v * 0x0101;
1291 uint32_t v32 = v * 0x01010101;
1300 uint64_t v64 = v * 0x0101010101010101ULL;
1306 uint32_t v32 = v * 0x01010101;
1321 0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
1324 0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf
1332 int row = s->
row, col = s->
col, row7 = s->
row7;
1333 enum TxfmMode max_tx = max_tx_for_bl_bp[b->
bs];
1337 int vref, filter_id;
1354 for (
y = 0;
y < h4;
y++)
1355 for (x = 0; x < w4; x++)
1356 pred =
FFMIN(pred, refsegmap[(
y + row) * 8 * s->
sb_cols + x + col]);
1393 if (have_a && have_l) {
1417 }
else if (have_l) {
1465 l[0] = a[1] = b->
mode[1];
1467 l[0] = a[1] = b->
mode[1] = b->
mode[0];
1475 l[1] = a[1] = b->
mode[3];
1477 l[1] = a[1] = b->
mode[3] = b->
mode[2];
1481 l[1] = a[1] = b->
mode[3] = b->
mode[1];
1493 }
else if (b->
intra) {
1522 static const uint8_t size_group[10] = {
1523 3, 3, 3, 3, 2, 2, 2, 1, 1, 1
1525 int sz = size_group[b->
bs];
1536 static const uint8_t inter_mode_ctx_lut[14][14] = {
1537 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1538 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1539 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1540 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1541 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1542 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1543 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1544 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1545 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1546 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1547 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1548 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1549 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },
1550 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },
1585 }
else if (have_l) {
1616 if (refl == refa && refa == s->
varcompref[1]) {
1623 c = (refa == refl) ? 3 : 1;
1640 c = (refl == refa) ? 4 : 2;
1652 }
else if (have_l) {
1778 }
else if (have_l) {
1792 b->
ref[0] = 1 + bit;
1801 static const uint8_t off[10] = {
1802 3, 0, 0, 1, 0, 0, 0, 0, 0, 0
1898 #define SPLAT_CTX(var, val, n) \
1900 case 1: var = val; break; \
1901 case 2: AV_WN16A(&var, val * 0x0101); break; \
1902 case 4: AV_WN32A(&var, val * 0x01010101); break; \
1903 case 8: AV_WN64A(&var, val * 0x0101010101010101ULL); break; \
1905 uint64_t v64 = val * 0x0101010101010101ULL; \
1906 AV_WN64A( &var, v64); \
1907 AV_WN64A(&((uint8_t *) &var)[8], v64); \
1912 #define SPLAT_CTX(var, val, n) \
1914 case 1: var = val; break; \
1915 case 2: AV_WN16A(&var, val * 0x0101); break; \
1916 case 4: AV_WN32A(&var, val * 0x01010101); break; \
1918 uint32_t v32 = val * 0x01010101; \
1919 AV_WN32A( &var, v32); \
1920 AV_WN32A(&((uint8_t *) &var)[4], v32); \
1924 uint32_t v32 = val * 0x01010101; \
1925 AV_WN32A( &var, v32); \
1926 AV_WN32A(&((uint8_t *) &var)[4], v32); \
1927 AV_WN32A(&((uint8_t *) &var)[8], v32); \
1928 AV_WN32A(&((uint8_t *) &var)[12], v32); \
1935 #define SET_CTXS(dir, off, n) \
1937 SPLAT_CTX(s->dir##_skip_ctx[off], b->skip, n); \
1938 SPLAT_CTX(s->dir##_txfm_ctx[off], b->tx, n); \
1939 SPLAT_CTX(s->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
1940 if (!s->keyframe && !s->intraonly) { \
1941 SPLAT_CTX(s->dir##_intra_ctx[off], b->intra, n); \
1942 SPLAT_CTX(s->dir##_comp_ctx[off], b->comp, n); \
1943 SPLAT_CTX(s->dir##_mode_ctx[off], b->mode[3], n); \
1945 SPLAT_CTX(s->dir##_ref_ctx[off], vref, n); \
1946 if (s->filtermode == FILTER_SWITCHABLE) { \
1947 SPLAT_CTX(s->dir##_filter_ctx[off], filter_id, n); \
1952 case 1:
SET_CTXS(above, col, 1);
break;
1953 case 2:
SET_CTXS(above, col, 2);
break;
1954 case 4:
SET_CTXS(above, col, 4);
break;
1955 case 8:
SET_CTXS(above, col, 8);
break;
1958 case 1:
SET_CTXS(left, row7, 1);
break;
1959 case 2:
SET_CTXS(left, row7, 2);
break;
1960 case 4:
SET_CTXS(left, row7, 4);
break;
1961 case 8:
SET_CTXS(left, row7, 8);
break;
1981 for (n = 0; n < w4 * 2; n++) {
1985 for (n = 0; n < h4 * 2; n++) {
1993 for (
y = 0;
y < h4;
y++) {
1994 int x, o = (row +
y) * s->
sb_cols * 8 + col;
1998 for (x = 0; x < w4; x++) {
2002 }
else if (b->
comp) {
2003 for (x = 0; x < w4; x++) {
2004 mv[x].ref[0] = b->
ref[0];
2005 mv[x].ref[1] = b->
ref[1];
2010 for (x = 0; x < w4; x++) {
2011 mv[x].ref[0] = b->
ref[0];
2022 int is_tx32x32,
unsigned (*cnt)[6][3],
2023 unsigned (*eob)[6][2],
uint8_t (*p)[6][11],
2024 int nnz,
const int16_t *scan,
const int16_t (*nb)[2],
2025 const int16_t *band_counts,
const int16_t *qmul)
2027 int i = 0,
band = 0, band_left = band_counts[
band];
2041 cnt[
band][nnz][0]++;
2043 band_left = band_counts[++
band];
2045 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2047 if (++i == n_coeffs)
2054 cnt[
band][nnz][1]++;
2062 cnt[
band][nnz][2]++;
2065 cache[rc] = val = 2;
2116 band_left = band_counts[++
band];
2121 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2123 }
while (++i < n_coeffs);
2129 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2130 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2131 const int16_t (*nb)[2],
const int16_t *band_counts,
2132 const int16_t *qmul)
2135 nnz, scan, nb, band_counts, qmul);
2139 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2140 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2141 const int16_t (*nb)[2],
const int16_t *band_counts,
2142 const int16_t *qmul)
2145 nnz, scan, nb, band_counts, qmul);
2152 int row = s->
row, col = s->
col;
2157 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2158 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2159 int n, pl, x,
y, res;
2162 const int16_t *
const *yscans =
vp9_scans[tx];
2168 static const int16_t band_counts[4][8] = {
2169 { 1, 2, 3, 4, 3, 16 - 13 },
2170 { 1, 2, 3, 4, 11, 64 - 21 },
2171 { 1, 2, 3, 4, 11, 256 - 21 },
2172 { 1, 2, 3, 4, 11, 1024 - 21 },
2174 const int16_t *y_band_counts = band_counts[b->tx];
2175 const int16_t *uv_band_counts = band_counts[b->
uvtx];
2177 #define MERGE(la, end, step, rd) \
2178 for (n = 0; n < end; n += step) \
2179 la[n] = !!rd(&la[n])
2180 #define MERGE_CTX(step, rd) \
2182 MERGE(l, end_y, step, rd); \
2183 MERGE(a, end_x, step, rd); \
2186 #define DECODE_Y_COEF_LOOP(step, mode_index, v) \
2187 for (n = 0, y = 0; y < end_y; y += step) { \
2188 for (x = 0; x < end_x; x += step, n += step * step) { \
2189 enum TxfmType txtp = vp9_intra_txfm_type[b->mode[mode_index]]; \
2190 res = decode_coeffs_b##v(&s->c, s->block + 16 * n, 16 * step * step, \
2191 c, e, p, a[x] + l[y], yscans[txtp], \
2192 ynbs[txtp], y_band_counts, qmul[0]); \
2193 a[x] = l[y] = !!res; \
2195 AV_WN16A(&s->eob[n], res); \
2202 #define SPLAT(la, end, step, cond) \
2204 for (n = 1; n < end; n += step) \
2205 la[n] = la[n - 1]; \
2206 } else if (step == 4) { \
2208 for (n = 0; n < end; n += step) \
2209 AV_WN32A(&la[n], la[n] * 0x01010101); \
2211 for (n = 0; n < end; n += step) \
2212 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
2216 if (HAVE_FAST_64BIT) { \
2217 for (n = 0; n < end; n += step) \
2218 AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
2220 for (n = 0; n < end; n += step) { \
2221 uint32_t v32 = la[n] * 0x01010101; \
2222 AV_WN32A(&la[n], v32); \
2223 AV_WN32A(&la[n + 4], v32); \
2227 for (n = 0; n < end; n += step) \
2228 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
2231 #define SPLAT_CTX(step) \
2233 SPLAT(a, end_x, step, end_x == w4); \
2234 SPLAT(l, end_y, step, end_y == h4); \
2259 #define DECODE_UV_COEF_LOOP(step) \
2260 for (n = 0, y = 0; y < end_y; y += step) { \
2261 for (x = 0; x < end_x; x += step, n += step * step) { \
2262 res = decode_coeffs_b(&s->c, s->uvblock[pl] + 16 * n, \
2263 16 * step * step, c, e, p, a[x] + l[y], \
2264 uvscan, uvnb, uv_band_counts, qmul[1]); \
2265 a[x] = l[y] = !!res; \
2267 AV_WN16A(&s->uveob[pl][n], res); \
2269 s->uveob[pl][n] = res; \
2281 for (pl = 0; pl < 2; pl++) {
2303 1024, c, e, p, a[0] + l[0],
2304 uvscan, uvnb, uv_band_counts, qmul[1]);
2305 a[0] = l[0] = !!res;
2314 uint8_t *dst_edge, ptrdiff_t stride_edge,
2315 uint8_t *dst_inner, ptrdiff_t stride_inner,
2316 uint8_t *l,
int col,
int x,
int w,
2320 int have_top = row > 0 || y > 0;
2322 int have_right = x < w - 1;
2323 static const uint8_t mode_conv[10][2 ][2 ] = {
2345 static const struct {
2353 [
DC_PRED] = { .needs_top = 1, .needs_left = 1 },
2356 [
VERT_RIGHT_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2357 [
HOR_DOWN_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2360 [
TM_VP8_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2369 mode = mode_conv[
mode][have_left][have_top];
2370 if (edges[mode].needs_top) {
2372 int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !p) - x) * 4;
2373 int n_px_need_tr = 0;
2375 if (tx ==
TX_4X4 && edges[mode].needs_topright && have_right)
2382 top = !(row & 7) && !y ?
2384 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
2386 topleft = !(row & 7) && !y ?
2388 y == 0 || x == 0 ? &dst_edge[-stride_edge] :
2389 &dst_inner[-stride_inner];
2393 (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
2394 (tx !=
TX_4X4 || !edges[mode].needs_topright || have_right) &&
2395 n_px_need + n_px_need_tr <= n_px_have) {
2399 if (n_px_need <= n_px_have) {
2400 memcpy(*a, top, n_px_need);
2402 memcpy(*a, top, n_px_have);
2403 memset(&(*a)[n_px_have], (*a)[n_px_have - 1],
2404 n_px_need - n_px_have);
2407 memset(*a, 127, n_px_need);
2409 if (edges[mode].needs_topleft) {
2410 if (have_left && have_top) {
2411 (*a)[-1] = topleft[-1];
2413 (*a)[-1] = have_top ? 129 : 127;
2416 if (tx ==
TX_4X4 && edges[mode].needs_topright) {
2417 if (have_top && have_right &&
2418 n_px_need + n_px_need_tr <= n_px_have) {
2419 memcpy(&(*a)[4], &top[4], 4);
2421 memset(&(*a)[4], (*a)[3], 4);
2426 if (edges[mode].needs_left) {
2428 int n_px_need = 4 << tx, i, n_px_have = (((s->
rows - row) << !p) -
y) * 4;
2429 uint8_t *dst = x == 0 ? dst_edge : dst_inner;
2430 ptrdiff_t
stride = x == 0 ? stride_edge : stride_inner;
2432 if (n_px_need <= n_px_have) {
2433 for (i = 0; i < n_px_need; i++)
2434 l[n_px_need - 1 - i] = dst[i * stride - 1];
2436 for (i = 0; i < n_px_have; i++)
2437 l[n_px_need - 1 - i] = dst[i * stride - 1];
2438 memset(l, l[n_px_need - n_px_have], n_px_need - n_px_have);
2441 memset(l, 129, 4 << tx);
2452 int row = s->
row, col = s->
col;
2453 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
2454 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
2455 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2456 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2458 int uvstep1d = 1 << b->
uvtx, p;
2463 for (
n = 0, y = 0; y < end_y; y += step1d) {
2464 uint8_t *ptr = dst, *ptr_r = dst_r;
2465 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d,
2466 ptr_r += 4 * step1d,
n += step) {
2476 col, x, w4, row, y, b->tx, 0);
2490 step = 1 << (b->
uvtx * 2);
2491 for (p = 0; p < 2; p++) {
2492 dst = s->
dst[1 + p];
2494 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
2495 uint8_t *ptr = dst, *ptr_r = dst_r;
2496 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d,
2497 ptr_r += 4 * uvstep1d,
n += step) {
2505 col, x, w4, row, y, b->
uvtx, p + 1);
2518 uint8_t *dst, ptrdiff_t dst_stride,
2519 const uint8_t *ref, ptrdiff_t ref_stride,
2521 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2522 int bw,
int bh,
int w,
int h)
2524 int mx = mv->
x, my = mv->
y,
th;
2528 ref += y * ref_stride + x;
2534 th = (y + bh + 4 * !!my + 7) >> 6;
2536 if (x < !!mx * 3 || y < !!my * 3 ||
2537 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2539 ref - !!my * 3 * ref_stride - !!mx * 3,
2541 bw + !!mx * 7, bh + !!my * 7,
2542 x - !!mx * 3, y - !!my * 3, w, h);
2546 mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
2551 ptrdiff_t dst_stride,
2552 const uint8_t *ref_u, ptrdiff_t src_stride_u,
2553 const uint8_t *ref_v, ptrdiff_t src_stride_v,
2555 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2556 int bw,
int bh,
int w,
int h)
2558 int mx = mv->
x, my = mv->
y,
th;
2562 ref_u += y * src_stride_u + x;
2563 ref_v += y * src_stride_v + x;
2569 th = (y + bh + 4 * !!my + 7) >> 5;
2571 if (x < !!mx * 3 || y < !!my * 3 ||
2572 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2574 ref_u - !!my * 3 * src_stride_u - !!mx * 3,
2576 bw + !!mx * 7, bh + !!my * 7,
2577 x - !!mx * 3, y - !!my * 3, w, h);
2579 mc[!!mx][!!my](dst_u, dst_stride, ref_u, 80, bh, mx, my);
2582 ref_v - !!my * 3 * src_stride_v - !!mx * 3,
2584 bw + !!mx * 7, bh + !!my * 7,
2585 x - !!mx * 3, y - !!my * 3, w, h);
2587 mc[!!mx][!!my](dst_v, dst_stride, ref_v, 80, bh, mx, my);
2589 mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
2590 mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
2597 { 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 },
2598 { 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4 },
2602 int row = s->
row, col = s->
col;
2620 row << 3, col << 3, &b->
mv[0][0], 8, 4, w1, h1);
2622 s->
dst[0] + 4 * ls_y, ls_y,
2624 (row << 3) + 4, col << 3, &b->
mv[2][0], 8, 4, w1, h1);
2628 ref2->data[0], ref2->linesize[0], tref2,
2629 row << 3, col << 3, &b->
mv[0][1], 8, 4, w2, h2);
2631 s->
dst[0] + 4 * ls_y, ls_y,
2632 ref2->data[0], ref2->linesize[0], tref2,
2633 (row << 3) + 4, col << 3, &b->
mv[2][1], 8, 4, w2, h2);
2638 row << 3, col << 3, &b->
mv[0][0], 4, 8, w1, h1);
2641 row << 3, (col << 3) + 4, &b->
mv[1][0], 4, 8, w1, h1);
2645 ref2->data[0], ref2->linesize[0], tref2,
2646 row << 3, col << 3, &b->
mv[0][1], 4, 8, w2, h2);
2648 ref2->data[0], ref2->linesize[0], tref2,
2649 row << 3, (col << 3) + 4, &b->
mv[1][1], 4, 8, w2, h2);
2658 row << 3, col << 3, &b->
mv[0][0], 4, 4, w1, h1);
2661 row << 3, (col << 3) + 4, &b->
mv[1][0], 4, 4, w1, h1);
2663 s->
dst[0] + 4 * ls_y, ls_y,
2665 (row << 3) + 4, col << 3, &b->
mv[2][0], 4, 4, w1, h1);
2667 s->
dst[0] + 4 * ls_y + 4, ls_y,
2669 (row << 3) + 4, (col << 3) + 4, &b->
mv[3][0], 4, 4, w1, h1);
2673 ref2->data[0], ref2->linesize[0], tref2,
2674 row << 3, col << 3, &b->
mv[0][1], 4, 4, w2, h2);
2676 ref2->data[0], ref2->linesize[0], tref2,
2677 row << 3, (col << 3) + 4, &b->
mv[1][1], 4, 4, w2, h2);
2679 s->
dst[0] + 4 * ls_y, ls_y,
2680 ref2->data[0], ref2->linesize[0], tref2,
2681 (row << 3) + 4, col << 3, &b->
mv[2][1], 4, 4, w2, h2);
2683 s->
dst[0] + 4 * ls_y + 4, ls_y,
2684 ref2->data[0], ref2->linesize[0], tref2,
2685 (row << 3) + 4, (col << 3) + 4, &b->
mv[3][1], 4, 4, w2, h2);
2689 int bwl = bwlog_tab[0][b->
bs];
2694 row << 3, col << 3, &b->
mv[0][0],bw, bh, w1, h1);
2698 ref2->data[0], ref2->linesize[0], tref2,
2699 row << 3, col << 3, &b->
mv[0][1], bw, bh, w2, h2);
2704 int bwl = bwlog_tab[1][b->
bs];
2722 s->
dst[1], s->
dst[2], ls_uv,
2725 row << 2, col << 2, &mvuv, bw, bh, w1, h1);
2735 s->
dst[1], s->
dst[2], ls_uv,
2736 ref2->data[1], ref2->linesize[1],
2737 ref2->data[2], ref2->linesize[2], tref2,
2738 row << 2, col << 2, &mvuv, bw, bh, w2, h2);
2745 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
2746 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
2747 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2748 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2750 int uvstep1d = 1 << b->
uvtx, p;
2754 for (
n = 0, y = 0; y < end_y; y += step1d) {
2756 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d,
n += step) {
2769 step = 1 << (b->
uvtx * 2);
2770 for (p = 0; p < 2; p++) {
2771 dst = s->
dst[p + 1];
2772 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
2774 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d,
n += step) {
2788 int row_and_7,
int col_and_7,
2789 int w,
int h,
int col_end,
int row_end,
2802 if (tx ==
TX_4X4 && is_uv) {
2817 if (tx ==
TX_4X4 && !skip_inter) {
2818 int t = 1 << col_and_7, m_col = (t << w) - t,
y;
2819 int m_col_odd = (t << (w - 1)) - t;
2823 int m_row_8 = m_col & 0x01, m_row_4 = m_col - m_row_8;
2825 for (
y = row_and_7;
y < h + row_and_7;
y++) {
2826 int col_mask_id = 2 - !(
y & 7);
2828 lflvl->
mask[is_uv][0][
y][1] |= m_row_8;
2829 lflvl->
mask[is_uv][0][
y][2] |= m_row_4;
2840 if ((col_end & 1) && (
y & 1)) {
2841 lflvl->
mask[is_uv][1][
y][col_mask_id] |= m_col_odd;
2843 lflvl->
mask[is_uv][1][
y][col_mask_id] |= m_col;
2847 int m_row_8 = m_col & 0x11, m_row_4 = m_col - m_row_8;
2849 for (
y = row_and_7;
y < h + row_and_7;
y++) {
2850 int col_mask_id = 2 - !(
y & 3);
2852 lflvl->
mask[is_uv][0][
y][1] |= m_row_8;
2853 lflvl->
mask[is_uv][0][
y][2] |= m_row_4;
2854 lflvl->
mask[is_uv][1][
y][col_mask_id] |= m_col;
2855 lflvl->
mask[is_uv][0][
y][3] |= m_col;
2856 lflvl->
mask[is_uv][1][
y][3] |= m_col;
2860 int y, t = 1 << col_and_7, m_col = (t << w) - t;
2863 int mask_id = (tx ==
TX_8X8);
2864 int l2 = tx + is_uv - 1, step1d = 1 << l2;
2865 static const unsigned masks[4] = { 0xff, 0x55, 0x11, 0x01 };
2866 int m_row = m_col & masks[l2];
2870 if (is_uv && tx >
TX_8X8 && (w ^ (w - 1)) == 1) {
2871 int m_row_16 = ((t << (w - 1)) - t) & masks[l2];
2872 int m_row_8 = m_row - m_row_16;
2874 for (y = row_and_7; y < h + row_and_7; y++) {
2875 lflvl->
mask[is_uv][0][
y][0] |= m_row_16;
2876 lflvl->
mask[is_uv][0][
y][1] |= m_row_8;
2879 for (y = row_and_7; y < h + row_and_7; y++)
2880 lflvl->
mask[is_uv][0][y][mask_id] |= m_row;
2883 if (is_uv && tx >
TX_8X8 && (h ^ (h - 1)) == 1) {
2884 for (y = row_and_7; y < h + row_and_7 - 1; y += step1d)
2885 lflvl->
mask[is_uv][1][y][0] |= m_col;
2886 if (y - row_and_7 == h - 1)
2887 lflvl->
mask[is_uv][1][
y][1] |= m_col;
2889 for (y = row_and_7; y < h + row_and_7; y += step1d)
2890 lflvl->
mask[is_uv][1][y][mask_id] |= m_col;
2892 }
else if (tx !=
TX_4X4) {
2895 mask_id = (tx ==
TX_8X8) || (is_uv && h == 1);
2896 lflvl->
mask[is_uv][1][row_and_7][mask_id] |= m_col;
2897 mask_id = (tx ==
TX_8X8) || (is_uv && w == 1);
2898 for (y = row_and_7; y < h + row_and_7; y++)
2899 lflvl->
mask[is_uv][0][y][mask_id] |= t;
2901 int t8 = t & 0x01,
t4 = t -
t8;
2903 for (y = row_and_7; y < h + row_and_7; y++) {
2904 lflvl->
mask[is_uv][0][
y][2] |=
t4;
2905 lflvl->
mask[is_uv][0][
y][1] |=
t8;
2907 lflvl->
mask[is_uv][1][row_and_7][2 - !(row_and_7 & 7)] |= m_col;
2909 int t8 = t & 0x11,
t4 = t -
t8;
2911 for (y = row_and_7; y < h + row_and_7; y++) {
2912 lflvl->
mask[is_uv][0][
y][2] |=
t4;
2913 lflvl->
mask[is_uv][0][
y][1] |=
t8;
2915 lflvl->
mask[is_uv][1][row_and_7][2 - !(row_and_7 & 3)] |= m_col;
2921 struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
2935 s->
min_mv.
x = -(128 + col * 64);
2936 s->
min_mv.
y = -(128 + row * 64);
2944 b->
uvtx = b->tx - (w4 * 2 == (1 << b->tx) || h4 * 2 == (1 << b->tx));
2951 #define SPLAT_ZERO_CTX(v, n) \
2953 case 1: v = 0; break; \
2954 case 2: AV_ZERO16(&v); break; \
2955 case 4: AV_ZERO32(&v); break; \
2956 case 8: AV_ZERO64(&v); break; \
2957 case 16: AV_ZERO128(&v); break; \
2959 #define SPLAT_ZERO_YUV(dir, var, off, n) \
2961 SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
2962 SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
2963 SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
2981 s->
block += w4 * h4 * 64;
2982 s->
uvblock[0] += w4 * h4 * 16;
2983 s->
uvblock[1] += w4 * h4 * 16;
2984 s->
eob += 4 * w4 * h4;
2985 s->
uveob[0] += w4 * h4;
2986 s->
uveob[1] += w4 * h4;
2995 emu[0] = (col + w4) * 8 > f->
linesize[0] ||
2996 (row + h4) > s->
rows;
2997 emu[1] = (col + w4) * 4 > f->
linesize[1] ||
2998 (row + h4) > s->
rows;
3003 s->
dst[0] = f->
data[0] + yoff;
3011 s->
dst[1] = f->
data[1] + uvoff;
3012 s->
dst[2] = f->
data[2] + uvoff;
3023 for (
n = 0; o < w;
n++) {
3029 s->
tmp_y + o, 64, h, 0, 0);
3037 for (
n = 1; o < w;
n++) {
3043 s->
tmp_uv[0] + o, 32, h, 0, 0);
3045 s->
tmp_uv[1] + o, 32, h, 0, 0);
3059 mask_edges(lflvl, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
3060 mask_edges(lflvl, 1, row7, col7, x_end, y_end,
3063 b->
uvtx, skip_inter);
3070 limit >>= (sharp + 3) >> 2;
3071 limit =
FFMIN(limit, 9 - sharp);
3073 limit =
FFMAX(limit, 1);
3082 s->
block += w4 * h4 * 64;
3083 s->
uvblock[0] += w4 * h4 * 16;
3084 s->
uvblock[1] += w4 * h4 * 16;
3085 s->
eob += 4 * w4 * h4;
3086 s->
uveob[0] += w4 * h4;
3087 s->
uveob[1] += w4 * h4;
3092 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3100 ptrdiff_t hbs = 4 >> bl;
3106 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3107 }
else if (col + hbs < s->cols) {
3108 if (row + hbs < s->rows) {
3112 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3115 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3116 yoff += hbs * 8 * y_stride;
3117 uvoff += hbs * 4 * uv_stride;
3118 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, bl, bp);
3121 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3124 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, bl, bp);
3127 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3129 yoff + 8 * hbs, uvoff + 4 * hbs, bl + 1);
3130 yoff += hbs * 8 * y_stride;
3131 uvoff += hbs * 4 * uv_stride;
3132 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3133 decode_sb(ctx, row + hbs, col + hbs, lflvl,
3134 yoff + 8 * hbs, uvoff + 4 * hbs, bl + 1);
3141 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3143 yoff + 8 * hbs, uvoff + 4 * hbs, bl + 1);
3146 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3148 }
else if (row + hbs < s->rows) {
3151 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3152 yoff += hbs * 8 * y_stride;
3153 uvoff += hbs * 4 * uv_stride;
3154 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3157 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3161 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3167 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3171 ptrdiff_t hbs = 4 >> bl;
3177 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3178 }
else if (s->
b->
bl == bl) {
3179 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3181 yoff += hbs * 8 * y_stride;
3182 uvoff += hbs * 4 * uv_stride;
3183 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3187 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, b->
bl, b->
bp);
3191 if (col + hbs < s->cols) {
3192 if (row + hbs < s->rows) {
3194 uvoff + 4 * hbs, bl + 1);
3195 yoff += hbs * 8 * y_stride;
3196 uvoff += hbs * 4 * uv_stride;
3197 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3199 yoff + 8 * hbs, uvoff + 4 * hbs, bl + 1);
3203 decode_sb_mem(ctx, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
3205 }
else if (row + hbs < s->rows) {
3206 yoff += hbs * 8 * y_stride;
3207 uvoff += hbs * 4 * uv_stride;
3208 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3214 int row,
int col, ptrdiff_t yoff, ptrdiff_t uvoff)
3229 for (y = 0; y < 8; y += 2, dst += 16 * ls_y, lvl += 16) {
3230 uint8_t *ptr = dst, *l = lvl, *hmask1 = lflvl->
mask[0][0][
y];
3232 unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2], hm13 = hmask1[3];
3233 unsigned hm2 = hmask2[1] | hmask2[2], hm23 = hmask2[3];
3234 unsigned hm = hm1 | hm2 | hm13 | hm23;
3236 for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 8, l++) {
3238 int L = *l,
H = L >> 4;
3242 if (hmask1[0] & x) {
3243 if (hmask2[0] & x) {
3249 }
else if (hm2 & x) {
3256 [0](ptr, ls_y,
E, I,
H);
3259 [0](ptr, ls_y, E, I, H);
3262 }
else if (hm2 & x) {
3263 int L = l[8],
H = L >> 4;
3268 [0](ptr + 8 * ls_y, ls_y, E, I, H);
3272 int L = *l,
H = L >> 4;
3284 }
else if (hm23 & x) {
3285 int L = l[8],
H = L >> 4;
3296 dst = f->
data[0] + yoff;
3298 for (y = 0; y < 8; y++, dst += 8 * ls_y, lvl += 8) {
3299 uint8_t *ptr = dst, *l = lvl, *vmask = lflvl->
mask[0][1][
y];
3300 unsigned vm = vmask[0] | vmask[1] | vmask[2], vm3 = vmask[3];
3302 for (x = 1; vm & ~(x - 1); x <<= 2, ptr += 16, l += 2) {
3305 int L = *l,
H = L >> 4;
3309 if (vmask[0] & (x << 1)) {
3315 }
else if (vm & (x << 1)) {
3321 [!!(vmask[1] & (x << 1))]
3322 [1](ptr, ls_y, E, I, H);
3325 [1](ptr, ls_y, E, I, H);
3327 }
else if (vm & (x << 1)) {
3328 int L = l[1],
H = L >> 4;
3332 [1](ptr + 8, ls_y,
E, I,
H);
3336 int L = *l,
H = L >> 4;
3339 if (vm3 & (x << 1)) {
3348 }
else if (vm3 & (x << 1)) {
3349 int L = l[1],
H = L >> 4;
3358 for (p = 0; p < 2; p++) {
3360 dst = f->
data[1 + p] + uvoff;
3361 for (y = 0; y < 8; y += 4, dst += 16 * ls_uv, lvl += 32) {
3362 uint8_t *ptr = dst, *l = lvl, *hmask1 = lflvl->
mask[1][0][
y];
3364 unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2];
3365 unsigned hm2 = hmask2[1] | hmask2[2], hm = hm1 | hm2;
3367 for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 4) {
3370 int L = *l,
H = L >> 4;
3373 if (hmask1[0] & x) {
3374 if (hmask2[0] & x) {
3380 }
else if (hm2 & x) {
3387 [0](ptr, ls_uv,
E, I,
H);
3390 [0](ptr, ls_uv, E, I, H);
3392 }
else if (hm2 & x) {
3393 int L = l[16],
H = L >> 4;
3397 [0](ptr + 8 * ls_uv, ls_uv, E, I, H);
3405 dst = f->
data[1 + p] + uvoff;
3406 for (y = 0; y < 8; y++, dst += 4 * ls_uv) {
3407 uint8_t *ptr = dst, *l = lvl, *vmask = lflvl->
mask[1][1][
y];
3408 unsigned vm = vmask[0] | vmask[1] | vmask[2];
3410 for (x = 1; vm & ~(x - 1); x <<= 4, ptr += 16, l += 4) {
3413 int L = *l,
H = L >> 4;
3417 if (vmask[0] & (x << 2)) {
3423 }
else if (vm & (x << 2)) {
3429 [!!(vmask[1] & (x << 2))]
3430 [1](ptr, ls_uv, E, I, H);
3433 [1](ptr, ls_uv, E, I, H);
3435 }
else if (vm & (x << 2)) {
3436 int L = l[2],
H = L >> 4;
3440 [1](ptr + 8, ls_uv,
E, I,
H);
3452 int sb_start = ( idx *
n) >> log2_n;
3453 int sb_end = ((idx + 1) * n) >> log2_n;
3454 *start =
FFMIN(sb_start, n) << 3;
3455 *end =
FFMIN(sb_end, n) << 3;
3459 int max_count,
int update_factor)
3461 unsigned ct = ct0 + ct1, p2, p1;
3467 p2 = ((ct0 << 8) + (ct >> 1)) / ct;
3468 p2 = av_clip(p2, 1, 255);
3469 ct =
FFMIN(ct, max_count);
3470 update_factor =
FASTDIV(update_factor * ct, max_count);
3473 *p = p1 + (((p2 - p1) * update_factor + 128) >> 8);
3483 for (i = 0; i < 4; i++)
3484 for (j = 0; j < 2; j++)
3485 for (k = 0; k < 2; k++)
3486 for (l = 0; l < 6; l++)
3487 for (m = 0; m < 6; m++) {
3492 if (l == 0 && m >= 3)
3496 adapt_prob(&pp[1], c[0], c[1] + c[2], 24, uf);
3509 for (i = 0; i < 3; i++)
3513 for (i = 0; i < 4; i++)
3518 for (i = 0; i < 5; i++)
3524 for (i = 0; i < 5; i++)
3530 for (i = 0; i < 5; i++) {
3534 adapt_prob(&pp[0], c[0][0], c[0][1], 20, 128);
3535 adapt_prob(&pp[1], c[1][0], c[1][1], 20, 128);
3540 for (i = 0; i < 4; i++)
3541 for (j = 0; j < 4; j++) {
3545 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3546 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3552 for (i = 0; i < 2; i++) {
3558 adapt_prob(&p->
tx32p[i][0], c32[0], c32[1] + c32[2] + c32[3], 20, 128);
3566 for (i = 0; i < 4; i++) {
3570 adapt_prob(&pp[0], c[0], c[1] + c[2], 20, 128);
3576 for (i = 0; i < 7; i++) {
3580 adapt_prob(&pp[0], c[2], c[1] + c[0] + c[3], 20, 128);
3581 adapt_prob(&pp[1], c[0], c[1] + c[3], 20, 128);
3590 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3591 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3596 for (i = 0; i < 2; i++) {
3598 unsigned *
c, (*c2)[2], sum;
3605 sum = c[1] + c[2] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9] + c[10];
3610 adapt_prob(&pp[2], c[2] + c[3], sum, 20, 128);
3613 adapt_prob(&pp[4], c[4] + c[5], sum, 20, 128);
3617 adapt_prob(&pp[7], c[7] + c[8], c[9] + c[10], 20, 128);
3625 for (j = 0; j < 10; j++)
3626 adapt_prob(&pp[j], c2[j][0], c2[j][1], 20, 128);
3628 for (j = 0; j < 2; j++) {
3631 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3632 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3637 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3638 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3650 for (i = 0; i < 4; i++) {
3654 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3674 for (i = 0; i < 10; i++) {
3678 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3710 for (i = 0; i < 2; i++) {
3715 for (i = 0; i < 8; i++) {
3737 int res, tile_row, tile_col, i, ref, row, col;
3738 ptrdiff_t yoff, uvoff, ls_y, ls_uv;
3743 }
else if (res == 0) {
3772 for (i = 0; i < 8; i++) {
3812 "Failed to allocate block buffers\n");
3818 for (i = 0; i < 4; i++) {
3819 for (j = 0; j < 2; j++)
3820 for (k = 0; k < 2; k++)
3821 for (l = 0; l < 6; l++)
3822 for (m = 0; m < 6; m++)
3859 if (tile_size > size) {
3874 row += 8, yoff += ls_y * 64, uvoff += ls_uv * 32) {
3876 ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
3894 memcpy(&s->
c, &s->
c_b[tile_col],
sizeof(s->
c));
3898 col < s->tiling.tile_col_end;
3899 col += 8, yoff2 += 64, uvoff2 += 32, lflvl_ptr++) {
3903 memset(lflvl_ptr->
mask, 0,
sizeof(lflvl_ptr->
mask));
3915 memcpy(&s->
c_b[tile_col], &s->
c,
sizeof(s->
c));
3925 if (row + 8 < s->
rows) {
3927 f->
data[0] + yoff + 63 * ls_y,
3930 f->
data[1] + uvoff + 31 * ls_uv,
3933 f->
data[2] + uvoff + 31 * ls_uv,
3941 lflvl_ptr = s->
lflvl;
3942 for (col = 0; col < s->
cols;
3943 col += 8, yoff2 += 64, uvoff2 += 32, lflvl_ptr++) {
3959 }
while (s->
pass++ == 1);
3963 for (i = 0; i < 8; i++) {
3983 for (i = 0; i < 2; i++)
3985 for (i = 0; i < 8; i++)
3994 for (i = 0; i < 2; i++) {
4002 for (i = 0; i < 8; i++) {
4040 (!ssrc->intra_pred_data[0] || s->
cols != ssrc->cols || s->
rows != ssrc->rows)) {
4044 for (i = 0; i < 2; i++) {
4047 if (ssrc->frames[i].tf.f->data[0]) {
4052 for (i = 0; i < 8; i++) {
4055 if (ssrc->next_refs[i].f->data[0]) {
4066 if (ssrc->segmentation.enabled) {