armVCM4P2_FillVLDBuffer.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
10c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: armVCM4P2_FillVLDBuffer.c 40c1bc742181ded4930842b46e9507372f0b1b963James Dong * OpenMAX DL: v1.0.2 50c1bc742181ded4930842b46e9507372f0b1b963James Dong * Revision: 9641 60c1bc742181ded4930842b46e9507372f0b1b963James Dong * Date: Thursday, February 7, 2008 70c1bc742181ded4930842b46e9507372f0b1b963James Dong * 80c1bc742181ded4930842b46e9507372f0b1b963James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 90c1bc742181ded4930842b46e9507372f0b1b963James Dong * 100c1bc742181ded4930842b46e9507372f0b1b963James Dong * 110c1bc742181ded4930842b46e9507372f0b1b963James Dong * 120c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 130c1bc742181ded4930842b46e9507372f0b1b963James Dong * Contains module for VLC get bits from the stream 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * 150c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 190c1bc742181ded4930842b46e9507372f0b1b963James Dong 200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_ZigZag_Tables.h" 210c1bc742181ded4930842b46e9507372f0b1b963James Dong 220c1bc742181ded4930842b46e9507372f0b1b963James Dong 230c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 240c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_FillVLDBuffer 250c1bc742181ded4930842b46e9507372f0b1b963James Dong * 260c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 270c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs filling of the coefficient buffer according to the run, level 280c1bc742181ded4930842b46e9507372f0b1b963James Dong * and sign, also updates the index 290c1bc742181ded4930842b46e9507372f0b1b963James Dong * 300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 310c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] storeRun Stored Run value (count of zeros) 320c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] storeLevel Stored Level value (non-zero value) 330c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] sign Flag indicating the sign of level 340c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] last status of the last flag 350c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pIndex pointer to coefficient index in 8x8 matrix 360c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pIndex pointer to updated coefficient index in 8x8 370c1bc742181ded4930842b46e9507372f0b1b963James Dong * matrix 380c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pZigzagTable pointer to the zigzag tables 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the coefficient buffer of current 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * block. Should be 32-bit aligned 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMXResult result. See enumeration for possible result codes. 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * 440c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 450c1bc742181ded4930842b46e9507372f0b1b963James Dong 460c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult armVCM4P2_FillVLDBuffer( 470c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U32 storeRun, 480c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 * pDst, 490c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 storeLevel, 500c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 sign, 510c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 last, 520c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 * pIndex, 530c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 * pZigzagTable 540c1bc742181ded4930842b46e9507372f0b1b963James Dong) 550c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 560c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Store the zero's as per the run length count */ 570c1bc742181ded4930842b46e9507372f0b1b963James Dong for (;storeRun > 0; storeRun--, (*pIndex)++) 580c1bc742181ded4930842b46e9507372f0b1b963James Dong { 590c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[pZigzagTable[*pIndex]] = 0; 600c1bc742181ded4930842b46e9507372f0b1b963James Dong } 610c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Store the level depending on the sign*/ 620c1bc742181ded4930842b46e9507372f0b1b963James Dong if (sign == 1) 630c1bc742181ded4930842b46e9507372f0b1b963James Dong { 640c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[pZigzagTable[*pIndex]] = -storeLevel; 650c1bc742181ded4930842b46e9507372f0b1b963James Dong } 660c1bc742181ded4930842b46e9507372f0b1b963James Dong else 670c1bc742181ded4930842b46e9507372f0b1b963James Dong { 680c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[pZigzagTable[*pIndex]] = storeLevel; 690c1bc742181ded4930842b46e9507372f0b1b963James Dong } 700c1bc742181ded4930842b46e9507372f0b1b963James Dong (*pIndex)++; 710c1bc742181ded4930842b46e9507372f0b1b963James Dong 720c1bc742181ded4930842b46e9507372f0b1b963James Dong /* If last is 1, fill the remaining elments of the buffer with zeros */ 730c1bc742181ded4930842b46e9507372f0b1b963James Dong if (last == 1) 740c1bc742181ded4930842b46e9507372f0b1b963James Dong { 750c1bc742181ded4930842b46e9507372f0b1b963James Dong while (*pIndex < 64) 760c1bc742181ded4930842b46e9507372f0b1b963James Dong { 770c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst[pZigzagTable[*pIndex]] = 0; 780c1bc742181ded4930842b46e9507372f0b1b963James Dong (*pIndex)++; 790c1bc742181ded4930842b46e9507372f0b1b963James Dong } 800c1bc742181ded4930842b46e9507372f0b1b963James Dong } 810c1bc742181ded4930842b46e9507372f0b1b963James Dong 820c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 830c1bc742181ded4930842b46e9507372f0b1b963James Dong} 840c1bc742181ded4930842b46e9507372f0b1b963James Dong 85