Sigrid Haflínudóttirfix lots of warningsfbf22d96 years agoHistory
2366 lines · 64.8 KB · C
RawDownload
/* * Copyright (C) 2009 The Android Open Source Project * Modified for use by h264bsd standalone library * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *      http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /*------------------------------------------------------------------------------     Table of contents      1. Include headers     2. External compiler flags     3. Module defines     4. Local function prototypes     5. Functions ------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------    1. Include headers------------------------------------------------------------------------------*/ #include "basetype.h"#include "h264bsd_reconstruct.h"#include "h264bsd_macroblock_layer.h"#include "h264bsd_image.h"#include "h264bsd_util.h" #ifdef H264DEC_OMXDL#include "omxtypes.h"#include "omxVC.h"#include "armVC.h"#endif /* H264DEC_OMXDL */ /*------------------------------------------------------------------------------    2. External compiler flags-------------------------------------------------------------------------------- --------------------------------------------------------------------------------    3. Module defines------------------------------------------------------------------------------*/ /* Switch off the following Lint messages for this file: * Info 701: Shift left of signed quantity (int) * Info 702: Shift right of signed quantity (int) *//*lint -e701 -e702 */ /* Luma fractional-sample positions * *  G a b c H *  d e f g *  h i j k m *  n p q r *  M   s   N * *  G, H, M and N are integer sample positions *  a-s are fractional samples that need to be interpolated. */#ifndef H264DEC_OMXDLstatic const u32 lumaFracPos[4][4] = {  /* G  d  h  n    a  e  i  p    b  f  j   q     c   g   k   r */    {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15}};#endif /* H264DEC_OMXDL */ /* clipping table, defined in h264bsd_intra_prediction.c */extern const u8 h264bsdClip[]; /*------------------------------------------------------------------------------    4. Local function prototypes------------------------------------------------------------------------------*/ #ifndef H264DEC_OMXDL /*------------------------------------------------------------------------------     Function: h264bsdInterpolateChromaHor         Functional description:          This function performs chroma interpolation in horizontal direction.          Overfilling is done only if needed. Reference image (pRef) is          read at correct position and the predicted part is written to          macroblock's chrominance (predPartChroma)        Inputs:          pRef              pointer to reference frame Cb top-left corner          x0                integer x-coordinate for prediction          y0                integer y-coordinate for prediction          width             width of the reference frame chrominance in pixels          height            height of the reference frame chrominance in pixels          xFrac             horizontal fraction for prediction in 1/8 pixels          chromaPartWidth   width of the predicted part in pixels          chromaPartHeight  height of the predicted part in pixels        Outputs:          predPartChroma    pointer where predicted part is written ------------------------------------------------------------------------------*/#ifndef H264DEC_ARM11void h264bsdInterpolateChromaHor(  u8 *pRef,  u8 *predPartChroma,  i32 x0,  i32 y0,  u32 width,  u32 height,  u32 xFrac,  u32 chromaPartWidth,  u32 chromaPartHeight){ /* Variables */     u32 x, y, tmp1, tmp2, tmp3, tmp4, c, val;    u8 *ptrA, *cbr;    u32 comp;    u8 block[9*8*2]; /* Code */     ASSERT(predPartChroma);    ASSERT(chromaPartWidth);    ASSERT(chromaPartHeight);    ASSERT(xFrac < 8);    ASSERT(pRef);     if ((x0 < 0) || ((u32)x0+chromaPartWidth+1 > width) ||        (y0 < 0) || ((u32)y0+chromaPartHeight > height))    {        h264bsdFillBlock(pRef, block, x0, y0, width, height,            chromaPartWidth + 1, chromaPartHeight, chromaPartWidth + 1);        pRef += width * height;        h264bsdFillBlock(pRef, block + (chromaPartWidth+1)*chromaPartHeight,            x0, y0, width, height, chromaPartWidth + 1,            chromaPartHeight, chromaPartWidth + 1);         pRef = block;        x0 = 0;        y0 = 0;        width = chromaPartWidth+1;        height = chromaPartHeight;    }     val = 8 - xFrac;     for (comp = 0; comp <= 1; comp++)    {         ptrA = pRef + (comp * height + (u32)y0) * width + x0;        cbr = predPartChroma + comp * 8 * 8;         /* 2x2 pels per iteration         * bilinear horizontal interpolation */        for (y = (chromaPartHeight >> 1); y; y--)        {            for (x = (chromaPartWidth >> 1); x; x--)            {                tmp1 = ptrA[width];                tmp2 = *ptrA++;                tmp3 = ptrA[width];                tmp4 = *ptrA++;                c = ((val * tmp1 + xFrac * tmp3) << 3) + 32;                c >>= 6;                cbr[8] = (u8)c;                c = ((val * tmp2 + xFrac * tmp4) << 3) + 32;                c >>= 6;                *cbr++ = (u8)c;                tmp1 = ptrA[width];                tmp2 = *ptrA;                c = ((val * tmp3 + xFrac * tmp1) << 3) + 32;                c >>= 6;                cbr[8] = (u8)c;                c = ((val * tmp4 + xFrac * tmp2) << 3) + 32;                c >>= 6;                *cbr++ = (u8)c;            }            cbr += 2*8 - chromaPartWidth;            ptrA += 2*width - chromaPartWidth;        }    } } /*------------------------------------------------------------------------------     Function: h264bsdInterpolateChromaVer         Functional description:          This function performs chroma interpolation in vertical direction.          Overfilling is done only if needed. Reference image (pRef) is          read at correct position and the predicted part is written to          macroblock's chrominance (predPartChroma) ------------------------------------------------------------------------------*/ void h264bsdInterpolateChromaVer(  u8 *pRef,  u8 *predPartChroma,  i32 x0,  i32 y0,  u32 width,  u32 height,  u32 yFrac,  u32 chromaPartWidth,  u32 chromaPartHeight){ /* Variables */     u32 x, y, tmp1, tmp2, tmp3, c, val;    u8 *ptrA, *cbr;    u32 comp;    u8 block[9*8*2]; /* Code */     ASSERT(predPartChroma);    ASSERT(chromaPartWidth);    ASSERT(chromaPartHeight);    ASSERT(yFrac < 8);    ASSERT(pRef);     if ((x0 < 0) || ((u32)x0+chromaPartWidth > width) ||        (y0 < 0) || ((u32)y0+chromaPartHeight+1 > height))    {        h264bsdFillBlock(pRef, block, x0, y0, width, height, chromaPartWidth,            chromaPartHeight + 1, chromaPartWidth);        pRef += width * height;        h264bsdFillBlock(pRef, block + chromaPartWidth*(chromaPartHeight+1),            x0, y0, width, height, chromaPartWidth,            chromaPartHeight + 1, chromaPartWidth);         pRef = block;        x0 = 0;        y0 = 0;        width = chromaPartWidth;        height = chromaPartHeight+1;    }     val = 8 - yFrac;     for (comp = 0; comp <= 1; comp++)    {         ptrA = pRef + (comp * height + (u32)y0) * width + x0;        cbr = predPartChroma + comp * 8 * 8;         /* 2x2 pels per iteration         * bilinear vertical interpolation */        for (y = (chromaPartHeight >> 1); y; y--)        {            for (x = (chromaPartWidth >> 1); x; x--)            {                tmp3 = ptrA[width*2];                tmp2 = ptrA[width];                tmp1 = *ptrA++;                c = ((val * tmp2 + yFrac * tmp3) << 3) + 32;                c >>= 6;                cbr[8] = (u8)c;                c = ((val * tmp1 + yFrac * tmp2) << 3) + 32;                c >>= 6;                *cbr++ = (u8)c;                tmp3 = ptrA[width*2];                tmp2 = ptrA[width];                tmp1 = *ptrA++;                c = ((val * tmp2 + yFrac * tmp3) << 3) + 32;                c >>= 6;                cbr[8] = (u8)c;                c = ((val * tmp1 + yFrac * tmp2) << 3) + 32;                c >>= 6;                *cbr++ = (u8)c;            }            cbr += 2*8 - chromaPartWidth;            ptrA += 2*width - chromaPartWidth;        }    } }#endif/*------------------------------------------------------------------------------     Function: h264bsdInterpolateChromaHorVer         Functional description:          This function performs chroma interpolation in horizontal and          vertical direction. Overfilling is done only if needed. Reference          image (ref) is read at correct position and the predicted part          is written to macroblock's chrominance (predPartChroma) ------------------------------------------------------------------------------*/ void h264bsdInterpolateChromaHorVer(  u8 *ref,  u8 *predPartChroma,  i32 x0,  i32 y0,  u32 width,  u32 height,  u32 xFrac,  u32 yFrac,  u32 chromaPartWidth,  u32 chromaPartHeight){    u8 block[9*9*2];    u32 x, y, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, valX, valY, plus32 = 32;    u32 comp;    u8 *ptrA, *cbr; /* Code */     ASSERT(predPartChroma);    ASSERT(chromaPartWidth);    ASSERT(chromaPartHeight);    ASSERT(xFrac < 8);    ASSERT(yFrac < 8);    ASSERT(ref);     if ((x0 < 0) || ((u32)x0+chromaPartWidth+1 > width) ||        (y0 < 0) || ((u32)y0+chromaPartHeight+1 > height))    {        h264bsdFillBlock(ref, block, x0, y0, width, height,            chromaPartWidth + 1, chromaPartHeight + 1, chromaPartWidth + 1);        ref += width * height;        h264bsdFillBlock(ref, block + (chromaPartWidth+1)*(chromaPartHeight+1),            x0, y0, width, height, chromaPartWidth + 1,            chromaPartHeight + 1, chromaPartWidth + 1);         ref = block;        x0 = 0;        y0 = 0;        width = chromaPartWidth+1;        height = chromaPartHeight+1;    }     valX = 8 - xFrac;    valY = 8 - yFrac;     for (comp = 0; comp <= 1; comp++)    {         ptrA = ref + (comp * height + (u32)y0) * width + x0;        cbr = predPartChroma + comp * 8 * 8;         /* 2x2 pels per iteration         * bilinear vertical and horizontal interpolation */        for (y = (chromaPartHeight >> 1); y; y--)        {            tmp1 = *ptrA;            tmp3 = ptrA[width];            tmp5 = ptrA[width*2];            tmp1 *= valY;            tmp1 += tmp3 * yFrac;            tmp3 *= valY;            tmp3 += tmp5 * yFrac;            for (x = (chromaPartWidth >> 1); x; x--)            {                tmp2 = *++ptrA;                tmp4 = ptrA[width];                tmp6 = ptrA[width*2];                tmp2 *= valY;                tmp2 += tmp4 * yFrac;                tmp4 *= valY;                tmp4 += tmp6 * yFrac;                tmp1 = tmp1 * valX + plus32;                tmp3 = tmp3 * valX + plus32;                tmp1 += tmp2 * xFrac;                tmp1 >>= 6;                tmp3 += tmp4 * xFrac;                tmp3 >>= 6;                cbr[8] = (u8)tmp3;                *cbr++ = (u8)tmp1;                 tmp1 = *++ptrA;                tmp3 = ptrA[width];                tmp5 = ptrA[width*2];                tmp1 *= valY;                tmp1 += tmp3 * yFrac;                tmp3 *= valY;                tmp3 += tmp5 * yFrac;                tmp2 = tmp2 * valX + plus32;                tmp4 = tmp4 * valX + plus32;                tmp2 += tmp1 * xFrac;                tmp2 >>= 6;                tmp4 += tmp3 * xFrac;                tmp4 >>= 6;                cbr[8] = (u8)tmp4;                *cbr++ = (u8)tmp2;            }            cbr += 2*8 - chromaPartWidth;            ptrA += 2*width - chromaPartWidth;        }    } } /*------------------------------------------------------------------------------     Function: PredictChroma         Functional description:          Top level chroma prediction function that calls the appropriate          interpolation function. The output is written to macroblock array. ------------------------------------------------------------------------------*/ static void PredictChroma(  u8 *mbPartChroma,  u32 xAL,  u32 yAL,  u32 partWidth,  u32 partHeight,  mv_t *mv,  image_t *refPic){ /* Variables */     u32 xFrac, yFrac, width, height, chromaPartWidth, chromaPartHeight;    i32 xInt, yInt;    u8 *ref; /* Code */     ASSERT(mv);    ASSERT(refPic);    ASSERT(refPic->data);    ASSERT(refPic->width);    ASSERT(refPic->height);     width  = 8 * refPic->width;    height = 8 * refPic->height;     xInt = (xAL >> 1) + (mv->hor >> 3);    yInt = (yAL >> 1) + (mv->ver >> 3);    xFrac = mv->hor & 0x7;    yFrac = mv->ver & 0x7;     chromaPartWidth  = partWidth >> 1;    chromaPartHeight = partHeight >> 1;    ref = refPic->data + 256 * refPic->width * refPic->height;     if (xFrac && yFrac)    {        h264bsdInterpolateChromaHorVer(ref, mbPartChroma, xInt, yInt, width,                height, xFrac, yFrac, chromaPartWidth, chromaPartHeight);    }    else if (xFrac)    {        h264bsdInterpolateChromaHor(ref, mbPartChroma, xInt, yInt, width,                height, xFrac, chromaPartWidth, chromaPartHeight);    }    else if (yFrac)    {        h264bsdInterpolateChromaVer(ref, mbPartChroma, xInt, yInt, width,                height, yFrac, chromaPartWidth, chromaPartHeight);    }    else    {        h264bsdFillBlock(ref, mbPartChroma, xInt, yInt, width, height,            chromaPartWidth, chromaPartHeight, 8);        ref += width * height;        h264bsdFillBlock(ref, mbPartChroma + 8*8, xInt, yInt, width, height,            chromaPartWidth, chromaPartHeight, 8);    } }  /*------------------------------------------------------------------------------     Function: h264bsdInterpolateVerHalf         Functional description:          Function to perform vertical interpolation of pixel position 'h'          for a block. Overfilling is done only if needed. Reference          image (ref) is read at correct position and the predicted part          is written to macroblock array (mb) ------------------------------------------------------------------------------*/#ifndef H264DEC_ARM11void h264bsdInterpolateVerHalf(  u8 *ref,  u8 *mb,  i32 x0,  i32 y0,  u32 width,  u32 height,  u32 partWidth,  u32 partHeight){    u32 p1[21*21/4+1];

Lines 1–500 of 2366.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t