📄 encprofile.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 : Profile&Level handling
--
-------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
1. Include headers
------------------------------------------------------------------------------*/
#include "EncProfile.h"
/*------------------------------------------------------------------------------
2. External compiler flags
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Module defines
------------------------------------------------------------------------------*/
typedef enum {
SIMPLE_L0 = 8,
SIMPLE_L0B = 9,
SIMPLE_L1 = 1,
SIMPLE_L2 = 2,
SIMPLE_L3 = 3,
MAIN_L2 = 50,
MAIN_L3 = 51,
MAIN_L4 = 52,
ADVANCED_SIMPLE_L0 = 240,
ADVANCED_SIMPLE_L1 = 241,
ADVANCED_SIMPLE_L2 = 242,
ADVANCED_SIMPLE_L3 = 243,
ADVANCED_SIMPLE_L4 = 244,
ADVANCED_SIMPLE_L5 = 245,
H263_P0_L10 = 1001,
H263_P0_L20 = 1002,
H263_P0_L30 = 1003,
H263_P0_L40 = 1004,
H263_P0_L50 = 1005,
H263_P0_L60 = 1006,
H263_P0_L70 = 1007
} profile_e;
typedef struct {
i32 mbPerVopMax;
i32 videoBufferSize;/* units of 16384 bits */
i32 vpSizeMax; /* Max video packet length (bits) */
i32 bitPerSecondMax;/* Max bitrate (kbit/s) 1kbit = 1000bit */
} parameter_s;
static const parameter_s parameter[] = {
{99, 10, 2048, 64}, /* Simple L0 */
{99, 20, 2048, 128}, /* Simple L0B */
{99, 10, 2048, 64}, /* Simple L1 */
{396, 40, 4096, 128}, /* Simple L2 */
{396, 40, 8192, 384}, /* Simple L3 */
{594, 80, 8192, 2000}, /* Main L2 */
{1620, 320, 16384, 15000}, /* Main L3 */
{8160, 760, 16384, 38400}, /* Main L4 */
{99, 10, 2048, 128}, /* Advanced Simple L0 */
{99, 10, 2048, 128}, /* Advanced Simple L1 */
{396, 40, 4096, 384}, /* Advanced Simple L2 */
{396, 40, 4096, 768}, /* Advanced Simple L3 */
{792, 80, 8192, 3000}, /* Advanced Simple L4 */
{1620, 112, 16384, 8000}, /* Advanced Simple L5 */
{99, 5, 0, 64}, /* H.263 Profile 0 Level 10 */
{396, 18, 0, 128}, /* H.263 Profile 0 Level 20 */
{396, 20, 0, 384}, /* H.263 Profile 0 Level 30 */
{396, 33, 0, 2048}, /* H.263 Profile 0 Level 40 */
{396, 50, 0, 4096}, /* H.263 Profile 0 Level 50 */
{810, 99, 0, 8192}, /* H.263 Profile 0 Level 60 */
{1620, 198, 0, 16384} /* H.263 Profile 0 Level 70 */
/* videoBufferSize for H.263 is
* (BppMax + 4*bitPerSecondMax/(30000/1001)) / 16384
* where BppMax is 64*1024 bits for picture sizes upto QCIF
* 256*1024 bits for picture sizes upto CIF and
* 512*1024 bits for picture sizes upto 4CIF
* vpSize for H.263 is not applicable */
};
/*------------------------------------------------------------------------------
4. Local function prototypes
------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------
EncProfile
------------------------------------------------------------------------------*/
bool_e EncInitProfile(profile_s *profile)
{
i32 index = 6;
i32 tmp;
switch ((profile_e)profile->profile) {
case SIMPLE_L0:
index = 0;
break;
case SIMPLE_L0B:
index = 1;
break;
case SIMPLE_L1:
index = 2;
break;
case SIMPLE_L2:
index = 3;
break;
case SIMPLE_L3:
index = 4;
break;
case MAIN_L2:
index = 5;
break;
case MAIN_L3:
index = 6;
break;
case MAIN_L4:
index = 7;
break;
case ADVANCED_SIMPLE_L0:
index = 8;
break;
case ADVANCED_SIMPLE_L1:
index = 9;
break;
case ADVANCED_SIMPLE_L2:
index = 10;
break;
case ADVANCED_SIMPLE_L3:
index = 11;
break;
case ADVANCED_SIMPLE_L4:
index = 12;
break;
case ADVANCED_SIMPLE_L5:
index = 13;
break;
case H263_P0_L10:
index = 14;
break;
case H263_P0_L20:
index = 15;
break;
case H263_P0_L30:
index = 16;
break;
case H263_P0_L40:
index = 17;
break;
case H263_P0_L50:
index = 18;
break;
case H263_P0_L60:
index = 19;
break;
case H263_P0_L70:
index = 20;
break;
default:
return NOK;
}
/* Profile depend parameters. The default value of vbv_occupancy is 170
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -