?? t264.h
字號:
/*****************************************************************************
*
* T264 AVC CODEC
*
* Copyright(C) 2004-2005 llcc <lcgate1@yahoo.com.cn>
* 2004-2005 visionany <visionany@yahoo.com.cn>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
****************************************************************************/
#ifndef _T264_H_
#define _T264_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "portab.h"
#define T264_MAJOR ((uint32_t)0 << 16)
#define T264_MINOR ((uint32_t)14)
#define T264_VER (T264_MAJOR | T264_MINOR)
// flags field
#define USE_INTRA16x16 0x1 // use intra 16x16 pred
#define USE_INTRA4x4 0x2 // use intra 4x4 pred
#define USE_SUBBLOCK 0x4 // use inter 8x8 pred
#define USE_HALFPEL 0x8 // half pel search
#define USE_QUARTPEL 0x10 // quarter pel search
#define USE_FULLSEARCH 0x20 // full search
#define USE_DIAMONDSEACH 0x40
#define USE_FORCEBLOCKSIZE 0x80 // search specify block size
#define USE_FASTINTERPOLATE 0x100 // fast interpolate
#define USE_SAD 0x10000 // use sad
#define USE_SATD 0x20000 // use satd
#define USE_INTRAININTER 0x40000 // inter will try intra mode
#define USE_EXTRASUBPELSEARCH 0x80000 // search 8 points vs 4 points (qulity vs. speed)
#define USE_SCENEDETECT 0x100000
// custom flag
#define CUSTOM_FASTINTERPOLATE (1 << 1)
#define SEARCH_16x16P 0x1
#define SEARCH_16x8P 0x2
#define SEARCH_8x16P 0x4
#define SEARCH_8x8P 0x8
#define SEARCH_8x4P 0x10
#define SEARCH_4x8P 0x20
#define SEARCH_4x4P 0x40
#define SEARCH_16x16B (0x1 << 16)
#define SEARCH_16x8B (0x2 << 16)
#define SEARCH_8x16B (0x4 << 16)
#define SEARCH_8x8B (0x8 << 16)
// cpu ability
#define T264_CPU_FORCE 0x1
#define T264_CPU_MMX 0x10
#define T264_CPU_SSE 0x1000
#define T264_CPU_SSE2 0x10000
// mb_neighbour
#define MB_LEFT 0x1
#define MB_TOP 0x2
#define MB_TOPRIGHT 0x4
#define MAX_REFFRAMES 16
#define MAX_BREFNUMS 5
#define MAX_PLUGINS 5
#define CACHE_SIZE 16
#define EDGED_WIDTH (32 + CACHE_SIZE)
#define EDGED_HEIGHT EDGED_WIDTH
#define T264_MIN(a,b) ( (a)<(b) ? (a) : (b) )
#define T264_MAX(a,b) ( (a)>(b) ? (a) : (b) )
/* plugins state */
#define STATE_BEFORESEQ 0 /* before sequence */
#define STATE_BEFOREGOP 1 /* before gop header */
#define STATE_BEFOREPIC 2 /* before picture */
#define STATE_AFTERPIC 3 /* after picture encoded */
/* stat control */
#define DISPLAY_PSNR 1
#define DISPLAY_BLOCK 2
#define CHROMA_COEFF_COST 4 /* default chroma coeff cost */
#define IPM_LUMA 9 /* index i4x4 pred mode */
#define VEC_LUMA 9 /* index vector */
#define NNZ_LUMA 9 /* index non zero count */
#define NNZ_CHROMA0 14
#define NNZ_CHROMA1 38
enum
{
NAL_SLICE_NOPART = 1,
NAL_SLICE_PARTA,
NAL_SLICE_PARTB,
NAL_SLICE_PARTC,
NAL_SLICE_IDR,
NAL_SEI,
NAL_SEQ_SET,
NAL_PIC_SET,
NAL_ACD,
NAL_END_SEQ,
NAL_END_STREAM,
NAL_FILTER,
NAL_CUSTOM_SET = 26
};
// Intra 16x16 MB predict
enum
{
Intra_16x16_TOP = 0,
Intra_16x16_LEFT,
Intra_16x16_DC,
Intra_16x16_PLANE,
Intra_16x16_DCTOP,
Intra_16x16_DCLEFT,
Intra_16x16_DC128
};
// Intra chroma 8x8 MB predict
enum
{
Intra_8x8_DC = 0,
Intra_8x8_LEFT,
Intra_8x8_TOP,
Intra_8x8_PLANE,
Intra_8x8_DCTOP,
Intra_8x8_DCLEFT,
Intra_8x8_DC128
};
// Intra 4x4 MB predict
enum
{
Intra_4x4_TOP = 0,
Intra_4x4_LEFT,
Intra_4x4_DC,
Intra_4x4_DIAGONAL_DOWNLEFT,
Intra_4x4_DIAGONAL_DOWNRIGHT,
Intra_4x4_VERTICAL_RIGHT,
Intra_4x4_HORIZONTAL_DOWN,
Intra_4x4_VERTICAL_LEFT,
Intra_4x4_HORIZONTAL_UP,
Intra_4x4_DCTOP = 9,
Intra_4x4_DCLEFT,
Intra_4x4_DC128
};
// Partition Size
enum
{
MB_16x16 = 0,
MB_16x8,
MB_8x16,
MB_8x8,
MB_8x8ref0,
MB_8x4,
MB_4x8,
MB_4x4,
MB_2x2
};
enum
{
B_DIRECT_16x16 = 10,
B_L0_16x16,
B_L1_16x16,
B_Bi_16x16,
B_L0_16x8,
B_L1_16x8,
B_Bi_16x8,
B_L0_8x16,
B_L1_8x16,
B_Bi_8x16,
};
enum
{
B_L0_L0_16x8 = 4,
B_L0_L0_8x16,
B_L1_L1_16x8,
B_L1_L1_8x16,
B_L0_L1_16x8,
B_L0_L1_8x16,
B_L1_L0_16x8,
B_L1_L0_8x16,
B_L0_Bi_16x8,
B_L0_Bi_8x16,
B_L1_Bi_16x8,
B_L1_Bi_8x16,
B_Bi_L0_16x8,
B_Bi_L0_8x16,
B_Bi_L1_16x8,
B_Bi_L1_8x16,
B_Bi_Bi_16x8,
B_Bi_Bi_8x16,
B_8x8
};
enum
{
B_DIRECT_8x8 = 100,
B_L0_8x8,
B_L1_8x8,
B_Bi_8x8,
B_L0_8x4,
B_L0_4x8,
B_L1_8x4,
B_L1_4x8,
B_Bi_8x4,
B_Bi_4x8,
B_L0_4x4,
B_L1_4x4,
B_Bi_4x4
};
// MB encode mode
enum
{
I_4x4,
I_16x16,
P_SKIP,
P_MODE,
B_SKIP,
B_MODE,
};
// Slice type
enum
{
SLICE_P = 0,
SLICE_B,
SLICE_I,
SLICE_SP,
SLICE_SI,
SLICE_IDR
};
typedef enum
{
DEC_STATE_BUFFER = -1,
DEC_STATE_OK,
DEC_STATE_SEQ,
DEC_STATE_PIC,
DEC_STATE_SLICE,
DEC_STATE_CUSTOM_SET,
DEC_STATE_UNKOWN
} decoder_state_t;
//Inverse raster scan for 4x4 blocks in MB
/*
from raster scan to lumaindex
0 1 2 3 (orgin)
4 5 6 7
8 9 10 11
12 13 14 15
0 1 4 5
2 3 6 7
8 9 12 13
10 11 14 15
*/
static const int8_t luma_index[] =
{
0, 1, 4, 5,
2, 3, 6, 7,
8, 9, 12, 13,
10, 11, 14, 15
};
static const int8_t luma_inverse_x[] =
{
0, 1, 0, 1, 2, 3, 2, 3, 0, 1, 0, 1, 2, 3, 2, 3
};
static const int8_t luma_inverse_y[] =
{
0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3
};
//! array used to find expencive coefficients
static const int8_t COEFF_COST[16] =
{
3,2,2,1,1,1,0,0,0,0,0,0,0,0,0,0
};
typedef struct T264_t T264_t;
//typedef struct T264_search_context_t T264_search_context_t;
typedef struct
{
int32_t width, height;
int32_t qp;
int32_t bitrate;
float framerate;
int32_t iframe; // I 幀間距
int32_t idrframe; // idr 間距
int32_t ref_num; // 參考幀數(shù)目
int32_t b_num; // b frame num
int32_t flags;
int32_t cpu;
int32_t search_x;
int32_t search_y;
int32_t block_size;
int32_t disable_filter;
int32_t aspect_ratio;
int32_t video_format;
int32_t luma_coeff_cost;
int32_t min_qp;
int32_t max_qp;
int32_t enable_rc;
int32_t enable_stat;
int32_t direct_flag;
//for CABAC
int32_t cabac;
void* rec_name;
} T264_param_t;
typedef struct
{
int32_t i_block_num[2];
int32_t p_block_num[8];
int32_t b_block_num[2];
int32_t skip_block_num;
} T264_stat_t;
//
// nal_unit
//
typedef struct
{
int32_t nal_ref_idc;
int32_t nal_unit_type;
int32_t nal_size;
} T264_nal_t;
typedef struct
{
int32_t profile_idc;
int32_t level_idc;
int32_t seq_id;
int32_t log2_max_frame_num_minus4;
int32_t pic_order_cnt_type;
int32_t max_pic_order;
int32_t num_ref_frames;
int32_t pic_width_in_mbs_minus1;
int32_t pic_height_in_mbs_minus1;
int32_t frame_mbs_only_flag;
} T264_seq_set_t;
typedef struct
{
int32_t pic_id;
int32_t seq_id;
int32_t entroy_coding_mode_flag;
int32_t pic_order_present_flag;
int32_t num_slice_groups_minus1;
int32_t num_ref_idx_l0_active_minus1;
int32_t num_ref_idx_l1_active_minus1;
int32_t weighted_pred_flag;
int32_t weighted_bipred_idc;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -