libavcodec/hevcpred_template.c:342: error: Buffer Overrun L1
  Offset: -1 Size: 3 by call to `intra_pred_10`.

libavcodec/hevcpred_template.c:342:1: Call
340. }
341. 
342. INTRA_PRED(2)
     ^
343. INTRA_PRED(3)
344. INTRA_PRED(4)

libavcodec/hevcpred_template.c:31:1: <Offset trace>
29. #define POS(x, y) src[(x) + stride * (y)]
30. 
31. static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
    ^
32.                                               int log2_size, int c_idx)
33. {

libavcodec/hevcpred_template.c:31:1: Parameter `log2_size`
  29. #define POS(x, y) src[(x) + stride * (y)]
  30. 
  31. static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
      ^
  32.                                               int log2_size, int c_idx)
  33. {

libavcodec/hevcpred_template.c:31:1: <Length trace>
29. #define POS(x, y) src[(x) + stride * (y)]
30. 
31. static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
    ^
32.                                               int log2_size, int c_idx)
33. {

libavcodec/hevcpred_template.c:31:1: Array declaration
  29. #define POS(x, y) src[(x) + stride * (y)]
  30. 
  31. static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
      ^
  32.                                               int log2_size, int c_idx)
  33. {

libavcodec/hevcpred_template.c:285:33: Array access: Offset: -1 Size: 3 by call to `intra_pred_10` 
  283.         int min_dist_vert_hor = FFMIN(FFABS((int)mode - 26),
  284.                                       FFABS((int)mode - 10));
  285.         if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
                                       ^
  286.             int threshold = 1 << (BIT_DEPTH - 5);
  287.             if (s->sps->sps_strong_intra_smoothing_enable_flag &&

static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
                                              int log2_size, int c_idx)
{
#define PU(x) \
    ((x) >> s->sps->log2_min_pu_size)
#define MVF(x, y) \
    (s->ref->tab_mvf[(x) + (y) * min_pu_width])
#define MVF_PU(x, y) \
    MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift)))
#define IS_INTRA(x, y) \
    MVF_PU(x, y).is_intra
#define MIN_TB_ADDR_ZS(x, y) \
    s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)]
#define EXTEND(ptr, val, len)         \
do {                                  \
    pixel4 pix = PIXEL_SPLAT_X4(val); \
    for (i = 0; i < (len); i += 4)    \
        AV_WN4P(ptr + i, pix);        \
} while (0)
#define EXTEND_LEFT_CIP(ptr, start, length) \
        for (i = (start); i > (start) - (length); i--) \
            if (!IS_INTRA(i - 1, -1)) \
                ptr[i - 1] = ptr[i]
#define EXTEND_RIGHT_CIP(ptr, start, length) \
        for (i = (start); i < (start) + (length); i++) \
            if (!IS_INTRA(i, -1)) \
                ptr[i] = ptr[i - 1]
#define EXTEND_UP_CIP(ptr, start, length) \
        for (i = (start); i > (start) - (length); i--) \
            if (!IS_INTRA(-1, i - 1)) \
                ptr[i - 1] = ptr[i]
#define EXTEND_UP_CIP_0(ptr, start, length) \
        for (i = (start); i > (start) - (length); i--) \
            ptr[i - 1] = ptr[i]
