36 #define VP9_SYNCCODE 0x498342
132 #define REF_FRAME_MVPAIR 1
133 #define REF_FRAME_SEGMAP 2
150 #define MAX_SEGMENT 8
210 unsigned coef[4][2][2][6][6][3];
211 unsigned eob[4][2][2][6][6][2];
261 { 16, 16 }, { 16, 8 }, { 8, 16 }, { 8, 8 }, { 8, 4 }, { 4, 8 },
262 { 4, 4 }, { 4, 2 }, { 2, 4 }, { 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 },
264 { 8, 8 }, { 8, 4 }, { 4, 8 }, { 4, 4 }, { 4, 2 }, { 2, 4 },
265 { 2, 2 }, { 2, 1 }, { 1, 2 }, { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 },
329 s->
cols = (w + 7) >> 3;
330 s->
rows = (h + 7) >> 3;
332 #define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
375 int chroma_blocks, chroma_eobs, bytesperpixel = s->
bytesperpixel;
382 chroma_blocks = 64 * 64 >> (s->
ss_h + s->
ss_v);
383 chroma_eobs = 16 * 16 >> (s->
ss_h + s->
ss_v);
389 16 * 16 + 2 * chroma_eobs) * sbs);
400 16 * 16 + 2 * chroma_eobs);
423 return v > 2 * m ? v : v & 1 ? m - ((v + 1) >> 1) : m + (v >> 1);
429 static const int inv_map_table[255] = {
430 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
431 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
432 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
433 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
434 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
435 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
436 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
437 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
438 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
439 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
440 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
441 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
442 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
443 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
444 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
445 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
446 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
447 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
496 s->
bpp = 8 + bits * 2;
505 res = pix_fmt_rgb[
bits];
517 static const enum AVPixelFormat pix_fmt_for_ss[3][2 ][2 ] = {
540 res = pix_fmt_for_ss[
bits][1][1];
551 int c, i, j, k, l,
m,
n, w,
h, max, size2, res, sharp;
675 for (i = 0; i < 3; i++) {
681 "Ref pixfmt (%s) did not match current frame (%s)",
685 }
else if (refw == w && refh == h) {
688 if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 16 * refh) {
690 "Invalid ref frame dimensions %dx%d for frame size %dx%d\n",
694 s->
mvscale[i][0] = (refw << 14) / w;
695 s->
mvscale[i][1] = (refh << 14) / h;
726 for (i = 0; i < 4; i++)
729 for (i = 0; i < 2; i++)
749 for (i = 0; i < 7; i++)
753 for (i = 0; i < 3; i++)
762 "Reference segmap (temp=%d,update=%d) enabled on size-change!\n",
770 for (i = 0; i < 8; i++) {
784 int qyac, qydc, quvac, quvdc, lflvl, sh;
794 qydc = av_clip_uintp2(qyac + s->
ydc_qdelta, 8);
797 qyac = av_clip_uintp2(qyac, 8);
816 av_clip_uintp2(lflvl + (s->
lf_delta.
ref[0] << sh), 6);
817 for (j = 1; j < 4; j++) {
833 av_log(ctx,
AV_LOG_ERROR,
"Failed to initialize decoder for %dx%d @ %d\n", w, h, fmt);
839 for (max = 0; (s->
sb_cols >> max) >= 4; max++) ;
840 max =
FFMAX(0, max - 1);
879 if (size2 > size - (data2 - data)) {
912 for (i = 0; i < 2; i++)
915 for (i = 0; i < 2; i++)
916 for (j = 0; j < 2; j++)
920 for (i = 0; i < 2; i++)
921 for (j = 0; j < 3; j++)
929 for (i = 0; i < 4; i++) {
932 for (j = 0; j < 2; j++)
933 for (k = 0; k < 2; k++)
934 for (l = 0; l < 6; l++)
935 for (m = 0; m < 6; m++) {
938 if (m >= 3 && l == 0)
940 for (n = 0; n < 3; n++) {
950 for (j = 0; j < 2; j++)
951 for (k = 0; k < 2; k++)
952 for (l = 0; l < 6; l++)
953 for (m = 0; m < 6; m++) {
967 for (i = 0; i < 3; i++)
971 for (i = 0; i < 7; i++)
972 for (j = 0; j < 3; j++)
978 for (i = 0; i < 4; i++)
979 for (j = 0; j < 2; j++)
984 for (i = 0; i < 4; i++)
993 for (i = 0; i < 5; i++)
1002 for (i = 0; i < 5; i++) {
1013 for (i = 0; i < 5; i++)
1019 for (i = 0; i < 4; i++)
1020 for (j = 0; j < 9; j++)
1025 for (i = 0; i < 4; i++)
1026 for (j = 0; j < 4; j++)
1027 for (k = 0; k < 3; k++)
1033 for (i = 0; i < 3; i++)
1037 for (i = 0; i < 2; i++) {
1041 for (j = 0; j < 10; j++)
1049 for (j = 0; j < 10; j++)
1055 for (i = 0; i < 2; i++) {
1056 for (j = 0; j < 2; j++)
1057 for (k = 0; k < 3; k++)
1062 for (j = 0; j < 3; j++)
1069 for (i = 0; i < 2; i++) {
1081 return (data2 - data) + size2;
1092 VP56mv *pmv,
int ref,
int z,
int idx,
int sb)
1094 static const int8_t mv_ref_blk_off[
N_BS_SIZES][8][2] = {
1095 [
BS_64x64] = {{ 3, -1 }, { -1, 3 }, { 4, -1 }, { -1, 4 },
1096 { -1, -1 }, { 0, -1 }, { -1, 0 }, { 6, -1 }},
1097 [
BS_64x32] = {{ 0, -1 }, { -1, 0 }, { 4, -1 }, { -1, 2 },
1098 { -1, -1 }, { 0, -3 }, { -3, 0 }, { 2, -1 }},
1099 [
BS_32x64] = {{ -1, 0 }, { 0, -1 }, { -1, 4 }, { 2, -1 },
1100 { -1, -1 }, { -3, 0 }, { 0, -3 }, { -1, 2 }},
1101 [
BS_32x32] = {{ 1, -1 }, { -1, 1 }, { 2, -1 }, { -1, 2 },
1102 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1103 [
BS_32x16] = {{ 0, -1 }, { -1, 0 }, { 2, -1 }, { -1, -1 },
1104 { -1, 1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1105 [
BS_16x32] = {{ -1, 0 }, { 0, -1 }, { -1, 2 }, { -1, -1 },
1106 { 1, -1 }, { -3, 0 }, { 0, -3 }, { -3, -3 }},
1107 [
BS_16x16] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, 1 },
1108 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1109 [
BS_16x8] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, -1 },
1110 { 0, -2 }, { -2, 0 }, { -2, -1 }, { -1, -2 }},
1111 [
BS_8x16] = {{ -1, 0 }, { 0, -1 }, { -1, 1 }, { -1, -1 },
1112 { -2, 0 }, { 0, -2 }, { -1, -2 }, { -2, -1 }},
1113 [
BS_8x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1114 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1115 [
BS_8x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1116 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1117 [
BS_4x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1118 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1119 [
BS_4x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1120 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1123 int row = s->
row, col = s->
col, row7 = s->
row7;
1124 const int8_t (*p)[2] = mv_ref_blk_off[b->
bs];
1125 #define INVALID_MV 0x80008000U
1129 #define RETURN_DIRECT_MV(mv) \
1131 uint32_t m = AV_RN32A(&mv); \
1135 } else if (mem == INVALID_MV) { \
1137 } else if (m != mem) { \
1144 if (sb == 2 || sb == 1) {
1146 }
else if (sb == 3) {
1152 #define RETURN_MV(mv) \
1157 av_assert2(idx == 1); \
1158 av_assert2(mem != INVALID_MV); \
1159 if (mem_sub8x8 == INVALID_MV) { \
1160 clamp_mv(&tmp, &mv, s); \
1161 m = AV_RN32A(&tmp); \
1166 mem_sub8x8 = AV_RN32A(&mv); \
1167 } else if (mem_sub8x8 != AV_RN32A(&mv)) { \
1168 clamp_mv(&tmp, &mv, s); \
1169 m = AV_RN32A(&tmp); \
1179 uint32_t m = AV_RN32A(&mv); \
1181 clamp_mv(pmv, &mv, s); \
1183 } else if (mem == INVALID_MV) { \
1185 } else if (m != mem) { \
1186 clamp_mv(pmv, &mv, s); \
1194 if (mv->
ref[0] == ref) {
1196 }
else if (mv->
ref[1] == ref) {
1202 if (mv->
ref[0] == ref) {
1204 }
else if (mv->
ref[1] == ref) {
1214 for (; i < 8; i++) {
1215 int c = p[i][0] + col,
r = p[i][1] + row;
1220 if (mv->
ref[0] == ref) {
1222 }
else if (mv->
ref[1] == ref) {
1234 if (mv->
ref[0] == ref) {
1236 }
else if (mv->
ref[1] == ref) {
1241 #define RETURN_SCALE_MV(mv, scale) \
1244 VP56mv mv_temp = { -mv.x, -mv.y }; \
1245 RETURN_MV(mv_temp); \
1252 for (i = 0; i < 8; i++) {
1253 int c = p[i][0] + col,
r = p[i][1] + row;
1258 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1261 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1275 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1278 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1290 #undef RETURN_SCALE_MV
1304 for (n = 0, m = 0; m <
c; m++) {
1330 n = (n << 3) | (bit << 1);
1343 return sign ? -(n + 1) : (n + 1);
1358 mode ==
NEWMV ? -1 : sb);
1360 if ((mode ==
NEWMV || sb == -1) &&
1375 if (mode ==
NEWMV) {
1389 mode ==
NEWMV ? -1 : sb);
1390 if ((mode ==
NEWMV || sb == -1) &&
1405 if (mode ==
NEWMV) {
1430 int v16 = v * 0x0101;
1438 uint32_t v32 = v * 0x01010101;
1447 uint64_t v64 = v * 0x0101010101010101ULL;
1453 uint32_t v32 = v * 0x01010101;
1468 0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
1471 0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf
1479 int row = s->
row, col = s->
col, row7 = s->
row7;
1480 enum TxfmMode max_tx = max_tx_for_bl_bp[b->
bs];
1484 int vref, filter_id;
1502 for (
y = 0;
y < h4;
y++) {
1503 int idx_base = (
y + row) * 8 * s->
sb_cols + col;
1504 for (x = 0; x < w4; x++)
1505 pred =
FFMIN(pred, refsegmap[idx_base + x]);
1543 if (have_a && have_l) {
1567 }
else if (have_l) {
1615 l[0] = a[1] = b->
mode[1];
1617 l[0] = a[1] = b->
mode[1] = b->
mode[0];
1625 l[1] = a[1] = b->
mode[3];
1627 l[1] = a[1] = b->
mode[3] = b->
mode[2];
1631 l[1] = a[1] = b->
mode[3] = b->
mode[1];
1643 }
else if (b->
intra) {
1672 static const uint8_t size_group[10] = {
1673 3, 3, 3, 3, 2, 2, 2, 1, 1, 1
1675 int sz = size_group[b->
bs];
1686 static const uint8_t inter_mode_ctx_lut[14][14] = {
1687 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1688 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1689 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1690 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1691 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1692 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1693 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1694 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1695 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1696 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1697 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1698 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1699 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },
1700 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },
1735 }
else if (have_l) {
1766 if (refl == refa && refa == s->
varcompref[1]) {
1773 c = (refa == refl) ? 3 : 1;
1790 c = (refl == refa) ? 4 : 2;
1802 }
else if (have_l) {
1928 }
else if (have_l) {
1942 b->
ref[0] = 1 + bit;
1951 static const uint8_t off[10] = {
1952 3, 0, 0, 1, 0, 0, 0, 0, 0, 0
2048 #define SPLAT_CTX(var, val, n) \
2050 case 1: var = val; break; \
2051 case 2: AV_WN16A(&var, val * 0x0101); break; \
2052 case 4: AV_WN32A(&var, val * 0x01010101); break; \
2053 case 8: AV_WN64A(&var, val * 0x0101010101010101ULL); break; \
2055 uint64_t v64 = val * 0x0101010101010101ULL; \
2056 AV_WN64A( &var, v64); \
2057 AV_WN64A(&((uint8_t *) &var)[8], v64); \
2062 #define SPLAT_CTX(var, val, n) \
2064 case 1: var = val; break; \
2065 case 2: AV_WN16A(&var, val * 0x0101); break; \
2066 case 4: AV_WN32A(&var, val * 0x01010101); break; \
2068 uint32_t v32 = val * 0x01010101; \
2069 AV_WN32A( &var, v32); \
2070 AV_WN32A(&((uint8_t *) &var)[4], v32); \
2074 uint32_t v32 = val * 0x01010101; \
2075 AV_WN32A( &var, v32); \
2076 AV_WN32A(&((uint8_t *) &var)[4], v32); \
2077 AV_WN32A(&((uint8_t *) &var)[8], v32); \
2078 AV_WN32A(&((uint8_t *) &var)[12], v32); \
2085 #define SET_CTXS(dir, off, n) \
2087 SPLAT_CTX(s->dir##_skip_ctx[off], b->skip, n); \
2088 SPLAT_CTX(s->dir##_txfm_ctx[off], b->tx, n); \
2089 SPLAT_CTX(s->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
2090 if (!s->keyframe && !s->intraonly) { \
2091 SPLAT_CTX(s->dir##_intra_ctx[off], b->intra, n); \
2092 SPLAT_CTX(s->dir##_comp_ctx[off], b->comp, n); \
2093 SPLAT_CTX(s->dir##_mode_ctx[off], b->mode[3], n); \
2095 SPLAT_CTX(s->dir##_ref_ctx[off], vref, n); \
2096 if (s->filtermode == FILTER_SWITCHABLE) { \
2097 SPLAT_CTX(s->dir##_filter_ctx[off], filter_id, n); \
2102 case 1:
SET_CTXS(above, col, 1);
break;
2103 case 2:
SET_CTXS(above, col, 2);
break;
2104 case 4:
SET_CTXS(above, col, 4);
break;
2105 case 8:
SET_CTXS(above, col, 8);
break;
2108 case 1:
SET_CTXS(left, row7, 1);
break;
2109 case 2:
SET_CTXS(left, row7, 2);
break;
2110 case 4:
SET_CTXS(left, row7, 4);
break;
2111 case 8:
SET_CTXS(left, row7, 8);
break;
2131 for (n = 0; n < w4 * 2; n++) {
2135 for (n = 0; n < h4 * 2; n++) {
2143 for (
y = 0;
y < h4;
y++) {
2144 int x, o = (row +
y) * s->
sb_cols * 8 + col;
2148 for (x = 0; x < w4; x++) {
2152 }
else if (b->
comp) {
2153 for (x = 0; x < w4; x++) {
2154 mv[x].ref[0] = b->
ref[0];
2155 mv[x].ref[1] = b->
ref[1];
2160 for (x = 0; x < w4; x++) {
2161 mv[x].ref[0] = b->
ref[0];
2172 int is_tx32x32,
int is8bitsperpixel,
int bpp,
unsigned (*cnt)[6][3],
2173 unsigned (*eob)[6][2],
uint8_t (*p)[6][11],
2174 int nnz,
const int16_t *scan,
const int16_t (*nb)[2],
2175 const int16_t *band_counts,
const int16_t *qmul)
2177 int i = 0,
band = 0, band_left = band_counts[
band];
2191 cnt[
band][nnz][0]++;
2193 band_left = band_counts[++
band];
2195 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2197 if (++i == n_coeffs)
2204 cnt[
band][nnz][1]++;
2212 cnt[
band][nnz][2]++;
2215 cache[rc] = val = 2;
2249 if (!is8bitsperpixel) {
2274 #define STORE_COEF(c, i, v) do { \
2275 if (is8bitsperpixel) { \
2278 AV_WN32A(&c[i * 2], v); \
2282 band_left = band_counts[++
band];
2287 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2289 }
while (++i < n_coeffs);
2295 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2296 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2297 const int16_t (*nb)[2],
const int16_t *band_counts,
2298 const int16_t *qmul)
2301 nnz, scan, nb, band_counts, qmul);
2305 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2306 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2307 const int16_t (*nb)[2],
const int16_t *band_counts,
2308 const int16_t *qmul)
2311 nnz, scan, nb, band_counts, qmul);
2315 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2316 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2317 const int16_t (*nb)[2],
const int16_t *band_counts,
2318 const int16_t *qmul)
2321 nnz, scan, nb, band_counts, qmul);
2325 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2326 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2327 const int16_t (*nb)[2],
const int16_t *band_counts,
2328 const int16_t *qmul)
2331 nnz, scan, nb, band_counts, qmul);
2338 int row = s->
row, col = s->
col;
2343 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2344 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2345 int n, pl, x,
y, res;
2348 const int16_t *
const *yscans =
vp9_scans[tx];
2354 static const int16_t band_counts[4][8] = {
2355 { 1, 2, 3, 4, 3, 16 - 13 },
2356 { 1, 2, 3, 4, 11, 64 - 21 },
2357 { 1, 2, 3, 4, 11, 256 - 21 },
2358 { 1, 2, 3, 4, 11, 1024 - 21 },
2360 const int16_t *y_band_counts = band_counts[b->tx];
2361 const int16_t *uv_band_counts = band_counts[b->
uvtx];
2362 int bytesperpixel = is8bitsperpixel ? 1 : 2;
2363 int total_coeff = 0;
2365 #define MERGE(la, end, step, rd) \
2366 for (n = 0; n < end; n += step) \
2367 la[n] = !!rd(&la[n])
2368 #define MERGE_CTX(step, rd) \
2370 MERGE(l, end_y, step, rd); \
2371 MERGE(a, end_x, step, rd); \
2374 #define DECODE_Y_COEF_LOOP(step, mode_index, v) \
2375 for (n = 0, y = 0; y < end_y; y += step) { \
2376 for (x = 0; x < end_x; x += step, n += step * step) { \
2377 enum TxfmType txtp = vp9_intra_txfm_type[b->mode[mode_index]]; \
2378 res = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
2379 (s, s->block + 16 * n * bytesperpixel, 16 * step * step, \
2380 c, e, p, a[x] + l[y], yscans[txtp], \
2381 ynbs[txtp], y_band_counts, qmul[0]); \
2382 a[x] = l[y] = !!res; \
2383 total_coeff |= !!res; \
2385 AV_WN16A(&s->eob[n], res); \
2392 #define SPLAT(la, end, step, cond) \
2394 for (n = 1; n < end; n += step) \
2395 la[n] = la[n - 1]; \
2396 } else if (step == 4) { \
2398 for (n = 0; n < end; n += step) \
2399 AV_WN32A(&la[n], la[n] * 0x01010101); \
2401 for (n = 0; n < end; n += step) \
2402 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
2406 if (HAVE_FAST_64BIT) { \
2407 for (n = 0; n < end; n += step) \
2408 AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
2410 for (n = 0; n < end; n += step) { \
2411 uint32_t v32 = la[n] * 0x01010101; \
2412 AV_WN32A(&la[n], v32); \
2413 AV_WN32A(&la[n + 4], v32); \
2417 for (n = 0; n < end; n += step) \
2418 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
2421 #define SPLAT_CTX(step) \
2423 SPLAT(a, end_x, step, end_x == w4); \
2424 SPLAT(l, end_y, step, end_y == h4); \
2449 #define DECODE_UV_COEF_LOOP(step, v) \
2450 for (n = 0, y = 0; y < end_y; y += step) { \
2451 for (x = 0; x < end_x; x += step, n += step * step) { \
2452 res = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
2453 (s, s->uvblock[pl] + 16 * n * bytesperpixel, \
2454 16 * step * step, c, e, p, a[x] + l[y], \
2455 uvscan, uvnb, uv_band_counts, qmul[1]); \
2456 a[x] = l[y] = !!res; \
2457 total_coeff |= !!res; \
2459 AV_WN16A(&s->uveob[pl][n], res); \
2461 s->uveob[pl][n] = res; \
2473 for (pl = 0; pl < 2; pl++) {
2512 uint8_t *dst_edge, ptrdiff_t stride_edge,
2513 uint8_t *dst_inner, ptrdiff_t stride_inner,
2514 uint8_t *l,
int col,
int x,
int w,
2516 int p,
int ss_h,
int ss_v,
int bytesperpixel)
2518 int have_top = row > 0 || y > 0;
2520 int have_right = x < w - 1;
2522 static const uint8_t mode_conv[10][2 ][2 ] = {
2544 static const struct {
2553 [
DC_PRED] = { .needs_top = 1, .needs_left = 1 },
2556 [
VERT_RIGHT_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2557 [
HOR_DOWN_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2559 [
HOR_UP_PRED] = { .needs_left = 1, .invert_left = 1 },
2560 [
TM_VP8_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2569 mode = mode_conv[
mode][have_left][have_top];
2570 if (edges[mode].needs_top) {
2572 int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !ss_h) - x) * 4;
2573 int n_px_need_tr = 0;
2575 if (tx ==
TX_4X4 && edges[mode].needs_topright && have_right)
2582 top = !(row & 7) && !y ?
2584 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
2586 topleft = !(row & 7) && !y ?
2588 y == 0 || x == 0 ? &dst_edge[-stride_edge] :
2589 &dst_inner[-stride_inner];
2593 (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
2594 (tx !=
TX_4X4 || !edges[mode].needs_topright || have_right) &&
2595 n_px_need + n_px_need_tr <= n_px_have) {
2599 if (n_px_need <= n_px_have) {
2600 memcpy(*a, top, n_px_need * bytesperpixel);
2602 #define memset_bpp(c, i1, v, i2, num) do { \
2603 if (bytesperpixel == 1) { \
2604 memset(&(c)[(i1)], (v)[(i2)], (num)); \
2606 int n, val = AV_RN16A(&(v)[(i2) * 2]); \
2607 for (n = 0; n < (num); n++) { \
2608 AV_WN16A(&(c)[((i1) + n) * 2], val); \
2612 memcpy(*a, top, n_px_have * bytesperpixel);
2613 memset_bpp(*a, n_px_have, (*a), n_px_have - 1, n_px_need - n_px_have);
2616 #define memset_val(c, val, num) do { \
2617 if (bytesperpixel == 1) { \
2618 memset((c), (val), (num)); \
2621 for (n = 0; n < (num); n++) { \
2622 AV_WN16A(&(c)[n * 2], (val)); \
2626 memset_val(*a, (128 << (bpp - 8)) - 1, n_px_need);
2628 if (edges[mode].needs_topleft) {
2629 if (have_left && have_top) {
2630 #define assign_bpp(c, i1, v, i2) do { \
2631 if (bytesperpixel == 1) { \
2632 (c)[(i1)] = (v)[(i2)]; \
2634 AV_COPY16(&(c)[(i1) * 2], &(v)[(i2) * 2]); \
2639 #define assign_val(c, i, v) do { \
2640 if (bytesperpixel == 1) { \
2643 AV_WN16A(&(c)[(i) * 2], (v)); \
2646 assign_val((*a), -1, (128 << (bpp - 8)) + (have_top ? +1 : -1));
2649 if (tx ==
TX_4X4 && edges[mode].needs_topright) {
2650 if (have_top && have_right &&
2651 n_px_need + n_px_need_tr <= n_px_have) {
2652 memcpy(&(*a)[4 * bytesperpixel], &top[4 * bytesperpixel], 4 * bytesperpixel);
2659 if (edges[mode].needs_left) {
2661 int n_px_need = 4 << tx, i, n_px_have = (((s->
rows - row) << !ss_v) -
y) * 4;
2662 uint8_t *dst = x == 0 ? dst_edge : dst_inner;
2663 ptrdiff_t
stride = x == 0 ? stride_edge : stride_inner;
2665 if (edges[mode].invert_left) {
2666 if (n_px_need <= n_px_have) {
2667 for (i = 0; i < n_px_need; i++)
2670 for (i = 0; i < n_px_have; i++)
2672 memset_bpp(l, n_px_have, l, n_px_have - 1, n_px_need - n_px_have);
2675 if (n_px_need <= n_px_have) {
2676 for (i = 0; i < n_px_need; i++)
2677 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
2679 for (i = 0; i < n_px_have; i++)
2680 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
2681 memset_bpp(l, 0, l, n_px_need - n_px_have, n_px_need - n_px_have);
2685 memset_val(l, (128 << (bpp - 8)) + 1, 4 << tx);
2693 ptrdiff_t uv_off,
int bytesperpixel)
2697 int row = s->
row, col = s->
col;
2698 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
2699 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
2700 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2701 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2703 int uvstep1d = 1 << b->
uvtx, p;
2708 for (
n = 0, y = 0; y < end_y; y += step1d) {
2709 uint8_t *ptr = dst, *ptr_r = dst_r;
2710 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d * bytesperpixel,
2711 ptr_r += 4 * step1d * bytesperpixel,
n += step) {
2721 col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
2725 s->
block + 16 * n * bytesperpixel, eob);
2735 step = 1 << (b->
uvtx * 2);
2736 for (p = 0; p < 2; p++) {
2737 dst = s->
dst[1 + p];
2739 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
2740 uint8_t *ptr = dst, *ptr_r = dst_r;
2741 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d * bytesperpixel,
2742 ptr_r += 4 * uvstep1d * bytesperpixel,
n += step) {
2749 ptr, s->
uv_stride, l, col, x, w4, row, y,
2754 s->
uvblock[p] + 16 * n * bytesperpixel, eob);
2773 uint8_t *dst, ptrdiff_t dst_stride,
2774 const uint8_t *ref, ptrdiff_t ref_stride,
2776 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *in_mv,
2777 int px,
int py,
int pw,
int ph,
2778 int bw,
int bh,
int w,
int h,
int bytesperpixel,
2779 const uint16_t *scale,
const uint8_t *step)
2781 #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
2783 int refbw_m1, refbh_m1;
2787 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 3, (s->
cols * 8 - x + px + 3) << 3);
2788 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 3, (s->
rows * 8 - y + py + 3) << 3);
2797 ref += y * ref_stride + x * bytesperpixel;
2800 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
2801 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
2805 th = (y + refbh_m1 + 4 + 7) >> 6;
2807 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
2809 ref - 3 * ref_stride - 3 * bytesperpixel,
2811 refbw_m1 + 8, refbh_m1 + 8,
2812 x - 3, y - 3, w, h);
2816 smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
2821 ptrdiff_t dst_stride,
2822 const uint8_t *ref_u, ptrdiff_t src_stride_u,
2823 const uint8_t *ref_v, ptrdiff_t src_stride_v,
2825 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *in_mv,
2826 int px,
int py,
int pw,
int ph,
2827 int bw,
int bh,
int w,
int h,
int bytesperpixel,
2828 const uint16_t *scale,
const uint8_t *step)
2831 int refbw_m1, refbh_m1;
2837 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 4, (s->
cols * 4 - x + px + 3) << 4);
2840 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 3, (s->
cols * 8 - x + px + 3) << 3);
2845 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 4, (s->
rows * 4 - y + py + 3) << 4);
2848 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 3, (s->
rows * 8 - y + py + 3) << 3);
2854 ref_u += y * src_stride_u + x * bytesperpixel;
2855 ref_v += y * src_stride_v + x * bytesperpixel;
2858 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
2859 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
2863 th = (y + refbh_m1 + 4 + 7) >> (6 - s->
ss_v);
2865 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
2867 ref_u - 3 * src_stride_u - 3 * bytesperpixel,
2869 refbw_m1 + 8, refbh_m1 + 8,
2870 x - 3, y - 3, w, h);
2872 smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
2875 ref_v - 3 * src_stride_v - 3 * bytesperpixel,
2877 refbw_m1 + 8, refbh_m1 + 8,
2878 x - 3, y - 3, w, h);
2880 smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
2882 smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
2883 smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
2887 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
2888 px, py, pw, ph, bw, bh, w, h, i) \
2889 mc_luma_scaled(s, s->dsp.s##mc, dst, dst_ls, src, src_ls, tref, row, col, \
2890 mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
2891 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
2892 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2893 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
2894 mc_chroma_scaled(s, s->dsp.s##mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2895 row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
2896 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
2898 #define FN(x) x##_scaled_8bpp
2899 #define BYTES_PER_PIXEL 1
2902 #undef BYTES_PER_PIXEL
2903 #define FN(x) x##_scaled_16bpp
2904 #define BYTES_PER_PIXEL 2
2907 #undef mc_chroma_dir
2909 #undef BYTES_PER_PIXEL
2913 uint8_t *dst, ptrdiff_t dst_stride,
2914 const uint8_t *ref, ptrdiff_t ref_stride,
2916 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2917 int bw,
int bh,
int w,
int h,
int bytesperpixel)
2919 int mx = mv->
x, my = mv->
y,
th;
2923 ref += y * ref_stride + x * bytesperpixel;
2929 th = (y + bh + 4 * !!my + 7) >> 6;
2931 if (x < !!mx * 3 || y < !!my * 3 ||
2932 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2934 ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
2936 bw + !!mx * 7, bh + !!my * 7,
2937 x - !!mx * 3, y - !!my * 3, w, h);
2941 mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
2946 ptrdiff_t dst_stride,
2947 const uint8_t *ref_u, ptrdiff_t src_stride_u,
2948 const uint8_t *ref_v, ptrdiff_t src_stride_v,
2950 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2951 int bw,
int bh,
int w,
int h,
int bytesperpixel)
2953 int mx = mv->
x << !s->
ss_h, my = mv->
y << !s->
ss_v,
th;
2957 ref_u += y * src_stride_u + x * bytesperpixel;
2958 ref_v += y * src_stride_v + x * bytesperpixel;
2964 th = (y + bh + 4 * !!my + 7) >> (6 - s->
ss_v);
2966 if (x < !!mx * 3 || y < !!my * 3 ||
2967 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2969 ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
2971 bw + !!mx * 7, bh + !!my * 7,
2972 x - !!mx * 3, y - !!my * 3, w, h);
2973 ref_u = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
2974 mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
2977 ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
2979 bw + !!mx * 7, bh + !!my * 7,
2980 x - !!mx * 3, y - !!my * 3, w, h);
2981 ref_v = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
2982 mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
2984 mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
2985 mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
2989 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
2990 px, py, pw, ph, bw, bh, w, h, i) \
2991 mc_luma_unscaled(s, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
2992 mv, bw, bh, w, h, bytesperpixel)
2993 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2994 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
2995 mc_chroma_unscaled(s, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2996 row, col, mv, bw, bh, w, h, bytesperpixel)
2998 #define FN(x) x##_8bpp
2999 #define BYTES_PER_PIXEL 1
3002 #undef BYTES_PER_PIXEL
3003 #define FN(x) x##_16bpp
3004 #define BYTES_PER_PIXEL 2
3006 #undef mc_luma_dir_dir
3007 #undef mc_chroma_dir_dir
3009 #undef BYTES_PER_PIXEL
3016 int row = s->
row, col = s->
col;
3019 if (bytesperpixel == 1) {
3020 inter_pred_scaled_8bpp(ctx);
3022 inter_pred_scaled_16bpp(ctx);
3025 if (bytesperpixel == 1) {
3026 inter_pred_8bpp(ctx);
3028 inter_pred_16bpp(ctx);
3034 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
3035 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
3036 int end_x =
FFMIN(2 * (s->
cols - col), w4);
3037 int end_y =
FFMIN(2 * (s->
rows - row), h4);
3039 int uvstep1d = 1 << b->
uvtx, p;
3043 for (
n = 0, y = 0; y < end_y; y += step1d) {
3045 for (x = 0; x < end_x; x += step1d,
3046 ptr += 4 * step1d * bytesperpixel,
n += step) {
3051 s->
block + 16 * n * bytesperpixel, eob);
3059 step = 1 << (b->
uvtx * 2);
3060 for (p = 0; p < 2; p++) {
3061 dst = s->
dst[p + 1];
3062 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
3064 for (x = 0; x < end_x; x += uvstep1d,
3065 ptr += 4 * uvstep1d * bytesperpixel,
n += step) {
3070 s->
uvblock[p] + 16 * n * bytesperpixel, eob);
3089 int row_and_7,
int col_and_7,
3090 int w,
int h,
int col_end,
int row_end,
3093 static const unsigned wide_filter_col_mask[2] = { 0x11, 0x01 };
3094 static const unsigned wide_filter_row_mask[2] = { 0x03, 0x07 };
3106 if (tx ==
TX_4X4 && (ss_v | ss_h)) {
3121 if (tx ==
TX_4X4 && !skip_inter) {
3122 int t = 1 << col_and_7, m_col = (t << w) - t,
y;
3124 int m_row_8 = m_col & wide_filter_col_mask[ss_h], m_row_4 = m_col - m_row_8;
3126 for (
y = row_and_7;
y < h + row_and_7;
y++) {
3127 int col_mask_id = 2 - !(
y & wide_filter_row_mask[ss_v]);
3129 mask[0][
y][1] |= m_row_8;
3130 mask[0][
y][2] |= m_row_4;
3141 if ((ss_h & ss_v) && (col_end & 1) && (
y & 1)) {
3142 mask[1][
y][col_mask_id] |= (t << (w - 1)) - t;
3144 mask[1][
y][col_mask_id] |= m_col;
3147 mask[0][
y][3] |= m_col;
3149 if (ss_h && (col_end & 1))
3150 mask[1][
y][3] |= (t << (w - 1)) - t;
3152 mask[1][
y][3] |= m_col;
3156 int y, t = 1 << col_and_7, m_col = (t << w) - t;
3159 int mask_id = (tx ==
TX_8X8);
3160 static const unsigned masks[4] = { 0xff, 0x55, 0x11, 0x01 };
3161 int l2 = tx + ss_h - 1, step1d;
3162 int m_row = m_col & masks[l2];
3166 if (ss_h && tx >
TX_8X8 && (w ^ (w - 1)) == 1) {
3167 int m_row_16 = ((t << (w - 1)) - t) & masks[l2];
3168 int m_row_8 = m_row - m_row_16;
3170 for (y = row_and_7; y < h + row_and_7; y++) {
3171 mask[0][
y][0] |= m_row_16;
3172 mask[0][
y][1] |= m_row_8;
3175 for (y = row_and_7; y < h + row_and_7; y++)
3176 mask[0][y][mask_id] |= m_row;
3181 if (ss_v && tx >
TX_8X8 && (h ^ (h - 1)) == 1) {
3182 for (y = row_and_7; y < h + row_and_7 - 1; y += step1d)
3183 mask[1][y][0] |= m_col;
3184 if (y - row_and_7 == h - 1)
3185 mask[1][
y][1] |= m_col;
3187 for (y = row_and_7; y < h + row_and_7; y += step1d)
3188 mask[1][y][mask_id] |= m_col;
3190 }
else if (tx !=
TX_4X4) {
3193 mask_id = (tx ==
TX_8X8) || (h == ss_v);
3194 mask[1][row_and_7][mask_id] |= m_col;
3195 mask_id = (tx ==
TX_8X8) || (w == ss_h);
3196 for (y = row_and_7; y < h + row_and_7; y++)
3197 mask[0][y][mask_id] |= t;
3199 int t8 = t & wide_filter_col_mask[ss_h],
t4 = t -
t8;
3201 for (y = row_and_7; y < h + row_and_7; y++) {
3205 mask[1][row_and_7][2 - !(row_and_7 & wide_filter_row_mask[ss_v])] |= m_col;
3211 struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
3226 s->
min_mv.
x = -(128 + col * 64);
3227 s->
min_mv.
y = -(128 + row * 64);
3235 b->
uvtx = b->tx - ((s->
ss_h && w4 * 2 == (1 << b->tx)) ||
3236 (s->
ss_v && h4 * 2 == (1 << b->tx)));
3241 if (bytesperpixel == 1) {
3254 #define SPLAT_ZERO_CTX(v, n) \
3256 case 1: v = 0; break; \
3257 case 2: AV_ZERO16(&v); break; \
3258 case 4: AV_ZERO32(&v); break; \
3259 case 8: AV_ZERO64(&v); break; \
3260 case 16: AV_ZERO128(&v); break; \
3262 #define SPLAT_ZERO_YUV(dir, var, off, n, dir2) \
3264 SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
3265 if (s->ss_##dir2) { \
3266 SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
3267 SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
3269 SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off * 2], n * 2); \
3270 SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off * 2], n * 2); \
3289 s->
block += w4 * h4 * 64 * bytesperpixel;
3292 s->
eob += 4 * w4 * h4;
3303 emu[0] = (col + w4) * 8 > f->
linesize[0] ||
3304 (row + h4) > s->
rows;
3305 emu[1] = (col + w4) * 4 > f->
linesize[1] ||
3306 (row + h4) > s->
rows;
3311 s->
dst[0] = f->
data[0] + yoff;
3319 s->
dst[1] = f->
data[1] + uvoff;
3320 s->
dst[2] = f->
data[2] + uvoff;
3339 for (
n = 0; o < w;
n++) {
3345 s->
tmp_y + o, 128,
h, 0, 0);
3346 o += bw * bytesperpixel;
3354 for (
n = s->
ss_h; o < w;
n++) {
3360 s->
tmp_uv[0] + o, 128,
h, 0, 0);
3362 s->
tmp_uv[1] + o, 128,
h, 0, 0);
3363 o += bw * bytesperpixel;
3376 mask_edges(lflvl->
mask[0], 0, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
3381 b->
uvtx, skip_inter);
3388 limit >>= (sharp + 3) >> 2;
3389 limit =
FFMIN(limit, 9 - sharp);
3391 limit =
FFMAX(limit, 1);
3400 s->
block += w4 * h4 * 64 * bytesperpixel;
3403 s->
eob += 4 * w4 * h4;
3410 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3418 ptrdiff_t hbs = 4 >> bl;
3425 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3426 }
else if (col + hbs < s->cols) {
3427 if (row + hbs < s->rows) {
3431 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3434 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3435 yoff += hbs * 8 * y_stride;
3436 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3437 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, bl, bp);
3440 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3441 yoff += hbs * 8 * bytesperpixel;
3442 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3443 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, bl, bp);
3446 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3448 yoff + 8 * hbs * bytesperpixel,
3449 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3450 yoff += hbs * 8 * y_stride;
3451 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3452 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3453 decode_sb(ctx, row + hbs, col + hbs, lflvl,
3454 yoff + 8 * hbs * bytesperpixel,
3455 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3462 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3464 yoff + 8 * hbs * bytesperpixel,
3465 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3468 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3470 }
else if (row + hbs < s->rows) {
3473 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3474 yoff += hbs * 8 * y_stride;
3475 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3476 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3479 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3483 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3489 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3493 ptrdiff_t hbs = 4 >> bl;
3500 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3501 }
else if (s->
b->
bl == bl) {
3502 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3504 yoff += hbs * 8 * y_stride;
3505 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3506 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3508 yoff += hbs * 8 * bytesperpixel;
3509 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3510 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, b->
bl, b->
bp);
3514 if (col + hbs < s->cols) {
3515 if (row + hbs < s->rows) {
3516 decode_sb_mem(ctx, row, col + hbs, lflvl, yoff + 8 * hbs * bytesperpixel,
3517 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3518 yoff += hbs * 8 * y_stride;
3519 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3520 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3522 yoff + 8 * hbs * bytesperpixel,
3523 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3525 yoff += hbs * 8 * bytesperpixel;
3526 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3527 decode_sb_mem(ctx, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
3529 }
else if (row + hbs < s->rows) {
3530 yoff += hbs * 8 * y_stride;
3531 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3532 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3544 for (y = 0; y < 8; y += 2 << ss_v, dst += 16 * ls, lvl += 16 << ss_v) {
3545 uint8_t *ptr = dst, *l = lvl, *hmask1 =
mask[
y], *hmask2 =
mask[y + 1 + ss_v];
3546 unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2], hm13 = hmask1[3];
3547 unsigned hm2 = hmask2[1] | hmask2[2], hm23 = hmask2[3];
3548 unsigned hm = hm1 | hm2 | hm13 | hm23;
3550 for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 8 * bytesperpixel >> ss_h) {
3553 int L = *l,
H = L >> 4;
3556 if (hmask1[0] & x) {
3557 if (hmask2[0] & x) {
3563 }
else if (hm2 & x) {
3570 [0](ptr, ls,
E, I,
H);
3573 [0](ptr, ls, E, I, H);
3575 }
else if (hm2 & x) {
3576 int L = l[8 << ss_v],
H = L >> 4;
3580 [0](ptr + 8 * ls, ls, E, I, H);
3588 int L = *l,
H = L >> 4;
3600 }
else if (hm23 & x) {
3601 int L = l[8 << ss_v],
H = L >> 4;
3621 for (y = 0; y < 8; y++, dst += 8 * ls >> ss_v) {
3623 unsigned vm = vmask[0] | vmask[1] | vmask[2], vm3 = vmask[3];
3625 for (x = 1; vm & ~(x - 1); x <<= (2 << ss_h), ptr += 16 * bytesperpixel, l += 2 << ss_h) {
3628 int L = *l,
H = L >> 4;
3632 if (vmask[0] & (x << (1 + ss_h))) {
3638 }
else if (vm & (x << (1 + ss_h))) {
3644 [!!(vmask[1] & (x << (1 + ss_h)))]
3645 [1](ptr, ls,
E, I,
H);
3648 [1](ptr, ls, E, I, H);
3650 }
else if (vm & (x << (1 + ss_h))) {
3651 int L = l[1 + ss_h],
H = L >> 4;
3655 [1](ptr + 8 * bytesperpixel, ls, E, I, H);
3660 int L = *l,
H = L >> 4;
3663 if (vm3 & (x << (1 + ss_h))) {
3672 }
else if (vm3 & (x << (1 + ss_h))) {
3673 int L = l[1 + ss_h],
H = L >> 4;
3690 int row,
int col, ptrdiff_t yoff, ptrdiff_t uvoff)
3708 for (p = 0; p < 2; p++) {
3709 dst = f->
data[1 + p] + uvoff;
3717 int sb_start = ( idx *
n) >> log2_n;
3718 int sb_end = ((idx + 1) * n) >> log2_n;
3719 *start =
FFMIN(sb_start, n) << 3;
3720 *end =
FFMIN(sb_end, n) << 3;
3724 int max_count,
int update_factor)
3726 unsigned ct = ct0 + ct1, p2, p1;
3731 update_factor =
FASTDIV(update_factor *
FFMIN(ct, max_count), max_count);
3733 p2 = ((((int64_t) ct0) << 8) + (ct >> 1)) / ct;
3734 p2 = av_clip(p2, 1, 255);
3737 *p = p1 + (((p2 - p1) * update_factor + 128) >> 8);
3747 for (i = 0; i < 4; i++)
3748 for (j = 0; j < 2; j++)
3749 for (k = 0; k < 2; k++)
3750 for (l = 0; l < 6; l++)
3751 for (m = 0; m < 6; m++) {
3756 if (l == 0 && m >= 3)
3760 adapt_prob(&pp[1], c[0], c[1] + c[2], 24, uf);
3773 for (i = 0; i < 3; i++)
3777 for (i = 0; i < 4; i++)
3782 for (i = 0; i < 5; i++)
3788 for (i = 0; i < 5; i++)
3794 for (i = 0; i < 5; i++) {
3798 adapt_prob(&pp[0], c[0][0], c[0][1], 20, 128);
3799 adapt_prob(&pp[1], c[1][0], c[1][1], 20, 128);
3804 for (i = 0; i < 4; i++)
3805 for (j = 0; j < 4; j++) {
3809 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3810 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3816 for (i = 0; i < 2; i++) {
3822 adapt_prob(&p->
tx32p[i][0], c32[0], c32[1] + c32[2] + c32[3], 20, 128);
3830 for (i = 0; i < 4; i++) {
3834 adapt_prob(&pp[0], c[0], c[1] + c[2], 20, 128);
3840 for (i = 0; i < 7; i++) {
3844 adapt_prob(&pp[0], c[2], c[1] + c[0] + c[3], 20, 128);
3845 adapt_prob(&pp[1], c[0], c[1] + c[3], 20, 128);
3854 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3855 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3860 for (i = 0; i < 2; i++) {
3862 unsigned *
c, (*c2)[2], sum;
3869 sum = c[1] + c[2] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9] + c[10];
3874 adapt_prob(&pp[2], c[2] + c[3], sum, 20, 128);
3877 adapt_prob(&pp[4], c[4] + c[5], sum, 20, 128);
3881 adapt_prob(&pp[7], c[7] + c[8], c[9] + c[10], 20, 128);
3889 for (j = 0; j < 10; j++)
3890 adapt_prob(&pp[j], c2[j][0], c2[j][1], 20, 128);
3892 for (j = 0; j < 2; j++) {
3895 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3896 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3901 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3902 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3914 for (i = 0; i < 4; i++) {
3918 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3938 for (i = 0; i < 10; i++) {
3942 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3974 for (i = 0; i < 3; i++) {
3979 for (i = 0; i < 8; i++) {
4001 int res, tile_row, tile_col, i, ref, row, col;
4004 ptrdiff_t yoff, uvoff, ls_y, ls_uv;
4010 }
else if (res == 0) {
4019 for (i = 0; i < 8; i++) {
4055 for (i = 0; i < 8; i++) {
4084 "Failed to allocate block buffers\n");
4090 for (i = 0; i < 4; i++) {
4091 for (j = 0; j < 2; j++)
4092 for (k = 0; k < 2; k++)
4093 for (l = 0; l < 6; l++)
4094 for (m = 0; m < 6; m++)
4131 if (tile_size > size) {
4148 row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->
ss_v) {
4150 ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
4168 memcpy(&s->
c, &s->
c_b[tile_col],
sizeof(s->
c));
4172 col < s->tiling.tile_col_end;
4173 col += 8, yoff2 += 64 * bytesperpixel,
4174 uvoff2 += 64 * bytesperpixel >> s->
ss_h, lflvl_ptr++) {
4178 memset(lflvl_ptr->
mask, 0,
sizeof(lflvl_ptr->
mask));
4190 memcpy(&s->
c_b[tile_col], &s->
c,
sizeof(s->
c));
4200 if (row + 8 < s->
rows) {
4202 f->
data[0] + yoff + 63 * ls_y,
4203 8 * s->
cols * bytesperpixel);
4205 f->
data[1] + uvoff + ((64 >> s->
ss_v) - 1) * ls_uv,
4206 8 * s->
cols * bytesperpixel >> s->
ss_h);
4208 f->
data[2] + uvoff + ((64 >> s->
ss_v) - 1) * ls_uv,
4209 8 * s->
cols * bytesperpixel >> s->
ss_h);
4216 lflvl_ptr = s->
lflvl;
4217 for (col = 0; col < s->
cols;
4218 col += 8, yoff2 += 64 * bytesperpixel,
4219 uvoff2 += 64 * bytesperpixel >> s->
ss_h, lflvl_ptr++) {
4235 }
while (s->
pass++ == 1);
4239 for (i = 0; i < 8; i++) {
4259 for (i = 0; i < 3; i++)
4261 for (i = 0; i < 8; i++)
4270 for (i = 0; i < 3; i++) {
4278 for (i = 0; i < 8; i++) {
4314 (!ssrc->intra_pred_data[0] || s->
cols != ssrc->cols || s->
rows != ssrc->rows)) {
4318 for (i = 0; i < 3; i++) {
4321 if (ssrc->frames[i].tf.f->data[0]) {
4326 for (i = 0; i < 8; i++) {
4329 if (ssrc->next_refs[i].f->data[0]) {
4338 s->
ss_v = ssrc->ss_v;
4339 s->
ss_h = ssrc->ss_h;
4347 if (ssrc->segmentation.enabled) {
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
uint8_t * segmentation_map
#define AV_PIX_FMT_YUV440P10
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
static av_always_inline void filter_plane_cols(VP9Context *s, int col, int ss_h, int ss_v, uint8_t *lvl, uint8_t(*mask)[4], uint8_t *dst, ptrdiff_t ls)
This structure describes decoded (raw) audio or video data.
static void set_tile_offset(int *start, int *end, int idx, int log2_n, int n)
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
uint8_t left_segpred_ctx[8]
VP5 and VP6 compatible video decoder (common features)
static av_always_inline int get_sbits_inv(GetBitContext *gb, int n)
static const int8_t vp9_segmentation_tree[7][2]
struct VP9Context::@107::@113 feat[MAX_SEGMENT]
static const uint8_t vp9_model_pareto8[256][8]
static av_always_inline void filter_plane_rows(VP9Context *s, int row, int ss_h, int ss_v, uint8_t *lvl, uint8_t(*mask)[4], uint8_t *dst, ptrdiff_t ls)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t(*tree)[2], const uint8_t *probs)
static av_cold int init(AVCodecContext *avctx)
#define SPLAT_CTX(var, val, n)
static int vp9_alloc_frame(AVCodecContext *ctx, VP9Frame *f)
static const uint8_t vp9_default_kf_ymode_probs[10][10][9]
static int decode_coeffs_b_8bpp(VP9Context *s, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
static const int8_t vp9_mv_fp_tree[3][2]
static av_always_inline int check_intra_mode(VP9Context *s, int mode, uint8_t **a, uint8_t *dst_edge, ptrdiff_t stride_edge, uint8_t *dst_inner, ptrdiff_t stride_inner, uint8_t *l, int col, int x, int w, int row, int y, enum TxfmMode tx, int p, int ss_h, int ss_v, int bytesperpixel)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define SET_CTXS(dir, off, n)
#define AV_PIX_FMT_GBRP10
static const int8_t vp9_intramode_tree[9][2]
#define FF_CODEC_PROPERTY_LOSSLESS
#define DECLARE_ALIGNED(n, t, v)
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above ...
static const uint8_t vp9_default_kf_uvmode_probs[10][9]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t left_uv_nnz_ctx[2][16]
#define AV_PIX_FMT_YUV420P12
static int update_size(AVCodecContext *ctx, int w, int h, enum AVPixelFormat fmt)
static void adapt_probs(VP9Context *s)
void(* intra_pred[N_TXFM_SIZES][N_INTRA_PRED_MODES])(uint8_t *dst, ptrdiff_t stride, const uint8_t *left, const uint8_t *top)
static int decode_frame_header(AVCodecContext *ctx, const uint8_t *data, int size, int *ref)
void ff_thread_await_progress(ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
static av_always_inline void mask_edges(uint8_t(*mask)[8][4], int ss_h, int ss_v, int row_and_7, int col_and_7, int w, int h, int col_end, int row_end, enum TxfmMode tx, int skip_inter)
static int vp9_decode_frame(AVCodecContext *ctx, void *frame, int *got_frame, AVPacket *pkt)
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
struct VP9Context::@112 max_mv
uint8_t * intra_pred_data[3]
vp9_mc_func mc[5][4][2][2][2]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void intra_recon_16bpp(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
static void vp9_unref_frame(AVCodecContext *ctx, VP9Frame *f)
void(* emulated_edge_mc)(uint8_t *dst, const uint8_t *src, ptrdiff_t dst_linesize, ptrdiff_t src_linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
uint8_t coef[4][2][2][6][6][3]
static av_always_inline void inter_recon(AVCodecContext *ctx, int bytesperpixel)
static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
AVColorSpace
YUV colorspace type.
static void free_buffers(VP9Context *s)
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
static const int16_t vp9_ac_qlookup[3][256]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define FF_PROFILE_UNKNOWN
static const uint8_t vp9_default_coef_probs[4][2][2][6][6][3]
struct VP9Context::@109 prob_ctx[4]
static av_cold int vp9_decode_free(AVCodecContext *ctx)
int ff_thread_ref_frame(ThreadFrame *dst, ThreadFrame *src)
bitstream reader API header.
uint8_t * above_uv_nnz_ctx[2]
static av_always_inline void clamp_mv(VP56mv *dst, const VP56mv *src, VP9Context *s)
#define AV_PIX_FMT_YUV422P12
static void decode_sb(AVCodecContext *ctx, int row, int col, struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
struct VP9Context::@111::@114 mv_comp[2]
#define assign_val(c, i, v)
static void intra_recon_8bpp(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given block if it is not large enough, otherwise do nothing.
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f)
Wrapper around release_buffer() frame-for multithreaded codecs.
static int update_block_buffers(AVCodecContext *ctx)
static const uint16_t mask[17]
enum CompPredMode comppredmode
static const int8_t vp9_mv_class_tree[10][2]
uint8_t left_partition_ctx[8]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static enum FilterMode vp9_filter_lut[3]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int active_thread_type
Which multithreading methods are in use by the codec.
struct VP9Context::@106 lf_delta
struct VP9Context::@108 tiling
static int decode_coeffs_8bpp(AVCodecContext *ctx)
struct prob_context::@115 mv_comp[2]
static void inter_recon_16bpp(AVCodecContext *ctx)
#define MERGE_CTX(step, rd)
static int decode_coeffs_b32_8bpp(VP9Context *s, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
static av_always_inline void mc_chroma_unscaled(VP9Context *s, vp9_mc_func(*mc)[2], uint8_t *dst_u, uint8_t *dst_v, ptrdiff_t dst_stride, const uint8_t *ref_u, ptrdiff_t src_stride_u, const uint8_t *ref_v, ptrdiff_t src_stride_v, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h, int bytesperpixel)
simple assert() macros that are a bit more flexible than ISO C assert().
static void find_ref_mvs(VP9Context *s, VP56mv *pmv, int ref, int z, int idx, int sb)
static enum TxfmType vp9_intra_txfm_type[14]
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_YUV444P10
int16_t * uvblock_base[2]
uint8_t use_last_frame_mvs
Libavcodec external API header.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
uint8_t * above_filter_ctx
#define RETURN_DIRECT_MV(mv)
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
static void vp9_decode_flush(AVCodecContext *ctx)
static void loopfilter_sb(AVCodecContext *ctx, struct VP9Filter *lflvl, int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff)
int ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
static av_always_inline void mc_chroma_scaled(VP9Context *s, vp9_scaled_mc_func smc, uint8_t *dst_u, uint8_t *dst_v, ptrdiff_t dst_stride, const uint8_t *ref_u, ptrdiff_t src_stride_u, const uint8_t *ref_v, ptrdiff_t src_stride_v, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv, int px, int py, int pw, int ph, int bw, int bh, int w, int h, int bytesperpixel, const uint16_t *scale, const uint8_t *step)
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
static void decode_mode(AVCodecContext *ctx)
enum AVPictureType pict_type
Picture type of the frame.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
VP56mv left_mv_ctx[16][2]
uint8_t left_y_nnz_ctx[16]
int width
picture width / height.
static int decode_coeffs_16bpp(AVCodecContext *ctx)
uint8_t left_mode_ctx[16]
static void decode_sb_mem(AVCodecContext *ctx, int row, int col, struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl)
unsigned eob[4][2][2][6][6][2]
ITU-R BT2020 non-constant luminance system.
void(* loop_filter_16[2])(uint8_t *dst, ptrdiff_t stride, int mb_lim, int lim, int hev_thr)
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
uint8_t partition[4][4][3]
static const AVProfile profiles[]
static av_always_inline void mc_luma_unscaled(VP9Context *s, vp9_mc_func(*mc)[2], uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *mv, int bw, int bh, int w, int h, int bytesperpixel)
av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp)
enum FilterMode filtermode
static void inter_recon_8bpp(AVCodecContext *ctx)
static const uint8_t bwh_tab[2][N_BS_SIZES][2]
uint8_t * above_partition_ctx
static av_cold int vp9_decode_init_thread_copy(AVCodecContext *avctx)
static const int8_t vp9_inter_mode_tree[3][2]
#define vp56_rac_get_prob
static int init_frames(AVCodecContext *ctx)
uint8_t * above_segpred_ctx
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
static const float pred[4]
static const int8_t mv[256][2]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
void(* loop_filter_mix2[2][2][2])(uint8_t *dst, ptrdiff_t stride, int mb_lim, int lim, int hev_thr)
static av_always_inline int vp56_rac_get_prob_branchy(VP56RangeCoder *c, int prob)
void(* vp9_scaled_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, int h, int mx, int my, int dx, int dy)
void(* loop_filter_8[3][2])(uint8_t *dst, ptrdiff_t stride, int mb_lim, int lim, int hev_thr)
#define STORE_COEF(c, i, v)
VP56mv(* above_mv_ctx)[2]
struct VP9Context::@110 prob
static const prob_context vp9_default_probs
void(* vp9_mc_func)(uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, int h, int mx, int my)
static void fill_mv(VP9Context *s, VP56mv *mv, int mode, int sb)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define memset_bpp(c, i1, v, i2, num)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
int ff_thread_get_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
uint8_t * data
The data buffer.
static av_cold int vp9_decode_init(AVCodecContext *ctx)
unsigned single_ref[5][2][2]
AVBufferRef * av_buffer_allocz(int size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
static unsigned int get_bits1(GetBitContext *s)
#define AV_PIX_FMT_YUV420P10
#define FF_THREAD_FRAME
Decode more than one frame at once.
unsigned partition[4][4][4]
uint8_t * above_y_nnz_ctx
static void skip_bits(GetBitContext *s, int n)
static av_always_inline int decode_coeffs(AVCodecContext *ctx, int is8bitsperpixel)
enum AVColorSpace colorspace
YUV colorspace type.
static const int16_t *const vp9_scans[5][4]
#define SPLAT_ZERO_YUV(dir, var, off, n, dir2)
#define DECODE_Y_COEF_LOOP(step, mode_index, v)
static const int8_t vp9_filter_tree[2][2]
static av_always_inline void mc_luma_scaled(VP9Context *s, vp9_scaled_mc_func smc, uint8_t *dst, ptrdiff_t dst_stride, const uint8_t *ref, ptrdiff_t ref_stride, ThreadFrame *ref_frame, ptrdiff_t y, ptrdiff_t x, const VP56mv *in_mv, int px, int py, int pw, int ph, int bw, int bh, int w, int h, int bytesperpixel, const uint16_t *scale, const uint8_t *step)
#define AV_PIX_FMT_YUV440P12
uint8_t left_filter_ctx[8]
uint8_t * above_intra_ctx
#define assign_bpp(c, i1, v, i2)
int allocate_progress
Whether to allocate progress for frame threading.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
struct VP9Context::@107 segmentation
static int vp8_rac_get_uint(VP56RangeCoder *c, int bits)
#define AV_PIX_FMT_GBRP12
static int vp9_ref_frame(AVCodecContext *ctx, VP9Frame *dst, VP9Frame *src)
#define AV_PIX_FMT_YUV422P10
struct VP9Context::@105 filter
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
the normal 219*2^(n-8) "MPEG" YUV ranges
struct VP9Context::@111 counts
#define LOCAL_ALIGNED_32(t, v,...)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
A reference to a data buffer.
static av_always_inline int inv_recenter_nonneg(int v, int m)
static int decode_coeffs_b32_16bpp(VP9Context *s, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
GLint GLenum GLboolean GLsizei stride
static av_always_inline int decode_coeffs_b_generic(VP56RangeCoder *c, int16_t *coef, int n_coeffs, int is_tx32x32, int is8bitsperpixel, int bpp, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
void(* itxfm_add[N_TXFM_SIZES+1][N_TXFM_TYPES])(uint8_t *dst, ptrdiff_t stride, int16_t *block, int eob)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
static const uint8_t vp9_default_kf_partition_probs[4][4][3]
static int ref_frame(Vp3DecodeContext *s, ThreadFrame *dst, ThreadFrame *src)
#define assign(var, type, n)
uint8_t tmp_uv[2][64 *64 *2]
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static av_always_inline int vp8_rac_get(VP56RangeCoder *c)
static const int16_t vp9_dc_qlookup[3][256]
Core video DSP helper functions.
static av_always_inline void setctx_2d(uint8_t *ptr, int w, int h, ptrdiff_t stride, int v)
static const int8_t vp9_mv_joint_tree[3][2]
static av_always_inline int read_mv_component(VP9Context *s, int idx, int hp)
struct VP9Context::@112 min_mv
#define memset_val(c, val, num)
struct AVCodecInternal * internal
Private context used for internal data.
static int decode012(GetBitContext *gb)
int key_frame
1 -> keyframe, 0-> not
static void decode_b(AVCodecContext *ctx, int row, int col, struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp)
uint8_t edge_emu_buffer[135 *144 *2]
static const uint8_t * align_get_bits(GetBitContext *s)
#define DECODE_UV_COEF_LOOP(step, v)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static av_always_inline void adapt_prob(uint8_t *p, unsigned ct0, unsigned ct1, int max_count, int update_factor)
static const int16_t(*const [5][4] vp9_scans_nb)[2]
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
static int init_thread_copy(AVCodecContext *avctx)
static enum AVPixelFormat read_colorspace_details(AVCodecContext *ctx)
static int update_prob(VP56RangeCoder *c, int p)
#define av_malloc_array(a, b)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
uint8_t left_intra_ctx[8]
AVPixelFormat
Pixel format.
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define RETURN_SCALE_MV(mv, scale)
int block_alloc_using_2pass
static int decode_coeffs_b_16bpp(VP9Context *s, int16_t *coef, int n_coeffs, unsigned(*cnt)[6][3], unsigned(*eob)[6][2], uint8_t(*p)[6][11], int nnz, const int16_t *scan, const int16_t(*nb)[2], const int16_t *band_counts, const int16_t *qmul)
static const int8_t vp9_partition_tree[3][2]
static av_always_inline void intra_recon(AVCodecContext *ctx, ptrdiff_t y_off, ptrdiff_t uv_off, int bytesperpixel)