10c1bc742181ded4930842b46e9507372f0b1b963James Dong/* 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * Copyright (C) 2009 The Android Open Source Project 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * Licensed under the Apache License, Version 2.0 (the "License"); 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * you may not use this file except in compliance with the License. 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * You may obtain a copy of the License at 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * http://www.apache.org/licenses/LICENSE-2.0 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * Unless required by applicable law or agreed to in writing, software 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * distributed under the License is distributed on an "AS IS" BASIS, 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * See the License for the specific language governing permissions and 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * limitations under the License. 150c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 180c1bc742181ded4930842b46e9507372f0b1b963James Dong 190c1bc742181ded4930842b46e9507372f0b1b963James Dong Table of contents 200c1bc742181ded4930842b46e9507372f0b1b963James Dong 210c1bc742181ded4930842b46e9507372f0b1b963James Dong 1. Include headers 220c1bc742181ded4930842b46e9507372f0b1b963James Dong 2. External compiler flags 230c1bc742181ded4930842b46e9507372f0b1b963James Dong 3. Module defines 240c1bc742181ded4930842b46e9507372f0b1b963James Dong 4. Local function prototypes 250c1bc742181ded4930842b46e9507372f0b1b963James Dong 5. Functions 260c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdInitMbNeighbours 270c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdGetNeighbourMb 280c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdNeighbour4x4BlockA 290c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdNeighbour4x4BlockB 300c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdNeighbour4x4BlockC 310c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdNeighbour4x4BlockD 320c1bc742181ded4930842b46e9507372f0b1b963James Dong 330c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 340c1bc742181ded4930842b46e9507372f0b1b963James Dong 350c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 360c1bc742181ded4930842b46e9507372f0b1b963James Dong 1. Include headers 370c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 380c1bc742181ded4930842b46e9507372f0b1b963James Dong 390c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_neighbour.h" 400c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_util.h" 410c1bc742181ded4930842b46e9507372f0b1b963James Dong 420c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 430c1bc742181ded4930842b46e9507372f0b1b963James Dong 2. External compiler flags 440c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 450c1bc742181ded4930842b46e9507372f0b1b963James Dong 460c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 470c1bc742181ded4930842b46e9507372f0b1b963James Dong 3. Module defines 480c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 490c1bc742181ded4930842b46e9507372f0b1b963James Dong 500c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Following four tables indicate neighbours of each block of a macroblock. 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * First 16 values are for luma blocks, next 4 values for Cb and last 4 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * values for Cr. Elements of the table indicate to which macroblock the 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * neighbour block belongs and the index of the neighbour block in question. 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * Indexing of the blocks goes as follows 550c1bc742181ded4930842b46e9507372f0b1b963James Dong * 560c1bc742181ded4930842b46e9507372f0b1b963James Dong * Y Cb Cr 570c1bc742181ded4930842b46e9507372f0b1b963James Dong * 0 1 4 5 16 17 20 21 580c1bc742181ded4930842b46e9507372f0b1b963James Dong * 2 3 6 7 18 19 22 23 590c1bc742181ded4930842b46e9507372f0b1b963James Dong * 8 9 12 13 600c1bc742181ded4930842b46e9507372f0b1b963James Dong * 10 11 14 15 610c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 620c1bc742181ded4930842b46e9507372f0b1b963James Dong 630c1bc742181ded4930842b46e9507372f0b1b963James Dong/* left neighbour for each block */ 640c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic const neighbour_t N_A_4x4B[24] = { 650c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_A,5}, {MB_CURR,0}, {MB_A,7}, {MB_CURR,2}, 660c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,1}, {MB_CURR,4}, {MB_CURR,3}, {MB_CURR,6}, 670c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_A,13}, {MB_CURR,8}, {MB_A,15}, {MB_CURR,10}, 680c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,9}, {MB_CURR,12},{MB_CURR,11},{MB_CURR,14}, 690c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_A,17}, {MB_CURR,16},{MB_A,19}, {MB_CURR,18}, 700c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_A,21}, {MB_CURR,20},{MB_A,23}, {MB_CURR,22} }; 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong/* above neighbour for each block */ 730c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic const neighbour_t N_B_4x4B[24] = { 740c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,10}, {MB_B,11}, {MB_CURR,0}, {MB_CURR,1}, 750c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,14}, {MB_B,15}, {MB_CURR,4}, {MB_CURR,5}, 760c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,2}, {MB_CURR,3}, {MB_CURR,8}, {MB_CURR,9}, 770c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,6}, {MB_CURR,7}, {MB_CURR,12},{MB_CURR,13}, 780c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,18}, {MB_B,19}, {MB_CURR,16},{MB_CURR,17}, 790c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,22}, {MB_B,23}, {MB_CURR,20},{MB_CURR,21} }; 800c1bc742181ded4930842b46e9507372f0b1b963James Dong 810c1bc742181ded4930842b46e9507372f0b1b963James Dong/* above-right neighbour for each block */ 820c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic const neighbour_t N_C_4x4B[24] = { 830c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,11}, {MB_B,14}, {MB_CURR,1}, {MB_NA,4}, 840c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,15}, {MB_C,10}, {MB_CURR,5}, {MB_NA,0}, 850c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,3}, {MB_CURR,6}, {MB_CURR,9}, {MB_NA,12}, 860c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,7}, {MB_NA,2}, {MB_CURR,13},{MB_NA,8}, 870c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,19}, {MB_C,18}, {MB_CURR,17},{MB_NA,16}, 880c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,23}, {MB_C,22}, {MB_CURR,21},{MB_NA,20} }; 890c1bc742181ded4930842b46e9507372f0b1b963James Dong 900c1bc742181ded4930842b46e9507372f0b1b963James Dong/* above-left neighbour for each block */ 910c1bc742181ded4930842b46e9507372f0b1b963James Dongstatic const neighbour_t N_D_4x4B[24] = { 920c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_D,15}, {MB_B,10}, {MB_A,5}, {MB_CURR,0}, 930c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_B,11}, {MB_B,14}, {MB_CURR,1}, {MB_CURR,4}, 940c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_A,7}, {MB_CURR,2}, {MB_A,13}, {MB_CURR,8}, 950c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_CURR,3}, {MB_CURR,6}, {MB_CURR,9}, {MB_CURR,12}, 960c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_D,19}, {MB_B,18}, {MB_A,17}, {MB_CURR,16}, 970c1bc742181ded4930842b46e9507372f0b1b963James Dong {MB_D,23}, {MB_B,22}, {MB_A,21}, {MB_CURR,20} }; 980c1bc742181ded4930842b46e9507372f0b1b963James Dong 990c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong 4. Local function prototypes 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdInitMbNeighbours 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong Initialize macroblock neighbours. Function sets neighbour 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong macroblock pointers in macroblock structures to point to 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong macroblocks on the left, above, above-right and above-left. 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong Pointers are set NULL if the neighbour does not fit into the 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong picture. 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong picWidth width of the picture in macroblocks 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong picSizeInMbs no need to clarify 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage neighbour pointers of each mbStorage structure 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong stored here 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong none 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong 1270c1bc742181ded4930842b46e9507372f0b1b963James Dongvoid h264bsdInitMbNeighbours(mbStorage_t *pMbStorage, u32 picWidth, 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 picSizeInMbs) 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 i, row, col; 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pMbStorage); 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(picWidth); 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(picWidth <= picSizeInMbs); 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(((picSizeInMbs / picWidth) * picWidth) == picSizeInMbs); 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong row = col = 0; 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 0; i < picSizeInMbs; i++) 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong if (col) 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbA = pMbStorage + i - 1; 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbA = NULL; 1510c1bc742181ded4930842b46e9507372f0b1b963James Dong 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong if (row) 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbB = pMbStorage + i - picWidth; 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbB = NULL; 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong if (row && (col < picWidth - 1)) 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbC = pMbStorage + i - (picWidth - 1); 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbC = NULL; 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong if (row && col) 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbD = pMbStorage + i - (picWidth + 1); 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong else 1650c1bc742181ded4930842b46e9507372f0b1b963James Dong pMbStorage[i].mbD = NULL; 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong col++; 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong if (col == picWidth) 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong col = 0; 1710c1bc742181ded4930842b46e9507372f0b1b963James Dong row++; 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdGetNeighbourMb 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong Get pointer to neighbour macroblock. 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong pMb pointer to macroblock structure of the macroblock 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong whose neighbour is wanted 1870c1bc742181ded4930842b46e9507372f0b1b963James Dong neighbour indicates which neighbour is wanted 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong none 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong pointer to neighbour macroblock 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong NULL if not available 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 1970c1bc742181ded4930842b46e9507372f0b1b963James Dong 1980c1bc742181ded4930842b46e9507372f0b1b963James DongmbStorage_t* h264bsdGetNeighbourMb(mbStorage_t *pMb, neighbourMb_e neighbour) 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 2050c1bc742181ded4930842b46e9507372f0b1b963James Dong 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT((neighbour <= MB_CURR) || (neighbour == MB_NA)); 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong if (neighbour == MB_A) 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong return(pMb->mbA); 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (neighbour == MB_B) 2110c1bc742181ded4930842b46e9507372f0b1b963James Dong return(pMb->mbB); 2120c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (neighbour == MB_C) 2130c1bc742181ded4930842b46e9507372f0b1b963James Dong return(pMb->mbC); 2140c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (neighbour == MB_D) 2150c1bc742181ded4930842b46e9507372f0b1b963James Dong return(pMb->mbD); 2160c1bc742181ded4930842b46e9507372f0b1b963James Dong else if (neighbour == MB_CURR) 2170c1bc742181ded4930842b46e9507372f0b1b963James Dong return(pMb); 2180c1bc742181ded4930842b46e9507372f0b1b963James Dong else 2190c1bc742181ded4930842b46e9507372f0b1b963James Dong return(NULL); 2200c1bc742181ded4930842b46e9507372f0b1b963James Dong 2210c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2220c1bc742181ded4930842b46e9507372f0b1b963James Dong 2230c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 2240c1bc742181ded4930842b46e9507372f0b1b963James Dong 2250c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdNeighbour4x4BlockA 2260c1bc742181ded4930842b46e9507372f0b1b963James Dong 2270c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 2280c1bc742181ded4930842b46e9507372f0b1b963James Dong Get left neighbour of the block. Function returns pointer to 2290c1bc742181ded4930842b46e9507372f0b1b963James Dong the table defined in the beginning of the file. 2300c1bc742181ded4930842b46e9507372f0b1b963James Dong 2310c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 2320c1bc742181ded4930842b46e9507372f0b1b963James Dong blockIndex indicates the block whose neighbours are wanted 2330c1bc742181ded4930842b46e9507372f0b1b963James Dong 2340c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 2350c1bc742181ded4930842b46e9507372f0b1b963James Dong 2360c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 2370c1bc742181ded4930842b46e9507372f0b1b963James Dong pointer to neighbour structure 2380c1bc742181ded4930842b46e9507372f0b1b963James Dong 2390c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 2400c1bc742181ded4930842b46e9507372f0b1b963James Dong 2410c1bc742181ded4930842b46e9507372f0b1b963James Dongconst neighbour_t* h264bsdNeighbour4x4BlockA(u32 blockIndex) 2420c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 2430c1bc742181ded4930842b46e9507372f0b1b963James Dong 2440c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 2450c1bc742181ded4930842b46e9507372f0b1b963James Dong 2460c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 2470c1bc742181ded4930842b46e9507372f0b1b963James Dong 2480c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(blockIndex < 24); 2490c1bc742181ded4930842b46e9507372f0b1b963James Dong 2500c1bc742181ded4930842b46e9507372f0b1b963James Dong return(N_A_4x4B+blockIndex); 2510c1bc742181ded4930842b46e9507372f0b1b963James Dong 2520c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2530c1bc742181ded4930842b46e9507372f0b1b963James Dong 2540c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 2550c1bc742181ded4930842b46e9507372f0b1b963James Dong 2560c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdNeighbour4x4BlockB 2570c1bc742181ded4930842b46e9507372f0b1b963James Dong 2580c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 2590c1bc742181ded4930842b46e9507372f0b1b963James Dong Get above neighbour of the block. Function returns pointer to 2600c1bc742181ded4930842b46e9507372f0b1b963James Dong the table defined in the beginning of the file. 2610c1bc742181ded4930842b46e9507372f0b1b963James Dong 2620c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 2630c1bc742181ded4930842b46e9507372f0b1b963James Dong blockIndex indicates the block whose neighbours are wanted 2640c1bc742181ded4930842b46e9507372f0b1b963James Dong 2650c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 2660c1bc742181ded4930842b46e9507372f0b1b963James Dong 2670c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 2680c1bc742181ded4930842b46e9507372f0b1b963James Dong pointer to neighbour structure 2690c1bc742181ded4930842b46e9507372f0b1b963James Dong 2700c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 2710c1bc742181ded4930842b46e9507372f0b1b963James Dong 2720c1bc742181ded4930842b46e9507372f0b1b963James Dongconst neighbour_t* h264bsdNeighbour4x4BlockB(u32 blockIndex) 2730c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 2740c1bc742181ded4930842b46e9507372f0b1b963James Dong 2750c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 2760c1bc742181ded4930842b46e9507372f0b1b963James Dong 2770c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 2780c1bc742181ded4930842b46e9507372f0b1b963James Dong 2790c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(blockIndex < 24); 2800c1bc742181ded4930842b46e9507372f0b1b963James Dong 2810c1bc742181ded4930842b46e9507372f0b1b963James Dong return(N_B_4x4B+blockIndex); 2820c1bc742181ded4930842b46e9507372f0b1b963James Dong 2830c1bc742181ded4930842b46e9507372f0b1b963James Dong} 2840c1bc742181ded4930842b46e9507372f0b1b963James Dong 2850c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 2860c1bc742181ded4930842b46e9507372f0b1b963James Dong 2870c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdNeighbour4x4BlockC 2880c1bc742181ded4930842b46e9507372f0b1b963James Dong 2890c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 2900c1bc742181ded4930842b46e9507372f0b1b963James Dong Get above-right neighbour of the block. Function returns pointer 2910c1bc742181ded4930842b46e9507372f0b1b963James Dong to the table defined in the beginning of the file. 2920c1bc742181ded4930842b46e9507372f0b1b963James Dong 2930c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 2940c1bc742181ded4930842b46e9507372f0b1b963James Dong blockIndex indicates the block whose neighbours are wanted 2950c1bc742181ded4930842b46e9507372f0b1b963James Dong 2960c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 2970c1bc742181ded4930842b46e9507372f0b1b963James Dong 2980c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 2990c1bc742181ded4930842b46e9507372f0b1b963James Dong pointer to neighbour structure 3000c1bc742181ded4930842b46e9507372f0b1b963James Dong 3010c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 3020c1bc742181ded4930842b46e9507372f0b1b963James Dong 3030c1bc742181ded4930842b46e9507372f0b1b963James Dongconst neighbour_t* h264bsdNeighbour4x4BlockC(u32 blockIndex) 3040c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 3050c1bc742181ded4930842b46e9507372f0b1b963James Dong 3060c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 3070c1bc742181ded4930842b46e9507372f0b1b963James Dong 3080c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 3090c1bc742181ded4930842b46e9507372f0b1b963James Dong 3100c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(blockIndex < 24); 3110c1bc742181ded4930842b46e9507372f0b1b963James Dong 3120c1bc742181ded4930842b46e9507372f0b1b963James Dong return(N_C_4x4B+blockIndex); 3130c1bc742181ded4930842b46e9507372f0b1b963James Dong 3140c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3150c1bc742181ded4930842b46e9507372f0b1b963James Dong 3160c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 3170c1bc742181ded4930842b46e9507372f0b1b963James Dong 3180c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdNeighbour4x4BlockD 3190c1bc742181ded4930842b46e9507372f0b1b963James Dong 3200c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 3210c1bc742181ded4930842b46e9507372f0b1b963James Dong Get above-left neighbour of the block. Function returns pointer to 3220c1bc742181ded4930842b46e9507372f0b1b963James Dong the table defined in the beginning of the file. 3230c1bc742181ded4930842b46e9507372f0b1b963James Dong 3240c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 3250c1bc742181ded4930842b46e9507372f0b1b963James Dong blockIndex indicates the block whose neighbours are wanted 3260c1bc742181ded4930842b46e9507372f0b1b963James Dong 3270c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 3280c1bc742181ded4930842b46e9507372f0b1b963James Dong 3290c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 3300c1bc742181ded4930842b46e9507372f0b1b963James Dong pointer to neighbour structure 3310c1bc742181ded4930842b46e9507372f0b1b963James Dong 3320c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 3330c1bc742181ded4930842b46e9507372f0b1b963James Dong 3340c1bc742181ded4930842b46e9507372f0b1b963James Dongconst neighbour_t* h264bsdNeighbour4x4BlockD(u32 blockIndex) 3350c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 3360c1bc742181ded4930842b46e9507372f0b1b963James Dong 3370c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 3380c1bc742181ded4930842b46e9507372f0b1b963James Dong 3390c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 3400c1bc742181ded4930842b46e9507372f0b1b963James Dong 3410c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(blockIndex < 24); 3420c1bc742181ded4930842b46e9507372f0b1b963James Dong 3430c1bc742181ded4930842b46e9507372f0b1b963James Dong return(N_D_4x4B+blockIndex); 3440c1bc742181ded4930842b46e9507372f0b1b963James Dong 3450c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3460c1bc742181ded4930842b46e9507372f0b1b963James Dong 3470c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 3480c1bc742181ded4930842b46e9507372f0b1b963James Dong 3490c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdIsNeighbourAvailable 3500c1bc742181ded4930842b46e9507372f0b1b963James Dong 3510c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 3520c1bc742181ded4930842b46e9507372f0b1b963James Dong Check if neighbour macroblock is available. Neighbour macroblock 3530c1bc742181ded4930842b46e9507372f0b1b963James Dong is considered available if it is within the picture and belongs 3540c1bc742181ded4930842b46e9507372f0b1b963James Dong to the same slice as the current macroblock. 3550c1bc742181ded4930842b46e9507372f0b1b963James Dong 3560c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 3570c1bc742181ded4930842b46e9507372f0b1b963James Dong pMb pointer to the current macroblock 3580c1bc742181ded4930842b46e9507372f0b1b963James Dong pNeighbour pointer to the neighbour macroblock 3590c1bc742181ded4930842b46e9507372f0b1b963James Dong 3600c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 3610c1bc742181ded4930842b46e9507372f0b1b963James Dong none 3620c1bc742181ded4930842b46e9507372f0b1b963James Dong 3630c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 3640c1bc742181ded4930842b46e9507372f0b1b963James Dong TRUE neighbour is available 3650c1bc742181ded4930842b46e9507372f0b1b963James Dong FALSE neighbour is not available 3660c1bc742181ded4930842b46e9507372f0b1b963James Dong 3670c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 3680c1bc742181ded4930842b46e9507372f0b1b963James Dong 3690c1bc742181ded4930842b46e9507372f0b1b963James Dongu32 h264bsdIsNeighbourAvailable(mbStorage_t *pMb, mbStorage_t *pNeighbour) 3700c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 3710c1bc742181ded4930842b46e9507372f0b1b963James Dong 3720c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 3730c1bc742181ded4930842b46e9507372f0b1b963James Dong 3740c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 3750c1bc742181ded4930842b46e9507372f0b1b963James Dong 3760c1bc742181ded4930842b46e9507372f0b1b963James Dong if ( (pNeighbour == NULL) || (pMb->sliceId != pNeighbour->sliceId) ) 3770c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_FALSE); 3780c1bc742181ded4930842b46e9507372f0b1b963James Dong else 3790c1bc742181ded4930842b46e9507372f0b1b963James Dong return(HANTRO_TRUE); 3800c1bc742181ded4930842b46e9507372f0b1b963James Dong 3810c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3820c1bc742181ded4930842b46e9507372f0b1b963James Dong 383