omxVCM4P2_EncodeVLCZigzag_Inter.c revision 0c1bc742181ded4930842b46e9507372f0b1b963
10c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
20c1bc742181ded4930842b46e9507372f0b1b963James Dong *
30c1bc742181ded4930842b46e9507372f0b1b963James Dong * File Name:  omxVCM4P2_EncodeVLCZigzag_Inter.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 zigzag scanning and VLC encoding
140c1bc742181ded4930842b46e9507372f0b1b963James Dong * for inter block.
150c1bc742181ded4930842b46e9507372f0b1b963James Dong *
160c1bc742181ded4930842b46e9507372f0b1b963James Dong */
170c1bc742181ded4930842b46e9507372f0b1b963James Dong
180c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxtypes.h"
190c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armOMX.h"
200c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "omxVC.h"
210c1bc742181ded4930842b46e9507372f0b1b963James Dong
220c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVC.h"
230c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM_Bitstream.h"
240c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armCOMM.h"
250c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_Huff_Tables_VLC.h"
260c1bc742181ded4930842b46e9507372f0b1b963James Dong#include "armVCM4P2_ZigZag_Tables.h"
270c1bc742181ded4930842b46e9507372f0b1b963James Dong
280c1bc742181ded4930842b46e9507372f0b1b963James Dong
290c1bc742181ded4930842b46e9507372f0b1b963James Dong
300c1bc742181ded4930842b46e9507372f0b1b963James Dong/**
310c1bc742181ded4930842b46e9507372f0b1b963James Dong * Function:  omxVCM4P2_EncodeVLCZigzag_Inter   (6.2.4.5.3)
320c1bc742181ded4930842b46e9507372f0b1b963James Dong *
330c1bc742181ded4930842b46e9507372f0b1b963James Dong * Description:
340c1bc742181ded4930842b46e9507372f0b1b963James Dong * Performs classical zigzag scanning and VLC encoding for one inter block.
350c1bc742181ded4930842b46e9507372f0b1b963James Dong *
360c1bc742181ded4930842b46e9507372f0b1b963James Dong * Input Arguments:
370c1bc742181ded4930842b46e9507372f0b1b963James Dong *
380c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - pointer to the pointer to the current byte in the bit
390c1bc742181ded4930842b46e9507372f0b1b963James Dong *            stream
400c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - pointer to the bit position in the byte pointed by
410c1bc742181ded4930842b46e9507372f0b1b963James Dong *            *ppBitStream. Valid within 0 to 7
420c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pQDctBlkCoef - pointer to the quantized DCT coefficient
430c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pattern - block pattern which is used to decide whether this block is
440c1bc742181ded4930842b46e9507372f0b1b963James Dong *            encoded
450c1bc742181ded4930842b46e9507372f0b1b963James Dong *   shortVideoHeader - binary flag indicating presence of
460c1bc742181ded4930842b46e9507372f0b1b963James Dong *            short_video_header; escape modes 0-3 are used if
470c1bc742181ded4930842b46e9507372f0b1b963James Dong *            shortVideoHeader==0, and escape mode 4 is used when
480c1bc742181ded4930842b46e9507372f0b1b963James Dong *            shortVideoHeader==1.
490c1bc742181ded4930842b46e9507372f0b1b963James Dong *
500c1bc742181ded4930842b46e9507372f0b1b963James Dong * Output Arguments:
510c1bc742181ded4930842b46e9507372f0b1b963James Dong *
520c1bc742181ded4930842b46e9507372f0b1b963James Dong *   ppBitStream - *ppBitStream is updated after the block is encoded so that
530c1bc742181ded4930842b46e9507372f0b1b963James Dong *            it points to the current byte in the bit stream buffer.
540c1bc742181ded4930842b46e9507372f0b1b963James Dong *   pBitOffset - *pBitOffset is updated so that it points to the current bit
550c1bc742181ded4930842b46e9507372f0b1b963James Dong *            position in the byte pointed by *ppBitStream.
560c1bc742181ded4930842b46e9507372f0b1b963James Dong *
570c1bc742181ded4930842b46e9507372f0b1b963James Dong * Return Value:
580c1bc742181ded4930842b46e9507372f0b1b963James Dong *
590c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_NoErr - no error
600c1bc742181ded4930842b46e9507372f0b1b963James Dong *    OMX_Sts_BadArgErr - Bad arguments
610c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -    At least one of the pointers: is NULL: ppBitStream, *ppBitStream,
620c1bc742181ded4930842b46e9507372f0b1b963James Dong *              pBitOffset, pQDctBlkCoef
630c1bc742181ded4930842b46e9507372f0b1b963James Dong *    -   *pBitOffset < 0, or *pBitOffset >7.
640c1bc742181ded4930842b46e9507372f0b1b963James Dong *
650c1bc742181ded4930842b46e9507372f0b1b963James Dong */
660c1bc742181ded4930842b46e9507372f0b1b963James DongOMXResult omxVCM4P2_EncodeVLCZigzag_Inter(
670c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U8 **ppBitStream,
680c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_INT * pBitOffset,
690c1bc742181ded4930842b46e9507372f0b1b963James Dong     const OMX_S16 *pQDctBlkCoef,
700c1bc742181ded4930842b46e9507372f0b1b963James Dong     OMX_U8 pattern,
710c1bc742181ded4930842b46e9507372f0b1b963James Dong	 OMX_INT shortVideoHeader
720c1bc742181ded4930842b46e9507372f0b1b963James Dong)
730c1bc742181ded4930842b46e9507372f0b1b963James Dong{
740c1bc742181ded4930842b46e9507372f0b1b963James Dong    OMX_U8 start = 0;
750c1bc742181ded4930842b46e9507372f0b1b963James Dong    const OMX_U8  *pZigzagTable = armVCM4P2_aClassicalZigzagScan;
760c1bc742181ded4930842b46e9507372f0b1b963James Dong
770c1bc742181ded4930842b46e9507372f0b1b963James Dong    /* Argument error checks */
780c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(ppBitStream == NULL, OMX_Sts_BadArgErr);
790c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(*ppBitStream == NULL, OMX_Sts_BadArgErr);
800c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pBitOffset == NULL, OMX_Sts_BadArgErr);
810c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf(pQDctBlkCoef == NULL, OMX_Sts_BadArgErr);
820c1bc742181ded4930842b46e9507372f0b1b963James Dong    armRetArgErrIf((*pBitOffset < 0) || (*pBitOffset >7), OMX_Sts_BadArgErr);
830c1bc742181ded4930842b46e9507372f0b1b963James Dong
840c1bc742181ded4930842b46e9507372f0b1b963James Dong    if (pattern)
850c1bc742181ded4930842b46e9507372f0b1b963James Dong    {
860c1bc742181ded4930842b46e9507372f0b1b963James Dong        armVCM4P2_PutVLCBits (
870c1bc742181ded4930842b46e9507372f0b1b963James Dong              ppBitStream,
880c1bc742181ded4930842b46e9507372f0b1b963James Dong              pBitOffset,
890c1bc742181ded4930842b46e9507372f0b1b963James Dong              pQDctBlkCoef,
900c1bc742181ded4930842b46e9507372f0b1b963James Dong              shortVideoHeader,
910c1bc742181ded4930842b46e9507372f0b1b963James Dong              start,
920c1bc742181ded4930842b46e9507372f0b1b963James Dong              26,
930c1bc742181ded4930842b46e9507372f0b1b963James Dong              40,
940c1bc742181ded4930842b46e9507372f0b1b963James Dong              10,
950c1bc742181ded4930842b46e9507372f0b1b963James Dong              1,
960c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterL0RunIdx,
970c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterVlcL0,
980c1bc742181ded4930842b46e9507372f0b1b963James Dong			  armVCM4P2_InterL1RunIdx,
990c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterVlcL1,
1000c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterL0LMAX,
1010c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterL1LMAX,
1020c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterL0RMAX,
1030c1bc742181ded4930842b46e9507372f0b1b963James Dong              armVCM4P2_InterL1RMAX,
1040c1bc742181ded4930842b46e9507372f0b1b963James Dong              pZigzagTable
1050c1bc742181ded4930842b46e9507372f0b1b963James Dong        );
1060c1bc742181ded4930842b46e9507372f0b1b963James Dong    } /* Pattern check ends*/
1070c1bc742181ded4930842b46e9507372f0b1b963James Dong
1080c1bc742181ded4930842b46e9507372f0b1b963James Dong    return OMX_Sts_NoErr;
1090c1bc742181ded4930842b46e9507372f0b1b963James Dong
1100c1bc742181ded4930842b46e9507372f0b1b963James Dong}
1110c1bc742181ded4930842b46e9507372f0b1b963James Dong
1120c1bc742181ded4930842b46e9507372f0b1b963James Dong/* End of file */
113