Home | History | Annotate | Download | only in common
      1 /******************************************************************************
      2  *
      3  * Copyright (C) 2015 The Android Open Source Project
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at:
      8  *
      9  * http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  *
     17  *****************************************************************************
     18  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
     19 */
     20 /**
     21  *******************************************************************************
     22  * @file
     23  *  ih264_luma_intra_pred_filters.c
     24  *
     25  * @brief
     26  *  Contains function definitions for intra prediction  filters
     27  *
     28  * @author
     29  *  Ittiam
     30  *
     31  * @par List of Functions:
     32  *  - ih264_intra_pred_luma_4x4_mode_vert
     33  *  - ih264_intra_pred_luma_4x4_mode_horz
     34  *  - ih264_intra_pred_luma_4x4_mode_dc
     35  *  - ih264_intra_pred_luma_4x4_mode_diag_dl
     36  *  - ih264_intra_pred_luma_4x4_mode_diag_dr
     37  *  - ih264_intra_pred_luma_4x4_mode_vert_r
     38  *  - ih264_intra_pred_luma_4x4_mode_horz_d
     39  *  - ih264_intra_pred_luma_4x4_mode_vert_l
     40  *  - ih264_intra_pred_luma_4x4_mode_horz_u
     41  *  - ih264_intra_pred_luma_8x8_mode_ref_filtering
     42  *  - ih264_intra_pred_luma_8x8_mode_vert
     43  *  - ih264_intra_pred_luma_8x8_mode_horz
     44  *  - ih264_intra_pred_luma_8x8_mode_dc
     45  *  - ih264_intra_pred_luma_8x8_mode_diag_dl
     46  *  - ih264_intra_pred_luma_8x8_mode_diag_dr
     47  *  - ih264_intra_pred_luma_8x8_mode_vert_r
     48  *  - ih264_intra_pred_luma_8x8_mode_horz_d
     49  *  - ih264_intra_pred_luma_8x8_mode_vert_l
     50  *  - ih264_intra_pred_luma_8x8_mode_horz_u
     51  *  - ih264_intra_pred_luma_16x16_mode_vert
     52  *  - ih264_intra_pred_luma_16x16_mode_horz
     53  *  - ih264_intra_pred_luma_16x16_mode_dc
     54  *  - ih264_intra_pred_luma_16x16_mode_plane
     55  *
     56  *
     57  * @remarks
     58  *  None
     59  *
     60  ******************************************************************************
     61  */
     62 
     63 /*****************************************************************************/
     64 /* File Includes                                                             */
     65 /*****************************************************************************/
     66 /* System include files */
     67 #include <stdio.h>
     68 #include <stddef.h>
     69 #include <string.h>
     70 
     71 /* User include files */
     72 #include "ih264_defs.h"
     73 #include "ih264_typedefs.h"
     74 #include "ih264_macros.h"
     75 #include "ih264_platform_macros.h"
     76 #include "ih264_intra_pred_filters.h"
     77 
     78 /* Global variables used only in assembly files*/
     79 const WORD8 ih264_gai1_intrapred_luma_plane_coeffs[] =
     80 { 0x01, 0x02, 0x03, 0x04,
     81   0x05, 0x06, 0x07, 0x08,
     82   0x09, 0x0A, 0x0B, 0x0C,
     83   0x0D, 0x0E, 0x0F, 0x10, };
     84 
     85 const WORD8  ih264_gai1_intrapred_luma_8x8_horz_u[] =
     86 { 0x06,0x15,0x05,0x14,
     87   0x04,0x13,0x03,0x12,
     88   0x02,0x11,0x01,0x10,
     89   0x00,0x1F,0x0F,0x0F
     90 };
     91 
     92 /*******************    LUMA INTRAPREDICTION    *******************/
     93 
     94 /*******************    4x4 Modes    *******************/
     95 
     96 /**
     97  *******************************************************************************
     98  *
     99  *ih264_intra_pred_luma_4x4_mode_vert
    100  *
    101  * @brief
    102  *  Perform Intra prediction for  luma_4x4 mode:vertical
    103  *
    104  * @par Description:
    105  * Perform Intra prediction for  luma_4x4 mode:vertical ,described in sec 8.3.1.2.1
    106  *
    107  * @param[in] pu1_src
    108  *  UWORD8 pointer to the source
    109  *
    110  * @param[out] pu1_dst
    111  *  UWORD8 pointer to the destination
    112  *
    113  * @param[in] src_strd
    114  *  integer source stride
    115  *
    116  * @param[in] dst_strd
    117  *  integer destination stride
    118  *
    119  * @param[in] ngbr_avail
    120  * availability of neighbouring pixels(Not used in this function)
    121  *
    122  * @returns
    123  *
    124  * @remarks
    125  *  None
    126  *
    127  *******************************************************************************
    128  */
    129 void ih264_intra_pred_luma_4x4_mode_vert(UWORD8 *pu1_src,
    130                                          UWORD8 *pu1_dst,
    131                                          WORD32 src_strd,
    132                                          WORD32 dst_strd,
    133                                          WORD32 ngbr_avail)
    134 {
    135     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    136     UNUSED(src_strd);
    137     UNUSED(ngbr_avail);
    138     pu1_top = pu1_src + BLK_SIZE + 1;
    139 
    140     memcpy(pu1_dst, pu1_top, 4);
    141     memcpy(pu1_dst + dst_strd, pu1_top, 4);
    142     memcpy(pu1_dst + 2 * dst_strd, pu1_top, 4);
    143     memcpy(pu1_dst + 3 * dst_strd, pu1_top, 4);
    144 }
    145 
    146 /**
    147  *******************************************************************************
    148  *
    149  *ih264_intra_pred_luma_4x4_mode_horz
    150  *
    151  * @brief
    152  *  Perform Intra prediction for  luma_4x4 mode:horizontal
    153  *
    154  * @par Description:
    155  *  Perform Intra prediction for  luma_4x4 mode:horizontal ,described in sec 8.3.1.2.2
    156  *
    157  * @param[in] pu1_src
    158  *  UWORD8 pointer to the source
    159  *
    160  * @param[out] pu1_dst
    161  *  UWORD8 pointer to the destination
    162  *
    163  * @param[in] src_strd
    164  *  integer source stride
    165  *
    166  * @param[in] dst_strd
    167  *  integer destination stride
    168  *
    169  * @param[in] ngbr_avail
    170  * availability of neighbouring pixels(Not used in this function)
    171  *
    172  * @returns
    173  *
    174  * @remarks
    175  *  None
    176  *
    177  *******************************************************************************
    178  */
    179 void ih264_intra_pred_luma_4x4_mode_horz(UWORD8 *pu1_src,
    180                                          UWORD8 *pu1_dst,
    181                                          WORD32 src_strd,
    182                                          WORD32 dst_strd,
    183                                          WORD32 ngbr_avail)
    184 {
    185     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    186 
    187     UNUSED(src_strd);
    188     UNUSED(ngbr_avail);
    189     pu1_left = pu1_src + BLK_SIZE - 1;
    190 
    191     memset(pu1_dst, *pu1_left, 4);
    192     memset(pu1_dst + dst_strd, *(pu1_left - 1), 4);
    193     memset(pu1_dst + 2 * dst_strd, *(pu1_left - 2), 4);
    194     memset(pu1_dst + 3 * dst_strd, *(pu1_left - 3), 4);
    195 }
    196 
    197 /**
    198  *******************************************************************************
    199  *
    200  *ih264_intra_pred_luma_4x4_mode_dc
    201  *
    202  * @brief
    203  *  Perform Intra prediction for  luma_4x4 mode:DC
    204  *
    205  * @par Description:
    206  *  Perform Intra prediction for  luma_4x4 mode:DC ,described in sec 8.3.1.2.3
    207  *
    208  * @param[in] pu1_src
    209  *  UWORD8 pointer to the source
    210  *
    211  * @param[out] pu1_dst
    212  *  UWORD8 pointer to the destination
    213  *
    214  * @param[in] src_strd
    215  *  integer source stride
    216  *
    217  * @param[in] dst_strd
    218  *  integer destination stride
    219  *
    220  * @param[in] ngbr_avail
    221  *  availability of neighbouring pixels
    222  *
    223  * @returns
    224  *
    225  * @remarks
    226  *  None
    227  *
    228  *******************************************************************************/
    229 void ih264_intra_pred_luma_4x4_mode_dc(UWORD8 *pu1_src,
    230                                        UWORD8 *pu1_dst,
    231                                        WORD32 src_strd,
    232                                        WORD32 dst_strd,
    233                                        WORD32 ngbr_avail)
    234 {
    235     UWORD8 u1_useleft; /* availability of left predictors (only for DC) */
    236     UWORD8 u1_usetop; /* availability of top predictors (only for DC) */
    237     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    238     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    239     WORD32 val = 0;
    240     UNUSED(src_strd);
    241     UNUSED(ngbr_avail);
    242     u1_useleft = BOOLEAN(ngbr_avail & LEFT_MB_AVAILABLE_MASK);
    243     u1_usetop = BOOLEAN(ngbr_avail & TOP_MB_AVAILABLE_MASK);
    244     pu1_top = pu1_src + BLK_SIZE + 1;
    245     pu1_left = pu1_src + BLK_SIZE - 1;
    246 
    247     if(u1_useleft)
    248     {
    249         val += *pu1_left--;
    250         val += *pu1_left--;
    251         val += *pu1_left--;
    252         val += *pu1_left + 2;
    253     }
    254     if(u1_usetop)
    255     {
    256         val += *pu1_top + *(pu1_top + 1) + *(pu1_top + 2) + *(pu1_top + 3)
    257                         + 2;
    258     }
    259     /* Since 2 is added if either left/top pred is there,
    260      val still being zero implies both preds are not there */
    261     val = (val) ? (val >> (1 + u1_useleft + u1_usetop)) : 128;
    262 
    263     /* 4 bytes are copied from src to dst */
    264     memset(pu1_dst, val, 4);
    265     memset(pu1_dst + dst_strd, val, 4);
    266     memset(pu1_dst + 2 * dst_strd, val, 4);
    267     memset(pu1_dst + 3 * dst_strd, val, 4);
    268 }
    269 
    270 /**
    271  *******************************************************************************
    272  *
    273  *ih264_intra_pred_luma_4x4_mode_diag_dl
    274  *
    275  * @brief
    276  *     Perform Intra prediction for  luma_4x4 mode:Diagonal_Down_Left
    277  *
    278  * @par Description:
    279  *    Perform Intra prediction for  luma_4x4 mode:Diagonal_Down_Left ,described in sec 8.3.1.2.4
    280  *
    281  * @param[in] pu1_src
    282  *  UWORD8 pointer to the source
    283  *
    284  * @param[out] pu1_dst
    285  *  UWORD8 pointer to the destination
    286  *
    287  * @param[in] src_strd
    288  *  integer source stride
    289  *
    290  * @param[in] dst_strd
    291  *  integer destination stride
    292  *
    293  * @param[in] ngbr_avail
    294  * availability of neighbouring pixels(Not used in this function)
    295  *
    296  * @returns
    297  *
    298  * @remarks
    299  *  None
    300  *
    301  *******************************************************************************/
    302 void ih264_intra_pred_luma_4x4_mode_diag_dl(UWORD8 *pu1_src,
    303                                             UWORD8 *pu1_dst,
    304                                             WORD32 src_strd,
    305                                             WORD32 dst_strd,
    306                                             WORD32 ngbr_avail)
    307 {
    308     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    309     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h;
    310     UWORD8 predicted_pixels[7];
    311     UNUSED(src_strd);
    312     UNUSED(ngbr_avail);
    313     pu1_top = pu1_src +BLK_SIZE + 1;
    314 
    315     ui4_a = *pu1_top++;
    316     ui4_b = *pu1_top++;
    317     ui4_c = *pu1_top++;
    318     ui4_d = *pu1_top++;
    319     ui4_e = *pu1_top++;
    320     ui4_f = *pu1_top++;
    321     ui4_g = *pu1_top++;
    322     ui4_h = *pu1_top;
    323 
    324     predicted_pixels[0] = FILT121(ui4_a, ui4_b, ui4_c);
    325     predicted_pixels[1] = FILT121(ui4_b, ui4_c, ui4_d);
    326     predicted_pixels[2] = FILT121(ui4_c, ui4_d, ui4_e);
    327     predicted_pixels[3] = FILT121(ui4_d, ui4_e, ui4_f);
    328     predicted_pixels[4] = FILT121(ui4_e, ui4_f, ui4_g);
    329     predicted_pixels[5] = FILT121(ui4_f, ui4_g, ui4_h);
    330     predicted_pixels[6] = FILT121(ui4_g, ui4_h, ui4_h);
    331 
    332     memcpy(pu1_dst, predicted_pixels, 4);
    333     memcpy(pu1_dst + dst_strd, predicted_pixels + 1, 4);
    334     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 2, 4);
    335     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 3, 4);
    336 }
    337 
    338 /**
    339  *******************************************************************************
    340  *
    341  *ih264_intra_pred_luma_4x4_mode_diag_dr
    342  *
    343  * @brief
    344  *     Perform Intra prediction for  luma_4x4 mode:Diagonal_Down_Right
    345  *
    346  * @par Description:
    347  *    Perform Intra prediction for  luma_4x4 mode:Diagonal_Down_Right ,described in sec 8.3.1.2.5
    348  *
    349  * @param[in] pu1_src
    350  *  UWORD8 pointer to the source
    351  *
    352  * @param[out] pu1_dst
    353  *  UWORD8 pointer to the destination
    354  *
    355  * @param[in] src_strd
    356  *  integer source stride
    357  *
    358  * @param[in] dst_strd
    359  *  integer destination stride
    360  *
    361  * @param[in] ngbr_avail
    362  * availability of neighbouring pixels(Not used in this function)
    363  *
    364  * @returns
    365  *
    366  * @remarks
    367  *  None
    368  *
    369  *******************************************************************************/
    370 void ih264_intra_pred_luma_4x4_mode_diag_dr(UWORD8 *pu1_src,
    371                                             UWORD8 *pu1_dst,
    372                                             WORD32 src_strd,
    373                                             WORD32 dst_strd,
    374                                             WORD32 ngbr_avail)
    375 {
    376     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    377     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    378     UWORD8 *pu1_topleft = NULL;/* Pointer to top left predictor */
    379     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_i, ui4_j, ui4_k, ui4_l, ui4_m;
    380     UWORD8 predicted_pixels[7];
    381     UNUSED(src_strd);
    382     UNUSED(ngbr_avail);
    383     pu1_top = pu1_src + BLK_SIZE + 1;
    384     pu1_left = pu1_src + BLK_SIZE - 1;
    385     pu1_topleft = pu1_src +BLK_SIZE;
    386 
    387     ui4_a = *pu1_top++;
    388     ui4_b = *pu1_top++;
    389     ui4_c = *pu1_top++;
    390     ui4_d = *pu1_top++;
    391     ui4_i = *pu1_left--;
    392     ui4_j = *pu1_left--;
    393     ui4_k = *pu1_left--;
    394     ui4_l = *pu1_left;
    395     ui4_m = *pu1_topleft;
    396 
    397     predicted_pixels[2] = FILT121(ui4_j, ui4_i, ui4_m);
    398     predicted_pixels[1] = FILT121(ui4_k, ui4_j, ui4_i);
    399     predicted_pixels[0] = FILT121(ui4_l, ui4_k, ui4_j);
    400     predicted_pixels[3] = FILT121(ui4_i, ui4_m, ui4_a);
    401     predicted_pixels[4] = FILT121(ui4_m, ui4_a, ui4_b);
    402     predicted_pixels[5] = FILT121(ui4_a, ui4_b, ui4_c);
    403     predicted_pixels[6] = FILT121(ui4_b, ui4_c, ui4_d);
    404 
    405     memcpy(pu1_dst, predicted_pixels + 3, 4);
    406     memcpy(pu1_dst + dst_strd, predicted_pixels + 2, 4);
    407     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 1, 4);
    408     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels, 4);
    409 }
    410 
    411 /**
    412  *******************************************************************************
    413  *
    414  *ih264_intra_pred_luma_4x4_mode_vert_r
    415  *
    416  * @brief
    417  *     Perform Intra prediction for  luma_4x4 mode:Vertical_Right
    418  *
    419  * @par Description:
    420  *    Perform Intra prediction for  luma_4x4 mode:Vertical_Right ,described in sec 8.3.1.2.6
    421  *
    422  * @param[in] pu1_src
    423  *  UWORD8 pointer to the source
    424  *
    425  * @param[out] pu1_dst
    426  *  UWORD8 pointer to the destination
    427  *
    428  * @param[in] src_strd
    429  *  integer source stride
    430  *
    431  * @param[in] dst_strd
    432  *  integer destination stride
    433  *
    434  * @param[in] ngbr_avail
    435  * availability of neighbouring pixels(Not used in this function)
    436  *
    437  * @returns
    438  *
    439  * @remarks
    440  *  None
    441  *
    442  *******************************************************************************/
    443 void ih264_intra_pred_luma_4x4_mode_vert_r(UWORD8 *pu1_src,
    444                                            UWORD8 *pu1_dst,
    445                                            WORD32 src_strd,
    446                                            WORD32 dst_strd,
    447                                            WORD32 ngbr_avail)
    448 {
    449 
    450     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_i, ui4_j, ui4_k, ui4_m;
    451     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    452     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    453     UWORD8 *pu1_topleft = NULL;/* Pointer to top left predictor */
    454     UWORD8 predicted_pixels[10];
    455     UNUSED(src_strd);
    456     UNUSED(ngbr_avail);
    457     pu1_top = pu1_src +BLK_SIZE + 1;
    458     pu1_left = pu1_src + BLK_SIZE - 1;
    459     pu1_topleft = pu1_src + BLK_SIZE;
    460 
    461     ui4_a = *pu1_top++;
    462     ui4_b = *pu1_top++;
    463     ui4_c = *pu1_top++;
    464     ui4_d = *pu1_top++;
    465     ui4_i = *pu1_left--;
    466     ui4_j = *pu1_left--;
    467     ui4_k = *pu1_left;
    468     ui4_m = *pu1_topleft;
    469 
    470     predicted_pixels[6] = FILT11(ui4_m, ui4_a);
    471     predicted_pixels[7] = FILT11(ui4_a, ui4_b);
    472     predicted_pixels[8] = FILT11(ui4_b, ui4_c);
    473     predicted_pixels[9] = FILT11(ui4_c, ui4_d);
    474     predicted_pixels[1] = FILT121(ui4_i, ui4_m, ui4_a);
    475     predicted_pixels[2] = FILT121(ui4_m, ui4_a, ui4_b);
    476     predicted_pixels[3] = FILT121(ui4_a, ui4_b, ui4_c);
    477     predicted_pixels[4] = FILT121(ui4_b, ui4_c, ui4_d);
    478     predicted_pixels[5] = FILT121(ui4_j, ui4_i, ui4_m);
    479     predicted_pixels[0] = FILT121(ui4_k, ui4_j, ui4_i);
    480 
    481     memcpy(pu1_dst, predicted_pixels + 6, 4);
    482     memcpy(pu1_dst + dst_strd, predicted_pixels + 1, 4);
    483     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 5, 4);
    484     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels, 4);
    485 }
    486 
    487 /*
    488  *******************************************************************************
    489  *
    490  *ih264_intra_pred_luma_4x4_mode_horz_d
    491  *
    492  * @brief
    493  *     Perform Intra prediction for  luma_4x4 mode:Horizontal_Down
    494  *
    495  * @par Description:
    496  *    Perform Intra prediction for  luma_4x4 mode:Horizontal_Down ,described in sec 8.3.1.2.7
    497  *
    498  * @param[in] pu1_src
    499  *  UWORD8 pointer to the source
    500  *
    501  * @param[out] pu1_dst
    502  *  UWORD8 pointer to the destination
    503  *
    504  * @param[in] src_strd
    505  *  integer source stride
    506  *
    507  * @param[in] dst_strd
    508  *  integer destination stride
    509  *
    510  * @param[in] ngbr_avail
    511  * availability of neighbouring pixels(Not used in this function)
    512  *
    513  * @returns
    514  *
    515  * @remarks
    516  *  None
    517  *
    518  *******************************************************************************/
    519 void ih264_intra_pred_luma_4x4_mode_horz_d(UWORD8 *pu1_src,
    520                                            UWORD8 *pu1_dst,
    521                                            WORD32 src_strd,
    522                                            WORD32 dst_strd,
    523                                            WORD32 ngbr_avail)
    524 {
    525     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    526     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    527     UWORD8 *pu1_topleft = NULL;/* Pointer to top left predictor */
    528     UWORD32 ui4_a, ui4_b, ui4_c, ui4_i, ui4_j, ui4_k, ui4_l, ui4_m;
    529     UWORD8 predicted_pixels[10];
    530     UNUSED(src_strd);
    531     UNUSED(ngbr_avail);
    532     pu1_top = pu1_src + BLK_SIZE + 1;
    533     pu1_left = pu1_src + BLK_SIZE - 1;
    534     pu1_topleft = pu1_src + BLK_SIZE;
    535 
    536     ui4_a = *pu1_top++;
    537     ui4_b = *pu1_top++;
    538     ui4_c = *pu1_top++;
    539     ui4_i = *pu1_left--;
    540     ui4_j = *pu1_left--;
    541     ui4_k = *pu1_left--;
    542     ui4_l = *pu1_left--;
    543     ui4_m = *pu1_topleft;
    544 
    545     predicted_pixels[6] = FILT11(ui4_i, ui4_m);
    546     predicted_pixels[7] = FILT121(ui4_i, ui4_m, ui4_a);
    547     predicted_pixels[8] = FILT121(ui4_m, ui4_a, ui4_b);
    548     predicted_pixels[9] = FILT121(ui4_a, ui4_b, ui4_c);
    549     predicted_pixels[1] = FILT121(ui4_l, ui4_k, ui4_j);
    550     predicted_pixels[2] = FILT11(ui4_k, ui4_j);
    551     predicted_pixels[3] = FILT121(ui4_k, ui4_j, ui4_i);
    552     predicted_pixels[4] = FILT11(ui4_j, ui4_i);
    553     predicted_pixels[5] = FILT121(ui4_j, ui4_i, ui4_m);
    554     predicted_pixels[0] = FILT11(ui4_l, ui4_k);
    555 
    556     memcpy(pu1_dst, predicted_pixels + 6, 4);
    557     memcpy(pu1_dst + dst_strd, predicted_pixels + 4, 4);
    558     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 2, 4);
    559     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels, 4);
    560 }
    561 
    562 /**
    563  *******************************************************************************
    564  *
    565  *ih264_intra_pred_luma_4x4_mode_vert_l
    566  *
    567  * @brief
    568  *     Perform Intra prediction for  luma_4x4 mode:Vertical_Left
    569  *
    570  * @par Description:
    571  *    Perform Intra prediction for  luma_4x4 mode:Vertical_Left ,described in sec 8.3.1.2.8
    572  *
    573  * @param[in] pu1_src
    574  *  UWORD8 pointer to the source
    575  *
    576  * @param[out] pu1_dst
    577  *  UWORD8 pointer to the destination
    578  *
    579  * @param[in] src_strd
    580  *  integer source stride
    581  *
    582  * @param[in] dst_strd
    583  *  integer destination stride
    584  *
    585  * @param[in] ngbr_avail
    586  * availability of neighbouring pixels(Not used in this function)
    587  *
    588  * @returns
    589  *
    590  * @remarks
    591  *  None
    592  *
    593  *******************************************************************************/
    594 void ih264_intra_pred_luma_4x4_mode_vert_l(UWORD8 *pu1_src,
    595                                            UWORD8 *pu1_dst,
    596                                            WORD32 src_strd,
    597                                            WORD32 dst_strd,
    598                                            WORD32 ngbr_avail)
    599 {
    600     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    601     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g;
    602     UWORD8 predicted_pixels[10];
    603     UNUSED(src_strd);
    604     UNUSED(ngbr_avail);
    605     pu1_top = pu1_src + BLK_SIZE + 1;
    606 
    607     ui4_a = *pu1_top++;
    608     ui4_b = *pu1_top++;
    609     ui4_c = *pu1_top++;
    610     ui4_d = *pu1_top++;
    611     ui4_e = *pu1_top++;
    612     ui4_f = *pu1_top++;
    613     ui4_g = *pu1_top;
    614 
    615     predicted_pixels[5] = FILT11(ui4_a, ui4_b);
    616     predicted_pixels[6] = FILT11(ui4_b, ui4_c);
    617     predicted_pixels[7] = FILT11(ui4_c, ui4_d);
    618     predicted_pixels[8] = FILT11(ui4_d, ui4_e);
    619     predicted_pixels[0] = FILT121(ui4_a, ui4_b, ui4_c);
    620     predicted_pixels[1] = FILT121(ui4_b, ui4_c, ui4_d);
    621     predicted_pixels[2] = FILT121(ui4_c, ui4_d, ui4_e);
    622     predicted_pixels[3] = FILT121(ui4_d, ui4_e, ui4_f);
    623     predicted_pixels[9] = FILT11(ui4_e, ui4_f);
    624     predicted_pixels[4] = FILT121(ui4_e, ui4_f, ui4_g);
    625 
    626     memcpy(pu1_dst, predicted_pixels + 5, 4);
    627     memcpy(pu1_dst + dst_strd, predicted_pixels, 4);
    628     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 6, 4);
    629     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 1, 4);
    630 }
    631 
    632 /**
    633  *******************************************************************************
    634  *
    635  *ih264_intra_pred_luma_4x4_mode_horz_u
    636  *
    637  * @brief
    638  *     Perform Intra prediction for  luma_4x4 mode:Horizontal_Up
    639  *
    640  * @par Description:
    641  *    Perform Intra prediction for  luma_4x4 mode:Horizontal_Up ,described in sec 8.3.1.2.9
    642  *
    643  * @param[in] pu1_src
    644  *  UWORD8 pointer to the source
    645  *
    646  * @param[out] pu1_dst
    647  *  UWORD8 pointer to the destination
    648  *
    649  * @param[in] src_strd
    650  *  integer source stride
    651  *
    652  * @param[in] dst_strd
    653  *  integer destination stride
    654  *
    655  * @param[in] ngbr_avail
    656  * availability of neighbouring pixels(Not used in this function)
    657  *
    658  * @returns
    659  *
    660  * @remarks
    661  *  None
    662  *
    663  *******************************************************************************/
    664 void ih264_intra_pred_luma_4x4_mode_horz_u(UWORD8 *pu1_src,
    665                                            UWORD8 *pu1_dst,
    666                                            WORD32 src_strd,
    667                                            WORD32 dst_strd,
    668                                            WORD32 ngbr_avail)
    669 {
    670     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    671     UWORD32 ui4_i, ui4_j, ui4_k, ui4_l;
    672     UWORD8 predicted_pixels[10];
    673     UNUSED(src_strd);
    674     UNUSED(ngbr_avail);
    675     pu1_left = pu1_src + BLK_SIZE - 1;
    676 
    677     ui4_i = *pu1_left--;
    678     ui4_j = *pu1_left--;
    679     ui4_k = *pu1_left--;
    680     ui4_l = *pu1_left--;
    681 
    682     predicted_pixels[0] = FILT11(ui4_j, ui4_i);
    683     predicted_pixels[1] = FILT121(ui4_k, ui4_j, ui4_i);
    684     predicted_pixels[2] = FILT11(ui4_k, ui4_j);
    685     predicted_pixels[3] = FILT121(ui4_l, ui4_k, ui4_j);
    686     predicted_pixels[4] = FILT11(ui4_l, ui4_k);
    687     predicted_pixels[5] = FILT121(ui4_l, ui4_l, ui4_k);
    688     predicted_pixels[6] = ui4_l;
    689     predicted_pixels[7] = ui4_l;
    690     predicted_pixels[8] = ui4_l;
    691     predicted_pixels[9] = ui4_l;
    692 
    693     memcpy(pu1_dst, predicted_pixels, 4);
    694     memcpy(pu1_dst + dst_strd, predicted_pixels + 2, 4);
    695     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 4, 4);
    696     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 6, 4);
    697 }
    698 
    699 /*******************    8x8 Modes    *******************/
    700 
    701 /**
    702  *******************************************************************************
    703  *
    704  *ih264_intra_pred_luma_8x8_mode_ref_filtering
    705  *
    706  * @brief
    707  *     Reference sample filtering process for Intra_8x8 sample prediction
    708  *
    709  * @par Description:
    710  *    Perform Reference sample filtering process for Intra_8x8 sample prediction ,described in sec 8.3.2.2.1
    711  *
    712  * @param[in] pu1_src
    713  *  UWORD8 pointer to the source
    714  *
    715  * @param[out] pu1_dst
    716  *  UWORD8 pointer to the destination
    717  *
    718  * @param[in] src_strd
    719  *  integer source stride[Not Used]
    720  *
    721  * @param[in] dst_strd
    722  *  integer destination stride[Not Used]
    723  *
    724  * @param[in] ngbr_avail
    725  * availability of neighbouring pixels(Not used in this function)
    726  *
    727  * @returns
    728  *
    729  * @remarks
    730  *  None
    731  *
    732  *
    733  *******************************************************************************/
    734 void ih264_intra_pred_luma_8x8_mode_ref_filtering(UWORD8 *pu1_left,
    735                                                   UWORD8 *pu1_topleft,
    736                                                   UWORD8 *pu1_top,
    737                                                   UWORD8 *pu1_dst,
    738                                                   WORD32 left_strd,
    739                                                   WORD32 ngbr_avail)
    740 {
    741     WORD32 top_avail, left_avail, top_left_avail, top_right_avail;
    742 
    743     left_avail = BOOLEAN(ngbr_avail & LEFT_MB_AVAILABLE_MASK);
    744     top_avail = BOOLEAN(ngbr_avail & TOP_MB_AVAILABLE_MASK);
    745     top_left_avail = BOOLEAN(ngbr_avail & TOP_LEFT_MB_AVAILABLE_MASK);
    746     top_right_avail = BOOLEAN(ngbr_avail & TOP_RIGHT_MB_AVAILABLE_MASK);
    747 
    748     if(top_avail)
    749     {
    750         WORD32 i;
    751         UWORD32 u4_xm1;
    752 
    753         if(!top_right_avail)
    754         {
    755             memset(pu1_dst + 8 + 1 + 8, pu1_top[7], 8);
    756             top_right_avail = 1;
    757         }
    758         else
    759         {
    760             memcpy(pu1_dst + 8 + 1 + 8, pu1_top + 8, 8);
    761         }
    762 
    763         if(top_left_avail)
    764         {
    765             pu1_dst[8 + 1 + 0] = FILT121((*pu1_topleft), pu1_top[0],
    766                                          pu1_top[1]);
    767 
    768         }
    769         else
    770         {
    771             pu1_dst[8 + 1] = ((3 * pu1_top[0]) + pu1_top[1] + 2) >> 2;
    772         }
    773 
    774         for(i = 1; i <= 6; i++)
    775         {
    776             pu1_dst[8 + 1 + i] = FILT121(pu1_top[i - 1], pu1_top[i],
    777                                          pu1_top[i + 1]);
    778 
    779         }
    780         /* First byte of Top Right input is in pu1_dst[8 + 1 + 8]*/
    781         pu1_dst[8 + 1 + 7] = FILT121(pu1_top[6], pu1_top[7],
    782                                      pu1_dst[8 + 1 + 8]);
    783 
    784         /* filtered output and source in same buf, to prevent output(x - 1)
    785          being over written in process */
    786         u4_xm1 = pu1_top[7];
    787 
    788         for(i = 8; i <= 14; i++)
    789         {
    790             UWORD32 u4_x;
    791             u4_x = (u4_xm1 + (pu1_dst[8 + 1 + i] << 1) + pu1_dst[8 + 1 + i + 1]
    792                             + 2) >> 2;
    793             /* assigning u4_xm1 from the un-filtered values for the next iteration */
    794             u4_xm1 = pu1_dst[8 + 1 + i];
    795             pu1_dst[8 + 1 + i] = u4_x;
    796         }
    797 
    798         pu1_dst[8 + 1 + 15] = (u4_xm1 + (3 * pu1_dst[8 + 1 + 15]) + 2) >> 2;
    799 
    800     }
    801 
    802     /* pu1_topleft is overloaded. It is both: */
    803     /* a. A pointer for the top left pixel */
    804     /* b. An indicator of availability of top left. */
    805     /*    If it is null then top left not available */
    806     if(top_left_avail)
    807     {
    808         if((!top_avail) || (!left_avail))
    809         {
    810             if(top_avail)
    811                 pu1_dst[8] = (3 * pu1_topleft[0] + pu1_top[0] + 2) >> 2;
    812             else if(left_avail)
    813                 pu1_dst[8] = (3 * pu1_topleft[0] + pu1_left[0] + 2) >> 2;
    814         }
    815         else
    816         {
    817             pu1_dst[8] = FILT121(pu1_top[0], (*pu1_topleft), pu1_left[0]);
    818         }
    819     }
    820 
    821     if(left_avail)
    822     {
    823         UWORD32 idx;
    824         if(0 != pu1_topleft)
    825         {
    826             pu1_dst[7] = FILT121((*pu1_topleft), pu1_left[0],
    827                                  pu1_left[left_strd]);
    828         }
    829         else
    830         {
    831             pu1_dst[7] = ((3 * pu1_left[0]) + pu1_left[left_strd] + 2) >> 2;
    832         }
    833 
    834         for(idx = 1; idx <= 6; idx++)
    835         {
    836             pu1_dst[7 - idx] = FILT121(pu1_left[(idx - 1) * left_strd],
    837                                        pu1_left[idx * left_strd],
    838                                        pu1_left[(idx + 1) * left_strd]);
    839 
    840         }
    841         pu1_dst[0] = (pu1_left[6 * left_strd] + 3 * pu1_left[7 * left_strd] + 2)
    842                         >> 2;
    843 
    844     }
    845 }
    846 
    847 /**
    848  *******************************************************************************
    849  *
    850  *ih264_intra_pred_luma_8x8_mode_vert
    851  *
    852  * @brief
    853  *  Perform Intra prediction for  luma_8x8 mode:vertical
    854  *
    855  * @par Description:
    856  *  Perform Intra prediction for  luma_8x8 mode:vertical ,described in sec 8.3.2.2.2
    857  *
    858  * @param[in] pu1_src
    859  *  UWORD8 pointer to the source
    860  *
    861  * @param[out] pu1_dst
    862  *  UWORD8 pointer to the destination
    863  *
    864  * @param[in] src_strd
    865  *  integer source stride
    866  *
    867  * @param[in] dst_strd
    868  *  integer destination stride
    869  *
    870  * @param[in] ngbr_avail
    871  * availability of neighbouring pixels(Not used in this function)
    872  *
    873  * @returns
    874  *
    875  * @remarks
    876  *  None
    877  *
    878  *******************************************************************************
    879  */
    880 void ih264_intra_pred_luma_8x8_mode_vert(UWORD8 *pu1_src,
    881                                          UWORD8 *pu1_dst,
    882                                          WORD32 src_strd,
    883                                          WORD32 dst_strd,
    884                                          WORD32 ngbr_avail)
    885 {
    886     UWORD8 *pu1_top = NULL;
    887     UNUSED(src_strd);
    888     UNUSED(ngbr_avail);
    889     pu1_top = pu1_src + BLK8x8SIZE + 1;
    890 
    891     memcpy(pu1_dst, pu1_top, 8);
    892     memcpy(pu1_dst + dst_strd, pu1_top, 8);
    893     memcpy(pu1_dst + 2 * dst_strd, pu1_top, 8);
    894     memcpy(pu1_dst + 3 * dst_strd, pu1_top, 8);
    895     memcpy(pu1_dst + 4 * dst_strd, pu1_top, 8);
    896     memcpy(pu1_dst + 5 * dst_strd, pu1_top, 8);
    897     memcpy(pu1_dst + 6 * dst_strd, pu1_top, 8);
    898     memcpy(pu1_dst + 7 * dst_strd, pu1_top, 8);
    899 }
    900 
    901 /**
    902  *******************************************************************************
    903  *
    904  *ih264_intra_pred_luma_8x8_mode_horz
    905  *
    906  * @brief
    907  *  Perform Intra prediction for  luma_8x8 mode:horizontal
    908  *
    909  * @par Description:
    910  *  Perform Intra prediction for  luma_8x8 mode:horizontal ,described in sec 8.3.2.2.2
    911  *
    912  * @param[in] pu1_src
    913  *  UWORD8 pointer to the source
    914  *
    915  * @param[out] pu1_dst
    916  *  UWORD8 pointer to the destination
    917  *
    918  * @param[in] src_strd
    919  *  integer source stride
    920  *
    921  * @param[in] dst_strd
    922  *  integer destination stride
    923  *
    924  * @param[in] ngbr_avail
    925  * availability of neighbouring pixels(Not used in this function)
    926  *
    927  * @returns
    928  *
    929  * @remarks
    930  *  None
    931  *
    932  *******************************************************************************
    933  */
    934 
    935 void ih264_intra_pred_luma_8x8_mode_horz(UWORD8 *pu1_src,
    936                                          UWORD8 *pu1_dst,
    937                                          WORD32 src_strd,
    938                                          WORD32 dst_strd,
    939                                          WORD32 ngbr_avail)
    940 {
    941     UWORD8 *pu1_left = pu1_src + BLK8x8SIZE - 1;
    942     UNUSED(src_strd);
    943     UNUSED(ngbr_avail);
    944     memset(pu1_dst, *pu1_left, 8);
    945     memset(pu1_dst + dst_strd, *(pu1_left - 1), 8);
    946     memset(pu1_dst + 2 * dst_strd, *(pu1_left - 2), 8);
    947     memset(pu1_dst + 3 * dst_strd, *(pu1_left - 3), 8);
    948     memset(pu1_dst + 4 * dst_strd, *(pu1_left - 4), 8);
    949     memset(pu1_dst + 5 * dst_strd, *(pu1_left - 5), 8);
    950     memset(pu1_dst + 6 * dst_strd, *(pu1_left - 6), 8);
    951     memset(pu1_dst + 7 * dst_strd, *(pu1_left - 7), 8);
    952 }
    953 
    954 /**
    955  *******************************************************************************
    956  *
    957  *ih264_intra_pred_luma_8x8_mode_dc
    958  *
    959  * @brief
    960  *     Perform Intra prediction for  luma_8x8 mode:DC
    961  *
    962  * @par Description:
    963  *    Perform Intra prediction for  luma_8x8 mode:DC ,described in sec 8.3.2.2.4
    964  *
    965  * @param[in] pu1_src
    966  *  UWORD8 pointer to the source
    967  *
    968  * @param[out] pu1_dst
    969  *  UWORD8 pointer to the destination
    970  *
    971  * @param[in] src_strd
    972  *  integer source stride
    973  *
    974  * @param[in] dst_strd
    975  *  integer destination stride
    976  *
    977  * @param[in] ngbr_avail
    978  *  availability of neighbouring pixels
    979  *
    980  * @returns
    981  *
    982  * @remarks
    983  *  None
    984  *
    985  *******************************************************************************/
    986 void ih264_intra_pred_luma_8x8_mode_dc(UWORD8 *pu1_src,
    987                                        UWORD8 *pu1_dst,
    988                                        WORD32 src_strd,
    989                                        WORD32 dst_strd,
    990                                        WORD32 ngbr_avail)
    991 {
    992     UWORD8 u1_useleft; /* availability of left predictors (only for DC) */
    993     UWORD8 u1_usetop; /* availability of top predictors (only for DC) */
    994     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
    995     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
    996     WORD32 row;
    997     WORD32 val = 0;
    998     UNUSED(src_strd);
    999 
   1000     u1_useleft = BOOLEAN(ngbr_avail & LEFT_MB_AVAILABLE_MASK);
   1001     u1_usetop = BOOLEAN(ngbr_avail & TOP_MB_AVAILABLE_MASK);
   1002     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1003     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1004 
   1005     if(u1_useleft)
   1006     {
   1007         for(row = 0; row < BLK8x8SIZE; row++)
   1008             val += *(pu1_left - row);
   1009         val += 4;
   1010     }
   1011     if(u1_usetop)
   1012     {
   1013         for(row = 0; row < BLK8x8SIZE; row++)
   1014             val += *(pu1_top + row);
   1015         val += 4;
   1016     }
   1017 
   1018     /* Since 4 is added if either left/top pred is there,
   1019      val still being zero implies both preds are not there */
   1020     val = (val) ? (val >> (2 + u1_useleft + u1_usetop)) : 128;
   1021 
   1022     memset(pu1_dst, val, 8);
   1023     memset(pu1_dst + dst_strd, val, 8);
   1024     memset(pu1_dst + 2 * dst_strd, val, 8);
   1025     memset(pu1_dst + 3 * dst_strd, val, 8);
   1026     memset(pu1_dst + 4 * dst_strd, val, 8);
   1027     memset(pu1_dst + 5 * dst_strd, val, 8);
   1028     memset(pu1_dst + 6 * dst_strd, val, 8);
   1029     memset(pu1_dst + 7 * dst_strd, val, 8);
   1030 }
   1031 
   1032 /**
   1033  *******************************************************************************
   1034  *
   1035  *ih264_intra_pred_luma_8x8_mode_diag_dl
   1036  *
   1037  * @brief
   1038  *     Perform Intra prediction for  luma_8x8 mode:Diagonal_Down_Left
   1039  *
   1040  * @par Description:
   1041  *    Perform Intra prediction for  luma_8x8 mode:Diagonal_Down_Left ,described in sec 8.3.2.2.5
   1042  *
   1043  * @param[in] pu1_src
   1044  *  UWORD8 pointer to the source
   1045  *
   1046  * @param[out] pu1_dst
   1047  *  UWORD8 pointer to the destination
   1048  *
   1049  * @param[in] src_strd
   1050  *  integer source stride
   1051  *
   1052  * @param[in] dst_strd
   1053  *  integer destination stride
   1054  *
   1055  * @param[in] ngbr_avail
   1056  * availability of neighbouring pixels(Not used in this function)
   1057  *
   1058  * @returns
   1059  *
   1060  * @remarks
   1061  *  None
   1062  *
   1063  *******************************************************************************/
   1064 void ih264_intra_pred_luma_8x8_mode_diag_dl(UWORD8 *pu1_src,
   1065                                             UWORD8 *pu1_dst,
   1066                                             WORD32 src_strd,
   1067                                             WORD32 dst_strd,
   1068                                             WORD32 ngbr_avail)
   1069 {
   1070     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1071     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h;
   1072     UWORD32 ui4_i, ui4_j, ui4_k, ui4_l, ui4_m, ui4_n, ui4_o, ui4_p;
   1073     UWORD8 predicted_pixels[15];
   1074     UNUSED(src_strd);
   1075     UNUSED(ngbr_avail);
   1076     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1077 
   1078     ui4_a = *pu1_top++;
   1079     ui4_b = *pu1_top++;
   1080     ui4_c = *pu1_top++;
   1081     ui4_d = *pu1_top++;
   1082     ui4_e = *pu1_top++;
   1083     ui4_f = *pu1_top++;
   1084     ui4_g = *pu1_top++;
   1085     ui4_h = *pu1_top++;
   1086     ui4_i = *pu1_top++;
   1087     ui4_j = *pu1_top++;
   1088     ui4_k = *pu1_top++;
   1089     ui4_l = *pu1_top++;
   1090     ui4_m = *pu1_top++;
   1091     ui4_n = *pu1_top++;
   1092     ui4_o = *pu1_top++;
   1093     ui4_p = *pu1_top;
   1094 
   1095     predicted_pixels[0] = FILT121(ui4_a, ui4_b, ui4_c);
   1096     predicted_pixels[1] = FILT121(ui4_b, ui4_c, ui4_d);
   1097     predicted_pixels[2] = FILT121(ui4_c, ui4_d, ui4_e);
   1098     predicted_pixels[3] = FILT121(ui4_d, ui4_e, ui4_f);
   1099     predicted_pixels[4] = FILT121(ui4_e, ui4_f, ui4_g);
   1100     predicted_pixels[5] = FILT121(ui4_f, ui4_g, ui4_h);
   1101     predicted_pixels[6] = FILT121(ui4_g, ui4_h, ui4_i);
   1102     predicted_pixels[7] = FILT121(ui4_h, ui4_i, ui4_j);
   1103     predicted_pixels[8] = FILT121(ui4_i, ui4_j, ui4_k);
   1104     predicted_pixels[9] = FILT121(ui4_j, ui4_k, ui4_l);
   1105     predicted_pixels[10] = FILT121(ui4_k, ui4_l, ui4_m);
   1106     predicted_pixels[11] = FILT121(ui4_l, ui4_m, ui4_n);
   1107     predicted_pixels[12] = FILT121(ui4_m, ui4_n, ui4_o);
   1108     predicted_pixels[13] = FILT121(ui4_n, ui4_o, ui4_p);
   1109     predicted_pixels[14] = FILT121(ui4_o, ui4_p, ui4_p);
   1110 
   1111     memcpy(pu1_dst, predicted_pixels, 8);
   1112     memcpy(pu1_dst + dst_strd, predicted_pixels + 1, 8);
   1113     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 2, 8);
   1114     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 3, 8);
   1115     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 4, 8);
   1116     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 5, 8);
   1117     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels + 6, 8);
   1118     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels + 7, 8);
   1119 }
   1120 
   1121 /**
   1122  *******************************************************************************
   1123  *
   1124  *ih264_intra_pred_luma_8x8_mode_diag_dr
   1125  *
   1126  * @brief
   1127  *     Perform Intra prediction for  luma_8x8 mode:Diagonal_Down_Right
   1128  *
   1129  * @par Description:
   1130  *    Perform Intra prediction for  luma_8x8 mode:Diagonal_Down_Right ,described in sec 8.3.2.2.6
   1131  *
   1132  * @param[in] pu1_src
   1133  *  UWORD8 pointer to the source
   1134  *
   1135  * @param[out] pu1_dst
   1136  *  UWORD8 pointer to the destination
   1137  *
   1138  * @param[in] src_strd
   1139  *  integer source stride
   1140  *
   1141  * @param[in] dst_strd
   1142  *  integer destination stride
   1143  *
   1144  * @param[in] ngbr_avail
   1145  * availability of neighbouring pixels(Not used in this function)
   1146  *
   1147  * @returns
   1148  *
   1149  * @remarks
   1150  *  None
   1151  *
   1152  *******************************************************************************/
   1153 void ih264_intra_pred_luma_8x8_mode_diag_dr(UWORD8 *pu1_src,
   1154                                             UWORD8 *pu1_dst,
   1155                                             WORD32 src_strd,
   1156                                             WORD32 dst_strd,
   1157                                             WORD32 ngbr_avail)
   1158 {
   1159     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1160     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1161     UWORD8 *pu1_topleft = NULL; /* Pointer to start of top left predictors */
   1162     UWORD32 ui4_a;
   1163     UWORD32 ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h, ui4_i;
   1164     UWORD32 ui4_j, ui4_k, ui4_l, ui4_m, ui4_n, ui4_o, ui4_p, ui4_q;
   1165     UWORD8 predicted_pixels[15];
   1166     UNUSED(src_strd);
   1167     UNUSED(ngbr_avail);
   1168     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1169     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1170     pu1_topleft = pu1_src + BLK8x8SIZE;
   1171 
   1172     ui4_a = *pu1_topleft;
   1173     ui4_b = *pu1_top++;
   1174     ui4_c = *pu1_top++;
   1175     ui4_d = *pu1_top++;
   1176     ui4_e = *pu1_top++;
   1177     ui4_f = *pu1_top++;
   1178     ui4_g = *pu1_top++;
   1179     ui4_h = *pu1_top++;
   1180     ui4_i = *pu1_top;
   1181     ui4_j = *pu1_left--;
   1182     ui4_k = *pu1_left--;
   1183     ui4_l = *pu1_left--;
   1184     ui4_m = *pu1_left--;
   1185     ui4_n = *pu1_left--;
   1186     ui4_o = *pu1_left--;
   1187     ui4_p = *pu1_left--;
   1188     ui4_q = *pu1_left;
   1189 
   1190     predicted_pixels[6] = FILT121(ui4_a, ui4_j, ui4_k);
   1191     predicted_pixels[5] = FILT121(ui4_j, ui4_k, ui4_l);
   1192     predicted_pixels[4] = FILT121(ui4_k, ui4_l, ui4_m);
   1193     predicted_pixels[3] = FILT121(ui4_l, ui4_m, ui4_n);
   1194     predicted_pixels[2] = FILT121(ui4_m, ui4_n, ui4_o);
   1195     predicted_pixels[1] = FILT121(ui4_n, ui4_o, ui4_p);
   1196     predicted_pixels[0] = FILT121(ui4_o, ui4_p, ui4_q);
   1197     predicted_pixels[7] = FILT121(ui4_b, ui4_a, ui4_j);
   1198     predicted_pixels[8] = FILT121(ui4_a, ui4_b, ui4_c);
   1199     predicted_pixels[9] = FILT121(ui4_b, ui4_c, ui4_d);
   1200     predicted_pixels[10] = FILT121(ui4_c, ui4_d, ui4_e);
   1201     predicted_pixels[11] = FILT121(ui4_d, ui4_e, ui4_f);
   1202     predicted_pixels[12] = FILT121(ui4_e, ui4_f, ui4_g);
   1203     predicted_pixels[13] = FILT121(ui4_f, ui4_g, ui4_h);
   1204     predicted_pixels[14] = FILT121(ui4_g, ui4_h, ui4_i);
   1205 
   1206     memcpy(pu1_dst, predicted_pixels + 7, 8);
   1207     memcpy(pu1_dst + dst_strd, predicted_pixels + 6, 8);
   1208     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 5, 8);
   1209     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 4, 8);
   1210     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 3, 8);
   1211     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 2, 8);
   1212     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels + 1, 8);
   1213     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels, 8);
   1214 }
   1215 
   1216 /**
   1217  *******************************************************************************
   1218  *
   1219  *ih264_intra_pred_luma_8x8_mode_vert_r
   1220  *
   1221  * @brief
   1222  *     Perform Intra prediction for  luma_8x8 mode:Vertical_Right
   1223  *
   1224  * @par Description:
   1225  *    Perform Intra prediction for  luma_8x8 mode:Vertical_Right ,described in sec 8.3.2.2.7
   1226  *
   1227  * @param[in] pu1_src
   1228  *  UWORD8 pointer to the source
   1229  *
   1230  * @param[out] pu1_dst
   1231  *  UWORD8 pointer to the destination
   1232  *
   1233  * @param[in] src_strd
   1234  *  integer source stride
   1235  *
   1236  * @param[in] dst_strd
   1237  *  integer destination stride
   1238  *
   1239  * @param[in] ngbr_avail
   1240  * availability of neighbouring pixels(Not used in this function)
   1241  *
   1242  * @returns
   1243  *
   1244  * @remarks
   1245  *  None
   1246  *
   1247  *******************************************************************************/
   1248 void ih264_intra_pred_luma_8x8_mode_vert_r(UWORD8 *pu1_src,
   1249                                            UWORD8 *pu1_dst,
   1250                                            WORD32 src_strd,
   1251                                            WORD32 dst_strd,
   1252                                            WORD32 ngbr_avail)
   1253 {
   1254     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1255     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1256     UWORD8 *pu1_topleft = NULL; /* Pointer to start of top left predictors */
   1257     UWORD32 ui4_a;
   1258     UWORD32 ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h, ui4_i;
   1259     UWORD32 ui4_j, ui4_k, ui4_l, ui4_m, ui4_n, ui4_o, ui4_p;
   1260     UWORD8 predicted_pixels[22];
   1261 
   1262     UNUSED(src_strd);
   1263     UNUSED(ngbr_avail);
   1264     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1265     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1266     pu1_topleft = pu1_src + BLK8x8SIZE;
   1267 
   1268     ui4_a = *pu1_topleft;
   1269 
   1270     ui4_b = *pu1_top++;
   1271     ui4_c = *pu1_top++;
   1272     ui4_d = *pu1_top++;
   1273     ui4_e = *pu1_top++;
   1274     ui4_f = *pu1_top++;
   1275     ui4_g = *pu1_top++;
   1276     ui4_h = *pu1_top++;
   1277     ui4_i = *pu1_top;
   1278     ui4_j = *pu1_left--;
   1279     ui4_k = *pu1_left--;
   1280     ui4_l = *pu1_left--;
   1281     ui4_m = *pu1_left--;
   1282     ui4_n = *pu1_left--;
   1283     ui4_o = *pu1_left--;
   1284     ui4_p = *pu1_left--;
   1285 
   1286     predicted_pixels[0] = FILT121(ui4_o, ui4_n, ui4_m);
   1287     predicted_pixels[1] = FILT121(ui4_m, ui4_l, ui4_k);
   1288     predicted_pixels[2] = FILT121(ui4_k, ui4_j, ui4_a);
   1289     predicted_pixels[3] = FILT11(ui4_a, ui4_b);
   1290     predicted_pixels[4] = FILT11(ui4_b, ui4_c);
   1291     predicted_pixels[5] = FILT11(ui4_c, ui4_d);
   1292     predicted_pixels[6] = FILT11(ui4_d, ui4_e);
   1293     predicted_pixels[7] = FILT11(ui4_e, ui4_f);
   1294     predicted_pixels[8] = FILT11(ui4_f, ui4_g);
   1295     predicted_pixels[9] = FILT11(ui4_g, ui4_h);
   1296     predicted_pixels[10] = FILT11(ui4_h, ui4_i);
   1297     predicted_pixels[11] = FILT121(ui4_p, ui4_o, ui4_n);
   1298     predicted_pixels[12] = FILT121(ui4_n, ui4_m, ui4_l);
   1299     predicted_pixels[13] = FILT121(ui4_l, ui4_k, ui4_j);
   1300     predicted_pixels[14] = FILT121(ui4_b, ui4_a, ui4_j);
   1301     predicted_pixels[15] = FILT121(ui4_a, ui4_b, ui4_c);
   1302     predicted_pixels[16] = FILT121(ui4_b, ui4_c, ui4_d);
   1303     predicted_pixels[17] = FILT121(ui4_c, ui4_d, ui4_e);
   1304     predicted_pixels[18] = FILT121(ui4_d, ui4_e, ui4_f);
   1305     predicted_pixels[19] = FILT121(ui4_e, ui4_f, ui4_g);
   1306     predicted_pixels[20] = FILT121(ui4_f, ui4_g, ui4_h);
   1307     predicted_pixels[21] = FILT121(ui4_g, ui4_h, ui4_i);
   1308 
   1309     memcpy(pu1_dst, predicted_pixels + 3, 8);
   1310     memcpy(pu1_dst + 1 * dst_strd, predicted_pixels + 14, 8);
   1311     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 2, 8);
   1312     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 13, 8);
   1313     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 1, 8);
   1314     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 12, 8);
   1315     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels, 8);
   1316     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels + 11, 8);
   1317 
   1318 }
   1319 
   1320 /*
   1321  *******************************************************************************
   1322  *
   1323  *ih264_intra_pred_luma_8x8_mode_horz_d
   1324  *
   1325  * @brief
   1326  *     Perform Intra prediction for  luma_8x8 mode:Horizontal_Down
   1327  *
   1328  * @par Description:
   1329  *    Perform Intra prediction for  luma_8x8 mode:Horizontal_Down ,described in sec 8.3.2.2.8
   1330  *
   1331  * @param[in] pu1_src
   1332  *  UWORD8 pointer to the source
   1333  *
   1334  * @param[out] pu1_dst
   1335  *  UWORD8 pointer to the destination
   1336  *
   1337  * @param[in] src_strd
   1338  *  integer source stride
   1339  *
   1340  * @param[in] dst_strd
   1341  *  integer destination stride
   1342  *
   1343  * @param[in] ngbr_avail
   1344  * availability of neighbouring pixels(Not used in this function)
   1345  *
   1346  * @returns
   1347  *
   1348  * @remarks
   1349  *  None
   1350  *
   1351  *******************************************************************************/
   1352 
   1353 void ih264_intra_pred_luma_8x8_mode_horz_d(UWORD8 *pu1_src,
   1354                                            UWORD8 *pu1_dst,
   1355                                            WORD32 src_strd,
   1356                                            WORD32 dst_strd,
   1357                                            WORD32 ngbr_avail)
   1358 {
   1359     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1360     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1361     UWORD8 *pu1_topleft = NULL; /* Pointer to start of top left predictors */
   1362     UWORD32 ui4_a;
   1363     UWORD32 ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h, ui4_i;
   1364     UWORD32 ui4_j, ui4_k, ui4_l, ui4_m, ui4_n, ui4_o, ui4_p;
   1365     UWORD8 predicted_pixels[22];
   1366     UNUSED(src_strd);
   1367     UNUSED(ngbr_avail);
   1368     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1369     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1370     pu1_topleft = pu1_src + BLK8x8SIZE;
   1371 
   1372     ui4_a = *pu1_topleft;
   1373     ui4_j = *pu1_top++;
   1374     ui4_k = *pu1_top++;
   1375     ui4_l = *pu1_top++;
   1376     ui4_m = *pu1_top++;
   1377     ui4_n = *pu1_top++;
   1378     ui4_o = *pu1_top++;
   1379     ui4_p = *pu1_top++;
   1380     ui4_b = *pu1_left--;
   1381     ui4_c = *pu1_left--;
   1382     ui4_d = *pu1_left--;
   1383     ui4_e = *pu1_left--;
   1384     ui4_f = *pu1_left--;
   1385     ui4_g = *pu1_left--;
   1386     ui4_h = *pu1_left--;
   1387     ui4_i = *pu1_left;
   1388 
   1389     predicted_pixels[0] = FILT11(ui4_h, ui4_i);
   1390     predicted_pixels[1] = FILT121(ui4_g, ui4_h, ui4_i);
   1391     predicted_pixels[2] = FILT11(ui4_g, ui4_h);
   1392     predicted_pixels[3] = FILT121(ui4_f, ui4_g, ui4_h);
   1393     predicted_pixels[4] = FILT11(ui4_f, ui4_g);
   1394     predicted_pixels[5] = FILT121(ui4_e, ui4_f, ui4_g);
   1395     predicted_pixels[6] = FILT11(ui4_e, ui4_f);
   1396     predicted_pixels[7] = FILT121(ui4_d, ui4_e, ui4_f);
   1397     predicted_pixels[8] = FILT11(ui4_d, ui4_e);
   1398     predicted_pixels[9] = FILT121(ui4_c, ui4_d, ui4_e);
   1399     predicted_pixels[10] = FILT11(ui4_c, ui4_d);
   1400     predicted_pixels[11] = FILT121(ui4_b, ui4_c, ui4_d);
   1401     predicted_pixels[12] = FILT11(ui4_b, ui4_c);
   1402     predicted_pixels[13] = FILT121(ui4_a, ui4_b, ui4_c);
   1403     predicted_pixels[14] = FILT11(ui4_a, ui4_b);
   1404     predicted_pixels[15] = FILT121(ui4_j, ui4_a, ui4_b);
   1405     predicted_pixels[16] = FILT121(ui4_k, ui4_j, ui4_a);
   1406     predicted_pixels[17] = FILT121(ui4_l, ui4_k, ui4_j);
   1407     predicted_pixels[18] = FILT121(ui4_m, ui4_l, ui4_k);
   1408     predicted_pixels[19] = FILT121(ui4_n, ui4_m, ui4_l);
   1409     predicted_pixels[20] = FILT121(ui4_o, ui4_n, ui4_m);
   1410     predicted_pixels[21] = FILT121(ui4_p, ui4_o, ui4_n);
   1411 
   1412     memcpy(pu1_dst, predicted_pixels + 14, 8);
   1413     memcpy(pu1_dst + dst_strd, predicted_pixels + 12, 8);
   1414     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 10, 8);
   1415     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 8, 8);
   1416     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 6, 8);
   1417     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 4, 8);
   1418     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels + 2, 8);
   1419     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels, 8);
   1420 }
   1421 
   1422 /**
   1423  *******************************************************************************
   1424  *
   1425  *ih264_intra_pred_luma_8x8_mode_vert_l
   1426  *
   1427  * @brief
   1428  *     Perform Intra prediction for  luma_8x8 mode:Vertical_Left
   1429  *
   1430  * @par Description:
   1431  *    Perform Intra prediction for  luma_8x8 mode:Vertical_Left ,described in sec 8.3.2.2.9
   1432  *
   1433  * @param[in] pu1_src
   1434  *  UWORD8 pointer to the source
   1435  *
   1436  * @param[out] pu1_dst
   1437  *  UWORD8 pointer to the destination
   1438  *
   1439  * @param[in] src_strd
   1440  *  integer source stride
   1441  *
   1442  * @param[in] dst_strd
   1443  *  integer destination stride
   1444  *
   1445  * @param[in] ngbr_avail
   1446  * availability of neighbouring pixels(Not used in this function)
   1447  *
   1448  * @returns
   1449  *
   1450  * @remarks
   1451  *  None
   1452  *
   1453  *******************************************************************************/
   1454 
   1455 void ih264_intra_pred_luma_8x8_mode_vert_l(UWORD8 *pu1_src,
   1456                                            UWORD8 *pu1_dst,
   1457                                            WORD32 src_strd,
   1458                                            WORD32 dst_strd,
   1459                                            WORD32 ngbr_avail)
   1460 {
   1461     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1462     UWORD32 ui4_a, ui4_b, ui4_c, ui4_d, ui4_e, ui4_f, ui4_g, ui4_h;
   1463     UWORD32 ui4_i, ui4_j, ui4_k, ui4_l, ui4_m;
   1464     UWORD8 predicted_pixels[22];
   1465     UNUSED(src_strd);
   1466     UNUSED(ngbr_avail);
   1467     pu1_top = pu1_src + BLK8x8SIZE + 1;
   1468 
   1469     ui4_a = *pu1_top++;
   1470     ui4_b = *pu1_top++;
   1471     ui4_c = *pu1_top++;
   1472     ui4_d = *pu1_top++;
   1473     ui4_e = *pu1_top++;
   1474     ui4_f = *pu1_top++;
   1475     ui4_g = *pu1_top++;
   1476     ui4_h = *pu1_top++;
   1477     ui4_i = *pu1_top++;
   1478     ui4_j = *pu1_top++;
   1479     ui4_k = *pu1_top++;
   1480     ui4_l = *pu1_top++;
   1481     ui4_m = *pu1_top++;
   1482 
   1483     predicted_pixels[0] = FILT11(ui4_a, ui4_b);
   1484     predicted_pixels[1] = FILT11(ui4_b, ui4_c);
   1485     predicted_pixels[2] = FILT11(ui4_c, ui4_d);
   1486     predicted_pixels[3] = FILT11(ui4_d, ui4_e);
   1487     predicted_pixels[4] = FILT11(ui4_e, ui4_f);
   1488     predicted_pixels[5] = FILT11(ui4_f, ui4_g);
   1489     predicted_pixels[6] = FILT11(ui4_g, ui4_h);
   1490     predicted_pixels[7] = FILT11(ui4_h, ui4_i);
   1491     predicted_pixels[8] = FILT11(ui4_i, ui4_j);
   1492     predicted_pixels[9] = FILT11(ui4_j, ui4_k);
   1493     predicted_pixels[10] = FILT11(ui4_k, ui4_l);
   1494     predicted_pixels[11] = FILT121(ui4_a, ui4_b, ui4_c);
   1495     predicted_pixels[12] = FILT121(ui4_b, ui4_c, ui4_d);
   1496     predicted_pixels[13] = FILT121(ui4_c, ui4_d, ui4_e);
   1497     predicted_pixels[14] = FILT121(ui4_d, ui4_e, ui4_f);
   1498     predicted_pixels[15] = FILT121(ui4_e, ui4_f, ui4_g);
   1499     predicted_pixels[16] = FILT121(ui4_f, ui4_g, ui4_h);
   1500     predicted_pixels[17] = FILT121(ui4_g, ui4_h, ui4_i);
   1501     predicted_pixels[18] = FILT121(ui4_h, ui4_i, ui4_j);
   1502     predicted_pixels[19] = FILT121(ui4_i, ui4_j, ui4_k);
   1503     predicted_pixels[20] = FILT121(ui4_j, ui4_k, ui4_l);
   1504     predicted_pixels[21] = FILT121(ui4_k, ui4_l, ui4_m);
   1505 
   1506     memcpy(pu1_dst, predicted_pixels, 8);
   1507     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 1, 8);
   1508     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 2, 8);
   1509     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels + 3, 8);
   1510     memcpy(pu1_dst + 1 * dst_strd, predicted_pixels + 11, 8);
   1511     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 12, 8);
   1512     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 13, 8);
   1513     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels + 14, 8);
   1514 }
   1515 
   1516 /**
   1517  *******************************************************************************
   1518  *
   1519  *ih264_intra_pred_luma_8x8_mode_horz_u
   1520  *
   1521  * @brief
   1522  *     Perform Intra prediction for  luma_8x8 mode:Horizontal_Up
   1523  *
   1524  * @par Description:
   1525  *    Perform Intra prediction for  luma_8x8 mode:Horizontal_Up ,described in sec 8.3.2.2.10
   1526  *
   1527  * @param[in] pu1_src
   1528  *  UWORD8 pointer to the source
   1529  *
   1530  * @param[out] pu1_dst
   1531  *  UWORD8 pointer to the destination
   1532  *
   1533  * @param[in] src_strd
   1534  *  integer source stride
   1535  *
   1536  * @param[in] dst_strd
   1537  *  integer destination stride
   1538  *
   1539  * @param[in] ngbr_avail
   1540  * availability of neighbouring pixels(Not used in this function)
   1541  *
   1542  * @returns
   1543  *
   1544  * @remarks
   1545  *  None
   1546  *
   1547  *******************************************************************************/
   1548 
   1549 void ih264_intra_pred_luma_8x8_mode_horz_u(UWORD8 *pu1_src,
   1550                                            UWORD8 *pu1_dst,
   1551                                            WORD32 src_strd,
   1552                                            WORD32 dst_strd,
   1553                                            WORD32 ngbr_avail)
   1554 
   1555 {
   1556     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1557     UWORD32 ui4_j, ui4_k, ui4_l, ui4_m, ui4_n, ui4_o, ui4_p, ui4_q;
   1558     UWORD8 predicted_pixels[22];
   1559     UNUSED(src_strd);
   1560     UNUSED(ngbr_avail);
   1561     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1562 
   1563     ui4_j = *pu1_left--;
   1564     ui4_k = *pu1_left--;
   1565     ui4_l = *pu1_left--;
   1566     ui4_m = *pu1_left--;
   1567     ui4_n = *pu1_left--;
   1568     ui4_o = *pu1_left--;
   1569     ui4_p = *pu1_left--;
   1570     ui4_q = *pu1_left;
   1571 
   1572     pu1_left = pu1_src + BLK8x8SIZE - 1;
   1573 
   1574     predicted_pixels[0] = FILT11(ui4_j, ui4_k);
   1575     predicted_pixels[1] = FILT121(ui4_j, ui4_k, ui4_l);
   1576     predicted_pixels[2] = FILT11(ui4_k, ui4_l);
   1577     predicted_pixels[3] = FILT121(ui4_k, ui4_l, ui4_m);
   1578     predicted_pixels[4] = FILT11(ui4_l, ui4_m);
   1579     predicted_pixels[5] = FILT121(ui4_l, ui4_m, ui4_n);
   1580     predicted_pixels[6] = FILT11(ui4_m, ui4_n);
   1581     predicted_pixels[7] = FILT121(ui4_m, ui4_n, ui4_o);
   1582     predicted_pixels[8] = FILT11(ui4_n, ui4_o);
   1583     predicted_pixels[9] = FILT121(ui4_n, ui4_o, ui4_p);
   1584     predicted_pixels[10] = FILT11(ui4_o, ui4_p);
   1585     predicted_pixels[11] = FILT121(ui4_o, ui4_p, ui4_q);
   1586     predicted_pixels[12] = FILT11(ui4_p, ui4_q);
   1587     predicted_pixels[13] = FILT121(ui4_p, ui4_q, ui4_q);
   1588     memset(predicted_pixels+14,ui4_q,8);
   1589 
   1590     memcpy(pu1_dst, predicted_pixels, 8);
   1591     memcpy(pu1_dst + 1 * dst_strd, predicted_pixels + 2, 8);
   1592     memcpy(pu1_dst + 2 * dst_strd, predicted_pixels + 4, 8);
   1593     memcpy(pu1_dst + 3 * dst_strd, predicted_pixels + 6, 8);
   1594     memcpy(pu1_dst + 4 * dst_strd, predicted_pixels + 8, 8);
   1595     memcpy(pu1_dst + 5 * dst_strd, predicted_pixels + 10, 8);
   1596     memcpy(pu1_dst + 6 * dst_strd, predicted_pixels + 12, 8);
   1597     memcpy(pu1_dst + 7 * dst_strd, predicted_pixels + 14, 8);
   1598 }
   1599 
   1600 
   1601 /*******************    16x16 Modes    *******************/
   1602 
   1603 /**
   1604  *******************************************************************************
   1605  *
   1606  *ih264_intra_pred_luma_16x16_mode_vert
   1607  *
   1608  * @brief
   1609  *  Perform Intra prediction for  luma_16x16 mode:Vertical
   1610  *
   1611  * @par Description:
   1612  *  Perform Intra prediction for  luma_16x16 mode:Vertical, described in sec 8.3.3.1
   1613  *
   1614  * @param[in] pu1_src
   1615  *  UWORD8 pointer to the source
   1616  *
   1617  * @param[out] pu1_dst
   1618  *  UWORD8 pointer to the destination
   1619  *
   1620  * @param[in] src_strd
   1621  *  integer source stride
   1622  *
   1623  * @param[in] dst_strd
   1624  *  integer destination stride
   1625  *
   1626  * @param[in] ngbr_avail
   1627  *  availability of neighbouring pixels (Not used in this function)
   1628  *
   1629  * @returns
   1630  *
   1631  * @remarks
   1632  *  None
   1633  *
   1634  *******************************************************************************/
   1635 
   1636 void ih264_intra_pred_luma_16x16_mode_vert(UWORD8 *pu1_src,
   1637                                            UWORD8 *pu1_dst,
   1638                                            WORD32 src_strd,
   1639                                            WORD32 dst_strd,
   1640                                            WORD32 ngbr_avail)
   1641 {
   1642     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1643     WORD32 rows; /* loop variables*/
   1644     UNUSED(src_strd);
   1645     UNUSED(ngbr_avail);
   1646     pu1_top = pu1_src + MB_SIZE + 1;
   1647 
   1648     for(rows = 0; rows < 16; rows += 4, pu1_dst += dst_strd)
   1649     {
   1650         memcpy(pu1_dst, pu1_top, 16);
   1651         pu1_dst += dst_strd;
   1652         memcpy(pu1_dst, pu1_top, 16);
   1653         pu1_dst += dst_strd;
   1654         memcpy(pu1_dst, pu1_top, 16);
   1655         pu1_dst += dst_strd;
   1656         memcpy(pu1_dst, pu1_top, 16);
   1657     }
   1658 }
   1659 
   1660 /**
   1661  *******************************************************************************
   1662  *
   1663  *ih264_intra_pred_luma_16x16_mode_horz
   1664  *
   1665  * @brief
   1666  *  Perform Intra prediction for  luma_16x16 mode:Horizontal
   1667  *
   1668  * @par Description:
   1669  *  Perform Intra prediction for  luma_16x16 mode:Horizontal, described in sec 8.3.3.2
   1670  *
   1671  * @param[in] pu1_src
   1672  *  UWORD8 pointer to the source
   1673  *
   1674  * @param[out] pu1_dst
   1675  *  UWORD8 pointer to the destination
   1676  *
   1677  * @param[in] src_strd
   1678  *  integer source stride
   1679  *
   1680  * @param[in] dst_strd
   1681  *  integer destination stride
   1682  *
   1683  * @param[in] ngbr_avail
   1684  * availability of neighbouring pixels(Not used in this function)
   1685  *
   1686  * @returns
   1687  *
   1688  * @remarks
   1689  *  None
   1690  *
   1691  *******************************************************************************/
   1692 
   1693 void ih264_intra_pred_luma_16x16_mode_horz(UWORD8 *pu1_src,
   1694                                            UWORD8 *pu1_dst,
   1695                                            WORD32 src_strd,
   1696                                            WORD32 dst_strd,
   1697                                            WORD32 ngbr_avail)
   1698 {
   1699     UWORD8 *pu1_left = NULL; /* Pointer to start of top predictors */
   1700     WORD32 rows;
   1701     UNUSED(src_strd);
   1702     UNUSED(ngbr_avail);
   1703     pu1_left = pu1_src + MB_SIZE - 1;
   1704 
   1705     for(rows = 0; rows < 16; rows += 4, pu1_dst += dst_strd, pu1_left --)
   1706     {
   1707         memset(pu1_dst, *pu1_left, 16); /* copy the left value to the entire row*/
   1708         pu1_left --;
   1709         pu1_dst += dst_strd;
   1710         memset(pu1_dst, *pu1_left, 16);
   1711         pu1_left --;
   1712         pu1_dst += dst_strd;
   1713         memset(pu1_dst, *pu1_left, 16);
   1714         pu1_left --;
   1715         pu1_dst += dst_strd;
   1716         memset(pu1_dst, *pu1_left, 16);
   1717     }
   1718 }
   1719 
   1720 /**
   1721  *******************************************************************************
   1722  *
   1723  *ih264_intra_pred_luma_16x16_mode_dc
   1724  *
   1725  * @brief
   1726  *  Perform Intra prediction for  luma_16x16 mode:DC
   1727  *
   1728  * @par Description:
   1729  *  Perform Intra prediction for  luma_16x16 mode:DC, described in sec 8.3.3.3
   1730  *
   1731  * @param[in] pu1_src
   1732  *  UWORD8 pointer to the source
   1733  *
   1734  * @param[out] pu1_dst
   1735  *  UWORD8 pointer to the destination
   1736  *
   1737  * @param[in] src_strd
   1738  *  integer source stride
   1739  *
   1740  * @param[in] dst_strd
   1741  *  integer destination stride
   1742  *
   1743  ** @param[in] ngbr_avail
   1744  *  availability of neighbouring pixels
   1745  *
   1746  * @returns
   1747  *
   1748  * @remarks
   1749  *  None
   1750  *
   1751  *******************************************************************************/
   1752 
   1753 void ih264_intra_pred_luma_16x16_mode_dc(UWORD8 *pu1_src,
   1754                                          UWORD8 *pu1_dst,
   1755                                          WORD32 src_strd,
   1756                                          WORD32 dst_strd,
   1757                                          WORD32 ngbr_avail)
   1758 {
   1759     WORD8 u1_useleft; /* availability of left predictors (only for DC) */
   1760     UWORD8 u1_usetop; /* availability of top predictors (only for DC) */
   1761     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1762     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1763     WORD32 rows; /* loop variables*/
   1764     WORD32 val = 0;
   1765     UNUSED(src_strd);
   1766 
   1767     u1_useleft = BOOLEAN(ngbr_avail & LEFT_MB_AVAILABLE_MASK);
   1768     u1_usetop = BOOLEAN(ngbr_avail & TOP_MB_AVAILABLE_MASK);
   1769     pu1_top = pu1_src + MB_SIZE + 1;
   1770     pu1_left = pu1_src + MB_SIZE - 1;
   1771     if(u1_useleft)
   1772     {
   1773         for(rows = 0; rows < 16; rows++)
   1774             val += *(pu1_left - rows);
   1775         val += 8;
   1776     }
   1777     if(u1_usetop)
   1778     {
   1779         for(rows = 0; rows < 16; rows++)
   1780             val += *(pu1_top + rows);
   1781         val += 8;
   1782     }
   1783     /* Since 8 is added if either left/top pred is there,
   1784      val still being zero implies both preds are not there */
   1785     val = (val) ? (val >> (3 + u1_useleft + u1_usetop)) : 128;
   1786 
   1787     for(rows = 0; rows < 16; rows += 4, pu1_dst += dst_strd)
   1788     {
   1789         memset(pu1_dst, val, 16);
   1790         pu1_dst += dst_strd;
   1791         memset(pu1_dst, val, 16);
   1792         pu1_dst += dst_strd;
   1793         memset(pu1_dst, val, 16);
   1794         pu1_dst += dst_strd;
   1795         memset(pu1_dst, val, 16);
   1796     }
   1797 }
   1798 
   1799 /**
   1800  *******************************************************************************
   1801  *
   1802  *ih264_intra_pred_luma_16x16_mode_plane
   1803  *
   1804  * @brief
   1805  *  Perform Intra prediction for  luma_16x16 mode:PLANE
   1806  *
   1807  * @par Description:
   1808  *  Perform Intra prediction for  luma_16x16 mode:PLANE, described in sec 8.3.3.4
   1809  *
   1810  * @param[in] pu1_src
   1811  *  UWORD8 pointer to the source
   1812  *
   1813  * @param[out] pu1_dst
   1814  *  UWORD8 pointer to the destination
   1815  *
   1816  * @param[in] src_strd
   1817  *  integer source stride
   1818  *
   1819  * @param[in] dst_strd
   1820  *  integer destination stride
   1821  *
   1822  * @param[in] ngbr_avail
   1823  * availability of neighbouring pixels(Not used in this function)
   1824  *
   1825  * @returns
   1826  *
   1827  * @remarks
   1828  *  None
   1829  *
   1830  *******************************************************************************/
   1831 
   1832 void ih264_intra_pred_luma_16x16_mode_plane(UWORD8 *pu1_src,
   1833                                             UWORD8 *pu1_dst,
   1834                                             WORD32 src_strd,
   1835                                             WORD32 dst_strd,
   1836                                             WORD32 ngbr_avail)
   1837 {
   1838     /*! Written with no multiplications */
   1839     UWORD8 *pu1_left = NULL; /* Pointer to start of left predictors */
   1840     UWORD8 *pu1_top = NULL; /* Pointer to start of top predictors */
   1841     UWORD8 *pu1_topleft = NULL;
   1842     WORD32 a, b, c, tmp;
   1843     UWORD8 *pu1_tmp1, *pu1_tmp2;
   1844     WORD32 shift;
   1845     UNUSED(src_strd);
   1846     UNUSED(ngbr_avail);
   1847     pu1_top = pu1_src + MB_SIZE + 1;
   1848     pu1_left = pu1_src + MB_SIZE - 1;
   1849     pu1_topleft = pu1_src + MB_SIZE;
   1850 
   1851     {
   1852         a = (*(pu1_top + 15) + *(pu1_left - 15)) << 4;
   1853 
   1854         /*! Implement Sum(x*(P((x+7),-1) - P((x-7),-1))) x=1...8 */
   1855         pu1_tmp1 = pu1_top + 8;
   1856         pu1_tmp2 = pu1_tmp1 - 2;
   1857 
   1858         /* Pixel diffs are only 9 bits;
   1859          so sign extension allows shifts to be used even for signed */
   1860         b = ((*pu1_tmp1++) - (*pu1_tmp2--)); /* x=1 */
   1861         b += ((*pu1_tmp1++) - (*pu1_tmp2--)) << 1; /* x=2 */
   1862         tmp = ((*pu1_tmp1++) - (*pu1_tmp2--));
   1863         b += (tmp << 1) + tmp; /* x=3 */
   1864         b += ((*pu1_tmp1++) - (*pu1_tmp2--)) << 2; /* x=4 */
   1865 
   1866         tmp = ((*pu1_tmp1++) - (*pu1_tmp2--));
   1867         b += (tmp << 2) + tmp; /* x=5 */
   1868         tmp = ((*pu1_tmp1++) - (*pu1_tmp2--));
   1869         b += (tmp << 2) + (tmp << 1); /* x=6 */
   1870         tmp = ((*pu1_tmp1++) - (*pu1_tmp2--));
   1871         b += (tmp << 3) - tmp; /* x=7 */
   1872         b += ((*pu1_tmp1) - (*pu1_topleft)) << 3; /* x=8 */
   1873 
   1874         b = ((b << 2) + b + 32) >> 6; /*! (5*H + 32)>>6 */
   1875 
   1876         /*! Implement Sum(y*(P(-1,(y+7)) - P(-1,(y-7)))) y=1...8 */
   1877         pu1_tmp1 = pu1_left - 8;
   1878         pu1_tmp2 = pu1_tmp1 + 2;
   1879 
   1880         c = ((*pu1_tmp1) - (*pu1_tmp2)); /* y=1 */
   1881         pu1_tmp1--;
   1882         pu1_tmp2++;
   1883         c += ((*pu1_tmp1) - (*pu1_tmp2)) << 1; /* y=2 */
   1884         pu1_tmp1--;
   1885         pu1_tmp2++;
   1886         tmp = ((*pu1_tmp1) - (*pu1_tmp2));
   1887         c += (tmp << 1) + tmp; /* y=3 */
   1888         pu1_tmp1--;
   1889         pu1_tmp2++;
   1890         c += ((*pu1_tmp1) - (*pu1_tmp2)) << 2; /* y=4 */
   1891         pu1_tmp1--;
   1892         pu1_tmp2++;
   1893 
   1894         tmp = ((*pu1_tmp1) - (*pu1_tmp2));
   1895         c += (tmp << 2) + tmp; /* y=5 */
   1896         pu1_tmp1--;
   1897         pu1_tmp2++;
   1898         tmp = ((*pu1_tmp1) - (*pu1_tmp2));
   1899         c += (tmp << 2) + (tmp << 1); /* y=6 */
   1900         pu1_tmp1--;
   1901         pu1_tmp2++;
   1902         tmp = ((*pu1_tmp1) - (*pu1_tmp2));
   1903         c += (tmp << 3) - tmp; /* y=7 */
   1904         pu1_tmp1--; //pu1_tmp2 ++;
   1905         /* Modified to get (-1,-1) location as *(pu1_top - 1) instead of (pu1_left - ui4_stride) */
   1906         //c += ((*pu1_tmp1) - (*(pu1_top - 1)))<<3;      /* y=8 */
   1907         c += ((*pu1_tmp1) - (*pu1_topleft)) << 3; /* y=8 */
   1908 
   1909         c = ((c << 2) + c + 32) >> 6; /*! (5*V + 32)>>32 */
   1910         shift = 3;
   1911     }
   1912 
   1913     /*! Now from the plane parameters a, b, and c,
   1914      compute the fitted plane values over the block */
   1915     {
   1916         WORD32 tmp1, tmpx, tmpx_init, j, i;
   1917 
   1918         tmpx_init = -(b << shift); /* -8b */
   1919         tmp = a - (c << shift) + 16; /* a-((4or8)*c)+16 */
   1920         for(i = 0; i < 16; i++)
   1921         {
   1922             tmp += c; /*increment every time by c to get c*(y-7or3)*/
   1923             tmpx = tmpx_init; /* Init to -8b */
   1924             for(j = 0; j < 16; j++)
   1925             {
   1926                 tmpx += b; /* increment every time by b to get b*(x-7or3) */
   1927                 tmp1 = (tmp + tmpx) >> 5;
   1928                 *pu1_dst++ = CLIP_U8(tmp1);
   1929             }
   1930             pu1_dst += (dst_strd - 16);
   1931         }
   1932     }
   1933 }
   1934