Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2007-2008 ARM Limited
      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 express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  *
     16  */
     17 /* ----------------------------------------------------------------
     18  *
     19  *
     20  * File Name:  armVCM4P10_DeBlockPixel.c
     21  * OpenMAX DL: v1.0.2
     22  * Revision:   9641
     23  * Date:       Thursday, February 7, 2008
     24  *
     25  *
     26  *
     27  *
     28  * H.264 luma deblock module
     29  *
     30  */
     31 
     32 #ifdef DEBUG_ARMVCM4P10_DEBLOCKPIXEL
     33 #undef DEBUG_ON
     34 #define DEBUG_ON
     35 #endif /* DEBUG_ARMVCM4P10_DEBLOCKPIXEL */
     36 
     37 #include "omxtypes.h"
     38 #include "armOMX.h"
     39 #include "omxVC.h"
     40 
     41 #include "armCOMM.h"
     42 #include "armVC.h"
     43 
     44 /*
     45  * Description
     46  * Deblock one boundary pixel
     47  *
     48  * Parameters:
     49  * [in]	pQ0         Pointer to pixel q0
     50  * [in] Step        Step between pixels q0 and q1
     51  * [in] tC0         Edge threshold value
     52  * [in] alpha       alpha threshold value
     53  * [in] beta        beta threshold value
     54  * [in] bS          deblocking strength
     55  * [in] ChromaFlag  True for chroma blocks
     56  * [out] pQ0        Deblocked pixels
     57  *
     58  */
     59 
     60 void armVCM4P10_DeBlockPixel(
     61     OMX_U8 *pQ0,    /* pointer to the pixel q0 */
     62     int Step,       /* step between pixels q0 and q1 */
     63     int tC0,        /* edge threshold value */
     64     int alpha,      /* alpha */
     65     int beta,       /* beta */
     66     int bS,         /* deblocking strength */
     67     int ChromaFlag
     68 )
     69 {
     70     int p3, p2, p1, p0, q0, q1, q2, q3;
     71     int ap, aq, delta;
     72 
     73     if (bS==0)
     74     {
     75         return;
     76     }
     77 
     78     p3 = pQ0[-4*Step];
     79     p2 = pQ0[-3*Step];
     80     p1 = pQ0[-2*Step];
     81     p0 = pQ0[-1*Step];
     82     q0 = pQ0[ 0*Step];
     83     q1 = pQ0[ 1*Step];
     84     q2 = pQ0[ 2*Step];
     85     q3 = pQ0[ 3*Step];
     86 
     87     if (armAbs(p0-q0)>=alpha || armAbs(p1-p0)>=beta || armAbs(q1-q0)>=beta)
     88     {
     89         DEBUG_PRINTF_10("DeBlockPixel: %02x %02x %02x %02x | %02x %02x %02x %02x alpha=%d beta=%d\n",
     90             p3, p2, p1, p0, q0, q1, q2, q3, alpha, beta);
     91         return;
     92     }
     93 
     94     ap = armAbs(p2 - p0);
     95     aq = armAbs(q2 - q0);
     96 
     97     if (bS < 4)
     98     {
     99         int tC = tC0;
    100 
    101         if (ChromaFlag)
    102         {
    103             tC++;
    104         }
    105         else
    106         {
    107             if (ap < beta)
    108             {
    109                 tC++;
    110             }
    111             if (aq < beta)
    112             {
    113                 tC++;
    114             }
    115         }
    116 
    117         delta = (((q0-p0)<<2) + (p1-q1) + 4) >> 3;
    118         delta = armClip(-tC, tC, delta);
    119 
    120         pQ0[-1*Step] = (OMX_U8)armClip(0, 255, p0 + delta);
    121         pQ0[ 0*Step] = (OMX_U8)armClip(0, 255, q0 - delta);
    122 
    123         if (ChromaFlag==0 && ap<beta)
    124         {
    125             delta = (p2 + ((p0+q0+1)>>1) - (p1<<1))>>1;
    126             delta = armClip(-tC0, tC0, delta);
    127             pQ0[-2*Step] = (OMX_U8)(p1 + delta);
    128         }
    129 
    130         if (ChromaFlag==0 && aq<beta)
    131         {
    132             delta = (q2 + ((p0+q0+1)>>1) - (q1<<1))>>1;
    133             delta = armClip(-tC0, tC0, delta);
    134             pQ0[ 1*Step] = (OMX_U8)(q1 + delta);
    135         }
    136     }
    137     else /* bS==4 */
    138     {
    139         if (ChromaFlag==0 && ap<beta && armAbs(p0-q0)<((alpha>>2)+2))
    140         {
    141             pQ0[-1*Step] = (OMX_U8)((p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4)>>3);
    142             pQ0[-2*Step] = (OMX_U8)((p2 + p1 + p0 + q0 + 2)>>2);
    143             pQ0[-3*Step] = (OMX_U8)((2*p3 + 3*p2 + p1 + p0 + q0 + 4)>>3);
    144         }
    145         else
    146         {
    147             pQ0[-1*Step] = (OMX_U8)((2*p1 + p0 + q1 + 2)>>2);
    148         }
    149 
    150         if (ChromaFlag==0 && aq<beta && armAbs(p0-q0)<((alpha>>2)+2))
    151         {
    152             pQ0[ 0*Step] = (OMX_U8)((q2 + 2*q1 + 2*q0 + 2*p0 + p1 + 4)>>3);
    153             pQ0[ 1*Step] = (OMX_U8)((q2 + q1 + p0 + q0 + 2)>>2);
    154             pQ0[ 2*Step] = (OMX_U8)((2*q3 + 3*q2 + q1 + q0 + p0 + 4)>>3);
    155         }
    156         else
    157         {
    158             pQ0[ 0*Step] = (OMX_U8)((2*q1 + q0 + p1 + 2)>>2);
    159         }
    160     }
    161 
    162     DEBUG_PRINTF_13("DeBlockPixel: %02x %02x %02x %02x | %02x %02x %02x %02x bS=%d -> %02x %02x %02x %02x\n",
    163         p3, p2, p1, p0, q0, q1, q2, q3, bS,
    164         pQ0[-2*Step], pQ0[-1*Step],pQ0[0*Step],pQ0[1*Step]);
    165 
    166 }
    167