10c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 20c1bc742181ded4930842b46e9507372f0b1b963James Dong * 30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name: armVCM4P2_DecodeVLCZigzag_intra.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 modules for filling of the coefficient buffer 140c1bc742181ded4930842b46e9507372f0b1b963James Dong * 150c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 160c1bc742181ded4930842b46e9507372f0b1b963James Dong 170c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h" 180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h" 190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h" 200c1bc742181ded4930842b46e9507372f0b1b963James Dong 210c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h" 220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM_Bitstream.h" 230c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h" 240c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_Huff_Tables_VLC.h" 250c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_ZigZag_Tables.h" 260c1bc742181ded4930842b46e9507372f0b1b963James Dong 270c1bc742181ded4930842b46e9507372f0b1b963James Dong 280c1bc742181ded4930842b46e9507372f0b1b963James Dong 290c1bc742181ded4930842b46e9507372f0b1b963James Dong/** 300c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function: armVCM4P2_DecodeVLCZigzag_Intra 310c1bc742181ded4930842b46e9507372f0b1b963James Dong * 320c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description: 330c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs VLC decoding and inverse zigzag scan for one intra coded block. 340c1bc742181ded4930842b46e9507372f0b1b963James Dong * 350c1bc742181ded4930842b46e9507372f0b1b963James Dong * Remarks: 360c1bc742181ded4930842b46e9507372f0b1b963James Dong * 370c1bc742181ded4930842b46e9507372f0b1b963James Dong * Parameters: 380c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] ppBitStream pointer to the pointer to the current byte in 390c1bc742181ded4930842b46e9507372f0b1b963James Dong * the bitstream buffer 400c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] pBitOffset pointer to the bit position in the byte pointed 410c1bc742181ded4930842b46e9507372f0b1b963James Dong * to by *ppBitStream. *pBitOffset is valid within 420c1bc742181ded4930842b46e9507372f0b1b963James Dong * [0-7]. 430c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] predDir AC prediction direction which is used to decide 440c1bc742181ded4930842b46e9507372f0b1b963James Dong * the zigzag scan pattern. It takes one of the 450c1bc742181ded4930842b46e9507372f0b1b963James Dong * following values: 460c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_VC_NONE AC prediction not used; 470c1bc742181ded4930842b46e9507372f0b1b963James Dong * perform classical zigzag scan; 480c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_VC_HORIZONTAL Horizontal prediction; 490c1bc742181ded4930842b46e9507372f0b1b963James Dong * perform alternate-vertical 500c1bc742181ded4930842b46e9507372f0b1b963James Dong * zigzag scan; 510c1bc742181ded4930842b46e9507372f0b1b963James Dong * OMX_VC_VERTICAL Vertical prediction; 520c1bc742181ded4930842b46e9507372f0b1b963James Dong * thus perform 530c1bc742181ded4930842b46e9507372f0b1b963James Dong * alternate-horizontal 540c1bc742181ded4930842b46e9507372f0b1b963James Dong * zigzag scan. 550c1bc742181ded4930842b46e9507372f0b1b963James Dong * [in] start start indicates whether the encoding begins with 0th element 560c1bc742181ded4930842b46e9507372f0b1b963James Dong * or 1st. 570c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] ppBitStream *ppBitStream is updated after the block is 580c1bc742181ded4930842b46e9507372f0b1b963James Dong * decoded, so that it points to the current byte 590c1bc742181ded4930842b46e9507372f0b1b963James Dong * in the bit stream buffer 600c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pBitOffset *pBitOffset is updated so that it points to the 610c1bc742181ded4930842b46e9507372f0b1b963James Dong * current bit position in the byte pointed by 620c1bc742181ded4930842b46e9507372f0b1b963James Dong * *ppBitStream 630c1bc742181ded4930842b46e9507372f0b1b963James Dong * [out] pDst pointer to the coefficient buffer of current 640c1bc742181ded4930842b46e9507372f0b1b963James Dong * block. Should be 32-bit aligned 650c1bc742181ded4930842b46e9507372f0b1b963James Dong * 660c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value: 670c1bc742181ded4930842b46e9507372f0b1b963James Dong * Standard OMXResult result. See enumeration for possible result codes. 680c1bc742181ded4930842b46e9507372f0b1b963James Dong * 690c1bc742181ded4930842b46e9507372f0b1b963James Dong */ 700c1bc742181ded4930842b46e9507372f0b1b963James Dong 710c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult armVCM4P2_DecodeVLCZigzag_Intra( 720c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 ** ppBitStream, 730c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT * pBitOffset, 740c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_S16 * pDst, 750c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 predDir, 760c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_INT shortVideoHeader, 770c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 start 780c1bc742181ded4930842b46e9507372f0b1b963James Dong) 790c1bc742181ded4930842b46e9507372f0b1b963James Dong{ 800c1bc742181ded4930842b46e9507372f0b1b963James Dong OMX_U8 last = 0; 810c1bc742181ded4930842b46e9507372f0b1b963James Dong const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan; 820c1bc742181ded4930842b46e9507372f0b1b963James Dong OMXResult errorCode; 830c1bc742181ded4930842b46e9507372f0b1b963James Dong 840c1bc742181ded4930842b46e9507372f0b1b963James Dong /* Argument error checks */ 850c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr); 860c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr); 870c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr); 880c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(pDst == NULL, OMX_Sts_BadArgErr); 890c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf(!armIs4ByteAligned(pDst), OMX_Sts_BadArgErr); 900c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr); 910c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetArgErrIf((predDir > 2), OMX_Sts_BadArgErr); 920c1bc742181ded4930842b46e9507372f0b1b963James Dong 930c1bc742181ded4930842b46e9507372f0b1b963James Dong switch (predDir) 940c1bc742181ded4930842b46e9507372f0b1b963James Dong { 950c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_NONE: 960c1bc742181ded4930842b46e9507372f0b1b963James Dong { 970c1bc742181ded4930842b46e9507372f0b1b963James Dong pZigzagTable = armVCM4P2_aClassicalZigzagScan; 980c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 990c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1000c1bc742181ded4930842b46e9507372f0b1b963James Dong 1010c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_HORIZONTAL: 1020c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1030c1bc742181ded4930842b46e9507372f0b1b963James Dong pZigzagTable = armVCM4P2_aVerticalZigzagScan; 1040c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 1050c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1060c1bc742181ded4930842b46e9507372f0b1b963James Dong 1070c1bc742181ded4930842b46e9507372f0b1b963James Dong case OMX_VC_VERTICAL: 1080c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1090c1bc742181ded4930842b46e9507372f0b1b963James Dong pZigzagTable = armVCM4P2_aHorizontalZigzagScan; 1100c1bc742181ded4930842b46e9507372f0b1b963James Dong break; 1110c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1120c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1130c1bc742181ded4930842b46e9507372f0b1b963James Dong 1140c1bc742181ded4930842b46e9507372f0b1b963James Dong errorCode = armVCM4P2_GetVLCBits ( 1150c1bc742181ded4930842b46e9507372f0b1b963James Dong ppBitStream, 1160c1bc742181ded4930842b46e9507372f0b1b963James Dong pBitOffset, 1170c1bc742181ded4930842b46e9507372f0b1b963James Dong pDst, 1180c1bc742181ded4930842b46e9507372f0b1b963James Dong shortVideoHeader, 1190c1bc742181ded4930842b46e9507372f0b1b963James Dong start, 1200c1bc742181ded4930842b46e9507372f0b1b963James Dong &last, 1210c1bc742181ded4930842b46e9507372f0b1b963James Dong 10, 1220c1bc742181ded4930842b46e9507372f0b1b963James Dong 62, 1230c1bc742181ded4930842b46e9507372f0b1b963James Dong 7, 1240c1bc742181ded4930842b46e9507372f0b1b963James Dong 21, 1250c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL0RunIdx, 1260c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraVlcL0, 1270c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL1RunIdx, 1280c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraVlcL1, 1290c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL0LMAX, 1300c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL1LMAX, 1310c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL0RMAX, 1320c1bc742181ded4930842b46e9507372f0b1b963James Dong armVCM4P2_IntraL1RMAX, 1330c1bc742181ded4930842b46e9507372f0b1b963James Dong pZigzagTable ); 1340c1bc742181ded4930842b46e9507372f0b1b963James Dong armRetDataErrIf((errorCode != OMX_Sts_NoErr), errorCode); 1350c1bc742181ded4930842b46e9507372f0b1b963James Dong 1360c1bc742181ded4930842b46e9507372f0b1b963James Dong if (last == 0) 1370c1bc742181ded4930842b46e9507372f0b1b963James Dong { 1380c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_Err; 1390c1bc742181ded4930842b46e9507372f0b1b963James Dong } 1400c1bc742181ded4930842b46e9507372f0b1b963James Dong return OMX_Sts_NoErr; 1410c1bc742181ded4930842b46e9507372f0b1b963James Dong} 1420c1bc742181ded4930842b46e9507372f0b1b963James Dong 1430c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */ 1440c1bc742181ded4930842b46e9507372f0b1b963James Dong 145