Sigrid Haflínudóttirfix lots of warningsfbf22d96 years agoHistory
2425 lines · 78.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          h264bsdFilterPicture          FilterVerLumaEdge          FilterHorLumaEdge          FilterHorLuma          FilterVerChromaEdge          FilterHorChromaEdge          FilterHorChroma          InnerBoundaryStrength          EdgeBoundaryStrength          GetBoundaryStrengths          IsSliceBoundaryOnLeft          IsSliceBoundaryOnTop          GetMbFilteringFlags          GetLumaEdgeThresholds          GetChromaEdgeThresholds          FilterLuma          FilterChroma ------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------    1. Include headers------------------------------------------------------------------------------*/ #include "basetype.h"#include "h264bsd_util.h"#include "h264bsd_macroblock_layer.h"#include "h264bsd_deblocking.h"#include "h264bsd_dpb.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 */ /* array of alpha values, from the standard */static const u8 alphas[52] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,5,6,7,8,9,10,    12,13,15,17,20,22,25,28,32,36,40,45,50,56,63,71,80,90,101,113,127,144,162,    182,203,226,255,255}; /* array of beta values, from the standard */static const u8 betas[52] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,3,3,3,3,4,4,    4,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18};   #ifndef H264DEC_OMXDL/* array of tc0 values, from the standard, each triplet corresponds to a * column in the table. Indexing goes as tc0[indexA][bS-1] */static const u8 tc0[52][3] = {    {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},    {0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},{0,0,0},    {0,0,0},{0,0,1},{0,0,1},{0,0,1},{0,0,1},{0,1,1},{0,1,1},{1,1,1},    {1,1,1},{1,1,1},{1,1,1},{1,1,2},{1,1,2},{1,1,2},{1,1,2},{1,2,3},    {1,2,3},{2,2,3},{2,2,4},{2,3,4},{2,3,4},{3,3,5},{3,4,6},{3,4,6},    {4,5,7},{4,5,8},{4,6,9},{5,7,10},{6,8,11},{6,8,13},{7,10,14},{8,11,16},    {9,12,18},{10,13,20},{11,15,23},{13,17,25}};#else/* array of tc0 values, from the standard, each triplet corresponds to a * column in the table. Indexing goes as tc0[indexA][bS] */static const u8 tc0[52][5] = {    {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},    {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},    {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},    {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0},    {0, 0, 0, 0, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 0}, {0, 0, 0, 1, 0},    {0, 0, 0, 1, 0}, {0, 0, 1, 1, 0}, {0, 0, 1, 1, 0}, {0, 1, 1, 1, 0},    {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 1, 0}, {0, 1, 1, 2, 0},    {0, 1, 1, 2, 0}, {0, 1, 1, 2, 0}, {0, 1, 1, 2, 0}, {0, 1, 2, 3, 0},    {0, 1, 2, 3, 0}, {0, 2, 2, 3, 0}, {0, 2, 2, 4, 0}, {0, 2, 3, 4, 0},    {0, 2, 3, 4, 0}, {0, 3, 3, 5, 0}, {0, 3, 4, 6, 0}, {0, 3, 4, 6, 0},    {0, 4, 5, 7, 0}, {0, 4, 5, 8, 0}, {0, 4, 6, 9, 0}, {0, 5, 7, 10, 0},    {0, 6, 8, 11, 0}, {0, 6, 8, 13, 0}, {0, 7, 10, 14, 0},    {0, 8, 11, 16, 0}, {0, 9, 12, 18, 0}, {0, 10, 13, 20, 0},    {0, 11, 15, 23, 0}, {0, 13, 17, 25, 0}};#endif  #ifndef H264DEC_OMXDL/* mapping of raster scan block index to 4x4 block index */static const u32 mb4x4Index[16] =    {0, 1, 4, 5, 2, 3, 6, 7, 8, 9, 12, 13, 10, 11, 14, 15}; typedef struct {    const u8 *tc0;    u32 alpha;    u32 beta;} edgeThreshold_t; typedef struct {    u32 top;    u32 left;} bS_t; enum { TOP = 0, LEFT = 1, INNER = 2 };#endif /* H264DEC_OMXDL */ #define FILTER_LEFT_EDGE    0x04#define FILTER_TOP_EDGE     0x02#define FILTER_INNER_EDGE   0x01  /* clipping table defined in intra_prediction.c */extern const u8 h264bsdClip[]; /*------------------------------------------------------------------------------    4. Local function prototypes------------------------------------------------------------------------------*/ static u32 InnerBoundaryStrength(mbStorage_t *mb1, u32 i1, u32 i2); #ifndef H264DEC_OMXDLstatic u32 EdgeBoundaryStrength(mbStorage_t *mb1, mbStorage_t *mb2,    u32 i1, u32 i2);#elsestatic u32 InnerBoundaryStrength2(mbStorage_t *mb1, u32 i1, u32 i2);static u32 EdgeBoundaryStrengthLeft(mbStorage_t *mb1, mbStorage_t *mb2);static u32 EdgeBoundaryStrengthTop(mbStorage_t *mb1, mbStorage_t *mb2);#endif static u32 IsSliceBoundaryOnLeft(mbStorage_t *mb); static u32 IsSliceBoundaryOnTop(mbStorage_t *mb); static u32 GetMbFilteringFlags(mbStorage_t *mb); #ifndef H264DEC_OMXDL static u32 GetBoundaryStrengths(mbStorage_t *mb, bS_t *bs, u32 flags); static void FilterLuma(u8 *data, bS_t *bS, edgeThreshold_t *thresholds,        u32 imageWidth); static void FilterChroma(u8 *cb, u8 *cr, bS_t *bS, edgeThreshold_t *thresholds,        u32 imageWidth); static void FilterVerLumaEdge( u8 *data, u32 bS, edgeThreshold_t *thresholds,        u32 imageWidth);static void FilterHorLumaEdge( u8 *data, u32 bS, edgeThreshold_t *thresholds,        i32 imageWidth);static void FilterHorLuma( u8 *data, u32 bS, edgeThreshold_t *thresholds,        i32 imageWidth); static void FilterVerChromaEdge( u8 *data, u32 bS, edgeThreshold_t *thresholds,  u32 imageWidth);static void FilterHorChromaEdge( u8 *data, u32 bS, edgeThreshold_t *thresholds,  i32 imageWidth);static void FilterHorChroma( u8 *data, u32 bS, edgeThreshold_t *thresholds,  i32 imageWidth); static void GetLumaEdgeThresholds(  edgeThreshold_t *thresholds,  mbStorage_t *mb,  u32 filteringFlags); static void GetChromaEdgeThresholds(  edgeThreshold_t *thresholds,  mbStorage_t *mb,  u32 filteringFlags,  i32 chromaQpIndexOffset); #else /* H264DEC_OMXDL */ static u32 GetBoundaryStrengths(mbStorage_t *mb, u8 (*bs)[16], u32 flags); static void GetLumaEdgeThresholds(    mbStorage_t *mb,    u8 (*alpha)[2],    u8 (*beta)[2],    u8 (*threshold)[16],    u8 (*bs)[16],    u32 filteringFlags ); static void GetChromaEdgeThresholds(    mbStorage_t *mb,    u8 (*alpha)[2],    u8 (*beta)[2],    u8 (*threshold)[8],    u8 (*bs)[16],    u32 filteringFlags,    i32 chromaQpIndexOffset); #endif /* H264DEC_OMXDL */ /*------------------------------------------------------------------------------     Function: IsSliceBoundaryOnLeft         Functional description:            Function to determine if there is a slice boundary on the left side            of a macroblock. ------------------------------------------------------------------------------*/static u32 IsSliceBoundaryOnLeft(mbStorage_t *mb){ /* Variables */ /* Code */     ASSERT(mb && mb->mbA);     if (mb->sliceId != mb->mbA->sliceId)        return(HANTRO_TRUE);    else        return(HANTRO_FALSE); } /*------------------------------------------------------------------------------     Function: IsSliceBoundaryOnTop         Functional description:            Function to determine if there is a slice boundary above the            current macroblock. ------------------------------------------------------------------------------*/static u32 IsSliceBoundaryOnTop(mbStorage_t *mb){ /* Variables */ /* Code */     ASSERT(mb && mb->mbB);     if (mb->sliceId != mb->mbB->sliceId)        return(HANTRO_TRUE);    else        return(HANTRO_FALSE); } /*------------------------------------------------------------------------------     Function: GetMbFilteringFlags         Functional description:          Function to determine which edges of a macroblock has to be          filtered. Output is a bit-wise OR of FILTER_LEFT_EDGE,          FILTER_TOP_EDGE and FILTER_INNER_EDGE, depending on which edges          shall be filtered. ------------------------------------------------------------------------------*/static u32 GetMbFilteringFlags(mbStorage_t *mb){ /* Variables */     u32 flags = 0; /* Code */     ASSERT(mb);     /* nothing will be filtered if disableDeblockingFilterIdc == 1 */    if (mb->disableDeblockingFilterIdc != 1)    {        flags |= FILTER_INNER_EDGE;         /* filterLeftMbEdgeFlag, left mb is MB_A */        if (mb->mbA &&            ((mb->disableDeblockingFilterIdc != 2) ||             !IsSliceBoundaryOnLeft(mb)))            flags |= FILTER_LEFT_EDGE;         /* filterTopMbEdgeFlag */        if (mb->mbB &&            ((mb->disableDeblockingFilterIdc != 2) ||             !IsSliceBoundaryOnTop(mb)))            flags |= FILTER_TOP_EDGE;    }     return(flags); } /*------------------------------------------------------------------------------     Function: InnerBoundaryStrength         Functional description:            Function to calculate boundary strength value bs for an inner            edge of a macroblock. Macroblock type is checked before this is            called -> no intra mb condition here. ------------------------------------------------------------------------------*/static u32 InnerBoundaryStrength(mbStorage_t *mb1, u32 ind1, u32 ind2){    i32 tmp1, tmp2;    i32 mv1, mv2, mv3, mv4;     tmp1 = mb1->totalCoeff[ind1];    tmp2 = mb1->totalCoeff[ind2];    mv1 = mb1->mv[ind1].hor;    mv2 = mb1->mv[ind2].hor;    mv3 = mb1->mv[ind1].ver;    mv4 = mb1->mv[ind2].ver;     if (tmp1 || tmp2)    {        return 2;    }    else if ( ((u32)ABS(mv1 - mv2) >= 4) || ((u32)ABS(mv3 - mv4) >= 4) ||              (mb1->refAddr[ind1 >> 2] != mb1->refAddr[ind2 >> 2]) )    {        return 1;    }    else        return 0;} /*------------------------------------------------------------------------------     Function: InnerBoundaryStrength2         Functional description:            Function to calculate boundary strength value bs for an inner            edge of a macroblock. The function is the same as            InnerBoundaryStrength but without checking totalCoeff. ------------------------------------------------------------------------------*/u32 InnerBoundaryStrength2(mbStorage_t *mb1, u32 ind1, u32 ind2){    i32 tmp1, tmp2, tmp3, tmp4;     tmp1 = mb1->mv[ind1].hor;    tmp2 = mb1->mv[ind2].hor;    tmp3 = mb1->mv[ind1].ver;    tmp4 = mb1->mv[ind2].ver;     if ( ((u32)ABS(tmp1 - tmp2) >= 4) || ((u32)ABS(tmp3 - tmp4) >= 4) ||         (mb1->refAddr[ind1 >> 2] != mb1->refAddr[ind2 >> 2]))    {        return 1;    }    else        return 0;}#ifndef H264DEC_OMXDL/*------------------------------------------------------------------------------     Function: EdgeBoundaryStrength         Functional description:            Function to calculate boundary strength value bs for left- or            top-most edge of a macroblock. Macroblock types are checked            before this is called -> no intra mb conditions here. ------------------------------------------------------------------------------*/static u32 EdgeBoundaryStrength(mbStorage_t *mb1, mbStorage_t *mb2,    u32 ind1, u32 ind2){     if (mb1->totalCoeff[ind1] || mb2->totalCoeff[ind2])    {        return 2;    }    else if ((mb1->refAddr[ind1 >> 2] != mb2->refAddr[ind2 >> 2]) ||             ((u32)ABS(mb1->mv[ind1].hor - mb2->mv[ind2].hor) >= 4) ||             ((u32)ABS(mb1->mv[ind1].ver - mb2->mv[ind2].ver) >= 4))    {        return 1;    }    else        return 0;} #else /* H264DEC_OMXDL */ /*------------------------------------------------------------------------------     Function: EdgeBoundaryStrengthTop         Functional description:            Function to calculate boundary strength value bs for            top-most edge of a macroblock. Macroblock types are checked            before this is called -> no intra mb conditions here. ------------------------------------------------------------------------------*/u32 EdgeBoundaryStrengthTop(mbStorage_t *mb1, mbStorage_t *mb2){    u32 topBs = 0;    u32 tmp1, tmp2, tmp3, tmp4;     tmp1 = mb1->totalCoeff[0];    tmp2 = mb2->totalCoeff[10];    tmp3 = mb1->totalCoeff[1];    tmp4 = mb2->totalCoeff[11];    if (tmp1 || tmp2)    {        topBs = 2<<0;    }    else if (((u32)ABS(mb1->mv[0].hor - mb2->mv[10].hor) >= 4) ||             ((u32)ABS(mb1->mv[0].ver - mb2->mv[10].ver) >= 4) ||             (mb1->refAddr[0] != mb2->refAddr[10 >> 2]))    {        topBs = 1<<0;    }    tmp1 = mb1->totalCoeff[4];    tmp2 = mb2->totalCoeff[14];    if (tmp3 || tmp4)    {        topBs += 2<<8;    }    else if (((u32)ABS(mb1->mv[1].hor - mb2->mv[11].hor) >= 4) ||             ((u32)ABS(mb1->mv[1].ver - mb2->mv[11].ver) >= 4) ||             (mb1->refAddr[0] != mb2->refAddr[11 >> 2]))    {        topBs += 1<<8;    }    tmp3 = mb1->totalCoeff[5];    tmp4 = mb2->totalCoeff[15];    if (tmp1 || tmp2)    {        topBs += 2<<16;    }    else if (((u32)ABS(mb1->mv[4].hor - mb2->mv[14].hor) >= 4) ||             ((u32)ABS(mb1->mv[4].ver - mb2->mv[14].ver) >= 4) ||             (mb1->refAddr[4 >> 2] != mb2->refAddr[14 >> 2]))    {        topBs += 1<<16;    }    if (tmp3 || tmp4)    {        topBs += 2<<24;    }    else if (((u32)ABS(mb1->mv[5].hor - mb2->mv[15].hor) >= 4) ||             ((u32)ABS(mb1->mv[5].ver - mb2->mv[15].ver) >= 4) ||             (mb1->refAddr[5 >> 2] != mb2->refAddr[15 >> 2]))    {        topBs += 1<<24;    }     return topBs;} /*------------------------------------------------------------------------------     Function: EdgeBoundaryStrengthLeft         Functional description:            Function to calculate boundary strength value bs for left-            edge of a macroblock. Macroblock types are checked            before this is called -> no intra mb conditions here. ------------------------------------------------------------------------------*/u32 EdgeBoundaryStrengthLeft(mbStorage_t *mb1, mbStorage_t *mb2){    u32 leftBs = 0;    u32 tmp1, tmp2, tmp3, tmp4;     tmp1 = mb1->totalCoeff[0];    tmp2 = mb2->totalCoeff[5];    tmp3 = mb1->totalCoeff[2];    tmp4 = mb2->totalCoeff[7];

Lines 1–500 of 2425.

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