You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

552 lines
22KB

  1. /*
  2. * HEVC video decoder
  3. *
  4. * Copyright (C) 2012 - 2013 Guillaume Martres
  5. *
  6. * This file is part of FFmpeg.
  7. *
  8. * FFmpeg is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * FFmpeg is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with FFmpeg; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #include "libavutil/pixdesc.h"
  23. #include "bit_depth_template.c"
  24. #include "hevcpred.h"
  25. #define POS(x, y) src[(x) + stride * (y)]
  26. static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
  27. int log2_size, int c_idx)
  28. {
  29. #define PU(x) \
  30. ((x) >> s->ps.sps->log2_min_pu_size)
  31. #define MVF(x, y) \
  32. (s->ref->tab_mvf[(x) + (y) * min_pu_width])
  33. #define MVF_PU(x, y) \
  34. MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift))))
  35. #define IS_INTRA(x, y) \
  36. (MVF_PU(x, y).pred_flag == PF_INTRA)
  37. #define MIN_TB_ADDR_ZS(x, y) \
  38. s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
  39. #define EXTEND(ptr, val, len) \
  40. do { \
  41. pixel4 pix = PIXEL_SPLAT_X4(val); \
  42. for (i = 0; i < (len); i += 4) \
  43. AV_WN4P(ptr + i, pix); \
  44. } while (0)
  45. #define EXTEND_RIGHT_CIP(ptr, start, length) \
  46. for (i = start; i < (start) + (length); i += 4) \
  47. if (!IS_INTRA(i, -1)) \
  48. AV_WN4P(&ptr[i], a); \
  49. else \
  50. a = PIXEL_SPLAT_X4(ptr[i+3])
  51. #define EXTEND_LEFT_CIP(ptr, start, length) \
  52. for (i = start; i > (start) - (length); i--) \
  53. if (!IS_INTRA(i - 1, -1)) \
  54. ptr[i - 1] = ptr[i]
  55. #define EXTEND_UP_CIP(ptr, start, length) \
  56. for (i = (start); i > (start) - (length); i -= 4) \
  57. if (!IS_INTRA(-1, i - 3)) \
  58. AV_WN4P(&ptr[i - 3], a); \
  59. else \
  60. a = PIXEL_SPLAT_X4(ptr[i - 3])
  61. #define EXTEND_DOWN_CIP(ptr, start, length) \
  62. for (i = start; i < (start) + (length); i += 4) \
  63. if (!IS_INTRA(-1, i)) \
  64. AV_WN4P(&ptr[i], a); \
  65. else \
  66. a = PIXEL_SPLAT_X4(ptr[i + 3])
  67. HEVCLocalContext *lc = s->HEVClc;
  68. int i;
  69. int hshift = s->ps.sps->hshift[c_idx];
  70. int vshift = s->ps.sps->vshift[c_idx];
  71. int size = (1 << log2_size);
  72. int size_in_luma_h = size << hshift;
  73. int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
  74. int size_in_luma_v = size << vshift;
  75. int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
  76. int x = x0 >> hshift;
  77. int y = y0 >> vshift;
  78. int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
  79. int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
  80. int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
  81. ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
  82. pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
  83. int min_pu_width = s->ps.sps->min_pu_width;
  84. enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
  85. lc->tu.intra_pred_mode;
  86. pixel4 a;
  87. pixel left_array[2 * MAX_TB_SIZE + 1];
  88. pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
  89. pixel top_array[2 * MAX_TB_SIZE + 1];
  90. pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
  91. pixel *left = left_array + 1;
  92. pixel *top = top_array + 1;
  93. pixel *filtered_left = filtered_left_array + 1;
  94. pixel *filtered_top = filtered_top_array + 1;
  95. int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v) & s->ps.sps->tb_mask);
  96. int cand_left = lc->na.cand_left;
  97. int cand_up_left = lc->na.cand_up_left;
  98. int cand_up = lc->na.cand_up;
  99. int cand_up_right = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1);
  100. int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) -
  101. (y0 + size_in_luma_v)) >> vshift;
  102. int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) -
  103. (x0 + size_in_luma_h)) >> hshift;
  104. if (s->ps.pps->constrained_intra_pred_flag == 1) {
  105. int size_in_luma_pu_v = PU(size_in_luma_v);
  106. int size_in_luma_pu_h = PU(size_in_luma_h);
  107. int on_pu_edge_x = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size);
  108. int on_pu_edge_y = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size);
  109. if (!size_in_luma_pu_h)
  110. size_in_luma_pu_h++;
  111. if (cand_bottom_left == 1 && on_pu_edge_x) {
  112. int x_left_pu = PU(x0 - 1);
  113. int y_bottom_pu = PU(y0 + size_in_luma_v);
  114. int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu);
  115. cand_bottom_left = 0;
  116. for (i = 0; i < max; i += 2)
  117. cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
  118. }
  119. if (cand_left == 1 && on_pu_edge_x) {
  120. int x_left_pu = PU(x0 - 1);
  121. int y_left_pu = PU(y0);
  122. int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu);
  123. cand_left = 0;
  124. for (i = 0; i < max; i += 2)
  125. cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
  126. }
  127. if (cand_up_left == 1) {
  128. int x_left_pu = PU(x0 - 1);
  129. int y_top_pu = PU(y0 - 1);
  130. cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
  131. }
  132. if (cand_up == 1 && on_pu_edge_y) {
  133. int x_top_pu = PU(x0);
  134. int y_top_pu = PU(y0 - 1);
  135. int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu);
  136. cand_up = 0;
  137. for (i = 0; i < max; i += 2)
  138. cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
  139. }
  140. if (cand_up_right == 1 && on_pu_edge_y) {
  141. int y_top_pu = PU(y0 - 1);
  142. int x_right_pu = PU(x0 + size_in_luma_h);
  143. int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu);
  144. cand_up_right = 0;
  145. for (i = 0; i < max; i += 2)
  146. cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
  147. }
  148. memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel));
  149. memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel));
  150. top[-1] = 128;
  151. }
  152. if (cand_up_left) {
  153. left[-1] = POS(-1, -1);
  154. top[-1] = left[-1];
  155. }
  156. if (cand_up)
  157. memcpy(top, src - stride, size * sizeof(pixel));
  158. if (cand_up_right) {
  159. memcpy(top + size, src - stride + size, size * sizeof(pixel));
  160. EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
  161. size - top_right_size);
  162. }
  163. if (cand_left)
  164. for (i = 0; i < size; i++)
  165. left[i] = POS(-1, i);
  166. if (cand_bottom_left) {
  167. for (i = size; i < size + bottom_left_size; i++)
  168. left[i] = POS(-1, i);
  169. EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
  170. size - bottom_left_size);
  171. }
  172. if (s->ps.pps->constrained_intra_pred_flag == 1) {
  173. if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
  174. int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ?
  175. 2 * size : (s->ps.sps->width - x0) >> hshift;
  176. int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ?
  177. 2 * size : (s->ps.sps->height - y0) >> vshift;
  178. int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
  179. if (!cand_up_right) {
  180. size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ?
  181. size : (s->ps.sps->width - x0) >> hshift;
  182. }
  183. if (!cand_bottom_left) {
  184. size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ?
  185. size : (s->ps.sps->height - y0) >> vshift;
  186. }
  187. if (cand_bottom_left || cand_left || cand_up_left) {
  188. while (j > -1 && !IS_INTRA(-1, j))
  189. j--;
  190. if (!IS_INTRA(-1, j)) {
  191. j = 0;
  192. while (j < size_max_x && !IS_INTRA(j, -1))
  193. j++;
  194. EXTEND_LEFT_CIP(top, j, j + 1);
  195. left[-1] = top[-1];
  196. }
  197. } else {
  198. j = 0;
  199. while (j < size_max_x && !IS_INTRA(j, -1))
  200. j++;
  201. if (j > 0)
  202. if (x0 > 0) {
  203. EXTEND_LEFT_CIP(top, j, j + 1);
  204. } else {
  205. EXTEND_LEFT_CIP(top, j, j);
  206. top[-1] = top[0];
  207. }
  208. left[-1] = top[-1];
  209. }
  210. left[-1] = top[-1];
  211. if (cand_bottom_left || cand_left) {
  212. a = PIXEL_SPLAT_X4(left[-1]);
  213. EXTEND_DOWN_CIP(left, 0, size_max_y);
  214. }
  215. if (!cand_left)
  216. EXTEND(left, left[-1], size);
  217. if (!cand_bottom_left)
  218. EXTEND(left + size, left[size - 1], size);
  219. if (x0 != 0 && y0 != 0) {
  220. a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
  221. EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
  222. if (!IS_INTRA(-1, - 1))
  223. left[-1] = left[0];
  224. } else if (x0 == 0) {
  225. EXTEND(left, 0, size_max_y);
  226. } else {
  227. a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
  228. EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
  229. }
  230. top[-1] = left[-1];
  231. if (y0 != 0) {
  232. a = PIXEL_SPLAT_X4(left[-1]);
  233. EXTEND_RIGHT_CIP(top, 0, size_max_x);
  234. }
  235. }
  236. }
  237. // Infer the unavailable samples
  238. if (!cand_bottom_left) {
  239. if (cand_left) {
  240. EXTEND(left + size, left[size - 1], size);
  241. } else if (cand_up_left) {
  242. EXTEND(left, left[-1], 2 * size);
  243. cand_left = 1;
  244. } else if (cand_up) {
  245. left[-1] = top[0];
  246. EXTEND(left, left[-1], 2 * size);
  247. cand_up_left = 1;
  248. cand_left = 1;
  249. } else if (cand_up_right) {
  250. EXTEND(top, top[size], size);
  251. left[-1] = top[size];
  252. EXTEND(left, left[-1], 2 * size);
  253. cand_up = 1;
  254. cand_up_left = 1;
  255. cand_left = 1;
  256. } else { // No samples available
  257. left[-1] = (1 << (BIT_DEPTH - 1));
  258. EXTEND(top, left[-1], 2 * size);
  259. EXTEND(left, left[-1], 2 * size);
  260. }
  261. }
  262. if (!cand_left)
  263. EXTEND(left, left[size], size);
  264. if (!cand_up_left) {
  265. left[-1] = left[0];
  266. }
  267. if (!cand_up)
  268. EXTEND(top, left[-1], size);
  269. if (!cand_up_right)
  270. EXTEND(top + size, top[size - 1], size);
  271. top[-1] = left[-1];
  272. // Filtering process
  273. if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
  274. if (mode != INTRA_DC && size != 4){
  275. int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
  276. int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
  277. FFABS((int)(mode - 10U)));
  278. if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
  279. int threshold = 1 << (BIT_DEPTH - 5);
  280. if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
  281. log2_size == 5 &&
  282. FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
  283. FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
  284. // We can't just overwrite values in top because it could be
  285. // a pointer into src
  286. filtered_top[-1] = top[-1];
  287. filtered_top[63] = top[63];
  288. for (i = 0; i < 63; i++)
  289. filtered_top[i] = ((64 - (i + 1)) * top[-1] +
  290. (i + 1) * top[63] + 32) >> 6;
  291. for (i = 0; i < 63; i++)
  292. left[i] = ((64 - (i + 1)) * left[-1] +
  293. (i + 1) * left[63] + 32) >> 6;
  294. top = filtered_top;
  295. } else {
  296. filtered_left[2 * size - 1] = left[2 * size - 1];
  297. filtered_top[2 * size - 1] = top[2 * size - 1];
  298. for (i = 2 * size - 2; i >= 0; i--)
  299. filtered_left[i] = (left[i + 1] + 2 * left[i] +
  300. left[i - 1] + 2) >> 2;
  301. filtered_top[-1] =
  302. filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
  303. for (i = 2 * size - 2; i >= 0; i--)
  304. filtered_top[i] = (top[i + 1] + 2 * top[i] +
  305. top[i - 1] + 2) >> 2;
  306. left = filtered_left;
  307. top = filtered_top;
  308. }
  309. }
  310. }
  311. }
  312. switch (mode) {
  313. case INTRA_PLANAR:
  314. s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
  315. (uint8_t *)left, stride);
  316. break;
  317. case INTRA_DC:
  318. s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
  319. (uint8_t *)left, stride, log2_size, c_idx);
  320. break;
  321. default:
  322. s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
  323. (uint8_t *)left, stride, c_idx,
  324. mode);
  325. break;
  326. }
  327. }
  328. #define INTRA_PRED(size) \
  329. static void FUNC(intra_pred_ ## size)(HEVCContext *s, int x0, int y0, int c_idx) \
  330. { \
  331. FUNC(intra_pred)(s, x0, y0, size, c_idx); \
  332. }
  333. INTRA_PRED(2)
  334. INTRA_PRED(3)
  335. INTRA_PRED(4)
  336. INTRA_PRED(5)
  337. #undef INTRA_PRED
  338. static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
  339. const uint8_t *_left, ptrdiff_t stride,
  340. int trafo_size)
  341. {
  342. int x, y;
  343. pixel *src = (pixel *)_src;
  344. const pixel *top = (const pixel *)_top;
  345. const pixel *left = (const pixel *)_left;
  346. int size = 1 << trafo_size;
  347. for (y = 0; y < size; y++)
  348. for (x = 0; x < size; x++)
  349. POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
  350. (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
  351. }
  352. #define PRED_PLANAR(size)\
  353. static void FUNC(pred_planar_ ## size)(uint8_t *src, const uint8_t *top, \
  354. const uint8_t *left, ptrdiff_t stride) \
  355. { \
  356. FUNC(pred_planar)(src, top, left, stride, size + 2); \
  357. }
  358. PRED_PLANAR(0)
  359. PRED_PLANAR(1)
  360. PRED_PLANAR(2)
  361. PRED_PLANAR(3)
  362. #undef PRED_PLANAR
  363. static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
  364. const uint8_t *_left,
  365. ptrdiff_t stride, int log2_size, int c_idx)
  366. {
  367. int i, j, x, y;
  368. int size = (1 << log2_size);
  369. pixel *src = (pixel *)_src;
  370. const pixel *top = (const pixel *)_top;
  371. const pixel *left = (const pixel *)_left;
  372. int dc = size;
  373. pixel4 a;
  374. for (i = 0; i < size; i++)
  375. dc += left[i] + top[i];
  376. dc >>= log2_size + 1;
  377. a = PIXEL_SPLAT_X4(dc);
  378. for (i = 0; i < size; i++)
  379. for (j = 0; j < size; j+=4)
  380. AV_WN4P(&POS(j, i), a);
  381. if (c_idx == 0 && size < 32) {
  382. POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
  383. for (x = 1; x < size; x++)
  384. POS(x, 0) = (top[x] + 3 * dc + 2) >> 2;
  385. for (y = 1; y < size; y++)
  386. POS(0, y) = (left[y] + 3 * dc + 2) >> 2;
  387. }
  388. }
  389. static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
  390. const uint8_t *_top,
  391. const uint8_t *_left,
  392. ptrdiff_t stride, int c_idx,
  393. int mode, int size)
  394. {
  395. int x, y;
  396. pixel *src = (pixel *)_src;
  397. const pixel *top = (const pixel *)_top;
  398. const pixel *left = (const pixel *)_left;
  399. static const int intra_pred_angle[] = {
  400. 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32,
  401. -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32
  402. };
  403. static const int inv_angle[] = {
  404. -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482,
  405. -630, -910, -1638, -4096
  406. };
  407. int angle = intra_pred_angle[mode - 2];
  408. pixel ref_array[3 * MAX_TB_SIZE + 4];
  409. pixel *ref_tmp = ref_array + size;
  410. const pixel *ref;
  411. int last = (size * angle) >> 5;
  412. if (mode >= 18) {
  413. ref = top - 1;
  414. if (angle < 0 && last < -1) {
  415. for (x = 0; x <= size; x += 4)
  416. AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1]));
  417. for (x = last; x <= -1; x++)
  418. ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
  419. ref = ref_tmp;
  420. }
  421. for (y = 0; y < size; y++) {
  422. int idx = ((y + 1) * angle) >> 5;
  423. int fact = ((y + 1) * angle) & 31;
  424. if (fact) {
  425. for (x = 0; x < size; x += 4) {
  426. POS(x , y) = ((32 - fact) * ref[x + idx + 1] +
  427. fact * ref[x + idx + 2] + 16) >> 5;
  428. POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] +
  429. fact * ref[x + 1 + idx + 2] + 16) >> 5;
  430. POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] +
  431. fact * ref[x + 2 + idx + 2] + 16) >> 5;
  432. POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] +
  433. fact * ref[x + 3 + idx + 2] + 16) >> 5;
  434. }
  435. } else {
  436. for (x = 0; x < size; x += 4)
  437. AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1]));
  438. }
  439. }
  440. if (mode == 26 && c_idx == 0 && size < 32) {
  441. for (y = 0; y < size; y++)
  442. POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1));
  443. }
  444. } else {
  445. ref = left - 1;
  446. if (angle < 0 && last < -1) {
  447. for (x = 0; x <= size; x += 4)
  448. AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1]));
  449. for (x = last; x <= -1; x++)
  450. ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
  451. ref = ref_tmp;
  452. }
  453. for (x = 0; x < size; x++) {
  454. int idx = ((x + 1) * angle) >> 5;
  455. int fact = ((x + 1) * angle) & 31;
  456. if (fact) {
  457. for (y = 0; y < size; y++) {
  458. POS(x, y) = ((32 - fact) * ref[y + idx + 1] +
  459. fact * ref[y + idx + 2] + 16) >> 5;
  460. }
  461. } else {
  462. for (y = 0; y < size; y++)
  463. POS(x, y) = ref[y + idx + 1];
  464. }
  465. }
  466. if (mode == 10 && c_idx == 0 && size < 32) {
  467. for (x = 0; x < size; x += 4) {
  468. POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1));
  469. POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1));
  470. POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1));
  471. POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1));
  472. }
  473. }
  474. }
  475. }
  476. static void FUNC(pred_angular_0)(uint8_t *src, const uint8_t *top,
  477. const uint8_t *left,
  478. ptrdiff_t stride, int c_idx, int mode)
  479. {
  480. FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2);
  481. }
  482. static void FUNC(pred_angular_1)(uint8_t *src, const uint8_t *top,
  483. const uint8_t *left,
  484. ptrdiff_t stride, int c_idx, int mode)
  485. {
  486. FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
  487. }
  488. static void FUNC(pred_angular_2)(uint8_t *src, const uint8_t *top,
  489. const uint8_t *left,
  490. ptrdiff_t stride, int c_idx, int mode)
  491. {
  492. FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4);
  493. }
  494. static void FUNC(pred_angular_3)(uint8_t *src, const uint8_t *top,
  495. const uint8_t *left,
  496. ptrdiff_t stride, int c_idx, int mode)
  497. {
  498. FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5);
  499. }
  500. #undef EXTEND_LEFT_CIP
  501. #undef EXTEND_RIGHT_CIP
  502. #undef EXTEND_UP_CIP
  503. #undef EXTEND_DOWN_CIP
  504. #undef IS_INTRA
  505. #undef MVF_PU
  506. #undef MVF
  507. #undef PU
  508. #undef EXTEND
  509. #undef MIN_TB_ADDR_ZS
  510. #undef POS