#define EXTEND_DOWN_CIP(ptr, start, length) \
        for (i = (start); i < (start) + (length); i++) \
            if (!IS_INTRA(-1, i)) \
                ptr[i] = ptr[i - 1]
    HEVCLocalContext *lc = &s->HEVClc;
    int i;
    int hshift = s->sps->hshift[c_idx];
    int vshift = s->sps->vshift[c_idx];
    int size = (1 << log2_size);
    int size_in_luma = size << hshift;
    int size_in_tbs = size_in_luma >> s->sps->log2_min_tb_size;
    int x = x0 >> hshift;
    int y = y0 >> vshift;
    int x_tb = x0 >> s->sps->log2_min_tb_size;
    int y_tb = y0 >> s->sps->log2_min_tb_size;
    int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
    ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
    pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
    int min_pu_width = s->sps->min_pu_width;
    enum IntraPredMode mode = c_idx ? lc->pu.intra_pred_mode_c :
                              lc->tu.cur_intra_pred_mode;
    pixel left_array[2 * MAX_TB_SIZE + 1];
    pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
    pixel top_array[2 * MAX_TB_SIZE + 1];
    pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
    pixel *left          = left_array + 1;
    pixel *top           = top_array  + 1;
    pixel *filtered_left = filtered_left_array + 1;
    pixel *filtered_top  = filtered_top_array  + 1;
    int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs);
    int cand_left        = lc->na.cand_left;
    int cand_up_left     = lc->na.cand_up_left;
    int cand_up          = lc->na.cand_up;
    int cand_up_right    = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs, y_tb - 1);
    int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma, s->sps->height) -
                            (y0 + size_in_luma)) >> vshift;
    int top_right_size   = (FFMIN(x0 + 2 * size_in_luma, s->sps->width) -
                            (x0 + size_in_luma)) >> hshift;
    if (s->pps->constrained_intra_pred_flag == 1) {
        int size_in_luma_pu = PU(size_in_luma);
        int on_pu_edge_x    = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));
        int on_pu_edge_y    = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));
        if (!size_in_luma_pu)
            size_in_luma_pu++;
        if (cand_bottom_left == 1 && on_pu_edge_x) {
            int x_left_pu   = PU(x0 - 1);
            int y_bottom_pu = PU(y0 + size_in_luma);
            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu);
            cand_bottom_left = 0;
            for (i = 0; i < max; i++)
                cand_bottom_left |= MVF(x_left_pu, y_bottom_pu + i).is_intra;
        }
        if (cand_left == 1 && on_pu_edge_x) {
            int x_left_pu   = PU(x0 - 1);
            int y_left_pu   = PU(y0);
            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu);
            cand_left = 0;
            for (i = 0; i < max; i++)
                cand_left |= MVF(x_left_pu, y_left_pu + i).is_intra;
        }
        if (cand_up_left == 1) {
            int x_left_pu   = PU(x0 - 1);
            int y_top_pu    = PU(y0 - 1);
            cand_up_left = MVF(x_left_pu, y_top_pu).is_intra;
        }
        if (cand_up == 1 && on_pu_edge_y) {
            int x_top_pu    = PU(x0);
            int y_top_pu    = PU(y0 - 1);
            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu);
            cand_up = 0;
            for (i = 0; i < max; i++)
                cand_up |= MVF(x_top_pu + i, y_top_pu).is_intra;
        }
        if (cand_up_right == 1 && on_pu_edge_y) {
            int y_top_pu    = PU(y0 - 1);
            int x_right_pu  = PU(x0 + size_in_luma);
            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu);
            cand_up_right = 0;
            for (i = 0; i < max; i++)
                cand_up_right |= MVF(x_right_pu + i, y_top_pu).is_intra;
        }
        for (i = 0; i < 2 * MAX_TB_SIZE; i++) {
            left[i] = 128;
            top[i]  = 128;
        }
    }
    if (cand_bottom_left) {
        for (i = size; i < size + bottom_left_size; i++)
            left[i] = POS(-1, i);
        EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
               size - bottom_left_size);
    }
    if (cand_left)
        for (i = size - 1; i >= 0; i--)
            left[i] = POS(-1, i);
    if (cand_up_left) {
        left[-1] = POS(-1, -1);
        top[-1]  = left[-1];
    }
    if (cand_up)
        memcpy(top, src - stride, size * sizeof(pixel));
    if (cand_up_right) {
        memcpy(top + size, src - stride + size, size * sizeof(pixel));
        EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
               size - top_right_size);
    }
    if (s->pps->constrained_intra_pred_flag == 1) {
        if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
            int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?
                                    2 * size : (s->sps->width - x0) >> hshift;
            int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?
                                    2 * size : (s->sps->height - y0) >> vshift;
            int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
            if (!cand_up_right) {
                size_max_x = x0 + ((size) << hshift) < s->sps->width ?
                                                    size : (s->sps->width - x0) >> hshift;
            }
            if (!cand_bottom_left) {
                size_max_y = y0 + (( size) << vshift) < s->sps->height ?
                                                     size : (s->sps->height - y0) >> vshift;
            }
            if (cand_bottom_left || cand_left || cand_up_left) {
                while (j > -1 && !IS_INTRA(-1, j))
                    j--;
                if (!IS_INTRA(-1, j)) {
                    j = 0;
                    while (j < size_max_x && !IS_INTRA(j, -1))
                        j++;
                    EXTEND_LEFT_CIP(top, j, j + 1);
                    left[-1] = top[-1];
                    j        = 0;
                }
            } else {
                j = 0;
                while (j < size_max_x && !IS_INTRA(j, -1))
                    j++;
                if (j > 0)
                    if (x0 > 0) {
                        EXTEND_LEFT_CIP(top, j, j + 1);
                    } else {
                        EXTEND_LEFT_CIP(top, j, j);
                        top[-1] = top[0];
                    }
                left[-1] = top[-1];
                j        = 0;
            }
            if (cand_bottom_left || cand_left) {
                EXTEND_DOWN_CIP(left, j, size_max_y - j);
            }
            if (!cand_left)
                EXTEND(left, left[-1], size);
            if (!cand_bottom_left)
                EXTEND(left + size, left[size - 1], size);
            if (x0 != 0 && y0 != 0) {
                EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
            } else if (x0 == 0) {
                EXTEND_UP_CIP_0(left, size_max_y - 1, size_max_y);
            } else {
                EXTEND_UP_CIP(left, size_max_y - 1, size_max_y - 1);
            }
            top[-1] = left[-1];
            if (y0 != 0) {
                EXTEND_RIGHT_CIP(top, 0, size_max_x);
            }
        }
    }
    if (!cand_bottom_left) {
        if (cand_left) {
            EXTEND(left + size, left[size - 1], size);
        } else if (cand_up_left) {
            EXTEND(left, left[-1], 2 * size);
            cand_left = 1;
        } else if (cand_up) {
            left[-1] = top[0];
            EXTEND(left, left[-1], 2 * size);
            cand_up_left = 1;
            cand_left    = 1;
        } else if (cand_up_right) {
            EXTEND(top, top[size], size);
            left[-1] = top[size];
            EXTEND(left, left[-1], 2 * size);
            cand_up      = 1;
            cand_up_left = 1;
            cand_left    = 1;
        } else {
            left[-1] = (1 << (BIT_DEPTH - 1));
            EXTEND(top,  left[-1], 2 * size);
            EXTEND(left, left[-1], 2 * size);
        }
    }
    if (!cand_left)
        EXTEND(left, left[size], size);
    if (!cand_up_left) {
        left[-1] = left[0];
    }
    if (!cand_up)
        EXTEND(top, left[-1], size);
    if (!cand_up_right)
        EXTEND(top + size, top[size - 1], size);
    top[-1] = left[-1];
    if (c_idx == 0 && mode != INTRA_DC && size != 4) {
        int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
        int min_dist_vert_hor = FFMIN(FFABS((int)mode - 26),
                                      FFABS((int)mode - 10));
        if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
            int threshold = 1 << (BIT_DEPTH - 5);
            if (s->sps->sps_strong_intra_smoothing_enable_flag &&
                log2_size == 5 &&
                FFABS(top[-1]  + top[63]  - 2 * top[31])  < threshold &&
                FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
                filtered_top[-1] = top[-1];
                filtered_top[63] = top[63];
                for (i = 0; i < 63; i++)
                    filtered_top[i] = ((64 - (i + 1)) * top[-1] +
                                             (i + 1)  * top[63] + 32) >> 6;
                for (i = 0; i < 63; i++)
                    left[i] = ((64 - (i + 1)) * left[-1] +
                                     (i + 1)  * left[63] + 32) >> 6;
                top = filtered_top;
            } else {
                filtered_left[2 * size - 1] = left[2 * size - 1];
                filtered_top[2 * size - 1]  = top[2 * size - 1];
                for (i = 2 * size - 2; i >= 0; i--)
                    filtered_left[i] = (left[i + 1] + 2 * left[i] +
                                        left[i - 1] + 2) >> 2;
                filtered_top[-1]  =
                filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
                for (i = 2 * size - 2; i >= 0; i--)
                    filtered_top[i] = (top[i + 1] + 2 * top[i] +
                                       top[i - 1] + 2) >> 2;
                left = filtered_left;
                top  = filtered_top;
            }
        }
    }
    switch (mode) {
    case INTRA_PLANAR:
        s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
                                          (uint8_t *)left, stride);
        break;
    case INTRA_DC:
        s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
                       (uint8_t *)left, stride, log2_size, c_idx);
        break;
    default:
        s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
                                           (uint8_t *)left, stride, c_idx,
                                           mode);
        break;
    }
}
['INTRA_PRED(2)', 'static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,\n                                              int log2_size, int c_idx)\n{\n#define PU(x) \\\n    ((x) >> s->sps->log2_min_pu_size)\n#define MVF(x, y) \\\n    (s->ref->tab_mvf[(x) + (y) * min_pu_width])\n#define MVF_PU(x, y) \\\n    MVF(PU(x0 + ((x) << hshift)), PU(y0 + ((y) << vshift)))\n#define IS_INTRA(x, y) \\\n    MVF_PU(x, y).is_intra\n#define MIN_TB_ADDR_ZS(x, y) \\\n    s->pps->min_tb_addr_zs[(y) * s->sps->min_tb_width + (x)]\n#define EXTEND(ptr, val, len)         \\\ndo {                                  \\\n    pixel4 pix = PIXEL_SPLAT_X4(val); \\\n    for (i = 0; i < (len); i += 4)    \\\n        AV_WN4P(ptr + i, pix);        \\\n} while (0)\n#define EXTEND_LEFT_CIP(ptr, start, length) \\\n        for (i = (start); i > (start) - (length); i--) \\\n            if (!IS_INTRA(i - 1, -1)) \\\n                ptr[i - 1] = ptr[i]\n#define EXTEND_RIGHT_CIP(ptr, start, length) \\\n        for (i = (start); i < (start) + (length); i++) \\\n            if (!IS_INTRA(i, -1)) \\\n                ptr[i] = ptr[i - 1]\n#define EXTEND_UP_CIP(ptr, start, length) \\\n        for (i = (start); i > (start) - (length); i--) \\\n            if (!IS_INTRA(-1, i - 1)) \\\n                ptr[i - 1] = ptr[i]\n#define EXTEND_UP_CIP_0(ptr, start, length) \\\n        for (i = (start); i > (start) - (length); i--) \\\n            ptr[i - 1] = ptr[i]\n#define EXTEND_DOWN_CIP(ptr, start, length) \\\n        for (i = (start); i < (start) + (length); i++) \\\n            if (!IS_INTRA(-1, i)) \\\n                ptr[i] = ptr[i - 1]\n    HEVCLocalContext *lc = &s->HEVClc;\n    int i;\n    int hshift = s->sps->hshift[c_idx];\n    int vshift = s->sps->vshift[c_idx];\n    int size = (1 << log2_size);\n    int size_in_luma = size << hshift;\n    int size_in_tbs = size_in_luma >> s->sps->log2_min_tb_size;\n    int x = x0 >> hshift;\n    int y = y0 >> vshift;\n    int x_tb = x0 >> s->sps->log2_min_tb_size;\n    int y_tb = y0 >> s->sps->log2_min_tb_size;\n    int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);\n    ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);\n    pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;\n    int min_pu_width = s->sps->min_pu_width;\n    enum IntraPredMode mode = c_idx ? lc->pu.intra_pred_mode_c :\n                              lc->tu.cur_intra_pred_mode;\n    pixel left_array[2 * MAX_TB_SIZE + 1];\n    pixel filtered_left_array[2 * MAX_TB_SIZE + 1];\n    pixel top_array[2 * MAX_TB_SIZE + 1];\n    pixel filtered_top_array[2 * MAX_TB_SIZE + 1];\n    pixel *left          = left_array + 1;\n    pixel *top           = top_array  + 1;\n    pixel *filtered_left = filtered_left_array + 1;\n    pixel *filtered_top  = filtered_top_array  + 1;\n    int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb - 1, y_tb + size_in_tbs);\n    int cand_left        = lc->na.cand_left;\n    int cand_up_left     = lc->na.cand_up_left;\n    int cand_up          = lc->na.cand_up;\n    int cand_up_right    = lc->na.cand_up_right && cur_tb_addr > MIN_TB_ADDR_ZS(x_tb + size_in_tbs, y_tb - 1);\n    int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma, s->sps->height) -\n                            (y0 + size_in_luma)) >> vshift;\n    int top_right_size   = (FFMIN(x0 + 2 * size_in_luma, s->sps->width) -\n                            (x0 + size_in_luma)) >> hshift;\n    if (s->pps->constrained_intra_pred_flag == 1) {\n        int size_in_luma_pu = PU(size_in_luma);\n        int on_pu_edge_x    = !(x0 & ((1 << s->sps->log2_min_pu_size) - 1));\n        int on_pu_edge_y    = !(y0 & ((1 << s->sps->log2_min_pu_size) - 1));\n        if (!size_in_luma_pu)\n            size_in_luma_pu++;\n        if (cand_bottom_left == 1 && on_pu_edge_x) {\n            int x_left_pu   = PU(x0 - 1);\n            int y_bottom_pu = PU(y0 + size_in_luma);\n            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_bottom_pu);\n            cand_bottom_left = 0;\n            for (i = 0; i < max; i++)\n                cand_bottom_left |= MVF(x_left_pu, y_bottom_pu + i).is_intra;\n        }\n        if (cand_left == 1 && on_pu_edge_x) {\n            int x_left_pu   = PU(x0 - 1);\n            int y_left_pu   = PU(y0);\n            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_height - y_left_pu);\n            cand_left = 0;\n            for (i = 0; i < max; i++)\n                cand_left |= MVF(x_left_pu, y_left_pu + i).is_intra;\n        }\n        if (cand_up_left == 1) {\n            int x_left_pu   = PU(x0 - 1);\n            int y_top_pu    = PU(y0 - 1);\n            cand_up_left = MVF(x_left_pu, y_top_pu).is_intra;\n        }\n        if (cand_up == 1 && on_pu_edge_y) {\n            int x_top_pu    = PU(x0);\n            int y_top_pu    = PU(y0 - 1);\n            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_top_pu);\n            cand_up = 0;\n            for (i = 0; i < max; i++)\n                cand_up |= MVF(x_top_pu + i, y_top_pu).is_intra;\n        }\n        if (cand_up_right == 1 && on_pu_edge_y) {\n            int y_top_pu    = PU(y0 - 1);\n            int x_right_pu  = PU(x0 + size_in_luma);\n            int max = FFMIN(size_in_luma_pu, s->sps->min_pu_width - x_right_pu);\n            cand_up_right = 0;\n            for (i = 0; i < max; i++)\n                cand_up_right |= MVF(x_right_pu + i, y_top_pu).is_intra;\n        }\n        for (i = 0; i < 2 * MAX_TB_SIZE; i++) {\n            left[i] = 128;\n            top[i]  = 128;\n        }\n    }\n    if (cand_bottom_left) {\n        for (i = size; i < size + bottom_left_size; i++)\n            left[i] = POS(-1, i);\n        EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),\n               size - bottom_left_size);\n    }\n    if (cand_left)\n        for (i = size - 1; i >= 0; i--)\n            left[i] = POS(-1, i);\n    if (cand_up_left) {\n        left[-1] = POS(-1, -1);\n        top[-1]  = left[-1];\n    }\n    if (cand_up)\n        memcpy(top, src - stride, size * sizeof(pixel));\n    if (cand_up_right) {\n        memcpy(top + size, src - stride + size, size * sizeof(pixel));\n        EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),\n               size - top_right_size);\n    }\n    if (s->pps->constrained_intra_pred_flag == 1) {\n        if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {\n            int size_max_x = x0 + ((2 * size) << hshift) < s->sps->width ?\n                                    2 * size : (s->sps->width - x0) >> hshift;\n            int size_max_y = y0 + ((2 * size) << vshift) < s->sps->height ?\n                                    2 * size : (s->sps->height - y0) >> vshift;\n            int j = size + (cand_bottom_left? bottom_left_size: 0) -1;\n            if (!cand_up_right) {\n                size_max_x = x0 + ((size) << hshift) < s->sps->width ?\n                                                    size : (s->sps->width - x0) >> hshift;\n            }\n            if (!cand_bottom_left) {\n                size_max_y = y0 + (( size) << vshift) < s->sps->height ?\n                                                     size : (s->sps->height - y0) >> vshift;\n            }\n            if (cand_bottom_left || cand_left || cand_up_left) {\n                while (j > -1 && !IS_INTRA(-1, j))\n                    j--;\n                if (!IS_INTRA(-1, j)) {\n                    j = 0;\n                    while (j < size_max_x && !IS_INTRA(j, -1))\n                        j++;\n                    EXTEND_LEFT_CIP(top, j, j + 1);\n                    left[-1] = top[-1];\n                    j        = 0;\n                }\n            } else {\n                j = 0;\n                while (j < size_max_x && !IS_INTRA(j, -1))\n                    j++;\n                if (j > 0)\n                    if (x0 > 0) {\n                        EXTEND_LEFT_CIP(top, j, j + 1);\n                    } else {\n                        EXTEND_LEFT_CIP(top, j, j);\n                        top[-1] = top[0];\n                    }\n                left[-1] = top[-1];\n                j        = 0;\n            }\n            if (cand_bottom_left || cand_left) {\n                EXTEND_DOWN_CIP(left, j, size_max_y - j);\n            }\n            if (!cand_left)\n                EXTEND(left, left[-1], size);\n            if (!cand_bottom_left)\n                EXTEND(left + size, left[size - 1], size);\n            if (x0 != 0 && y0 != 0) {\n                EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);\n            } else if (x0 == 0) {\n                EXTEND_UP_CIP_0(left, size_max_y - 1, size_max_y);\n            } else {\n                EXTEND_UP_CIP(left, size_max_y - 1, size_max_y - 1);\n            }\n            top[-1] = left[-1];\n            if (y0 != 0) {\n                EXTEND_RIGHT_CIP(top, 0, size_max_x);\n            }\n        }\n    }\n    if (!cand_bottom_left) {\n        if (cand_left) {\n            EXTEND(left + size, left[size - 1], size);\n        } else if (cand_up_left) {\n            EXTEND(left, left[-1], 2 * size);\n            cand_left = 1;\n        } else if (cand_up) {\n            left[-1] = top[0];\n            EXTEND(left, left[-1], 2 * size);\n            cand_up_left = 1;\n            cand_left    = 1;\n        } else if (cand_up_right) {\n            EXTEND(top, top[size], size);\n            left[-1] = top[size];\n            EXTEND(left, left[-1], 2 * size);\n            cand_up      = 1;\n            cand_up_left = 1;\n            cand_left    = 1;\n        } else {\n            left[-1] = (1 << (BIT_DEPTH - 1));\n            EXTEND(top,  left[-1], 2 * size);\n            EXTEND(left, left[-1], 2 * size);\n        }\n    }\n    if (!cand_left)\n        EXTEND(left, left[size], size);\n    if (!cand_up_left) {\n        left[-1] = left[0];\n    }\n    if (!cand_up)\n        EXTEND(top, left[-1], size);\n    if (!cand_up_right)\n        EXTEND(top + size, top[size - 1], size);\n    top[-1] = left[-1];\n    if (c_idx == 0 && mode != INTRA_DC && size != 4) {\n        int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };\n        int min_dist_vert_hor = FFMIN(FFABS((int)mode - 26),\n                                      FFABS((int)mode - 10));\n        if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {\n            int threshold = 1 << (BIT_DEPTH - 5);\n            if (s->sps->sps_strong_intra_smoothing_enable_flag &&\n                log2_size == 5 &&\n                FFABS(top[-1]  + top[63]  - 2 * top[31])  < threshold &&\n                FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {\n                filtered_top[-1] = top[-1];\n                filtered_top[63] = top[63];\n                for (i = 0; i < 63; i++)\n                    filtered_top[i] = ((64 - (i + 1)) * top[-1] +\n                                             (i + 1)  * top[63] + 32) >> 6;\n                for (i = 0; i < 63; i++)\n                    left[i] = ((64 - (i + 1)) * left[-1] +\n                                     (i + 1)  * left[63] + 32) >> 6;\n                top = filtered_top;\n            } else {\n                filtered_left[2 * size - 1] = left[2 * size - 1];\n                filtered_top[2 * size - 1]  = top[2 * size - 1];\n                for (i = 2 * size - 2; i >= 0; i--)\n                    filtered_left[i] = (left[i + 1] + 2 * left[i] +\n                                        left[i - 1] + 2) >> 2;\n                filtered_top[-1]  =\n                filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;\n                for (i = 2 * size - 2; i >= 0; i--)\n                    filtered_top[i] = (top[i + 1] + 2 * top[i] +\n                                       top[i - 1] + 2) >> 2;\n                left = filtered_left;\n                top  = filtered_top;\n            }\n        }\n    }\n    switch (mode) {\n    case INTRA_PLANAR:\n        s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,\n                                          (uint8_t *)left, stride);\n        break;\n    case INTRA_DC:\n        s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,\n                       (uint8_t *)left, stride, log2_size, c_idx);\n        break;\n    default:\n        s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,\n                                           (uint8_t *)left, stride, c_idx,\n                                           mode);\n        break;\n    }\n}']