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 },
328 s->
cols = (w + 7) >> 3;
329 s->
rows = (h + 7) >> 3;
331 #define assign(var, type, n) var = (type) p; p += s->sb_cols * (n) * sizeof(*var)
374 int chroma_blocks, chroma_eobs, bytesperpixel = s->
bytesperpixel;
381 chroma_blocks = 64 * 64 >> (s->
ss_h + s->
ss_v);
382 chroma_eobs = 16 * 16 >> (s->
ss_h + s->
ss_v);
388 16 * 16 + 2 * chroma_eobs) * sbs);
399 16 * 16 + 2 * chroma_eobs);
422 return v > 2 * m ? v : v & 1 ? m - ((v + 1) >> 1) : m + (v >> 1);
428 static const int inv_map_table[255] = {
429 7, 20, 33, 46, 59, 72, 85, 98, 111, 124, 137, 150, 163, 176,
430 189, 202, 215, 228, 241, 254, 1, 2, 3, 4, 5, 6, 8, 9,
431 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 24,
432 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39,
433 40, 41, 42, 43, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54,
434 55, 56, 57, 58, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
435 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
436 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 99, 100,
437 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 112, 113, 114, 115,
438 116, 117, 118, 119, 120, 121, 122, 123, 125, 126, 127, 128, 129, 130,
439 131, 132, 133, 134, 135, 136, 138, 139, 140, 141, 142, 143, 144, 145,
440 146, 147, 148, 149, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
441 161, 162, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
442 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 190, 191,
443 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 203, 204, 205, 206,
444 207, 208, 209, 210, 211, 212, 213, 214, 216, 217, 218, 219, 220, 221,
445 222, 223, 224, 225, 226, 227, 229, 230, 231, 232, 233, 234, 235, 236,
446 237, 238, 239, 240, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251,
495 s->
bpp = 8 + bits * 2;
504 res = pix_fmt_rgb[
bits];
512 static const enum AVPixelFormat pix_fmt_for_ss[3][2 ][2 ] = {
535 res = pix_fmt_for_ss[
bits][1][1];
546 int c, i, j, k, l,
m,
n, w,
h, max, size2, res, sharp;
670 for (i = 0; i < 3; i++) {
676 "Ref pixfmt (%s) did not match current frame (%s)",
680 }
else if (refw == w && refh == h) {
683 if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 16 * refh) {
685 "Invalid ref frame dimensions %dx%d for frame size %dx%d\n",
689 s->
mvscale[i][0] = (refw << 14) / w;
690 s->
mvscale[i][1] = (refh << 14) / h;
720 for (i = 0; i < 4; i++)
723 for (i = 0; i < 2; i++)
741 for (i = 0; i < 7; i++)
745 for (i = 0; i < 3; i++)
754 "Reference segmap (temp=%d,update=%d) enabled on size-change!\n",
762 for (i = 0; i < 8; i++) {
781 int qyac, qydc, quvac, quvdc, lflvl, sh;
791 qydc = av_clip_uintp2(qyac + s->
ydc_qdelta, 8);
794 qyac = av_clip_uintp2(qyac, 8);
813 av_clip_uintp2(lflvl + (s->
lf_delta.
ref[0] << sh), 6);
814 for (j = 1; j < 4; j++) {
830 av_log(ctx,
AV_LOG_ERROR,
"Failed to initialize decoder for %dx%d @ %d\n", w, h, fmt);
836 for (max = 0; (s->
sb_cols >> max) >= 4; max++) ;
837 max =
FFMAX(0, max - 1);
872 if (size2 > size - (data2 - data)) {
902 for (i = 0; i < 2; i++)
905 for (i = 0; i < 2; i++)
906 for (j = 0; j < 2; j++)
910 for (i = 0; i < 2; i++)
911 for (j = 0; j < 3; j++)
919 for (i = 0; i < 4; i++) {
922 for (j = 0; j < 2; j++)
923 for (k = 0; k < 2; k++)
924 for (l = 0; l < 6; l++)
925 for (m = 0; m < 6; m++) {
928 if (m >= 3 && l == 0)
930 for (n = 0; n < 3; n++) {
940 for (j = 0; j < 2; j++)
941 for (k = 0; k < 2; k++)
942 for (l = 0; l < 6; l++)
943 for (m = 0; m < 6; m++) {
957 for (i = 0; i < 3; i++)
961 for (i = 0; i < 7; i++)
962 for (j = 0; j < 3; j++)
968 for (i = 0; i < 4; i++)
969 for (j = 0; j < 2; j++)
974 for (i = 0; i < 4; i++)
983 for (i = 0; i < 5; i++)
992 for (i = 0; i < 5; i++) {
1003 for (i = 0; i < 5; i++)
1009 for (i = 0; i < 4; i++)
1010 for (j = 0; j < 9; j++)
1015 for (i = 0; i < 4; i++)
1016 for (j = 0; j < 4; j++)
1017 for (k = 0; k < 3; k++)
1023 for (i = 0; i < 3; i++)
1027 for (i = 0; i < 2; i++) {
1031 for (j = 0; j < 10; j++)
1039 for (j = 0; j < 10; j++)
1045 for (i = 0; i < 2; i++) {
1046 for (j = 0; j < 2; j++)
1047 for (k = 0; k < 3; k++)
1052 for (j = 0; j < 3; j++)
1059 for (i = 0; i < 2; i++) {
1071 return (data2 - data) + size2;
1082 VP56mv *pmv,
int ref,
int z,
int idx,
int sb)
1084 static const int8_t mv_ref_blk_off[
N_BS_SIZES][8][2] = {
1085 [
BS_64x64] = {{ 3, -1 }, { -1, 3 }, { 4, -1 }, { -1, 4 },
1086 { -1, -1 }, { 0, -1 }, { -1, 0 }, { 6, -1 }},
1087 [
BS_64x32] = {{ 0, -1 }, { -1, 0 }, { 4, -1 }, { -1, 2 },
1088 { -1, -1 }, { 0, -3 }, { -3, 0 }, { 2, -1 }},
1089 [
BS_32x64] = {{ -1, 0 }, { 0, -1 }, { -1, 4 }, { 2, -1 },
1090 { -1, -1 }, { -3, 0 }, { 0, -3 }, { -1, 2 }},
1091 [
BS_32x32] = {{ 1, -1 }, { -1, 1 }, { 2, -1 }, { -1, 2 },
1092 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1093 [
BS_32x16] = {{ 0, -1 }, { -1, 0 }, { 2, -1 }, { -1, -1 },
1094 { -1, 1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1095 [
BS_16x32] = {{ -1, 0 }, { 0, -1 }, { -1, 2 }, { -1, -1 },
1096 { 1, -1 }, { -3, 0 }, { 0, -3 }, { -3, -3 }},
1097 [
BS_16x16] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, 1 },
1098 { -1, -1 }, { 0, -3 }, { -3, 0 }, { -3, -3 }},
1099 [
BS_16x8] = {{ 0, -1 }, { -1, 0 }, { 1, -1 }, { -1, -1 },
1100 { 0, -2 }, { -2, 0 }, { -2, -1 }, { -1, -2 }},
1101 [
BS_8x16] = {{ -1, 0 }, { 0, -1 }, { -1, 1 }, { -1, -1 },
1102 { -2, 0 }, { 0, -2 }, { -1, -2 }, { -2, -1 }},
1103 [
BS_8x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1104 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1105 [
BS_8x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1106 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1107 [
BS_4x8] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1108 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1109 [
BS_4x4] = {{ 0, -1 }, { -1, 0 }, { -1, -1 }, { 0, -2 },
1110 { -2, 0 }, { -1, -2 }, { -2, -1 }, { -2, -2 }},
1113 int row = s->
row, col = s->
col, row7 = s->
row7;
1114 const int8_t (*p)[2] = mv_ref_blk_off[b->
bs];
1115 #define INVALID_MV 0x80008000U
1119 #define RETURN_DIRECT_MV(mv) \
1121 uint32_t m = AV_RN32A(&mv); \
1125 } else if (mem == INVALID_MV) { \
1127 } else if (m != mem) { \
1134 if (sb == 2 || sb == 1) {
1136 }
else if (sb == 3) {
1142 #define RETURN_MV(mv) \
1147 av_assert2(idx == 1); \
1148 av_assert2(mem != INVALID_MV); \
1149 if (mem_sub8x8 == INVALID_MV) { \
1150 clamp_mv(&tmp, &mv, s); \
1151 m = AV_RN32A(&tmp); \
1156 mem_sub8x8 = AV_RN32A(&mv); \
1157 } else if (mem_sub8x8 != AV_RN32A(&mv)) { \
1158 clamp_mv(&tmp, &mv, s); \
1159 m = AV_RN32A(&tmp); \
1169 uint32_t m = AV_RN32A(&mv); \
1171 clamp_mv(pmv, &mv, s); \
1173 } else if (mem == INVALID_MV) { \
1175 } else if (m != mem) { \
1176 clamp_mv(pmv, &mv, s); \
1184 if (mv->
ref[0] == ref) {
1186 }
else if (mv->
ref[1] == ref) {
1192 if (mv->
ref[0] == ref) {
1194 }
else if (mv->
ref[1] == ref) {
1204 for (; i < 8; i++) {
1205 int c = p[i][0] + col,
r = p[i][1] + row;
1210 if (mv->
ref[0] == ref) {
1212 }
else if (mv->
ref[1] == ref) {
1224 if (mv->
ref[0] == ref) {
1226 }
else if (mv->
ref[1] == ref) {
1231 #define RETURN_SCALE_MV(mv, scale) \
1234 VP56mv mv_temp = { -mv.x, -mv.y }; \
1235 RETURN_MV(mv_temp); \
1242 for (i = 0; i < 8; i++) {
1243 int c = p[i][0] + col,
r = p[i][1] + row;
1248 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1251 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1265 if (mv->
ref[0] != ref && mv->
ref[0] >= 0) {
1268 if (mv->
ref[1] != ref && mv->
ref[1] >= 0 &&
1280 #undef RETURN_SCALE_MV
1294 for (n = 0, m = 0; m <
c; m++) {
1320 n = (n << 3) | (bit << 1);
1333 return sign ? -(n + 1) : (n + 1);
1348 mode ==
NEWMV ? -1 : sb);
1350 if ((mode ==
NEWMV || sb == -1) &&
1365 if (mode ==
NEWMV) {
1379 mode ==
NEWMV ? -1 : sb);
1380 if ((mode ==
NEWMV || sb == -1) &&
1395 if (mode ==
NEWMV) {
1420 int v16 = v * 0x0101;
1428 uint32_t v32 = v * 0x01010101;
1437 uint64_t v64 = v * 0x0101010101010101ULL;
1443 uint32_t v32 = v * 0x01010101;
1458 0x0, 0x8, 0x0, 0x8, 0xc, 0x8, 0xc, 0xe, 0xc, 0xe, 0xf, 0xe, 0xf
1461 0x0, 0x0, 0x8, 0x8, 0x8, 0xc, 0xc, 0xc, 0xe, 0xe, 0xe, 0xf, 0xf
1469 int row = s->
row, col = s->
col, row7 = s->
row7;
1470 enum TxfmMode max_tx = max_tx_for_bl_bp[b->
bs];
1474 int vref, filter_id;
1491 for (
y = 0;
y < h4;
y++) {
1492 int idx_base = (
y + row) * 8 * s->
sb_cols + col;
1493 for (x = 0; x < w4; x++)
1494 pred =
FFMIN(pred, refsegmap[idx_base + x]);
1532 if (have_a && have_l) {
1556 }
else if (have_l) {
1604 l[0] = a[1] = b->
mode[1];
1606 l[0] = a[1] = b->
mode[1] = b->
mode[0];
1614 l[1] = a[1] = b->
mode[3];
1616 l[1] = a[1] = b->
mode[3] = b->
mode[2];
1620 l[1] = a[1] = b->
mode[3] = b->
mode[1];
1632 }
else if (b->
intra) {
1661 static const uint8_t size_group[10] = {
1662 3, 3, 3, 3, 2, 2, 2, 1, 1, 1
1664 int sz = size_group[b->
bs];
1675 static const uint8_t inter_mode_ctx_lut[14][14] = {
1676 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1677 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1678 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1679 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1680 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1681 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1682 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1683 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1684 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1685 { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5 },
1686 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1687 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 1, 3 },
1688 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 0, 3 },
1689 { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4 },
1724 }
else if (have_l) {
1755 if (refl == refa && refa == s->
varcompref[1]) {
1762 c = (refa == refl) ? 3 : 1;
1779 c = (refl == refa) ? 4 : 2;
1791 }
else if (have_l) {
1917 }
else if (have_l) {
1931 b->
ref[0] = 1 + bit;
1940 static const uint8_t off[10] = {
1941 3, 0, 0, 1, 0, 0, 0, 0, 0, 0
2037 #define SPLAT_CTX(var, val, n) \
2039 case 1: var = val; break; \
2040 case 2: AV_WN16A(&var, val * 0x0101); break; \
2041 case 4: AV_WN32A(&var, val * 0x01010101); break; \
2042 case 8: AV_WN64A(&var, val * 0x0101010101010101ULL); break; \
2044 uint64_t v64 = val * 0x0101010101010101ULL; \
2045 AV_WN64A( &var, v64); \
2046 AV_WN64A(&((uint8_t *) &var)[8], v64); \
2051 #define SPLAT_CTX(var, val, n) \
2053 case 1: var = val; break; \
2054 case 2: AV_WN16A(&var, val * 0x0101); break; \
2055 case 4: AV_WN32A(&var, val * 0x01010101); break; \
2057 uint32_t v32 = val * 0x01010101; \
2058 AV_WN32A( &var, v32); \
2059 AV_WN32A(&((uint8_t *) &var)[4], v32); \
2063 uint32_t v32 = val * 0x01010101; \
2064 AV_WN32A( &var, v32); \
2065 AV_WN32A(&((uint8_t *) &var)[4], v32); \
2066 AV_WN32A(&((uint8_t *) &var)[8], v32); \
2067 AV_WN32A(&((uint8_t *) &var)[12], v32); \
2074 #define SET_CTXS(dir, off, n) \
2076 SPLAT_CTX(s->dir##_skip_ctx[off], b->skip, n); \
2077 SPLAT_CTX(s->dir##_txfm_ctx[off], b->tx, n); \
2078 SPLAT_CTX(s->dir##_partition_ctx[off], dir##_ctx[b->bs], n); \
2079 if (!s->keyframe && !s->intraonly) { \
2080 SPLAT_CTX(s->dir##_intra_ctx[off], b->intra, n); \
2081 SPLAT_CTX(s->dir##_comp_ctx[off], b->comp, n); \
2082 SPLAT_CTX(s->dir##_mode_ctx[off], b->mode[3], n); \
2084 SPLAT_CTX(s->dir##_ref_ctx[off], vref, n); \
2085 if (s->filtermode == FILTER_SWITCHABLE) { \
2086 SPLAT_CTX(s->dir##_filter_ctx[off], filter_id, n); \
2091 case 1:
SET_CTXS(above, col, 1);
break;
2092 case 2:
SET_CTXS(above, col, 2);
break;
2093 case 4:
SET_CTXS(above, col, 4);
break;
2094 case 8:
SET_CTXS(above, col, 8);
break;
2097 case 1:
SET_CTXS(left, row7, 1);
break;
2098 case 2:
SET_CTXS(left, row7, 2);
break;
2099 case 4:
SET_CTXS(left, row7, 4);
break;
2100 case 8:
SET_CTXS(left, row7, 8);
break;
2120 for (n = 0; n < w4 * 2; n++) {
2124 for (n = 0; n < h4 * 2; n++) {
2132 for (
y = 0;
y < h4;
y++) {
2133 int x, o = (row +
y) * s->
sb_cols * 8 + col;
2137 for (x = 0; x < w4; x++) {
2141 }
else if (b->
comp) {
2142 for (x = 0; x < w4; x++) {
2143 mv[x].ref[0] = b->
ref[0];
2144 mv[x].ref[1] = b->
ref[1];
2149 for (x = 0; x < w4; x++) {
2150 mv[x].ref[0] = b->
ref[0];
2161 int is_tx32x32,
int is8bitsperpixel,
int bpp,
unsigned (*cnt)[6][3],
2162 unsigned (*eob)[6][2],
uint8_t (*p)[6][11],
2163 int nnz,
const int16_t *scan,
const int16_t (*nb)[2],
2164 const int16_t *band_counts,
const int16_t *qmul)
2166 int i = 0,
band = 0, band_left = band_counts[
band];
2180 cnt[
band][nnz][0]++;
2182 band_left = band_counts[++
band];
2184 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2186 if (++i == n_coeffs)
2193 cnt[
band][nnz][1]++;
2201 cnt[
band][nnz][2]++;
2204 cache[rc] = val = 2;
2238 if (!is8bitsperpixel) {
2263 #define STORE_COEF(c, i, v) do { \
2264 if (is8bitsperpixel) { \
2267 AV_WN32A(&c[i * 2], v); \
2271 band_left = band_counts[++
band];
2276 nnz = (1 + cache[nb[i][0]] + cache[nb[i][1]]) >> 1;
2278 }
while (++i < n_coeffs);
2284 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2285 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2286 const int16_t (*nb)[2],
const int16_t *band_counts,
2287 const int16_t *qmul)
2290 nnz, scan, nb, band_counts, qmul);
2294 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2295 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2296 const int16_t (*nb)[2],
const int16_t *band_counts,
2297 const int16_t *qmul)
2300 nnz, scan, nb, band_counts, qmul);
2304 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2305 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2306 const int16_t (*nb)[2],
const int16_t *band_counts,
2307 const int16_t *qmul)
2310 nnz, scan, nb, band_counts, qmul);
2314 unsigned (*cnt)[6][3],
unsigned (*eob)[6][2],
2315 uint8_t (*p)[6][11],
int nnz,
const int16_t *scan,
2316 const int16_t (*nb)[2],
const int16_t *band_counts,
2317 const int16_t *qmul)
2320 nnz, scan, nb, band_counts, qmul);
2327 int row = s->
row, col = s->
col;
2332 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2333 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2334 int n, pl, x,
y, res;
2337 const int16_t *
const *yscans =
vp9_scans[tx];
2343 static const int16_t band_counts[4][8] = {
2344 { 1, 2, 3, 4, 3, 16 - 13 },
2345 { 1, 2, 3, 4, 11, 64 - 21 },
2346 { 1, 2, 3, 4, 11, 256 - 21 },
2347 { 1, 2, 3, 4, 11, 1024 - 21 },
2349 const int16_t *y_band_counts = band_counts[b->tx];
2350 const int16_t *uv_band_counts = band_counts[b->
uvtx];
2351 int bytesperpixel = is8bitsperpixel ? 1 : 2;
2352 int total_coeff = 0;
2354 #define MERGE(la, end, step, rd) \
2355 for (n = 0; n < end; n += step) \
2356 la[n] = !!rd(&la[n])
2357 #define MERGE_CTX(step, rd) \
2359 MERGE(l, end_y, step, rd); \
2360 MERGE(a, end_x, step, rd); \
2363 #define DECODE_Y_COEF_LOOP(step, mode_index, v) \
2364 for (n = 0, y = 0; y < end_y; y += step) { \
2365 for (x = 0; x < end_x; x += step, n += step * step) { \
2366 enum TxfmType txtp = vp9_intra_txfm_type[b->mode[mode_index]]; \
2367 res = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
2368 (s, s->block + 16 * n * bytesperpixel, 16 * step * step, \
2369 c, e, p, a[x] + l[y], yscans[txtp], \
2370 ynbs[txtp], y_band_counts, qmul[0]); \
2371 a[x] = l[y] = !!res; \
2372 total_coeff |= !!res; \
2374 AV_WN16A(&s->eob[n], res); \
2381 #define SPLAT(la, end, step, cond) \
2383 for (n = 1; n < end; n += step) \
2384 la[n] = la[n - 1]; \
2385 } else if (step == 4) { \
2387 for (n = 0; n < end; n += step) \
2388 AV_WN32A(&la[n], la[n] * 0x01010101); \
2390 for (n = 0; n < end; n += step) \
2391 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 3)); \
2395 if (HAVE_FAST_64BIT) { \
2396 for (n = 0; n < end; n += step) \
2397 AV_WN64A(&la[n], la[n] * 0x0101010101010101ULL); \
2399 for (n = 0; n < end; n += step) { \
2400 uint32_t v32 = la[n] * 0x01010101; \
2401 AV_WN32A(&la[n], v32); \
2402 AV_WN32A(&la[n + 4], v32); \
2406 for (n = 0; n < end; n += step) \
2407 memset(&la[n + 1], la[n], FFMIN(end - n - 1, 7)); \
2410 #define SPLAT_CTX(step) \
2412 SPLAT(a, end_x, step, end_x == w4); \
2413 SPLAT(l, end_y, step, end_y == h4); \
2438 #define DECODE_UV_COEF_LOOP(step, v) \
2439 for (n = 0, y = 0; y < end_y; y += step) { \
2440 for (x = 0; x < end_x; x += step, n += step * step) { \
2441 res = (is8bitsperpixel ? decode_coeffs_b##v##_8bpp : decode_coeffs_b##v##_16bpp) \
2442 (s, s->uvblock[pl] + 16 * n * bytesperpixel, \
2443 16 * step * step, c, e, p, a[x] + l[y], \
2444 uvscan, uvnb, uv_band_counts, qmul[1]); \
2445 a[x] = l[y] = !!res; \
2446 total_coeff |= !!res; \
2448 AV_WN16A(&s->uveob[pl][n], res); \
2450 s->uveob[pl][n] = res; \
2462 for (pl = 0; pl < 2; pl++) {
2501 uint8_t *dst_edge, ptrdiff_t stride_edge,
2502 uint8_t *dst_inner, ptrdiff_t stride_inner,
2503 uint8_t *l,
int col,
int x,
int w,
2505 int p,
int ss_h,
int ss_v,
int bytesperpixel)
2507 int have_top = row > 0 || y > 0;
2509 int have_right = x < w - 1;
2511 static const uint8_t mode_conv[10][2 ][2 ] = {
2533 static const struct {
2542 [
DC_PRED] = { .needs_top = 1, .needs_left = 1 },
2545 [
VERT_RIGHT_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2546 [
HOR_DOWN_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2548 [
HOR_UP_PRED] = { .needs_left = 1, .invert_left = 1 },
2549 [
TM_VP8_PRED] = { .needs_left = 1, .needs_top = 1, .needs_topleft = 1 },
2558 mode = mode_conv[
mode][have_left][have_top];
2559 if (edges[mode].needs_top) {
2561 int n_px_need = 4 << tx, n_px_have = (((s->
cols - col) << !ss_h) - x) * 4;
2562 int n_px_need_tr = 0;
2564 if (tx ==
TX_4X4 && edges[mode].needs_topright && have_right)
2571 top = !(row & 7) && !y ?
2573 y == 0 ? &dst_edge[-stride_edge] : &dst_inner[-stride_inner];
2575 topleft = !(row & 7) && !y ?
2577 y == 0 || x == 0 ? &dst_edge[-stride_edge] :
2578 &dst_inner[-stride_inner];
2582 (!edges[mode].needs_topleft || (have_left && top == topleft)) &&
2583 (tx !=
TX_4X4 || !edges[mode].needs_topright || have_right) &&
2584 n_px_need + n_px_need_tr <= n_px_have) {
2588 if (n_px_need <= n_px_have) {
2589 memcpy(*a, top, n_px_need * bytesperpixel);
2591 #define memset_bpp(c, i1, v, i2, num) do { \
2592 if (bytesperpixel == 1) { \
2593 memset(&(c)[(i1)], (v)[(i2)], (num)); \
2595 int n, val = AV_RN16A(&(v)[(i2) * 2]); \
2596 for (n = 0; n < (num); n++) { \
2597 AV_WN16A(&(c)[((i1) + n) * 2], val); \
2601 memcpy(*a, top, n_px_have * bytesperpixel);
2602 memset_bpp(*a, n_px_have, (*a), n_px_have - 1, n_px_need - n_px_have);
2605 #define memset_val(c, val, num) do { \
2606 if (bytesperpixel == 1) { \
2607 memset((c), (val), (num)); \
2610 for (n = 0; n < (num); n++) { \
2611 AV_WN16A(&(c)[n * 2], (val)); \
2615 memset_val(*a, (128 << (bpp - 8)) - 1, n_px_need);
2617 if (edges[mode].needs_topleft) {
2618 if (have_left && have_top) {
2619 #define assign_bpp(c, i1, v, i2) do { \
2620 if (bytesperpixel == 1) { \
2621 (c)[(i1)] = (v)[(i2)]; \
2623 AV_COPY16(&(c)[(i1) * 2], &(v)[(i2) * 2]); \
2628 #define assign_val(c, i, v) do { \
2629 if (bytesperpixel == 1) { \
2632 AV_WN16A(&(c)[(i) * 2], (v)); \
2635 assign_val((*a), -1, (128 << (bpp - 8)) + (have_top ? +1 : -1));
2638 if (tx ==
TX_4X4 && edges[mode].needs_topright) {
2639 if (have_top && have_right &&
2640 n_px_need + n_px_need_tr <= n_px_have) {
2641 memcpy(&(*a)[4 * bytesperpixel], &top[4 * bytesperpixel], 4 * bytesperpixel);
2648 if (edges[mode].needs_left) {
2650 int n_px_need = 4 << tx, i, n_px_have = (((s->
rows - row) << !ss_v) -
y) * 4;
2651 uint8_t *dst = x == 0 ? dst_edge : dst_inner;
2652 ptrdiff_t
stride = x == 0 ? stride_edge : stride_inner;
2654 if (edges[mode].invert_left) {
2655 if (n_px_need <= n_px_have) {
2656 for (i = 0; i < n_px_need; i++)
2659 for (i = 0; i < n_px_have; i++)
2661 memset_bpp(l, n_px_have, l, n_px_have - 1, n_px_need - n_px_have);
2664 if (n_px_need <= n_px_have) {
2665 for (i = 0; i < n_px_need; i++)
2666 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
2668 for (i = 0; i < n_px_have; i++)
2669 assign_bpp(l, n_px_need - 1 - i, &dst[i * stride], -1);
2670 memset_bpp(l, 0, l, n_px_need - n_px_have, n_px_need - n_px_have);
2674 memset_val(l, (128 << (bpp - 8)) + 1, 4 << tx);
2682 ptrdiff_t uv_off,
int bytesperpixel)
2686 int row = s->
row, col = s->
col;
2687 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
2688 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
2689 int end_x =
FFMIN(2 * (s->
cols - col), w4);
2690 int end_y =
FFMIN(2 * (s->
rows - row), h4);
2692 int uvstep1d = 1 << b->
uvtx, p;
2697 for (
n = 0, y = 0; y < end_y; y += step1d) {
2698 uint8_t *ptr = dst, *ptr_r = dst_r;
2699 for (x = 0; x < end_x; x += step1d, ptr += 4 * step1d * bytesperpixel,
2700 ptr_r += 4 * step1d * bytesperpixel,
n += step) {
2710 col, x, w4, row, y, b->tx, 0, 0, 0, bytesperpixel);
2714 s->
block + 16 * n * bytesperpixel, eob);
2724 step = 1 << (b->
uvtx * 2);
2725 for (p = 0; p < 2; p++) {
2726 dst = s->
dst[1 + p];
2728 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
2729 uint8_t *ptr = dst, *ptr_r = dst_r;
2730 for (x = 0; x < end_x; x += uvstep1d, ptr += 4 * uvstep1d * bytesperpixel,
2731 ptr_r += 4 * uvstep1d * bytesperpixel,
n += step) {
2738 ptr, s->
uv_stride, l, col, x, w4, row, y,
2743 s->
uvblock[p] + 16 * n * bytesperpixel, eob);
2762 uint8_t *dst, ptrdiff_t dst_stride,
2763 const uint8_t *ref, ptrdiff_t ref_stride,
2765 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *in_mv,
2766 int px,
int py,
int pw,
int ph,
2767 int bw,
int bh,
int w,
int h,
int bytesperpixel,
2768 const uint16_t *scale,
const uint8_t *step)
2770 #define scale_mv(n, dim) (((int64_t)(n) * scale[dim]) >> 14)
2772 int refbw_m1, refbh_m1;
2776 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 3, (s->
cols * 8 - x + px + 3) << 3);
2777 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 3, (s->
rows * 8 - y + py + 3) << 3);
2786 ref += y * ref_stride + x * bytesperpixel;
2789 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
2790 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
2794 th = (y + refbh_m1 + 4 + 7) >> 6;
2796 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
2798 ref - 3 * ref_stride - 3 * bytesperpixel,
2800 refbw_m1 + 8, refbh_m1 + 8,
2801 x - 3, y - 3, w, h);
2805 smc(dst, dst_stride, ref, ref_stride, bh, mx, my, step[0], step[1]);
2810 ptrdiff_t dst_stride,
2811 const uint8_t *ref_u, ptrdiff_t src_stride_u,
2812 const uint8_t *ref_v, ptrdiff_t src_stride_v,
2814 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *in_mv,
2815 int px,
int py,
int pw,
int ph,
2816 int bw,
int bh,
int w,
int h,
int bytesperpixel,
2817 const uint16_t *scale,
const uint8_t *step)
2820 int refbw_m1, refbh_m1;
2826 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 4, (s->
cols * 4 - x + px + 3) << 4);
2829 mv.
x = av_clip(in_mv->
x, -(x + pw - px + 4) << 3, (s->
cols * 8 - x + px + 3) << 3);
2834 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 4, (s->
rows * 4 - y + py + 3) << 4);
2837 mv.
y = av_clip(in_mv->
y, -(y + ph - py + 4) << 3, (s->
rows * 8 - y + py + 3) << 3);
2843 ref_u += y * src_stride_u + x * bytesperpixel;
2844 ref_v += y * src_stride_v + x * bytesperpixel;
2847 refbw_m1 = ((bw - 1) * step[0] + mx) >> 4;
2848 refbh_m1 = ((bh - 1) * step[1] + my) >> 4;
2852 th = (y + refbh_m1 + 4 + 7) >> (6 - s->
ss_v);
2854 if (x < 3 || y < 3 || x + 4 >= w - refbw_m1 || y + 4 >= h - refbh_m1) {
2856 ref_u - 3 * src_stride_u - 3 * bytesperpixel,
2858 refbw_m1 + 8, refbh_m1 + 8,
2859 x - 3, y - 3, w, h);
2861 smc(dst_u, dst_stride, ref_u, 288, bh, mx, my, step[0], step[1]);
2864 ref_v - 3 * src_stride_v - 3 * bytesperpixel,
2866 refbw_m1 + 8, refbh_m1 + 8,
2867 x - 3, y - 3, w, h);
2869 smc(dst_v, dst_stride, ref_v, 288, bh, mx, my, step[0], step[1]);
2871 smc(dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my, step[0], step[1]);
2872 smc(dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my, step[0], step[1]);
2876 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
2877 px, py, pw, ph, bw, bh, w, h, i) \
2878 mc_luma_scaled(s, s->dsp.s##mc, dst, dst_ls, src, src_ls, tref, row, col, \
2879 mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
2880 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
2881 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2882 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
2883 mc_chroma_scaled(s, s->dsp.s##mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2884 row, col, mv, px, py, pw, ph, bw, bh, w, h, bytesperpixel, \
2885 s->mvscale[b->ref[i]], s->mvstep[b->ref[i]])
2887 #define FN(x) x##_scaled_8bpp
2888 #define BYTES_PER_PIXEL 1
2891 #undef BYTES_PER_PIXEL
2892 #define FN(x) x##_scaled_16bpp
2893 #define BYTES_PER_PIXEL 2
2896 #undef mc_chroma_dir
2898 #undef BYTES_PER_PIXEL
2902 uint8_t *dst, ptrdiff_t dst_stride,
2903 const uint8_t *ref, ptrdiff_t ref_stride,
2905 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2906 int bw,
int bh,
int w,
int h,
int bytesperpixel)
2908 int mx = mv->
x, my = mv->
y,
th;
2912 ref += y * ref_stride + x * bytesperpixel;
2918 th = (y + bh + 4 * !!my + 7) >> 6;
2920 if (x < !!mx * 3 || y < !!my * 3 ||
2921 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2923 ref - !!my * 3 * ref_stride - !!mx * 3 * bytesperpixel,
2925 bw + !!mx * 7, bh + !!my * 7,
2926 x - !!mx * 3, y - !!my * 3, w, h);
2930 mc[!!mx][!!my](dst, dst_stride, ref, ref_stride, bh, mx << 1, my << 1);
2935 ptrdiff_t dst_stride,
2936 const uint8_t *ref_u, ptrdiff_t src_stride_u,
2937 const uint8_t *ref_v, ptrdiff_t src_stride_v,
2939 ptrdiff_t
y, ptrdiff_t x,
const VP56mv *
mv,
2940 int bw,
int bh,
int w,
int h,
int bytesperpixel)
2942 int mx = mv->
x << !s->
ss_h, my = mv->
y << !s->
ss_v,
th;
2946 ref_u += y * src_stride_u + x * bytesperpixel;
2947 ref_v += y * src_stride_v + x * bytesperpixel;
2953 th = (y + bh + 4 * !!my + 7) >> (6 - s->
ss_v);
2955 if (x < !!mx * 3 || y < !!my * 3 ||
2956 x + !!mx * 4 > w - bw || y + !!my * 4 > h - bh) {
2958 ref_u - !!my * 3 * src_stride_u - !!mx * 3 * bytesperpixel,
2960 bw + !!mx * 7, bh + !!my * 7,
2961 x - !!mx * 3, y - !!my * 3, w, h);
2962 ref_u = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
2963 mc[!!mx][!!my](dst_u, dst_stride, ref_u, 160, bh, mx, my);
2966 ref_v - !!my * 3 * src_stride_v - !!mx * 3 * bytesperpixel,
2968 bw + !!mx * 7, bh + !!my * 7,
2969 x - !!mx * 3, y - !!my * 3, w, h);
2970 ref_v = s->
edge_emu_buffer + !!my * 3 * 160 + !!mx * 3 * bytesperpixel;
2971 mc[!!mx][!!my](dst_v, dst_stride, ref_v, 160, bh, mx, my);
2973 mc[!!mx][!!my](dst_u, dst_stride, ref_u, src_stride_u, bh, mx, my);
2974 mc[!!mx][!!my](dst_v, dst_stride, ref_v, src_stride_v, bh, mx, my);
2978 #define mc_luma_dir(s, mc, dst, dst_ls, src, src_ls, tref, row, col, mv, \
2979 px, py, pw, ph, bw, bh, w, h, i) \
2980 mc_luma_unscaled(s, s->dsp.mc, dst, dst_ls, src, src_ls, tref, row, col, \
2981 mv, bw, bh, w, h, bytesperpixel)
2982 #define mc_chroma_dir(s, mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2983 row, col, mv, px, py, pw, ph, bw, bh, w, h, i) \
2984 mc_chroma_unscaled(s, s->dsp.mc, dstu, dstv, dst_ls, srcu, srcu_ls, srcv, srcv_ls, tref, \
2985 row, col, mv, bw, bh, w, h, bytesperpixel)
2987 #define FN(x) x##_8bpp
2988 #define BYTES_PER_PIXEL 1
2991 #undef BYTES_PER_PIXEL
2992 #define FN(x) x##_16bpp
2993 #define BYTES_PER_PIXEL 2
2995 #undef mc_luma_dir_dir
2996 #undef mc_chroma_dir_dir
2998 #undef BYTES_PER_PIXEL
3005 int row = s->
row, col = s->
col;
3008 if (bytesperpixel == 1) {
3009 inter_pred_scaled_8bpp(ctx);
3011 inter_pred_scaled_16bpp(ctx);
3014 if (bytesperpixel == 1) {
3015 inter_pred_8bpp(ctx);
3017 inter_pred_16bpp(ctx);
3023 int w4 =
bwh_tab[1][b->
bs][0] << 1, step1d = 1 << b->tx,
n;
3024 int h4 =
bwh_tab[1][b->
bs][1] << 1, x,
y, step = 1 << (b->tx * 2);
3025 int end_x =
FFMIN(2 * (s->
cols - col), w4);
3026 int end_y =
FFMIN(2 * (s->
rows - row), h4);
3028 int uvstep1d = 1 << b->
uvtx, p;
3032 for (
n = 0, y = 0; y < end_y; y += step1d) {
3034 for (x = 0; x < end_x; x += step1d,
3035 ptr += 4 * step1d * bytesperpixel,
n += step) {
3040 s->
block + 16 * n * bytesperpixel, eob);
3048 step = 1 << (b->
uvtx * 2);
3049 for (p = 0; p < 2; p++) {
3050 dst = s->
dst[p + 1];
3051 for (
n = 0, y = 0; y < end_y; y += uvstep1d) {
3053 for (x = 0; x < end_x; x += uvstep1d,
3054 ptr += 4 * uvstep1d * bytesperpixel,
n += step) {
3059 s->
uvblock[p] + 16 * n * bytesperpixel, eob);
3078 int row_and_7,
int col_and_7,
3079 int w,
int h,
int col_end,
int row_end,
3082 static const unsigned wide_filter_col_mask[2] = { 0x11, 0x01 };
3083 static const unsigned wide_filter_row_mask[2] = { 0x03, 0x07 };
3095 if (tx ==
TX_4X4 && (ss_v | ss_h)) {
3110 if (tx ==
TX_4X4 && !skip_inter) {
3111 int t = 1 << col_and_7, m_col = (t << w) - t,
y;
3113 int m_row_8 = m_col & wide_filter_col_mask[ss_h], m_row_4 = m_col - m_row_8;
3115 for (
y = row_and_7;
y < h + row_and_7;
y++) {
3116 int col_mask_id = 2 - !(
y & wide_filter_row_mask[ss_v]);
3118 mask[0][
y][1] |= m_row_8;
3119 mask[0][
y][2] |= m_row_4;
3130 if ((ss_h & ss_v) && (col_end & 1) && (
y & 1)) {
3131 mask[1][
y][col_mask_id] |= (t << (w - 1)) - t;
3133 mask[1][
y][col_mask_id] |= m_col;
3136 mask[0][
y][3] |= m_col;
3138 if (ss_h && (col_end & 1))
3139 mask[1][
y][3] |= (t << (w - 1)) - t;
3141 mask[1][
y][3] |= m_col;
3145 int y, t = 1 << col_and_7, m_col = (t << w) - t;
3148 int mask_id = (tx ==
TX_8X8);
3149 static const unsigned masks[4] = { 0xff, 0x55, 0x11, 0x01 };
3150 int l2 = tx + ss_h - 1, step1d;
3151 int m_row = m_col & masks[l2];
3155 if (ss_h && tx >
TX_8X8 && (w ^ (w - 1)) == 1) {
3156 int m_row_16 = ((t << (w - 1)) - t) & masks[l2];
3157 int m_row_8 = m_row - m_row_16;
3159 for (y = row_and_7; y < h + row_and_7; y++) {
3160 mask[0][
y][0] |= m_row_16;
3161 mask[0][
y][1] |= m_row_8;
3164 for (y = row_and_7; y < h + row_and_7; y++)
3165 mask[0][y][mask_id] |= m_row;
3170 if (ss_v && tx >
TX_8X8 && (h ^ (h - 1)) == 1) {
3171 for (y = row_and_7; y < h + row_and_7 - 1; y += step1d)
3172 mask[1][y][0] |= m_col;
3173 if (y - row_and_7 == h - 1)
3174 mask[1][
y][1] |= m_col;
3176 for (y = row_and_7; y < h + row_and_7; y += step1d)
3177 mask[1][y][mask_id] |= m_col;
3179 }
else if (tx !=
TX_4X4) {
3182 mask_id = (tx ==
TX_8X8) || (h == ss_v);
3183 mask[1][row_and_7][mask_id] |= m_col;
3184 mask_id = (tx ==
TX_8X8) || (w == ss_h);
3185 for (y = row_and_7; y < h + row_and_7; y++)
3186 mask[0][y][mask_id] |= t;
3188 int t8 = t & wide_filter_col_mask[ss_h],
t4 = t -
t8;
3190 for (y = row_and_7; y < h + row_and_7; y++) {
3194 mask[1][row_and_7][2 - !(row_and_7 & wide_filter_row_mask[ss_v])] |= m_col;
3200 struct VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff,
3215 s->
min_mv.
x = -(128 + col * 64);
3216 s->
min_mv.
y = -(128 + row * 64);
3224 b->
uvtx = b->tx - ((s->
ss_h && w4 * 2 == (1 << b->tx)) ||
3225 (s->
ss_v && h4 * 2 == (1 << b->tx)));
3230 if (bytesperpixel == 1) {
3243 #define SPLAT_ZERO_CTX(v, n) \
3245 case 1: v = 0; break; \
3246 case 2: AV_ZERO16(&v); break; \
3247 case 4: AV_ZERO32(&v); break; \
3248 case 8: AV_ZERO64(&v); break; \
3249 case 16: AV_ZERO128(&v); break; \
3251 #define SPLAT_ZERO_YUV(dir, var, off, n, dir2) \
3253 SPLAT_ZERO_CTX(s->dir##_y_##var[off * 2], n * 2); \
3254 if (s->ss_##dir2) { \
3255 SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off], n); \
3256 SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off], n); \
3258 SPLAT_ZERO_CTX(s->dir##_uv_##var[0][off * 2], n * 2); \
3259 SPLAT_ZERO_CTX(s->dir##_uv_##var[1][off * 2], n * 2); \
3278 s->
block += w4 * h4 * 64 * bytesperpixel;
3281 s->
eob += 4 * w4 * h4;
3292 emu[0] = (col + w4) * 8 > f->
linesize[0] ||
3293 (row + h4) > s->
rows;
3294 emu[1] = (col + w4) * 4 > f->
linesize[1] ||
3295 (row + h4) > s->
rows;
3300 s->
dst[0] = f->
data[0] + yoff;
3308 s->
dst[1] = f->
data[1] + uvoff;
3309 s->
dst[2] = f->
data[2] + uvoff;
3328 for (
n = 0; o < w;
n++) {
3334 s->
tmp_y + o, 128,
h, 0, 0);
3335 o += bw * bytesperpixel;
3343 for (
n = s->
ss_h; o < w;
n++) {
3349 s->
tmp_uv[0] + o, 128,
h, 0, 0);
3351 s->
tmp_uv[1] + o, 128,
h, 0, 0);
3352 o += bw * bytesperpixel;
3365 mask_edges(lflvl->
mask[0], 0, 0, row7, col7, x_end, y_end, 0, 0, b->tx, skip_inter);
3370 b->
uvtx, skip_inter);
3377 limit >>= (sharp + 3) >> 2;
3378 limit =
FFMIN(limit, 9 - sharp);
3380 limit =
FFMAX(limit, 1);
3389 s->
block += w4 * h4 * 64 * bytesperpixel;
3392 s->
eob += 4 * w4 * h4;
3399 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3407 ptrdiff_t hbs = 4 >> bl;
3414 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3415 }
else if (col + hbs < s->cols) {
3416 if (row + hbs < s->rows) {
3420 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3423 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3424 yoff += hbs * 8 * y_stride;
3425 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3426 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, bl, bp);
3429 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3430 yoff += hbs * 8 * bytesperpixel;
3431 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3432 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, bl, bp);
3435 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3437 yoff + 8 * hbs * bytesperpixel,
3438 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3439 yoff += hbs * 8 * y_stride;
3440 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3441 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3442 decode_sb(ctx, row + hbs, col + hbs, lflvl,
3443 yoff + 8 * hbs * bytesperpixel,
3444 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3451 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3453 yoff + 8 * hbs * bytesperpixel,
3454 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3457 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3459 }
else if (row + hbs < s->rows) {
3462 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3463 yoff += hbs * 8 * y_stride;
3464 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3465 decode_sb(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3468 decode_b(ctx, row, col, lflvl, yoff, uvoff, bl, bp);
3472 decode_sb(ctx, row, col, lflvl, yoff, uvoff, bl + 1);
3478 ptrdiff_t yoff, ptrdiff_t uvoff,
enum BlockLevel bl)
3482 ptrdiff_t hbs = 4 >> bl;
3489 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3490 }
else if (s->
b->
bl == bl) {
3491 decode_b(ctx, row, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3493 yoff += hbs * 8 * y_stride;
3494 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3495 decode_b(ctx, row + hbs, col, lflvl, yoff, uvoff, b->
bl, b->
bp);
3497 yoff += hbs * 8 * bytesperpixel;
3498 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3499 decode_b(ctx, row, col + hbs, lflvl, yoff, uvoff, b->
bl, b->
bp);
3503 if (col + hbs < s->cols) {
3504 if (row + hbs < s->rows) {
3505 decode_sb_mem(ctx, row, col + hbs, lflvl, yoff + 8 * hbs * bytesperpixel,
3506 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3507 yoff += hbs * 8 * y_stride;
3508 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3509 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3511 yoff + 8 * hbs * bytesperpixel,
3512 uvoff + (8 * hbs * bytesperpixel >> s->
ss_h), bl + 1);
3514 yoff += hbs * 8 * bytesperpixel;
3515 uvoff += hbs * 8 * bytesperpixel >> s->
ss_h;
3516 decode_sb_mem(ctx, row, col + hbs, lflvl, yoff, uvoff, bl + 1);
3518 }
else if (row + hbs < s->rows) {
3519 yoff += hbs * 8 * y_stride;
3520 uvoff += hbs * 8 * uv_stride >> s->
ss_v;
3521 decode_sb_mem(ctx, row + hbs, col, lflvl, yoff, uvoff, bl + 1);
3533 for (y = 0; y < 8; y += 2 << ss_v, dst += 16 * ls, lvl += 16 << ss_v) {
3534 uint8_t *ptr = dst, *l = lvl, *hmask1 =
mask[
y], *hmask2 =
mask[y + 1 + ss_v];
3535 unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2], hm13 = hmask1[3];
3536 unsigned hm2 = hmask2[1] | hmask2[2], hm23 = hmask2[3];
3537 unsigned hm = hm1 | hm2 | hm13 | hm23;
3539 for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 8 * bytesperpixel >> ss_h) {
3542 int L = *l,
H = L >> 4;
3545 if (hmask1[0] & x) {
3546 if (hmask2[0] & x) {
3552 }
else if (hm2 & x) {
3559 [0](ptr, ls,
E, I,
H);
3562 [0](ptr, ls, E, I, H);
3564 }
else if (hm2 & x) {
3565 int L = l[8 << ss_v],
H = L >> 4;
3569 [0](ptr + 8 * ls, ls, E, I, H);
3577 int L = *l,
H = L >> 4;
3589 }
else if (hm23 & x) {
3590 int L = l[8 << ss_v],
H = L >> 4;
3610 for (y = 0; y < 8; y++, dst += 8 * ls >> ss_v) {
3612 unsigned vm = vmask[0] | vmask[1] | vmask[2], vm3 = vmask[3];
3614 for (x = 1; vm & ~(x - 1); x <<= (2 << ss_h), ptr += 16 * bytesperpixel, l += 2 << ss_h) {
3617 int L = *l,
H = L >> 4;
3621 if (vmask[0] & (x << (1 + ss_h))) {
3627 }
else if (vm & (x << (1 + ss_h))) {
3633 [!!(vmask[1] & (x << (1 + ss_h)))]
3634 [1](ptr, ls,
E, I,
H);
3637 [1](ptr, ls, E, I, H);
3639 }
else if (vm & (x << (1 + ss_h))) {
3640 int L = l[1 + ss_h],
H = L >> 4;
3644 [1](ptr + 8 * bytesperpixel, ls, E, I, H);
3649 int L = *l,
H = L >> 4;
3652 if (vm3 & (x << (1 + ss_h))) {
3661 }
else if (vm3 & (x << (1 + ss_h))) {
3662 int L = l[1 + ss_h],
H = L >> 4;
3679 int row,
int col, ptrdiff_t yoff, ptrdiff_t uvoff)
3697 for (p = 0; p < 2; p++) {
3698 dst = f->
data[1 + p] + uvoff;
3706 int sb_start = ( idx *
n) >> log2_n;
3707 int sb_end = ((idx + 1) * n) >> log2_n;
3708 *start =
FFMIN(sb_start, n) << 3;
3709 *end =
FFMIN(sb_end, n) << 3;
3713 int max_count,
int update_factor)
3715 unsigned ct = ct0 + ct1, p2, p1;
3721 p2 = ((ct0 << 8) + (ct >> 1)) / ct;
3722 p2 = av_clip(p2, 1, 255);
3723 ct =
FFMIN(ct, max_count);
3724 update_factor =
FASTDIV(update_factor * ct, max_count);
3727 *p = p1 + (((p2 - p1) * update_factor + 128) >> 8);
3737 for (i = 0; i < 4; i++)
3738 for (j = 0; j < 2; j++)
3739 for (k = 0; k < 2; k++)
3740 for (l = 0; l < 6; l++)
3741 for (m = 0; m < 6; m++) {
3746 if (l == 0 && m >= 3)
3750 adapt_prob(&pp[1], c[0], c[1] + c[2], 24, uf);
3763 for (i = 0; i < 3; i++)
3767 for (i = 0; i < 4; i++)
3772 for (i = 0; i < 5; i++)
3778 for (i = 0; i < 5; i++)
3784 for (i = 0; i < 5; i++) {
3788 adapt_prob(&pp[0], c[0][0], c[0][1], 20, 128);
3789 adapt_prob(&pp[1], c[1][0], c[1][1], 20, 128);
3794 for (i = 0; i < 4; i++)
3795 for (j = 0; j < 4; j++) {
3799 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3800 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3806 for (i = 0; i < 2; i++) {
3812 adapt_prob(&p->
tx32p[i][0], c32[0], c32[1] + c32[2] + c32[3], 20, 128);
3820 for (i = 0; i < 4; i++) {
3824 adapt_prob(&pp[0], c[0], c[1] + c[2], 20, 128);
3830 for (i = 0; i < 7; i++) {
3834 adapt_prob(&pp[0], c[2], c[1] + c[0] + c[3], 20, 128);
3835 adapt_prob(&pp[1], c[0], c[1] + c[3], 20, 128);
3844 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3845 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3850 for (i = 0; i < 2; i++) {
3852 unsigned *
c, (*c2)[2], sum;
3859 sum = c[1] + c[2] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9] + c[10];
3864 adapt_prob(&pp[2], c[2] + c[3], sum, 20, 128);
3867 adapt_prob(&pp[4], c[4] + c[5], sum, 20, 128);
3871 adapt_prob(&pp[7], c[7] + c[8], c[9] + c[10], 20, 128);
3879 for (j = 0; j < 10; j++)
3880 adapt_prob(&pp[j], c2[j][0], c2[j][1], 20, 128);
3882 for (j = 0; j < 2; j++) {
3885 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3886 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3891 adapt_prob(&pp[0], c[0], c[1] + c[2] + c[3], 20, 128);
3892 adapt_prob(&pp[1], c[1], c[2] + c[3], 20, 128);
3904 for (i = 0; i < 4; i++) {
3908 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3928 for (i = 0; i < 10; i++) {
3932 sum = c[0] + c[1] + c[3] + c[4] + c[5] + c[6] + c[7] + c[8] + c[9];
3964 for (i = 0; i < 3; i++) {
3969 for (i = 0; i < 8; i++) {
3991 int res, tile_row, tile_col, i, ref, row, col;
3994 ptrdiff_t yoff, uvoff, ls_y, ls_uv;
4000 }
else if (res == 0) {
4009 for (i = 0; i < 8; i++) {
4022 if (!retain_segmap_ref) {
4045 for (i = 0; i < 8; i++) {
4074 "Failed to allocate block buffers\n");
4080 for (i = 0; i < 4; i++) {
4081 for (j = 0; j < 2; j++)
4082 for (k = 0; k < 2; k++)
4083 for (l = 0; l < 6; l++)
4084 for (m = 0; m < 6; m++)
4121 if (tile_size > size) {
4136 row += 8, yoff += ls_y * 64, uvoff += ls_uv * 64 >> s->
ss_v) {
4138 ptrdiff_t yoff2 = yoff, uvoff2 = uvoff;
4156 memcpy(&s->
c, &s->
c_b[tile_col],
sizeof(s->
c));
4160 col < s->tiling.tile_col_end;
4161 col += 8, yoff2 += 64 * bytesperpixel,
4162 uvoff2 += 64 * bytesperpixel >> s->
ss_h, lflvl_ptr++) {
4166 memset(lflvl_ptr->
mask, 0,
sizeof(lflvl_ptr->
mask));
4178 memcpy(&s->
c_b[tile_col], &s->
c,
sizeof(s->
c));
4188 if (row + 8 < s->
rows) {
4190 f->
data[0] + yoff + 63 * ls_y,
4191 8 * s->
cols * bytesperpixel);
4193 f->
data[1] + uvoff + ((64 >> s->
ss_v) - 1) * ls_uv,
4194 8 * s->
cols * bytesperpixel >> s->
ss_h);
4196 f->
data[2] + uvoff + ((64 >> s->
ss_v) - 1) * ls_uv,
4197 8 * s->
cols * bytesperpixel >> s->
ss_h);
4204 lflvl_ptr = s->
lflvl;
4205 for (col = 0; col < s->
cols;
4206 col += 8, yoff2 += 64 * bytesperpixel,
4207 uvoff2 += 64 * bytesperpixel >> s->
ss_h, lflvl_ptr++) {
4223 }
while (s->
pass++ == 1);
4227 for (i = 0; i < 8; i++) {
4247 for (i = 0; i < 3; i++)
4249 for (i = 0; i < 8; i++)
4258 for (i = 0; i < 3; i++) {
4266 for (i = 0; i < 8; i++) {
4302 (!ssrc->intra_pred_data[0] || s->
cols != ssrc->cols || s->
rows != ssrc->rows)) {
4306 for (i = 0; i < 3; i++) {
4309 if (ssrc->frames[i].tf.f->data[0]) {
4314 for (i = 0; i < 8; i++) {
4317 if (ssrc->next_refs[i].f->data[0]) {
4325 s->
ss_v = ssrc->ss_v;
4326 s->
ss_h = ssrc->ss_h;
4334 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
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]
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)
struct VP9Context::@102 prob
struct VP9Context::@103 counts
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 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)
#define FF_ARRAY_ELEMS(a)
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)
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::@104 min_mv
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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)
struct VP9Context::@97 filter
#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...
#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.
static int decode_coeffs_8bpp(AVCodecContext *ctx)
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.
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)
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]
struct VP9Context::@101 prob_ctx[4]
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
static void flush(AVCodecContext *avctx)
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]
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.
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)
void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
struct VP9Context::@104 max_mv
the normal 219*2^(n-8) "MPEG" YUV ranges
#define LOCAL_ALIGNED_32(t, v,...)
struct VP9Context::@99::@105 feat[MAX_SEGMENT]
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)
struct VP9Context::@103::@106 mv_comp[2]
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]
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
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::@98 lf_delta
#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]
struct VP9Context::@100 tiling
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
struct VP9Context::@99 segmentation
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.
struct prob_context::@107 mv_comp[2]
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 ...
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)