⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 encvideoobjectplane.c

📁 freescale i.mx31 BSP CE5.0全部源码
💻 C
字号:
/*------------------------------------------------------------------------------
--                                                                            --
--       This software is confidential and proprietary and may be used        --
--        only as expressly authorized by a licensing agreement from          --
--                                                                            --
--                            Hantro Products Oy.                             --
--                                                                            --
--      In the event of publication, the following notice is applicable:      --
--                                                                            --
--                   (C) COPYRIGHT 2004 HANTRO PRODUCTS OY                    --
--                            ALL RIGHTS RESERVED                             --
--                                                                            --
--          The entire notice above must be reproduced on all copies.         --
--                                                                            --
--------------------------------------------------------------------------------
--
--  Description : Encoder internal
--
-------------------------------------------------------------------------------*/


/*------------------------------------------------------------------------------

    Table of context

    1. Include headers
    2. External compiler flags
    3. Module defines
    4. Local function prototypes
    5. Functions
        5.1  EncVideoObjectPlane
        5.2  TimeCode;

------------------------------------------------------------------------------*/

/*------------------------------------------------------------------------------
    1. Include headers
------------------------------------------------------------------------------*/
#include "EncSim.h"
#include "EncVideoObjectPlane.h"
#include "EncStartCode.h"
#include "EncTrace.h"

/*------------------------------------------------------------------------------
    2. External compiler flags
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
    3. Module defines
------------------------------------------------------------------------------*/
/* Table 6-20, see vopType_e
0,2 intra-coded (I)
1,2 predictive-coded (P)
2,2 bidirectionally-predictive-coded (B)
3,2 sprite (S)

Table 6-21
0,3 Use Intra DC VLC for entire VOP
1,3 Switch to Intra AC VLC at running Qp >= 13
2,3 Switch to Intra AC VLC at running Qp >= 15
3,3 Switch to Intra AC VLC at running Qp >= 17
4,3 Switch to Intra AC VLC at running Qp >= 19
5,3 Switch to Intra AC VLC at running Qp >= 21
6,3 Switch to Intra AC VLC at running Qp >= 23
7,3 Use Intra AC VLC for entire VOP

Table 7-5: Range for motion vectors
0,3 Forbidden
1,3 [-32,31]
2,3 [-64,63]
3,3 [-128,127]
4,3 [-256,255]
5,3 [-512,511]
6,3 [-1024,1023]
7,3 [-2048,2047] */

/*------------------------------------------------------------------------------
    4. Local function prototypes
------------------------------------------------------------------------------*/
static void TimeCode(stream_s *, i32, i32, i32);

/*------------------------------------------------------------------------------

	EncVopHdr

------------------------------------------------------------------------------*/
void EncVopInit(vop_s *vop)
{
	vop->header = YES;
	vop->vopCoded = YES;
	vop->hec = NO;
	vop->acPred = NO;
	vop->vopType = IVOP;
	vop->vopTimeInc = 0;
	vop->roundControl = 0;
	vop->intraDcVlcThr = 0;
	vop->vopFcodeForward = 0;
	vop->moduloTimeBase = 0;

	return;
}

/*------------------------------------------------------------------------------

	EncVopHdr

------------------------------------------------------------------------------*/
void EncVopHdr(stream_s *stream, vop_s *vop, i32 qp)
{
	/* Start Code Prefix And Start Code */
	EncPutBits(stream, START_CODE_PREFIX_VAL, START_CODE_PREFIX_NUM);
	EncPutBits(stream, START_CODE_VOP_VAL, START_CODE_VOP_NUM);
	COMMENT("Video Object Plane Start Code");

	/* Vop Coding Type */
	EncPutBits(stream, vop->vopType, 2);
	COMMENT("Vop Coding Type");

	/* Modulo Time Base */
	TimeCode(stream, vop->moduloTimeBase, vop->vopTimeIncRes,
			vop->vopTimeInc);

	/* Vop Coded */
	if (vop->vopCoded == YES) {
		EncPutBits(stream, 1, 1);
		COMMENT("Vop Coded");
	} else {
		EncPutBits(stream, 0, 1);
		COMMENT("Vop Coded");

		/* Next Start Code */
		EncNextStartCode(stream);
		COMMENT("Next start Code");

		return;
	}

	if (vop->vopType == PVOP) {
		/* Vop Rounding Type */
		EncPutBits(stream, vop->roundControl, 1);
		COMMENT("Vop Rounding Type");
	}

	/* Intra Dc Vlc Thr */
	EncPutBits(stream, vop->intraDcVlcThr, 3);
	COMMENT("Intra Dc Vlc Thr");

	/* Vop Quant */
	EncPutBits(stream, qp, 5);
	COMMENT("Vop Quant");

	if (vop->vopType != IVOP) {
		EncPutBits(stream, vop->vopFcodeForward, 3);
		COMMENT("Vop Fcode Forward");
	}

	return;
}

/*------------------------------------------------------------------------------

	TimeCode

------------------------------------------------------------------------------*/
void TimeCode(stream_s *stream, i32 seconds, i32 vopTimeIncRes, i32 vopTimeInc)
{
	i32 bits = 0;

	/* Modulo Time Base */
	while (seconds > 0) {
		EncPutBits(stream, 1, 1);
		seconds--;
	}
	EncPutBits(stream, 0, 1);
	COMMENT("Modulo Time Base");

	/* Marker Bit */
	EncPutBits(stream, 1, 1);
	COMMENT("Marker Bit");

	/* The number of bits representing the value of vopTimeIcrement is the
	 * minimun number of bits required to representing range of [0
	 * vopTimeIncRes) */
	ASSERT(vopTimeInc < vopTimeIncRes);
	while ((1 << ++bits) < vopTimeIncRes);

	/* Vop Time Increment */
	EncPutBits(stream, vopTimeInc, bits);
	COMMENT("Vop Time Increment");

	/* Marker Bit */
	EncPutBits(stream, 1, 1);
	COMMENT("Marker Bit");

	return;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -