Home | History | Annotate | Download | only in src
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*
     19 ------------------------------------------------------------------------------
     20  INPUT AND OUTPUT DEFINITIONS
     21 
     22  Inputs:
     23     [input_variable_name] = [description of the input to module, its type
     24                  definition, and length (when applicable)]
     25 
     26  Local Stores/Buffers/Pointers Needed:
     27     [local_store_name] = [description of the local store, its type
     28                   definition, and length (when applicable)]
     29     [local_buffer_name] = [description of the local buffer, its type
     30                    definition, and length (when applicable)]
     31     [local_ptr_name] = [description of the local pointer, its type
     32                 definition, and length (when applicable)]
     33 
     34  Global Stores/Buffers/Pointers Needed:
     35     [global_store_name] = [description of the global store, its type
     36                    definition, and length (when applicable)]
     37     [global_buffer_name] = [description of the global buffer, its type
     38                 definition, and length (when applicable)]
     39     [global_ptr_name] = [description of the global pointer, its type
     40                  definition, and length (when applicable)]
     41 
     42  Outputs:
     43     [return_variable_name] = [description of data/pointer returned
     44                   by module, its type definition, and length
     45                   (when applicable)]
     46 
     47  Pointers and Buffers Modified:
     48     [variable_bfr_ptr] points to the [describe where the
     49       variable_bfr_ptr points to, its type definition, and length
     50       (when applicable)]
     51     [variable_bfr] contents are [describe the new contents of
     52       variable_bfr]
     53 
     54  Local Stores Modified:
     55     [local_store_name] = [describe new contents, its type
     56                   definition, and length (when applicable)]
     57 
     58  Global Stores Modified:
     59     [global_store_name] = [describe new contents, its type
     60                    definition, and length (when applicable)]
     61 
     62 ------------------------------------------------------------------------------
     63  FUNCTION DESCRIPTION
     64 
     65    For fast Deblock filtering
     66    Newer version (macroblock based processing)
     67 
     68 ------------------------------------------------------------------------------
     69  REQUIREMENTS
     70 
     71  [List requirements to be satisfied by this module.]
     72 
     73 ------------------------------------------------------------------------------
     74  REFERENCES
     75 
     76  [List all references used in designing this module.]
     77 
     78 ------------------------------------------------------------------------------
     79  PSEUDO-CODE
     80 
     81 ------------------------------------------------------------------------------
     82  RESOURCES USED
     83    When the code is written for a specific target processor the
     84      the resources used should be documented below.
     85 
     86  STACK USAGE: [stack count for this module] + [variable to represent
     87           stack usage for each subroutine called]
     88 
     89      where: [stack usage variable] = stack usage for [subroutine
     90          name] (see [filename].ext)
     91 
     92  DATA MEMORY USED: x words
     93 
     94  PROGRAM MEMORY USED: x words
     95 
     96  CLOCK CYCLES: [cycle count equation for this module] + [variable
     97            used to represent cycle count for each subroutine
     98            called]
     99 
    100      where: [cycle count variable] = cycle count for [subroutine
    101         name] (see [filename].ext)
    102 
    103 ------------------------------------------------------------------------------
    104 */
    105 
    106 
    107 /*----------------------------------------------------------------------------
    108 ; INCLUDES
    109 ----------------------------------------------------------------------------*/
    110 #include    "mp4dec_lib.h"
    111 #include    "post_proc.h"
    112 
    113 #define OSCL_DISABLE_WARNING_CONV_POSSIBLE_LOSS_OF_DATA
    114 #include "osclconfig_compiler_warnings.h"
    115 
    116 /*----------------------------------------------------------------------------
    117 ; MACROS
    118 ; Define module specific macros here
    119 ----------------------------------------------------------------------------*/
    120 //#define FILTER_LEN_8
    121 
    122 /*----------------------------------------------------------------------------
    123 ; DEFINES
    124 ; Include all pre-processor statements here. Include conditional
    125 ; compile variables also.
    126 ----------------------------------------------------------------------------*/
    127 
    128 /*----------------------------------------------------------------------------
    129 ; LOCAL FUNCTION DEFINITIONS
    130 ; Function Prototype declaration
    131 
    132 ----------------------------------------------------------------------------
    133 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
    134 ; Variable declaration - defined here and used outside this module
    135 ----------------------------------------------------------------------------*/
    136 
    137 /*----------------------------------------------------------------------------
    138 ; EXTERNAL FUNCTION REFERENCES
    139 ; Declare functions defined elsewhere and referenced in this module
    140 ----------------------------------------------------------------------------*/
    141 
    142 /*----------------------------------------------------------------------------
    143 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
    144 ; Declare variables used in this module but defined elsewhere
    145 ----------------------------------------------------------------------------*/
    146 #ifdef PV_POSTPROC_ON
    147 
    148 /*************************************************************************
    149     Function prototype : void CombinedHorzVertFilter(   uint8 *rec,
    150                                                         int width,
    151                                                         int height,
    152                                                         int *QP_store,
    153                                                         int chr,
    154                                                         uint8 *pp_mod)
    155     Parameters  :
    156         rec     :   pointer to the decoded frame buffer.
    157         width   :   width of decoded frame.
    158         height  :   height of decoded frame
    159         QP_store:   pointer to the array of QP corresponding to the decoded frame.
    160                     It had only one value for each MB.
    161         chr     :   luma or color indication
    162                     == 0 luma
    163                     == 1 color
    164         pp_mod  :   The semphore used for deblocking
    165 
    166     Remark      :   The function do the deblocking on decoded frames.
    167                     First based on the semaphore info., it is divided into hard and soft filtering.
    168                     To differentiate real and fake edge, it then check the difference with QP to
    169                     decide whether to do the filtering or not.
    170 
    171 *************************************************************************/
    172 
    173 
    174 /*----------------------------------------------------------------------------
    175 ; FUNCTION CODE
    176 ----------------------------------------------------------------------------*/
    177 void CombinedHorzVertFilter(
    178     uint8 *rec,
    179     int width,
    180     int height,
    181     int16 *QP_store,
    182     int chr,
    183     uint8 *pp_mod)
    184 {
    185 
    186     /*----------------------------------------------------------------------------
    187     ; Define all local variables
    188     ----------------------------------------------------------------------------*/
    189     int br, bc, mbr, mbc;
    190     int QP = 1;
    191     uint8 *ptr, *ptr_e;
    192     int pp_w, pp_h;
    193     int brwidth;
    194 
    195     int jVal0, jVal1, jVal2;
    196     /*----------------------------------------------------------------------------
    197     ; Function body here
    198     ----------------------------------------------------------------------------*/
    199     pp_w = (width >> 3);
    200     pp_h = (height >> 3);
    201 
    202     for (mbr = 0; mbr < pp_h; mbr += 2)         /* row of blocks */
    203     {
    204         brwidth = mbr * pp_w;               /* number of blocks above current block row */
    205         for (mbc = 0; mbc < pp_w; mbc += 2)     /* col of blocks */
    206         {
    207             if (!chr)
    208                 QP = QP_store[(brwidth>>2) + (mbc>>1)]; /* QP is per MB based value */
    209 
    210             /********* for each block **************/
    211             /****************** Horiz. Filtering ********************/
    212             for (br = mbr + 1; br < mbr + 3; br++)  /* 2x2 blocks */
    213             {
    214                 brwidth += pp_w;                    /* number of blocks above & left current block row */
    215                 /* the profile on ARM920T shows separate these two boundary check is faster than combine them */
    216                 if (br < pp_h)                  /* boundary : don't do it on the lowest row block */
    217                     for (bc = mbc; bc < mbc + 2; bc++)
    218                     {
    219                         /****** check boundary for deblocking ************/
    220                         if (bc < pp_w)              /* boundary : don't do it on the most right col block */
    221                         {
    222                             ptr = rec + (brwidth << 6) + (bc << 3);
    223                             jVal0 = brwidth + bc;
    224                             if (chr)    QP = QP_store[jVal0];
    225 
    226                             ptr_e = ptr + 8;        /* pointer to where the loop ends */
    227 
    228                             if (((pp_mod[jVal0]&0x02)) && ((pp_mod[jVal0-pp_w]&0x02)))
    229                             {
    230                                 /* Horiz Hard filter */
    231                                 do
    232                                 {
    233                                     jVal0 = *(ptr - width);     /* C */
    234                                     jVal1 = *ptr;               /* D */
    235                                     jVal2 = jVal1 - jVal0;
    236 
    237                                     if (((jVal2 > 0) && (jVal2 < (QP << 1)))
    238                                             || ((jVal2 < 0) && (jVal2 > -(QP << 1)))) /* (D-C) compared with 2QP */
    239                                     {
    240                                         /* differentiate between real and fake edge */
    241                                         jVal0 = ((jVal0 + jVal1) >> 1);     /* (D+C)/2 */
    242                                         *(ptr - width) = (uint8)(jVal0);    /*  C */
    243                                         *ptr = (uint8)(jVal0);          /*  D */
    244 
    245                                         jVal0 = *(ptr - (width << 1));      /* B */
    246                                         jVal1 = *(ptr + width);         /* E */
    247                                         jVal2 = jVal1 - jVal0;      /* E-B */
    248 
    249                                         if (jVal2 > 0)
    250                                         {
    251                                             jVal0 += ((jVal2 + 3) >> 2);
    252                                             jVal1 -= ((jVal2 + 3) >> 2);
    253                                             *(ptr - (width << 1)) = (uint8)jVal0;       /*  store B */
    254                                             *(ptr + width) = (uint8)jVal1;          /* store E */
    255                                         }
    256                                         else if (jVal2)
    257                                         {
    258                                             jVal0 -= ((3 - jVal2) >> 2);
    259                                             jVal1 += ((3 - jVal2) >> 2);
    260                                             *(ptr - (width << 1)) = (uint8)jVal0;       /*  store B */
    261                                             *(ptr + width) = (uint8)jVal1;          /* store E */
    262                                         }
    263 
    264                                         jVal0 = *(ptr - (width << 1) - width);  /* A */
    265                                         jVal1 = *(ptr + (width << 1));      /* F */
    266                                         jVal2 = jVal1 - jVal0;              /* (F-A) */
    267 
    268                                         if (jVal2 > 0)
    269                                         {
    270                                             jVal0 += ((jVal2 + 7) >> 3);
    271                                             jVal1 -= ((jVal2 + 7) >> 3);
    272                                             *(ptr - (width << 1) - width) = (uint8)(jVal0);
    273                                             *(ptr + (width << 1)) = (uint8)(jVal1);
    274                                         }
    275                                         else if (jVal2)
    276                                         {
    277                                             jVal0 -= ((7 - jVal2) >> 3);
    278                                             jVal1 += ((7 - jVal2) >> 3);
    279                                             *(ptr - (width << 1) - width) = (uint8)(jVal0);
    280                                             *(ptr + (width << 1)) = (uint8)(jVal1);
    281                                         }
    282                                     }/* a3_0 > 2QP */
    283                                 }
    284                                 while (++ptr < ptr_e);
    285                             }
    286                             else   /* Horiz soft filter*/
    287                             {
    288                                 do
    289                                 {
    290                                     jVal0 = *(ptr - width); /* B */
    291                                     jVal1 = *ptr;           /* C */
    292                                     jVal2 = jVal1 - jVal0;  /* C-B */
    293 
    294                                     if (((jVal2 > 0) && (jVal2 < (QP)))
    295                                             || ((jVal2 < 0) && (jVal2 > -(QP)))) /* (C-B) compared with QP */
    296                                     {
    297 
    298                                         jVal0 = ((jVal0 + jVal1) >> 1);     /* (B+C)/2 cannot overflow; ceil() */
    299                                         *(ptr - width) = (uint8)(jVal0);    /* B = (B+C)/2 */
    300                                         *ptr = (uint8)jVal0;            /* C = (B+C)/2 */
    301 
    302                                         jVal0 = *(ptr - (width << 1));      /* A */
    303                                         jVal1 = *(ptr + width);         /* D */
    304                                         jVal2 = jVal1 - jVal0;          /* D-A */
    305 
    306 
    307                                         if (jVal2 > 0)
    308                                         {
    309                                             jVal1 -= ((jVal2 + 7) >> 3);
    310                                             jVal0 += ((jVal2 + 7) >> 3);
    311                                             *(ptr - (width << 1)) = (uint8)jVal0;       /* A */
    312                                             *(ptr + width) = (uint8)jVal1;          /* D */
    313                                         }
    314                                         else if (jVal2)
    315                                         {
    316                                             jVal1 += ((7 - jVal2) >> 3);
    317                                             jVal0 -= ((7 - jVal2) >> 3);
    318                                             *(ptr - (width << 1)) = (uint8)jVal0;       /* A */
    319                                             *(ptr + width) = (uint8)jVal1;          /* D */
    320                                         }
    321                                     }
    322                                 }
    323                                 while (++ptr < ptr_e);
    324                             } /* Soft filter*/
    325                         }/* boundary checking*/
    326                     }/*bc*/
    327             }/*br*/
    328             brwidth -= (pp_w << 1);
    329             /****************** Vert. Filtering ********************/
    330             for (br = mbr; br < mbr + 2; br++)
    331             {
    332                 if (br < pp_h)
    333                     for (bc = mbc + 1; bc < mbc + 3; bc++)
    334                     {
    335                         /****** check boundary for deblocking ************/
    336                         if (bc < pp_w)
    337                         {
    338                             ptr = rec + (brwidth << 6) + (bc << 3);
    339                             jVal0 = brwidth + bc;
    340                             if (chr)    QP = QP_store[jVal0];
    341 
    342                             ptr_e = ptr + (width << 3);
    343 
    344                             if (((pp_mod[jVal0-1]&0x01)) && ((pp_mod[jVal0]&0x01)))
    345                             {
    346                                 /* Vert Hard filter */
    347                                 do
    348                                 {
    349                                     jVal1 = *ptr;       /* D */
    350                                     jVal0 = *(ptr - 1); /* C */
    351                                     jVal2 = jVal1 - jVal0;  /* D-C */
    352 
    353                                     if (((jVal2 > 0) && (jVal2 < (QP << 1)))
    354                                             || ((jVal2 < 0) && (jVal2 > -(QP << 1))))
    355                                     {
    356                                         jVal1 = (jVal0 + jVal1) >> 1;   /* (C+D)/2 */
    357                                         *ptr        =   jVal1;
    358                                         *(ptr - 1)  =   jVal1;
    359 
    360                                         jVal1 = *(ptr + 1);     /* E */
    361                                         jVal0 = *(ptr - 2);     /* B */
    362                                         jVal2 = jVal1 - jVal0;      /* E-B */
    363 
    364                                         if (jVal2 > 0)
    365                                         {
    366                                             jVal1 -= ((jVal2 + 3) >> 2);        /* E = E -(E-B)/4 */
    367                                             jVal0 += ((jVal2 + 3) >> 2);        /* B = B +(E-B)/4 */
    368                                             *(ptr + 1) = jVal1;
    369                                             *(ptr - 2) = jVal0;
    370                                         }
    371                                         else if (jVal2)
    372                                         {
    373                                             jVal1 += ((3 - jVal2) >> 2);        /* E = E -(E-B)/4 */
    374                                             jVal0 -= ((3 - jVal2) >> 2);        /* B = B +(E-B)/4 */
    375                                             *(ptr + 1) = jVal1;
    376                                             *(ptr - 2) = jVal0;
    377                                         }
    378 
    379                                         jVal1 = *(ptr + 2);     /* F */
    380                                         jVal0 = *(ptr - 3);     /* A */
    381 
    382                                         jVal2 = jVal1 - jVal0;          /* (F-A) */
    383 
    384                                         if (jVal2 > 0)
    385                                         {
    386                                             jVal1 -= ((jVal2 + 7) >> 3);    /* F -= (F-A)/8 */
    387                                             jVal0 += ((jVal2 + 7) >> 3);    /* A += (F-A)/8 */
    388                                             *(ptr + 2) = jVal1;
    389                                             *(ptr - 3) = jVal0;
    390                                         }
    391                                         else if (jVal2)
    392                                         {
    393                                             jVal1 -= ((jVal2 - 7) >> 3);    /* F -= (F-A)/8 */
    394                                             jVal0 += ((jVal2 - 7) >> 3);    /* A += (F-A)/8 */
    395                                             *(ptr + 2) = jVal1;
    396                                             *(ptr - 3) = jVal0;
    397                                         }
    398                                     }   /* end of ver hard filetering */
    399                                 }
    400                                 while ((ptr += width) < ptr_e);
    401                             }
    402                             else   /* Vert soft filter*/
    403                             {
    404                                 do
    405                                 {
    406                                     jVal1 = *ptr;               /* C */
    407                                     jVal0 = *(ptr - 1);         /* B */
    408                                     jVal2 = jVal1 - jVal0;
    409 
    410                                     if (((jVal2 > 0) && (jVal2 < (QP)))
    411                                             || ((jVal2 < 0) && (jVal2 > -(QP))))
    412                                     {
    413 
    414                                         jVal1 = (jVal0 + jVal1 + 1) >> 1;
    415                                         *ptr = jVal1;           /* C */
    416                                         *(ptr - 1) = jVal1;     /* B */
    417 
    418                                         jVal1 = *(ptr + 1);     /* D */
    419                                         jVal0 = *(ptr - 2);     /* A */
    420                                         jVal2 = (jVal1 - jVal0);        /* D- A */
    421 
    422                                         if (jVal2 > 0)
    423                                         {
    424                                             jVal1 -= (((jVal2) + 7) >> 3);      /* D -= (D-A)/8 */
    425                                             jVal0 += (((jVal2) + 7) >> 3);      /* A += (D-A)/8 */
    426                                             *(ptr + 1) = jVal1;
    427                                             *(ptr - 2) = jVal0;
    428 
    429                                         }
    430                                         else if (jVal2)
    431                                         {
    432                                             jVal1 += ((7 - (jVal2)) >> 3);      /* D -= (D-A)/8 */
    433                                             jVal0 -= ((7 - (jVal2)) >> 3);      /* A += (D-A)/8 */
    434                                             *(ptr + 1) = jVal1;
    435                                             *(ptr - 2) = jVal0;
    436                                         }
    437                                     }
    438                                 }
    439                                 while ((ptr += width) < ptr_e);
    440                             } /* Soft filter*/
    441                         } /* boundary*/
    442                     } /*bc*/
    443                 brwidth += pp_w;
    444             }/*br*/
    445             brwidth -= (pp_w << 1);
    446         }/*mbc*/
    447         brwidth += (pp_w << 1);
    448     }/*mbr*/
    449     /*----------------------------------------------------------------------------
    450     ; Return nothing or data or data pointer
    451     ----------------------------------------------------------------------------*/
    452     return;
    453 }
    454 void CombinedHorzVertFilter_NoSoftDeblocking(
    455     uint8 *rec,
    456     int width,
    457     int height,
    458     int16 *QP_store,
    459     int chr,
    460     uint8 *pp_mod)
    461 {
    462 
    463     /*----------------------------------------------------------------------------
    464     ; Define all local variables
    465     ----------------------------------------------------------------------------*/
    466     int br, bc, mbr, mbc;
    467     int QP = 1;
    468     uint8 *ptr, *ptr_e;
    469     int pp_w, pp_h;
    470     int brwidth;
    471 
    472     int jVal0, jVal1, jVal2;
    473     /*----------------------------------------------------------------------------
    474     ; Function body here
    475     ----------------------------------------------------------------------------*/
    476     pp_w = (width >> 3);
    477     pp_h = (height >> 3);
    478 
    479     for (mbr = 0; mbr < pp_h; mbr += 2)         /* row of blocks */
    480     {
    481         brwidth = mbr * pp_w;               /* number of blocks above current block row */
    482         for (mbc = 0; mbc < pp_w; mbc += 2)     /* col of blocks */
    483         {
    484             if (!chr)
    485                 QP = QP_store[(brwidth>>2) + (mbc>>1)]; /* QP is per MB based value */
    486 
    487             /********* for each block **************/
    488             /****************** Horiz. Filtering ********************/
    489             for (br = mbr + 1; br < mbr + 3; br++)  /* 2x2 blocks */
    490             {
    491                 brwidth += pp_w;                    /* number of blocks above & left current block row */
    492                 /* the profile on ARM920T shows separate these two boundary check is faster than combine them */
    493                 if (br < pp_h)                  /* boundary : don't do it on the lowest row block */
    494                     for (bc = mbc; bc < mbc + 2; bc++)
    495                     {
    496                         /****** check boundary for deblocking ************/
    497                         if (bc < pp_w)              /* boundary : don't do it on the most right col block */
    498                         {
    499                             ptr = rec + (brwidth << 6) + (bc << 3);
    500                             jVal0 = brwidth + bc;
    501                             if (chr)    QP = QP_store[jVal0];
    502 
    503                             ptr_e = ptr + 8;        /* pointer to where the loop ends */
    504 
    505                             if (((pp_mod[jVal0]&0x02)) && ((pp_mod[jVal0-pp_w]&0x02)))
    506                             {
    507                                 /* Horiz Hard filter */
    508                                 do
    509                                 {
    510                                     jVal0 = *(ptr - width);     /* C */
    511                                     jVal1 = *ptr;               /* D */
    512                                     jVal2 = jVal1 - jVal0;
    513 
    514                                     if (((jVal2 > 0) && (jVal2 < (QP << 1)))
    515                                             || ((jVal2 < 0) && (jVal2 > -(QP << 1)))) /* (D-C) compared with 2QP */
    516                                     {
    517                                         /* differentiate between real and fake edge */
    518                                         jVal0 = ((jVal0 + jVal1) >> 1);     /* (D+C)/2 */
    519                                         *(ptr - width) = (uint8)(jVal0);    /*  C */
    520                                         *ptr = (uint8)(jVal0);          /*  D */
    521 
    522                                         jVal0 = *(ptr - (width << 1));      /* B */
    523                                         jVal1 = *(ptr + width);         /* E */
    524                                         jVal2 = jVal1 - jVal0;      /* E-B */
    525 
    526                                         if (jVal2 > 0)
    527                                         {
    528                                             jVal0 += ((jVal2 + 3) >> 2);
    529                                             jVal1 -= ((jVal2 + 3) >> 2);
    530                                             *(ptr - (width << 1)) = (uint8)jVal0;       /*  store B */
    531                                             *(ptr + width) = (uint8)jVal1;          /* store E */
    532                                         }
    533                                         else if (jVal2)
    534                                         {
    535                                             jVal0 -= ((3 - jVal2) >> 2);
    536                                             jVal1 += ((3 - jVal2) >> 2);
    537                                             *(ptr - (width << 1)) = (uint8)jVal0;       /*  store B */
    538                                             *(ptr + width) = (uint8)jVal1;          /* store E */
    539                                         }
    540 
    541                                         jVal0 = *(ptr - (width << 1) - width);  /* A */
    542                                         jVal1 = *(ptr + (width << 1));      /* F */
    543                                         jVal2 = jVal1 - jVal0;              /* (F-A) */
    544 
    545                                         if (jVal2 > 0)
    546                                         {
    547                                             jVal0 += ((jVal2 + 7) >> 3);
    548                                             jVal1 -= ((jVal2 + 7) >> 3);
    549                                             *(ptr - (width << 1) - width) = (uint8)(jVal0);
    550                                             *(ptr + (width << 1)) = (uint8)(jVal1);
    551                                         }
    552                                         else if (jVal2)
    553                                         {
    554                                             jVal0 -= ((7 - jVal2) >> 3);
    555                                             jVal1 += ((7 - jVal2) >> 3);
    556                                             *(ptr - (width << 1) - width) = (uint8)(jVal0);
    557                                             *(ptr + (width << 1)) = (uint8)(jVal1);
    558                                         }
    559                                     }/* a3_0 > 2QP */
    560                                 }
    561                                 while (++ptr < ptr_e);
    562                             }
    563 
    564                         }/* boundary checking*/
    565                     }/*bc*/
    566             }/*br*/
    567             brwidth -= (pp_w << 1);
    568             /****************** Vert. Filtering ********************/
    569             for (br = mbr; br < mbr + 2; br++)
    570             {
    571                 if (br < pp_h)
    572                     for (bc = mbc + 1; bc < mbc + 3; bc++)
    573                     {
    574                         /****** check boundary for deblocking ************/
    575                         if (bc < pp_w)
    576                         {
    577                             ptr = rec + (brwidth << 6) + (bc << 3);
    578                             jVal0 = brwidth + bc;
    579                             if (chr)    QP = QP_store[jVal0];
    580 
    581                             ptr_e = ptr + (width << 3);
    582 
    583                             if (((pp_mod[jVal0-1]&0x01)) && ((pp_mod[jVal0]&0x01)))
    584                             {
    585                                 /* Vert Hard filter */
    586                                 do
    587                                 {
    588                                     jVal1 = *ptr;       /* D */
    589                                     jVal0 = *(ptr - 1); /* C */
    590                                     jVal2 = jVal1 - jVal0;  /* D-C */
    591 
    592                                     if (((jVal2 > 0) && (jVal2 < (QP << 1)))
    593                                             || ((jVal2 < 0) && (jVal2 > -(QP << 1))))
    594                                     {
    595                                         jVal1 = (jVal0 + jVal1) >> 1;   /* (C+D)/2 */
    596                                         *ptr        =   jVal1;
    597                                         *(ptr - 1)  =   jVal1;
    598 
    599                                         jVal1 = *(ptr + 1);     /* E */
    600                                         jVal0 = *(ptr - 2);     /* B */
    601                                         jVal2 = jVal1 - jVal0;      /* E-B */
    602 
    603                                         if (jVal2 > 0)
    604                                         {
    605                                             jVal1 -= ((jVal2 + 3) >> 2);        /* E = E -(E-B)/4 */
    606                                             jVal0 += ((jVal2 + 3) >> 2);        /* B = B +(E-B)/4 */
    607                                             *(ptr + 1) = jVal1;
    608                                             *(ptr - 2) = jVal0;
    609                                         }
    610                                         else if (jVal2)
    611                                         {
    612                                             jVal1 += ((3 - jVal2) >> 2);        /* E = E -(E-B)/4 */
    613                                             jVal0 -= ((3 - jVal2) >> 2);        /* B = B +(E-B)/4 */
    614                                             *(ptr + 1) = jVal1;
    615                                             *(ptr - 2) = jVal0;
    616                                         }
    617 
    618                                         jVal1 = *(ptr + 2);     /* F */
    619                                         jVal0 = *(ptr - 3);     /* A */
    620 
    621                                         jVal2 = jVal1 - jVal0;          /* (F-A) */
    622 
    623                                         if (jVal2 > 0)
    624                                         {
    625                                             jVal1 -= ((jVal2 + 7) >> 3);    /* F -= (F-A)/8 */
    626                                             jVal0 += ((jVal2 + 7) >> 3);    /* A += (F-A)/8 */
    627                                             *(ptr + 2) = jVal1;
    628                                             *(ptr - 3) = jVal0;
    629                                         }
    630                                         else if (jVal2)
    631                                         {
    632                                             jVal1 -= ((jVal2 - 7) >> 3);    /* F -= (F-A)/8 */
    633                                             jVal0 += ((jVal2 - 7) >> 3);    /* A += (F-A)/8 */
    634                                             *(ptr + 2) = jVal1;
    635                                             *(ptr - 3) = jVal0;
    636                                         }
    637                                     }   /* end of ver hard filetering */
    638                                 }
    639                                 while ((ptr += width) < ptr_e);
    640                             }
    641 
    642                         } /* boundary*/
    643                     } /*bc*/
    644                 brwidth += pp_w;
    645             }/*br*/
    646             brwidth -= (pp_w << 1);
    647         }/*mbc*/
    648         brwidth += (pp_w << 1);
    649     }/*mbr*/
    650     /*----------------------------------------------------------------------------
    651     ; Return nothing or data or data pointer
    652     ----------------------------------------------------------------------------*/
    653     return;
    654 }
    655 #endif
    656