1bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/** 2bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 3bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * File Name: omxVCM4P2_EncodeVLCZigzag_Inter.c 4bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * OpenMAX DL: v1.0.2 5bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Revision: 9641 6bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Date: Thursday, February 7, 2008 7bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 8bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * (c) Copyright 2007-2008 ARM Limited. All Rights Reserved. 9bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 10bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 11bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 12bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description: 13bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Contains modules for zigzag scanning and VLC encoding 14bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * for inter block. 15bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 16bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */ 17bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 18bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxtypes.h" 19bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armOMX.h" 20bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "omxVC.h" 21bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 22bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armVC.h" 23bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armCOMM_Bitstream.h" 24bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armCOMM.h" 25bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armVCM4P2_Huff_Tables_VLC.h" 26bebc99d6fa433c04139294a5057f8439d772dbd9James Dong#include "armVCM4P2_ZigZag_Tables.h" 27bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 28bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 29bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 30bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/** 31bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Function: omxVCM4P2_EncodeVLCZigzag_Inter (6.2.4.5.3) 32bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 33bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Description: 34bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Performs classical zigzag scanning and VLC encoding for one inter block. 35bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 36bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Input Arguments: 37bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 38bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * ppBitStream - pointer to the pointer to the current byte in the bit 39bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * stream 40bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * pBitOffset - pointer to the bit position in the byte pointed by 41bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * *ppBitStream. Valid within 0 to 7 42bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * pQDctBlkCoef - pointer to the quantized DCT coefficient 43bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * pattern - block pattern which is used to decide whether this block is 44bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * encoded 45bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * shortVideoHeader - binary flag indicating presence of 46bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * short_video_header; escape modes 0-3 are used if 47bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * shortVideoHeader==0, and escape mode 4 is used when 48bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * shortVideoHeader==1. 49bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 50bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Output Arguments: 51bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 52bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * ppBitStream - *ppBitStream is updated after the block is encoded so that 53bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * it points to the current byte in the bit stream buffer. 54bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * pBitOffset - *pBitOffset is updated so that it points to the current bit 55bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * position in the byte pointed by *ppBitStream. 56bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 57bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * Return Value: 58bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 59bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * OMX_Sts_NoErr - no error 60bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * OMX_Sts_BadArgErr - Bad arguments 61bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * - At least one of the pointers: is NULL: ppBitStream, *ppBitStream, 62bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * pBitOffset, pQDctBlkCoef 63bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * - *pBitOffset < 0, or *pBitOffset >7. 64bebc99d6fa433c04139294a5057f8439d772dbd9James Dong * 65bebc99d6fa433c04139294a5057f8439d772dbd9James Dong */ 66bebc99d6fa433c04139294a5057f8439d772dbd9James DongOMXResult omxVCM4P2_EncodeVLCZigzag_Inter( 67bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMX_U8 **ppBitStream, 68bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMX_INT * pBitOffset, 69bebc99d6fa433c04139294a5057f8439d772dbd9James Dong const OMX_S16 *pQDctBlkCoef, 70bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMX_U8 pattern, 71bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMX_INT shortVideoHeader 72bebc99d6fa433c04139294a5057f8439d772dbd9James Dong) 73bebc99d6fa433c04139294a5057f8439d772dbd9James Dong{ 74bebc99d6fa433c04139294a5057f8439d772dbd9James Dong OMX_U8 start = 0; 75bebc99d6fa433c04139294a5057f8439d772dbd9James Dong const OMX_U8 *pZigzagTable = armVCM4P2_aClassicalZigzagScan; 76bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 77bebc99d6fa433c04139294a5057f8439d772dbd9James Dong /* Argument error checks */ 78bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr); 79bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr); 80bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr); 81bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armRetArgErrIf(pQDctBlkCoef == NULL, OMX_Sts_BadArgErr); 82bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr); 83bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 84bebc99d6fa433c04139294a5057f8439d772dbd9James Dong if (pattern) 85bebc99d6fa433c04139294a5057f8439d772dbd9James Dong { 86bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_PutVLCBits ( 87bebc99d6fa433c04139294a5057f8439d772dbd9James Dong ppBitStream, 88bebc99d6fa433c04139294a5057f8439d772dbd9James Dong pBitOffset, 89bebc99d6fa433c04139294a5057f8439d772dbd9James Dong pQDctBlkCoef, 90bebc99d6fa433c04139294a5057f8439d772dbd9James Dong shortVideoHeader, 91bebc99d6fa433c04139294a5057f8439d772dbd9James Dong start, 92bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 26, 93bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 40, 94bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 10, 95bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 1, 96bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL0RunIdx, 97bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterVlcL0, 98bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL1RunIdx, 99bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterVlcL1, 100bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL0LMAX, 101bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL1LMAX, 102bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL0RMAX, 103bebc99d6fa433c04139294a5057f8439d772dbd9James Dong armVCM4P2_InterL1RMAX, 104bebc99d6fa433c04139294a5057f8439d772dbd9James Dong pZigzagTable 105bebc99d6fa433c04139294a5057f8439d772dbd9James Dong ); 106bebc99d6fa433c04139294a5057f8439d772dbd9James Dong } /* Pattern check ends*/ 107bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 108bebc99d6fa433c04139294a5057f8439d772dbd9James Dong return OMX_Sts_NoErr; 109bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 110bebc99d6fa433c04139294a5057f8439d772dbd9James Dong} 111bebc99d6fa433c04139294a5057f8439d772dbd9James Dong 112bebc99d6fa433c04139294a5057f8439d772dbd9James Dong/* End of file */ 113