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 h264bsdWriteMacroblock 270c1bc742181ded4930842b46e9507372f0b1b963James Dong h264bsdWriteOutputBlocks 280c1bc742181ded4930842b46e9507372f0b1b963James Dong 290c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 300c1bc742181ded4930842b46e9507372f0b1b963James Dong 310c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 320c1bc742181ded4930842b46e9507372f0b1b963James Dong 1. Include headers 330c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 340c1bc742181ded4930842b46e9507372f0b1b963James Dong 350c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_image.h" 360c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_util.h" 370c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "h264bsd_neighbour.h" 380c1bc742181ded4930842b46e9507372f0b1b963James Dong 390c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 400c1bc742181ded4930842b46e9507372f0b1b963James Dong 2. External compiler flags 410c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 420c1bc742181ded4930842b46e9507372f0b1b963James Dong 430c1bc742181ded4930842b46e9507372f0b1b963James Dong-------------------------------------------------------------------------------- 440c1bc742181ded4930842b46e9507372f0b1b963James Dong 3. Module defines 450c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 460c1bc742181ded4930842b46e9507372f0b1b963James Dong 470c1bc742181ded4930842b46e9507372f0b1b963James Dong/* x- and y-coordinates for each block, defined in h264bsd_intra_prediction.c */ 480c1bc742181ded4930842b46e9507372f0b1b963James Dongextern const u32 h264bsdBlockX[]; 490c1bc742181ded4930842b46e9507372f0b1b963James Dongextern const u32 h264bsdBlockY[]; 500c1bc742181ded4930842b46e9507372f0b1b963James Dong 510c1bc742181ded4930842b46e9507372f0b1b963James Dong/* clipping table, defined in h264bsd_intra_prediction.c */ 520c1bc742181ded4930842b46e9507372f0b1b963James Dongextern const u8 h264bsdClip[]; 530c1bc742181ded4930842b46e9507372f0b1b963James Dong 540c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 550c1bc742181ded4930842b46e9507372f0b1b963James Dong 4. Local function prototypes 560c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 570c1bc742181ded4930842b46e9507372f0b1b963James Dong 580c1bc742181ded4930842b46e9507372f0b1b963James Dong 590c1bc742181ded4930842b46e9507372f0b1b963James Dong 600c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 610c1bc742181ded4930842b46e9507372f0b1b963James Dong 620c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdWriteMacroblock 630c1bc742181ded4930842b46e9507372f0b1b963James Dong 640c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 650c1bc742181ded4930842b46e9507372f0b1b963James Dong Write one macroblock into the image. Both luma and chroma 660c1bc742181ded4930842b46e9507372f0b1b963James Dong components will be written at the same time. 670c1bc742181ded4930842b46e9507372f0b1b963James Dong 680c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 690c1bc742181ded4930842b46e9507372f0b1b963James Dong data pointer to macroblock data to be written, 256 values for 700c1bc742181ded4930842b46e9507372f0b1b963James Dong luma followed by 64 values for both chroma components 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 730c1bc742181ded4930842b46e9507372f0b1b963James Dong image pointer to the image where the macroblock will be written 740c1bc742181ded4930842b46e9507372f0b1b963James Dong 750c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 760c1bc742181ded4930842b46e9507372f0b1b963James Dong none 770c1bc742181ded4930842b46e9507372f0b1b963James Dong 780c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 790c1bc742181ded4930842b46e9507372f0b1b963James Dong#ifndef H264DEC_NEON 800c1bc742181ded4930842b46e9507372f0b1b963James Dongvoid h264bsdWriteMacroblock(image_t *image, u8 *data) 810c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 820c1bc742181ded4930842b46e9507372f0b1b963James Dong 830c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 840c1bc742181ded4930842b46e9507372f0b1b963James Dong 850c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 i; 860c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 width; 870c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *lum, *cb, *cr; 880c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 *ptr; 890c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 tmp1, tmp2; 900c1bc742181ded4930842b46e9507372f0b1b963James Dong 910c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 920c1bc742181ded4930842b46e9507372f0b1b963James Dong 930c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(image); 940c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(data); 950c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)data&0x3)); 960c1bc742181ded4930842b46e9507372f0b1b963James Dong 970c1bc742181ded4930842b46e9507372f0b1b963James Dong width = image->width; 980c1bc742181ded4930842b46e9507372f0b1b963James Dong 990c1bc742181ded4930842b46e9507372f0b1b963James Dong /*lint -save -e826 lum, cb and cr used to copy 4 bytes at the time, disable 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong * "area too small" info message */ 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong lum = (u32*)image->luma; 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong cb = (u32*)image->cb; 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong cr = (u32*)image->cr; 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)lum&0x3)); 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)cb&0x3)); 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)cr&0x3)); 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong ptr = (u32*)data; 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong width *= 4; 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 16; i ; i--) 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *ptr++; 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *ptr++; 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong *lum++ = tmp1; 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong *lum++ = tmp2; 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *ptr++; 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *ptr++; 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong *lum++ = tmp1; 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong *lum++ = tmp2; 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong lum += width-4; 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong width >>= 1; 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 8; i ; i--) 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *ptr++; 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *ptr++; 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong *cb++ = tmp1; 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong *cb++ = tmp2; 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong cb += width-2; 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 8; i ; i--) 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *ptr++; 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *ptr++; 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong *cr++ = tmp1; 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong *cr++ = tmp2; 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong cr += width-2; 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong#endif 1450c1bc742181ded4930842b46e9507372f0b1b963James Dong#ifndef H264DEC_OMXDL 1460c1bc742181ded4930842b46e9507372f0b1b963James Dong/*------------------------------------------------------------------------------ 1470c1bc742181ded4930842b46e9507372f0b1b963James Dong 1480c1bc742181ded4930842b46e9507372f0b1b963James Dong Function: h264bsdWriteOutputBlocks 1490c1bc742181ded4930842b46e9507372f0b1b963James Dong 1500c1bc742181ded4930842b46e9507372f0b1b963James Dong Functional description: 1510c1bc742181ded4930842b46e9507372f0b1b963James Dong Write one macroblock into the image. Prediction for the macroblock 1520c1bc742181ded4930842b46e9507372f0b1b963James Dong and the residual are given separately and will be combined while 1530c1bc742181ded4930842b46e9507372f0b1b963James Dong writing the data to the image 1540c1bc742181ded4930842b46e9507372f0b1b963James Dong 1550c1bc742181ded4930842b46e9507372f0b1b963James Dong Inputs: 1560c1bc742181ded4930842b46e9507372f0b1b963James Dong data pointer to macroblock prediction data, 256 values for 1570c1bc742181ded4930842b46e9507372f0b1b963James Dong luma followed by 64 values for both chroma components 1580c1bc742181ded4930842b46e9507372f0b1b963James Dong mbNum number of the macroblock 1590c1bc742181ded4930842b46e9507372f0b1b963James Dong residual pointer to residual data, 16 16-element arrays for luma 1600c1bc742181ded4930842b46e9507372f0b1b963James Dong followed by 4 16-element arrays for both chroma 1610c1bc742181ded4930842b46e9507372f0b1b963James Dong components 1620c1bc742181ded4930842b46e9507372f0b1b963James Dong 1630c1bc742181ded4930842b46e9507372f0b1b963James Dong Outputs: 1640c1bc742181ded4930842b46e9507372f0b1b963James Dong image pointer to the image where the data will be written 1650c1bc742181ded4930842b46e9507372f0b1b963James Dong 1660c1bc742181ded4930842b46e9507372f0b1b963James Dong Returns: 1670c1bc742181ded4930842b46e9507372f0b1b963James Dong none 1680c1bc742181ded4930842b46e9507372f0b1b963James Dong 1690c1bc742181ded4930842b46e9507372f0b1b963James Dong------------------------------------------------------------------------------*/ 1700c1bc742181ded4930842b46e9507372f0b1b963James Dong 1710c1bc742181ded4930842b46e9507372f0b1b963James Dongvoid h264bsdWriteOutputBlocks(image_t *image, u32 mbNum, u8 *data, 1720c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 residual[][16]) 1730c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 1740c1bc742181ded4930842b46e9507372f0b1b963James Dong 1750c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Variables */ 1760c1bc742181ded4930842b46e9507372f0b1b963James Dong 1770c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 i; 1780c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 picWidth, picSize; 1790c1bc742181ded4930842b46e9507372f0b1b963James Dong u8 *lum, *cb, *cr; 1800c1bc742181ded4930842b46e9507372f0b1b963James Dong u8 *imageBlock; 1810c1bc742181ded4930842b46e9507372f0b1b963James Dong u8 *tmp; 1820c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 row, col; 1830c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 block; 1840c1bc742181ded4930842b46e9507372f0b1b963James Dong u32 x, y; 1850c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *pRes; 1860c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 tmp1, tmp2, tmp3, tmp4; 1870c1bc742181ded4930842b46e9507372f0b1b963James Dong const u8 *clp = h264bsdClip + 512; 1880c1bc742181ded4930842b46e9507372f0b1b963James Dong 1890c1bc742181ded4930842b46e9507372f0b1b963James Dong/* Code */ 1900c1bc742181ded4930842b46e9507372f0b1b963James Dong 1910c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(image); 1920c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(data); 1930c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(mbNum < image->width * image->height); 1940c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)data&0x3)); 1950c1bc742181ded4930842b46e9507372f0b1b963James Dong 1960c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Image size in macroblocks */ 1970c1bc742181ded4930842b46e9507372f0b1b963James Dong picWidth = image->width; 1980c1bc742181ded4930842b46e9507372f0b1b963James Dong picSize = picWidth * image->height; 1990c1bc742181ded4930842b46e9507372f0b1b963James Dong row = mbNum / picWidth; 2000c1bc742181ded4930842b46e9507372f0b1b963James Dong col = mbNum % picWidth; 2010c1bc742181ded4930842b46e9507372f0b1b963James Dong 2020c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Output macroblock position in output picture */ 2030c1bc742181ded4930842b46e9507372f0b1b963James Dong lum = (image->data + row * picWidth * 256 + col * 16); 2040c1bc742181ded4930842b46e9507372f0b1b963James Dong cb = (image->data + picSize * 256 + row * picWidth * 64 + col * 8); 2050c1bc742181ded4930842b46e9507372f0b1b963James Dong cr = (cb + picSize * 64); 2060c1bc742181ded4930842b46e9507372f0b1b963James Dong 2070c1bc742181ded4930842b46e9507372f0b1b963James Dong picWidth *= 16; 2080c1bc742181ded4930842b46e9507372f0b1b963James Dong 2090c1bc742181ded4930842b46e9507372f0b1b963James Dong for (block = 0; block < 16; block++) 2100c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2110c1bc742181ded4930842b46e9507372f0b1b963James Dong x = h264bsdBlockX[block]; 2120c1bc742181ded4930842b46e9507372f0b1b963James Dong y = h264bsdBlockY[block]; 2130c1bc742181ded4930842b46e9507372f0b1b963James Dong 2140c1bc742181ded4930842b46e9507372f0b1b963James Dong pRes = residual[block]; 2150c1bc742181ded4930842b46e9507372f0b1b963James Dong 2160c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pRes); 2170c1bc742181ded4930842b46e9507372f0b1b963James Dong 2180c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = data + y*16 + x; 2190c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock = lum + y*picWidth + x; 2200c1bc742181ded4930842b46e9507372f0b1b963James Dong 2210c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)tmp&0x3)); 2220c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)imageBlock&0x3)); 2230c1bc742181ded4930842b46e9507372f0b1b963James Dong 2240c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_RESIDUAL_EMPTY(pRes)) 2250c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2260c1bc742181ded4930842b46e9507372f0b1b963James Dong /*lint -e826 */ 2270c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *in32 = (i32*)tmp; 2280c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *out32 = (i32*)imageBlock; 2290c1bc742181ded4930842b46e9507372f0b1b963James Dong 2300c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Residual is zero => copy prediction block to output */ 2310c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *in32; in32 += 4; 2320c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *in32; in32 += 4; 2330c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp1; out32 += picWidth/4; 2340c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp2; out32 += picWidth/4; 2350c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *in32; in32 += 4; 2360c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *in32; 2370c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp1; out32 += picWidth/4; 2380c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp2; 2390c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2400c1bc742181ded4930842b46e9507372f0b1b963James Dong else 2410c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2420c1bc742181ded4930842b46e9507372f0b1b963James Dong 2430c1bc742181ded4930842b46e9507372f0b1b963James Dong RANGE_CHECK_ARRAY(pRes, -512, 511, 16); 2440c1bc742181ded4930842b46e9507372f0b1b963James Dong 2450c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Calculate image = prediction + residual 2460c1bc742181ded4930842b46e9507372f0b1b963James Dong * Process four pixels in a loop */ 2470c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 4; i; i--) 2480c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2490c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = tmp[0]; 2500c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *pRes++; 2510c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = tmp[1]; 2520c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = clp[tmp1 + tmp2]; 2530c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp4 = *pRes++; 2540c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[0] = (u8)tmp1; 2550c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = clp[tmp3 + tmp4]; 2560c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = tmp[2]; 2570c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *pRes++; 2580c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[1] = (u8)tmp3; 2590c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = clp[tmp1 + tmp2]; 2600c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = tmp[3]; 2610c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp4 = *pRes++; 2620c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[2] = (u8)tmp1; 2630c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = clp[tmp3 + tmp4]; 2640c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp += 16; 2650c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[3] = (u8)tmp3; 2660c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock += picWidth; 2670c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2680c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2690c1bc742181ded4930842b46e9507372f0b1b963James Dong 2700c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2710c1bc742181ded4930842b46e9507372f0b1b963James Dong 2720c1bc742181ded4930842b46e9507372f0b1b963James Dong picWidth /= 2; 2730c1bc742181ded4930842b46e9507372f0b1b963James Dong 2740c1bc742181ded4930842b46e9507372f0b1b963James Dong for (block = 16; block <= 23; block++) 2750c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2760c1bc742181ded4930842b46e9507372f0b1b963James Dong x = h264bsdBlockX[block & 0x3]; 2770c1bc742181ded4930842b46e9507372f0b1b963James Dong y = h264bsdBlockY[block & 0x3]; 2780c1bc742181ded4930842b46e9507372f0b1b963James Dong 2790c1bc742181ded4930842b46e9507372f0b1b963James Dong pRes = residual[block]; 2800c1bc742181ded4930842b46e9507372f0b1b963James Dong 2810c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(pRes); 2820c1bc742181ded4930842b46e9507372f0b1b963James Dong 2830c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp = data + 256; 2840c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock = cb; 2850c1bc742181ded4930842b46e9507372f0b1b963James Dong 2860c1bc742181ded4930842b46e9507372f0b1b963James Dong if (block >= 20) 2870c1bc742181ded4930842b46e9507372f0b1b963James Dong { 2880c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock = cr; 2890c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp += 64; 2900c1bc742181ded4930842b46e9507372f0b1b963James Dong } 2910c1bc742181ded4930842b46e9507372f0b1b963James Dong 2920c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp += y*8 + x; 2930c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock += y*picWidth + x; 2940c1bc742181ded4930842b46e9507372f0b1b963James Dong 2950c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)tmp&0x3)); 2960c1bc742181ded4930842b46e9507372f0b1b963James Dong ASSERT(!((u32)imageBlock&0x3)); 2970c1bc742181ded4930842b46e9507372f0b1b963James Dong 2980c1bc742181ded4930842b46e9507372f0b1b963James Dong if (IS_RESIDUAL_EMPTY(pRes)) 2990c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3000c1bc742181ded4930842b46e9507372f0b1b963James Dong /*lint -e826 */ 3010c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *in32 = (i32*)tmp; 3020c1bc742181ded4930842b46e9507372f0b1b963James Dong i32 *out32 = (i32*)imageBlock; 3030c1bc742181ded4930842b46e9507372f0b1b963James Dong 3040c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Residual is zero => copy prediction block to output */ 3050c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *in32; in32 += 2; 3060c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *in32; in32 += 2; 3070c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp1; out32 += picWidth/4; 3080c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp2; out32 += picWidth/4; 3090c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = *in32; in32 += 2; 3100c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *in32; 3110c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp1; out32 += picWidth/4; 3120c1bc742181ded4930842b46e9507372f0b1b963James Dong *out32 = tmp2; 3130c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3140c1bc742181ded4930842b46e9507372f0b1b963James Dong else 3150c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3160c1bc742181ded4930842b46e9507372f0b1b963James Dong 3170c1bc742181ded4930842b46e9507372f0b1b963James Dong RANGE_CHECK_ARRAY(pRes, -512, 511, 16); 3180c1bc742181ded4930842b46e9507372f0b1b963James Dong 3190c1bc742181ded4930842b46e9507372f0b1b963James Dong for (i = 4; i; i--) 3200c1bc742181ded4930842b46e9507372f0b1b963James Dong { 3210c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = tmp[0]; 3220c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *pRes++; 3230c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = tmp[1]; 3240c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = clp[tmp1 + tmp2]; 3250c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp4 = *pRes++; 3260c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[0] = (u8)tmp1; 3270c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = clp[tmp3 + tmp4]; 3280c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = tmp[2]; 3290c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp2 = *pRes++; 3300c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[1] = (u8)tmp3; 3310c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp1 = clp[tmp1 + tmp2]; 3320c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = tmp[3]; 3330c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp4 = *pRes++; 3340c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[2] = (u8)tmp1; 3350c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp3 = clp[tmp3 + tmp4]; 3360c1bc742181ded4930842b46e9507372f0b1b963James Dong tmp += 8; 3370c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock[3] = (u8)tmp3; 3380c1bc742181ded4930842b46e9507372f0b1b963James Dong imageBlock += picWidth; 3390c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3400c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3410c1bc742181ded4930842b46e9507372f0b1b963James Dong } 3420c1bc742181ded4930842b46e9507372f0b1b963James Dong 3430c1bc742181ded4930842b46e9507372f0b1b963James Dong} 3440c1bc742181ded4930842b46e9507372f0b1b963James Dong#endif /* H264DEC_OMXDL */ 3450c1bc742181ded4930842b46e9507372f0b1b963James Dong 346