75 int log2_size,
int c_idx)
78 ((x) >> sps->log2_min_pu_size)
80 (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width])
82 MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift))))
83#define IS_INTRA(x, y) \
84 (MVF_PU(x, y).pred_flag == PF_INTRA)
85#define MIN_TB_ADDR_ZS(x, y) \
86 pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)]
87#define EXTEND(ptr, val, len) \
89 pixel4 pix = PIXEL_SPLAT_X4(val); \
90 for (i = 0; i < (len); i += 4) \
91 AV_WN4P(ptr + i, pix); \
94#define EXTEND_RIGHT_CIP(ptr, start, length) \
95 for (i = start; i < (start) + (length); i += 4) \
96 if (!IS_INTRA(i, -1)) \
97 AV_WN4P(&ptr[i], a); \
99 a = PIXEL_SPLAT_X4(ptr[i+3])
100#define EXTEND_LEFT_CIP(ptr, start, length) \
101 for (i = start; i > (start) - (length); i--) \
102 if (!IS_INTRA(i - 1, -1)) \
104#define EXTEND_UP_CIP(ptr, start, length) \
105 for (i = (start); i > (start) - (length); i -= 4) \
106 if (!IS_INTRA(-1, i - 3)) \
107 AV_WN4P(&ptr[i - 3], a); \
109 a = PIXEL_SPLAT_X4(ptr[i - 3])
110#define EXTEND_DOWN_CIP(ptr, start, length) \
111 for (i = start; i < (start) + (length); i += 4) \
112 if (!IS_INTRA(-1, i)) \
113 AV_WN4P(&ptr[i], a); \
115 a = PIXEL_SPLAT_X4(ptr[i + 3])
120 int hshift =
sps->hshift[c_idx];
121 int vshift =
sps->vshift[c_idx];
122 int size = (1 << log2_size);
123 int size_in_luma_h =
size << hshift;
124 int size_in_tbs_h = size_in_luma_h >>
sps->log2_min_tb_size;
125 int size_in_luma_v =
size << vshift;
126 int size_in_tbs_v = size_in_luma_v >>
sps->log2_min_tb_size;
127 int x = x0 >> hshift;
128 int y = y0 >> vshift;
129 int x_tb = (x0 >>
sps->log2_min_tb_size) &
sps->tb_mask;
130 int y_tb = (y0 >>
sps->log2_min_tb_size) &
sps->tb_mask;
131 int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 <<
sps->log2_min_tb_size));
135 ptrdiff_t
stride =
s->cur_frame->f->linesize[c_idx] /
sizeof(
pixel);
138 int min_pu_width =
sps->min_pu_width;
141 lc->tu.intra_pred_mode;
151 pixel *top = top_array + 1;
152 pixel *filtered_left = filtered_left_array + 1;
153 pixel *filtered_top = filtered_top_array + 1;
154 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 + spin) &
sps->tb_mask);
155 int cand_left = lc->na.cand_left;
156 int cand_up_left = lc->na.cand_up_left;
157 int cand_up = lc->na.cand_up;
158 int cand_up_right = lc->na.cand_up_right && !spin && cur_tb_addr >
MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) &
sps->tb_mask, y_tb - 1);
160 int bottom_left_size = (
FFMIN(y0 + 2 * size_in_luma_v,
sps->height) -
161 (y0 + size_in_luma_v)) >> vshift;
162 int top_right_size = (
FFMIN(x0 + 2 * size_in_luma_h,
sps->width) -
163 (x0 + size_in_luma_h)) >> hshift;
165 if (
pps->constrained_intra_pred_flag == 1) {
166 int size_in_luma_pu_v =
PU(size_in_luma_v);
167 int size_in_luma_pu_h =
PU(size_in_luma_h);
170 if (!size_in_luma_pu_h)
172 if (cand_bottom_left == 1 && on_pu_edge_x) {
173 int x_left_pu =
PU(x0 - 1);
174 int y_bottom_pu =
PU(y0 + size_in_luma_v);
175 int max =
FFMIN(size_in_luma_pu_v,
sps->min_pu_height - y_bottom_pu);
176 cand_bottom_left = 0;
177 for (
i = 0;
i <
max;
i += 2)
178 cand_bottom_left |= (
MVF(x_left_pu, y_bottom_pu +
i).pred_flag ==
PF_INTRA);
180 if (cand_left == 1 && on_pu_edge_x) {
181 int x_left_pu =
PU(x0 - 1);
182 int y_left_pu =
PU(y0);
183 int max =
FFMIN(size_in_luma_pu_v,
sps->min_pu_height - y_left_pu);
185 for (
i = 0;
i <
max;
i += 2)
186 cand_left |= (
MVF(x_left_pu, y_left_pu +
i).pred_flag ==
PF_INTRA);
188 if (cand_up_left == 1) {
189 int x_left_pu =
PU(x0 - 1);
190 int y_top_pu =
PU(y0 - 1);
191 cand_up_left =
MVF(x_left_pu, y_top_pu).pred_flag ==
PF_INTRA;
193 if (cand_up == 1 && on_pu_edge_y) {
194 int x_top_pu =
PU(x0);
195 int y_top_pu =
PU(y0 - 1);
196 int max =
FFMIN(size_in_luma_pu_h,
sps->min_pu_width - x_top_pu);
198 for (
i = 0;
i <
max;
i += 2)
199 cand_up |= (
MVF(x_top_pu +
i, y_top_pu).pred_flag ==
PF_INTRA);
201 if (cand_up_right == 1 && on_pu_edge_y) {
202 int y_top_pu =
PU(y0 - 1);
203 int x_right_pu =
PU(x0 + size_in_luma_h);
204 int max =
FFMIN(size_in_luma_pu_h,
sps->min_pu_width - x_right_pu);
206 for (
i = 0;
i <
max;
i += 2)
207 cand_up_right |= (
MVF(x_right_pu +
i, y_top_pu).pred_flag ==
PF_INTRA);
222 size - top_right_size);
227 if (cand_bottom_left) {
231 size - bottom_left_size);
234 if (
pps->constrained_intra_pred_flag == 1) {
235 if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
236 int size_max_x = x0 + ((2 *
size) << hshift) <
sps->width ?
237 2 *
size : (
sps->width - x0) >> hshift;
238 int size_max_y = y0 + ((2 *
size) << vshift) <
sps->height ?
239 2 *
size : (
sps->height - y0) >> vshift;
240 int j =
size + (cand_bottom_left? bottom_left_size: 0) -1;
241 if (!cand_up_right) {
242 size_max_x = x0 + ((
size) << hshift) <
sps->width ?
243 size : (
sps->width - x0) >> hshift;
245 if (!cand_bottom_left) {
246 size_max_y = y0 + ((
size) << vshift) <
sps->height ?
247 size : (
sps->height - y0) >> vshift;
249 if (cand_bottom_left || cand_left || cand_up_left) {
254 while (j < size_max_x && !
IS_INTRA(j, -1))
261 while (j < size_max_x && !
IS_INTRA(j, -1))
270 if (cand_bottom_left || cand_left) {
276 if (!cand_bottom_left)
278 if (x0 != 0 && y0 != 0) {
283 }
else if (x0 == 0) {
297 if (!cand_bottom_left) {
300 }
else if (cand_up_left) {
303 }
else if (cand_up) {
308 }
else if (cand_up_right) {
335 if (!
sps->intra_smoothing_disabled && (c_idx == 0 ||
sps->chroma_format_idc == 3)) {
337 int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
340 if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
342 if (
sps->strong_intra_smoothing_enabled && c_idx == 0 &&
344 FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
346 s->hpc.ref_filter_strong((uint8_t *)filtered_top,
348 (
const uint8_t *)top);
351 s->hpc.ref_filter_3tap[log2_size - 3](
352 (uint8_t *)filtered_left, (uint8_t *)filtered_top,
353 (
const uint8_t *)
left, (
const uint8_t *)top,
size);
354 left = filtered_left;
363 s->hpc.pred_planar[log2_size - 2]((uint8_t *)
src, (uint8_t *)top,
367 s->hpc.pred_dc((uint8_t *)
src, (uint8_t *)top,
371 s->hpc.pred_angular[log2_size - 2]((uint8_t *)
src, (uint8_t *)top,
454 const uint8_t *_left,
455 ptrdiff_t
stride,
int c_idx,
463 static const int intra_pred_angle[] = {
464 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32,
465 -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32
467 static const int inv_angle[] = {
468 -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482,
469 -630, -910, -1638, -4096
472 int angle = intra_pred_angle[
mode - 2];
476 int last = (
size * angle) >> 5;
480 if (angle < 0 && last < -1) {
481 for (x = 0; x <=
size; x += 4)
483 for (x = last; x <= -1; x++)
484 ref_tmp[x] =
left[-1 + ((x * inv_angle[
mode - 11] + 128) >> 8)];
488 for (y = 0; y <
size; y++) {
489 int idx = ((y + 1) * angle) >> 5;
490 int fact = ((y + 1) * angle) & 31;
492 for (x = 0; x <
size; x += 4) {
493 POS(x , y) = ((32 -
fact) *
ref[x + idx + 1] +
494 fact *
ref[x + idx + 2] + 16) >> 5;
495 POS(x + 1, y) = ((32 -
fact) *
ref[x + 1 + idx + 1] +
496 fact *
ref[x + 1 + idx + 2] + 16) >> 5;
497 POS(x + 2, y) = ((32 -
fact) *
ref[x + 2 + idx + 1] +
498 fact *
ref[x + 2 + idx + 2] + 16) >> 5;
499 POS(x + 3, y) = ((32 -
fact) *
ref[x + 3 + idx + 1] +
500 fact *
ref[x + 3 + idx + 2] + 16) >> 5;
503 for (x = 0; x <
size; x += 4)
507 if (
mode == 26 && c_idx == 0 &&
size < 32) {
508 for (y = 0; y <
size; y++)
513 if (angle < 0 && last < -1) {
514 for (x = 0; x <=
size; x += 4)
516 for (x = last; x <= -1; x++)
517 ref_tmp[x] = top[-1 + ((x * inv_angle[
mode - 11] + 128) >> 8)];
521 for (x = 0; x <
size; x++) {
522 int idx = ((x + 1) * angle) >> 5;
523 int fact = ((x + 1) * angle) & 31;
525 for (y = 0; y <
size; y++) {
527 fact *
ref[y + idx + 2] + 16) >> 5;
530 for (y = 0; y <
size; y++)
531 POS(x, y) =
ref[y + idx + 1];
534 if (
mode == 10 && c_idx == 0 &&
size < 32) {
535 for (x = 0; x <
size; x += 4) {