123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917 |
- /*
- * Copyright (c) 2015 The WebM project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
- #include "./vpx_config.h"
- #include "./vpx_dsp_rtcd.h"
- #include "vpx_dsp/vpx_dsp_common.h"
- #include "vpx_mem/vpx_mem.h"
- #define DST(x, y) dst[(x) + (y)*stride]
- #define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
- #define AVG2(a, b) (((a) + (b) + 1) >> 1)
- static INLINE void d207_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r, c;
- (void)above;
- // first column
- for (r = 0; r < bs - 1; ++r) dst[r * stride] = AVG2(left[r], left[r + 1]);
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // second column
- for (r = 0; r < bs - 2; ++r)
- dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
- dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // rest of last row
- for (c = 0; c < bs - 2; ++c) dst[(bs - 1) * stride + c] = left[bs - 1];
- for (r = bs - 2; r >= 0; --r)
- for (c = 0; c < bs - 2; ++c)
- dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
- }
- static INLINE void d63_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r, c;
- int size;
- (void)left;
- for (c = 0; c < bs; ++c) {
- dst[c] = AVG2(above[c], above[c + 1]);
- dst[stride + c] = AVG3(above[c], above[c + 1], above[c + 2]);
- }
- for (r = 2, size = bs - 2; r < bs; r += 2, --size) {
- memcpy(dst + (r + 0) * stride, dst + (r >> 1), size);
- memset(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
- memcpy(dst + (r + 1) * stride, dst + stride + (r >> 1), size);
- memset(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
- }
- }
- static INLINE void d45_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- const uint8_t above_right = above[bs - 1];
- const uint8_t *const dst_row0 = dst;
- int x, size;
- (void)left;
- for (x = 0; x < bs - 1; ++x) {
- dst[x] = AVG3(above[x], above[x + 1], above[x + 2]);
- }
- dst[bs - 1] = above_right;
- dst += stride;
- for (x = 1, size = bs - 2; x < bs; ++x, --size) {
- memcpy(dst, dst_row0 + x, size);
- memset(dst + size, above_right, x + 1);
- dst += stride;
- }
- }
- static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r, c;
- // first row
- for (c = 0; c < bs; c++) dst[c] = AVG2(above[c - 1], above[c]);
- dst += stride;
- // second row
- dst[0] = AVG3(left[0], above[-1], above[0]);
- for (c = 1; c < bs; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
- dst += stride;
- // the rest of first col
- dst[0] = AVG3(above[-1], left[0], left[1]);
- for (r = 3; r < bs; ++r)
- dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
- // the rest of the block
- for (r = 2; r < bs; ++r) {
- for (c = 1; c < bs; c++) dst[c] = dst[-2 * stride + c - 1];
- dst += stride;
- }
- }
- static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int i;
- #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
- // silence a spurious -Warray-bounds warning, possibly related to:
- // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
- uint8_t border[69];
- #else
- uint8_t border[32 + 32 - 1]; // outer border from bottom-left to top-right
- #endif
- // dst(bs, bs - 2)[0], i.e., border starting at bottom-left
- for (i = 0; i < bs - 2; ++i) {
- border[i] = AVG3(left[bs - 3 - i], left[bs - 2 - i], left[bs - 1 - i]);
- }
- border[bs - 2] = AVG3(above[-1], left[0], left[1]);
- border[bs - 1] = AVG3(left[0], above[-1], above[0]);
- border[bs - 0] = AVG3(above[-1], above[0], above[1]);
- // dst[0][2, size), i.e., remaining top border ascending
- for (i = 0; i < bs - 2; ++i) {
- border[bs + 1 + i] = AVG3(above[i], above[i + 1], above[i + 2]);
- }
- for (i = 0; i < bs; ++i) {
- memcpy(dst + i * stride, border + bs - 1 - i, bs);
- }
- }
- static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r, c;
- dst[0] = AVG2(above[-1], left[0]);
- for (r = 1; r < bs; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
- dst++;
- dst[0] = AVG3(left[0], above[-1], above[0]);
- dst[stride] = AVG3(above[-1], left[0], left[1]);
- for (r = 2; r < bs; r++)
- dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
- dst++;
- for (c = 0; c < bs - 2; c++)
- dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
- dst += stride;
- for (r = 1; r < bs; ++r) {
- for (c = 0; c < bs - 2; c++) dst[c] = dst[-stride + c - 2];
- dst += stride;
- }
- }
- static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r;
- (void)left;
- for (r = 0; r < bs; r++) {
- memcpy(dst, above, bs);
- dst += stride;
- }
- }
- static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r;
- (void)above;
- for (r = 0; r < bs; r++) {
- memset(dst, left[r], bs);
- dst += stride;
- }
- }
- static INLINE void tm_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r, c;
- int ytop_left = above[-1];
- for (r = 0; r < bs; r++) {
- for (c = 0; c < bs; c++)
- dst[c] = clip_pixel(left[r] + above[c] - ytop_left);
- dst += stride;
- }
- }
- static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int r;
- (void)above;
- (void)left;
- for (r = 0; r < bs; r++) {
- memset(dst, 128, bs);
- dst += stride;
- }
- }
- static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above,
- const uint8_t *left) {
- int i, r, expected_dc, sum = 0;
- (void)above;
- for (i = 0; i < bs; i++) sum += left[i];
- expected_dc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++) {
- memset(dst, expected_dc, bs);
- dst += stride;
- }
- }
- static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int i, r, expected_dc, sum = 0;
- (void)left;
- for (i = 0; i < bs; i++) sum += above[i];
- expected_dc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++) {
- memset(dst, expected_dc, bs);
- dst += stride;
- }
- }
- static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bs,
- const uint8_t *above, const uint8_t *left) {
- int i, r, expected_dc, sum = 0;
- const int count = 2 * bs;
- for (i = 0; i < bs; i++) {
- sum += above[i];
- sum += left[i];
- }
- expected_dc = (sum + (count >> 1)) / count;
- for (r = 0; r < bs; r++) {
- memset(dst, expected_dc, bs);
- dst += stride;
- }
- }
- void vpx_he_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int H = above[-1];
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- memset(dst + stride * 0, AVG3(H, I, J), 4);
- memset(dst + stride * 1, AVG3(I, J, K), 4);
- memset(dst + stride * 2, AVG3(J, K, L), 4);
- memset(dst + stride * 3, AVG3(K, L, L), 4);
- }
- void vpx_ve_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int H = above[-1];
- const int I = above[0];
- const int J = above[1];
- const int K = above[2];
- const int L = above[3];
- const int M = above[4];
- (void)left;
- dst[0] = AVG3(H, I, J);
- dst[1] = AVG3(I, J, K);
- dst[2] = AVG3(J, K, L);
- dst[3] = AVG3(K, L, M);
- memcpy(dst + stride * 1, dst, 4);
- memcpy(dst + stride * 2, dst, 4);
- memcpy(dst + stride * 3, dst, 4);
- }
- void vpx_d207_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- (void)above;
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) = DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
- }
- void vpx_d63_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- (void)left;
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
- DST(3, 2) = AVG2(E, F); // differs from vp8
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 3) = AVG3(E, F, G); // differs from vp8
- }
- void vpx_d63e_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- const int H = above[7];
- (void)left;
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
- DST(3, 2) = AVG3(E, F, G);
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 3) = AVG3(F, G, H);
- }
- void vpx_d45_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- const int H = above[7];
- (void)stride;
- (void)left;
- DST(0, 0) = AVG3(A, B, C);
- DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
- DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
- DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
- DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
- DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
- DST(3, 3) = H; // differs from vp8
- }
- void vpx_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- const int H = above[7];
- (void)stride;
- (void)left;
- DST(0, 0) = AVG3(A, B, C);
- DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
- DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
- DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
- DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
- DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
- DST(3, 3) = AVG3(G, H, H);
- }
- void vpx_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- DST(0, 0) = DST(1, 2) = AVG2(X, A);
- DST(1, 0) = DST(2, 2) = AVG2(A, B);
- DST(2, 0) = DST(3, 2) = AVG2(B, C);
- DST(3, 0) = AVG2(C, D);
- DST(0, 3) = AVG3(K, J, I);
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
- DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
- DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
- DST(3, 1) = AVG3(B, C, D);
- }
- void vpx_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- (void)stride;
- DST(0, 3) = AVG3(J, K, L);
- DST(1, 3) = DST(0, 2) = AVG3(I, J, K);
- DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X, I, J);
- DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
- DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B, A, X);
- DST(3, 1) = DST(2, 0) = AVG3(C, B, A);
- DST(3, 0) = AVG3(D, C, B);
- }
- void vpx_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
- const uint8_t *above, const uint8_t *left) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
- }
- #if CONFIG_VP9_HIGHBITDEPTH
- static INLINE void highbd_d207_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int r, c;
- (void)above;
- (void)bd;
- // First column.
- for (r = 0; r < bs - 1; ++r) {
- dst[r * stride] = AVG2(left[r], left[r + 1]);
- }
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Second column.
- for (r = 0; r < bs - 2; ++r) {
- dst[r * stride] = AVG3(left[r], left[r + 1], left[r + 2]);
- }
- dst[(bs - 2) * stride] = AVG3(left[bs - 2], left[bs - 1], left[bs - 1]);
- dst[(bs - 1) * stride] = left[bs - 1];
- dst++;
- // Rest of last row.
- for (c = 0; c < bs - 2; ++c) dst[(bs - 1) * stride + c] = left[bs - 1];
- for (r = bs - 2; r >= 0; --r) {
- for (c = 0; c < bs - 2; ++c)
- dst[r * stride + c] = dst[(r + 1) * stride + c - 2];
- }
- }
- static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- int r, c;
- int size;
- (void)left;
- (void)bd;
- for (c = 0; c < bs; ++c) {
- dst[c] = AVG2(above[c], above[c + 1]);
- dst[stride + c] = AVG3(above[c], above[c + 1], above[c + 2]);
- }
- for (r = 2, size = bs - 2; r < bs; r += 2, --size) {
- memcpy(dst + (r + 0) * stride, dst + (r >> 1), size * sizeof(*dst));
- vpx_memset16(dst + (r + 0) * stride + size, above[bs - 1], bs - size);
- memcpy(dst + (r + 1) * stride, dst + stride + (r >> 1),
- size * sizeof(*dst));
- vpx_memset16(dst + (r + 1) * stride + size, above[bs - 1], bs - size);
- }
- }
- static INLINE void highbd_d45_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- const uint16_t above_right = above[bs - 1];
- const uint16_t *const dst_row0 = dst;
- int x, size;
- (void)left;
- (void)bd;
- for (x = 0; x < bs - 1; ++x) {
- dst[x] = AVG3(above[x], above[x + 1], above[x + 2]);
- }
- dst[bs - 1] = above_right;
- dst += stride;
- for (x = 1, size = bs - 2; x < bs; ++x, --size) {
- memcpy(dst, dst_row0 + x, size * sizeof(*dst));
- vpx_memset16(dst + size, above_right, x + 1);
- dst += stride;
- }
- }
- static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int r, c;
- (void)bd;
- // first row
- for (c = 0; c < bs; c++) dst[c] = AVG2(above[c - 1], above[c]);
- dst += stride;
- // second row
- dst[0] = AVG3(left[0], above[-1], above[0]);
- for (c = 1; c < bs; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
- dst += stride;
- // the rest of first col
- dst[0] = AVG3(above[-1], left[0], left[1]);
- for (r = 3; r < bs; ++r)
- dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
- // the rest of the block
- for (r = 2; r < bs; ++r) {
- for (c = 1; c < bs; c++) dst[c] = dst[-2 * stride + c - 1];
- dst += stride;
- }
- }
- static INLINE void highbd_d135_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int i;
- #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
- // silence a spurious -Warray-bounds warning, possibly related to:
- // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
- uint16_t border[69];
- #else
- uint16_t border[32 + 32 - 1]; // outer border from bottom-left to top-right
- #endif
- (void)bd;
- // dst(bs, bs - 2)[0], i.e., border starting at bottom-left
- for (i = 0; i < bs - 2; ++i) {
- border[i] = AVG3(left[bs - 3 - i], left[bs - 2 - i], left[bs - 1 - i]);
- }
- border[bs - 2] = AVG3(above[-1], left[0], left[1]);
- border[bs - 1] = AVG3(left[0], above[-1], above[0]);
- border[bs - 0] = AVG3(above[-1], above[0], above[1]);
- // dst[0][2, size), i.e., remaining top border ascending
- for (i = 0; i < bs - 2; ++i) {
- border[bs + 1 + i] = AVG3(above[i], above[i + 1], above[i + 2]);
- }
- for (i = 0; i < bs; ++i) {
- memcpy(dst + i * stride, border + bs - 1 - i, bs * sizeof(dst[0]));
- }
- }
- static INLINE void highbd_d153_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int r, c;
- (void)bd;
- dst[0] = AVG2(above[-1], left[0]);
- for (r = 1; r < bs; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
- dst++;
- dst[0] = AVG3(left[0], above[-1], above[0]);
- dst[stride] = AVG3(above[-1], left[0], left[1]);
- for (r = 2; r < bs; r++)
- dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
- dst++;
- for (c = 0; c < bs - 2; c++)
- dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
- dst += stride;
- for (r = 1; r < bs; ++r) {
- for (c = 0; c < bs - 2; c++) dst[c] = dst[-stride + c - 2];
- dst += stride;
- }
- }
- static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- int r;
- (void)left;
- (void)bd;
- for (r = 0; r < bs; r++) {
- memcpy(dst, above, bs * sizeof(uint16_t));
- dst += stride;
- }
- }
- static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- int r;
- (void)above;
- (void)bd;
- for (r = 0; r < bs; r++) {
- vpx_memset16(dst, left[r], bs);
- dst += stride;
- }
- }
- static INLINE void highbd_tm_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- int r, c;
- int ytop_left = above[-1];
- (void)bd;
- for (r = 0; r < bs; r++) {
- for (c = 0; c < bs; c++)
- dst[c] = clip_pixel_highbd(left[r] + above[c] - ytop_left, bd);
- dst += stride;
- }
- }
- static INLINE void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int r;
- (void)above;
- (void)left;
- for (r = 0; r < bs; r++) {
- vpx_memset16(dst, 128 << (bd - 8), bs);
- dst += stride;
- }
- }
- static INLINE void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int i, r, expected_dc, sum = 0;
- (void)above;
- (void)bd;
- for (i = 0; i < bs; i++) sum += left[i];
- expected_dc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++) {
- vpx_memset16(dst, expected_dc, bs);
- dst += stride;
- }
- }
- static INLINE void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
- int bs, const uint16_t *above,
- const uint16_t *left, int bd) {
- int i, r, expected_dc, sum = 0;
- (void)left;
- (void)bd;
- for (i = 0; i < bs; i++) sum += above[i];
- expected_dc = (sum + (bs >> 1)) / bs;
- for (r = 0; r < bs; r++) {
- vpx_memset16(dst, expected_dc, bs);
- dst += stride;
- }
- }
- static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- int i, r, expected_dc, sum = 0;
- const int count = 2 * bs;
- (void)bd;
- for (i = 0; i < bs; i++) {
- sum += above[i];
- sum += left[i];
- }
- expected_dc = (sum + (count >> 1)) / count;
- for (r = 0; r < bs; r++) {
- vpx_memset16(dst, expected_dc, bs);
- dst += stride;
- }
- }
- void vpx_highbd_d207_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- (void)above;
- (void)bd;
- DST(0, 0) = AVG2(I, J);
- DST(2, 0) = DST(0, 1) = AVG2(J, K);
- DST(2, 1) = DST(0, 2) = AVG2(K, L);
- DST(1, 0) = AVG3(I, J, K);
- DST(3, 0) = DST(1, 1) = AVG3(J, K, L);
- DST(3, 1) = DST(1, 2) = AVG3(K, L, L);
- DST(3, 2) = DST(2, 2) = DST(0, 3) = DST(1, 3) = DST(2, 3) = DST(3, 3) = L;
- }
- void vpx_highbd_d63_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above, const uint16_t *left,
- int bd) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- (void)left;
- (void)bd;
- DST(0, 0) = AVG2(A, B);
- DST(1, 0) = DST(0, 2) = AVG2(B, C);
- DST(2, 0) = DST(1, 2) = AVG2(C, D);
- DST(3, 0) = DST(2, 2) = AVG2(D, E);
- DST(3, 2) = AVG2(E, F); // differs from vp8
- DST(0, 1) = AVG3(A, B, C);
- DST(1, 1) = DST(0, 3) = AVG3(B, C, D);
- DST(2, 1) = DST(1, 3) = AVG3(C, D, E);
- DST(3, 1) = DST(2, 3) = AVG3(D, E, F);
- DST(3, 3) = AVG3(E, F, G); // differs from vp8
- }
- void vpx_highbd_d45_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above, const uint16_t *left,
- int bd) {
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- const int E = above[4];
- const int F = above[5];
- const int G = above[6];
- const int H = above[7];
- (void)left;
- (void)bd;
- DST(0, 0) = AVG3(A, B, C);
- DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
- DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
- DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
- DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
- DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
- DST(3, 3) = H; // differs from vp8
- }
- void vpx_highbd_d117_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- (void)bd;
- DST(0, 0) = DST(1, 2) = AVG2(X, A);
- DST(1, 0) = DST(2, 2) = AVG2(A, B);
- DST(2, 0) = DST(3, 2) = AVG2(B, C);
- DST(3, 0) = AVG2(C, D);
- DST(0, 3) = AVG3(K, J, I);
- DST(0, 2) = AVG3(J, I, X);
- DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
- DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
- DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
- DST(3, 1) = AVG3(B, C, D);
- }
- void vpx_highbd_d135_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- const int D = above[3];
- (void)bd;
- DST(0, 3) = AVG3(J, K, L);
- DST(1, 3) = DST(0, 2) = AVG3(I, J, K);
- DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X, I, J);
- DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
- DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B, A, X);
- DST(3, 1) = DST(2, 0) = AVG3(C, B, A);
- DST(3, 0) = AVG3(D, C, B);
- }
- void vpx_highbd_d153_predictor_4x4_c(uint16_t *dst, ptrdiff_t stride,
- const uint16_t *above,
- const uint16_t *left, int bd) {
- const int I = left[0];
- const int J = left[1];
- const int K = left[2];
- const int L = left[3];
- const int X = above[-1];
- const int A = above[0];
- const int B = above[1];
- const int C = above[2];
- (void)bd;
- DST(0, 0) = DST(2, 1) = AVG2(I, X);
- DST(0, 1) = DST(2, 2) = AVG2(J, I);
- DST(0, 2) = DST(2, 3) = AVG2(K, J);
- DST(0, 3) = AVG2(L, K);
- DST(3, 0) = AVG3(A, B, C);
- DST(2, 0) = AVG3(X, A, B);
- DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
- DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
- DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
- DST(1, 3) = AVG3(L, K, J);
- }
- #endif // CONFIG_VP9_HIGHBITDEPTH
- // This serves as a wrapper function, so that all the prediction functions
- // can be unified and accessed as a pointer array. Note that the boundary
- // above and left are not necessarily used all the time.
- #define intra_pred_sized(type, size) \
- void vpx_##type##_predictor_##size##x##size##_c( \
- uint8_t *dst, ptrdiff_t stride, const uint8_t *above, \
- const uint8_t *left) { \
- type##_predictor(dst, stride, size, above, left); \
- }
- #if CONFIG_VP9_HIGHBITDEPTH
- #define intra_pred_highbd_sized(type, size) \
- void vpx_highbd_##type##_predictor_##size##x##size##_c( \
- uint16_t *dst, ptrdiff_t stride, const uint16_t *above, \
- const uint16_t *left, int bd) { \
- highbd_##type##_predictor(dst, stride, size, above, left, bd); \
- }
- /* clang-format off */
- #define intra_pred_allsizes(type) \
- intra_pred_sized(type, 4) \
- intra_pred_sized(type, 8) \
- intra_pred_sized(type, 16) \
- intra_pred_sized(type, 32) \
- intra_pred_highbd_sized(type, 4) \
- intra_pred_highbd_sized(type, 8) \
- intra_pred_highbd_sized(type, 16) \
- intra_pred_highbd_sized(type, 32)
- #define intra_pred_no_4x4(type) \
- intra_pred_sized(type, 8) \
- intra_pred_sized(type, 16) \
- intra_pred_sized(type, 32) \
- intra_pred_highbd_sized(type, 8) \
- intra_pred_highbd_sized(type, 16) \
- intra_pred_highbd_sized(type, 32)
- #else
- #define intra_pred_allsizes(type) \
- intra_pred_sized(type, 4) \
- intra_pred_sized(type, 8) \
- intra_pred_sized(type, 16) \
- intra_pred_sized(type, 32)
- #define intra_pred_no_4x4(type) \
- intra_pred_sized(type, 8) \
- intra_pred_sized(type, 16) \
- intra_pred_sized(type, 32)
- #endif // CONFIG_VP9_HIGHBITDEPTH
- intra_pred_no_4x4(d207)
- intra_pred_no_4x4(d63)
- intra_pred_no_4x4(d45)
- intra_pred_no_4x4(d117)
- intra_pred_no_4x4(d135)
- intra_pred_no_4x4(d153)
- intra_pred_allsizes(v)
- intra_pred_allsizes(h)
- intra_pred_allsizes(tm)
- intra_pred_allsizes(dc_128)
- intra_pred_allsizes(dc_left)
- intra_pred_allsizes(dc_top)
- intra_pred_allsizes(dc)
- /* clang-format on */
- #undef intra_pred_allsizes
|