mirror of
https://github.com/sengeiou/realtek_ameba_mp_sdk.git
synced 2026-07-08 12:35:43 +00:00
ameba micropython sdk first commit
This commit is contained in:
commit
8508ee6139
5619 changed files with 1874619 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef ENCODER_BUFFER_HANDLER_H
|
||||
#define ENCODER_BUFFER_HANDLER_H
|
||||
#include "osdep_service.h"
|
||||
|
||||
struct encoder_data{
|
||||
unsigned int index;//index value
|
||||
int size;
|
||||
unsigned char *addr;//start address
|
||||
int type;//for audio or video
|
||||
int common_count;//if share the common buffer
|
||||
u32 timestamp;
|
||||
u32 hw_timestamp;
|
||||
_list list_data;
|
||||
};
|
||||
|
||||
struct encoder_list_head{
|
||||
void *memory_ctx;
|
||||
_mutex list_lock;
|
||||
_list list;
|
||||
};
|
||||
|
||||
struct mem_info{
|
||||
uint32_t mem_total_size;
|
||||
uint32_t mem_block_size;
|
||||
uint32_t mem_frame_size;
|
||||
};
|
||||
|
||||
struct enc_buf_data{
|
||||
u32 index;
|
||||
u32 y_addr;
|
||||
u32 uv_addr;
|
||||
u32 audio_addr;
|
||||
u32 sample_addr;
|
||||
u32 size;
|
||||
u32 timestamp;
|
||||
u32 hw_timestamp;
|
||||
_list list;
|
||||
};
|
||||
|
||||
struct enc_list_handle{
|
||||
_list enc_idle_list;
|
||||
_list enc_acti_list;
|
||||
_sema enc_sema;
|
||||
_lock enc_lock;
|
||||
};
|
||||
void enc_list_initial(struct enc_list_handle *enc_list);
|
||||
void enc_list_deinitial(struct enc_list_handle *enc_list);
|
||||
void enc_set_idle_buffer(struct enc_list_handle *enc_list,struct enc_buf_data *enc_data);
|
||||
void enc_set_acti_buffer(struct enc_list_handle *enc_list,struct enc_buf_data *enc_data);
|
||||
struct enc_buf_data *enc_get_idle_buffer(struct enc_list_handle *enc_list);
|
||||
struct enc_buf_data *enc_get_acti_buffer(struct enc_list_handle *enc_list);
|
||||
#endif
|
||||
43
sdk/component/common/drivers/video/realtek/common/h264_api.h
Normal file
43
sdk/component/common/drivers/video/realtek/common/h264_api.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#ifndef _H264_API_H_
|
||||
#define _H264_API_H_
|
||||
|
||||
#include "video_common_api.h"
|
||||
#include "h264_encoder.h"
|
||||
|
||||
typedef enum {
|
||||
H264_OK = 0,
|
||||
|
||||
H264_ERROR = -1,
|
||||
H264_NULL_ARGUMENT = -2,
|
||||
H264_INVALID_ARGUMENT = -3,
|
||||
H264_MEMORY_ERROR = -4,
|
||||
H264_EWL_ERROR = -5,
|
||||
H264_EWL_MEMORY_ERROR = -6,
|
||||
H264_INVALID_STATUS = -7,
|
||||
H264_OUTPUT_BUFFER_OVERFLOW = -8,
|
||||
H264_HW_BUS_ERROR = -9,
|
||||
H264_HW_DATA_ERROR = -10,
|
||||
H264_HW_TIMEOUT = -11,
|
||||
H264_HW_RESERVED = -12,
|
||||
H264_SYSTEM_ERROR = -13,
|
||||
H264_INSTANCE_ERROR = -14,
|
||||
H264_HRD_ERROR = -15,
|
||||
H264_HW_RESET = -16,
|
||||
} H264_RET;
|
||||
|
||||
typedef enum {
|
||||
H264_RC_MODE_CBR = 1,
|
||||
H264_RC_MODE_VBR = 2,
|
||||
H264_RC_MODE_FIXQP = 3,
|
||||
H264_RC_MODE_RATEADP = 4,
|
||||
} H264_RC_MODE;
|
||||
|
||||
H264_RET h264_create_encoder(struct h264_context* *p_h264_ctx);
|
||||
H264_RET h264_free_encoder(struct h264_context* *p_h264_ctx);
|
||||
H264_RET h264_set_parm(struct h264_context* h264_ctx, struct h264_parameter* parm);
|
||||
H264_RET h264_get_parm(struct h264_context* h264_ctx, struct h264_parameter* parm);
|
||||
H264_RET h264_init_encoder(struct h264_context* h264_ctx);
|
||||
H264_RET h264_encode_frame(struct h264_context* h264_ctx, isp_buf_t* isp_buf, VIDEO_BUFFER* video_buf);
|
||||
int h264_is_i_frame(u8* frame_buf);
|
||||
|
||||
#endif //#ifndef _H264_API_H_
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef H264_ENCODER
|
||||
#define H264_ENCODER
|
||||
#include "memory_encoder.h"
|
||||
#include "encoder_buffer_handler.h"
|
||||
#include "isp_api.h"
|
||||
|
||||
#define RC_MODE_H264CBR 1
|
||||
#define RC_MODE_H264VBR 2
|
||||
#define RC_MODE_H264ABR 3
|
||||
#define RC_MODE_H264FIXQP 4
|
||||
#define RC_MODE_H264RATEADP 5 // bit rate adaptive, original mode
|
||||
|
||||
struct h264_parameter {
|
||||
int inputtype; //YUV420 SEMI-PLANAR
|
||||
int width;
|
||||
int height;
|
||||
int ratenum;
|
||||
unsigned int bps; // for CBR/ABR
|
||||
unsigned int gopLen;
|
||||
unsigned int rcMode;
|
||||
unsigned int iQp; // for fixed QP
|
||||
unsigned int pQp; // for fixed QP
|
||||
unsigned int minQp; // for CBR/VBR/ABR
|
||||
unsigned int minIQp; // for CBR/VBR/ABR
|
||||
unsigned int maxQp; // for CBR/VBR/ABR
|
||||
|
||||
unsigned int rc_adv_enable;
|
||||
|
||||
unsigned int maxBps; // for VBR
|
||||
unsigned int minBps; // for VBR
|
||||
|
||||
int intraQpDelta;
|
||||
int mbQpAdjustment;
|
||||
unsigned int mbQpAutoBoost;
|
||||
|
||||
int adaptQpEn; // for Adaptive QP
|
||||
};
|
||||
|
||||
struct h264_change_config{
|
||||
int bps;
|
||||
int bps_config;
|
||||
};
|
||||
|
||||
#define SPS_PPS_SIZE 64
|
||||
|
||||
struct h264_context {
|
||||
void* encoder;
|
||||
struct h264_parameter h264_parm;
|
||||
long index;
|
||||
int start;
|
||||
uint32_t source_addr;
|
||||
uint32_t y_addr;
|
||||
uint32_t uv_addr;
|
||||
uint32_t dest_addr;
|
||||
uint32_t dest_len;
|
||||
uint32_t dest_actual_len;
|
||||
//uint32_t stab_addr;
|
||||
uint8_t sps_pps_buf[SPS_PPS_SIZE];
|
||||
uint32_t sps_pps_len;
|
||||
struct isp_info isp_info_value;
|
||||
struct mem_info mem_info_value;
|
||||
struct encoder_list_head encoder_lh;
|
||||
int (*snapshot_encode_cb)(uint32_t,uint32_t);
|
||||
void (*change_parm_cb)(void*);
|
||||
struct h264_change_config h264_ch_config;
|
||||
int pause;
|
||||
};
|
||||
void *h264_open();
|
||||
int h264_encode(void *ctx);
|
||||
int h264_release(void *ctx);
|
||||
int h264_initial(void *ctx,struct h264_parameter *h264_parm);
|
||||
int h264_init_param(struct h264_parameter *h264_parm);
|
||||
int h264_info();
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Basic type definitions.
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BASETYPE_H_INCLUDED
|
||||
#define BASETYPE_H_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include "basic_types.h"
|
||||
#define VOLATILE volatile
|
||||
|
||||
#ifdef __linux__ /* typedefs for Linux */
|
||||
|
||||
#include <stddef.h> /* for size_t, NULL, etc. */
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef signed char i8;
|
||||
typedef unsigned short u16;
|
||||
typedef signed short i16;
|
||||
typedef unsigned int u32;
|
||||
typedef signed int i32;
|
||||
typedef unsigned long long u64;
|
||||
typedef int64_t i64;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef enum {
|
||||
false = 0,
|
||||
true = 1
|
||||
} bool;
|
||||
#endif
|
||||
|
||||
#else /* __symbian__ or __win__ or whatever, customize it to suit well */
|
||||
|
||||
//#ifndef _SIZE_T_DEFINED
|
||||
//typedef unsigned int size_t;
|
||||
//#define _SIZE_T_DEFINED
|
||||
//#endif
|
||||
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else /* */
|
||||
#define NULL ((void *)0)
|
||||
#endif /* */
|
||||
#endif
|
||||
|
||||
#ifndef u8
|
||||
typedef unsigned char u8;
|
||||
#endif
|
||||
#ifndef i8
|
||||
typedef signed char i8;
|
||||
#endif
|
||||
#ifndef u16
|
||||
typedef unsigned short u16;
|
||||
#endif
|
||||
#ifndef i16
|
||||
typedef signed short i16;
|
||||
#endif
|
||||
#ifndef u32
|
||||
typedef unsigned int u32;
|
||||
#endif
|
||||
#ifndef i32
|
||||
typedef signed int i32;
|
||||
#endif
|
||||
#ifndef u64
|
||||
typedef unsigned long long u64;
|
||||
#endif
|
||||
#ifndef i64
|
||||
typedef int64_t i64;
|
||||
#endif
|
||||
|
||||
#ifndef bool
|
||||
//typedef unsigned char bool;
|
||||
#define true (1)
|
||||
#define false (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(VC1SWDEC_16BIT) || defined(MP4ENC_ARM11)
|
||||
typedef unsigned short u16x;
|
||||
typedef signed short i16x;
|
||||
#else
|
||||
typedef unsigned int u16x;
|
||||
typedef signed int i16x;
|
||||
#endif
|
||||
|
||||
#endif /* BASETYPE_H_INCLUDED */
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Only for test purpose. Input line buffer registers.
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ENC_INPUTLINEBUFREGISTER_H
|
||||
#define ENC_INPUTLINEBUFREGISTER_H
|
||||
|
||||
#include "basetype.h"
|
||||
#include "encswhwregisters.h"
|
||||
|
||||
#if 0
|
||||
slice_hw_mode_en
|
||||
a) [8:0] : slice_wr_cntr // +slice_depth when one slice is filled into slice_fifo
|
||||
b) [17:9]: slice_depth // unit is MB line
|
||||
c) [18]: slice_hw_mode_en // active high, enable bit of slice_fifo hardware mode, should be disabled before the start of next frame.
|
||||
d) [27:19] : pic_height // same value of swreg14[18:10] in H1
|
||||
e) [36:28] : slice_rd_cntr // read only
|
||||
#endif
|
||||
|
||||
/* HW Register field names */
|
||||
typedef enum {
|
||||
InputlineBufWrCntr,
|
||||
InputlineBufDepth,
|
||||
InputlineBufHwHandshake,
|
||||
InputlineBufPicHeight,
|
||||
InputlineBufRdCntr,
|
||||
} lineBufRegName;
|
||||
|
||||
#define LINE_BUF_SWREG_AMOUNT 4 /*4x 32-bit*/
|
||||
|
||||
static const regField_s lineBufRegisterDesc[] = {
|
||||
/* HW ID register, read-only */
|
||||
{InputlineBufWrCntr , 0x000, 0x000001ff, 0, 0, RW, "slice_wr_cntr. +slice_depth when one slice is filled into slice_fifo"},
|
||||
{InputlineBufDepth , 0x000, 0x0003fe00, 9, 0, RW, "slice_depth. unit is MB line"},
|
||||
{InputlineBufHwHandshake , 0x000, 0x00040000, 18, 0, RW, "slice_hw_mode_en. active high. enable bit of slice_fifo hardware mode. should be disabled before the start of next frame."},
|
||||
{InputlineBufPicHeight , 0x000, 0x0ff80000, 19, 0, RW, "pic_height. same value of swreg14[18:10] in H1."},
|
||||
{InputlineBufRdCntr , 0x008, 0x000001ff, 0, 0, RO, "slice_rd_cntr. read only"},
|
||||
};
|
||||
|
||||
#define GetInputLineBufReg(reg,name,value) \
|
||||
value=(reg[lineBufRegisterDesc[name].base/4]&lineBufRegisterDesc[name].mask)>>lineBufRegisterDesc[name].lsb
|
||||
|
||||
#define SetInputLineBufReg(reg,name,value) \
|
||||
reg[lineBufRegisterDesc[name].base/4]= \
|
||||
(reg[lineBufRegisterDesc[name].base/4] & ~(lineBufRegisterDesc[name].mask)) | \
|
||||
((value << lineBufRegisterDesc[name].lsb) & lineBufRegisterDesc[name].mask)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,239 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Encoder common definitions for control code and system model
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ENC_COMMON_H__
|
||||
#define __ENC_COMMON_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. External compiler flags
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Encoder global definitions
|
||||
*
|
||||
* _ASSERT_USED # Asserts enabled
|
||||
* _DEBUG_PRINT # Prints debug information on stdout
|
||||
* TRACE_STREAM # Creates stream trace file
|
||||
* TEST_DATA # Creates test data files
|
||||
*
|
||||
* Can be defined here or using compiler flags */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#include "basetype.h"
|
||||
#include "ewl.h"
|
||||
|
||||
/* Test data generation requires stream trace */
|
||||
#ifdef TEST_DATA
|
||||
#ifndef TRACE_STREAM
|
||||
#define TRACE_STREAM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Stream tracing requires encdebug.h */
|
||||
#ifdef TRACE_STREAM
|
||||
#ifndef H1_HAVE_ENCDEBUG_H
|
||||
#define H1_HAVE_ENCDEBUG_H
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef H1_HAVE_ENCDEBUG_H
|
||||
#include "encdebug.h"
|
||||
#else
|
||||
#undef ASSERT
|
||||
#define ASSERT(expr)
|
||||
#define DEBUG_PRINT(args)
|
||||
#define COMMENT(x)
|
||||
#define COMMENTMBTYPE(x,y)
|
||||
#define TRACE_BIT_STREAM(v,n)
|
||||
#endif
|
||||
|
||||
#ifdef H1_HAVE_ENCTRACE_H
|
||||
#include "enctrace.h"
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ENCHW_NOK = -1,
|
||||
ENCHW_OK = 0
|
||||
} bool_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ENCHW_NO = 0,
|
||||
ENCHW_YES = 1
|
||||
} true_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NONIDR = 1, /* Coded slice of a non-IDR picture */
|
||||
IDR = 5, /* Coded slice of an IDR picture */
|
||||
SEI = 6, /* SEI message */
|
||||
SPSET = 7, /* Sequence parameter set */
|
||||
PPSET = 8, /* Picture parameter set */
|
||||
ENDOFSEQUENCE = 10, /* End of sequence */
|
||||
ENDOFSTREAM = 11, /* End of stream */
|
||||
FILLERDATA = 12, /* Filler data */
|
||||
PREFIX = 14, /* Prefix */
|
||||
SSPSET = 15, /* Subset sequence parameter set */
|
||||
MVC = 20 /* Coded slice of a view picture */
|
||||
} nalUnitType_e;
|
||||
|
||||
/* VLC TABLE */
|
||||
typedef struct
|
||||
{
|
||||
i32 value; /* Value of bits */
|
||||
i32 number; /* Number of bits */
|
||||
} table_s;
|
||||
|
||||
/* used in stream buffer handling */
|
||||
typedef struct
|
||||
{
|
||||
u8 *stream; /* Pointer to next byte of stream */
|
||||
u32 size; /* Byte size of stream buffer */
|
||||
u32 byteCnt; /* Byte counter */
|
||||
u32 bitCnt; /* Bit counter */
|
||||
u32 byteBuffer; /* Byte buffer */
|
||||
u32 bufferedBits; /* Amount of bits in byte buffer, [0-7] */
|
||||
u32 zeroBytes; /* Amount of consecutive zero bytes */
|
||||
i32 overflow; /* This will signal a buffer overflow */
|
||||
u32 emulCnt; /* Counter for emulation_3_byte, needed in SEI */
|
||||
i32 *table; /* Video packet or Gob sizes */
|
||||
i32 tableSize; /* Size of above table */
|
||||
i32 tableCnt; /* Table counter of above table */
|
||||
} stream_s;
|
||||
|
||||
/* General tools */
|
||||
#define ABS(x) ((x) < (0) ? -(x) : (x))
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define SIGN(a) ((a) < (0) ? (-1) : (1))
|
||||
#define OUT_OF_RANGE(x,a,b) ((((i32)x)<(a)?(1):(0)) || ((x)>(b)?(1):(0)))
|
||||
#define CLIP3(v, min, max) ((v) < (min) ? (min) : ((v) > (max) ? (max) : (v)))
|
||||
|
||||
/* VP8 MB output information. Amount of data is 32 bytes/macroblock. */
|
||||
|
||||
/* Encoder MB output information defined as a struct.
|
||||
|
||||
NOTE! By defining this struct we rely that ASIC output endianess
|
||||
is configured properly to produce output that is identical
|
||||
to the way the compiler constructs this struct. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 mode; /* refIdx 2b, chromaIntraMode 2b, mbMode 4b */
|
||||
u8 nonZeroCnt;
|
||||
u16 bitCount;
|
||||
i8 mvY[4];
|
||||
i16 mvX[4];
|
||||
u8 intra4x4[8]; /* 4 bits per block */
|
||||
u16 intraSad;
|
||||
u16 interSad;
|
||||
u8 inputMad_div128;
|
||||
u8 yMean;
|
||||
u8 cbMean;
|
||||
u8 crMean;
|
||||
u8 boostQp; /* H264 macroblock autoboost qp */
|
||||
u8 dummy0; /* Dummy (not used) place holder */
|
||||
u16 varRecon[3]; /* Mb variance after reconstruction but before DB-filter */
|
||||
u8 dummy1[2]; /* Dummy (not used) place holder */
|
||||
u16 varInput[3]; /* Mb variance before encoding loop */
|
||||
} encOutputMbInfo_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 mode; /* refIdx 2b, chromaIntraMode 2b, mbMode 4b */
|
||||
u8 nonZeroCnt;
|
||||
u16 bitCount;
|
||||
i8 mvY[4];
|
||||
i16 mvX[4];
|
||||
u8 intra4x4[8]; /* 4 bits per block */
|
||||
u16 intraSad;
|
||||
u16 interSad;
|
||||
u8 inputMad_div128;
|
||||
u8 yMean;
|
||||
u8 cbMean;
|
||||
u8 crMean;
|
||||
u8 boostQp; /* H264 macroblock autoboost qp */
|
||||
u8 dummy0; /* Dummy (not used) place holder */
|
||||
u16 varRecon[3]; /* Mb variance after reconstruction but before DB-filter */
|
||||
u8 dummy1[2]; /* Dummy (not used) place holder */
|
||||
u16 varInput[3]; /* Mb variance before encoding loop */
|
||||
u8 data[8];
|
||||
} encOutputMbInfoDebug_s;
|
||||
|
||||
/* Masks for encOutputMbInfo.mode */
|
||||
#define MBOUT_8_MODE_MASK 0x0F
|
||||
#define MBOUT_8_CHROMA_MODE_MASK 0x30
|
||||
#define MBOUT_8_REFIDX_MASK 0xC0
|
||||
|
||||
/* MB output information. Amount of data/mb in 16-bit words / bytes.
|
||||
This is how things used to be before Foxtail release.
|
||||
Older models rely on these defines.
|
||||
For Foxtail data has increased to 48 bytes/MB, this is defined in model. */
|
||||
#define MBOUT_16 16
|
||||
#define MBOUT_8 32
|
||||
|
||||
/* 16-bit pointer offset to field. */
|
||||
#define MBOUT_16_BITCOUNT 1
|
||||
#define MBOUT_16_MV_B0_X 4
|
||||
#define MBOUT_16_MV_B1_X 5
|
||||
#define MBOUT_16_MV_B2_X 6
|
||||
#define MBOUT_16_MV_B3_X 7
|
||||
#define MBOUT_16_INTRA_SAD 12
|
||||
#define MBOUT_16_INTER_SAD 13
|
||||
|
||||
/* 8-bit pointer offset to field. */
|
||||
#define MBOUT_8_MODE 0
|
||||
#define MBOUT_8_NONZERO_CNT 1
|
||||
#define MBOUT_8_MV_B0_Y 4
|
||||
#define MBOUT_8_MV_B1_Y 5
|
||||
#define MBOUT_8_MV_B2_Y 6
|
||||
#define MBOUT_8_MV_B3_Y 7
|
||||
#define MBOUT_8_I4X4 16
|
||||
#define MBOUT_8_INPUT_MAD 28
|
||||
#define MBOUT_8_LUMA_MEAN 29
|
||||
#define MBOUT_8_CB_MEAN 30
|
||||
#define MBOUT_8_CR_MEAN 31
|
||||
|
||||
#define MBOUT_8_BOOS_QP 32
|
||||
#define MBOUT_8_VAR_REC_LUM 34 /* varRecon[0] */
|
||||
#define MBOUT_8_VAR_INP_LUM 42 /* varInput[0] */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
typedef void (*EncInputMBLineBufCallBackFunc)(void *pAppData);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 inputLineBufEn; /* enable input image control signals */
|
||||
u32 inputLineBufLoopBackEn; /* input buffer loopback mode enable */
|
||||
u32 inputLineBufDepth; /* input loopback buffer size in mb lines */
|
||||
u32 inputLineBufHwModeEn; /* hw handshake mode */
|
||||
u32 wrCnt;
|
||||
EncInputMBLineBufCallBackFunc cbFunc; /* call back function for line buffer interrupt */
|
||||
} inputLineBuf_s;
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,428 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Hantro Encoder Wrapper Layer for OS services
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __EWL_H__
|
||||
#define __EWL_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
#define _VOE_NO_USE
|
||||
|
||||
#define AMEBA_VERIFY 0
|
||||
#define AMEBA_PRO 1
|
||||
#define AMEBA_POLLING 0
|
||||
#define AMEBA_IRQ 1
|
||||
|
||||
#define AMEBA_SHARE_INATANCE_ALL 0 //Share all instance
|
||||
#define AMEBA_SHARE_INSTANCE_IND 1 //Individual setting
|
||||
|
||||
//#define H264ENC_TRACE
|
||||
//#define TRACE_EWL
|
||||
|
||||
|
||||
#if AMEBA_VERIFY
|
||||
/* Return values */
|
||||
#define EWL_OK 0
|
||||
#define EWL_ERROR -1
|
||||
|
||||
#define EWL_HW_WAIT_OK EWL_OK
|
||||
#define EWL_HW_WAIT_ERROR EWL_ERROR
|
||||
#define EWL_HW_WAIT_TIMEOUT 1
|
||||
|
||||
/* HW configuration values */
|
||||
#define EWL_HW_BUS_TYPE_UNKNOWN 0
|
||||
#define EWL_HW_BUS_TYPE_AHB 1
|
||||
#define EWL_HW_BUS_TYPE_OCP 2
|
||||
#define EWL_HW_BUS_TYPE_AXI 3
|
||||
#define EWL_HW_BUS_TYPE_PCI 4
|
||||
|
||||
#define EWL_HW_BUS_WIDTH_UNKNOWN 0
|
||||
#define EWL_HW_BUS_WIDTH_32BITS 1
|
||||
#define EWL_HW_BUS_WIDTH_64BITS 2
|
||||
#define EWL_HW_BUS_WIDTH_128BITS 3
|
||||
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_UNKNOWN 0
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_VHDL 1
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_VERILOG 2
|
||||
|
||||
#define EWL_HW_CONFIG_NOT_SUPPORTED 0
|
||||
#define EWL_HW_CONFIG_ENABLED 1
|
||||
|
||||
/* Hardware configuration description */
|
||||
typedef struct EWLHwConfig
|
||||
{
|
||||
u32 maxEncodedWidth; /* Maximum supported width for video encoding (not JPEG) */
|
||||
u32 h264Enabled; /* HW supports H.264 */
|
||||
u32 jpegEnabled; /* HW supports JPEG */
|
||||
u32 vp8Enabled; /* HW supports VP8 */
|
||||
u32 vsEnabled; /* HW supports video stabilization */
|
||||
u32 rgbEnabled; /* HW supports RGB input */
|
||||
u32 searchAreaSmall; /* HW search area reduced */
|
||||
u32 scalingEnabled; /* HW supports down-scaling */
|
||||
u32 busType; /* HW bus type in use */
|
||||
u32 busWidth;
|
||||
u32 synthesisLanguage;
|
||||
} EWLHwConfig_t;
|
||||
|
||||
/* Allocated linear memory area information */
|
||||
typedef struct EWLLinearMem
|
||||
{
|
||||
u32 *virtualAddress;
|
||||
u32 busAddress;
|
||||
u32 size;
|
||||
} EWLLinearMem_t;
|
||||
|
||||
/* EWLInitParam is used to pass parameters when initializing the EWL */
|
||||
typedef struct EWLInitParam
|
||||
{
|
||||
u32 clientType;
|
||||
} EWLInitParam_t;
|
||||
|
||||
#define EWL_CLIENT_TYPE_H264_ENC 1U
|
||||
#define EWL_CLIENT_TYPE_VP8_ENC 2U
|
||||
#define EWL_CLIENT_TYPE_JPEG_ENC 3U
|
||||
#define EWL_CLIENT_TYPE_VIDEOSTAB 4U
|
||||
|
||||
extern void (*pollInputLineBufTestFunc)(void);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Read and return the HW ID register value, static implementation */
|
||||
u32 EWLReadAsicID(void);
|
||||
|
||||
/* Read and return HW configuration info, static implementation */
|
||||
EWLHwConfig_t EWLReadAsicConfig(void);
|
||||
|
||||
/* Initialize the EWL instance
|
||||
* Returns a wrapper instance or NULL for error
|
||||
* EWLInit is called when the encoder instance is initialized */
|
||||
const void *EWLInit(EWLInitParam_t * param);
|
||||
|
||||
/* Release the EWL instance
|
||||
* Returns EWL_OK or EWL_ERROR
|
||||
* EWLRelease is called when the encoder instance is released */
|
||||
i32 EWLRelease(const void *inst);
|
||||
|
||||
/* Reserve the HW resource for one codec instance
|
||||
* EWLReserveHw is called when beginning a frame encoding
|
||||
* The function may block until the resource is available.
|
||||
* Returns EWL_OK if the resource was successfully reserved for this instance
|
||||
* or EWL_ERROR if unable to reserve the resource. */
|
||||
i32 EWLReserveHw(const void *inst);
|
||||
|
||||
/* Release the HW resource
|
||||
* EWLReleaseHw is called when the HW has finished the frame encoding.
|
||||
* The codec SW will continue the frame encoding but the HW can
|
||||
* be used by another codec.*/
|
||||
void EWLReleaseHw(const void *inst);
|
||||
|
||||
/* Frame buffers memory */
|
||||
i32 EWLMallocRefFrm(const void *inst, u32 size, EWLLinearMem_t * info);
|
||||
void EWLFreeRefFrm(const void *inst, EWLLinearMem_t * info);
|
||||
|
||||
/* SW/HW shared memory */
|
||||
i32 EWLMallocLinear(const void *inst, u32 size, EWLLinearMem_t * info);
|
||||
void EWLFreeLinear(const void *inst, EWLLinearMem_t * info);
|
||||
|
||||
/* D-Cache coherence *//* Not in use currently */
|
||||
void EWLDCacheRangeFlush(const void *instance, EWLLinearMem_t * info);
|
||||
void EWLDCacheRangeRefresh(const void *instance, EWLLinearMem_t * info);
|
||||
|
||||
/* Write value to a HW register
|
||||
* All registers are written at once at the beginning of frame encoding
|
||||
* Offset is relative to the the HW ID register (#0) in bytes
|
||||
* Enable indicates when the HW is enabled. If shadow registers are used then
|
||||
* they must be flushed to the HW registers when enable is '1' before
|
||||
* writing the register that enables the HW */
|
||||
void EWLWriteReg(const void *inst, u32 offset, u32 val);
|
||||
|
||||
/* Read and return the value of a HW register
|
||||
* The status register is read after every macroblock encoding by SW
|
||||
* The other registers which may be updated by the HW are read after
|
||||
* BUFFER_FULL or FRAME_READY interrupt
|
||||
* Offset is relative to the the HW ID register (#0) in bytes */
|
||||
u32 EWLReadReg(const void *inst, u32 offset);
|
||||
|
||||
/* Writing all registers in one call *//*Not in use currently */
|
||||
void EWLWriteRegAll(const void *inst, const u32 * table, u32 size);
|
||||
/* Reading all registers in one call *//*Not in use currently */
|
||||
void EWLReadRegAll(const void *inst, u32 * table, u32 size);
|
||||
|
||||
/* HW enable/disable. This will write <val> to register <offset> and by */
|
||||
/* this enablig/disabling the hardware. */
|
||||
void EWLEnableHW(const void *inst, u32 offset, u32 val);
|
||||
void EWLDisableHW(const void *inst, u32 offset, u32 val);
|
||||
|
||||
/* Synchronize SW with HW
|
||||
* Returns EWL_HW_WAIT_OK, EWL_HW_WAIT_ERROR or EWL_HW_WAIT_TIMEOUT
|
||||
* EWLWaitHwRdy is called after enabling the HW to wait for IRQ from HW.
|
||||
* If slicesReady pointer is given, at input it should contain the number
|
||||
* of slicesReady received. The function will return when the HW has finished
|
||||
* encoding next slice. Upon return the slicesReady pointer will contain
|
||||
* the number of slices that are ready and available in the HW output buffer.
|
||||
*/
|
||||
i32 EWLWaitHwRdy(const void *inst, u32 *slicesReady);
|
||||
|
||||
/* SW/SW shared memory handling */
|
||||
void *EWLmalloc(u32 n);
|
||||
void *EWLcalloc(u32 n, u32 s);
|
||||
void EWLfree(void *p);
|
||||
void *EWLmemcpy(void *d, const void *s, u32 n);
|
||||
void *EWLmemset(void *d, i32 c, u32 n);
|
||||
int EWLmemcmp(const void *s1, const void *s2, u32 n);
|
||||
|
||||
/* Get the base address of on-chip sram used for input MB line buffer. */
|
||||
i32 EWLGetInputLineBufferBase(const void *instance, EWLLinearMem_t * info);
|
||||
|
||||
/* Clear Line Buffer IRQ status bit */
|
||||
void EWLClearLineBufferIrq (const void *inst, u32 offset, u32 val);
|
||||
#endif
|
||||
|
||||
#if AMEBA_PRO
|
||||
#define EWL_OK 0
|
||||
#define EWL_ERROR -1
|
||||
|
||||
#define EWL_HW_WAIT_OK EWL_OK
|
||||
#define EWL_HW_WAIT_ERROR EWL_ERROR
|
||||
#define EWL_HW_WAIT_TIMEOUT 1
|
||||
|
||||
/* HW configuration values */
|
||||
#define EWL_HW_BUS_TYPE_UNKNOWN 0
|
||||
#define EWL_HW_BUS_TYPE_AHB 1
|
||||
#define EWL_HW_BUS_TYPE_OCP 2
|
||||
#define EWL_HW_BUS_TYPE_AXI 3
|
||||
#define EWL_HW_BUS_TYPE_PCI 4
|
||||
|
||||
#define EWL_HW_BUS_WIDTH_UNKNOWN 0
|
||||
#define EWL_HW_BUS_WIDTH_32BITS 1
|
||||
#define EWL_HW_BUS_WIDTH_64BITS 2
|
||||
#define EWL_HW_BUS_WIDTH_128BITS 3
|
||||
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_UNKNOWN 0
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_VHDL 1
|
||||
#define EWL_HW_SYNTHESIS_LANGUAGE_VERILOG 2
|
||||
|
||||
#define EWL_HW_CONFIG_NOT_SUPPORTED 0
|
||||
#define EWL_HW_CONFIG_ENABLED 1
|
||||
|
||||
/* Hardware configuration description */
|
||||
typedef struct EWLHwConfig
|
||||
{
|
||||
u32 maxEncodedWidth; /* Maximum supported width for video encoding (not JPEG) */
|
||||
u32 h264Enabled; /* HW supports H.264 */
|
||||
u32 jpegEnabled; /* HW supports JPEG */
|
||||
u32 vp8Enabled; /* HW supports VP8 */
|
||||
u32 vsEnabled; /* HW supports video stabilization */
|
||||
u32 rgbEnabled; /* HW supports RGB input */
|
||||
u32 searchAreaSmall; /* HW search area reduced */
|
||||
u32 scalingEnabled; /* HW supports down-scaling */
|
||||
u32 busType; /* HW bus type in use */
|
||||
u32 busWidth;
|
||||
u32 synthesisLanguage;
|
||||
} EWLHwConfig_t;
|
||||
|
||||
/* Allocated linear memory area information */
|
||||
typedef struct EWLLinearMem
|
||||
{
|
||||
u32 *virtualAddress;
|
||||
u32 busAddress;
|
||||
u32 size;
|
||||
} EWLLinearMem_t;
|
||||
|
||||
/* EWLInitParam is used to pass parameters when initializing the EWL */
|
||||
typedef struct EWLInitParam
|
||||
{
|
||||
u32 clientType;
|
||||
} EWLInitParam_t;
|
||||
|
||||
#define EWL_CLIENT_TYPE_H264_ENC 1U
|
||||
#define EWL_CLIENT_TYPE_VP8_ENC 2U
|
||||
#define EWL_CLIENT_TYPE_JPEG_ENC 3U
|
||||
#define EWL_CLIENT_TYPE_VIDEOSTAB 4U
|
||||
|
||||
extern void (*pollInputLineBufTestFunc)(void);
|
||||
|
||||
/* define encorder core type */
|
||||
enum enc_type_e
|
||||
{
|
||||
EncH264 = 0,
|
||||
EncJPEG = 1
|
||||
|
||||
};
|
||||
typedef uint8_t enc_type_t;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Read and return the HW ID register value, static implementation */
|
||||
u32 EWLReadAsicID(enc_type_t enc_type);
|
||||
|
||||
/* Read and return HW configuration info, static implementation */
|
||||
EWLHwConfig_t EWLReadAsicConfig(enc_type_t enc_type);
|
||||
|
||||
/* Initialize the EWL instance
|
||||
* Returns a wrapper instance or NULL for error
|
||||
* EWLInit is called when the encoder instance is initialized */
|
||||
const void *EWLInit(EWLInitParam_t * param);
|
||||
|
||||
/* Release the EWL instance
|
||||
* Returns EWL_OK or EWL_ERROR
|
||||
* EWLRelease is called when the encoder instance is released */
|
||||
i32 EWLRelease(const void *inst);
|
||||
|
||||
/* Reserve the HW resource for one codec instance
|
||||
* EWLReserveHw is called when beginning a frame encoding
|
||||
* The function may block until the resource is available.
|
||||
* Returns EWL_OK if the resource was successfully reserved for this instance
|
||||
* or EWL_ERROR if unable to reserve the resource. */
|
||||
i32 EWLReserveHw(const void *inst);
|
||||
|
||||
/* Release the HW resource
|
||||
* EWLReleaseHw is called when the HW has finished the frame encoding.
|
||||
* The codec SW will continue the frame encoding but the HW can
|
||||
* be used by another codec.*/
|
||||
void EWLReleaseHw(const void *inst);
|
||||
|
||||
/* Frame buffers memory */
|
||||
i32 EWLMallocRefFrm(const void *inst, u32 size, EWLLinearMem_t * info);
|
||||
void EWLFreeRefFrm(const void *inst, EWLLinearMem_t * info);
|
||||
|
||||
/* SW/HW shared memory */
|
||||
i32 EWLMallocLinear(const void *inst, u32 size, EWLLinearMem_t * info);
|
||||
void EWLFreeLinear(const void *inst, EWLLinearMem_t * info);
|
||||
|
||||
/* D-Cache coherence *//* Not in use currently */
|
||||
void EWLDCacheRangeFlush(const void *instance, EWLLinearMem_t * info);
|
||||
void EWLDCacheRangeRefresh(const void *instance, EWLLinearMem_t * info);
|
||||
|
||||
/* Write value to a HW register
|
||||
* All registers are written at once at the beginning of frame encoding
|
||||
* Offset is relative to the the HW ID register (#0) in bytes
|
||||
* Enable indicates when the HW is enabled. If shadow registers are used then
|
||||
* they must be flushed to the HW registers when enable is '1' before
|
||||
* writing the register that enables the HW */
|
||||
void EWLWriteReg(const void *inst, u32 offset, u32 val);
|
||||
|
||||
/* Read and return the value of a HW register
|
||||
* The status register is read after every macroblock encoding by SW
|
||||
* The other registers which may be updated by the HW are read after
|
||||
* BUFFER_FULL or FRAME_READY interrupt
|
||||
* Offset is relative to the the HW ID register (#0) in bytes */
|
||||
u32 EWLReadReg(const void *inst, u32 offset);
|
||||
|
||||
/* Writing all registers in one call *//*Not in use currently */
|
||||
void EWLWriteRegAll(const void *inst, const u32 * table, u32 size);
|
||||
/* Reading all registers in one call *//*Not in use currently */
|
||||
void EWLReadRegAll(const void *inst, u32 * table, u32 size);
|
||||
|
||||
/* HW enable/disable. This will write <val> to register <offset> and by */
|
||||
/* this enablig/disabling the hardware. */
|
||||
void EWLEnableHW(const void *inst, u32 offset, u32 val);
|
||||
void EWLDisableHW(const void *inst, u32 offset, u32 val);
|
||||
|
||||
/* Synchronize SW with HW
|
||||
* Returns EWL_HW_WAIT_OK, EWL_HW_WAIT_ERROR or EWL_HW_WAIT_TIMEOUT
|
||||
* EWLWaitHwRdy is called after enabling the HW to wait for IRQ from HW.
|
||||
* If slicesReady pointer is given, at input it should contain the number
|
||||
* of slicesReady received. The function will return when the HW has finished
|
||||
* encoding next slice. Upon return the slicesReady pointer will contain
|
||||
* the number of slices that are ready and available in the HW output buffer.
|
||||
*/
|
||||
i32 EWLWaitHwRdy(const void *inst, u32 *slicesReady);
|
||||
|
||||
/* SW/SW shared memory handling */
|
||||
void *EWLmalloc(u32 n);
|
||||
void *EWLcalloc(u32 n, u32 s);
|
||||
void EWLfree(void *p);
|
||||
void *EWLmemcpy(void *d, const void *s, u32 n);
|
||||
void *EWLmemset(void *d, i32 c, u32 n);
|
||||
int EWLmemcmp(const void *s1, const void *s2, u32 n);
|
||||
|
||||
/* Get the base address of on-chip sram used for input MB line buffer. */
|
||||
i32 EWLGetInputLineBufferBase(const void *instance, EWLLinearMem_t * info);
|
||||
|
||||
/* Clear Line Buffer IRQ status bit */
|
||||
void EWLClearLineBufferIrq (const void *inst, u32 offset, u32 val);
|
||||
|
||||
/*IRQ DeInit*/
|
||||
//void EWLIrqDeinit(void* pdata);
|
||||
void EWLIrqDeinit(int type);
|
||||
/*Register IRQ*/
|
||||
//void EWLIrqRegister(void *ptg_adp);
|
||||
void EWLIrqRegister(int type);
|
||||
|
||||
|
||||
//============== memory define ========================//
|
||||
#if 0
|
||||
#define CABAC_BUF_BASE_ADDR 0x70000000
|
||||
#define CONTROL_BUF_BASE_ADDR 0x70010000
|
||||
#define MV_OUTPUT_BUF_BASE_ADDR 0x70020000
|
||||
#define PIC_OUTPUT_BUF_BASE_ADDR 0x700C0000
|
||||
#define PIC_INPUT_BUF_BASE_ADDR 0x70200000
|
||||
#define INTERNAL_LUMA0_BASE_ADDR 0x70A00000
|
||||
#define INTERNAL_CHROM0_BASE_ADDR 0x70C00000
|
||||
#define INTERNAL_LUMA1_BASE_ADDR 0x70D00000
|
||||
#define INTERNAL_CHROM1_BASE_ADDR 0x70F00000
|
||||
#else
|
||||
|
||||
#endif
|
||||
//================================================//
|
||||
//encswhwregisters.c file
|
||||
//#define DEBUG_PRINT_REGS
|
||||
//encommon.h // NALU settinh log
|
||||
//#define ENCCOMMON_LOG
|
||||
//H264Init.c log
|
||||
//#define LOG_H264INIT
|
||||
//H264EncApi.c
|
||||
//#define H264ENCAPI_LOG
|
||||
//H264PictureBuffer.c
|
||||
//#define TRACE_PIC_BUFFER
|
||||
//h264testbench.c: ISP write frame
|
||||
//#define ISP_LOG_ENABLE
|
||||
//h264RateControl.c
|
||||
//#define ENABLE_H264_RC_LOG
|
||||
//encasiccontroller.c log
|
||||
//#define ENABLE_MEM_DBG
|
||||
|
||||
//Configure ISR pr poll mode
|
||||
#define ENABLE_ISR_MODE
|
||||
//Input Selection
|
||||
//#define INPUT_SAMAN
|
||||
#define INPUT_PARK_RUN
|
||||
//#define PXP_REPEAT_MODE_NEABLE
|
||||
#define MAX_REGRESSION_LOOP_NUM 3
|
||||
//#define ENABLE_ISP_MODEL_PARALLEL_MODE
|
||||
#define ENABLE_REAL_ISP
|
||||
//#define AUTO_CABAC_ADDRESS
|
||||
//#define INIT_CABAC_ADDRESS
|
||||
|
||||
//#define _VOE_NO_USE
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__EWL_H__*/
|
||||
|
|
@ -0,0 +1,564 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Hantro H1 H.264 Encoder API
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264ENCAPI_H__
|
||||
#define __H264ENCAPI_H__
|
||||
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Type definition for encoder instance
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef const void *H264EncInst;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Enumerations for API parameters
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Function return values */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_OK = 0,
|
||||
H264ENC_FRAME_READY = 1,
|
||||
|
||||
H264ENC_ERROR = -1,
|
||||
H264ENC_NULL_ARGUMENT = -2,
|
||||
H264ENC_INVALID_ARGUMENT = -3,
|
||||
H264ENC_MEMORY_ERROR = -4,
|
||||
H264ENC_EWL_ERROR = -5,
|
||||
H264ENC_EWL_MEMORY_ERROR = -6,
|
||||
H264ENC_INVALID_STATUS = -7,
|
||||
H264ENC_OUTPUT_BUFFER_OVERFLOW = -8,
|
||||
H264ENC_HW_BUS_ERROR = -9,
|
||||
H264ENC_HW_DATA_ERROR = -10,
|
||||
H264ENC_HW_TIMEOUT = -11,
|
||||
H264ENC_HW_RESERVED = -12,
|
||||
H264ENC_SYSTEM_ERROR = -13,
|
||||
H264ENC_INSTANCE_ERROR = -14,
|
||||
H264ENC_HRD_ERROR = -15,
|
||||
H264ENC_HW_RESET = -16
|
||||
} H264EncRet;
|
||||
|
||||
/* Stream type for initialization */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_BYTE_STREAM = 0, /* H.264 annex B: NAL unit starts with
|
||||
* hex bytes '00 00 00 01' */
|
||||
H264ENC_NAL_UNIT_STREAM = 1 /* Plain NAL units without startcode */
|
||||
} H264EncStreamType;
|
||||
|
||||
/* Stream view mode and buffer requirement for initialization */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_BASE_VIEW_DOUBLE_BUFFER = 0, /* H.264 stream using
|
||||
two reference frame buffers */
|
||||
H264ENC_BASE_VIEW_SINGLE_BUFFER = 1, /* H.264 stream using
|
||||
one reference frame buffers,
|
||||
HRD frame discard not possible */
|
||||
H264ENC_MVC_STEREO_INTER_VIEW_PRED = 2, /* H.264 MVC Stereo stream using
|
||||
one reference frame buffer,
|
||||
no HRD frame discard,
|
||||
second view is always
|
||||
inter-view predicted */
|
||||
H264ENC_MVC_STEREO_INTER_PRED = 3, /* H.264 MVC Stereo stream using
|
||||
two reference frame buffers,
|
||||
no HRD frame discard,
|
||||
second view can be inter
|
||||
predicted */
|
||||
H264ENC_BASE_VIEW_MULTI_BUFFER = 4, /* H.264 stream using
|
||||
two or more reference frame buffers */
|
||||
H264ENC_INTERLACED_FIELD = 5, /* H.264 stream coded as fields
|
||||
of interlaced video */
|
||||
} H264EncViewMode;
|
||||
|
||||
/* Level for initialization */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_LEVEL_1 = 10,
|
||||
H264ENC_LEVEL_1_b = 99,
|
||||
H264ENC_LEVEL_1_1 = 11,
|
||||
H264ENC_LEVEL_1_2 = 12,
|
||||
H264ENC_LEVEL_1_3 = 13,
|
||||
H264ENC_LEVEL_2 = 20,
|
||||
H264ENC_LEVEL_2_1 = 21,
|
||||
H264ENC_LEVEL_2_2 = 22,
|
||||
H264ENC_LEVEL_3 = 30,
|
||||
H264ENC_LEVEL_3_1 = 31,
|
||||
H264ENC_LEVEL_3_2 = 32,
|
||||
H264ENC_LEVEL_4 = 40,
|
||||
H264ENC_LEVEL_4_1 = 41,
|
||||
H264ENC_LEVEL_4_2 = 42,
|
||||
H264ENC_LEVEL_5 = 50,
|
||||
H264ENC_LEVEL_5_1 = 51
|
||||
} H264EncLevel;
|
||||
|
||||
/* Picture YUV type for initialization */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV... */
|
||||
H264ENC_YUV420_SEMIPLANAR, /* YYYY... UVUVUV... */
|
||||
H264ENC_YUV420_SEMIPLANAR_VU, /* YYYY... VUVUVU... */
|
||||
H264ENC_YUV422_INTERLEAVED_YUYV, /* YUYVYUYV... */
|
||||
H264ENC_YUV422_INTERLEAVED_UYVY, /* UYVYUYVY... */
|
||||
H264ENC_RGB565, /* 16-bit RGB 16bpp */
|
||||
H264ENC_BGR565, /* 16-bit RGB 16bpp */
|
||||
H264ENC_RGB555, /* 15-bit RGB 16bpp */
|
||||
H264ENC_BGR555, /* 15-bit RGB 16bpp */
|
||||
H264ENC_RGB444, /* 12-bit RGB 16bpp */
|
||||
H264ENC_BGR444, /* 12-bit RGB 16bpp */
|
||||
H264ENC_RGB888, /* 24-bit RGB 32bpp */
|
||||
H264ENC_BGR888, /* 24-bit RGB 32bpp */
|
||||
H264ENC_RGB101010, /* 30-bit RGB 32bpp */
|
||||
H264ENC_BGR101010, /* 30-bit RGB 32bpp */
|
||||
H264ENC_YUV420_COMPRESSED /* compressed yuv420 */
|
||||
} H264EncPictureType;
|
||||
|
||||
/* Picture rotation for pre-processing */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_ROTATE_0 = 0,
|
||||
H264ENC_ROTATE_90R = 1, /* Rotate 90 degrees clockwise */
|
||||
H264ENC_ROTATE_90L = 2 /* Rotate 90 degrees counter-clockwise */
|
||||
} H264EncPictureRotation;
|
||||
|
||||
/* Picture color space conversion (RGB input) for pre-processing */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_RGBTOYUV_BT601 = 0, /* Color conversion according to BT.601 */
|
||||
H264ENC_RGBTOYUV_BT709 = 1, /* Color conversion according to BT.709 */
|
||||
H264ENC_RGBTOYUV_USER_DEFINED = 2 /* User defined color conversion */
|
||||
} H264EncColorConversionType;
|
||||
|
||||
/* Picture type for encoding */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_INTRA_FRAME = 0, /* IDR-frame or field */
|
||||
H264ENC_PREDICTED_FRAME = 1, /* P-frame or field */
|
||||
H264ENC_NONIDR_INTRA_FRAME = 2, /* Non-IDR I-frame or field */
|
||||
H264ENC_NOTCODED_FRAME /* Used just as a return value */
|
||||
} H264EncPictureCodingType;
|
||||
|
||||
/* Reference picture mode for reading and writing */
|
||||
typedef enum
|
||||
{
|
||||
H264ENC_NO_REFERENCE_NO_REFRESH = 0,
|
||||
H264ENC_REFERENCE = 1,
|
||||
H264ENC_REFRESH = 2,
|
||||
H264ENC_REFERENCE_AND_REFRESH = 3
|
||||
} H264EncRefPictureMode;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Structures for API function parameters
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Configuration info for initialization
|
||||
* Width and height are picture dimensions after rotation
|
||||
* Width and height are restricted by level limitations
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
H264EncStreamType streamType; /* Byte stream / Plain NAL units */
|
||||
H264EncViewMode viewMode; /* Mode of stream to be generated and
|
||||
the corresponding amount of encoder
|
||||
internal frame buffers required */
|
||||
/* Stream Profile will be automatically decided based on parameters:
|
||||
* CABAC -> Main/High Profile,
|
||||
* 8x8-transform -> High Profile,
|
||||
* MVC -> Stereo High Profile */
|
||||
H264EncLevel level;
|
||||
u32 width; /* Encoded picture width in pixels, multiple of 4 */
|
||||
u32 height; /* Encoded picture height in pixels, multiple of 2 */
|
||||
u32 frameRateNum; /* The stream time scale, [1..1048575] */
|
||||
u32 frameRateDenom; /* Maximum frame rate is frameRateNum/frameRateDenom
|
||||
* in frames/second. The actual frame rate will be
|
||||
* defined by timeIncrement of encoded pictures,
|
||||
* [1..frameRateNum] */
|
||||
u32 scaledWidth; /* Optional down-scaled output picture width,
|
||||
multiple of 4. 0=disabled. [16..width] */
|
||||
u32 scaledHeight; /* Optional down-scaled output picture height,
|
||||
multiple of 2. [96..height] */
|
||||
u32 refFrameAmount; /* Amount of reference frame buffers, [1..2]
|
||||
* 1 = only last frame buffered,
|
||||
* 2 = last and long term frames buffered */
|
||||
u32 refFrameCompress; /* reference frame compress: 0=disable; 1=enable */
|
||||
u32 rfcLumBufLimit; /* Limit of luma RFC buffer in percent of original reference frame size. */
|
||||
u32 rfcChrBufLimit; /* Limit of chroma RFC buffer in percent of original reference frame size. */
|
||||
} H264EncConfig;
|
||||
|
||||
/* Defining rectangular macroblock area in encoder picture */
|
||||
typedef struct
|
||||
{
|
||||
u32 enable; /* [0,1] Enables this area */
|
||||
u32 top; /* Top macroblock row inside area [0..heightMbs-1] */
|
||||
u32 left; /* Left macroblock row inside area [0..widthMbs-1] */
|
||||
u32 bottom; /* Bottom macroblock row inside area [top..heightMbs-1] */
|
||||
u32 right; /* Right macroblock row inside area [left..widthMbs-1] */
|
||||
} H264EncPictureArea;
|
||||
|
||||
/* Coding control parameters */
|
||||
typedef struct
|
||||
{
|
||||
u32 sliceSize; /* Slice size in macroblock rows,
|
||||
* 0 to encode each picture in one slice,
|
||||
* [0..height/16]
|
||||
*/
|
||||
u32 seiMessages; /* Insert picture timing and buffering
|
||||
* period SEI messages into the stream,
|
||||
* [0,1]
|
||||
*/
|
||||
u32 idrHeader; /* Insert SPS/PPS header to stream either
|
||||
* for every IDR frame or only to the beginning
|
||||
* of the sequence.
|
||||
* [0,1]
|
||||
*/
|
||||
u32 videoFullRange; /* Input video signal sample range, [0,1]
|
||||
* 0 = Y range in [16..235],
|
||||
* Cb&Cr range in [16..240]
|
||||
* 1 = Y, Cb and Cr range in [0..255]
|
||||
*/
|
||||
u32 constrainedIntraPrediction; /* 0 = No constrains,
|
||||
* 1 = Only use intra neighbours */
|
||||
u32 disableDeblockingFilter; /* 0 = Filter enabled,
|
||||
* 1 = Filter disabled,
|
||||
* 2 = Filter disabled on slice edges */
|
||||
u32 sampleAspectRatioWidth; /* Horizontal size of the sample aspect
|
||||
* ratio (in arbitrary units), 0 for
|
||||
* unspecified, [0..65535]
|
||||
*/
|
||||
u32 sampleAspectRatioHeight; /* Vertical size of the sample aspect ratio
|
||||
* (in same units as sampleAspectRatioWidth)
|
||||
* 0 for unspecified, [0..65535]
|
||||
*/
|
||||
u32 enableCabac; /* 0 = CAVLC - Baseline profile,
|
||||
* 1 = CABAC - Main profile,
|
||||
* 2 = CABAC/CAVLC frame based -
|
||||
* Performance optimized Main profile with
|
||||
* Intra frames encoded using CAVLC and
|
||||
* Inter frames encoded using CABAC */
|
||||
u32 cabacInitIdc; /* [0,2] CABAC table initial value */
|
||||
u32 transform8x8Mode; /* Enable 8x8 transform mode, High profile
|
||||
* 0=disabled, 1=adaptive 8x8, 2=always 8x8 */
|
||||
u32 quarterPixelMv; /* 1/4 pixel motion estimation
|
||||
* 0=disabled, 1=adaptive, 2=enabled */
|
||||
u32 cirStart; /* [0..mbTotal] First macroblock for
|
||||
Cyclic Intra Refresh */
|
||||
u32 cirInterval; /* [0..mbTotal] Macroblock interval for
|
||||
Cyclic Intra Refresh, 0=disabled */
|
||||
u32 intraSliceMap1; /* Bitmap for forcing slices 0..31 to intra,
|
||||
LSB=slice 0, MSB=slice 31, 1=intra. */
|
||||
u32 intraSliceMap2; /* Bitmap for forcing slices 32..63 to intra,
|
||||
LSB=slice 32, MSB=slice 63, 1=intra. */
|
||||
u32 intraSliceMap3; /* Bitmap for forcing slices 64..95 to intra,
|
||||
LSB=slice 64, MSB=slice 95, 1=intra. */
|
||||
H264EncPictureArea intraArea; /* Area for forcing intra macroblocks */
|
||||
H264EncPictureArea roi1Area; /* Area for 1st Region-Of-Interest */
|
||||
H264EncPictureArea roi2Area; /* Area for 2nd Region-Of-Interest */
|
||||
i32 roi1DeltaQp; /* [-15..0] QP delta value for 1st ROI */
|
||||
i32 roi2DeltaQp; /* [-15..0] QP delta value for 2nd ROI */
|
||||
i32 adaptiveRoi; /* [-51..0] QP delta value for adaptive ROI */
|
||||
i32 adaptiveRoiColor; /* [-10..10] Color temperature sensitivity
|
||||
* for adaptive ROI skin detection.
|
||||
* -10 = 2000K, 0=3000K, 10=5000K */
|
||||
i32 roiMapEnable; /* ROI map status, 0=disable, 1=enable. */
|
||||
i32 qpOffset[3]; /* when roiMapEnable is 1, the qp offset for index 1,2,3. */
|
||||
u32 fieldOrder; /* Field order for interlaced coding,
|
||||
0 = bottom field first, 1 = top field first */
|
||||
u32 gdrDuration; /*how many pictures it will take to do GDR, if 0, not do GDR*/
|
||||
|
||||
u32 inputLineBufEn; /* enable input image control signals */
|
||||
u32 inputLineBufLoopBackEn; /* input buffer loopback mode enable */
|
||||
u32 inputLineBufDepth; /* input buffer depth in mb lines */
|
||||
u32 inputLineBufHwModeEn; /* hw handshake*/
|
||||
} H264EncCodingCtrl;
|
||||
|
||||
/* Rate control parameters */
|
||||
typedef struct
|
||||
{
|
||||
u32 pictureRc; /* Adjust QP between pictures, [0,1] */
|
||||
u32 mbRc; /* Adjust QP inside picture, [0,1] */
|
||||
u32 pictureSkip; /* Allow rate control to skip pictures, [0,1] */
|
||||
i32 qpHdr; /* QP for next encoded picture, [-1..51]
|
||||
* -1 = Let rate control calculate initial QP
|
||||
* This QP is used for all pictures if
|
||||
* HRD and pictureRc and mbRc are disabled
|
||||
* If HRD is enabled it may override this QP
|
||||
*/
|
||||
u32 qpMin; /* Minimum QP for any picture, [0..51] */
|
||||
u32 qpMax; /* Maximum QP for any picture, [0..51] */
|
||||
u32 bitPerSecond; /* Target bitrate in bits/second, this is
|
||||
* needed if pictureRc, mbRc, pictureSkip or
|
||||
* hrd is enabled [10000..60000000]
|
||||
*/
|
||||
u32 hrd; /* Hypothetical Reference Decoder model, [0,1]
|
||||
* restricts the instantaneous bitrate and
|
||||
* total bit amount of every coded picture.
|
||||
* Enabling HRD will cause tight constrains
|
||||
* on the operation of the rate control
|
||||
*/
|
||||
u32 hrdCpbSize; /* Size of Coded Picture Buffer in HRD (bits) */
|
||||
u32 gopLen; /* Length for Group of Pictures, indicates
|
||||
* the distance of two intra pictures,
|
||||
* including first intra [1..300]
|
||||
*/
|
||||
i32 intraQpDelta; /* Intra QP delta. intraQP = QP + intraQpDelta
|
||||
* This can be used to change the relative quality
|
||||
* of the Intra pictures or to lower the size
|
||||
* of Intra pictures. [-12..12]
|
||||
*/
|
||||
u32 fixedIntraQp; /* Fixed QP value for all Intra pictures, [0..51]
|
||||
* 0 = Rate control calculates intra QP.
|
||||
*/
|
||||
i32 mbQpAdjustment; /* Encoder uses MAD thresholding to recognize
|
||||
* macroblocks with least details. This value is
|
||||
* used to adjust the QP of these macroblocks
|
||||
* increasing the subjective quality. [-8..7]
|
||||
*/
|
||||
i32 longTermPicRate; /* period between long term pic refreshes */
|
||||
i32 mbQpAutoBoost; /* Encoder uses motion vectors and variance to
|
||||
* recognize background/object macroblocks.
|
||||
* This value is used to enable the auto QP
|
||||
* boost of these macroblocks. [0,1]
|
||||
*/
|
||||
i32 adaptQpEn; /* adjust qpMax and qpMin dynamicly
|
||||
* qpMin range [max(qpMin-6, 10)..qpMin]
|
||||
* qpMax range [qpMax..min(qpMax-6, 51)]
|
||||
*/
|
||||
} H264EncRateCtrl;
|
||||
|
||||
/* Encoder input structure */
|
||||
typedef struct
|
||||
{
|
||||
u32 busLuma; /* Bus address for input picture
|
||||
* planar format: luminance component
|
||||
* semiplanar format: luminance component
|
||||
* interleaved format: whole picture
|
||||
*/
|
||||
u32 busChromaU; /* Bus address for input chrominance
|
||||
* planar format: cb component
|
||||
* semiplanar format: both chrominance
|
||||
* interleaved format: not used
|
||||
*/
|
||||
u32 busChromaV; /* Bus address for input chrominance
|
||||
* planar format: cr component
|
||||
* semiplanar format: not used
|
||||
* interleaved format: not used
|
||||
*/
|
||||
u32 timeIncrement; /* The previous picture duration in units
|
||||
* of 1/frameRateNum. 0 for the very first picture
|
||||
* and typically equal to frameRateDenom for the rest.
|
||||
*/
|
||||
u32 *pOutBuf; /* Pointer to output stream buffer */
|
||||
u32 busOutBuf; /* Bus address of output stream buffer */
|
||||
u32 outBufSize; /* Size of output stream buffer in bytes */
|
||||
H264EncPictureCodingType codingType; /* Proposed picture coding type,
|
||||
* INTRA/PREDICTED
|
||||
*/
|
||||
u32 busLumaStab; /* bus address of next picture to stabilize (luminance) */
|
||||
H264EncRefPictureMode ipf; /* Immediately previous == last frame */
|
||||
H264EncRefPictureMode ltrf; /* Long term reference frame */
|
||||
|
||||
u32 busLumaTable; /* Bus address for compression table of input luminance if input is compressed */
|
||||
u32 busChromaTable; /* Bus address for compression table of input chrominance if input is compressed */
|
||||
u32 busLumaStabTable;
|
||||
|
||||
u32 lineBufWrCnt; /* The number of MB lines already in input MB line buffer */
|
||||
} H264EncIn;
|
||||
|
||||
/* Encoder output structure */
|
||||
typedef struct
|
||||
{
|
||||
H264EncPictureCodingType codingType; /* Realized picture coding type,
|
||||
* INTRA/PREDICTED/NOTCODED
|
||||
*/
|
||||
u32 streamSize; /* Size of output stream in bytes */
|
||||
i8 *motionVectors; /* One pixel motion vector x and y and corresponding
|
||||
SAD value for every macroblock.
|
||||
Format: mb0x mb0y mb0sadMsb mb0sadLsb mb1x .. */
|
||||
u32 *pNaluSizeBuf; /* Output buffer for NAL unit sizes
|
||||
* pNaluSizeBuf[0] = NALU 0 size in bytes
|
||||
* pNaluSizeBuf[1] = NALU 1 size in bytes
|
||||
* etc
|
||||
* Zero value is written after last NALU.
|
||||
*/
|
||||
u32 numNalus; /* Amount of NAL units */
|
||||
u32 mse_mul256; /* Encoded frame Mean Squared Error
|
||||
multiplied by 256. */
|
||||
u32 busScaledLuma; /* Bus address for scaled encoder picture luma */
|
||||
u8 *scaledPicture; /* Pointer for scaled encoder picture */
|
||||
H264EncRefPictureMode ipf; /* Immediately previous == last frame */
|
||||
H264EncRefPictureMode ltrf; /* Long term reference frame */
|
||||
} H264EncOut;
|
||||
|
||||
/* Input pre-processing */
|
||||
typedef struct
|
||||
{
|
||||
H264EncColorConversionType type;
|
||||
u16 coeffA; /* User defined color conversion coefficient */
|
||||
u16 coeffB; /* User defined color conversion coefficient */
|
||||
u16 coeffC; /* User defined color conversion coefficient */
|
||||
u16 coeffE; /* User defined color conversion coefficient */
|
||||
u16 coeffF; /* User defined color conversion coefficient */
|
||||
} H264EncColorConversion;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 origWidth; /* Input camera picture width */
|
||||
u32 origHeight; /* Input camera picture height*/
|
||||
u32 xOffset; /* Horizontal offset */
|
||||
u32 yOffset; /* Vertical offset */
|
||||
H264EncPictureType inputType; /* Input picture color format */
|
||||
H264EncPictureRotation rotation; /* Input picture rotation */
|
||||
u32 videoStabilization; /* Enable video stabilization */
|
||||
H264EncColorConversion colorConversion; /* Define color conversion
|
||||
parameters for RGB input */
|
||||
u32 scaledOutput; /* Enable output of down-scaled
|
||||
encoder picture. Dimensions
|
||||
specified at Init. */
|
||||
u32 interlacedFrame; /* Enable input frame format
|
||||
with two interlaced fields.
|
||||
Even pictures will be read
|
||||
from top field, odd pictures
|
||||
from bottom field. */
|
||||
} H264EncPreProcessingCfg;
|
||||
|
||||
/* Callback struct and function type. The callback is made by the encoder
|
||||
* when a slice is completed and available in the encoder stream output buffer. */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 slicesReadyPrev;/* Indicates how many slices were completed at
|
||||
previous callback. This is given because
|
||||
several slices can be completed between
|
||||
the callbacks. */
|
||||
u32 slicesReady; /* Indicates how many slices are completed. */
|
||||
u32 *sliceSizes; /* Holds the size (bytes) of every completed slice. */
|
||||
u32 *pOutBuf; /* Pointer to beginning of output stream buffer. */
|
||||
void *pAppData; /* Pointer to application data. */
|
||||
} H264EncSliceReady;
|
||||
|
||||
typedef void (*H264EncSliceReadyCallBackFunc)(H264EncSliceReady *sliceReady);
|
||||
|
||||
/* Version information */
|
||||
typedef struct
|
||||
{
|
||||
u32 major; /* Encoder API major version */
|
||||
u32 minor; /* Encoder API minor version */
|
||||
} H264EncApiVersion;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 swBuild; /* Software build ID */
|
||||
u32 hwBuild; /* Hardware build ID */
|
||||
} H264EncBuild;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Encoder API function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Version information */
|
||||
H264EncApiVersion H264EncGetApiVersion(void);
|
||||
H264EncBuild H264EncGetBuild(void);
|
||||
|
||||
/* Helper for input format bit-depths */
|
||||
u32 H264EncGetBitsPerPixel(H264EncPictureType type);
|
||||
|
||||
/* Initialization & release */
|
||||
H264EncRet H264EncInit(const H264EncConfig * pEncConfig,
|
||||
H264EncInst * instAddr);
|
||||
H264EncRet H264EncRelease(H264EncInst inst);
|
||||
|
||||
/* Encoder configuration before stream generation */
|
||||
H264EncRet H264EncSetCodingCtrl(H264EncInst inst, const H264EncCodingCtrl *
|
||||
pCodingParams);
|
||||
H264EncRet H264EncGetCodingCtrl(H264EncInst inst, H264EncCodingCtrl *
|
||||
pCodingParams);
|
||||
|
||||
/* Encoder configuration before and during stream generation */
|
||||
H264EncRet H264EncSetRateCtrl(H264EncInst inst,
|
||||
const H264EncRateCtrl * pRateCtrl);
|
||||
H264EncRet H264EncGetRateCtrl(H264EncInst inst,
|
||||
H264EncRateCtrl * pRateCtrl);
|
||||
|
||||
H264EncRet H264EncSetPreProcessing(H264EncInst inst,
|
||||
const H264EncPreProcessingCfg *
|
||||
pPreProcCfg);
|
||||
H264EncRet H264EncGetPreProcessing(H264EncInst inst,
|
||||
H264EncPreProcessingCfg * pPreProcCfg);
|
||||
|
||||
H264EncRet H264EncSetRoiMap(H264EncInst inst, u8 *map);
|
||||
|
||||
/* Encoder user data insertion during stream generation */
|
||||
H264EncRet H264EncSetSeiUserData(H264EncInst inst, const u8 * pUserData,
|
||||
u32 userDataSize);
|
||||
|
||||
/* Stream generation */
|
||||
|
||||
/* H264EncStrmStart generates the SPS and PPS. SPS is the first NAL unit and PPS
|
||||
* is the second NAL unit. NaluSizeBuf indicates the size of NAL units.
|
||||
*/
|
||||
H264EncRet H264EncStrmStart(H264EncInst inst, const H264EncIn * pEncIn,
|
||||
H264EncOut * pEncOut);
|
||||
|
||||
/* H264EncStrmEncode encodes one video frame. If SEI messages are enabled the
|
||||
* first NAL unit is a SEI message. When MVC mode is selected first encoded
|
||||
* frame belongs to view=0 and second encoded frame belongs to view=1 and so on.
|
||||
* When MVC mode is selected a prefix NAL unit is generated before view=0 frames.
|
||||
*/
|
||||
H264EncRet H264EncStrmEncode(H264EncInst inst, const H264EncIn * pEncIn,
|
||||
H264EncOut * pEncOut,
|
||||
H264EncSliceReadyCallBackFunc cbFunc,
|
||||
EncInputMBLineBufCallBackFunc lineBufCbFunc,
|
||||
void * pAppData);
|
||||
|
||||
/* H264EncStrmEnd ends a stream with an EOS code. */
|
||||
H264EncRet H264EncStrmEnd(H264EncInst inst, const H264EncIn * pEncIn,
|
||||
H264EncOut * pEncOut);
|
||||
|
||||
/* Hantro internal encoder testing */
|
||||
H264EncRet H264EncSetTestId(H264EncInst inst, u32 testId);
|
||||
|
||||
/* Set valid input MB lines for encoder to work */
|
||||
H264EncRet H264EncSetInputMBLines(H264EncInst inst, int lines);
|
||||
|
||||
/* Get encoded lines information from encoder */
|
||||
int H264EncGetEncodedMbLines(H264EncInst inst);
|
||||
|
||||
/* Set motionVectors field of H264EncOut structure to point macroblock mbNum */
|
||||
H264EncRet H264EncGetMbInfo(H264EncInst inst, H264EncOut * pEncOut,
|
||||
u32 mbNum);
|
||||
|
||||
H264EncRet H264ChangeBitRate(H264EncInst inst, u32 rate);
|
||||
/*------------------------------------------------------------------------------
|
||||
5. Encoder API tracing callback function
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
void H264EncTrace(const char *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__H264ENCAPI_H__*/
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Hantro 6250 H.264 Encoder Extended API
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264ENCAPI_EXT_H__
|
||||
#define __H264ENCAPI_EXT_H__
|
||||
|
||||
#include "basetype.h"
|
||||
#include "h264encapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 disableDeblocking;
|
||||
i32 filterOffsetA;
|
||||
i32 filterOffsetB;
|
||||
} H264EncFilter;
|
||||
|
||||
H264EncRet H264EncGetFilter(H264EncInst inst, H264EncFilter * pEncCfg);
|
||||
H264EncRet H264EncSetFilter(H264EncInst inst,
|
||||
const H264EncFilter * pEncCfg);
|
||||
|
||||
H264EncRet H264EncSetFilter(H264EncInst inst,
|
||||
const H264EncFilter * pEncCfg);
|
||||
|
||||
H264EncRet H264EncSetChromaQpIndexOffset(H264EncInst inst, i32 offset);
|
||||
|
||||
H264EncRet H264EncSetHwBurstSize(H264EncInst inst, u32 burst);
|
||||
|
||||
H264EncRet H264EncSetHwBurstType(H264EncInst inst, u32 burstType);
|
||||
|
||||
H264EncRet H264EncTestInputLineBuf(H264EncInst inst);
|
||||
|
||||
H264EncRet H264EncTestCropping(H264EncInst inst);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__H264ENCAPI_EXT_H__*/
|
||||
|
|
@ -0,0 +1,283 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Hantro H1 JPEG Encoder API
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __JPEGENCAPI_H__
|
||||
#define __JPEGENCAPI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef const void *JpegEncInst;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_FRAME_READY = 1,
|
||||
JPEGENC_RESTART_INTERVAL = 2,
|
||||
JPEGENC_OK = 0,
|
||||
JPEGENC_ERROR = -1,
|
||||
JPEGENC_NULL_ARGUMENT = -2,
|
||||
JPEGENC_INVALID_ARGUMENT = -3,
|
||||
JPEGENC_MEMORY_ERROR = -4,
|
||||
JPEGENC_INVALID_STATUS = -5,
|
||||
JPEGENC_OUTPUT_BUFFER_OVERFLOW = -6,
|
||||
JPEGENC_EWL_ERROR = -7,
|
||||
JPEGENC_EWL_MEMORY_ERROR = -8,
|
||||
JPEGENC_HW_BUS_ERROR = -9,
|
||||
JPEGENC_HW_DATA_ERROR = -10,
|
||||
JPEGENC_HW_TIMEOUT = -11,
|
||||
JPEGENC_HW_RESERVED = -12,
|
||||
JPEGENC_SYSTEM_ERROR = -13,
|
||||
JPEGENC_INSTANCE_ERROR = -14,
|
||||
JPEGENC_HW_RESET = -15
|
||||
} JpegEncRet;
|
||||
|
||||
/* Picture YUV type for initialization */
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV... */
|
||||
JPEGENC_YUV420_SEMIPLANAR, /* YYYY... UVUVUV... */
|
||||
JPEGENC_YUV420_SEMIPLANAR_VU, /* YYYY... VUVUVU... */
|
||||
JPEGENC_YUV422_INTERLEAVED_YUYV, /* YUYVYUYV... */
|
||||
JPEGENC_YUV422_INTERLEAVED_UYVY, /* UYVYUYVY... */
|
||||
JPEGENC_RGB565, /* 16-bit RGB 16bpp */
|
||||
JPEGENC_BGR565, /* 16-bit RGB 16bpp */
|
||||
JPEGENC_RGB555, /* 15-bit RGB 16bpp */
|
||||
JPEGENC_BGR555, /* 15-bit RGB 16bpp */
|
||||
JPEGENC_RGB444, /* 12-bit RGB 16bpp */
|
||||
JPEGENC_BGR444, /* 12-bit RGB 16bpp */
|
||||
JPEGENC_RGB888, /* 24-bit RGB 32bpp */
|
||||
JPEGENC_BGR888, /* 24-bit RGB 32bpp */
|
||||
JPEGENC_RGB101010, /* 30-bit RGB 32bpp */
|
||||
JPEGENC_BGR101010 /* 30-bit RGB 32bpp */
|
||||
} JpegEncFrameType;
|
||||
|
||||
/* Picture rotation for initialization */
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_ROTATE_0 = 0,
|
||||
JPEGENC_ROTATE_90R = 1, /* Rotate 90 degrees clockwise */
|
||||
JPEGENC_ROTATE_90L = 2 /* Rotate 90 degrees counter-clockwise */
|
||||
} JpegEncPictureRotation;
|
||||
|
||||
/* Picture color space conversion for RGB input */
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_RGBTOYUV_BT601 = 0, /* Color conversion according to BT.601 */
|
||||
JPEGENC_RGBTOYUV_BT709 = 1, /* Color conversion according to BT.709 */
|
||||
JPEGENC_RGBTOYUV_USER_DEFINED = 2 /* User defined color conversion */
|
||||
} JpegEncColorConversionType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_WHOLE_FRAME = 0, /* The whole frame is stored in linear memory */
|
||||
JPEGENC_SLICED_FRAME /* The frame is sliced into restart intervals;
|
||||
* Input address is given for each slice */
|
||||
} JpegEncCodingType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_420_MODE = 0, /* Encoding in YUV 4:2:0 mode */
|
||||
JPEGENC_422_MODE /* Encoding in YUV 4:2:2 mode */
|
||||
} JpegEncCodingMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_NO_UNITS = 0, /* No units,
|
||||
* X and Y specify the pixel aspect ratio */
|
||||
JPEGENC_DOTS_PER_INCH = 1, /* X and Y are dots per inch */
|
||||
JPEGENC_DOTS_PER_CM = 2 /* X and Y are dots per cm */
|
||||
} JpegEncAppUnitsType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_SINGLE_MARKER = 0, /* Luma/Chroma tables are written behind
|
||||
* one marker */
|
||||
JPEGENC_MULTI_MARKER /* Luma/Chroma tables are written behind
|
||||
* one marker/component */
|
||||
} JpegEncTableMarkerType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENC_THUMB_JPEG = 0x10, /* Thumbnail coded using JPEG */
|
||||
JPEGENC_THUMB_PALETTE_RGB8 = 0x11, /* Thumbnail stored using 1 byte/pixel */
|
||||
JPEGENC_THUMB_RGB24 = 0x13 /* Thumbnail stored using 3 bytes/pixel */
|
||||
} JpegEncThumbFormat;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
/* Version information */
|
||||
typedef struct
|
||||
{
|
||||
u32 major; /* Encoder API major version */
|
||||
u32 minor; /* Encoder API minor version */
|
||||
} JpegEncApiVersion;
|
||||
typedef struct
|
||||
{
|
||||
u32 swBuild; /* Software build ID */
|
||||
u32 hwBuild; /* Hardware build ID */
|
||||
} JpegEncBuild;
|
||||
|
||||
/* thumbnail info */
|
||||
typedef struct
|
||||
{
|
||||
JpegEncThumbFormat format; /* Format of the thumbnail */
|
||||
u8 width; /* Width in pixels of thumbnail */
|
||||
u8 height; /* Height in pixels of thumbnail */
|
||||
const void *data; /* Thumbnail data */
|
||||
u16 dataLength; /* Data amount in bytes */
|
||||
} JpegEncThumb;
|
||||
|
||||
/* RGB input to YUV color conversion */
|
||||
typedef struct
|
||||
{
|
||||
JpegEncColorConversionType type;
|
||||
u16 coeffA; /* User defined color conversion coefficient */
|
||||
u16 coeffB; /* User defined color conversion coefficient */
|
||||
u16 coeffC; /* User defined color conversion coefficient */
|
||||
u16 coeffE; /* User defined color conversion coefficient */
|
||||
u16 coeffF; /* User defined color conversion coefficient */
|
||||
} JpegEncColorConversion;
|
||||
|
||||
/* Encoder configuration */
|
||||
typedef struct
|
||||
{
|
||||
u32 inputWidth; /* Number of pixels/line in input image */
|
||||
u32 inputHeight; /* Number of lines in input image */
|
||||
u32 xOffset; /* Pixels from top-left corner of input image */
|
||||
u32 yOffset; /* to top-left corner of encoded image */
|
||||
u32 codingWidth; /* Width of encoded image */
|
||||
u32 codingHeight; /* Height of encoded image */
|
||||
u32 restartInterval; /* Restart interval (MCU lines) */
|
||||
u32 qLevel; /* Quantization level (0 - 9) */
|
||||
const u8 *qTableLuma; /* Quantization table for luminance [64],
|
||||
* overrides quantization level, zigzag order */
|
||||
const u8 *qTableChroma; /* Quantization table for chrominance [64],
|
||||
* overrides quantization level, zigzag order */
|
||||
JpegEncFrameType frameType; /* Input frame YUV / RGB format */
|
||||
JpegEncColorConversion colorConversion; /* RGB to YUV conversion */
|
||||
JpegEncPictureRotation rotation; /* rotation off/-90/+90 */
|
||||
JpegEncCodingType codingType; /* Whole frame / restart interval */
|
||||
JpegEncCodingMode codingMode; /* 4:2:0 / 4:2:2 coding */
|
||||
JpegEncAppUnitsType unitsType; /* Units for X & Y density in APP0 */
|
||||
JpegEncTableMarkerType markerType; /* Table marker type */
|
||||
u32 xDensity; /* Horizontal pixel density */
|
||||
u32 yDensity; /* Vertical pixel density */
|
||||
u32 comLength; /* Length of COM header */
|
||||
const u8 *pCom; /* Comment header pointer */
|
||||
u32 inputLineBufEn; /* enable input image control signals */
|
||||
u32 inputLineBufLoopBackEn; /* input buffer loopback mode enable */
|
||||
u32 inputLineBufDepth; /* input buffer depth in mb lines */
|
||||
u32 inputLineBufHwModeEn; /* hw handshake*/
|
||||
} JpegEncCfg;
|
||||
|
||||
/* Input info */
|
||||
typedef struct
|
||||
{
|
||||
u32 frameHeader; /* Enable/disable creation of frame headers */
|
||||
u32 busLum; /* Bus address of luminance input (Y) */
|
||||
u32 busCb; /* Bus address of chrominance input (Cb) */
|
||||
u32 busCr; /* Bus address of chrominance input (Cr) */
|
||||
const u8 *pLum; /* Pointer to luminance input (Y) */
|
||||
const u8 *pCb; /* Pointer to chrominance input (Cb) */
|
||||
const u8 *pCr; /* Pointer to chrominance input (Cr) */
|
||||
u8 *pOutBuf; /* Pointer to output buffer */
|
||||
u32 busOutBuf; /* Bus address of output stream buffer */
|
||||
u32 outBufSize; /* Size of output buffer (bytes) */
|
||||
u32 lineBufWrCnt; /* The number of MB lines already in input MB line buffer */
|
||||
} JpegEncIn;
|
||||
|
||||
/* Output info */
|
||||
typedef struct
|
||||
{
|
||||
u32 jfifSize; /* Encoded JFIF size (bytes) */
|
||||
} JpegEncOut;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Version information */
|
||||
JpegEncApiVersion JpegEncGetApiVersion(void);
|
||||
|
||||
/* Build information */
|
||||
JpegEncBuild JpegEncGetBuild(void);
|
||||
|
||||
/* Helper for input format bit-depths */
|
||||
u32 JpegEncGetBitsPerPixel(JpegEncFrameType type);
|
||||
|
||||
/* Initialization & release */
|
||||
JpegEncRet JpegEncInit(const JpegEncCfg * pEncCfg, JpegEncInst * instAddr);
|
||||
JpegEncRet JpegEncRelease(JpegEncInst inst);
|
||||
|
||||
/* Encoding configuration */
|
||||
JpegEncRet JpegEncSetPictureSize(JpegEncInst inst,
|
||||
const JpegEncCfg * pEncCfg);
|
||||
|
||||
JpegEncRet JpegEncSetThumbnail(JpegEncInst inst,
|
||||
const JpegEncThumb * JpegThumb);
|
||||
|
||||
/* Jfif generation */
|
||||
JpegEncRet JpegEncEncode(JpegEncInst inst,
|
||||
const JpegEncIn * pEncIn,
|
||||
JpegEncOut * pEncOut,
|
||||
EncInputMBLineBufCallBackFunc lineBufCbFunc,
|
||||
void * pAppData);
|
||||
|
||||
/* Set valid input MB lines for encoder to work */
|
||||
u32 JpegEncGetEncodedMbLines(JpegEncInst inst);
|
||||
|
||||
/* Get encoded lines information from encoder */
|
||||
JpegEncRet JpegEncSetInputMBLines(JpegEncInst inst, u32 lines);
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
5. Encoder API tracing callback function
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
void JpegEnc_Trace(const char *msg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
-
|
||||
- Description : Video Stabilization Standalone API
|
||||
-
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __VIDSTBAPI_H__
|
||||
#define __VIDSTBAPI_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
/* Function return values */
|
||||
typedef enum VideoStbRet_
|
||||
{
|
||||
VIDEOSTB_OK = 0,
|
||||
VIDEOSTB_ERROR = -1,
|
||||
VIDEOSTB_NULL_ARGUMENT = -2,
|
||||
VIDEOSTB_INVALID_ARGUMENT = -3,
|
||||
VIDEOSTB_MEMORY_ERROR = -4,
|
||||
VIDEOSTB_EWL_ERROR = -5,
|
||||
VIDEOSTB_EWL_MEMORY_ERROR = -6,
|
||||
VIDEOSTB_HW_BUS_ERROR = -9,
|
||||
VIDEOSTB_HW_TIMEOUT = -11,
|
||||
VIDEOSTB_HW_RESERVED = -12,
|
||||
VIDEOSTB_SYSTEM_ERROR = -13,
|
||||
VIDEOSTB_INSTANCE_ERROR = -14,
|
||||
VIDEOSTB_HW_RESET = -16
|
||||
} VideoStbRet;
|
||||
|
||||
/* YUV type for initialization */
|
||||
typedef enum VideoStbInputFormat_
|
||||
{
|
||||
VIDEOSTB_YUV420_PLANAR = 0, /* YYYY... UUUU... VVVV */
|
||||
VIDEOSTB_YUV420_SEMIPLANAR = 1, /* YYYY... UVUVUV... */
|
||||
VIDEOSTB_YUV422_INTERLEAVED_YUYV = 2, /* YUYVYUYV... */
|
||||
VIDEOSTB_YUV422_INTERLEAVED_UYVY = 3, /* UYVYUYVY... */
|
||||
VIDEOSTB_RGB565 = 4, /* 16-bit RGB */
|
||||
VIDEOSTB_BGR565 = 5, /* 16-bit RGB */
|
||||
VIDEOSTB_RGB555 = 6, /* 15-bit RGB */
|
||||
VIDEOSTB_BGR555 = 7, /* 15-bit RGB */
|
||||
VIDEOSTB_RGB444 = 8, /* 12-bit RGB */
|
||||
VIDEOSTB_BGR444 = 9, /* 12-bit RGB */
|
||||
VIDEOSTB_RGB888 = 10, /* 24-bit RGB */
|
||||
VIDEOSTB_BGR888 = 11, /* 24-bit RGB */
|
||||
VIDEOSTB_RGB101010 = 12, /* 30-bit RGB */
|
||||
VIDEOSTB_BGR101010 = 13 /* 30-bit RGB */
|
||||
} VideoStbInputFormat;
|
||||
|
||||
typedef const void *VideoStbInst;
|
||||
|
||||
typedef struct VideoStbParam_
|
||||
{
|
||||
u32 inputWidth;
|
||||
u32 inputHeight;
|
||||
u32 stride;
|
||||
u32 stabilizedWidth;
|
||||
u32 stabilizedHeight;
|
||||
VideoStbInputFormat format;
|
||||
} VideoStbParam;
|
||||
|
||||
typedef struct VideoStbResult_
|
||||
{
|
||||
u32 stabOffsetX;
|
||||
u32 stabOffsetY;
|
||||
} VideoStbResult;
|
||||
|
||||
/* Version information */
|
||||
typedef struct
|
||||
{
|
||||
u32 major; /* API major version */
|
||||
u32 minor; /* API minor version */
|
||||
} VideoStbApiVersion;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 swBuild; /* Software build ID */
|
||||
u32 hwBuild; /* Hardware build ID */
|
||||
} VideoStbBuild;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
API prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Version information */
|
||||
VideoStbApiVersion VideoStbGetApiVersion(void);
|
||||
VideoStbBuild VideoStbGetBuild(void);
|
||||
|
||||
/* Initialization & release */
|
||||
VideoStbRet VideoStbInit(VideoStbInst * instAddr,
|
||||
const VideoStbParam * param);
|
||||
VideoStbRet VideoStbReset(VideoStbInst vidStab,
|
||||
const VideoStbParam * param);
|
||||
VideoStbRet VideoStbRelease(VideoStbInst vidStab);
|
||||
|
||||
/* Stabilize next image based on the current one */
|
||||
VideoStbRet VideoStbStabilize(VideoStbInst vidStab, VideoStbResult * result,
|
||||
u32 referenceFrameLum, u32 stabilizedFameLum);
|
||||
|
||||
/* API tracing callback function */
|
||||
void VideoStb_Trace(const char *str);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __VIDSTBAPI_H__ */
|
||||
|
|
@ -0,0 +1,146 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Camera stabilization standalone configuration
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __VIDSTBCFG_H__
|
||||
#define __VIDSTBCFG_H__
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
/* Here is defined the default values for the encoder build-time configuration.
|
||||
* You can override these settings by defining the values as compiler flags
|
||||
* in the Makefile.
|
||||
*/
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input YUV
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef VSH1_INPUT_SWAP_32_YUV
|
||||
#define VSH1_INPUT_SWAP_32_YUV 0
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input YUV
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_16_YUV
|
||||
#define VSH1_INPUT_SWAP_16_YUV 1
|
||||
#endif
|
||||
|
||||
/* The input image's 8-bit swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input YUV
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_8_YUV
|
||||
#define VSH1_INPUT_SWAP_8_YUV 1
|
||||
#endif
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input RGB16
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef VSH1_INPUT_SWAP_32_RGB16
|
||||
#define VSH1_INPUT_SWAP_32_RGB16 0
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input RGB16
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_16_RGB16
|
||||
#define VSH1_INPUT_SWAP_16_RGB16 1
|
||||
#endif
|
||||
|
||||
/* The input image's byte swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input RGB16
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_8_RGB16
|
||||
#define VSH1_INPUT_SWAP_8_RGB16 0
|
||||
#endif
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input RGB32
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef VSH1_INPUT_SWAP_32_RGB32
|
||||
#define VSH1_INPUT_SWAP_32_RGB32 0
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input RGB32
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_16_RGB32
|
||||
#define VSH1_INPUT_SWAP_16_RGB32 0
|
||||
#endif
|
||||
|
||||
/* The input image's byte swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input RGB32
|
||||
*/
|
||||
#ifndef VSH1_INPUT_SWAP_8_RGB32
|
||||
#define VSH1_INPUT_SWAP_8_RGB32 0
|
||||
#endif
|
||||
|
||||
/* ASIC interrupt enable.
|
||||
* This enables/disables the ASIC to generate interrupts
|
||||
* If this is '1', the EWL must poll the registers to find out
|
||||
* when the HW is ready.
|
||||
*/
|
||||
#ifndef VSH1_IRQ_DISABLE
|
||||
#define VSH1_IRQ_DISABLE 0
|
||||
#endif
|
||||
|
||||
/* ASIC bus interface configuration values */
|
||||
/* DO NOT CHANGE IF NOT FAMILIAR WITH THE CONCEPTS INVOLVED */
|
||||
|
||||
/* Burst length. This sets the maximum length of a single ASIC burst in addresses.
|
||||
* Allowed values are:
|
||||
* AHB {0, 4, 8, 16} ( 0 means incremental burst type INCR)
|
||||
* OCP [1,63]
|
||||
* AXI [1,16]
|
||||
*/
|
||||
#ifndef VSH1_BURST_LENGTH
|
||||
#define VSH1_BURST_LENGTH 16
|
||||
#endif
|
||||
|
||||
/* INCR type burst mode */
|
||||
/* 0 allowe INCR type bursts */
|
||||
/* 1 disable INCR type and use SINGLE instead */
|
||||
#ifndef VSH1_BURST_INCR_TYPE_ENABLED
|
||||
#define VSH1_BURST_INCR_TYPE_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* Data discard mode. When enabled read bursts of length 2 or 3 are converted to */
|
||||
/* BURST4 and useless data is discarded. Otherwise use INCR type for that kind */
|
||||
/* of read bursts */
|
||||
/* 0 disable data discard */
|
||||
/* 1 enable data discard */
|
||||
#ifndef VSH1_BURST_DATA_DISCARD_ENABLED
|
||||
#define VSH1_BURST_DATA_DISCARD_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* AXI bus read and write ID values used by HW. 0 - 255 */
|
||||
#ifndef VSH1_AXI_READ_ID
|
||||
#define VSH1_AXI_READ_ID 0
|
||||
#endif
|
||||
|
||||
#ifndef VSH1_AXI_WRITE_ID
|
||||
#define VSH1_AXI_WRITE_ID 0
|
||||
#endif
|
||||
|
||||
/* End of "ASIC bus interface configuration values" */
|
||||
|
||||
/* ASIC internal clock gating control. 0 - disabled, 1 - enabled */
|
||||
#ifndef VSH1_ASIC_CLOCK_GATING_ENABLED
|
||||
#define VSH1_ASIC_CLOCK_GATING_ENABLED 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
-
|
||||
- Description : ...
|
||||
-
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __VIDSTABCOMMON_H__
|
||||
#define __VIDSTABCOMMON_H__
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
#ifdef H8290_HAVE_VIDSTABDEBUG_H
|
||||
#include "vidstabdebug.h"
|
||||
#else
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(expr)
|
||||
#endif
|
||||
#ifndef DEBUG_PRINT
|
||||
#define DEBUG_PRINT(args)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct HWStabData_
|
||||
{
|
||||
u32 rMotionSum;
|
||||
u32 rMotionMin;
|
||||
i32 rGmvX;
|
||||
i32 rGmvY;
|
||||
u32 rMatrixVal[9];
|
||||
} HWStabData;
|
||||
|
||||
/* Stabilizer parameter and data structure */
|
||||
typedef struct SwStbData_
|
||||
{
|
||||
/* User defined parameters */
|
||||
i32 inputWidth; /* Input picture dimensions in pixels */
|
||||
i32 inputHeight;
|
||||
i32 stride; /* Input picture scanline length in bytes */
|
||||
i32 stabilizedWidth; /* Stabilized picture dimensions in pixels, */
|
||||
i32 stabilizedHeight; /* multiple of 4, [8, inputHeight-8] */
|
||||
|
||||
/* Stabilized picture position from top-left corner of input picture,
|
||||
* algorithm input/output, initialize to (inputWidth-stabilizedWidth)/2 */
|
||||
i32 stabOffsetX; /* [0, inputWidth-stabilizedWidth] */
|
||||
i32 stabOffsetY; /* [0, inputHeight-stabilizedHeight] */
|
||||
|
||||
/* Algorithm internal data, MUST INITIALIZE TO ZERO */
|
||||
i32 qpMotionX;
|
||||
i32 qpMotionY;
|
||||
i32 filterPosX;
|
||||
i32 filterPosY;
|
||||
i32 filterX;
|
||||
i32 filterY;
|
||||
i32 filterLengthX;
|
||||
i32 filterLengthY;
|
||||
i32 filterSumMotX;
|
||||
i32 filterSumMotY;
|
||||
i32 filterSumStabX;
|
||||
i32 filterSumStabY;
|
||||
i32 filterErrorX;
|
||||
i32 filterErrorY;
|
||||
i32 filterErrorXp;
|
||||
i32 filterErrorYp;
|
||||
const u32 *motion;
|
||||
i32 half[5][5];
|
||||
i32 quarter[5][5];
|
||||
u32 prevMin;
|
||||
u32 prevMean;
|
||||
u32 sceneChange;
|
||||
} SwStbData;
|
||||
|
||||
void VSAlgInit(SwStbData * data, u32 srcWidth, u32 srcHeight, u32 width,
|
||||
u32 height);
|
||||
void VSAlgReset(SwStbData * data);
|
||||
u32 VSAlgStabilize(SwStbData * data, const HWStabData * hwStabData);
|
||||
void VSAlgGetResult(const SwStbData * data, u32 * xOff, u32 * yOff);
|
||||
void VSReadStabData(const u32 * regMirror, HWStabData * hwStabData);
|
||||
|
||||
#endif /* __VIDSTABCOMMON_H__ */
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
-
|
||||
- Description : Standalone stabilization internal stuff
|
||||
-
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __VIDSTBINTERNAL_H__
|
||||
#define __VIDSTBINTERNAL_H__
|
||||
|
||||
#include "basetype.h"
|
||||
#include "vidstabcommon.h"
|
||||
#include "vidstbapi.h"
|
||||
#include "ewl.h"
|
||||
|
||||
/* HW status register bits */
|
||||
#define ASIC_STATUS_SLICE_READY 0x100
|
||||
#define ASIC_STATUS_HW_TIMEOUT 0x040
|
||||
#define ASIC_STATUS_BUFF_FULL 0x020
|
||||
#define ASIC_STATUS_HW_RESET 0x010
|
||||
#define ASIC_STATUS_ERROR 0x008
|
||||
#define ASIC_STATUS_FRAME_READY 0x004
|
||||
|
||||
#define ASIC_STATUS_ALL 0x1FD
|
||||
|
||||
#define ASIC_IRQ_LINE 0x001
|
||||
#define ASIC_STATUS_ENABLE 0x001
|
||||
|
||||
#define ASIC_VS_MODE_OFF 0x00
|
||||
#define ASIC_VS_MODE_ALONE 0x01
|
||||
#define ASIC_VS_MODE_ENCODER 0x02
|
||||
|
||||
#define ASIC_INPUT_YUV420PLANAR 0x00
|
||||
#define ASIC_INPUT_YUV420SEMIPLANAR 0x01
|
||||
#define ASIC_INPUT_YUYV422INTERLEAVED 0x02
|
||||
#define ASIC_INPUT_UYVY422INTERLEAVED 0x03
|
||||
#define ASIC_INPUT_RGB565 0x04
|
||||
#define ASIC_INPUT_RGB555 0x05
|
||||
#define ASIC_INPUT_RGB444 0x06
|
||||
#define ASIC_INPUT_RGB888 0x07
|
||||
#define ASIC_INPUT_RGB101010 0x08
|
||||
|
||||
typedef struct RegValues_
|
||||
{
|
||||
u32 irqDisable;
|
||||
u32 mbsInCol;
|
||||
u32 mbsInRow;
|
||||
u32 pixelsOnRow;
|
||||
u32 xFill;
|
||||
u32 yFill;
|
||||
u32 inputImageFormat;
|
||||
u32 inputLumBase;
|
||||
u32 inputLumaBaseOffset;
|
||||
|
||||
u32 rwNextLumaBase;
|
||||
u32 rwStabMode;
|
||||
|
||||
u32 rMaskMsb;
|
||||
u32 gMaskMsb;
|
||||
u32 bMaskMsb;
|
||||
u32 colorConversionCoeffA;
|
||||
u32 colorConversionCoeffB;
|
||||
u32 colorConversionCoeffC;
|
||||
u32 colorConversionCoeffE;
|
||||
u32 colorConversionCoeffF;
|
||||
|
||||
HWStabData hwStabData;
|
||||
|
||||
u32 asicCfgReg;
|
||||
|
||||
#ifdef ASIC_WAVE_TRACE_TRIGGER
|
||||
u32 vop_count;
|
||||
#endif
|
||||
} RegValues;
|
||||
|
||||
typedef u32 SwStbMotionType;
|
||||
|
||||
typedef struct VideoStb_
|
||||
{
|
||||
const void *ewl;
|
||||
u32 regMirror[64];
|
||||
const void *checksum;
|
||||
SwStbData data;
|
||||
RegValues regval;
|
||||
u32 stride;
|
||||
VideoStbInputFormat yuvFormat;
|
||||
} VideoStb;
|
||||
|
||||
void VSSetCropping(VideoStb * pVidStab, u32 currentPictBus, u32 nextPictBus);
|
||||
|
||||
void VSInitAsicCtrl(VideoStb * pVidStab);
|
||||
i32 VSCheckInput(const VideoStbParam * param);
|
||||
void VSSetupAsicAll(VideoStb * pVidStab);
|
||||
i32 VSWaitAsicReady(VideoStb * pVidStab);
|
||||
|
||||
#endif /* __VIDSTBINTERNAL_H__ */
|
||||
|
|
@ -0,0 +1,396 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : ASIC low level controller
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_ASIC_CONTROLLER_H__
|
||||
#define __ENC_ASIC_CONTROLLER_H__
|
||||
|
||||
#include "basetype.h"
|
||||
#include "enccfg.h"
|
||||
#include "ewl.h"
|
||||
#include "encswhwregisters.h"
|
||||
|
||||
/* HW status register bits */
|
||||
#define ASIC_STATUS_ALL 0xFFD
|
||||
|
||||
#define ASIC_STATUS_RFC_BUFF_OVERFLOW 0x800
|
||||
#define ASIC_STATUS_LINE_BUFFER_DONE 0x400
|
||||
#define ASIC_STATUS_FUSE 0x200
|
||||
#define ASIC_STATUS_SLICE_READY 0x100
|
||||
#define ASIC_STATUS_HW_TIMEOUT 0x040
|
||||
#define ASIC_STATUS_BUFF_FULL 0x020
|
||||
#define ASIC_STATUS_HW_RESET 0x010
|
||||
#define ASIC_STATUS_ERROR 0x008
|
||||
#define ASIC_STATUS_FRAME_READY 0x004
|
||||
|
||||
#define ASIC_IRQ_LINE 0x001
|
||||
|
||||
#define ASIC_STATUS_ENABLE 0x001
|
||||
|
||||
#define ASIC_H264_BYTE_STREAM 0x00
|
||||
#define ASIC_H264_NAL_UNIT 0x01
|
||||
|
||||
#define ASIC_PENALTY_UNDEFINED -1
|
||||
|
||||
#define ASIC_PENALTY_TABLE_SIZE 128
|
||||
|
||||
#define ASIC_FRAME_BUF_LUM_MAX 3
|
||||
#define ASIC_FRAME_BUF_CHR_MAX 4
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IDLE = 0, /* Initial state, both HW and SW disabled */
|
||||
HWON_SWOFF, /* HW processing, SW waiting for HW */
|
||||
HWON_SWON, /* Both HW and SW processing */
|
||||
HWOFF_SWON, /* HW is paused or disabled, SW is processing */
|
||||
DONE
|
||||
} bufferState_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ASIC_VP8 = 1,
|
||||
ASIC_JPEG = 2,
|
||||
ASIC_H264 = 3
|
||||
} asicCodingType_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ASIC_P_16x16 = 0,
|
||||
ASIC_P_16x8 = 1,
|
||||
ASIC_P_8x16 = 2,
|
||||
ASIC_P_8x8 = 3,
|
||||
ASIC_I_4x4 = 4,
|
||||
ASIC_I_16x16 = 5
|
||||
} asicMbType_e;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ASIC_INTER = 0,
|
||||
ASIC_INTRA = 1,
|
||||
ASIC_MVC = 2,
|
||||
ASIC_MVC_REF_MOD = 3
|
||||
} asicFrameCodingType_e;
|
||||
|
||||
enum
|
||||
{
|
||||
ASIC_PENALTY_I16MODE0 = 0,
|
||||
ASIC_PENALTY_I16MODE1,
|
||||
ASIC_PENALTY_I16MODE2,
|
||||
ASIC_PENALTY_I16MODE3,
|
||||
ASIC_PENALTY_I4MODE0,
|
||||
ASIC_PENALTY_I4MODE1,
|
||||
ASIC_PENALTY_I4MODE2,
|
||||
ASIC_PENALTY_I4MODE3,
|
||||
ASIC_PENALTY_I4MODE4,
|
||||
ASIC_PENALTY_I4MODE5,
|
||||
ASIC_PENALTY_I4MODE6,
|
||||
ASIC_PENALTY_I4MODE7,
|
||||
ASIC_PENALTY_I4MODE8,
|
||||
ASIC_PENALTY_I4MODE9,
|
||||
ASIC_PENALTY_I16FAVOR,
|
||||
ASIC_PENALTY_I4_PREV_MODE_FAVOR,
|
||||
ASIC_PENALTY_COST_INTER,
|
||||
ASIC_PENALTY_DMV_COST_CONST,
|
||||
ASIC_PENALTY_INTER_FAVOR,
|
||||
ASIC_PENALTY_SKIP,
|
||||
ASIC_PENALTY_GOLDEN,
|
||||
ASIC_PENALTY_SPLIT4x4,
|
||||
ASIC_PENALTY_SPLIT8x4,
|
||||
ASIC_PENALTY_SPLIT8x8,
|
||||
ASIC_PENALTY_SPLIT16x8,
|
||||
ASIC_PENALTY_SPLIT_ZERO,
|
||||
ASIC_PENALTY_DMV_4P,
|
||||
ASIC_PENALTY_DMV_1P,
|
||||
ASIC_PENALTY_DMV_QP,
|
||||
ASIC_PENALTY_DZ_RATE0,
|
||||
ASIC_PENALTY_DZ_RATE1,
|
||||
ASIC_PENALTY_DZ_RATE2,
|
||||
ASIC_PENALTY_DZ_RATE3,
|
||||
ASIC_PENALTY_DZ_SKIP0,
|
||||
ASIC_PENALTY_DZ_SKIP1,
|
||||
|
||||
ASIC_PENALTY_AMOUNT
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 irqDisable;
|
||||
u32 irqInterval;
|
||||
u32 traceMbTiming;
|
||||
u32 inputReadChunk;
|
||||
u32 mbsInCol;
|
||||
u32 mbsInRow;
|
||||
u32 qp;
|
||||
u32 qpMin;
|
||||
u32 qpMax;
|
||||
u32 constrainedIntraPrediction;
|
||||
u32 roundingCtrl;
|
||||
u32 frameCodingType;
|
||||
u32 codingType;
|
||||
u32 pixelsOnRow;
|
||||
u32 xFill;
|
||||
u32 yFill;
|
||||
u32 ppsId;
|
||||
u32 idrPicId;
|
||||
u32 frameNum;
|
||||
u32 picInitQp;
|
||||
i32 sliceAlphaOffset;
|
||||
i32 sliceBetaOffset;
|
||||
u32 filterDisable;
|
||||
u32 transform8x8Mode;
|
||||
u32 enableCabac;
|
||||
u32 cabacInitIdc;
|
||||
i32 chromaQpIndexOffset;
|
||||
u32 chromaSwap;
|
||||
u32 sliceSizeMbRows;
|
||||
u32 inputImageFormat;
|
||||
u32 inputImageRotation;
|
||||
u32 outputStrmBase;
|
||||
u32 outputStrmSize;
|
||||
u32 firstFreeBit;
|
||||
u32 strmStartMSB;
|
||||
u32 strmStartLSB;
|
||||
u32 rlcBase;
|
||||
u32 rlcLimitSpace;
|
||||
u32 sizeTblBase;
|
||||
u32 sliceReadyInterrupt;
|
||||
u32 recWriteBuffer;
|
||||
u32 recWriteDisable;
|
||||
u32 reconImageId;
|
||||
u32 internalImageLumBaseW;
|
||||
u32 internalImageChrBaseW;
|
||||
u32 internalImageLumTableBaseW;
|
||||
u32 internalImageChrTableBaseW;
|
||||
u32 internalImageLumBaseR[2];
|
||||
u32 internalImageChrBaseR[2];
|
||||
u32 internalImageLumTableBaseR[2];
|
||||
u32 internalImageChrTableBaseR[2];
|
||||
u32 refLumCompress;
|
||||
u32 refChrCompress;
|
||||
u32 rfcLumDiscreteMode;
|
||||
u32 rfcLumBufLimit;
|
||||
u32 rfcChrBufLimit;
|
||||
u32 rfcOverflowIRQEn;
|
||||
u32 inputLumBase;
|
||||
u32 inputCbBase;
|
||||
u32 inputCrBase;
|
||||
u32 cpDistanceMbs;
|
||||
u32 *cpTargetResults;
|
||||
const u32 *cpTarget;
|
||||
const i32 *targetError;
|
||||
const i32 *deltaQp;
|
||||
u32 rlcCount;
|
||||
u32 qpSum;
|
||||
u32 h264StrmMode; /* 0 - byte stream, 1 - NAL units */
|
||||
u8 quantTable[8 * 8 * 2];
|
||||
u8 dmvPenalty[ASIC_PENALTY_TABLE_SIZE];
|
||||
u8 dmvQpelPenalty[ASIC_PENALTY_TABLE_SIZE];
|
||||
u32 ipolFilterMode;
|
||||
u32 jpegMode;
|
||||
u32 jpegSliceEnable;
|
||||
u32 jpegRestartInterval;
|
||||
u32 jpegRestartMarker;
|
||||
//u32 regMirror[ASIC_SWREG_AMOUNT];
|
||||
#ifdef _VOE_NO_USE //Modified by Devin
|
||||
u32 regMirror[ASIC_SWREG_AMOUNT];
|
||||
#else
|
||||
u32 *regMirror;
|
||||
#endif
|
||||
u32 inputLumaBaseOffset;
|
||||
u32 inputLumaBaseOffsetVert;
|
||||
u32 inputChromaBaseOffset;
|
||||
u32 h264Inter4x4Disabled;
|
||||
u32 disableQuarterPixelMv;
|
||||
u32 vsNextLumaBase;
|
||||
u32 vsMode;
|
||||
u32 asicCfgReg;
|
||||
u32 asicHwId;
|
||||
i32 madQpDelta[3];
|
||||
u32 madThreshold[3];
|
||||
u32 madCount[3];
|
||||
u32 mvcAnchorPicFlag;
|
||||
u32 mvcPriorityId;
|
||||
u32 mvcViewId;
|
||||
u32 mvcTemporalId;
|
||||
u32 mvcInterViewFlag;
|
||||
u32 cirStart;
|
||||
u32 cirInterval;
|
||||
u32 intraSliceMap1;
|
||||
u32 intraSliceMap2;
|
||||
u32 intraSliceMap3;
|
||||
u32 intraAreaTop;
|
||||
u32 intraAreaLeft;
|
||||
u32 intraAreaBottom;
|
||||
u32 intraAreaRight;
|
||||
u32 roi1Top;
|
||||
u32 roi1Left;
|
||||
u32 roi1Bottom;
|
||||
u32 roi1Right;
|
||||
u32 roi2Top;
|
||||
u32 roi2Left;
|
||||
u32 roi2Bottom;
|
||||
u32 roi2Right;
|
||||
i32 roi1DeltaQp;
|
||||
i32 roi2DeltaQp;
|
||||
u32 roiUpdate;
|
||||
u32 mvOutputBase;
|
||||
u32 cabacCtxBase;
|
||||
u32 probCountBase;
|
||||
u32 segmentMapBase;
|
||||
u32 colorConversionCoeffA;
|
||||
u32 colorConversionCoeffB;
|
||||
u32 colorConversionCoeffC;
|
||||
u32 colorConversionCoeffE;
|
||||
u32 colorConversionCoeffF;
|
||||
u32 rMaskMsb;
|
||||
u32 gMaskMsb;
|
||||
u32 bMaskMsb;
|
||||
u32 partitionBase[8];
|
||||
u32 qpY1QuantDc[4];
|
||||
u32 qpY1QuantAc[4];
|
||||
u32 qpY2QuantDc[4];
|
||||
u32 qpY2QuantAc[4];
|
||||
u32 qpChQuantDc[4];
|
||||
u32 qpChQuantAc[4];
|
||||
u32 qpY1ZbinDc[4];
|
||||
u32 qpY1ZbinAc[4];
|
||||
u32 qpY2ZbinDc[4];
|
||||
u32 qpY2ZbinAc[4];
|
||||
u32 qpChZbinDc[4];
|
||||
u32 qpChZbinAc[4];
|
||||
u32 qpY1RoundDc[4];
|
||||
u32 qpY1RoundAc[4];
|
||||
u32 qpY2RoundDc[4];
|
||||
u32 qpY2RoundAc[4];
|
||||
u32 qpChRoundDc[4];
|
||||
u32 qpChRoundAc[4];
|
||||
u32 qpY1DequantDc[4];
|
||||
u32 qpY1DequantAc[4];
|
||||
u32 qpY2DequantDc[4];
|
||||
u32 qpY2DequantAc[4];
|
||||
u32 qpChDequantDc[4];
|
||||
u32 qpChDequantAc[4];
|
||||
u32 segmentEnable;
|
||||
u32 segmentMapUpdate;
|
||||
u32 mvRefIdx[2];
|
||||
u32 ref2Enable;
|
||||
u32 boolEncValue;
|
||||
u32 boolEncValueBits;
|
||||
u32 boolEncRange;
|
||||
u32 dctPartitions;
|
||||
u32 filterLevel[4];
|
||||
u32 filterSharpness;
|
||||
u32 zeroMvFavorDiv2;
|
||||
u32 splitMvMode;
|
||||
i32 lfRefDelta[4];
|
||||
i32 lfModeDelta[4];
|
||||
u32 deadzoneEnable;
|
||||
u8 dzCoeffRate[4*8*3*2]; /* Coeff 0&1 rate values for dead zone */
|
||||
u8 dzEobRate[4*8*2]; /* Eob token rate values for dead zone */
|
||||
u32 squaredError;
|
||||
u32 mse_mul256;
|
||||
u32 pen[4][ASIC_PENALTY_AMOUNT]; /* Penalty values for four segments */
|
||||
u32 scaledLumBase;
|
||||
u32 scaledWidth;
|
||||
u32 scaledHeight;
|
||||
u32 scaledWidthRatio;
|
||||
u32 scaledHeightRatio;
|
||||
u32 avgVar;
|
||||
u32 invAvgVar;
|
||||
u32 fieldPicFlag;
|
||||
u32 bottomFieldFlag;
|
||||
u32 fieldParity;
|
||||
u32 markCurrentLongTerm;
|
||||
u32 boostQp;
|
||||
u32 boostVar1;
|
||||
u32 boostVar2;
|
||||
u32 varLimitDiv32;
|
||||
u32 varInterFavorDiv16;
|
||||
u32 varMultiplier;
|
||||
u32 varAdd;
|
||||
u32 pskipMode;
|
||||
|
||||
u32 mbWrPtr;
|
||||
u32 mbRrPtr;
|
||||
u32 lineBufferDepth;
|
||||
u32 lineBufferEn;
|
||||
u32 lineBufferHwHandShake;
|
||||
u32 lineBufferLoopBackEn;
|
||||
|
||||
/* input compression related */
|
||||
u32 inputLeftOffset;
|
||||
u32 inputTopOffset;
|
||||
u32 inputLumTableBase;
|
||||
u32 inputChrTableBase;
|
||||
u32 vsNextLumaTableBase;
|
||||
|
||||
#ifdef ASIC_WAVE_TRACE_TRIGGER
|
||||
u32 vop_count;
|
||||
#endif
|
||||
} regValues_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const void *ewl;
|
||||
regValues_s regs;
|
||||
EWLLinearMem_t internalImageLuma[ASIC_FRAME_BUF_LUM_MAX];
|
||||
EWLLinearMem_t internalImageChroma[ASIC_FRAME_BUF_CHR_MAX];
|
||||
EWLLinearMem_t scaledImage;
|
||||
EWLLinearMem_t cabacCtx;
|
||||
EWLLinearMem_t mvOutput;
|
||||
EWLLinearMem_t probCount;
|
||||
EWLLinearMem_t segmentMap;
|
||||
u32 sizeTblSize;
|
||||
EWLLinearMem_t sizeTbl;
|
||||
u32 traceRecon;
|
||||
u32 internalImageLumSize;
|
||||
u32 internalImageChrSize;
|
||||
u32 irqStatus;
|
||||
} asicData_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
i32 EncAsicControllerInit(asicData_s * asic);
|
||||
|
||||
i32 EncAsicMemAlloc_V2(asicData_s * asic, u32 width, u32 height,
|
||||
u32 scaledWidth, u32 scaledHeight,
|
||||
u32 encodingType, u32 numRefBuffsLum, u32 numRefBuffsChr);
|
||||
void EncAsicMemFree_V2(asicData_s * asic);
|
||||
|
||||
/* Functions for controlling ASIC */
|
||||
void EncAsicSetQuantTable(asicData_s * asic,
|
||||
const u8 * lumTable, const u8 * chTable);
|
||||
|
||||
void EncAsicGetRegisters(const void *ewl, regValues_s * val);
|
||||
u32 EncAsicGetStatus(const void *ewl);
|
||||
|
||||
u32 EncAsicGetId(const void *ewl);
|
||||
|
||||
void EncAsicFrameStart(const void *ewl, regValues_s * val);
|
||||
|
||||
void EncAsicStop(const void *ewl);
|
||||
|
||||
void EncAsicRecycleInternalImage(asicData_s *asic, u32 numViews, u32 viewId,
|
||||
u32 anchor, u32 numRefBuffsLum, u32 numRefBuffsChr);
|
||||
|
||||
i32 EncAsicCheckStatus_V2(asicData_s *asic);
|
||||
u32 *EncAsicGetMvOutput(asicData_s *asic, u32 mbNum);
|
||||
void EncAsicClearStatusBit(const void *ewl, u32 statusBit);
|
||||
void EncAsicClearLineBufIrqStatus(const void *ewl, regValues_s * val);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Encoder common configuration parameters
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENCCFG_H__
|
||||
#define __ENCCFG_H__
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
/* Here is defined the default values for the encoder build-time configuration.
|
||||
* You can override these settings by defining the values as compiler flags
|
||||
* in the Makefile.
|
||||
*/
|
||||
|
||||
#ifdef PCIE_FPGA_VERIFICATION
|
||||
#define ENCH1_INPUT_SWAP_32_YUV 1
|
||||
#define ENCH1_INPUT_SWAP_32_RGB16 1
|
||||
#define ENCH1_INPUT_SWAP_32_RGB32 1
|
||||
#define ENCH1_OUTPUT_SWAP_32 1
|
||||
#endif
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input YUV
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef ENCH1_INPUT_SWAP_32_YUV
|
||||
#define ENCH1_INPUT_SWAP_32_YUV 1
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input YUV
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_16_YUV
|
||||
#define ENCH1_INPUT_SWAP_16_YUV 1
|
||||
#endif
|
||||
|
||||
/* The input image's 8-bit swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input YUV
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_8_YUV
|
||||
#define ENCH1_INPUT_SWAP_8_YUV 1
|
||||
#endif
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input RGB16
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef ENCH1_INPUT_SWAP_32_RGB16
|
||||
#define ENCH1_INPUT_SWAP_32_RGB16 0
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input RGB16
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_16_RGB16
|
||||
#define ENCH1_INPUT_SWAP_16_RGB16 1
|
||||
#endif
|
||||
|
||||
/* The input image's byte swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input RGB16
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_8_RGB16
|
||||
#define ENCH1_INPUT_SWAP_8_RGB16 0
|
||||
#endif
|
||||
|
||||
/* The input image's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC input RGB32
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef ENCH1_INPUT_SWAP_32_RGB32
|
||||
#define ENCH1_INPUT_SWAP_32_RGB32 0
|
||||
#endif
|
||||
|
||||
/* The input image's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC input RGB32
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_16_RGB32
|
||||
#define ENCH1_INPUT_SWAP_16_RGB32 0
|
||||
#endif
|
||||
|
||||
/* The input image's byte swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC input RGB32
|
||||
*/
|
||||
#ifndef ENCH1_INPUT_SWAP_8_RGB32
|
||||
#define ENCH1_INPUT_SWAP_8_RGB32 0
|
||||
#endif
|
||||
|
||||
/* ENCH1_OUTPUT_SWAP_XX define the byte endianess of the ASIC output stream.
|
||||
* This MUST be configured to be the same as the native system endianess,
|
||||
* because the control software relies on system endianess when reading
|
||||
* the data from the memory. */
|
||||
|
||||
/* The output stream's 32-bit swap: 0 or 1
|
||||
* This defines the 32-bit endianess of the ASIC output stream
|
||||
* 1 = 64-bit endianess */
|
||||
#ifndef ENCH1_OUTPUT_SWAP_32
|
||||
#define ENCH1_OUTPUT_SWAP_32 1
|
||||
#endif
|
||||
|
||||
/* The output stream's 16-bit swap: 0 or 1
|
||||
* This defines the 16-bit endianess of the ASIC output stream.
|
||||
*/
|
||||
#ifndef ENCH1_OUTPUT_SWAP_16
|
||||
#define ENCH1_OUTPUT_SWAP_16 1
|
||||
#endif
|
||||
|
||||
/* The output stream's 8-bit swap: 0 or 1
|
||||
* This defines the byte endianess of the ASIC output stream.
|
||||
*/
|
||||
#ifndef ENCH1_OUTPUT_SWAP_8
|
||||
#define ENCH1_OUTPUT_SWAP_8 1
|
||||
#endif
|
||||
|
||||
/* The output down-scaled image's swapping is defined the same way as
|
||||
* output stream swapping. Typically these should be the same values
|
||||
* as for output stream. */
|
||||
#ifndef ENCH1_SCALE_OUTPUT_SWAP_32
|
||||
#define ENCH1_SCALE_OUTPUT_SWAP_32 ENCH1_OUTPUT_SWAP_32
|
||||
#endif
|
||||
#ifndef ENCH1_SCALE_OUTPUT_SWAP_16
|
||||
#define ENCH1_SCALE_OUTPUT_SWAP_16 ENCH1_OUTPUT_SWAP_16
|
||||
#endif
|
||||
#ifndef ENCH1_SCALE_OUTPUT_SWAP_8
|
||||
#define ENCH1_SCALE_OUTPUT_SWAP_8 ENCH1_OUTPUT_SWAP_8
|
||||
#endif
|
||||
|
||||
/* The output MV and macroblock info swapping is defined the same way as
|
||||
* output stream swapping. Typically these should be the same values
|
||||
* as for output stream. */
|
||||
#ifndef ENCH1_MV_OUTPUT_SWAP_32
|
||||
#define ENCH1_MV_OUTPUT_SWAP_32 ENCH1_OUTPUT_SWAP_32
|
||||
#endif
|
||||
#ifndef ENCH1_MV_OUTPUT_SWAP_16
|
||||
#define ENCH1_MV_OUTPUT_SWAP_16 ENCH1_OUTPUT_SWAP_16
|
||||
#endif
|
||||
#ifndef ENCH1_MV_OUTPUT_SWAP_8
|
||||
#define ENCH1_MV_OUTPUT_SWAP_8 ENCH1_OUTPUT_SWAP_8
|
||||
#endif
|
||||
|
||||
/* ASIC interrupt enable.
|
||||
* This enables/disables the ASIC to generate interrupts
|
||||
* If this is '1', the EWL must poll the registers to find out
|
||||
* when the HW is ready.
|
||||
*/
|
||||
#ifndef ENCH1_IRQ_DISABLE
|
||||
#define ENCH1_IRQ_DISABLE 0
|
||||
#endif
|
||||
|
||||
/* ASIC bus interface configuration values */
|
||||
/* DO NOT CHANGE IF NOT FAMILIAR WITH THE CONCEPTS INVOLVED */
|
||||
|
||||
/* Burst length. This sets the maximum length of a single ASIC burst in addresses.
|
||||
* Allowed values are:
|
||||
* AHB {0, 4, 8, 16} ( 0 means incremental burst type INCR)
|
||||
* OCP [1,63]
|
||||
* AXI [1,16]
|
||||
*/
|
||||
#ifndef ENCH1_BURST_LENGTH
|
||||
#define ENCH1_BURST_LENGTH 16
|
||||
#endif
|
||||
|
||||
/* SCMD burst mode disable */
|
||||
/* 0 - enable SCMD burst mode */
|
||||
/* 1 - disable SCMD burst mode */
|
||||
#ifndef ENCH1_BURST_SCMD_DISABLE
|
||||
#define ENCH1_BURST_SCMD_DISABLE 0
|
||||
#endif
|
||||
|
||||
/* INCR type burst mode */
|
||||
/* 0 - enable INCR type bursts */
|
||||
/* 1 - disable INCR type and use SINGLE instead */
|
||||
#ifndef ENCH1_BURST_INCR_TYPE_ENABLED
|
||||
#define ENCH1_BURST_INCR_TYPE_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* Data discard mode. When enabled read bursts of length 2 or 3 are converted */
|
||||
/* to BURST4 and useless data is discarded. Otherwise use INCR type for that */
|
||||
/* kind of read bursts */
|
||||
/* 0 - disable data discard */
|
||||
/* 1 - enable data discard */
|
||||
#ifndef ENCH1_BURST_DATA_DISCARD_ENABLED
|
||||
#define ENCH1_BURST_DATA_DISCARD_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* AXI bus read and write ID values used by HW. 0 - 255 */
|
||||
#ifndef ENCH1_AXI_READ_ID
|
||||
#define ENCH1_AXI_READ_ID 0
|
||||
#endif
|
||||
|
||||
#ifndef ENCH1_AXI_WRITE_ID
|
||||
#define ENCH1_AXI_WRITE_ID 0
|
||||
#endif
|
||||
|
||||
/* End of "ASIC bus interface configuration values" */
|
||||
|
||||
/* ASIC internal clock gating control. 0 - disabled, 1 - enabled */
|
||||
#ifndef ENCH1_ASIC_CLOCK_GATING_ENABLED
|
||||
#define ENCH1_ASIC_CLOCK_GATING_ENABLED 1
|
||||
#endif
|
||||
|
||||
/* ASIC timeout interrupt enable/disable */
|
||||
#ifndef ENCH1_TIMEOUT_INTERRUPT
|
||||
#define ENCH1_TIMEOUT_INTERRUPT 1
|
||||
#endif
|
||||
|
||||
/* H.264 slice ready interrupt enable/disable. When enabled the HW will raise */
|
||||
/* interrupt after every completed slice creating several IRQ per frame. */
|
||||
/* When disabled the HW will raise interrupt only when the frame encoding is */
|
||||
/* finished. */
|
||||
#ifndef ENCH1_SLICE_READY_INTERRUPT
|
||||
#define ENCH1_SLICE_READY_INTERRUPT 1
|
||||
#endif
|
||||
|
||||
/* ASIC input picture read chunk size, 0=4 MBs, 1=1 MB */
|
||||
#ifndef ENCH1_INPUT_READ_CHUNK
|
||||
#define ENCH1_INPUT_READ_CHUNK 0
|
||||
#endif
|
||||
|
||||
/* AXI bus dual channel disable, 0=use two channels, 1=use single channel. */
|
||||
#ifndef ENCH1_AXI_2CH_DISABLE
|
||||
#define ENCH1_AXI_2CH_DISABLE 0
|
||||
#endif
|
||||
|
||||
/* Reconstructed picture output writing, 0=1 MB (write burst for every MB),
|
||||
1=4MBs (write burst for every fourth MB). */
|
||||
#ifndef ENCH1_REC_WRITE_BUFFER
|
||||
#define ENCH1_REC_WRITE_BUFFER 1
|
||||
#endif
|
||||
|
||||
/* How often to update VP8 entropy probabilities, higher value lowers SW load.
|
||||
1=update for every frame, 2=update for every second frame, etc. */
|
||||
#ifndef ENCH1_VP8_ENTROPY_UPDATE_DISTANCE
|
||||
#define ENCH1_VP8_ENTROPY_UPDATE_DISTANCE 1
|
||||
#endif
|
||||
|
||||
/* ASIC RFC overflow interrupt enable/disable */
|
||||
#ifndef ENCH1_RFC_OVERFLOW_INTERRUPT
|
||||
#define ENCH1_RFC_OVERFLOW_INTERRUPT 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Preprocessor setup
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_PRE_PROCESS_H__
|
||||
#define __ENC_PRE_PROCESS_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "encasiccontroller.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#define ROTATE_0 0U
|
||||
#define ROTATE_90R 1U /* Rotate 90 degrees clockwise */
|
||||
#define ROTATE_90L 2U /* Rotate 90 degrees counter-clockwise */
|
||||
|
||||
/* maximum input picture width set by the available bits in ASIC regs */
|
||||
#define MAX_INPUT_IMAGE_WIDTH (8192)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 lumWidthSrc; /* Source input image width */
|
||||
u32 lumHeightSrc; /* Source input image height */
|
||||
u32 lumWidth; /* Encoded image width */
|
||||
u32 lumHeight; /* Encoded image height */
|
||||
u32 scaledWidth; /* Scaled output image width */
|
||||
u32 scaledHeight; /* Scaled output image height */
|
||||
u32 horOffsetSrc; /* Encoded frame offset, reference is ... */
|
||||
u32 verOffsetSrc; /* ...top left corner of source image */
|
||||
u32 inputFormat;
|
||||
u32 rotation;
|
||||
u32 videoStab;
|
||||
u32 scaledOutput;
|
||||
u32 colorConversionType; /* 0 = bt601, 1 = bt709, 2 = user defined */
|
||||
u32 colorConversionCoeffA;
|
||||
u32 colorConversionCoeffB;
|
||||
u32 colorConversionCoeffC;
|
||||
u32 colorConversionCoeffE;
|
||||
u32 colorConversionCoeffF;
|
||||
i32 roiMapEnable;
|
||||
i32 adaptiveRoi;
|
||||
i32 qpOffset[3];
|
||||
i32 adaptiveRoiColor; /* Color temperature -10..10 = 2000K..5000K */
|
||||
i32 adaptiveRoiMotion; /* Motion sensitivity -10..10 */
|
||||
u32 prevMapCount; /* How many frames previous map is used in. */
|
||||
u32 intra;
|
||||
u32 mvFrames; /* How many frames mvMap is counted for. */
|
||||
u32 cbComp; /* Chroma compensation for white balance fix. */
|
||||
u32 crComp;
|
||||
u32 boxw; /* Filter box dimensions. */
|
||||
u32 boxh;
|
||||
u8 *skinMap[2]; /* Skin MBs before/after filtering */
|
||||
u8 *roiSegmentMap[3]; /* MB maps, 0=curr, 1=prev, 2=curr expanded */
|
||||
u32 roiMbCount[3]; /* Amount of MBs in each of above maps */
|
||||
i32 *mvMap; /* Motion map based on MB MVs */
|
||||
u8 *scoreMap; /* Skin + motion score for each MB */
|
||||
u32 roiUpdate; /* AROI calculation has updated roiSegmentMap[2] */
|
||||
u32 roiCoded; /* The new ROI map has been coded to stream */
|
||||
u32 interlacedFrame; /* Enable interlaced frame input */
|
||||
u32 bottomField; /* Current picture is interlaced bottom field */
|
||||
} preProcess_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
i32 EncPreProcessAlloc(preProcess_s * preProcess, i32 mbPerPicture);
|
||||
void EncPreProcessFree(preProcess_s * preProcess);
|
||||
i32 EncPreProcessCheck(const preProcess_s * preProcess);
|
||||
void EncPreProcess(asicData_s * asic, preProcess_s * preProcess);
|
||||
void EncSetColorConversion(preProcess_s * preProcess, asicData_s * asic);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Locking semaphore for hardware sharing
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __EWL_LINUX_LOCK_H__
|
||||
#define __EWL_LINUX_LOCK_H__
|
||||
|
||||
int binary_semaphore_allocation(void *key, int nsem, int sem_flags);
|
||||
int binary_semaphore_deallocate(int semid);
|
||||
int binary_semaphore_wait(int semid, int sem_num);
|
||||
int binary_semaphore_post(int semid, int sem_num);
|
||||
int binary_semaphore_initialize(int semid, int sem_num);
|
||||
|
||||
#endif /* __EWL_LINUX_LOCK_H__ */
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Hantro 6280/7280/8270/8290 Encoder Wrapper Layer for OS services
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __EWL_X280_COMMON_H__
|
||||
#define __EWL_X280_COMMON_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Macro for debug printing */
|
||||
#undef PTRACE
|
||||
//#define TRACE_EWL
|
||||
#ifdef TRACE_EWL
|
||||
# include "platform_stdlib.h"
|
||||
# define PTRACE(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
# define PTRACE(...) /* no trace */
|
||||
#endif
|
||||
|
||||
#define ASIC_STATUS_RFC_BUFF_OVERFLOW 0x800
|
||||
#define ASIC_STATUS_LINE_BUFFER_DONE 0x400
|
||||
#define ASIC_STATUS_SLICE_READY 0x100
|
||||
#define ASIC_STATUS_TEST_COPY_RDY 0x80
|
||||
#define ASIC_STATUS_TEST_IRQ 0x40
|
||||
#define ASIC_STATUS_BUFF_FULL 0x20
|
||||
#define ASIC_STATUS_RESET 0x10
|
||||
#define ASIC_STATUS_ERROR 0x08
|
||||
#define ASIC_STATUS_FRAME_READY 0x04
|
||||
#define ASIC_IRQ_LINE 0x01
|
||||
|
||||
#ifdef RT_LINE_BUF
|
||||
#define ASIC_STATUS_ALL (ASIC_STATUS_SLICE_READY |\
|
||||
ASIC_STATUS_TEST_IRQ |\
|
||||
ASIC_STATUS_TEST_COPY_RDY |\
|
||||
ASIC_STATUS_FRAME_READY | \
|
||||
ASIC_STATUS_BUFF_FULL | \
|
||||
ASIC_STATUS_RESET | \
|
||||
ASIC_STATUS_ERROR | \
|
||||
ASIC_STATUS_LINE_BUFFER_DONE | \
|
||||
ASIC_STATUS_RFC_BUFF_OVERFLOW)
|
||||
#else
|
||||
#define ASIC_STATUS_ALL (ASIC_STATUS_SLICE_READY |\
|
||||
ASIC_STATUS_TEST_IRQ |\
|
||||
ASIC_STATUS_TEST_COPY_RDY |\
|
||||
ASIC_STATUS_FRAME_READY | \
|
||||
ASIC_STATUS_BUFF_FULL | \
|
||||
ASIC_STATUS_RESET | \
|
||||
ASIC_STATUS_ERROR | \
|
||||
ASIC_STATUS_RFC_BUFF_OVERFLOW)
|
||||
#endif
|
||||
|
||||
/* the encoder device driver nod */
|
||||
#ifndef MEMALLOC_MODULE_PATH
|
||||
#define MEMALLOC_MODULE_PATH "/tmp/dev/memalloc"
|
||||
#endif
|
||||
|
||||
#ifndef ENC_MODULE_PATH
|
||||
#define ENC_MODULE_PATH "/tmp/dev/hx280"
|
||||
#endif
|
||||
|
||||
#ifndef SDRAM_LM_BASE
|
||||
#define SDRAM_LM_BASE 0x00000000
|
||||
#endif
|
||||
|
||||
/* EWL internal information for Linux */
|
||||
typedef struct
|
||||
{
|
||||
u32 clientType;
|
||||
int fd_mem; /* /dev/mem */
|
||||
int fd_enc; /* /dev/hx280 */
|
||||
int fd_memalloc; /* /dev/memalloc */
|
||||
u32 regSize; /* IO mem size */
|
||||
u32 regBase;
|
||||
volatile u32 *pRegBase; /* IO mem base */
|
||||
#ifdef PCIE_FPGA_VERIFICATION
|
||||
u32 linMemBase; /* start address of linear memory wxh added for pcie verification */
|
||||
#endif
|
||||
#ifdef PCIE_FPGA_VERI_LINEBUF
|
||||
u32 sram_base;
|
||||
u32 sram_size;
|
||||
volatile u32 *psrame; /* srame mem base */
|
||||
#endif
|
||||
int semid;
|
||||
int sigio_needed;
|
||||
} hx280ewl_t;
|
||||
|
||||
void HandleSIGIO(hx280ewl_t * enc);
|
||||
|
||||
#endif /* __EWLX280_COMMON_H__ */
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _RTL8195B_EWL_REG_H_
|
||||
#define _RTL8195B_EWL_REG_H_
|
||||
|
||||
// TODO: these address are fake address
|
||||
#define HX280ENC_IOCGHWOFFSET 0x12345678
|
||||
#define HX280ENC_IOCGHWIOSIZE 0x00001000
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
-
|
||||
- Description : H264 CABAC
|
||||
-
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264CABAC_H__
|
||||
#define __H264CABAC_H__
|
||||
|
||||
#include "basetype.h"
|
||||
|
||||
u32 H264CabacInit(u32 *contextTable, u32 cabac_init_idc);
|
||||
|
||||
#endif /* __H264CABAC_H__ */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,55 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Encode picture
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_CODE_FRAME_H__
|
||||
#define __H264_CODE_FRAME_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "H264Instance.h"
|
||||
#include "H264Slice.h"
|
||||
#include "H264RateControl.h"
|
||||
#include "encasiccontroller.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
H264ENCODE_OK = 0,
|
||||
H264ENCODE_TIMEOUT = 1,
|
||||
H264ENCODE_DATA_ERROR = 2,
|
||||
H264ENCODE_HW_ERROR = 3,
|
||||
H264ENCODE_SYSTEM_ERROR = 4,
|
||||
H264ENCODE_HW_RESET = 5
|
||||
} h264EncodeFrame_e;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
h264EncodeFrame_e H264CodeFrame(h264Instance_s * inst);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Encoder initialization and setup
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_INIT_H__
|
||||
#define __H264_INIT_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "h264encapi.h"
|
||||
#include "H264Instance.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
bool_e H264CheckCfg(const H264EncConfig * pEncCfg);
|
||||
i32 H264GetAllowedWidth(i32 width, H264EncPictureType inputType);
|
||||
|
||||
H264EncRet H264Init(const H264EncConfig * pEncCfg, h264Instance_s ** instAddr);
|
||||
|
||||
void H264Shutdown(h264Instance_s *data);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Encoder instance
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_INSTANCE_H__
|
||||
#define __H264_INSTANCE_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "enccommon.h"
|
||||
#include "encpreprocess.h"
|
||||
#include "encasiccontroller.h"
|
||||
|
||||
#include "h264encapi.h" /* Callback type from API is reused */
|
||||
|
||||
#include "H264NalUnit.h"
|
||||
#include "H264SequenceParameterSet.h"
|
||||
#include "H264PictureParameterSet.h"
|
||||
#include "H264PictureBuffer.h"
|
||||
#include "H264Slice.h"
|
||||
#include "H264RateControl.h"
|
||||
#include "H264Mad.h"
|
||||
|
||||
#ifdef VIDEOSTAB_ENABLED
|
||||
#include "vidstabcommon.h"
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
enum H264EncStatus
|
||||
{
|
||||
H264ENCSTAT_INIT = 0xA1,
|
||||
H264ENCSTAT_START_STREAM,
|
||||
H264ENCSTAT_START_FRAME,
|
||||
H264ENCSTAT_ERROR
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 encStatus;
|
||||
u32 mbPerFrame;
|
||||
u32 mbPerRow;
|
||||
u32 mbPerCol;
|
||||
u32 interlaced;
|
||||
u32 frameCnt;
|
||||
u32 fillerNalSize;
|
||||
u32 testId;
|
||||
u32 numViews;
|
||||
u32 numRefBuffsLum;
|
||||
u32 numRefBuffsChr;
|
||||
u32 intraSliceMap[3];
|
||||
u32 idrHdr;
|
||||
stream_s stream;
|
||||
preProcess_s preProcess;
|
||||
sps_s seqParameterSet;
|
||||
pps_s picParameterSet;
|
||||
slice_s slice;
|
||||
mvc_s mvc;
|
||||
h264RateControl_s rateControl;
|
||||
madTable_s mad;
|
||||
asicData_s asic;
|
||||
i32 naluOffset; /* Start offset for NAL unit size table */
|
||||
i32 numNalus; /* Number of NAL units created */
|
||||
H264EncSliceReadyCallBackFunc sliceReadyCbFunc;
|
||||
u32 *pOutBuf; /* User given stream output buffer */
|
||||
void *pAppData; /* User given application specific data */
|
||||
const void *inst;
|
||||
picBuffer picBuffer;
|
||||
#ifdef VIDEOSTAB_ENABLED
|
||||
HWStabData vsHwData;
|
||||
SwStbData vsSwData;
|
||||
#endif
|
||||
i32 gdrEnabled;
|
||||
i32 gdrStart;
|
||||
i32 gdrDuration;
|
||||
i32 gdrCount;
|
||||
i32 gdrAverageMBRows;
|
||||
i32 gdrMBLeft;
|
||||
i32 gdrFirstIntraFrame;
|
||||
inputLineBuf_s inputLineBuf;
|
||||
i32 rfcBufOverflow;
|
||||
} h264Instance_s;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : MAD threshold calculation
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef H264_MAD_H
|
||||
#define H264_MAD_H
|
||||
|
||||
#include "enccommon.h"
|
||||
|
||||
#define DSCY 32 /* n * 32 */
|
||||
#define I32_MAX 2147483647 /* 2 ^ 31 - 1 */
|
||||
#define DIV(a, b) (((a) + (SIGN(a) * (b)) / 2) / (b))
|
||||
#define MAD_TABLE_LEN 5
|
||||
|
||||
typedef struct {
|
||||
i32 a1; /* model parameter, y = a1*x + a2 */
|
||||
i32 a2; /* model parameter */
|
||||
i32 th[MAD_TABLE_LEN]; /* mad threshold */
|
||||
i32 count[MAD_TABLE_LEN]; /* number of macroblocks under threshold */
|
||||
i32 pos; /* current position */
|
||||
i32 len; /* current lenght */
|
||||
i32 threshold[3]; /* current frame thresholds: high/mid/low */
|
||||
i32 mbPerFrame; /* number of macroblocks per frame */
|
||||
} madTable_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
void H264MadInit(madTable_s *mad, u32 mbPerFrame);
|
||||
|
||||
void H264MadThreshold(madTable_s *madTable, u32 *madCount);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : NAL unit handling
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_NAL_UNIT_H__
|
||||
#define __H264_NAL_UNIT_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "H264PutBits.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 anchorPicFlag;
|
||||
u32 priorityId;
|
||||
u32 viewId;
|
||||
u32 temporalId;
|
||||
u32 interViewFlag;
|
||||
} mvc_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
void H264NalUnitHdr(stream_s * stream, i32 nalRefIdc, nalUnitType_e
|
||||
nalUnitType, true_e byteStream);
|
||||
void H264NalUnitHdrMvcExtension(stream_s * stream, mvc_s * mvc);
|
||||
void H264NalUnitTrailinBits(stream_s * stream, true_e byteStream);
|
||||
u32 H264FillerNALU(stream_s * sp, i32 cnt, true_e byteStream);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef H264PICTURE_BUFFER_H
|
||||
#define H264PICTURE_BUFFER_H
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "encasiccontroller.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
#define BUFFER_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
i32 lumWidth; /* Width of *lum */
|
||||
i32 lumHeight; /* Height of *lum */
|
||||
i32 chWidth; /* Width of *cb and *cr */
|
||||
i32 chHeight; /* Height of *cb and *cr */
|
||||
u32 lum;
|
||||
u32 cb;
|
||||
} picture;
|
||||
|
||||
typedef struct refPic {
|
||||
picture picture; /* Image data */
|
||||
i32 poc; /* Picture order count */
|
||||
|
||||
bool i_frame; /* I frame (key frame), only intra mb */
|
||||
bool p_frame; /* P frame, intra and inter mb */
|
||||
bool show; /* Frame is for display (showFrame flag) */
|
||||
bool ipf; /* Frame is immediately previous frame */
|
||||
bool arf; /* Frame is altref frame */
|
||||
bool grf; /* Frame is golden frame */
|
||||
bool search; /* Frame is used for motion estimation */
|
||||
struct refPic *refPic; /* Back reference pointer to itself */
|
||||
} refPic;
|
||||
|
||||
typedef struct {
|
||||
i32 size; /* Amount of allocated reference pictures */
|
||||
picture input; /* Input picture */
|
||||
refPic refPic[BUFFER_SIZE + 1]; /* Reference picture store */
|
||||
refPic refPicList[BUFFER_SIZE]; /* Reference picture list */
|
||||
refPic *cur_pic; /* Pointer to picture under reconstruction */
|
||||
refPic *last_pic; /* Last picture */
|
||||
} picBuffer;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
i32 H264PictureBufferAlloc(picBuffer *picBuffer, i32 width, i32 height);
|
||||
void H264PictureBufferFree(picBuffer *picBuffer);
|
||||
void H264InitializePictureBuffer(picBuffer *picBuffer);
|
||||
void H264UpdatePictureBuffer(picBuffer *picBuffer);
|
||||
void H264PictureBufferSetRef(picBuffer *picBuffer, asicData_s *asic, u32 numViews);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_PICTURE_PARAMETER_SET_H__
|
||||
#define __H264_PICTURE_PARAMETER_SET_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
#include "H264PutBits.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
true_e byteStream;
|
||||
i32 picParameterSetId;
|
||||
i32 seqParameterSetId;
|
||||
true_e entropyCodingMode;
|
||||
true_e picOrderPresent;
|
||||
i32 numSliceGroupsMinus1;
|
||||
i32 numRefIdxL0ActiveMinus1;
|
||||
i32 numRefIdxL1ActiveMinus1;
|
||||
true_e weightedPred;
|
||||
i32 weightedBipredIdc;
|
||||
i32 picInitQpMinus26;
|
||||
i32 picInitQsMinus26;
|
||||
i32 chromaQpIndexOffset;
|
||||
true_e deblockingFilterControlPresent;
|
||||
true_e constIntraPred;
|
||||
true_e redundantPicCntPresent;
|
||||
true_e transform8x8Mode;
|
||||
u32 enableCabac; /* 0=cavlc, 1=cabac, 2=cavlc(intra)+cabac(inter) */
|
||||
} pps_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
void H264PicParameterSetInit(pps_s * pps);
|
||||
void H264PicParameterSet(stream_s * stream, pps_s * pps);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Bit stream handling
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_PUT_BITS_H__
|
||||
#define __H264_PUT_BITS_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#if 1
|
||||
#define H264NalBits(stream, val, num) H264PutNalBits(stream, val, num)
|
||||
#else
|
||||
#define H264NalBits(stream, val, num) \
|
||||
if (stream->bufferedBits + num < 8) { \
|
||||
i32 bits = stream->bufferedBits + (num); \
|
||||
stream->bufferedBits += (num); \
|
||||
stream->byteBuffer = stream->byteBuffer | ((u32)(val) << (32-bits)); \
|
||||
} else { \
|
||||
H264PutNalBits(stream, val, num); \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
bool_e H264SetBuffer(stream_s * buffer, u8 * stream, u32 size);
|
||||
void H264PutBits(stream_s *, i32, i32);
|
||||
void H264PutNalBits(stream_s *, i32, i32);
|
||||
void H264ExpGolombUnsigned(stream_s * stream, u32 val);
|
||||
void H264ExpGolombSigned(stream_s * stream, i32 val);
|
||||
void H264RbspTrailingBits(stream_s * stream);
|
||||
void H264Comment(char *comment);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Rate control structures and function prototypes
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef H264_RATE_CONTROL_H
|
||||
#define H264_RATE_CONTROL_H
|
||||
|
||||
#include "enccommon.h"
|
||||
#include "H264Sei.h"
|
||||
|
||||
enum
|
||||
{ H264RC_OVERFLOW = -1 };
|
||||
|
||||
#define RC_CBR_HRD 0 /* 1 = Constant bit rate model. Must use filler
|
||||
* data to conform */
|
||||
|
||||
#define CTRL_LEVELS 7 /* DO NOT CHANGE THIS */
|
||||
#define CHECK_POINTS_MAX 10 /* DO NOT CHANGE THIS */
|
||||
#define RC_TABLE_LENGTH 10 /* DO NOT CHANGE THIS */
|
||||
|
||||
typedef struct {
|
||||
i32 a1; /* model parameter */
|
||||
i32 a2; /* model parameter */
|
||||
i32 qp_prev; /* previous QP */
|
||||
i32 qs[RC_TABLE_LENGTH+1]; /* quantization step size */
|
||||
i32 bits[RC_TABLE_LENGTH+1];/* Number of bits needed to code residual */
|
||||
i32 pos; /* current position */
|
||||
i32 len; /* current lenght */
|
||||
i32 zero_div; /* a1 divisor is 0 */
|
||||
} linReg_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
i32 wordError[CTRL_LEVELS]; /* Check point error bit */
|
||||
i32 qpChange[CTRL_LEVELS]; /* Check point qp difference */
|
||||
i32 wordCntTarget[CHECK_POINTS_MAX]; /* Required bit count */
|
||||
i32 wordCntPrev[CHECK_POINTS_MAX]; /* Real bit count */
|
||||
i32 checkPointDistance;
|
||||
i32 checkPoints;
|
||||
} h264QpCtrl_s;
|
||||
|
||||
/* Virtual buffer */
|
||||
typedef struct
|
||||
{
|
||||
i32 bufferSize; /* size of the virtual buffer */
|
||||
i32 bitRate; /* input bit rate per second */
|
||||
i32 bitPerPic; /* average number of bits per picture */
|
||||
i32 picTimeInc; /* timeInc since last coded picture */
|
||||
i32 timeScale; /* input frame rate numerator */
|
||||
i32 unitsInTic; /* input frame rate denominator */
|
||||
i32 virtualBitCnt; /* virtual (channel) bit count */
|
||||
i32 realBitCnt; /* real bit count */
|
||||
i32 bufferOccupancy; /* number of bits in the buffer */
|
||||
i32 skipFrameTarget; /* how many frames should be skipped in a row */
|
||||
i32 skippedFrames; /* how many frames have been skipped in a row */
|
||||
i32 nonZeroTarget;
|
||||
i32 bucketFullness; /* Leaky Bucket fullness */
|
||||
i32 bucketLevel; /* Leaky Bucket fullness + virtualBitCnt */
|
||||
/* new rate control */
|
||||
i32 windowRem;
|
||||
i32 seconds; /* Full seconds elapsed */
|
||||
i32 averageBitRate; /* This buffer average bitrate for full seconds */
|
||||
} h264VirtualBuffer_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
true_e picRc;
|
||||
true_e mbRc; /* Mb header qp can vary, check point rc */
|
||||
true_e picSkip; /* Frame Skip enable */
|
||||
true_e hrd; /* HRD restrictions followed or not */
|
||||
u32 fillerIdx;
|
||||
i32 mbPerPic; /* Number of macroblock per picture */
|
||||
i32 mbRows; /* MB rows in picture */
|
||||
i32 coeffCntMax; /* Number of coeff per picture */
|
||||
i32 nonZeroCnt;
|
||||
i32 srcPrm; /* Source parameter */
|
||||
i32 qpSum; /* Qp sum counter */
|
||||
u32 sliceTypeCur;
|
||||
u32 sliceTypePrev;
|
||||
true_e frameCoded; /* Pic coded information */
|
||||
i32 fixedQp; /* Pic header qp when fixed */
|
||||
i32 qpHdr; /* Pic header qp of current voded picture */
|
||||
i32 qpMin; /* Pic header minimum qp, user set */
|
||||
i32 qpMax; /* Pic header maximum qp, user set */
|
||||
i32 qpHdrPrev; /* Pic header qp of previous coded picture */
|
||||
i32 qpLastCoded; /* Quantization parameter of last coded mb */
|
||||
i32 qpTarget; /* Target quantrization parameter */
|
||||
u32 estTimeInc;
|
||||
i32 outRateNum;
|
||||
i32 outRateDenom;
|
||||
i32 gDelaySum;
|
||||
i32 gInitialDelay;
|
||||
i32 gInitialDoffs;
|
||||
h264QpCtrl_s qpCtrl;
|
||||
h264VirtualBuffer_s virtualBuffer;
|
||||
sei_s sei;
|
||||
i32 gBufferMin, gBufferMax;
|
||||
/* new rate control */
|
||||
linReg_s linReg; /* Data for R-Q model for inter frames */
|
||||
linReg_s rError; /* Rate prediction error for inter frames(bits) */
|
||||
linReg_s intra; /* Data for intra frames */
|
||||
linReg_s intraError; /* Prediction error for intra frames */
|
||||
linReg_s gop; /* Data for GOP */
|
||||
i32 targetPicSize;
|
||||
i32 frameBitCnt;
|
||||
i32 sumQp;
|
||||
i32 sumBitrateError;
|
||||
i32 sumFrameError;
|
||||
/* for gop rate control */
|
||||
i32 gopQpSum; /* Sum of current GOP inter frame QPs */
|
||||
i32 gopQpDiv;
|
||||
i32 gopBitCnt; /* Current GOP bit count so far */
|
||||
i32 gopAvgBitCnt; /* Previous GOP average bit count */
|
||||
u32 frameCnt;
|
||||
i32 gopLen;
|
||||
i32 windowLen; /* Bitrate window which tries to match target */
|
||||
i32 intraInterval; /* Distance between two previous I-frames */
|
||||
i32 intraIntervalCtr;
|
||||
i32 intraQpDelta;
|
||||
u32 fixedIntraQp;
|
||||
i32 mbQpAdjustment[3]; /* QP delta for MAD macroblock QP adjustment */
|
||||
i32 longTermPicRate;
|
||||
i32 mbQpAutoBoost;
|
||||
/* for adaptive QP (can be lower or higher) */
|
||||
i32 adaptQpEn; /* enable = 1 */
|
||||
i32 qpPrevDesired; /* store unbounded QP (not limited by qpMax and qpMin) */
|
||||
i32 qpInitMax; /* init value of qpMax */
|
||||
i32 qpInitMin; /* init value of qpMin */
|
||||
|
||||
} h264RateControl_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
bool_e H264InitRc(h264RateControl_s * rc, u32 newStream);
|
||||
void H264BeforePicRc(h264RateControl_s * rc, u32 timeInc, u32 sliceType);
|
||||
i32 H264AfterPicRc(h264RateControl_s * rc, u32 nonZeroCnt, u32 byteCnt,
|
||||
u32 qpSum);
|
||||
u32 H264FillerRc(h264RateControl_s * rc, u32 frameCnt);
|
||||
i32 H264Calculate(i32 a, i32 b, i32 c);
|
||||
|
||||
#endif /* H264_RATE_CONTROL_H */
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : H.264 SEI Messages.
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef H264_SEI_H
|
||||
#define H264_SEI_H
|
||||
|
||||
#include "basetype.h"
|
||||
#include "H264PutBits.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 fts; /* Full time stamp */
|
||||
u32 timeScale;
|
||||
u32 nuit; /* number of units in tick */
|
||||
u32 time; /* Modulo time */
|
||||
u32 secf;
|
||||
u32 sec; /* Seconds */
|
||||
u32 minf;
|
||||
u32 min; /* Minutes */
|
||||
u32 hrf;
|
||||
u32 hr; /* Hours */
|
||||
} timeStamp_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
timeStamp_s ts;
|
||||
u32 nalUnitSize;
|
||||
u32 enabled;
|
||||
true_e byteStream;
|
||||
u32 hrd; /* HRD conformance */
|
||||
u32 seqId;
|
||||
u32 icrd; /* initial cpb removal delay */
|
||||
u32 icrdLen;
|
||||
u32 icrdo; /* initial cpb removal delay offset */
|
||||
u32 icrdoLen;
|
||||
u32 crd; /* CPB removal delay */
|
||||
u32 crdLen;
|
||||
u32 dod; /* DPB removal delay */
|
||||
u32 dodLen;
|
||||
u32 psp;
|
||||
u32 ps;
|
||||
u32 cts;
|
||||
u32 cntType;
|
||||
u32 cdf;
|
||||
u32 nframes;
|
||||
u32 toffs;
|
||||
u32 toffsLen;
|
||||
u32 userDataEnabled;
|
||||
const u8 * pUserData;
|
||||
u32 userDataSize;
|
||||
u32 insertRecoveryPointMessage;
|
||||
u32 recoveryFrameCnt;
|
||||
} sei_s;
|
||||
|
||||
void H264InitSei(sei_s * sei, true_e byteStream, u32 hrd, u32 timeScale,
|
||||
u32 nuit);
|
||||
void H264UpdateSeiTS(sei_s * sei, u32 timeInc);
|
||||
void H264FillerSei(stream_s * sp, sei_s * sei, i32 cnt);
|
||||
void H264BufferingSei(stream_s * stream, sei_s * sei);
|
||||
void H264PicTimingSei(stream_s * stream, sei_s * sei);
|
||||
void H264UserDataUnregSei(stream_s * sp, sei_s * sei);
|
||||
void H264RecoveryPointSei(stream_s * sp, sei_s * sei);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : H264 Sequence Parameter Set
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_SEQUENCE_PARAMETER_SET_h__
|
||||
#define __H264_SEQUENCE_PARAMETER_SET_h__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
#include "H264PutBits.h"
|
||||
#include "H264Slice.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 timeScale;
|
||||
u32 numUnitsInTick;
|
||||
u32 bitStreamRestrictionFlag;
|
||||
u32 videoFullRange;
|
||||
u32 sarWidth;
|
||||
u32 sarHeight;
|
||||
u32 nalHrdParametersPresentFlag;
|
||||
u32 vclHrdParametersPresentFlag;
|
||||
u32 pictStructPresentFlag;
|
||||
u32 initialCpbRemovalDelayLength;
|
||||
u32 cpbRemovalDelayLength;
|
||||
u32 dpbOutputDelayLength;
|
||||
u32 timeOffsetLength;
|
||||
u32 bitRate;
|
||||
u32 cpbSize;
|
||||
} vui_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
true_e byteStream;
|
||||
u32 profileIdc;
|
||||
true_e constraintSet0;
|
||||
true_e constraintSet1;
|
||||
true_e constraintSet2;
|
||||
true_e constraintSet3;
|
||||
u32 levelIdc;
|
||||
u32 levelIdx;
|
||||
u32 seqParameterSetId;
|
||||
i32 log2MaxFrameNumMinus4;
|
||||
u32 picOrderCntType;
|
||||
u32 numRefFrames;
|
||||
true_e gapsInFrameNumValueAllowed;
|
||||
i32 picWidthInMbsMinus1;
|
||||
i32 picHeightInMapUnitsMinus1;
|
||||
true_e frameMbsOnly;
|
||||
true_e direct8x8Inference;
|
||||
true_e frameCropping;
|
||||
true_e vuiParametersPresent;
|
||||
vui_t vui;
|
||||
u32 frameCropLeftOffset;
|
||||
u32 frameCropRightOffset;
|
||||
u32 frameCropTopOffset;
|
||||
u32 frameCropBottomOffset;
|
||||
} sps_s;
|
||||
|
||||
extern const u32 H264LevelIdc[];
|
||||
extern const u32 H264MaxCPBS[];
|
||||
extern const u32 H264MaxFS[];
|
||||
extern const u32 H264SqrtMaxFS8[];
|
||||
extern const u32 H264MaxMBPS[];
|
||||
extern const u32 H264MaxBR[];
|
||||
|
||||
#define INVALID_LEVEL 0xFFFF
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
void H264SeqParameterSetInit(sps_s * sps);
|
||||
void H264SeqParameterSet(stream_s * stream, sps_s * sps, true_e nalHeader);
|
||||
void H264SubsetSeqParameterSet(stream_s * stream, sps_s * sps);
|
||||
|
||||
void H264EndOfSequence(stream_s * stream, sps_s * sps);
|
||||
void H264EndOfStream(stream_s * stream, sps_s * sps);
|
||||
|
||||
u32 H264GetLevelIndex(u32 levelIdc);
|
||||
|
||||
bool_e H264CheckLevel(sps_s * sps, i32 bitRate, i32 frameRateNum,
|
||||
i32 frameRateDenom);
|
||||
|
||||
void H264SpsSetVuiTimigInfo(sps_s * sps, u32 timeScale, u32 numUnitsInTick);
|
||||
void H264SpsSetVuiVideoInfo(sps_s * sps, u32 videoFullRange);
|
||||
void H264SpsSetVuiAspectRatio(sps_s * sps, u32 sampleAspectRatioWidth,
|
||||
u32 sampleAspectRatioHeight);
|
||||
void H264SpsSetVuiPictStructPresentFlag(sps_s * sps, u32 flag);
|
||||
void H264SpsSetVuiHrd(sps_s * sps, u32 present);
|
||||
void H264SpsSetVuiHrdBitRate(sps_s * sps, u32 bitRate);
|
||||
void H264SpsSetVuiHrdCpbSize(sps_s * sps, u32 cpbSize);
|
||||
u32 H264SpsGetVuiHrdBitRate(sps_s * sps);
|
||||
u32 H264SpsGetVuiHrdCpbSize(sps_s * sps);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_SLICE_H__
|
||||
#define __H264_SLICE_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
#include "H264PutBits.h"
|
||||
#include "H264NalUnit.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
typedef enum
|
||||
{
|
||||
PSLICE = 0,
|
||||
ISLICE = 2,
|
||||
PSLICES = 5,
|
||||
ISLICES = 7
|
||||
} sliceType_e;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
true_e byteStream;
|
||||
u32 sliceSize;
|
||||
sliceType_e sliceType;
|
||||
nalUnitType_e nalUnitType;
|
||||
u32 picParameterSetId;
|
||||
u32 prevFrameNum;
|
||||
u32 frameNum;
|
||||
u32 frameNumBits;
|
||||
u32 idrPicId;
|
||||
u32 nalRefIdc;
|
||||
u32 disableDeblocking;
|
||||
i32 filterOffsetA;
|
||||
i32 filterOffsetB;
|
||||
u32 cabacInitIdc;
|
||||
u32 quarterPixelMv;
|
||||
u32 fieldOrder; /* 1=top first, 0=bottom first */
|
||||
} slice_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
void H264SliceInit(slice_s * slice);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Description : Encoder setup according to a test vector
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __H264_TESTID_H__
|
||||
#define __H264_TESTID_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "H264Instance.h"
|
||||
#include "H264Slice.h"
|
||||
#include "H264RateControl.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
void H264ConfigureTestBeforeFrame(h264Instance_s * inst);
|
||||
void H264ConfigureTestPenalties(h264Instance_s * inst);
|
||||
void H264InputLineBufDepthTest(h264Instance_s *inst);
|
||||
void H264CroppingTest(h264Instance_s *inst);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,186 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_JPEG_H__
|
||||
#define __ENC_JPEG_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "jpegencapi.h"
|
||||
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
|
||||
#include "EncJpegPutBits.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#define MAX_NUMBER_OF_COMPONENTS 3
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
enum
|
||||
{
|
||||
ENC_WHOLE_FRAME,
|
||||
ENC_PARTIAL_FRAME,
|
||||
ENC_420_MODE,
|
||||
ENC_422_MODE
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ENC_NO_UNITS = 0,
|
||||
ENC_DOTS_PER_INCH = 1,
|
||||
ENC_DOTS_PER_CM = 2
|
||||
} EncAppUnitsType;
|
||||
|
||||
enum
|
||||
{
|
||||
ENC_SINGLE_MARKER,
|
||||
ENC_MULTI_MARKER
|
||||
};
|
||||
|
||||
typedef struct JpegEncQuantTables_t
|
||||
{
|
||||
const u8 *pQlumi;
|
||||
const u8 *pQchromi;
|
||||
|
||||
} JpegEncQuantTables;
|
||||
|
||||
typedef struct JpegEncFrameHeader_t /* SOF0 */
|
||||
{
|
||||
u32 header;
|
||||
u32 Lf;
|
||||
u32 P;
|
||||
u32 Y;
|
||||
u32 X;
|
||||
u32 Nf;
|
||||
u32 Ci[MAX_NUMBER_OF_COMPONENTS];
|
||||
u32 Hi[MAX_NUMBER_OF_COMPONENTS];
|
||||
u32 Vi[MAX_NUMBER_OF_COMPONENTS];
|
||||
u32 Tqi[MAX_NUMBER_OF_COMPONENTS];
|
||||
|
||||
} JpegEncFrameHeader;
|
||||
|
||||
typedef struct JpegEncCommentHeader_t /* COM */
|
||||
{
|
||||
u32 comEnable;
|
||||
u32 Lc;
|
||||
u32 comLen;
|
||||
const u8 *pComment;
|
||||
|
||||
} JpegEncCommentHeader;
|
||||
|
||||
typedef struct JpegEncRestart_t /* DRI */
|
||||
{
|
||||
u32 Lr;
|
||||
u32 Ri;
|
||||
|
||||
} JpegEncRestart;
|
||||
|
||||
typedef struct JpegEncAppn_t /* APP0 */
|
||||
{
|
||||
u32 Lp;
|
||||
u32 ident1;
|
||||
u32 ident2;
|
||||
u32 ident3;
|
||||
u32 version;
|
||||
u32 units;
|
||||
u32 Xdensity;
|
||||
u32 Ydensity;
|
||||
/*u32 XThumbnail;*/
|
||||
/*u32 YThumbnail;*/
|
||||
/*u32 thumbMode;*/
|
||||
/*u32 rgb1;*/
|
||||
/*u32 rgb2;*/
|
||||
u32 thumbEnable;
|
||||
/*u32 thumbSize;*/
|
||||
/*u32 targetStart;*/
|
||||
/*u32 targetEnd;*/
|
||||
/*u8 *pStartOfOutput;*/
|
||||
/*u8 *pHor;*/
|
||||
/*u8 *pVer;*/
|
||||
/*u32 appExtLp;*/
|
||||
/*u32 appExtId1;*/
|
||||
/*u32 appExtId2;*/
|
||||
/*u32 appExtId3;*/
|
||||
/*u32 extCode;*/
|
||||
} JpegEncAppn_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
true_e header;
|
||||
JpegEncRestart restart; /* Restart Interval */
|
||||
i32 rstCount;
|
||||
JpegEncFrameHeader frame; /* Frame Header Data */
|
||||
JpegEncCommentHeader com; /* COM Header Data */
|
||||
JpegEncAppn_t appn; /* APPn Header Data */
|
||||
JpegEncQuantTables qTable;
|
||||
i32 markerType;
|
||||
i32 codingType; /* Whole or slice */
|
||||
i32 codingMode; /* 420 or 422 */
|
||||
i32 sliceNum; /* Number of current input slice */
|
||||
i32 sliceRows; /* Amount of MB rows in a slice */
|
||||
/*i32 rotation;*/ /* Rotation 0/-90*+90 */
|
||||
i32 width;
|
||||
i32 height;
|
||||
i32 mbNum;
|
||||
i32 mbPerFrame;
|
||||
i32 row;
|
||||
/*i32 column;*/
|
||||
/*i32 lastColumn;*/
|
||||
/*i32 dcAbove[6];*/
|
||||
/*i32 dcCurrent[6];*/
|
||||
/*i32 dc[6];*/ /* Macroblock DC */
|
||||
/*i32 rlcCount[6];*/ /* Block RLC count */
|
||||
/*const i16 *rlc[6];*/ /* RLC data for each block */
|
||||
u8 qTableLuma[64];
|
||||
u8 qTableChroma[64];
|
||||
u8 *streamStartAddress; /* output start address */
|
||||
JpegEncThumb thumbnail; /* thumbnail data */
|
||||
} jpegData_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
void EncJpegInit(jpegData_s * jpeg);
|
||||
|
||||
u32 EncJpegHdr(stream_s * stream, jpegData_s * data);
|
||||
|
||||
/*void EncJpegImageEnd(stream_s * stream, jpegData_s * data);*/
|
||||
|
||||
/*void EncJpegImageEndReplaceRst(stream_s * stream, jpegData_s * data);*/
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. External compiler flags
|
||||
3. Module defines
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_JPEG_CODE_VOP_H__
|
||||
#define __ENC_JPEG_CODE_VOP_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "EncJpeg.h"
|
||||
#include "EncJpegInstance.h"
|
||||
|
||||
#include "enccommon.h"
|
||||
#include "encasiccontroller.h"
|
||||
#include "EncJpegPutBits.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
JPEGENCODE_OK = 0,
|
||||
JPEGENCODE_TIMEOUT = 1,
|
||||
JPEGENCODE_DATA_ERROR = 2,
|
||||
JPEGENCODE_HW_ERROR = 3,
|
||||
JPEGENCODE_SYSTEM_ERROR = 4,
|
||||
JPEGENCODE_HW_RESET = 5
|
||||
} jpegEncodeFrame_e;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
jpegEncodeFrame_e EncJpegCodeFrame(jpegInstance_s * inst);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. External compiler flags
|
||||
3. Module defines
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __JPEG_COMMON_H__
|
||||
#define __JPEG_COMMON_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,310 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_JPEG_DHT_TABLES_H__
|
||||
#define __ENC_JPEG_DHT_TABLES_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------ DC Huffman codes for DHT header --------------------*/
|
||||
|
||||
typedef struct JpegEncDcDhtTables_t
|
||||
{
|
||||
u32 DcLumLi;
|
||||
u32 DcChromLi;
|
||||
|
||||
} JpegEncDcDhtTables;
|
||||
|
||||
/* Table for Luminance & Chrominace DC coefficient to DHT */
|
||||
|
||||
static const JpegEncDcDhtTables Dc_Li[16] = {
|
||||
{0x00, 0x00},
|
||||
{0x01, 0x03},
|
||||
{0x05, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x01, 0x01},
|
||||
{0x00, 0x01},
|
||||
{0x00, 0x01},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x00}
|
||||
};
|
||||
|
||||
/* Table for Luminance & Chrominace DC coefficient value associated to Li */
|
||||
|
||||
typedef struct JpegEncDcVijTables_t
|
||||
{
|
||||
u32 DcLumVij;
|
||||
u32 DcChromVij;
|
||||
|
||||
} JpegEncDcVijTables;
|
||||
|
||||
static const JpegEncDcVijTables Vij_Dc[12] = {
|
||||
{0x00, 0x00},
|
||||
{0x01, 0x01},
|
||||
{0x02, 0x02},
|
||||
{0x03, 0x03},
|
||||
{0x04, 0x04},
|
||||
{0x05, 0x05},
|
||||
{0x06, 0x06},
|
||||
{0x07, 0x07},
|
||||
{0x08, 0x08},
|
||||
{0x09, 0x09},
|
||||
{0x0A, 0x0A},
|
||||
{0x0B, 0x0B},
|
||||
};
|
||||
|
||||
/* AC Huffman codes for DHT header */
|
||||
|
||||
/*------------------ AC Huffman codes for DHT header --------------------*/
|
||||
|
||||
typedef struct JpegEncAcDhtTables_t
|
||||
{
|
||||
u32 AcLumLi;
|
||||
u32 AcChromLi;
|
||||
|
||||
} JpegEncAcDhtTables;
|
||||
|
||||
/* Table for Luminance & Chrominace AC coefficient to DHT */
|
||||
|
||||
static const JpegEncAcDhtTables Ac_Li[16] = {
|
||||
{0x00, 0x00},
|
||||
{0x02, 0x02},
|
||||
{0x01, 0x01},
|
||||
{0x03, 0x02},
|
||||
{0x03, 0x04},
|
||||
{0x02, 0x04},
|
||||
{0x04, 0x03},
|
||||
{0x03, 0x04},
|
||||
{0x05, 0x07},
|
||||
{0x05, 0x05},
|
||||
{0x04, 0x04},
|
||||
{0x04, 0x04},
|
||||
{0x00, 0x00},
|
||||
{0x00, 0x01},
|
||||
{0x01, 0x02},
|
||||
{0x7D, 0x77}
|
||||
};
|
||||
|
||||
/* Table for Luminance & Chrominace AC coefficient value associated to Li */
|
||||
|
||||
typedef struct JpegEncAcVijTables_t
|
||||
{
|
||||
u32 AcLumVij;
|
||||
u32 AcChromVij;
|
||||
|
||||
} JpegEncAcVijTables;
|
||||
|
||||
static const JpegEncAcVijTables Vij_Ac[162] = {
|
||||
{0x01, 0x00},
|
||||
{0x02, 0x01},
|
||||
{0x03, 0x02},
|
||||
{0x00, 0x03},
|
||||
{0x04, 0x11},
|
||||
{0x11, 0x04},
|
||||
{0x05, 0x05},
|
||||
{0x12, 0x21},
|
||||
{0x21, 0x31},
|
||||
{0x31, 0x06},
|
||||
{0x41, 0x12},
|
||||
{0x06, 0x41},
|
||||
{0x13, 0x51},
|
||||
{0x51, 0x07},
|
||||
{0x61, 0x61},
|
||||
{0x07, 0x71},
|
||||
{0x22, 0x13},
|
||||
{0x71, 0x22},
|
||||
{0x14, 0x32},
|
||||
{0x32, 0x81},
|
||||
{0x81, 0x08},
|
||||
{0x91, 0x14},
|
||||
{0xA1, 0x42},
|
||||
{0x08, 0x91},
|
||||
{0x23, 0xA1},
|
||||
{0x42, 0xB1},
|
||||
{0xB1, 0xC1},
|
||||
{0xC1, 0x09},
|
||||
{0x15, 0x23},
|
||||
{0x52, 0x33},
|
||||
{0xD1, 0x52},
|
||||
{0xF0, 0xF0},
|
||||
{0x24, 0x15},
|
||||
{0x33, 0x62},
|
||||
{0x62, 0x72},
|
||||
{0x72, 0xD1},
|
||||
{0x82, 0x0A},
|
||||
{0x09, 0x16},
|
||||
{0x0A, 0x24},
|
||||
{0x16, 0x34},
|
||||
{0x17, 0xE1},
|
||||
{0x18, 0x25},
|
||||
{0x19, 0xF1},
|
||||
{0x1A, 0x17},
|
||||
{0x25, 0x18},
|
||||
{0x26, 0x19},
|
||||
{0x27, 0x1A},
|
||||
{0x28, 0x26},
|
||||
{0x29, 0x27},
|
||||
{0x2A, 0x28},
|
||||
{0x34, 0x29},
|
||||
{0x35, 0x2A},
|
||||
{0x36, 0x35},
|
||||
{0x37, 0x36},
|
||||
{0x38, 0x37},
|
||||
{0x39, 0x38},
|
||||
{0x3A, 0x39},
|
||||
{0x43, 0x3A},
|
||||
{0x44, 0x43},
|
||||
{0x45, 0x44},
|
||||
{0x46, 0x45},
|
||||
{0x47, 0x46},
|
||||
{0x48, 0x47},
|
||||
{0x49, 0x48},
|
||||
{0x4A, 0x49},
|
||||
{0x53, 0x4A},
|
||||
{0x54, 0x53},
|
||||
{0x55, 0x54},
|
||||
{0x56, 0x55},
|
||||
{0x57, 0x56},
|
||||
{0x58, 0x57},
|
||||
{0x59, 0x58},
|
||||
{0x5A, 0x59},
|
||||
{0x63, 0x5A},
|
||||
{0x64, 0x63},
|
||||
{0x65, 0x64},
|
||||
{0x66, 0x65},
|
||||
{0x67, 0x66},
|
||||
{0x68, 0x67},
|
||||
{0x69, 0x68},
|
||||
{0x6A, 0x69},
|
||||
{0x73, 0x6A},
|
||||
{0x74, 0x73},
|
||||
{0x75, 0x74},
|
||||
{0x76, 0x75},
|
||||
{0x77, 0x76},
|
||||
{0x78, 0x77},
|
||||
{0x79, 0x78},
|
||||
{0x7A, 0x79},
|
||||
{0x83, 0x7A},
|
||||
{0x84, 0x82},
|
||||
{0x85, 0x83},
|
||||
{0x86, 0x84},
|
||||
{0x87, 0x85},
|
||||
{0x88, 0x86},
|
||||
{0x89, 0x87},
|
||||
{0x8A, 0x88},
|
||||
{0x92, 0x89},
|
||||
{0x93, 0x8A},
|
||||
{0x94, 0x92},
|
||||
{0x95, 0x93},
|
||||
{0x96, 0x94},
|
||||
{0x97, 0x95},
|
||||
{0x98, 0x96},
|
||||
{0x99, 0x97},
|
||||
{0x9A, 0x98},
|
||||
{0xA2, 0x99},
|
||||
{0xA3, 0x9A},
|
||||
{0xA4, 0xA2},
|
||||
{0xA5, 0xA3},
|
||||
{0xA6, 0xA4},
|
||||
{0xA7, 0xA5},
|
||||
{0xA8, 0xA6},
|
||||
{0xA9, 0xA7},
|
||||
{0xAA, 0xA8},
|
||||
{0xB2, 0xA9},
|
||||
{0xB3, 0xAA},
|
||||
{0xB4, 0xB2},
|
||||
{0xB5, 0xB3},
|
||||
{0xB6, 0xB4},
|
||||
{0xB7, 0xB5},
|
||||
{0xB8, 0xB6},
|
||||
{0xB9, 0xB7},
|
||||
{0xBA, 0xB8},
|
||||
{0xC2, 0xB9},
|
||||
{0xC3, 0xBA},
|
||||
{0xC4, 0xC2},
|
||||
{0xC5, 0xC3},
|
||||
{0xC6, 0xC4},
|
||||
{0xC7, 0xC5},
|
||||
{0xC8, 0xC6},
|
||||
{0xC9, 0xC7},
|
||||
{0xCA, 0xC8},
|
||||
{0xD2, 0xC9},
|
||||
{0xD3, 0xCA},
|
||||
{0xD4, 0xD2},
|
||||
{0xD5, 0xD3},
|
||||
{0xD6, 0xD4},
|
||||
{0xD7, 0xD5},
|
||||
{0xD8, 0xD6},
|
||||
{0xD9, 0xD7},
|
||||
{0xDA, 0xD8},
|
||||
{0xE1, 0xD9},
|
||||
{0xE2, 0xDA},
|
||||
{0xE3, 0xE2},
|
||||
{0xE4, 0xE3},
|
||||
{0xE5, 0xE4},
|
||||
{0xE6, 0xE5},
|
||||
{0xE7, 0xE6},
|
||||
{0xE8, 0xE7},
|
||||
{0xE9, 0xE8},
|
||||
{0xEA, 0xE9},
|
||||
{0xF1, 0xEA},
|
||||
{0xF2, 0xF2},
|
||||
{0xF3, 0xF3},
|
||||
{0xF4, 0xF4},
|
||||
{0xF5, 0xF5},
|
||||
{0xF6, 0xF6},
|
||||
{0xF7, 0xF7},
|
||||
{0xF8, 0xF8},
|
||||
{0xF9, 0xF9},
|
||||
{0xFA, 0xFA}
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_JPEG_INIT_H__
|
||||
#define __ENC_JPEG_INIT_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "jpegencapi.h"
|
||||
#include "EncJpegQuantTables.h"
|
||||
#include "EncJpegInstance.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
JpegEncRet JpegInit(const JpegEncCfg * pEncCfg, jpegInstance_s ** instAddr);
|
||||
|
||||
void JpegShutdown(jpegInstance_s * data);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. External compiler flags
|
||||
3. Module defines
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ENC_JPEG_INSTANCE_H__
|
||||
#define __ENC_JPEG_INSTANCE_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "enccommon.h"
|
||||
#include "encpreprocess.h"
|
||||
#include "encasiccontroller.h"
|
||||
|
||||
#include "EncJpeg.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
enum JpegEncStatus
|
||||
{
|
||||
ENCSTAT_INIT = 0xA1,
|
||||
ENCSTAT_ENCODE,
|
||||
ENCSTAT_ERROR
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 encStatus;
|
||||
stream_s stream;
|
||||
preProcess_s preProcess;
|
||||
jpegData_s jpeg;
|
||||
asicData_s asic;
|
||||
inputLineBuf_s inputLineBuf;
|
||||
const void *inst; /* used as checksum */
|
||||
void *pAppData; /* Pointer to application data. */
|
||||
} jpegInstance_s;
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ENC_JPEG_MARKERS_H__
|
||||
#define __ENC_JPEG_MARKERS_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* JPEG markers, table B.1 page 32 */
|
||||
|
||||
enum
|
||||
{
|
||||
SOI = 0xFFD8, /* Start of Image */
|
||||
DQT = 0xFFDB, /* Define Quantization Table(s) */
|
||||
SOF0 = 0xFFC0, /* Start of Frame */
|
||||
DRI = 0xFFDD, /* Define Restart Interval */
|
||||
RST0 = 0xFFD0, /* Restart marker 0 */
|
||||
RST1 = 0xFFD1, /* Restart marker 1 */
|
||||
RST2 = 0xFFD2, /* Restart marker 2 */
|
||||
RST3 = 0xFFD3, /* Restart marker 3 */
|
||||
RST4 = 0xFFD4, /* Restart marker 4 */
|
||||
RST5 = 0xFFD5, /* Restart marker 5 */
|
||||
RST6 = 0xFFD6, /* Restart marker 6 */
|
||||
RST7 = 0xFFD7, /* Restart marker 7 */
|
||||
DHT = 0xFFC4, /* Define Huffman Table(s) */
|
||||
SOS = 0xFFDA, /* Start of Scan */
|
||||
EOI = 0xFFD9, /* End of Image */
|
||||
APP0 = 0xFFE0, /* APP0 Marker */
|
||||
COM = 0xFFFE /* Comment marker */
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. External compiler flags
|
||||
3. Module defines
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __ENC_JPEG_PUT_BITS_H__
|
||||
#define __ENC_JPEG_PUT_BITS_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
#include "enccommon.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
void EncJpegPutBits(stream_s *, u32, u32);
|
||||
void EncJpegByteAligned(stream_s * stream);
|
||||
void EncJpegHeaderPutBits(stream_s *, u32, u32);
|
||||
void EncJpegNextByteAligned(stream_s * stream);
|
||||
bool_e EncJpegBufferStatus(stream_s * stream);
|
||||
bool_e EncJpegSetBuffer(stream_s * buffer, u8 * stream, u32 size);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,251 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract :
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
|
||||
Table of contents
|
||||
|
||||
1. Include headers
|
||||
2. Module defines
|
||||
3. Data types
|
||||
4. Function prototypes
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef __QUANT_TABLES_H__
|
||||
#define __QUANT_TABLES_H__
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
3. Data types
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
/* Quantization tables for luminance, levels 0-10 */
|
||||
static const u8 QuantLuminance[11][64] = {
|
||||
|
||||
{80, 56, 50, 80, 120, 200, 248, 248,
|
||||
60, 60, 72, 96, 136, 248, 248, 248,
|
||||
72, 68, 80, 120, 200, 248, 248, 248,
|
||||
72, 88, 112, 152, 248, 248, 248, 248,
|
||||
92, 112, 192, 248, 248, 248, 248, 248,
|
||||
120, 176, 248, 248, 248, 248, 248, 248,
|
||||
152, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248},
|
||||
|
||||
{40, 28, 25, 40, 60, 100, 128, 160,
|
||||
30, 30, 36, 48, 68, 152, 152, 144,
|
||||
36, 34, 40, 60, 100, 144, 176, 144,
|
||||
36, 44, 56, 76, 128, 224, 200, 160,
|
||||
46, 56, 96, 144, 176, 248, 248, 200,
|
||||
60, 88, 144, 160, 208, 248, 248, 232,
|
||||
124, 160, 200, 224, 248, 248, 248, 248,
|
||||
184, 232, 240, 248, 248, 248, 248, 248},
|
||||
|
||||
{27, 18, 17, 27, 40, 68, 88, 104,
|
||||
20, 20, 23, 32, 44, 96, 100, 92,
|
||||
23, 22, 27, 40, 68, 96, 116, 96,
|
||||
23, 28, 38, 48, 88, 144, 136, 104,
|
||||
30, 38, 62, 96, 116, 184, 176, 128,
|
||||
40, 58, 92, 108, 136, 176, 192, 160,
|
||||
84, 108, 136, 144, 176, 208, 200, 168,
|
||||
120, 160, 160, 168, 192, 168, 176, 168},
|
||||
|
||||
{20, 14, 13, 20, 30, 50, 64, 76,
|
||||
15, 15, 18, 24, 34, 76, 76, 72,
|
||||
18, 16, 20, 30, 50, 72, 88, 72,
|
||||
18, 21, 28, 36, 64, 112, 100, 80,
|
||||
23, 28, 46, 72, 88, 136, 136, 96,
|
||||
30, 44, 72, 80, 104, 136, 144, 116,
|
||||
62, 80, 100, 112, 136, 152, 152, 128,
|
||||
92, 116, 120, 124, 144, 128, 136, 124},
|
||||
|
||||
{16, 11, 10, 16, 24, 40, 52, 62,
|
||||
12, 12, 14, 19, 26, 58, 60, 56,
|
||||
14, 13, 16, 24, 40, 58, 72, 56,
|
||||
14, 17, 22, 29, 52, 88, 80, 62,
|
||||
18, 22, 38, 56, 68, 112, 104, 80,
|
||||
24, 36, 56, 64, 84, 104, 116, 92,
|
||||
50, 64, 80, 88, 104, 124, 120, 104,
|
||||
72, 92, 96, 100, 124, 100, 104, 100},
|
||||
|
||||
{13, 9, 8, 13, 19, 32, 42, 50,
|
||||
10, 10, 11, 15, 21, 46, 48, 44,
|
||||
11, 10, 13, 19, 32, 46, 56, 46,
|
||||
11, 14, 18, 23, 42, 72, 64, 50,
|
||||
14, 18, 30, 46, 54, 88, 84, 62,
|
||||
19, 28, 44, 52, 68, 84, 92, 76,
|
||||
40, 52, 62, 72, 84, 100, 96, 84,
|
||||
58, 76, 76, 80, 100, 80, 84, 80},
|
||||
|
||||
{10, 7, 6, 10, 14, 24, 31, 38,
|
||||
7, 7, 8, 11, 16, 36, 36, 34,
|
||||
8, 8, 10, 14, 24, 34, 42, 34,
|
||||
8, 10, 13, 17, 32, 52, 48, 38,
|
||||
11, 13, 22, 34, 42, 68, 62, 46,
|
||||
14, 21, 34, 38, 50, 62, 68, 56,
|
||||
29, 38, 48, 52, 62, 76, 72, 62,
|
||||
44, 56, 58, 60, 68, 60, 62, 60},
|
||||
|
||||
{ 6, 4, 4, 6, 10, 16, 20, 24,
|
||||
5, 5, 6, 8, 10, 23, 24, 22,
|
||||
6, 5, 6, 10, 16, 23, 28, 22,
|
||||
6, 7, 9, 12, 20, 36, 32, 25,
|
||||
7, 9, 15, 22, 27, 44, 42, 31,
|
||||
10, 14, 22, 26, 32, 42, 46, 38,
|
||||
20, 26, 31, 36, 42, 48, 48, 40,
|
||||
29, 38, 38, 40, 46, 40, 42, 40},
|
||||
|
||||
{ 3, 2, 2, 3, 5, 8, 10, 12,
|
||||
2, 2, 3, 4, 5, 12, 12, 11,
|
||||
3, 3, 3, 5, 8, 11, 14, 11,
|
||||
3, 3, 4, 6, 10, 17, 16, 12,
|
||||
4, 4, 7, 11, 14, 22, 21, 15,
|
||||
5, 7, 11, 13, 16, 21, 23, 18,
|
||||
10, 13, 16, 17, 21, 24, 24, 20,
|
||||
14, 18, 19, 20, 22, 20, 21, 20},
|
||||
|
||||
{ 1, 1, 1, 1, 2, 3, 3, 4,
|
||||
1, 1, 1, 1, 2, 4, 4, 4,
|
||||
1, 1, 1, 2, 3, 4, 5, 4,
|
||||
1, 1, 1, 2, 3, 6, 5, 4,
|
||||
1, 1, 2, 4, 5, 7, 7, 5,
|
||||
2, 2, 4, 4, 5, 7, 8, 6,
|
||||
3, 4, 5, 6, 7, 8, 8, 7,
|
||||
5, 6, 6, 7, 7, 7, 7, 7},
|
||||
|
||||
{1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1}
|
||||
};
|
||||
|
||||
/* Quantization tables for chrominance, levels 0-10 */
|
||||
static const u8 QuantChrominance[11][64] = {
|
||||
{88, 92, 120, 240, 248, 248, 248, 248,
|
||||
92, 108, 136, 248, 248, 248, 248, 248,
|
||||
120, 136, 248, 248, 248, 248, 248, 248,
|
||||
240, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248},
|
||||
|
||||
{44, 46, 60, 120, 248, 248, 248, 248,
|
||||
46, 54, 68, 168, 248, 248, 248, 248,
|
||||
60, 66, 144, 248, 248, 248, 248, 248,
|
||||
120, 168, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248,
|
||||
248, 248, 248, 248, 248, 248, 248, 248},
|
||||
|
||||
{28, 30, 40, 80, 168, 168, 168, 168,
|
||||
30, 36, 44, 112, 168, 168, 168, 168,
|
||||
40, 44, 96, 168, 168, 168, 168, 168,
|
||||
80, 112, 168, 168, 168, 168, 168, 168,
|
||||
168, 168, 168, 168, 168, 168, 168, 168,
|
||||
168, 168, 168, 168, 168, 168, 168, 168,
|
||||
168, 168, 168, 168, 168, 168, 168, 168,
|
||||
168, 168, 168, 168, 168, 168, 168, 168},
|
||||
|
||||
{21, 23, 30, 60, 124, 124, 124, 124,
|
||||
23, 26, 34, 84, 124, 124, 124, 124,
|
||||
30, 34, 72, 124, 124, 124, 124, 124,
|
||||
60, 84, 124, 124, 124, 124, 124, 124,
|
||||
124, 124, 124, 124, 124, 124, 124, 124,
|
||||
124, 124, 124, 124, 124, 124, 124, 124,
|
||||
124, 124, 124, 124, 124, 124, 124, 124,
|
||||
124, 124, 124, 124, 124, 124, 124, 124},
|
||||
|
||||
{17, 18, 24, 48, 100, 100, 100, 100,
|
||||
18, 21, 26, 68, 100, 100, 100, 100,
|
||||
24, 26, 56, 100, 100, 100, 100, 100,
|
||||
48, 68, 100, 100, 100, 100, 100, 100,
|
||||
100, 100, 100, 100, 100, 100, 100, 100,
|
||||
100, 100, 100, 100, 100, 100, 100, 100,
|
||||
100, 100, 100, 100, 100, 100, 100, 100,
|
||||
100, 100, 100, 100, 100, 100, 100, 100},
|
||||
|
||||
{14, 14, 19, 38, 80, 80, 80, 80,
|
||||
14, 17, 21, 54, 80, 80, 80, 80,
|
||||
19, 21, 46, 80, 80, 80, 80, 80,
|
||||
38, 54, 80, 80, 80, 80, 80, 80,
|
||||
80, 80, 80, 80, 80, 80, 80, 80,
|
||||
80, 80, 80, 80, 80, 80, 80, 80,
|
||||
80, 80, 80, 80, 80, 80, 80, 80,
|
||||
80, 80, 80, 80, 80, 80, 80, 80},
|
||||
|
||||
{10, 11, 14, 28, 60, 60, 60, 60,
|
||||
11, 13, 16, 40, 60, 60, 60, 60,
|
||||
14, 16, 34, 60, 60, 60, 60, 60,
|
||||
28, 40, 60, 60, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 60, 60, 60,
|
||||
60, 60, 60, 60, 60, 60, 60, 60},
|
||||
|
||||
{ 7, 7, 10, 19, 40, 40, 40, 40,
|
||||
7, 8, 10, 26, 40, 40, 40, 40,
|
||||
10, 10, 22, 40, 40, 40, 40, 40,
|
||||
19, 26, 40, 40, 40, 40, 40, 40,
|
||||
40, 40, 40, 40, 40, 40, 40, 40,
|
||||
40, 40, 40, 40, 40, 40, 40, 40,
|
||||
40, 40, 40, 40, 40, 40, 40, 40,
|
||||
40, 40, 40, 40, 40, 40, 40, 40},
|
||||
|
||||
{ 3, 4, 5, 9, 20, 20, 20, 20,
|
||||
4, 4, 5, 13, 20, 20, 20, 20,
|
||||
5, 5, 11, 20, 20, 20, 20, 20,
|
||||
9, 13, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20},
|
||||
|
||||
{ 1, 1, 2, 3, 7, 7, 7, 7,
|
||||
1, 1, 2, 4, 7, 7, 7, 7,
|
||||
2, 2, 4, 7, 7, 7, 7, 7,
|
||||
3, 4, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7},
|
||||
|
||||
{1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1}
|
||||
};
|
||||
|
||||
#endif /* #ifndef __QUANT_TABLES_H__ */
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : Command line parameter parsing
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ENC_GET_OPTION
|
||||
#define ENC_GET_OPTION
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
1. Include headers
|
||||
------------------------------------------------------------------------------*/
|
||||
#include "basetype.h"
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
2. External compiler flags
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
char *longOpt;
|
||||
char shortOpt;
|
||||
i32 enableArg;
|
||||
} option_s;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
i32 optCnt;
|
||||
char *optArg;
|
||||
char shortOpt;
|
||||
char *longOpt;
|
||||
i32 enableArg;
|
||||
} argument_s;
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
4. Function prototypes
|
||||
------------------------------------------------------------------------------*/
|
||||
i32 EncGetOption(i32 argc, char **argv, option_s *, argument_s *);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/*------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- This software is confidential and proprietary and may be used --
|
||||
-- only as expressly authorized by a licensing agreement from --
|
||||
-- --
|
||||
-- Hantro Products Oy. --
|
||||
-- --
|
||||
-- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
|
||||
-- ALL RIGHTS RESERVED --
|
||||
-- --
|
||||
-- The entire notice above must be reproduced --
|
||||
-- on all copies and should not be removed. --
|
||||
-- --
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- Abstract : H264 Encoder testbench for linux
|
||||
--
|
||||
------------------------------------------------------------------------------*/
|
||||
#ifndef _H264TESTBENCH_H_
|
||||
#define _H264TESTBENCH_H_
|
||||
|
||||
#include "basetype.h"
|
||||
#include "h264encapi.h"
|
||||
|
||||
/*--------------------------------------------------------------------------------
|
||||
3. Module defines
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
#define DEFAULT -255
|
||||
#define MAX_BPS_ADJUST 20
|
||||
|
||||
/* Structure for command line options */
|
||||
typedef struct
|
||||
{
|
||||
u8 *input;
|
||||
i32 inputLen;
|
||||
u8 *inputMvc;
|
||||
i32 inputMvcLen;
|
||||
u8 *output;
|
||||
u8 *userData;
|
||||
i32 userDataLen;
|
||||
i32 firstPic;
|
||||
i32 lastPic;
|
||||
i32 width;
|
||||
i32 height;
|
||||
i32 lumWidthSrc;
|
||||
i32 lumHeightSrc;
|
||||
i32 horOffsetSrc;
|
||||
i32 verOffsetSrc;
|
||||
i32 outputRateNumer;
|
||||
i32 outputRateDenom;
|
||||
i32 inputRateNumer;
|
||||
i32 inputRateDenom;
|
||||
i32 refFrameAmount;
|
||||
i32 level;
|
||||
i32 hrdConformance;
|
||||
i32 cpbSize;
|
||||
i32 intraPicRate;
|
||||
i32 longTermPicRate;
|
||||
i32 constIntraPred;
|
||||
i32 disableDeblocking;
|
||||
i32 mbRowPerSlice;
|
||||
i32 qpHdr;
|
||||
i32 qpMin;
|
||||
i32 qpMax;
|
||||
i32 bitPerSecond;
|
||||
i32 picRc;
|
||||
i32 mbRc;
|
||||
i32 picSkip;
|
||||
i32 rotation;
|
||||
i32 inputFormat;
|
||||
i32 colorConversion;
|
||||
i32 videoBufferSize;
|
||||
i32 videoRange;
|
||||
i32 chromaQpOffset;
|
||||
i32 filterOffsetA;
|
||||
i32 filterOffsetB;
|
||||
i32 trans8x8;
|
||||
i32 enableCabac;
|
||||
i32 cabacInitIdc;
|
||||
i32 testId;
|
||||
i32 burst;
|
||||
i32 bursttype;
|
||||
i32 quarterPixelMv;
|
||||
i32 sei;
|
||||
i32 idrHdr;
|
||||
i32 byteStream;
|
||||
i32 videoStab;
|
||||
i32 gopLength;
|
||||
i32 intraQpDelta;
|
||||
i32 fixedIntraQp;
|
||||
i32 mbQpAdjustment;
|
||||
i32 mbQpAutoBoost;
|
||||
i32 testParam;
|
||||
i32 mvOutput;
|
||||
i32 mvPredictor;
|
||||
i32 cirStart;
|
||||
i32 cirInterval;
|
||||
i32 intraSliceMap1;
|
||||
i32 intraSliceMap2;
|
||||
i32 intraSliceMap3;
|
||||
i32 intraAreaEnable;
|
||||
i32 intraAreaTop;
|
||||
i32 intraAreaLeft;
|
||||
i32 intraAreaBottom;
|
||||
i32 intraAreaRight;
|
||||
i32 roi1AreaEnable;
|
||||
i32 roi2AreaEnable;
|
||||
i32 roi1AreaTop;
|
||||
i32 roi1AreaLeft;
|
||||
i32 roi1AreaBottom;
|
||||
i32 roi1AreaRight;
|
||||
i32 roi2AreaTop;
|
||||
i32 roi2AreaLeft;
|
||||
i32 roi2AreaBottom;
|
||||
i32 roi2AreaRight;
|
||||
i32 roi1DeltaQp;
|
||||
i32 roi2DeltaQp;
|
||||
i32 adaptiveRoiMotion;
|
||||
i32 adaptiveRoiColor;
|
||||
i32 adaptiveRoi;
|
||||
i32 viewMode;
|
||||
i32 psnr;
|
||||
i32 traceRecon;
|
||||
i32 scaledWidth;
|
||||
i32 scaledHeight;
|
||||
i32 interlacedFrame;
|
||||
i32 fieldOrder;
|
||||
i32 enableRfc;
|
||||
i32 rfcLumBufLimit;
|
||||
i32 rfcChrBufLimit;
|
||||
i32 bpsAdjustFrame[MAX_BPS_ADJUST];
|
||||
i32 bpsAdjustBitrate[MAX_BPS_ADJUST];
|
||||
i32 gdrDuration;
|
||||
i32 roiMapEnable;
|
||||
i32 qpOffset[3];
|
||||
u8 *roiMapIndexBuf;
|
||||
i32 roiMapIndexBufLen;
|
||||
i32 inputLineBufMode;
|
||||
i32 inputLineBufDepth;
|
||||
} commandLine_s;
|
||||
|
||||
/* struct for input mb line buffer */
|
||||
typedef struct
|
||||
{
|
||||
u8 *lumSrc;
|
||||
u8 *cbSrc;
|
||||
u8 *crSrc;
|
||||
|
||||
u8 *buf;
|
||||
u32 *reg;
|
||||
u8 *lumBuf;
|
||||
u8 *cbBuf;
|
||||
u8 *crBuf;
|
||||
|
||||
u32 inputFormat; /* format of input video */
|
||||
u32 pixOnRow; /* pixels in one line */
|
||||
u32 encWidth;
|
||||
u32 encHeight;
|
||||
|
||||
i32 wrCnt;
|
||||
u32 depth; /* number of MB_row lines in the input line buffer */
|
||||
u32 loopBackEn;
|
||||
u32 hwHandShake;
|
||||
|
||||
void *inst;
|
||||
}inputLineBufferCfg;
|
||||
|
||||
void TestNaluSizes(i32 * pNaluSizes, u8 * stream, u32 strmSize, u32 picBytes);
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,370 @@
|
|||
/*!
|
||||
* \mainpage rtstream API reference
|
||||
*
|
||||
* \section Introduction
|
||||
*
|
||||
* rtstream is a library that helps you to develop your multimedia application using realtek's soc camera
|
||||
*
|
||||
* \section features
|
||||
*
|
||||
* 1.a stream represent a video or an audio
|
||||
*
|
||||
* 2.a stream will contain several units
|
||||
*
|
||||
* 3.a unit represent a device or an encoder
|
||||
*
|
||||
* \section start
|
||||
*
|
||||
* Some example programs can be found in the examples subdirectory
|
||||
*
|
||||
* \example example_isp_stream.c
|
||||
* \example example_h264_stream.c
|
||||
* \example example_mjpeg_stream.c
|
||||
* \example example_isp_ctrl.c
|
||||
* \example example_osd.c
|
||||
* \example example_md.c
|
||||
* \example example_mask.c
|
||||
* \example example_audio_capture_stream.c
|
||||
* \example example_audio_playback_stream.c
|
||||
* \example example_audio_ctrl.c
|
||||
* \example example_custom_unit.c
|
||||
*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* inc/rtsavapi.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*
|
||||
*/
|
||||
#ifndef _INC_RTSAVAPI_H
|
||||
#define _INC_RTSAVAPI_H
|
||||
|
||||
#include <rtstream.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define rts_av_fourcc(a, b, c, d)\
|
||||
((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c)<<16) | ((uint32_t)(d)<<24))
|
||||
|
||||
/*!
|
||||
* new a rts_av_buffer object
|
||||
*
|
||||
* length : > 0, will alloc memory and assign the address to vm_addr
|
||||
* = 0, will not alloc memory
|
||||
*
|
||||
* @return the pointer of the buffer when success, or NULL when fail
|
||||
*/
|
||||
struct rts_av_buffer *rts_av_new_buffer(uint32_t length);
|
||||
|
||||
/*!
|
||||
* delete a rts_av_buffer object
|
||||
*/
|
||||
int rts_av_delete_buffer(struct rts_av_buffer *buffer);
|
||||
|
||||
/*!
|
||||
* get the reference count for buffer
|
||||
*/
|
||||
unsigned int rts_av_get_buffer_refs(struct rts_av_buffer *buffer);
|
||||
|
||||
enum rts_av_ability_type {
|
||||
rts_av_ability_undefined = 0,
|
||||
rts_av_ability_v4l2,
|
||||
rts_av_ability_isp,
|
||||
rts_av_ability_reserved
|
||||
};
|
||||
|
||||
enum rts_v4l2_frmsizetypes {
|
||||
RTS_V4L2_FRMSIZE_TYPE_DISCRETE = 1,
|
||||
RTS_V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
|
||||
RTS_V4L2_FRMSIZE_TYPE_STEPWISE = 3
|
||||
};
|
||||
|
||||
enum rts_v4l2_frmivaltypes {
|
||||
RTS_V4L2_FRMIVAL_TYPE_DISCRETE = 1,
|
||||
RTS_V4L2_FRMIVAL_TYPE_CONTINUOUS = 2,
|
||||
RTS_V4L2_FRMIVAL_TYPE_STEPWISE = 3
|
||||
};
|
||||
|
||||
struct rts_fract {
|
||||
uint32_t numerator;
|
||||
uint32_t denominator;
|
||||
};
|
||||
|
||||
struct rts_v4l2_frmival_stepwise {
|
||||
struct rts_fract min;
|
||||
struct rts_fract max;
|
||||
struct rts_fract step;
|
||||
};
|
||||
|
||||
struct rts_v4l2_resolution_discrets {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
struct rts_v4l2_resolution_stepwise {
|
||||
uint32_t min_width;
|
||||
uint32_t max_width;
|
||||
uint32_t step_width;
|
||||
uint32_t min_height;
|
||||
uint32_t max_height;
|
||||
uint32_t step_height;
|
||||
};
|
||||
|
||||
struct rts_v4l2_frmival {
|
||||
uint32_t type;
|
||||
union {
|
||||
struct rts_fract discrete;
|
||||
struct rts_v4l2_frmival_stepwise stepwise;
|
||||
};
|
||||
};
|
||||
|
||||
struct rts_v4l2_resolution {
|
||||
uint32_t type;
|
||||
union {
|
||||
struct rts_v4l2_resolution_discrets discrete;
|
||||
struct rts_v4l2_resolution_stepwise stepwise;
|
||||
};
|
||||
int number;
|
||||
struct rts_v4l2_frmival *pfrmivals;
|
||||
};
|
||||
|
||||
struct rts_v4l2_format {
|
||||
uint32_t format;
|
||||
int number;
|
||||
struct rts_v4l2_resolution *presolutions;
|
||||
};
|
||||
|
||||
struct rts_v4l2_ability {
|
||||
int number;
|
||||
struct rts_v4l2_format *pformats;
|
||||
};
|
||||
|
||||
struct rts_isp_ability {
|
||||
int fmt_number;
|
||||
uint32_t *pformats;
|
||||
struct rts_v4l2_resolution_stepwise resolution;
|
||||
int frmival_num;
|
||||
struct rts_fract *pfrmivals;
|
||||
};
|
||||
|
||||
struct rts_av_ability_t {
|
||||
uint32_t type;
|
||||
union {
|
||||
struct rts_v4l2_ability v4l2_ability;
|
||||
struct rts_isp_ability isp_ability;
|
||||
};
|
||||
};
|
||||
|
||||
struct rts_av_unit;
|
||||
|
||||
/*!
|
||||
* new a rts_av_unit object
|
||||
*
|
||||
* unitid
|
||||
*
|
||||
* @return the pointer of the unit : success, NULL : fail
|
||||
*/
|
||||
struct rts_av_unit *rts_av_new_unit(unsigned int unitid);
|
||||
|
||||
/*!
|
||||
* new a rts_av_unit object
|
||||
*
|
||||
* unitid
|
||||
* arg
|
||||
*
|
||||
* @return the pointer of the unit : success, NULL : fail
|
||||
*/
|
||||
struct rts_av_unit *rts_av_new_unit_ex(unsigned int unitid, void *arg);
|
||||
|
||||
/*!
|
||||
* delete the rts_av_unit object
|
||||
*
|
||||
*/
|
||||
int rts_av_delete_unit(struct rts_av_unit *unit);
|
||||
|
||||
/*!
|
||||
* get unit id
|
||||
*
|
||||
*/
|
||||
int rts_av_get_unit_id(struct rts_av_unit *unit, unsigned int *id);
|
||||
|
||||
/*!
|
||||
* get unit type
|
||||
*
|
||||
*/
|
||||
int rts_av_get_unit_type(struct rts_av_unit *unit);
|
||||
|
||||
/*!
|
||||
* set unit attribute, should call before rts_av_apply
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_set_attr(struct rts_av_unit *unit, void *attr);
|
||||
|
||||
/*!
|
||||
* get unit attibute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_get_attr(struct rts_av_unit *unit, void *attr);
|
||||
|
||||
/*!
|
||||
* get unit ability
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, call rts_av_release_ability to release it.
|
||||
*/
|
||||
int rts_av_query_ability(struct rts_av_unit *unit,
|
||||
struct rts_av_ability_t **ability);
|
||||
|
||||
/*!
|
||||
* relesee ability after query_ability
|
||||
*
|
||||
*/
|
||||
void rts_av_release_ability(struct rts_av_ability_t *ability);
|
||||
|
||||
/*!
|
||||
* get unit output profile
|
||||
* unit type : source or filter
|
||||
*
|
||||
* @return 0 : success, minus : fail.
|
||||
* */
|
||||
int rts_av_get_profile(struct rts_av_unit *unit,
|
||||
struct rts_av_profile *profile);
|
||||
|
||||
/*!
|
||||
* set unit intput profile
|
||||
* unit type : sink or filter
|
||||
*
|
||||
* @return 0 : success, minus : fail.
|
||||
* */
|
||||
int rts_av_set_profile(struct rts_av_unit *unit,
|
||||
struct rts_av_profile *profile);
|
||||
|
||||
/*!
|
||||
* new a stream object
|
||||
*
|
||||
*/
|
||||
RtStream rts_av_new_stream();
|
||||
|
||||
/*!
|
||||
* delete a stream object
|
||||
*
|
||||
*/
|
||||
int rts_av_delete_stream(RtStream stream);
|
||||
|
||||
/*!
|
||||
* add a unit to stream
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_add_tail(RtStream stream, struct rts_av_unit *unit);
|
||||
/*!
|
||||
* rm a unit from stream
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_del(RtStream stream, struct rts_av_unit *unit);
|
||||
|
||||
/*!
|
||||
* insert a unit to stream before the pos unit
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_insert(RtStream stream,
|
||||
struct rts_av_unit *unit, struct rts_av_unit *pos);
|
||||
/*!
|
||||
* insert a unit to stream at index
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_insert_at(RtStream stream,
|
||||
struct rts_av_unit *unit, int index);
|
||||
/*!
|
||||
* swap two unit in stream
|
||||
*
|
||||
*/
|
||||
int rts_av_stream_swap(RtStream stream,
|
||||
struct rts_av_unit *unita, struct rts_av_unit *unitb);
|
||||
|
||||
/*!
|
||||
* send data to the stream
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_send(RtStream stream, struct rts_av_buffer *pbuf);
|
||||
|
||||
/*!
|
||||
* rts_av_stream_get_item: get unit from stream
|
||||
*
|
||||
* unit : NULL : get the first unit.
|
||||
* other : get next of it
|
||||
*
|
||||
* @return the pointer of the unit when success, or NULL when fail
|
||||
*/
|
||||
struct rts_av_unit *rts_av_stream_get_item(RtStream stream,
|
||||
struct rts_av_unit *unit);
|
||||
|
||||
#define RTS_AV_ID_V4L2 rts_av_fourcc('v','4','l','2')
|
||||
#define RTS_AV_ID_ISP rts_av_fourcc('i','s','p', 0)
|
||||
#define RTS_AV_ID_H264 rts_av_fourcc('h','2','6','4')
|
||||
#define RTS_AV_ID_MJPGENC rts_av_fourcc('m','j','p','g')
|
||||
#define RTS_AV_ID_AUDIO_PLAYBACK rts_av_fourcc('a','u','p','l')
|
||||
#define RTS_AV_ID_AUDIO_CAPTURE rts_av_fourcc('a','u','c','a')
|
||||
#define RTS_AV_ID_AUDIO_MIXER rts_av_fourcc('a','m','i','x')
|
||||
#define RTS_AV_ID_AUDIO_PLAYBACK_AEC rts_av_fourcc('a','p','l','a')
|
||||
#define RTS_AV_ID_AUDIO_CAPTURE_AEC rts_av_fourcc('a','c','a','a')
|
||||
#define RTS_AV_ID_AUDIO_ENCODE rts_av_fourcc('a','e','n','c')
|
||||
|
||||
struct rts_v4l2_attr {
|
||||
uint32_t pixelformat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t numerator;
|
||||
uint32_t denominator;
|
||||
int v4l2_buf_num;
|
||||
char dev_node[64]; /*it will only be used in get attr*/
|
||||
};
|
||||
|
||||
struct rts_isp_attr {
|
||||
uint32_t pixelformat;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t numerator;
|
||||
uint32_t denominator;
|
||||
int isp_buf_num;
|
||||
int isp_id; /*it will only be used in get attr*/
|
||||
};
|
||||
|
||||
struct rts_h264_attr {
|
||||
enum rts_h264_profile profile;
|
||||
enum rts_h264_level level;
|
||||
|
||||
int qp;
|
||||
unsigned int bps;
|
||||
unsigned int gop;
|
||||
enum rts_av_rotation rotation;
|
||||
int videostab;
|
||||
};
|
||||
|
||||
struct rts_jpgenc_attr {
|
||||
enum rts_av_rotation rotation;
|
||||
};
|
||||
|
||||
struct rts_audio_attr {
|
||||
char dev_node[64];
|
||||
uint32_t format;
|
||||
uint32_t channels;
|
||||
uint32_t rate;
|
||||
|
||||
unsigned long period_frames;
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* inc/rtsavdef.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INC_RTSAVDEF_H
|
||||
#define _INC_RTSAVDEF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define RTS_AV_FMT_AUDIO 0x80
|
||||
enum RTS_AV_FMT {
|
||||
rts_av_fmt_undefined = 0x0,
|
||||
rts_v_fmt_yuyv = 0x1,
|
||||
rts_v_fmt_yuv420planar,
|
||||
rts_v_fmt_yuv420semiplanar, //V4L2_PIX_FMT_NV12
|
||||
rts_v_fmt_yuv422semiplanar,
|
||||
rts_v_fmt_mjpeg,
|
||||
rts_v_fmt_h264,
|
||||
|
||||
rts_a_fmt_audio = RTS_AV_FMT_AUDIO | 0x1,
|
||||
};
|
||||
|
||||
enum rts_av_rotation {
|
||||
rts_av_rotation_0 = 0,
|
||||
rts_av_rotation_90r = 1,
|
||||
rts_av_rotation_90l = 2,
|
||||
rts_av_rotation_180 = 3
|
||||
};
|
||||
|
||||
/*!
|
||||
* convert v4l2 pixelformat to rts_av_fmt
|
||||
*/
|
||||
enum RTS_AV_FMT rts_get_av_fmt_from_v4l2_fmt(uint32_t pixelformat);
|
||||
|
||||
/*!
|
||||
* convert rts_av_fmt to v4l2 pixelformat
|
||||
*/
|
||||
uint32_t rts_get_v4l2_fmt_from_av_fmt(enum RTS_AV_FMT fmt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsfw.h
|
||||
*
|
||||
* Copyright (C) 2016 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSFW_H
|
||||
#define _INCLUDE_RTSFW_H
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* rts_upload_fw
|
||||
*
|
||||
* length : fw length
|
||||
*
|
||||
* fw : point to fw data
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* */
|
||||
int rts_upload_fw(unsigned int length, uint8_t *fw);
|
||||
|
||||
/*!
|
||||
* rts_get_fw_size
|
||||
*
|
||||
* @return positive : size, minus : fail
|
||||
* */
|
||||
int rts_get_fw_size();
|
||||
|
||||
/*!
|
||||
* rts_dump_fw
|
||||
*
|
||||
* length : fw length
|
||||
*
|
||||
* fw : point to fw data
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* */
|
||||
int rts_dump_fw(unsigned int length, uint8_t *fw);
|
||||
|
||||
/*!
|
||||
* rts_load_fw
|
||||
*
|
||||
* @return 0
|
||||
* */
|
||||
int rts_load_fw();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,460 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsisp.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSISP_H
|
||||
#define _INCLUDE_RTSISP_H
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <rtscamkit.h>
|
||||
#include <rtsisp_def.h>
|
||||
|
||||
#define RTS_ISP_CMD_DATA_LIMIT 32
|
||||
|
||||
enum rts_isp_raw_fmt {
|
||||
rts_isp_raw_diable = 0,
|
||||
rts_isp_raw_blc_b = 0x1,
|
||||
rts_isp_raw_blc_a = 0x2,
|
||||
rts_isp_raw_lsc_a = 0x3,
|
||||
rts_isp_raw_dns_a = 0x4,
|
||||
rts_isp_raw_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_mem_rw {
|
||||
uint16_t addr;
|
||||
uint16_t length;
|
||||
uint8_t *pdata;
|
||||
};
|
||||
|
||||
enum rts_isp_i2c_mode {
|
||||
rts_isp_i2c_mode_general = 0,
|
||||
rts_isp_i2c_mode_random = 1,
|
||||
rts_isp_i2c_mode_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_i2c_rw {
|
||||
enum rts_isp_i2c_mode mode;
|
||||
uint8_t slave_id;
|
||||
uint8_t len;
|
||||
uint8_t data[8];
|
||||
};
|
||||
|
||||
struct rts_isp_sensor_reg {
|
||||
uint16_t addr;
|
||||
uint8_t len;
|
||||
uint8_t data[32];
|
||||
};
|
||||
|
||||
struct rts_isp_snr_fmt {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
enum {
|
||||
snr_fmt_raw8 = 0,
|
||||
snr_fmt_raw10,
|
||||
snr_fmt_raw12,
|
||||
snr_fmt_yuv,
|
||||
snr_fmt_reserved
|
||||
} fmt;
|
||||
};
|
||||
|
||||
struct rts_isp_scale_coeff {
|
||||
uint32_t scale_h;
|
||||
uint32_t scale_v;
|
||||
};
|
||||
|
||||
struct rts_isp_zoom_start {
|
||||
uint32_t start_x;
|
||||
uint32_t start_y;
|
||||
};
|
||||
|
||||
struct rts_isp_color_yuv {
|
||||
uint8_t y;
|
||||
uint8_t u;
|
||||
uint8_t v;
|
||||
};
|
||||
|
||||
struct rts_isp_grid_t {
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
uint16_t grid_width;
|
||||
uint16_t grid_height;
|
||||
uint8_t grid_rows;
|
||||
uint8_t grid_columns;
|
||||
};
|
||||
|
||||
struct rts_isp_rect_t {
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
int16_t end_x;
|
||||
int16_t end_y;
|
||||
};
|
||||
|
||||
struct rts_isp_grid_bitmap {
|
||||
uint16_t number;
|
||||
uint8_t bitmap[RTS_GRID_BITMAP_SIZE];
|
||||
};
|
||||
|
||||
struct rts_isp_md_data_fmt {
|
||||
enum {
|
||||
blc_output = 0, //raw data
|
||||
mlsc_output = 1, //raw data
|
||||
awb_output = 2, //raw data
|
||||
ccm_input = 4, //rgb data
|
||||
ccm_output = 5, //rgb data
|
||||
gamma_input = 6, //rgb data
|
||||
gamma_output = 7, //rgb data
|
||||
eeh_input = 8, //yuv422 data
|
||||
eeh_output = 9, //yuv422 data
|
||||
rgb2yuv_output = 0xc, //yuv444 data
|
||||
zoom_jpeg_output = 0x10, //yuv422 data
|
||||
zoom_full_hd_output = 0x11, //yuv422 data
|
||||
zoom_hd_output = 0x12, //yuv422 data
|
||||
zoom_vga_output = 0x13, //yuv422 data
|
||||
zoom_qvga_output = 0x14, //yuv422 data
|
||||
} data_format;
|
||||
|
||||
union {
|
||||
enum {
|
||||
raw_gr = 0,
|
||||
raw_r = 1,
|
||||
raw_b = 2,
|
||||
raw_gb = 3
|
||||
} raw_data;
|
||||
enum {
|
||||
rgb_r = 0,
|
||||
rgb_g = 1,
|
||||
rgb_b = 2,
|
||||
rgb_reserved
|
||||
} rgb_data;
|
||||
enum {
|
||||
yuv_y = 0,
|
||||
yuv_u = 1,
|
||||
yuv_v = 2,
|
||||
yuv_reserved
|
||||
} yuv_data;
|
||||
} data_element;
|
||||
};
|
||||
|
||||
struct rts_isp_device_desc {
|
||||
uint8_t length;
|
||||
uint8_t type;
|
||||
uint16_t hwversion;
|
||||
uint16_t fwversion;
|
||||
uint8_t streamnum;
|
||||
uint8_t frmivalnum;
|
||||
};
|
||||
|
||||
struct rts_isp_fw_version_t {
|
||||
uint8_t header;
|
||||
uint8_t len;
|
||||
uint32_t magictag;
|
||||
uint16_t ic_name;
|
||||
uint16_t vid;
|
||||
uint16_t pid;
|
||||
uint32_t fw_ver;
|
||||
uint32_t cus_ver;
|
||||
uint8_t reserved[12];
|
||||
};
|
||||
|
||||
struct rts_isp_dma_buffer {
|
||||
void *vm_addr;
|
||||
uint32_t length;
|
||||
uint32_t phy_addr;
|
||||
};
|
||||
|
||||
struct rts_isp_iq_table_attr {
|
||||
uint8_t version;
|
||||
uint16_t addr;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct rts_isp_3a_version {
|
||||
uint16_t main;
|
||||
uint8_t sub;
|
||||
};
|
||||
|
||||
struct rts_isp_3a_version_t {
|
||||
struct rts_isp_3a_version awb;
|
||||
struct rts_isp_3a_version ae;
|
||||
struct rts_isp_3a_version af;
|
||||
};
|
||||
|
||||
enum rts_isp_wdr_mode {
|
||||
wdr_disable = 0,
|
||||
wdr_manual,
|
||||
wdr_auto_weak,
|
||||
wdr_auto_medium,
|
||||
wdr_auto_strong,
|
||||
wdr_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_api_version {
|
||||
uint8_t main;
|
||||
uint8_t sub;
|
||||
};
|
||||
|
||||
typedef const void *RtsRegInst;
|
||||
|
||||
int rts_isp_read_xmem(int fd, struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_write_xmem(int fd, struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_read_i2c(int fd, struct rts_isp_i2c_rw *pi2c);
|
||||
int rts_isp_write_i2c(int fd, struct rts_isp_i2c_rw *pi2c);
|
||||
int rts_isp_read_sensor_reg(int fd, struct rts_isp_sensor_reg *reg);
|
||||
int rts_isp_write_sensor_reg(int fd, struct rts_isp_sensor_reg *reg);
|
||||
|
||||
int rts_isp_get_md_count(int fd);
|
||||
int rts_isp_get_md_type(int fd, uint8_t mdidx);
|
||||
int rts_isp_set_md_enable(int fd, uint8_t mdidx, int enable);
|
||||
int rts_isp_get_md_enable(int fd, uint8_t mdidx, int *penable);
|
||||
int rts_isp_set_md_data_fmt(int fd, struct rts_isp_md_data_fmt *pfmt);
|
||||
int rts_isp_get_md_data_fmt(int fd, struct rts_isp_md_data_fmt *pfmt);
|
||||
int rts_isp_set_md_grid_bitmap(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_md_grid_bitmap(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_md_result(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_set_md_grid(int fd, unsigned int strmidx, uint8_t mdidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid(int fd, unsigned int strmidx, uint8_t mdidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect(int fd, uint8_t strmidx, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect(int fd, uint8_t strmidx, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_md_grid_absolute(int fd, uint8_t mdidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid_absolute(int fd, uint8_t mdidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect_absolute(int fd, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect_absolute(int fd, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_md_sensitivity(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_sensitivity(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_set_md_percentage(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_percentage(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_set_md_frame_interval(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_frame_interval(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_get_md_status(int fd, uint8_t mdidx);
|
||||
int rts_isp_get_mask_count(int fd);
|
||||
int rts_isp_set_md_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect_res(int fd, uint8_t mdidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect_res(int fd, uint8_t mdidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_type(int fd, uint8_t maskidx);
|
||||
int rts_isp_set_mask_enable(int fd, uint8_t maskidx, int enable);
|
||||
int rts_isp_get_mask_enable(int fd, uint8_t maskidx, int *penable);
|
||||
int rts_isp_set_mask_color(int fd, struct rts_isp_color_yuv *pcolor);
|
||||
int rts_isp_get_mask_color(int fd, struct rts_isp_color_yuv *pcolor);
|
||||
int rts_isp_set_mask_grid_bitmap(int fd, uint8_t maskidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_mask_grid_bitmap(int fd, uint8_t maskidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_set_mask_grid(int fd, unsigned int strmidx, uint8_t maskidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid(int fd, unsigned int strmidx, uint8_t maskidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect(int fd, uint8_t strmidx, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect(int fd, uint8_t strmidx, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_mask_grid_absolute(int fd, uint8_t maskidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid_absolute(int fd, uint8_t maskidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect_absolute(int fd, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect_absolute(int fd, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_mask_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect_res(int fd, uint8_t maskidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect_res(int fd, uint8_t maskidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
|
||||
int rts_isp_get_device_des(int fd, struct rts_isp_device_desc *desc);
|
||||
int rts_isp_get_fw_version(int fd, struct rts_isp_fw_version_t *pversion);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_api_version
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_get_api_version(int fd, struct rts_isp_api_version *pversion);
|
||||
|
||||
int rts_isp_enable_ldc(int fd, uint8_t *ptable, unsigned int length);
|
||||
int rts_isp_disable_ldc(int fd);
|
||||
int rts_isp_get_ldc_state(int fd);
|
||||
|
||||
int rts_isp_enable_temporal_denoise(int fd, int enable);
|
||||
int rts_isp_get_temporal_denoise_state(int fd);
|
||||
|
||||
int rts_isp_set_dehaze(int fd, int enable);
|
||||
int rts_isp_get_dehaze(int fd);
|
||||
|
||||
int rts_isp_get_snr_fmt(int fd, struct rts_isp_snr_fmt *pfmt);
|
||||
int rts_isp_get_scale_coeff(int fd, uint8_t strmidx, struct rts_isp_scale_coeff *pcoeff);
|
||||
int rts_isp_get_zoom_start(int fd, uint8_t strmidx, struct rts_isp_zoom_start *pzoom);
|
||||
|
||||
|
||||
int rts_isp_set_raw(int fd,uint8_t streamid, enum rts_isp_raw_fmt raw_type);
|
||||
|
||||
int rts_isp_get_streamid(int fd);
|
||||
int rts_isp_get_stream_count(void);
|
||||
|
||||
unsigned long rts_isp_get_video_phy_addr(int fd, unsigned long vm_addr);
|
||||
|
||||
int rts_isp_ctrl_open(void);
|
||||
int rts_isp_ctrl_close(int fd);
|
||||
|
||||
int rts_isp_soc_attach(void);
|
||||
int rts_isp_soc_detach(void);
|
||||
|
||||
int rts_isp_mem_open(void);
|
||||
void rts_isp_mem_close(int memfd);
|
||||
int rts_isp_mem_alloc(int memfd, struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_mem_free(int memfd, struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_alloc_dma(struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_free_dma(struct rts_isp_dma_buffer *buffer);
|
||||
|
||||
int rts_reg_close(RtsRegInst reginst);
|
||||
int rts_reg_isp_open(RtsRegInst *reginst);
|
||||
int rts_reg_isp_close(RtsRegInst ispreg);
|
||||
int rts_reg_h264_open(RtsRegInst *reginst);
|
||||
int rts_reg_h264_close(RtsRegInst h264reg);
|
||||
int rts_reg_mjpg_open(RtsRegInst *reginst);
|
||||
int rts_reg_mjpg_close(RtsRegInst mjpgreg);
|
||||
int rts_reg_mjpg_reset(RtsRegInst mjpgreg);
|
||||
uint32_t rts_reg_read_reg(RtsRegInst reginst, unsigned int offset);
|
||||
void rts_reg_write_reg(RtsRegInst reginst,
|
||||
unsigned int offset, uint32_t val);
|
||||
void rts_reg_set_reg_bit(RtsRegInst reginst,
|
||||
unsigned int offset, uint8_t bit_idx);
|
||||
void rts_reg_clr_reg_bit(RtsRegInst reginst,
|
||||
unsigned int offset, uint8_t bit_idx);
|
||||
int rts_reg_get_handle(RtsRegInst reginst);
|
||||
unsigned int rts_reg_get_size(RtsRegInst reginst);
|
||||
|
||||
enum rts_isp_gray_mode {
|
||||
RTS_ISP_NON_GRAY_MODE = 0,
|
||||
RTS_ISP_GRAY_MODE = 1
|
||||
};
|
||||
|
||||
#define RTS_ISP_GPIO_NUM 8
|
||||
enum rts_isp_gpio_status {
|
||||
RTS_ISP_GPIO_IDLE = 0,
|
||||
RTS_ISP_GPIO_USED = 1
|
||||
};
|
||||
|
||||
enum rts_isp_gpio_direction {
|
||||
RTS_ISP_GPIO_INPUT = 0,
|
||||
RTS_ISP_GPIO_OUTPUT = 1
|
||||
};
|
||||
|
||||
enum rts_isp_gpio_value {
|
||||
RTS_ISP_GPIO_LOW = 0,
|
||||
RTS_ISP_GPIO_HIGH = 1
|
||||
};
|
||||
|
||||
int rts_isp_get_gray_mode(int fd, enum rts_isp_gray_mode *gray_mode);
|
||||
int rts_isp_set_gray_mode(int fd, enum rts_isp_gray_mode gray_mode);
|
||||
int rts_isp_get_gpio_use_status(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_status *status);
|
||||
int rts_isp_get_gpio_direction(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_direction *direction);
|
||||
int rts_isp_set_gpio_direction(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_direction direction);
|
||||
int rts_isp_get_gpio_value(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_value *value);
|
||||
int rts_isp_set_gpio_value(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_value value);
|
||||
|
||||
int rts_isp_set_crop_window(int fd, int strmid, struct rts_isp_rect_t *window);
|
||||
int rts_isp_get_iq_table_attr(int fd, struct rts_isp_iq_table_attr *attr);
|
||||
int rts_isp_get_3a_version(int fd, struct rts_isp_3a_version_t *version);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_wdr_mode
|
||||
*
|
||||
* mode : wdr mode
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_wdr_mode(int fd, enum rts_isp_wdr_mode mode);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_wdr_mode
|
||||
*
|
||||
* @return wdr mode, minus : fail
|
||||
*/
|
||||
int rts_isp_get_wdr_mode(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_wdr_level
|
||||
*
|
||||
* level : wdr level, 0 ~ 100, only when wdr mode equals to manual
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_wdr_level(int fd, int level);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_wdr_level
|
||||
*
|
||||
* @return wdr level, minus : fail
|
||||
*/
|
||||
int rts_isp_get_wdr_level(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_tpnr_level
|
||||
*
|
||||
* level : tpnr level, 0 ~ 100
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_tpnr_level(int fd, int level);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_tpnr_level
|
||||
*
|
||||
* @return tpnr level, minus : fail
|
||||
*/
|
||||
int rts_isp_get_tpnr_level(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_ir_mode
|
||||
*
|
||||
* enable 1 : enable IR mode, 0 : disable IR mode
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* */
|
||||
int rts_isp_set_ir_mode(int fd, int enable);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_ir_mode
|
||||
*
|
||||
* @return 0 : disable, 1 : enable, minus : fail
|
||||
* */
|
||||
int rts_isp_get_ir_mode(int fd);
|
||||
|
||||
int rts_isp_get_ae_gain(int fd, struct rts_isp_ae_gain *gain);
|
||||
int rts_isp_set_ae_gain(int fd, struct rts_isp_ae_gain *gain);
|
||||
int rts_isp_get_ae_weight(int fd, struct rts_isp_ae_weight *weight);
|
||||
int rts_isp_set_ae_weight(int fd, struct rts_isp_ae_weight *weight);
|
||||
int rts_isp_get_ae_statis(int fd, struct rts_isp_ae_statis *statis);
|
||||
int rts_isp_get_awb_statis(int fd, struct rts_isp_awb_statis *statis);
|
||||
int rts_isp_get_awb_ct_gain(int fd, int ct, struct rts_isp_awb_ct_gain *gain);
|
||||
int rts_isp_get_ae_target_delta(int fd, int8_t *delta);
|
||||
int rts_isp_set_ae_target_delta(int fd, int8_t delta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsisp_def.h
|
||||
*
|
||||
* Copyright (C) 2016 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSISP_DEF_H
|
||||
#define _INCLUDE_RTSISP_DEF_H
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define RTS_ISP_GRID_MAX_NUM (1200)
|
||||
#define RTS_GRID_BITMAP_SIZE ((RTS_ISP_GRID_MAX_NUM + 7) / 8)
|
||||
|
||||
#define RTS_ISP_AE_WINDOW_NUM 25
|
||||
#define RTS_ISP_AWB_WINDOW_NUM 25
|
||||
|
||||
#define RTS_ISP_AE_GAIN_UNIT 256
|
||||
|
||||
enum rts_isp_blk_type {
|
||||
RTS_ISP_BLK_TYPE_UNDEFINED = 0,
|
||||
RTS_ISP_BLK_TYPE_RECT = 1,
|
||||
RTS_ISP_BLK_TYPE_GRID,
|
||||
};
|
||||
|
||||
enum {
|
||||
RTS_ISP_AE_AUTO = 0,
|
||||
RTS_ISP_AE_MANUAL = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
RTS_ISP_AWB_TEMPERATURE = 0,
|
||||
RTS_ISP_AWB_AUTO = 1,
|
||||
RTS_ISP_AWB_COMPONENT
|
||||
};
|
||||
|
||||
struct rts_isp_ae_gain {
|
||||
uint16_t analog;
|
||||
uint16_t digital;
|
||||
uint16_t isp_digital;
|
||||
};
|
||||
|
||||
struct rts_isp_ae_weight {
|
||||
uint8_t weights[RTS_ISP_AE_WINDOW_NUM];
|
||||
};
|
||||
|
||||
struct rts_isp_ae_statis {
|
||||
uint8_t y_mean;
|
||||
uint8_t y_means[RTS_ISP_AE_WINDOW_NUM];
|
||||
uint16_t statis[64];
|
||||
};
|
||||
|
||||
struct rts_isp_awb_statis {
|
||||
uint8_t r_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
uint8_t g_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
uint8_t b_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
};
|
||||
|
||||
enum rts_isp_color_temperature {
|
||||
RTS_ISP_CT_2800K = 0, /*A*/
|
||||
RTS_ISP_CT_3000K, /*U30*/
|
||||
RTS_ISP_CT_4000K, /*CWF*/
|
||||
RTS_ISP_CT_5000K, /*D50*/
|
||||
RTS_ISP_CT_6500K, /*D65*/
|
||||
RTS_ISP_CT_7500K, /*D75*/
|
||||
RTS_ISP_CT_RESERVED
|
||||
};
|
||||
|
||||
struct rts_isp_awb_ct_gain {
|
||||
uint8_t r_gain;
|
||||
uint8_t b_gain;
|
||||
};
|
||||
|
||||
typedef enum RS_PIXEL_FORMAT_E {
|
||||
|
||||
PIXEL_FORMAT_RGB_1BPP = 0,
|
||||
PIXEL_FORMAT_RGB_1555,
|
||||
} PIXEL_FORMAT_E;
|
||||
|
||||
typedef struct RS_BITMAP_S {
|
||||
PIXEL_FORMAT_E pixel_fmt;
|
||||
uint32_t u32Width;
|
||||
uint32_t u32Height;
|
||||
void *pData;
|
||||
} BITMAP_S;
|
||||
|
||||
enum {
|
||||
RTS_ISP_PWR_FREQUENCY_DISABLED = 0,
|
||||
RTS_ISP_PWR_FREQUENCY_50HZ = 1,
|
||||
RTS_ISP_PWR_FREQUENCY_60HZ = 2,
|
||||
RTS_ISP_PWR_FREQUENCY_AUTO = 3
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* libs/include/rtsosd.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LIBS_INCLUDE_RTSOSD_H
|
||||
#define _LIBS_INCLUDE_RTSOSD_H
|
||||
|
||||
#include <rtscolor.h>
|
||||
#include <rtsisp_def.h>
|
||||
|
||||
#define RTS_OSD_MIN_GAP 2
|
||||
|
||||
enum rts_osd_char_rotation {
|
||||
osd_char_rotation_0 = 0,
|
||||
osd_char_rotation_90 = 1,
|
||||
osd_char_rotation_180 = 2,
|
||||
osd_char_rotation_270 = 3
|
||||
};
|
||||
|
||||
|
||||
enum rts_osd_time_fmt {
|
||||
osd_time_fmt_no = 0, /*not show time*/
|
||||
osd_time_fmt_24,
|
||||
osd_time_fmt_12,
|
||||
osd_time_fmt_12_1,
|
||||
osd_time_fmt_12_2,
|
||||
osd_time_fmt_12_3,
|
||||
osd_time_fmt_12_4,
|
||||
osd_time_fmt_12_5,
|
||||
osd_time_fmt_12_6,
|
||||
osd_time_fmt_12_7,
|
||||
osd_time_fmt_reserved
|
||||
};
|
||||
|
||||
enum rts_osd_date_fmt {
|
||||
osd_date_fmt_no = 0, /*not show date*/
|
||||
osd_date_fmt_0, /*dd/MM/yyyy, eg. 26/05/2015*/
|
||||
osd_date_fmt_1, /*dd/MM/yy, eg. 26/05/15*/
|
||||
osd_date_fmt_2, /*d/M/yy, eg. 26/5/15*/
|
||||
osd_date_fmt_3, /*M/d/yyyy, eg. 5/26/2015*/
|
||||
osd_date_fmt_4, /*M/d/yy, eg. 5/26/15*/
|
||||
osd_date_fmt_5, /*MM/dd/yy, eg. 05/26/15*/
|
||||
osd_date_fmt_6, /*MM/dd/yyyy, eg. 05/26/2015*/
|
||||
osd_date_fmt_7, /*yyyy/M/d, eg. 2015/5/26*/
|
||||
osd_date_fmt_8, /*yyyy-M-d, eg. 2015-5-26*/
|
||||
osd_date_fmt_9, /*yyyy-MM-dd, eg. 2015-05-26*/
|
||||
osd_date_fmt_10, /*yyyy/MM/dd, eg. 2015/05/26*/
|
||||
osd_date_fmt_11, /*yy-MM-dd, eg. 15-05-26*/
|
||||
osd_date_fmt_12, /*yy/M/d, eg. 15/5/26*/
|
||||
osd_date_fmt_13, /*yy-M-d, eg. 15-5-26*/
|
||||
osd_date_fmt_14, /*yy/MM/dd, eg. 15/05/26*/
|
||||
osd_date_fmt_reserved
|
||||
};
|
||||
|
||||
enum osd_char_type {
|
||||
char_type_single = 0,
|
||||
char_type_double = 1,
|
||||
char_type_picture = 2
|
||||
};
|
||||
|
||||
struct rts_osd_char_t {
|
||||
enum osd_char_type char_type;
|
||||
unsigned char char_value[4];
|
||||
};
|
||||
|
||||
struct rts_osd_text_t {
|
||||
struct rts_osd_char_t *content;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
struct rts_osd_datetime_t {
|
||||
enum rts_osd_time_fmt time_fmt;
|
||||
uint8_t time_blkidx;
|
||||
int time_pos;
|
||||
enum rts_osd_date_fmt date_fmt;
|
||||
uint8_t date_blkidx;
|
||||
int date_pos;
|
||||
};
|
||||
|
||||
struct rts_osd_rect_t {
|
||||
uint16_t start_x;
|
||||
uint16_t start_y;
|
||||
uint16_t end_x;
|
||||
uint16_t end_y;
|
||||
};
|
||||
|
||||
struct rts_osd_attr_t {
|
||||
uint8_t h_gap:4;
|
||||
uint8_t v_gap:4;
|
||||
uint8_t bg_enable; /*0 : no show, others : show*/
|
||||
rts_color bg_color;
|
||||
rts_color ch_color;
|
||||
uint8_t flick_enable;
|
||||
uint8_t flick_freq;
|
||||
uint8_t char_color_thd;
|
||||
uint8_t char_color_inc;
|
||||
uint8_t char_color_alpha;
|
||||
uint8_t stroke_enable; /* 1:enable char stroke, 0: disable*/
|
||||
uint8_t stroke_direct; /* 0:minus inc, 1:add inc */
|
||||
uint8_t stroke_inc;
|
||||
};
|
||||
|
||||
struct rts_osd_lib_info {
|
||||
enum osd_char_type char_type;
|
||||
uint16_t char_width;
|
||||
uint16_t char_height;
|
||||
uint8_t font_type;
|
||||
uint8_t font_size;
|
||||
uint8_t coding_fmt;
|
||||
uint8_t char_num;
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
* rts_new_osd : new a realtek osd object
|
||||
*
|
||||
* @fd : device handle, returned by open
|
||||
*
|
||||
* @strmidx : stream index
|
||||
*
|
||||
* return value : the pointer of the osd object when success, or NULL when fail
|
||||
*
|
||||
* */
|
||||
void *rts_new_osd(int fd, uint8_t strmidx);
|
||||
|
||||
/*
|
||||
* rts_delete_osd : delete the osd object
|
||||
*
|
||||
* @p : returned by rts_new_osd
|
||||
*
|
||||
* */
|
||||
void rts_delete_osd(void *p);
|
||||
|
||||
/*
|
||||
* rts_osd_add_font_lib_ram : add lattice from ram
|
||||
*
|
||||
* @p : returned by rts_new_osd
|
||||
*
|
||||
* @addr : lib address location
|
||||
*
|
||||
* return value : the index of font lib when success, or minus when fail
|
||||
*
|
||||
* */
|
||||
int rts_osd_add_font_lib_ram(void *p, unsigned int addr, struct rts_osd_lib_info *pinfo);
|
||||
int rts_osd_rm_font_lib(void *p, int index);
|
||||
|
||||
int rts_osd_show_text(void *p, uint8_t blkidx, struct rts_osd_text_t *ptext);
|
||||
int rts_osd_show_picture(void *p, uint8_t blkidx, int picidx); //__attribute__((deprecated));;
|
||||
int rts_osd_show_datetime(void *p, struct rts_osd_datetime_t *pdatetime);
|
||||
int rts_osd_fast_show_datetime(void *p, struct rts_osd_datetime_t *pdatetime, uint8_t blkidx, uint8_t date_hide, uint8_t time_hide);
|
||||
int rts_osd_preset_text(void *p, uint8_t blkidx, struct rts_osd_text_t *ptext);
|
||||
int rts_osd_fast_draw_text(void *p, uint8_t blkidx, struct rts_osd_text_t *ptext);
|
||||
int rts_osd_cancel(void *p, uint8_t blkidx);
|
||||
void rts_osd_disable(void *p, int blkidx, uint8_t blk_hide);
|
||||
int rts_osd_set_position(void *p, uint8_t blkidx, struct rts_osd_rect_t *pos);
|
||||
int rts_osd_get_position(void *p, uint8_t blkidx, struct rts_osd_rect_t *pos);
|
||||
int rts_osd_set_attr(void *p, uint8_t blkidx, struct rts_osd_attr_t *pattr);
|
||||
int rts_osd_get_attr(void *p, uint8_t blkidx, struct rts_osd_attr_t *pattr);
|
||||
|
||||
int rts_osd_get_block_number(void *p);
|
||||
int rts_osd_set_rotate(void *p, uint8_t _rotate);
|
||||
int rts_osd_set_font_size(void *p, uint8_t osd_w, uint8_t osd_h);
|
||||
int rts_osd_get_font_size(void *p, uint8_t *p_osd_char_w, uint8_t *p_osd_char_h);
|
||||
|
||||
int rts_osd_set_bitmap(void *p, uint8_t blkidx, const BITMAP_S *pstBitmap);
|
||||
int rts_osd_preset_pic(void *p, const BITMAP_S *pstBitmap, int *picidx);
|
||||
int rts_osd_fast_draw_pic(void *p, uint8_t blkidx, const BITMAP_S *pbitmap, int picidx);
|
||||
|
||||
int rts_osd_refresh_datetime(void *p);
|
||||
int rts_osd_get_time_length(enum rts_osd_time_fmt time_fmt);
|
||||
int rts_osd_get_date_length(enum rts_osd_date_fmt date_fmt);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,290 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtstream.h
|
||||
*
|
||||
* Copyright (C) 2016 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSTREAM_H
|
||||
#define _INCLUDE_RTSTREAM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <rtsavdef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
enum {
|
||||
RTSTREAM_PKT_FLAG_KEY = (1 << 0),
|
||||
RTSTREAM_PKT_FLAG_NO_OUTPUT = (1 << 1),
|
||||
};
|
||||
|
||||
struct rts_av_buffer {
|
||||
void *vm_addr;
|
||||
uint32_t length;
|
||||
uint32_t bytesused;
|
||||
uint32_t phy_addr;
|
||||
uint32_t flags;
|
||||
uint32_t index;
|
||||
uint32_t type;
|
||||
uint64_t timestamp;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
struct rts_av_profile {
|
||||
enum RTS_AV_FMT fmt;
|
||||
union {
|
||||
struct {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t numerator;
|
||||
uint32_t denominator;
|
||||
} video;
|
||||
struct {
|
||||
uint32_t samplerate;
|
||||
uint32_t bitfmt;
|
||||
uint32_t channel;
|
||||
uint32_t reserved;
|
||||
} audio;
|
||||
};
|
||||
};
|
||||
|
||||
typedef struct rts_av_stream *RtStream;
|
||||
|
||||
/*!
|
||||
* init rtstream library
|
||||
*/
|
||||
int rts_av_init();
|
||||
|
||||
/*!
|
||||
* release rtstream library
|
||||
*/
|
||||
int rts_av_release();
|
||||
|
||||
|
||||
/*!
|
||||
* initialize custom buffer
|
||||
*/
|
||||
int rts_av_init_buffer(struct rts_av_buffer *buffer,
|
||||
void *vm_addr, uint32_t length, uint32_t phy_addr);
|
||||
|
||||
/*!
|
||||
* uninitialize custom buffer
|
||||
*/
|
||||
int rts_av_uninit_buffer(struct rts_av_buffer *buffer);
|
||||
|
||||
/*!
|
||||
* increment reference count for buffer
|
||||
*/
|
||||
struct rts_av_buffer *rts_av_get_buffer(struct rts_av_buffer *buffer);
|
||||
|
||||
/*!
|
||||
* decrement reference count for buffer
|
||||
*/
|
||||
int rts_av_put_buffer(struct rts_av_buffer *buffer);
|
||||
|
||||
/*!
|
||||
* apply stream : start streaming
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_apply(RtStream stream);
|
||||
|
||||
/*!
|
||||
* cancel stream : stop streaming
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_cancel(RtStream stream);
|
||||
|
||||
/*!
|
||||
* check is there any output
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_poll(RtStream stream);
|
||||
|
||||
/*!
|
||||
* receive data from the streaming stream
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_av_stream_recv(RtStream stream, struct rts_av_buffer **ppbuf);
|
||||
|
||||
/*!
|
||||
* rts_av_stream_get_profile: get stream output profile
|
||||
*
|
||||
* if the stream has unit whose type is unit_type_sink,
|
||||
* this api is not support
|
||||
*
|
||||
* @return 0 : success, minus : fail.
|
||||
*/
|
||||
int rts_av_stream_get_profile(RtStream stream,
|
||||
struct rts_av_profile *profile);
|
||||
|
||||
/*!
|
||||
* rts_av_stream_set_profile: set stream intput profile
|
||||
*
|
||||
* if the stream has unit whose type is unit_type_source,
|
||||
* this api is not support
|
||||
*
|
||||
* @return 0 : success, minus : fail.
|
||||
*/
|
||||
int rts_av_stream_set_profile(RtStream stream,
|
||||
struct rts_av_profile *profile);
|
||||
|
||||
/*!
|
||||
* rts_destroy_stream: cancel stream, delete all units, delete stream
|
||||
*
|
||||
*/
|
||||
void rts_destroy_stream(RtStream stream);
|
||||
|
||||
enum rts_h264_profile {
|
||||
H264_PROFILE_UNKNOWN,
|
||||
H264_PROFILE_BASE,
|
||||
H264_PROFILE_MAIN,
|
||||
H264_PROFILE_HIGH
|
||||
};
|
||||
|
||||
enum rts_h264_level {
|
||||
H264_LEVEL_UNKNOWN = 0,
|
||||
H264_LEVEL_1,
|
||||
H264_LEVEL_1_b,
|
||||
H264_LEVEL_1_1,
|
||||
H264_LEVEL_1_2,
|
||||
H264_LEVEL_1_3,
|
||||
H264_LEVEL_2,
|
||||
H264_LEVEL_2_1,
|
||||
H264_LEVEL_2_2,
|
||||
H264_LEVEL_3,
|
||||
H264_LEVEL_3_1,
|
||||
H264_LEVEL_3_2,
|
||||
H264_LEVEL_4,
|
||||
H264_LEVEL_4_1,
|
||||
H264_LEVEL_4_2,
|
||||
H264_LEVEL_5,
|
||||
H264_LEVEL_5_1,
|
||||
H264_LEVEL_RESERVED
|
||||
};
|
||||
|
||||
struct rts_isp_stream_cfg {
|
||||
int isp_id;
|
||||
enum RTS_AV_FMT format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t numerator;
|
||||
uint32_t denominator;
|
||||
int isp_buf_num;
|
||||
};
|
||||
|
||||
/*!
|
||||
* rts_create_isp_stream : create an isp stream
|
||||
*
|
||||
* cfg->numerator: in
|
||||
* cfg->denominator: in
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_isp_stream(struct rts_isp_stream_cfg *cfg);
|
||||
|
||||
struct rts_h264_stream_cfg {
|
||||
struct rts_isp_stream_cfg isp_cfg;
|
||||
|
||||
enum rts_h264_profile profile;
|
||||
enum rts_h264_level level;
|
||||
|
||||
int qp;
|
||||
unsigned int bps;
|
||||
unsigned int gop;
|
||||
enum rts_av_rotation rotation;
|
||||
int videostab;
|
||||
};
|
||||
|
||||
/*!
|
||||
* rts_create_h264_stream: create a h264 stream
|
||||
*
|
||||
* cfg->rotation: in
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_h264_stream(struct rts_h264_stream_cfg *cfg);
|
||||
|
||||
struct rts_mjpeg_stream_cfg {
|
||||
struct rts_isp_stream_cfg isp_cfg;
|
||||
|
||||
enum rts_av_rotation rotation;
|
||||
};
|
||||
|
||||
/*!
|
||||
* rts_create_mjpeg_stream: create a mjpeg stream
|
||||
*
|
||||
* cfg->rotation: in
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_mjpeg_stream(struct rts_mjpeg_stream_cfg *cfg);
|
||||
|
||||
struct rts_audio_stream_cfg {
|
||||
char dev_node[64];
|
||||
uint32_t format;
|
||||
uint32_t channels;
|
||||
uint32_t rate;
|
||||
};
|
||||
|
||||
/*!
|
||||
* rts_create_audio_playback_stream: create a audio playback stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_playback_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_capture_stream: create a audio capture stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_capture_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_mixer_playback_stream: create a audio mixer + playback stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_mixer_playback_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_capture_encode_stream: create a audio capture + encode stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_capture_encode_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_decode_stream: create a audio decode stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_decode_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_encode_stream: create a audio encode stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_encode_stream(struct rts_audio_stream_cfg *cfg);
|
||||
|
||||
/*!
|
||||
* rts_create_audio_server_stream: create a audio server stream
|
||||
*
|
||||
* @return the pointer of the stream when success, or NULL when fail
|
||||
*/
|
||||
RtStream rts_create_audio_server_stream(struct rts_audio_stream_cfg *cfg_p,
|
||||
struct rts_audio_stream_cfg *cfg_c);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* lib/rtsv4l2.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LIB_RTSV4L2_H
|
||||
#define _LIB_RTSV4L2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
//#include <linux/videodev2.h>
|
||||
//#include <fcntl.h>
|
||||
|
||||
#define v4l2pixfmtstr(x) (x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, ((x) >> 24) & 0xff
|
||||
|
||||
/*int rts_v4l2_open(const char *path);
|
||||
int rts_v4l2_close(int fd);
|
||||
int rts_v4l2_get_fmt(int fd, uint32_t *pfmt, uint32_t *pw, uint32_t *ph);
|
||||
int rts_v4l2_set_fmt(int fd, uint32_t fmt, uint32_t width, uint32_t height);
|
||||
int rts_v4l2_get_frmival(int fd, uint32_t *numerator, uint32_t *denominator);
|
||||
int rts_v4l2_set_frmival(int fd, uint32_t numerator, uint32_t denominator);
|
||||
int rts_v4l2_enum_fmt(int fd, int index, struct v4l2_fmtdesc *fmtdesc);
|
||||
int rts_v4l2_enum_frmsizes(int fd, uint32_t fmt, int index,
|
||||
struct v4l2_frmsizeenum *frmsize);
|
||||
int rts_v4l2_enum_frmival(int fd, uint32_t fmt, uint32_t width,
|
||||
uint32_t height, int index, struct v4l2_frmivalenum *frmival);
|
||||
int rts_v4l2_request_bufs(int fd, unsigned int num);
|
||||
int rts_v4l2_query_mmap_buf(int fd,
|
||||
int index, void **ppbuf, uint32_t *plength);
|
||||
int rts_v4l2_munmap_buf(void *pbuf, uint32_t length);
|
||||
int rts_v4l2_streamon(int fd);
|
||||
int rts_v4l2_streamoff(int fd);
|
||||
int rts_v4l2_get_buffer(int fd, struct v4l2_buffer *pbuf);
|
||||
int rts_v4l2_put_buffer(int fd, struct v4l2_buffer *pbuf);
|
||||
int rts_v4l2_check_frame(int fd);
|
||||
*/
|
||||
|
||||
int rts_v4l2_queryctrl(int fd, struct v4l2_queryctrl *pqctrl);
|
||||
//int rts_v4l2_query_next_ctrl(int fd, struct v4l2_queryctrl *pqctrl);
|
||||
int rts_v4l2_get_ctrl(int fd, struct v4l2_control *pctrl);
|
||||
int rts_v4l2_set_ctrl(int fd, struct v4l2_control *pctrl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,673 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsvideo.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSVIDEO_H
|
||||
#define _INCLUDE_RTSVIDEO_H
|
||||
#include <stdint.h>
|
||||
#include <rtsisp_def.h>
|
||||
#include <rtsisp.h>
|
||||
#include <rtsosd.h>
|
||||
#include <rtstream.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
enum enum_rts_video_ctrl_id {
|
||||
RTS_VIDEO_CTRL_ID_BRIGHTNESS = 1,
|
||||
RTS_VIDEO_CTRL_ID_CONTRAST,
|
||||
RTS_VIDEO_CTRL_ID_HUE,
|
||||
RTS_VIDEO_CTRL_ID_SATURATION,
|
||||
RTS_VIDEO_CTRL_ID_SHARPNESS,
|
||||
RTS_VIDEO_CTRL_ID_GAMMA,
|
||||
RTS_VIDEO_CTRL_ID_AWB_CTRL,
|
||||
RTS_VIDEO_CTRL_ID_WB_TEMPERATURE,
|
||||
RTS_VIDEO_CTRL_ID_BLC,
|
||||
RTS_VIDEO_CTRL_ID_GAIN,
|
||||
RTS_VIDEO_CTRL_ID_PWR_FREQUENCY,
|
||||
RTS_VIDEO_CTRL_ID_EXPOSURE_MODE,
|
||||
RTS_VIDEO_CTRL_ID_EXPOSURE_PRIORITY,
|
||||
RTS_VIDEO_CTRL_ID_EXPOSURE_TIME,
|
||||
RTS_VIDEO_CTRL_ID_AF,
|
||||
RTS_VIDEO_CTRL_ID_FOCUS,
|
||||
RTS_VIDEO_CTRL_ID_ZOOM,
|
||||
RTS_VIDEO_CTRL_ID_PAN,
|
||||
RTS_VIDEO_CTRL_ID_TILT,
|
||||
RTS_VIDEO_CTRL_ID_ROLL,
|
||||
RTS_VIDEO_CTRL_ID_FLIP,
|
||||
RTS_VIDEO_CTRL_ID_MIRROR,
|
||||
RTS_VIDEO_CTRL_ID_ROTATE,
|
||||
RTS_VIDEO_CTRL_ID_ISP_SPECIAL_EFFECT,
|
||||
RTS_VIDEO_CTRL_ID_EV_COMPENSATE,
|
||||
RTS_VIDEO_CTRL_ID_COLOR_TEMPERATURE_ESTIMATION,
|
||||
RTS_VIDEO_CTRL_ID_AE_LOCK,
|
||||
RTS_VIDEO_CTRL_ID_AWB_LOCK,
|
||||
RTS_VIDEO_CTRL_ID_AF_LOCK,
|
||||
RTS_VIDEO_CTRL_ID_LED_TOUCH_MODE,
|
||||
RTS_VIDEO_CTRL_ID_LED_FLASH_MODE,
|
||||
RTS_VIDEO_CTRL_ID_ISO,
|
||||
RTS_VIDEO_CTRL_ID_SCENE_MODE,
|
||||
RTS_VIDEO_CTRL_ID_ROI_MODE,
|
||||
RTS_VIDEO_CTRL_ID_3A_STATUS,
|
||||
RTS_VIDEO_CTRL_ID_IDEA_EYE_SENSITIVITY,
|
||||
RTS_VIDEO_CTRL_ID_IDEA_EYE_STATUS,
|
||||
RTS_VIDEO_CTRL_ID_IEDA_EYE_MODE,
|
||||
RTS_VIDEO_CTRL_ID_GRAY_MODE,
|
||||
RTS_VIDEO_CTRL_ID_WDR_MODE,
|
||||
RTS_VIDEO_CTRL_ID_WDR_LEVEL,
|
||||
RTS_VIDEO_CTRL_ID_GREEN_BALANCE,
|
||||
RTS_VIDEO_CTRL_ID_RED_BALANCE,
|
||||
RTS_VIDEO_CTRL_ID_BLUE_BALANCE,
|
||||
RTS_VIDEO_CTRL_ID_AE_GAIN,
|
||||
RTS_VIDEO_CTRL_ID_3DNR,
|
||||
RTS_VIDEO_CTRL_ID_DEHAZE,
|
||||
RTS_VIDEO_CTRL_ID_IR_MODE,
|
||||
RTS_VIDEO_CTRL_ID_RESERVED,
|
||||
|
||||
/*deprecated*/
|
||||
RTS_VIDEO_CTRL_WDR_MODE = RTS_VIDEO_CTRL_ID_WDR_MODE,
|
||||
RTS_VIDEO_CTRL_WDR_LEVEL = RTS_VIDEO_CTRL_ID_WDR_LEVEL,
|
||||
RTS_VIDEO_CTRL_GREEN_BALANCE = RTS_VIDEO_CTRL_ID_GREEN_BALANCE,
|
||||
RTS_VIDEO_CTRL_RED_BALANCE = RTS_VIDEO_CTRL_ID_RED_BALANCE,
|
||||
RTS_VIDEO_CTRL_BLUE_BALANCE = RTS_VIDEO_CTRL_ID_BLUE_BALANCE,
|
||||
RTS_VIDEO_CTRL_AE_GAIN = RTS_VIDEO_CTRL_ID_AE_GAIN,
|
||||
RTS_VIDEO_CTRL_3DNR = RTS_VIDEO_CTRL_ID_3DNR,
|
||||
RTS_VIDEO_CTRL_DEHAZE = RTS_VIDEO_CTRL_ID_DEHAZE,
|
||||
};
|
||||
|
||||
enum RTS_ISP_WDR_MODE {
|
||||
RTS_ISP_WDR_DISABLE = 0,
|
||||
RTS_ISP_WDR_MANUAL,
|
||||
RTS_ISP_WDR_AUTO_WEAK,
|
||||
RTS_ISP_WDR_AUTO_MEDIUM,
|
||||
RTS_ISP_WDR_AUTO_STRONG,
|
||||
RTS_ISP_WDR_RESERVED,
|
||||
};
|
||||
|
||||
struct rts_video_control {
|
||||
uint32_t type;
|
||||
char name[32];
|
||||
int32_t minimum;
|
||||
int32_t maximum;
|
||||
int32_t step;
|
||||
int32_t default_value;
|
||||
int32_t current_value;
|
||||
uint32_t flags;
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
struct rts_video_rect {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
int32_t right;
|
||||
int32_t bottom;
|
||||
};
|
||||
|
||||
struct rts_video_grid_unit {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
};
|
||||
|
||||
struct rts_video_grid_bitmap {
|
||||
uint32_t rows;
|
||||
uint32_t columns;
|
||||
uint8_t bitmap[RTS_GRID_BITMAP_SIZE];
|
||||
};
|
||||
|
||||
struct rts_video_grid {
|
||||
int32_t left;
|
||||
int32_t top;
|
||||
|
||||
struct rts_video_grid_unit cell;
|
||||
uint32_t rows;
|
||||
uint32_t columns;
|
||||
|
||||
int length;
|
||||
uint8_t bitmap[RTS_GRID_BITMAP_SIZE];
|
||||
};
|
||||
|
||||
struct rts_video_md_block {
|
||||
int type;
|
||||
int enable;
|
||||
union {
|
||||
struct rts_video_grid area;
|
||||
struct rts_video_rect rect;
|
||||
};
|
||||
uint32_t res_width;
|
||||
uint32_t res_height;
|
||||
|
||||
uint32_t sensitivity;
|
||||
uint32_t percentage;
|
||||
uint32_t frame_interval;
|
||||
};
|
||||
|
||||
struct rts_video_md_attr {
|
||||
int number;
|
||||
struct rts_video_md_block *blocks;
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
struct rts_video_mask_block {
|
||||
int type;
|
||||
int enable;
|
||||
union {
|
||||
struct rts_video_grid area;
|
||||
struct rts_video_rect rect;
|
||||
};
|
||||
uint32_t res_width;
|
||||
uint32_t res_height;
|
||||
};
|
||||
|
||||
struct rts_video_mask_attr {
|
||||
uint32_t color; /*rgb24*/
|
||||
int number;
|
||||
struct rts_video_mask_block *blocks;
|
||||
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
struct rts_video_osd_block {
|
||||
struct rts_video_rect rect;
|
||||
uint8_t bg_enable;
|
||||
uint32_t bg_color;
|
||||
uint32_t ch_color;
|
||||
|
||||
uint8_t h_gap : 4,
|
||||
v_gap : 4;
|
||||
|
||||
uint8_t flick_enable;
|
||||
uint32_t flick_speed;
|
||||
uint8_t char_color_alpha;
|
||||
|
||||
uint8_t stroke_enable;
|
||||
uint8_t stroke_direct;
|
||||
uint8_t stroke_delta;
|
||||
|
||||
struct rts_osd_text_t *pshowtext;
|
||||
BITMAP_S *pbitmap;
|
||||
uint8_t blk_hide;
|
||||
};
|
||||
|
||||
struct rts_video_osd_attr {
|
||||
int number;
|
||||
struct rts_video_osd_block *blocks;
|
||||
|
||||
enum rts_osd_time_fmt time_fmt;
|
||||
uint8_t time_blkidx;
|
||||
int time_pos;
|
||||
enum rts_osd_date_fmt date_fmt;
|
||||
uint8_t date_blkidx;
|
||||
int date_pos;
|
||||
|
||||
unsigned int single_font_addr;
|
||||
unsigned int double_font_addr;
|
||||
|
||||
uint8_t osd_char_w;
|
||||
uint8_t osd_char_h;
|
||||
struct rts_osd_text_t *presettext;
|
||||
|
||||
BITMAP_S *ppresetbitmap[4];
|
||||
int presetbmpidx[4];
|
||||
int presetbmpnum;
|
||||
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
enum rts_bitrate_mode {
|
||||
RTS_BITRATE_MODE_CBR = (1 << 1),
|
||||
RTS_BITRATE_MODE_VBR = (1 << 2),
|
||||
RTS_BITRATE_MODE_C_VBR = (1 << 3),
|
||||
};
|
||||
|
||||
struct rts_video_h264_info {
|
||||
int sps_pps_len;
|
||||
char sps_pps[48];
|
||||
};
|
||||
|
||||
struct rts_video_h264_ctrl {
|
||||
uint32_t supported_bitrate_mode;
|
||||
uint32_t bitrate_mode;
|
||||
|
||||
uint32_t bitrate;
|
||||
uint32_t max_bitrate;
|
||||
uint32_t min_bitrate;
|
||||
|
||||
int32_t qp;
|
||||
uint32_t max_qp;
|
||||
uint32_t min_qp;
|
||||
int32_t intraQpDelta;
|
||||
|
||||
uint32_t gop;
|
||||
|
||||
uint32_t slice_size;
|
||||
uint32_t sei_messages;
|
||||
uint32_t video_full_range;
|
||||
uint32_t constrained_intra_prediction;
|
||||
uint32_t disable_deblocking_filter;
|
||||
uint32_t enable_cabac;
|
||||
uint32_t cabac_init_idc;
|
||||
uint32_t transform8x8mode;
|
||||
uint32_t gdr;
|
||||
|
||||
uint32_t hrd;
|
||||
uint32_t hrd_cpb_size;
|
||||
int32_t longterm_pic_rate;
|
||||
|
||||
int drop_frame_en;
|
||||
int drop_frame_th;
|
||||
int cvbr_en;
|
||||
int cvbr_diff_n;
|
||||
int p_wnd_size;
|
||||
int p_target_min_percentage;
|
||||
int p_target_max_percentage;
|
||||
int p_diff_x_th_percentage;
|
||||
int p_diff_adjust_percentage;
|
||||
int rs_rc_en;
|
||||
|
||||
uint32_t reserved[4];
|
||||
};
|
||||
|
||||
struct rts_video_mjpeg_ctrl {
|
||||
uint16_t normal_compress_rate:4; /*0.5 as the unit*/
|
||||
};
|
||||
|
||||
enum rts_video_roi_type {
|
||||
RTS_VIDEO_ROI_UNKNOWN = 0,
|
||||
RTS_VIDEO_ROI_H264,
|
||||
RTS_VIDEO_ROI_RESERVED
|
||||
};
|
||||
|
||||
struct rts_video_roi_ctrl {
|
||||
int enable;
|
||||
struct rts_video_rect area;
|
||||
int32_t value;
|
||||
};
|
||||
|
||||
/*!
|
||||
* get video control,
|
||||
* id: defined in enum enum_rts_video_ctrl_id
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_get_ctrl(RtStream stream,
|
||||
uint32_t id, struct rts_video_control *pctrl);
|
||||
|
||||
/*!
|
||||
* set video control,
|
||||
* id: defined in enum enum_rts_video_ctrl_id
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_ctrl(RtStream stream,
|
||||
uint32_t id, struct rts_video_control *pctrl);
|
||||
|
||||
/*!
|
||||
* get motion detect attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_video_release_md_attr to release it.
|
||||
*/
|
||||
int rts_video_query_md_attr(RtStream stream,
|
||||
struct rts_video_md_attr **attr);
|
||||
|
||||
/*!
|
||||
* update motion detect setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_md_attr(RtStream stream,
|
||||
struct rts_video_md_attr *attr);
|
||||
|
||||
/*!
|
||||
* release motion detect attribute
|
||||
*
|
||||
*/
|
||||
void rts_video_release_md_attr(RtStream stream,
|
||||
struct rts_video_md_attr *attr);
|
||||
|
||||
/*!
|
||||
* check motion detect result
|
||||
*
|
||||
* @return 1 : detected, 0 : not
|
||||
*/
|
||||
int rts_video_check_md_status(RtStream stream, int mdidx);
|
||||
|
||||
/*!
|
||||
* get motion detect bitmap result
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_get_md_result(RtStream stream, int mdidx,
|
||||
struct rts_video_grid_bitmap *result);
|
||||
|
||||
/*!
|
||||
* get private mask attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_video_release_mask_attr to release if.
|
||||
*
|
||||
*/
|
||||
int rts_video_query_mask_attr(RtStream stream,
|
||||
struct rts_video_mask_attr **attr);
|
||||
|
||||
/*!
|
||||
* update private mask setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_mask_attr(RtStream stream,
|
||||
struct rts_video_mask_attr *attr);
|
||||
|
||||
/*!
|
||||
* release private mask attribute
|
||||
*
|
||||
*/
|
||||
void rts_video_release_mask_attr(RtStream stream,
|
||||
struct rts_video_mask_attr *attr);
|
||||
|
||||
/*!
|
||||
* get osd attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_video_release_osd_attr to release it
|
||||
*
|
||||
*/
|
||||
|
||||
int rts_video_query_osd_attr(RtStream stream,
|
||||
struct rts_video_osd_attr **attr);
|
||||
|
||||
/*!
|
||||
* update osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_osd_attr(RtStream stream,
|
||||
struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* preset osd bmp data
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_preset_osd_bmp(RtStream stream,
|
||||
struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* fast update osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_fast_set_osd_attr(RtStream stream,
|
||||
struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* fast update one osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_fast_set_one_osd_attr(RtStream stream,
|
||||
struct rts_video_osd_attr *attr,
|
||||
int blknum);
|
||||
|
||||
/*!
|
||||
* update osd date/time
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_refresh_osd_datetime(RtStream stream,
|
||||
struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* release osd attribute
|
||||
*
|
||||
*/
|
||||
void rts_video_release_osd_attr(RtStream stream,
|
||||
struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* get h264 info
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_get_h264_mediainfo(RtStream stream,
|
||||
struct rts_video_h264_info *info);
|
||||
|
||||
/*!
|
||||
* get h264 control
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_get_h264_ctrl(RtStream stream,
|
||||
struct rts_video_h264_ctrl *rc);
|
||||
|
||||
/*!
|
||||
* set h264 control
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_h264_ctrl(RtStream stream,
|
||||
struct rts_video_h264_ctrl *rc);
|
||||
|
||||
/*!
|
||||
* request an h264 key frame
|
||||
*
|
||||
* @return 0
|
||||
*/
|
||||
int rts_video_request_h264_key_frame(RtStream stream);
|
||||
|
||||
/*!
|
||||
* get mjpeg control
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_get_mjpeg_ctrl(RtStream stream,
|
||||
struct rts_video_mjpeg_ctrl *pctrl);
|
||||
|
||||
/*!
|
||||
* set mjpeg control
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_video_set_mjpeg_ctrl(RtStream stream,
|
||||
struct rts_video_mjpeg_ctrl *pctrl);
|
||||
|
||||
int rts_video_get_ae_gain(RtStream stream,
|
||||
struct rts_isp_ae_gain *gain);
|
||||
|
||||
int rts_video_set_ae_gain(RtStream stream,
|
||||
struct rts_isp_ae_gain *gain);
|
||||
|
||||
int rts_video_get_ae_weight(RtStream stream,
|
||||
struct rts_isp_ae_weight *weight);
|
||||
|
||||
int rts_video_set_ae_weight(RtStream stream,
|
||||
struct rts_isp_ae_weight *weight);
|
||||
|
||||
int rts_video_get_ae_statis(RtStream stream,
|
||||
struct rts_isp_ae_statis *statis);
|
||||
|
||||
int rts_video_get_awb_statis(RtStream stream,
|
||||
struct rts_isp_awb_statis *statis);
|
||||
|
||||
int rts_video_get_awb_ct_gain(RtStream stream,
|
||||
uint8_t ct, struct rts_isp_awb_ct_gain *gain);
|
||||
|
||||
int rts_video_get_ae_target_delta(RtStream stream,
|
||||
int8_t *delta);
|
||||
|
||||
int rts_video_set_ae_target_delta(RtStream stream,
|
||||
int8_t delta);
|
||||
|
||||
int rts_video_get_roi_count(RtStream stream, int type);
|
||||
|
||||
int rts_video_get_roi_ctrl(RtStream stream,
|
||||
int type, int index, struct rts_video_roi_ctrl *roi);
|
||||
|
||||
int rts_video_set_roi_ctrl(RtStream stream,
|
||||
int type, int index, struct rts_video_roi_ctrl *roi);
|
||||
|
||||
/*!
|
||||
* get isp video control,
|
||||
* id: defined in enum enum_rts_video_ctrl_id
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_get_isp_ctrl(uint32_t id, struct rts_video_control *pctrl);
|
||||
|
||||
/*!
|
||||
* set isp video control,
|
||||
* id: defined in enum enum_rts_video_ctrl_id
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_set_isp_ctrl(uint32_t id, struct rts_video_control *pctrl);
|
||||
|
||||
/*!
|
||||
* get motion detect attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_release_isp_md_attr to release it.
|
||||
*/
|
||||
int rts_query_isp_md_attr(struct rts_video_md_attr **attr,
|
||||
uint32_t res_width, uint32_t res_height);
|
||||
|
||||
/*!
|
||||
* update motion detect setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_set_isp_md_attr(struct rts_video_md_attr *attr);
|
||||
|
||||
/*!
|
||||
* release motion detect attribute
|
||||
*
|
||||
*/
|
||||
void rts_release_isp_md_attr(struct rts_video_md_attr *attr);
|
||||
|
||||
/*!
|
||||
* check motion detect result
|
||||
*
|
||||
* @return 1 : detected, 0 : not
|
||||
*/
|
||||
int rts_check_isp_md_status(int mdidx);
|
||||
|
||||
/*!
|
||||
* get motion detect bitmap result
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_get_isp_md_result(int mdidx, struct rts_video_grid_bitmap *result);
|
||||
|
||||
/*!
|
||||
* get private mask attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_release_isp_mask_attr to release if.
|
||||
*
|
||||
*/
|
||||
int rts_query_isp_mask_attr(struct rts_video_mask_attr **attr,
|
||||
uint32_t res_width, uint32_t res_height);
|
||||
|
||||
/*!
|
||||
* update private mask setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_set_isp_mask_attr(struct rts_video_mask_attr *attr);
|
||||
|
||||
/*!
|
||||
* release private mask attribute
|
||||
*
|
||||
*/
|
||||
void rts_release_isp_mask_attr(struct rts_video_mask_attr *attr);
|
||||
|
||||
/*!
|
||||
* get osd attribute
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* if success, you need to call rts_release_isp_osd_attr to release if.
|
||||
*
|
||||
*/
|
||||
int rts_query_isp_osd_attr(int isp_id, struct rts_video_osd_attr **attr);
|
||||
|
||||
/*!
|
||||
* update osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_set_isp_osd_attr(struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* preset osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_preset_isp_osd_attr(struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* fast update osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_fast_set_isp_osd_attr(struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* fast update 1 osd setting
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_fast_set_one_isp_osd_attr(struct rts_video_osd_attr *attr, int blknum);
|
||||
|
||||
/*!
|
||||
* update osd date/time
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_refresh_isp_osd_datetime(struct rts_video_osd_attr *attr);
|
||||
|
||||
/*!
|
||||
* update date w/o attr
|
||||
*
|
||||
*/
|
||||
void rts_write_isp_osd_date(int dNextDate, int dFormat, int dYear, int dMonth, int dDay);
|
||||
|
||||
/*!
|
||||
* release osd attribute
|
||||
*
|
||||
*/
|
||||
void rts_release_isp_osd_attr(struct rts_video_osd_attr *attr);
|
||||
|
||||
int rts_get_isp_ae_gain(struct rts_isp_ae_gain *gain);
|
||||
|
||||
int rts_set_isp_ae_gain(struct rts_isp_ae_gain *gain);
|
||||
|
||||
int rts_get_isp_ae_weight(struct rts_isp_ae_weight *weight);
|
||||
|
||||
int rts_set_isp_ae_weight(struct rts_isp_ae_weight *weight);
|
||||
|
||||
int rts_get_isp_ae_statis(struct rts_isp_ae_statis *statis);
|
||||
|
||||
int rts_get_isp_awb_statis(struct rts_isp_awb_statis *statis);
|
||||
|
||||
int rts_get_isp_awb_ct_gain(uint8_t ct, struct rts_isp_awb_ct_gain *gain);
|
||||
|
||||
int rts_get_isp_ae_target_delta(int8_t *delta);
|
||||
|
||||
int rts_set_isp_ae_target_delta(int8_t delta);
|
||||
|
||||
/*!
|
||||
* get version number
|
||||
*
|
||||
*/
|
||||
char *rts_get_lib_version();
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* rts_camera.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LINUX_RTS_CAMERA_H
|
||||
#define _LINUX_RTS_CAMERA_H
|
||||
|
||||
//#include <linux/ioctl.h>
|
||||
//#include <linux/types.h>
|
||||
|
||||
#define RTSCAM_DEV_MAJOR 82
|
||||
|
||||
#define RTS_V4L2_CID_BASE (V4L2_CID_USER_BASE | 0xf000)
|
||||
#define RTS_V4L2_CID_ROLL_ABSOLUTE (RTS_V4L2_CID_BASE + 0)
|
||||
#define RTS_V4L2_CID_AUTO_WHITE_BALANCE_COMPONENT (RTS_V4L2_CID_BASE + 1)
|
||||
#define RTS_V4L2_CID_GREEN_BALANCE (RTS_V4L2_CID_BASE + 2)
|
||||
#define RTS_V4L2_CID_AE_GAIN (RTS_V4L2_CID_BASE + 3)
|
||||
|
||||
struct rtscam_vcmd {
|
||||
unsigned int cmdcode;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
#define RTSCAMIOC_VENDOR_CMD 0x01
|
||||
#define RTSCAMIOC_GET_PHYADDDR 0x02
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* rts_camera_soc.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _UAPI_RTS_CAMERA_SOC_H
|
||||
#define _UAPI_RTS_CAMERA_SOC_H
|
||||
|
||||
enum rtscam_soc_cmd_error_type
|
||||
{
|
||||
RTSCAM_CMD_STS_CMD_ERR = 0x01,
|
||||
RTSCAM_CMD_STS_LEN_ERR = 0x02,
|
||||
RTSCAM_CMD_STS_ADDR_ERR = 0x03
|
||||
};
|
||||
|
||||
struct rtscam_soc_cmd_stru
|
||||
{
|
||||
uint16_t cmdcode;
|
||||
uint8_t index;
|
||||
uint8_t length;
|
||||
uint16_t param;
|
||||
uint16_t addr;
|
||||
uint8_t *buf;
|
||||
uint32_t error_type;
|
||||
};
|
||||
|
||||
struct rtscam_soc_mtd_state
|
||||
{
|
||||
int index;
|
||||
int state;
|
||||
};
|
||||
|
||||
struct rtscam_soc_ldc_stru
|
||||
{
|
||||
unsigned int length;
|
||||
uint8_t *ptable;
|
||||
};
|
||||
|
||||
struct rtscam_soc_fw
|
||||
{
|
||||
unsigned int length;
|
||||
uint8_t *fw;
|
||||
};
|
||||
|
||||
#define RTSOCIOC_ISPCMD 0x31
|
||||
#define RTSOCIOC_G_HWOFFSET 0x34
|
||||
#define RTSOCIOC_G_HWIOSIZE 0x35
|
||||
#define RTSOCIOC_G_MTDSTATE 0x36
|
||||
#define RTSOCIOC_G_STREAMID 0x37
|
||||
|
||||
#define RTSOCIOC_S_TD 0x3a
|
||||
#define RTSOCIOC_G_TD 0x3b
|
||||
#define RTSOCIOC_ENABLE_LDC 0x3c
|
||||
#define RTSOCIOC_DISABLE_LDC 0x3d
|
||||
#define RTSOCIOC_G_LDC 0x3e
|
||||
|
||||
#define RTSOCIOC_CAMERA_DETACH 0x40
|
||||
#define RTSOCIOC_CAMERA_ATTACH 0x41
|
||||
#define RTSOCIOC_CAMERA_LOAD_FW 0x42
|
||||
#define RTSOCIOC_CAMERA_DUMP_FW 0x43
|
||||
#define RTSOCIOC_CAMERA_G_FW_SIZE 0x44
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* librtscamkit/rts_errno.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _RTS_ERRNO_H
|
||||
#define _RTS_ERRNO_H
|
||||
|
||||
#ifndef RTS_RETURN
|
||||
#define RTS_RETURN(e) (-(e))
|
||||
#endif
|
||||
|
||||
#ifndef RTS_ERRNO
|
||||
#define RTS_ERRNO(r) ((r) < 0 ? (-(r)) : (r))
|
||||
#endif
|
||||
|
||||
enum RTS_ERRNO {
|
||||
RTS_OK = 0,
|
||||
RTS_FAIL,
|
||||
RTS_E_NULL_POINT = 10,
|
||||
RTS_E_NO_MEMORY,
|
||||
RTS_E_NOT_REALIZED,
|
||||
RTS_E_EXIST,
|
||||
RTS_E_NOT_EXIST,
|
||||
RTS_E_NOT_FOUND,
|
||||
RTS_E_NOT_REGISTERED,
|
||||
RTS_E_NOT_READY,
|
||||
RTS_E_EMPTY,
|
||||
RTS_E_NOT_EMPTY,
|
||||
RTS_E_FULL,
|
||||
RTS_E_INVALID_ARG,
|
||||
RTS_E_INVALID_TYPE,
|
||||
RTS_E_NOT_MATCH,
|
||||
RTS_E_OPEN_FAIL,
|
||||
RTS_E_CLOSE_FAIL,
|
||||
RTS_E_NOT_OPEN,
|
||||
RTS_E_GET_FAIL,
|
||||
RTS_E_SET_FAIL,
|
||||
RTS_E_NOT_SUPPORT,
|
||||
RTS_E_INITIALIZED,
|
||||
RTS_E_NOT_INITIALIZED,
|
||||
RTS_E_INUSE,
|
||||
RTS_E_WRITE_FAIL,
|
||||
RTS_E_READ_FAIL,
|
||||
RTS_E_LOCK_FAIL,
|
||||
RTS_E_INVALID_LENGTH,
|
||||
RTS_E_TIMEOUT,
|
||||
RTS_E_THREAD_FAIL,
|
||||
RTS_E_OVERFLOW,
|
||||
RTS_E_BIG,
|
||||
RTS_E_PERM,
|
||||
RTS_E_NO_ENT,
|
||||
RTS_E_IO,
|
||||
RTS_E_AGAIN,
|
||||
RTS_E_NO_DEV,
|
||||
RTS_E_NO_SYS,
|
||||
RTS_E_IOCTL,
|
||||
RTS_E_LESS_DATA,
|
||||
RTS_E_OUT_OF_RANGE,
|
||||
RTS_E_MMAP_FAIL,
|
||||
RTS_E_MUNMAP_FAIL,
|
||||
RTS_E_INVALID_DATA,
|
||||
RTS_E_NO_REALIZED,
|
||||
RTS_E_INVALID_VERSION,
|
||||
RTS_E_UNKNOWN,
|
||||
RTS_E_RECEIVE_FAIL,
|
||||
RTS_E_SEND_FAIL,
|
||||
RTS_E_DISCONNECT,
|
||||
RTS_E_SAVE_FAIL,
|
||||
RTS_E_CMP_FAIL,
|
||||
RTS_E_ERASE_FAIL,
|
||||
RTS_E_RESET_FAIL,
|
||||
RTS_E_DISABLE,
|
||||
};
|
||||
|
||||
char *rts_strerrno(int errnum);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* librtscamkit/rts_log.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LIBRTSCAMKIT_RTS_LOG_H
|
||||
#define _LIBRTSCAMKIT_RTS_LOG_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
enum RTS_LOG_TYPE {
|
||||
RTS_LOG_IDX_CONS = 0,
|
||||
RTS_LOG_IDX_SYSLOG,
|
||||
RTS_LOG_IDX_FILE,
|
||||
RTS_LOG_IDX_CALLBACK,
|
||||
RTS_LOG_IDX_RESERVED
|
||||
};
|
||||
|
||||
#define RTS_LOG_MASK_CONS (0x1 << RTS_LOG_IDX_CONS)
|
||||
#define RTS_LOG_MASK_SYSLOG (0x1 << RTS_LOG_IDX_SYSLOG)
|
||||
#define RTS_LOG_MASK_FILE (0x1 << RTS_LOG_IDX_FILE)
|
||||
#define RTS_LOG_MASK_CALLBACK (0x1 << RTS_LOG_IDX_CALLBACK)
|
||||
|
||||
enum RTS_LOG_PRIORITY {
|
||||
RTS_LOG_DEBUG = 0,
|
||||
RTS_LOG_INFO,
|
||||
RTS_LOG_NOTICE,
|
||||
RTS_LOG_WARNING,
|
||||
RTS_LOG_ERR,
|
||||
RTS_LOG_CRIT,
|
||||
RTS_LOG_ALERT,
|
||||
RTS_LOG_EMERG,
|
||||
RTS_LOG_MEM,
|
||||
RTS_LOG_RESERVED
|
||||
};
|
||||
|
||||
/*
|
||||
* rts_log :
|
||||
* */
|
||||
void rts_log(int priority, const char *format, ...);
|
||||
|
||||
/*
|
||||
* rts_set_log_ident :
|
||||
* */
|
||||
int rts_set_log_ident(const char *ident);
|
||||
|
||||
/*
|
||||
* rts_set_log_mask :
|
||||
*
|
||||
* @mask : If the mask argument is 0, the current log mask is not modified
|
||||
*
|
||||
* return value : the current log_mask
|
||||
*
|
||||
* */
|
||||
int rts_set_log_mask(int mask);
|
||||
|
||||
/*
|
||||
* rts_set_log_file :
|
||||
*
|
||||
* @filename : NULL will close log file
|
||||
*
|
||||
* return value: 0 success, others fail
|
||||
*
|
||||
* */
|
||||
int rts_set_log_file(const char *filename);
|
||||
|
||||
int rts_set_log_callback(void (*callback)(const char *, va_list));
|
||||
|
||||
/*
|
||||
* rts_set_log_level
|
||||
*
|
||||
* @level_mask : If the level_mask argument is 0, the current level_mask is not modified.
|
||||
*
|
||||
* return value : the current level_mask
|
||||
*
|
||||
* */
|
||||
int rts_set_log_level(int level_mask);
|
||||
|
||||
/*
|
||||
* rts_dump_data :
|
||||
* */
|
||||
void rts_dump_data(char *data, unsigned int len, unsigned int row);
|
||||
|
||||
#define RTS_DEBUG(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_DEBUG, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_INFO(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_INFO, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_NOTICE(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_NOTICE, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_WARNING(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_WARNING, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_ERR(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_ERR, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_CRIT(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_CRIT, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_ALERT(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_ALERT, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_EMERG(...) \
|
||||
do {\
|
||||
rts_log(RTS_LOG_EMERG, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#define RTS_OPT(...) \
|
||||
do {\
|
||||
fprintf(stdout, __VA_ARGS__);\
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rts_linux_lock.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _RTS_CAMKIT_H
|
||||
#define _RTS_CAMKIT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
//#include <sys/types.h>
|
||||
//#include <drv_types.h>
|
||||
#include <rts_errno.h>
|
||||
#include <rts_log.h>
|
||||
//#include <rts_linux_lock.h>
|
||||
|
||||
typedef long int off_t;
|
||||
|
||||
#ifdef RTS_FALSE
|
||||
#undef RTS_FALSE
|
||||
#endif
|
||||
#define RTS_FALSE 0
|
||||
|
||||
#ifdef RTS_TRUE
|
||||
#undef RTS_TRUE
|
||||
#endif
|
||||
#define RTS_TRUE 1
|
||||
|
||||
#ifndef RTS_L_BYTE
|
||||
#define RTS_L_BYTE(a) ((a) & 0xff)
|
||||
#endif
|
||||
#ifndef RTS_H_BYTE
|
||||
#define RTS_H_BYTE(a) (((a) >> 8) & 0xff)
|
||||
#endif
|
||||
#ifndef RTS_L_WORD
|
||||
#define RTS_L_WORD(a) ((a) & 0xffff)
|
||||
#endif
|
||||
#ifndef RTS_H_WORD
|
||||
#define RTS_H_WORD(a) (((a) >> 16) & 0xffff)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RTS_MAKE_WORD
|
||||
#define RTS_MAKE_WORD(a, b) ((a) | ((b) << 8))
|
||||
#endif
|
||||
#ifndef RTS_MAKE_DWORD
|
||||
#define RTS_MAKE_DWORD(a, b, c, d) \
|
||||
((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
|
||||
#endif
|
||||
|
||||
#ifndef RTS_MAKE_WORD_BE
|
||||
#define RTS_MAKE_WORD_BE(a, b) ((b) | ((a) << 8))
|
||||
#endif
|
||||
#ifndef RTS_MAKE_DWORD_BE
|
||||
#define RTS_MAKE_DWORD_BE(a, b, c, d) \
|
||||
((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
|
||||
#endif
|
||||
|
||||
#ifndef RTS_SET_BIT
|
||||
#define RTS_SET_BIT(v, i) ((v) | (1<<(i)))
|
||||
#endif
|
||||
#ifndef RTS_CLEAR_BIT
|
||||
#define RTS_CLEAR_BIT(v, i) ((v) & (~(1<<(i))))
|
||||
#endif
|
||||
#ifndef RTS_CHECK_BIT
|
||||
#define RTS_CHECK_BIT(v, i) (((v)>>(i)) & 1)
|
||||
#endif
|
||||
|
||||
#ifndef RTS_SAFE_DELETE
|
||||
#define RTS_SAFE_DELETE(p) \
|
||||
do { \
|
||||
if (p)\
|
||||
rts_free(p);\
|
||||
p = NULL;\
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef RTS_ARRAY_SIZE
|
||||
#define RTS_ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
|
||||
#endif
|
||||
|
||||
#define RTS_YUV_HEADER_SIZE 128
|
||||
|
||||
#ifndef offsetof
|
||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ({ \
|
||||
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
|
||||
(type *)( (char *)__mptr - offsetof(type,member) );})
|
||||
#endif
|
||||
|
||||
struct rts_version_t {
|
||||
unsigned int major;
|
||||
unsigned int minor;
|
||||
unsigned int build;
|
||||
unsigned int reserved;
|
||||
};
|
||||
|
||||
int rts_is_integer(const char *s);
|
||||
off_t rts_get_file_size(const char *filename);
|
||||
int rts_save_raw_data(const char *name, uint8_t *data, int length);
|
||||
int rts_save_yuv_image(const char *name, uint8_t *data,
|
||||
uint32_t width, uint32_t height, int length);
|
||||
|
||||
void *rts_malloc(size_t size);
|
||||
void rts_free(void *ptr);
|
||||
void *rts_calloc(size_t nmemb, size_t size);
|
||||
void *rts_realloc(void *ptr, size_t size);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* libs/include/rtscolor.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _RTSCOLOR_H
|
||||
#define _RTSCOLOR_H
|
||||
|
||||
#define CONVERT_YUV_TO_RGB(y,u,v,r,g,b) do {\
|
||||
r = (298*(y-16) + 409*(v-128) + 128) >> 8;\
|
||||
g = (298*(y-16) - 100*(u-128) - 208*(v-128) + 128) >> 8;\
|
||||
b = (298*(y-16) + 516*(u-128) + 128) >> 8;\
|
||||
r = (r > 255) ? 255 : ((r < 0) ? 0 : r);\
|
||||
g = (g > 255) ? 255 : ((g < 0) ? 0 : g);\
|
||||
b = (b > 255) ? 255 : ((b < 0) ? 0 : b);\
|
||||
} while(0)
|
||||
|
||||
#define CONVERT_RGB_TO_YUV(r,g,b,y,u,v) do {\
|
||||
y = ((66*r + 129*g + 25*b + 128) >> 8) + 16;\
|
||||
u = ((-38*r - 74*g + 112*b + 128) >> 8) + 128;\
|
||||
v = ((112*r - 94*g - 18*b + 128) >> 8) + 128;\
|
||||
y = (y > 236) ? 236 : ((y < 16) ? 16 : y);\
|
||||
u = (u > 240) ? 240 : ((u < 16) ? 16 : u);\
|
||||
v = (v > 240) ? 240 : ((v < 16) ? 16 : v);\
|
||||
} while(0)
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
unsigned char b;
|
||||
unsigned char g;
|
||||
unsigned char r;
|
||||
} rgb;
|
||||
unsigned int color;
|
||||
} rts_color;
|
||||
|
||||
enum {
|
||||
RTS_PIX_FMT_NV12 = 0,
|
||||
RTS_PIX_FMT_NV16,
|
||||
RTS_PIX_FMT_YUYV,
|
||||
|
||||
RTS_PIX_FMT_1BPP = 0x100,
|
||||
RTS_PIX_FMT_GRAY_2,
|
||||
RTS_PIX_FMT_GRAY_4,
|
||||
RTS_PIX_FMT_GRAY_8,
|
||||
|
||||
RTS_PIX_FMT_RGB888 = 0x200,
|
||||
RTS_PIX_FMT_ARGB8888,
|
||||
|
||||
RTS_PIX_FMT_RGBA1111,
|
||||
RTS_PIX_FMT_RGBA2222,
|
||||
RTS_PIX_FMT_RGBA5551,
|
||||
RTS_PIX_FMT_RGBA4444,
|
||||
RTS_PIX_FMT_RGBA8888,
|
||||
|
||||
RTS_PIX_FMT_MJPEG = 0x300,
|
||||
RTS_PIX_FMT_H264
|
||||
};
|
||||
|
||||
int rts_get_bit_per_pixel(int pixelfmt);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,462 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsisp.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSISP_H
|
||||
#define _INCLUDE_RTSISP_H
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <rtscamkit.h>
|
||||
#include <rtsisp_def.h>
|
||||
|
||||
#define RTS_ISP_CMD_DATA_LIMIT 32
|
||||
|
||||
#define RTSOCIOC_ISPCMD 0x31
|
||||
|
||||
enum rts_isp_raw_fmt {
|
||||
rts_isp_raw_diable = 0,
|
||||
rts_isp_raw_blc_b = 0x1,
|
||||
rts_isp_raw_blc_a = 0x2,
|
||||
rts_isp_raw_lsc_a = 0x3,
|
||||
rts_isp_raw_dns_a = 0x4,
|
||||
rts_isp_raw_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_mem_rw {
|
||||
uint16_t addr;
|
||||
uint16_t length;
|
||||
uint8_t *pdata;
|
||||
};
|
||||
|
||||
enum rts_isp_i2c_mode {
|
||||
rts_isp_i2c_mode_general = 0,
|
||||
rts_isp_i2c_mode_random = 1,
|
||||
rts_isp_i2c_mode_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_i2c_rw {
|
||||
enum rts_isp_i2c_mode mode;
|
||||
uint8_t slave_id;
|
||||
uint8_t len;
|
||||
uint8_t data[8];
|
||||
};
|
||||
|
||||
struct rts_isp_sensor_reg {
|
||||
uint16_t addr;
|
||||
uint8_t len;
|
||||
uint8_t data[32];
|
||||
};
|
||||
|
||||
struct rts_isp_snr_fmt {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
enum {
|
||||
snr_fmt_raw8 = 0,
|
||||
snr_fmt_raw10,
|
||||
snr_fmt_raw12,
|
||||
snr_fmt_yuv,
|
||||
snr_fmt_reserved
|
||||
} fmt;
|
||||
};
|
||||
|
||||
struct rts_isp_scale_coeff {
|
||||
uint32_t scale_h;
|
||||
uint32_t scale_v;
|
||||
};
|
||||
|
||||
struct rts_isp_zoom_start {
|
||||
uint32_t start_x;
|
||||
uint32_t start_y;
|
||||
};
|
||||
|
||||
struct rts_isp_color_yuv {
|
||||
uint8_t y;
|
||||
uint8_t u;
|
||||
uint8_t v;
|
||||
};
|
||||
|
||||
struct rts_isp_grid_t {
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
uint16_t grid_width;
|
||||
uint16_t grid_height;
|
||||
uint8_t grid_rows;
|
||||
uint8_t grid_columns;
|
||||
};
|
||||
|
||||
struct rts_isp_rect_t {
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
int16_t end_x;
|
||||
int16_t end_y;
|
||||
};
|
||||
|
||||
struct rts_isp_grid_bitmap {
|
||||
uint16_t number;
|
||||
uint8_t bitmap[RTS_GRID_BITMAP_SIZE];
|
||||
};
|
||||
|
||||
struct rts_isp_md_data_fmt {
|
||||
enum {
|
||||
blc_output = 0, //raw data
|
||||
mlsc_output = 1, //raw data
|
||||
awb_output = 2, //raw data
|
||||
ccm_input = 4, //rgb data
|
||||
ccm_output = 5, //rgb data
|
||||
gamma_input = 6, //rgb data
|
||||
gamma_output = 7, //rgb data
|
||||
eeh_input = 8, //yuv422 data
|
||||
eeh_output = 9, //yuv422 data
|
||||
rgb2yuv_output = 0xc, //yuv444 data
|
||||
zoom_jpeg_output = 0x10, //yuv422 data
|
||||
zoom_full_hd_output = 0x11, //yuv422 data
|
||||
zoom_hd_output = 0x12, //yuv422 data
|
||||
zoom_vga_output = 0x13, //yuv422 data
|
||||
zoom_qvga_output = 0x14, //yuv422 data
|
||||
} data_format;
|
||||
|
||||
union {
|
||||
enum {
|
||||
raw_gr = 0,
|
||||
raw_r = 1,
|
||||
raw_b = 2,
|
||||
raw_gb = 3
|
||||
} raw_data;
|
||||
enum {
|
||||
rgb_r = 0,
|
||||
rgb_g = 1,
|
||||
rgb_b = 2,
|
||||
rgb_reserved
|
||||
} rgb_data;
|
||||
enum {
|
||||
yuv_y = 0,
|
||||
yuv_u = 1,
|
||||
yuv_v = 2,
|
||||
yuv_reserved
|
||||
} yuv_data;
|
||||
} data_element;
|
||||
};
|
||||
|
||||
struct rts_isp_device_desc {
|
||||
uint8_t length;
|
||||
uint8_t type;
|
||||
uint16_t hwversion;
|
||||
uint16_t fwversion;
|
||||
uint8_t streamnum;
|
||||
uint8_t frmivalnum;
|
||||
};
|
||||
|
||||
struct rts_isp_fw_version_t {
|
||||
uint8_t header;
|
||||
uint8_t len;
|
||||
uint32_t magictag;
|
||||
uint16_t ic_name;
|
||||
uint16_t vid;
|
||||
uint16_t pid;
|
||||
uint32_t fw_ver;
|
||||
uint32_t cus_ver;
|
||||
uint8_t reserved[12];
|
||||
};
|
||||
|
||||
struct rts_isp_dma_buffer {
|
||||
void *vm_addr;
|
||||
uint32_t length;
|
||||
uint32_t phy_addr;
|
||||
};
|
||||
|
||||
struct rts_isp_iq_table_attr {
|
||||
uint8_t version;
|
||||
uint16_t addr;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
struct rts_isp_3a_version {
|
||||
uint16_t main;
|
||||
uint8_t sub;
|
||||
};
|
||||
|
||||
struct rts_isp_3a_version_t {
|
||||
struct rts_isp_3a_version awb;
|
||||
struct rts_isp_3a_version ae;
|
||||
struct rts_isp_3a_version af;
|
||||
};
|
||||
|
||||
enum rts_isp_wdr_mode {
|
||||
wdr_disable = 0,
|
||||
wdr_manual,
|
||||
wdr_auto_weak,
|
||||
wdr_auto_medium,
|
||||
wdr_auto_strong,
|
||||
wdr_reserved
|
||||
};
|
||||
|
||||
struct rts_isp_api_version {
|
||||
uint8_t main;
|
||||
uint8_t sub;
|
||||
};
|
||||
|
||||
typedef const void *RtsRegInst;
|
||||
|
||||
int rts_isp_read_xmem(int fd, struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_write_xmem(int fd, struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_read_i2c(int fd, struct rts_isp_i2c_rw *pi2c);
|
||||
int rts_isp_write_i2c(int fd, struct rts_isp_i2c_rw *pi2c);
|
||||
int rts_isp_read_sensor_reg(int fd, struct rts_isp_sensor_reg *reg);
|
||||
int rts_isp_write_sensor_reg(int fd, struct rts_isp_sensor_reg *reg);
|
||||
|
||||
int rts_isp_get_md_count(int fd);
|
||||
int rts_isp_get_md_type(int fd, uint8_t mdidx);
|
||||
int rts_isp_set_md_enable(int fd, uint8_t mdidx, int enable);
|
||||
int rts_isp_get_md_enable(int fd, uint8_t mdidx, int *penable);
|
||||
int rts_isp_set_md_data_fmt(int fd, struct rts_isp_md_data_fmt *pfmt);
|
||||
int rts_isp_get_md_data_fmt(int fd, struct rts_isp_md_data_fmt *pfmt);
|
||||
int rts_isp_set_md_grid_bitmap(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_md_grid_bitmap(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_md_result(int fd, uint8_t mdidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_set_md_grid(int fd, unsigned int strmidx, uint8_t mdidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid(int fd, unsigned int strmidx, uint8_t mdidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect(int fd, uint8_t strmidx, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect(int fd, uint8_t strmidx, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_md_grid_absolute(int fd, uint8_t mdidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid_absolute(int fd, uint8_t mdidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect_absolute(int fd, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect_absolute(int fd, uint8_t mdidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_md_sensitivity(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_sensitivity(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_set_md_percentage(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_percentage(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_set_md_frame_interval(int fd, uint8_t mdidx, uint8_t val);
|
||||
int rts_isp_get_md_frame_interval(int fd, uint8_t mdidx, uint8_t *pval);
|
||||
int rts_isp_get_md_status(int fd, uint8_t mdidx);
|
||||
int rts_isp_get_mask_count(int fd);
|
||||
int rts_isp_set_md_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_md_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_md_rect_res(int fd, uint8_t mdidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_md_rect_res(int fd, uint8_t mdidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_type(int fd, uint8_t maskidx);
|
||||
int rts_isp_set_mask_enable(int fd, uint8_t maskidx, int enable);
|
||||
int rts_isp_get_mask_enable(int fd, uint8_t maskidx, int *penable);
|
||||
int rts_isp_set_mask_color(int fd, struct rts_isp_color_yuv *pcolor);
|
||||
int rts_isp_get_mask_color(int fd, struct rts_isp_color_yuv *pcolor);
|
||||
int rts_isp_set_mask_grid_bitmap(int fd, uint8_t maskidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_get_mask_grid_bitmap(int fd, uint8_t maskidx, struct rts_isp_grid_bitmap *pbitmap);
|
||||
int rts_isp_set_mask_grid(int fd, unsigned int strmidx, uint8_t maskidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid(int fd, unsigned int strmidx, uint8_t maskidx,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect(int fd, uint8_t strmidx, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect(int fd, uint8_t strmidx, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_mask_grid_absolute(int fd, uint8_t maskidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid_absolute(int fd, uint8_t maskidx, struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect_absolute(int fd, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect_absolute(int fd, uint8_t maskidx,
|
||||
struct rts_isp_rect_t *prect);
|
||||
int rts_isp_set_mask_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_get_mask_grid_res(int fd, uint16_t res_width, uint16_t res_height,
|
||||
struct rts_isp_grid_t *pgrid);
|
||||
int rts_isp_set_mask_rect_res(int fd, uint8_t maskidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
int rts_isp_get_mask_rect_res(int fd, uint8_t maskidx, uint16_t res_width,
|
||||
uint16_t res_height, struct rts_isp_rect_t *prect);
|
||||
|
||||
int rts_isp_get_device_des(int fd, struct rts_isp_device_desc *desc);
|
||||
int rts_isp_get_fw_version(int fd, struct rts_isp_fw_version_t *pversion);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_api_version
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_get_api_version(int fd, struct rts_isp_api_version *pversion);
|
||||
|
||||
int rts_isp_enable_ldc(int fd, uint8_t *ptable, unsigned int length);
|
||||
int rts_isp_disable_ldc(int fd);
|
||||
int rts_isp_get_ldc_state(int fd);
|
||||
|
||||
int rts_isp_enable_temporal_denoise(int fd, int enable);
|
||||
int rts_isp_get_temporal_denoise_state(int fd);
|
||||
|
||||
int rts_isp_set_dehaze(int fd, int enable);
|
||||
int rts_isp_get_dehaze(int fd);
|
||||
|
||||
int rts_isp_get_snr_fmt(int fd, struct rts_isp_snr_fmt *pfmt);
|
||||
int rts_isp_get_scale_coeff(int fd, uint8_t strmidx, struct rts_isp_scale_coeff *pcoeff);
|
||||
int rts_isp_get_zoom_start(int fd, uint8_t strmidx, struct rts_isp_zoom_start *pzoom);
|
||||
|
||||
|
||||
int rts_isp_set_raw(int fd,uint8_t streamid, enum rts_isp_raw_fmt raw_type);
|
||||
|
||||
int rts_isp_get_streamid(int fd);
|
||||
int rts_isp_get_stream_count();
|
||||
|
||||
unsigned long rts_isp_get_video_phy_addr(int fd, unsigned long vm_addr);
|
||||
|
||||
int rts_isp_ctrl_open();
|
||||
int rts_isp_ctrl_close(int fd);
|
||||
|
||||
int rts_isp_soc_attach();
|
||||
int rts_isp_soc_detach();
|
||||
|
||||
int rts_isp_mem_open(int oflag);
|
||||
void rts_isp_mem_close(int memfd);
|
||||
int rts_isp_mem_alloc(int memfd, struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_mem_free(int memfd, struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_alloc_dma(struct rts_isp_dma_buffer *buffer);
|
||||
int rts_isp_free_dma(struct rts_isp_dma_buffer *buffer);
|
||||
|
||||
int rts_reg_close(RtsRegInst reginst);
|
||||
int rts_reg_isp_open(RtsRegInst *reginst);
|
||||
int rts_reg_isp_close(RtsRegInst ispreg);
|
||||
int rts_reg_h264_open(RtsRegInst *reginst);
|
||||
int rts_reg_h264_close(RtsRegInst h264reg);
|
||||
int rts_reg_mjpg_open(RtsRegInst *reginst);
|
||||
int rts_reg_mjpg_close(RtsRegInst mjpgreg);
|
||||
int rts_reg_mjpg_reset(RtsRegInst mjpgreg);
|
||||
uint32_t rts_reg_read_reg(RtsRegInst reginst, unsigned int offset);
|
||||
void rts_reg_write_reg(RtsRegInst reginst,
|
||||
unsigned int offset, uint32_t val);
|
||||
void rts_reg_set_reg_bit(RtsRegInst reginst,
|
||||
unsigned int offset, uint8_t bit_idx);
|
||||
void rts_reg_clr_reg_bit(RtsRegInst reginst,
|
||||
unsigned int offset, uint8_t bit_idx);
|
||||
int rts_reg_get_handle(RtsRegInst reginst);
|
||||
unsigned int rts_reg_get_size(RtsRegInst reginst);
|
||||
|
||||
enum rts_isp_gray_mode {
|
||||
RTS_ISP_NON_GRAY_MODE = 0,
|
||||
RTS_ISP_GRAY_MODE = 1
|
||||
};
|
||||
|
||||
#define RTS_ISP_GPIO_NUM 8
|
||||
enum rts_isp_gpio_status {
|
||||
RTS_ISP_GPIO_IDLE = 0,
|
||||
RTS_ISP_GPIO_USED = 1
|
||||
};
|
||||
|
||||
enum rts_isp_gpio_direction {
|
||||
RTS_ISP_GPIO_INPUT = 0,
|
||||
RTS_ISP_GPIO_OUTPUT = 1
|
||||
};
|
||||
|
||||
enum rts_isp_gpio_value {
|
||||
RTS_ISP_GPIO_LOW = 0,
|
||||
RTS_ISP_GPIO_HIGH = 1
|
||||
};
|
||||
|
||||
int rts_isp_get_gray_mode(int fd, enum rts_isp_gray_mode *gray_mode);
|
||||
int rts_isp_set_gray_mode(int fd, enum rts_isp_gray_mode gray_mode);
|
||||
int rts_isp_get_gpio_use_status(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_status *status);
|
||||
int rts_isp_get_gpio_direction(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_direction *direction);
|
||||
int rts_isp_set_gpio_direction(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_direction direction);
|
||||
int rts_isp_get_gpio_value(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_value *value);
|
||||
int rts_isp_set_gpio_value(int fd, uint8_t gpio_idx,
|
||||
enum rts_isp_gpio_value value);
|
||||
|
||||
int rts_isp_set_crop_window(int fd, int strmid, struct rts_isp_rect_t *window);
|
||||
int rts_isp_get_iq_table_attr(int fd, struct rts_isp_iq_table_attr *attr);
|
||||
int rts_isp_get_3a_version(int fd, struct rts_isp_3a_version_t *version);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_wdr_mode
|
||||
*
|
||||
* mode : wdr mode
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_wdr_mode(int fd, enum rts_isp_wdr_mode mode);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_wdr_mode
|
||||
*
|
||||
* @return wdr mode, minus : fail
|
||||
*/
|
||||
int rts_isp_get_wdr_mode(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_wdr_level
|
||||
*
|
||||
* level : wdr level, 0 ~ 100, only when wdr mode equals to manual
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_wdr_level(int fd, int level);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_wdr_level
|
||||
*
|
||||
* @return wdr level, minus : fail
|
||||
*/
|
||||
int rts_isp_get_wdr_level(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_tpnr_level
|
||||
*
|
||||
* level : tpnr level, 0 ~ 100
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
*/
|
||||
int rts_isp_set_tpnr_level(int fd, int level);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_tpnr_level
|
||||
*
|
||||
* @return tpnr level, minus : fail
|
||||
*/
|
||||
int rts_isp_get_tpnr_level(int fd);
|
||||
|
||||
/*!
|
||||
* rts_isp_set_ir_mode
|
||||
*
|
||||
* enable 1 : enable IR mode, 0 : disable IR mode
|
||||
*
|
||||
* @return 0 : success, minus : fail
|
||||
* */
|
||||
int rts_isp_set_ir_mode(int fd, int enable);
|
||||
|
||||
/*!
|
||||
* rts_isp_get_ir_mode
|
||||
*
|
||||
* @return 0 : disable, 1 : enable, minus : fail
|
||||
* */
|
||||
int rts_isp_get_ir_mode(int fd);
|
||||
|
||||
int rts_isp_get_ae_gain(int fd, struct rts_isp_ae_gain *gain);
|
||||
int rts_isp_set_ae_gain(int fd, struct rts_isp_ae_gain *gain);
|
||||
int rts_isp_get_ae_weight(int fd, struct rts_isp_ae_weight *weight);
|
||||
int rts_isp_set_ae_weight(int fd, struct rts_isp_ae_weight *weight);
|
||||
int rts_isp_get_ae_statis(int fd, struct rts_isp_ae_statis *statis);
|
||||
int rts_isp_get_awb_statis(int fd, struct rts_isp_awb_statis *statis);
|
||||
int rts_isp_get_awb_ct_gain(int fd, int ct, struct rts_isp_awb_ct_gain *gain);
|
||||
int rts_isp_get_ae_target_delta(int fd, int8_t *delta);
|
||||
int rts_isp_set_ae_target_delta(int fd, int8_t delta);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* libs/rtsisp/rtsisp_cmdcode.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LIBS_RTSISP_RTSISP_CMDCODE_H
|
||||
#define _LIBS_RTSISP_RTSISP_CMDCODE_H
|
||||
|
||||
#define RTS_ISP_CMD_XMEM_R ((0x00 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_XMEM_W ((0x00 << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_I2C_R ((0x00 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_I2C_W ((0x00 << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_READ_SENSOR_REG ((0x00 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_WRITE_SENSOR_REG ((0x00 << 8) | 0x03)
|
||||
|
||||
#define RTS_ISP_CMD_GET_DEVICE_DES ((0x01 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_GET_FW_VERSION ((0x01 << 8) | 0x88)
|
||||
#define RTS_ISP_CMD_GET_API_VERSION ((0x01 << 8) | 0x8a)
|
||||
|
||||
#define RTS_ISP_CMD_SET_OUTPUT_FMT ((0x02 << 8) | 0x04)
|
||||
#define RTS_ISP_CMD_SET_CROP_WINDOW ((0x02 << 8) | 0x08)
|
||||
|
||||
#define RTS_ISP_CMD_GET_SNR_FMT ((0x06 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_GET_SCALE_COEFF ((0x06 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_GET_ZOOM_START ((0x06 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_SET_MTD_ENABLE ((0x07 << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_GET_MTD_ENABLE ((0x07 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_MTD_DAT_FMT ((0x07 << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_MTD_DAT_FMT ((0x07 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_SET_MTD_GRID_MASK ((0x07 << 8) | 0x03)
|
||||
#define RTS_ISP_CMD_GET_MTD_GRID_MASK ((0x07 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_SET_MTD_GRID ((0x07 << 8) | 0x04)
|
||||
#define RTS_ISP_CMD_GET_MTD_GRID ((0x07 << 8) | 0x84)
|
||||
#define RTS_ISP_CMD_SET_MTD_RECT ((0x07 << 8) | 0x05)
|
||||
#define RTS_ISP_CMD_GET_MTD_RECT ((0x07 << 8) | 0x85)
|
||||
#define RTS_ISP_CMD_SET_MTD_GRID_ABS ((0x07 << 8) | 0x06)
|
||||
#define RTS_ISP_CMD_GET_MTD_GRID_ABS ((0x07 << 8) | 0x86)
|
||||
#define RTS_ISP_CMD_SET_MTD_RECT_ABS ((0x07 << 8) | 0x07)
|
||||
#define RTS_ISP_CMD_GET_MTD_RECT_ABS ((0x07 << 8) | 0x87)
|
||||
#define RTS_ISP_CMD_SET_MTD_SENSITIVITY ((0x07 << 8) | 0x08)
|
||||
#define RTS_ISP_CMD_GET_MTD_SENSITIVITY ((0x07 << 8) | 0x88)
|
||||
#define RTS_ISP_CMD_SET_MTD_PERCENTAGE ((0x07 << 8) | 0x09)
|
||||
#define RTS_ISP_CMD_GET_MTD_PERCENTAGE ((0x07 << 8) | 0x89)
|
||||
#define RTS_ISP_CMD_SET_MTD_FRM_INTVAL ((0x07 << 8) | 0x0a)
|
||||
#define RTS_ISP_CMD_GET_MTD_FRM_INTVAL ((0x07 << 8) | 0x8a)
|
||||
#define RTS_ISP_CMD_SET_MTD_GRID_RES ((0x07 << 8) | 0x0b)
|
||||
#define RTS_ISP_CMD_GET_MTD_GRID_RES ((0x07 << 8) | 0x8b)
|
||||
#define RTS_ISP_CMD_SET_MTD_RECT_RES ((0x07 << 8) | 0x0c)
|
||||
#define RTS_ISP_CMD_GET_MTD_RECT_RES ((0x07 << 8) | 0x8c)
|
||||
#define RTS_ISP_CMD_GET_MTD_RESULT ((0x07 << 8) | 0x8d)
|
||||
|
||||
#define RTS_ISP_CMD_SET_OSD_LIB_CHAR_ATTR ((0x08 << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_GET_OSD_LIB_CHAR_ATTR ((0x08 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_OSD_CHINESE_ADDR ((0x08 << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_OSD_CHINESE_ADDR ((0x08 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_DATE_EN ((0x08 << 8) | 0x03)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_DATE_EN ((0x08 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_DATE_DISP_CFG ((0x08 << 8) | 0x04)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_DATE_DISP_CFG ((0x08 << 8) | 0x84)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_FMT ((0x08 << 8) | 0x05)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_FMT ((0x08 << 8) | 0x85)
|
||||
#define RTS_ISP_CMD_SET_OSD_CUR_TIME ((0x08 << 8) | 0x06)
|
||||
#define RTS_ISP_CMD_SET_OSD_CUR_DATE ((0x08 << 8) | 0x07)
|
||||
#define RTS_ISP_CMD_SET_OSD_NEXT_DATE ((0x08 << 8) | 0x08)
|
||||
#define RTS_ISP_CMD_SET_OSD_BLK_EN ((0x08 << 8) | 0x09)
|
||||
#define RTS_ISP_CMD_GET_OSD_BLK_EN ((0x08 << 8) | 0x89)
|
||||
#define RTS_ISP_CMD_SET_OSD_BLK_ATTR ((0x08 << 8) | 0x0a)
|
||||
#define RTS_ISP_CMD_GET_OSD_BLK_ATTR ((0x08 << 8) | 0x8a)
|
||||
#define RTS_ISP_CMD_WRITE_OSD_MEM ((0x08 << 8) | 0x0b)
|
||||
#define RTS_ISP_CMD_READ_OSD_MEM ((0x08 << 8) | 0x8b)
|
||||
#define RTS_ISP_CMD_GET_OSD_MEM_SIZE ((0x08 << 8) | 0x8c)
|
||||
|
||||
#define RTS_ISP_CMD_SET_MASK_ENABLE ((0x09 << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_GET_MASK_ENABLE ((0x09 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_MASK_COLOR ((0x09 << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_MASK_COLOR ((0x09 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_SET_MASK_GRID_BITMAP ((0x09 << 8) | 0x03)
|
||||
#define RTS_ISP_CMD_GET_MASK_GRID_BITMAP ((0x09 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_SET_MASK_GRID ((0x09 << 8) | 0x04)
|
||||
#define RTS_ISP_CMD_GET_MASK_GRID ((0x09 << 8) | 0x84)
|
||||
#define RTS_ISP_CMD_SET_MASK_RECT ((0x09 << 8) | 0x05)
|
||||
#define RTS_ISP_CMD_GET_MASK_RECT ((0x09 << 8) | 0x85)
|
||||
#define RTS_ISP_CMD_SET_MASK_GRID_ABSOLUTE ((0x09 << 8) | 0x06)
|
||||
#define RTS_ISP_CMD_GET_MASK_GRID_ABSOLUTE ((0x09 << 8) | 0x86)
|
||||
#define RTS_ISP_CMD_SET_MASK_RECT_ABSOLUTE ((0x09 << 8) | 0x07)
|
||||
#define RTS_ISP_CMD_GET_MASK_RECT_ABSOLUTE ((0x09 << 8) | 0x87)
|
||||
#define RTS_ISP_CMD_SET_MASK_GRID_RES ((0x09 << 8) | 0x08)
|
||||
#define RTS_ISP_CMD_GET_MASK_GRID_RES ((0x09 << 8) | 0x88)
|
||||
#define RTS_ISP_CMD_SET_MASK_RECT_RES ((0x09 << 8) | 0x09)
|
||||
#define RTS_ISP_CMD_GET_MASK_RECT_RES ((0x09 << 8) | 0x89)
|
||||
|
||||
#define RTS_ISP_CMD_SET_ISP_FUN_ENABLE ((0x0a << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_GET_ISP_FUN_ENABLE ((0x0a << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_ISP_GRAY_MODE ((0x0a << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_ISP_GRAY_MODE ((0x0a << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_GET_IQ_TABLE_ATTR ((0x0a << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_GET_3A_VERSION ((0x0a << 8) | 0x84)
|
||||
#define RTS_ISP_CMD_SET_WDR_MODE ((0x0a << 8) | 0x05)
|
||||
#define RTS_ISP_CMD_GET_WDR_MODE ((0x0a << 8) | 0x85)
|
||||
#define RTS_ISP_CMD_SET_WDR_LEVEL ((0x0a << 8) | 0x06)
|
||||
#define RTS_ISP_CMD_GET_WDR_LEVEL ((0x0a << 8) | 0x86)
|
||||
#define RTS_ISP_CMD_SET_TPNR_LEVEL ((0x0a << 8) | 0x07)
|
||||
#define RTS_ISP_CMD_GET_TPNR_LEVEL ((0x0a << 8) | 0x87)
|
||||
#define RTS_ISP_CMD_SET_IR_MODE ((0x0a << 8) | 0x08)
|
||||
#define RTS_ISP_CMD_GET_IR_MODE ((0x0a << 8) | 0x88)
|
||||
#define RTS_ISP_CMD_GET_AE_GAIN ((0x0a << 8) | 0x89)
|
||||
#define RTS_ISP_CMD_SET_AE_GAIN ((0x0a << 8) | 0x09)
|
||||
#define RTS_ISP_CMD_GET_AE_WEIGHT ((0x0a << 8) | 0x8a)
|
||||
#define RTS_ISP_CMD_SET_AE_WEIGHT ((0x0a << 8) | 0x0a)
|
||||
#define RTS_ISP_CMD_GET_AE_STATIS ((0x0a << 8) | 0x8b)
|
||||
#define RTS_ISP_CMD_GET_AWB_STATIS ((0x0a << 8) | 0x8c)
|
||||
#define RTS_ISP_CMD_GET_AWB_CT_GAIN ((0x0a << 8) | 0x8d)
|
||||
#define RTS_ISP_CMD_GET_AT_TARGET_DELTA ((0x0a << 8) | 0x8e)
|
||||
#define RTS_ISP_CMD_SET_AT_TARGET_DELTA ((0x0a << 8) | 0x0e)
|
||||
|
||||
#define RTS_ISP_CMD_GET_FT2_ISP_STATIS ((0x0b << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_GET_GPIO_USE_STATUS ((0x0c << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_GPIO_DIR ((0x0c << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_GPIO_DIR ((0x0c << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_SET_GPIO_VALUE ((0x0c << 8) | 0x03)
|
||||
#define RTS_ISP_CMD_GET_GPIO_VALUE ((0x0c << 8) | 0x83)
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* include/rtsisp_def.h
|
||||
*
|
||||
* Copyright (C) 2016 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _INCLUDE_RTSISP_DEF_H
|
||||
#define _INCLUDE_RTSISP_DEF_H
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define RTS_ISP_GRID_MAX_NUM (1200)
|
||||
#define RTS_GRID_BITMAP_SIZE ((RTS_ISP_GRID_MAX_NUM + 7) / 8)
|
||||
|
||||
#define RTS_ISP_AE_WINDOW_NUM 25
|
||||
#define RTS_ISP_AWB_WINDOW_NUM 25
|
||||
|
||||
#define RTS_ISP_AE_GAIN_UNIT 256
|
||||
|
||||
enum rts_isp_blk_type {
|
||||
RTS_ISP_BLK_TYPE_UNDEFINED = 0,
|
||||
RTS_ISP_BLK_TYPE_RECT = 1,
|
||||
RTS_ISP_BLK_TYPE_GRID,
|
||||
};
|
||||
|
||||
enum {
|
||||
RTS_ISP_AE_AUTO = 0,
|
||||
RTS_ISP_AE_MANUAL = 1
|
||||
};
|
||||
|
||||
enum {
|
||||
RTS_ISP_AWB_TEMPERATURE = 0,
|
||||
RTS_ISP_AWB_AUTO = 1,
|
||||
RTS_ISP_AWB_COMPONENT
|
||||
};
|
||||
|
||||
struct rts_isp_ae_gain {
|
||||
uint16_t analog;
|
||||
uint16_t digital;
|
||||
uint16_t isp_digital;
|
||||
};
|
||||
|
||||
struct rts_isp_ae_weight {
|
||||
uint8_t weights[RTS_ISP_AE_WINDOW_NUM];
|
||||
};
|
||||
|
||||
struct rts_isp_ae_statis {
|
||||
uint8_t y_mean;
|
||||
uint8_t y_means[RTS_ISP_AE_WINDOW_NUM];
|
||||
uint16_t statis[64];
|
||||
};
|
||||
|
||||
struct rts_isp_awb_statis {
|
||||
uint8_t r_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
uint8_t g_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
uint8_t b_means[RTS_ISP_AWB_WINDOW_NUM];
|
||||
};
|
||||
|
||||
enum rts_isp_color_temperature {
|
||||
RTS_ISP_CT_2800K = 0, /*A*/
|
||||
RTS_ISP_CT_3000K, /*U30*/
|
||||
RTS_ISP_CT_4000K, /*CWF*/
|
||||
RTS_ISP_CT_5000K, /*D50*/
|
||||
RTS_ISP_CT_6500K, /*D65*/
|
||||
RTS_ISP_CT_7500K, /*D75*/
|
||||
RTS_ISP_CT_RESERVED
|
||||
};
|
||||
|
||||
struct rts_isp_awb_ct_gain {
|
||||
uint8_t r_gain;
|
||||
uint8_t b_gain;
|
||||
};
|
||||
|
||||
typedef enum RS_PIXEL_FORMAT_E {
|
||||
|
||||
PIXEL_FORMAT_RGB_1BPP = 0,
|
||||
PIXEL_FORMAT_RGB_1555,
|
||||
} PIXEL_FORMAT_E;
|
||||
|
||||
typedef struct RS_BITMAP_S {
|
||||
PIXEL_FORMAT_E pixel_fmt;
|
||||
uint32_t u32Width;
|
||||
uint32_t u32Height;
|
||||
void *pData;
|
||||
} BITMAP_S;
|
||||
|
||||
enum {
|
||||
RTS_ISP_PWR_FREQUENCY_DISABLED = 0,
|
||||
RTS_ISP_PWR_FREQUENCY_50HZ = 1,
|
||||
RTS_ISP_PWR_FREQUENCY_60HZ = 2,
|
||||
RTS_ISP_PWR_FREQUENCY_AUTO = 3
|
||||
};
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* libs/include/rtsosd.h
|
||||
*
|
||||
* Copyright (C) 2014 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _LIBS_INCLUDE_RTSOSD_H
|
||||
#define _LIBS_INCLUDE_RTSOSD_H
|
||||
|
||||
#include <rtscolor.h>
|
||||
#include <rtsisp_def.h>
|
||||
|
||||
#define RTS_OSD_MIN_GAP 2
|
||||
|
||||
enum rts_osd_char_rotation {
|
||||
osd_char_rotation_0 = 0,
|
||||
osd_char_rotation_90 = 1,
|
||||
osd_char_rotation_180 = 2,
|
||||
osd_char_rotation_270 = 3
|
||||
};
|
||||
|
||||
|
||||
enum rts_osd_time_fmt {
|
||||
osd_time_fmt_no = 0, /*not show time*/
|
||||
osd_time_fmt_24,
|
||||
osd_time_fmt_12,
|
||||
osd_time_fmt_12_1,
|
||||
osd_time_fmt_12_2,
|
||||
osd_time_fmt_12_3,
|
||||
osd_time_fmt_12_4,
|
||||
osd_time_fmt_12_5,
|
||||
osd_time_fmt_12_6,
|
||||
osd_time_fmt_12_7,
|
||||
osd_time_fmt_reserved
|
||||
};
|
||||
|
||||
enum rts_osd_date_fmt {
|
||||
osd_date_fmt_no = 0, /*not show date*/
|
||||
osd_date_fmt_0, /*dd/MM/yyyy, eg. 26/05/2015*/
|
||||
osd_date_fmt_1, /*dd/MM/yy, eg. 26/05/15*/
|
||||
osd_date_fmt_2, /*d/M/yy, eg. 26/5/15*/
|
||||
osd_date_fmt_3, /*M/d/yyyy, eg. 5/26/2015*/
|
||||
osd_date_fmt_4, /*M/d/yy, eg. 5/26/15*/
|
||||
osd_date_fmt_5, /*MM/dd/yy, eg. 05/26/15*/
|
||||
osd_date_fmt_6, /*MM/dd/yyyy, eg. 05/26/2015*/
|
||||
osd_date_fmt_7, /*yyyy/M/d, eg. 2015/5/26*/
|
||||
osd_date_fmt_8, /*yyyy-M-d, eg. 2015-5-26*/
|
||||
osd_date_fmt_9, /*yyyy-MM-dd, eg. 2015-05-26*/
|
||||
osd_date_fmt_10, /*yyyy/MM/dd, eg. 2015/05/26*/
|
||||
osd_date_fmt_11, /*yy-MM-dd, eg. 15-05-26*/
|
||||
osd_date_fmt_12, /*yy/M/d, eg. 15/5/26*/
|
||||
osd_date_fmt_13, /*yy-M-d, eg. 15-5-26*/
|
||||
osd_date_fmt_14, /*yy/MM/dd, eg. 15/05/26*/
|
||||
osd_date_fmt_15, /*yyyy.mm.dd, eg. 2015.05.26*/
|
||||
osd_date_fmt_16, /*dd.mm.yyyy, eg. 26.05.2015*/
|
||||
osd_date_fmt_17, /*mm.dd.yyyy, eg. 05.26.2015*/
|
||||
osd_date_fmt_18, /*mm-dd-yyyy, eg. 05-26-2015*/
|
||||
osd_date_fmt_19, /*dd-mm-yyyy, eg. 26-05-2015*/
|
||||
osd_date_fmt_reserved
|
||||
};
|
||||
|
||||
enum osd_char_type {
|
||||
char_type_single = 0,
|
||||
char_type_double = 1,
|
||||
char_type_picture = 2
|
||||
};
|
||||
|
||||
struct rts_osd_char_t {
|
||||
enum osd_char_type char_type;
|
||||
unsigned char char_value[4];
|
||||
};
|
||||
|
||||
struct rts_osd_text_t {
|
||||
struct rts_osd_char_t *content;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
struct rts_osd_datetime_t {
|
||||
enum rts_osd_time_fmt time_fmt;
|
||||
uint8_t time_blkidx;
|
||||
int time_pos;
|
||||
enum rts_osd_date_fmt date_fmt;
|
||||
uint8_t date_blkidx;
|
||||
int date_pos;
|
||||
};
|
||||
|
||||
struct rts_osd_rect_t {
|
||||
uint16_t start_x;
|
||||
uint16_t start_y;
|
||||
uint16_t end_x;
|
||||
uint16_t end_y;
|
||||
};
|
||||
|
||||
struct rts_osd_attr_t {
|
||||
uint8_t h_gap:4;
|
||||
uint8_t v_gap:4;
|
||||
uint8_t bg_enable; /*0 : no show, others : show*/
|
||||
rts_color bg_color;
|
||||
rts_color ch_color;
|
||||
uint8_t flick_enable;
|
||||
uint8_t flick_freq;
|
||||
uint8_t char_color_thd;
|
||||
uint8_t char_color_inc;
|
||||
uint8_t char_color_alpha;
|
||||
uint8_t stroke_enable; /* 1:enable char stroke, 0: disable*/
|
||||
uint8_t stroke_direct; /* 0:minus inc, 1:add inc */
|
||||
uint8_t stroke_inc;
|
||||
};
|
||||
|
||||
struct rts_osd_lib_info {
|
||||
enum osd_char_type char_type;
|
||||
uint16_t char_width;
|
||||
uint16_t char_height;
|
||||
uint8_t font_type;
|
||||
uint8_t font_size;
|
||||
uint8_t coding_fmt;
|
||||
uint8_t char_num;
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
* rts_new_osd : new a realtek osd object
|
||||
*
|
||||
* @fd : device handle, returned by open
|
||||
*
|
||||
* @strmidx : stream index
|
||||
*
|
||||
* return value : the pointer of the osd object when success, or NULL when fail
|
||||
*
|
||||
* */
|
||||
void *rts_new_osd(int fd, uint8_t strmidx);
|
||||
|
||||
/*
|
||||
* rts_delete_osd : delete the osd object
|
||||
*
|
||||
* @p : returned by rts_new_osd
|
||||
*
|
||||
* */
|
||||
void rts_delete_osd(void *p);
|
||||
|
||||
/*
|
||||
* rts_osd_add_font_lib : add lattice from file
|
||||
*
|
||||
* @p : returned by rts_new_osd
|
||||
*
|
||||
* @filename : lib file name
|
||||
*
|
||||
* return value : the index of font lib when success, or minus when fail
|
||||
*
|
||||
* */
|
||||
int rts_osd_add_font_lib(void *p, const char *filename, struct rts_osd_lib_info *pinfo);
|
||||
int rts_osd_rm_font_lib(void *p, int index);
|
||||
|
||||
int rts_osd_show_text(void *p, uint8_t blkidx, struct rts_osd_text_t *ptext);
|
||||
int rts_osd_show_picture(void *p, uint8_t blkidx, int picidx);// __attribute__ ((deprecated));
|
||||
int rts_osd_show_datetime(void *p, struct rts_osd_datetime_t *pdatetime);
|
||||
int rts_osd_cancel(void *p, uint8_t blkidx);
|
||||
int rts_osd_set_position(void *p, uint8_t blkidx, struct rts_osd_rect_t *pos);
|
||||
int rts_osd_get_position(void *p, uint8_t blkidx, struct rts_osd_rect_t *pos);
|
||||
int rts_osd_set_attr(void *p, uint8_t blkidx, struct rts_osd_attr_t *pattr);
|
||||
int rts_osd_get_attr(void *p, uint8_t blkidx, struct rts_osd_attr_t *pattr);
|
||||
|
||||
int rts_osd_get_block_number(void *p);
|
||||
int rts_osd_set_rotate(void *p, uint8_t _rotate);
|
||||
int rts_osd_set_font_size(void *p, uint8_t osd_w, uint8_t osd_h);
|
||||
int rts_osd_get_font_size(void *p, uint8_t *p_osd_char_w, uint8_t *p_osd_char_h);
|
||||
|
||||
int rts_osd_set_bitmap(void *p, uint8_t blkidx, const BITMAP_S *pstBitmap);
|
||||
|
||||
int rts_osd_refresh_datetime(void *p);
|
||||
int rts_osd_get_time_length(enum rts_osd_time_fmt time_fmt);
|
||||
int rts_osd_get_date_length(enum rts_osd_date_fmt date_fmt);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Realtek Semiconductor Corp.
|
||||
*
|
||||
* rtsosd/rtsosd_cmd.h
|
||||
*
|
||||
* Copyright (C) 2016 Ming Qian<ming_qian@realsil.com.cn>
|
||||
*/
|
||||
#ifndef _RTSOSD_RTSOSD_CMD_H
|
||||
#define _RTSOSD_RTSOSD_CMD_H
|
||||
#include <stdint.h>
|
||||
//#include <rtsisp_hwver.h>
|
||||
#include "rtsosd.h"
|
||||
|
||||
#if 0
|
||||
#define __OSD_PRE_CHECK() do {\
|
||||
struct rts_isp_hw_id hw_id = rts_get_hw_id();\
|
||||
if (RTS_HW_ID_VER_RTS3901 != hw_id.hw_ver &&\
|
||||
RTS_HW_ID_VER_RLE0745 != hw_id.hw_ver) {\
|
||||
RTS_ERR("only 0745/3901 support rtsosd, pls use rtosd2\n");\
|
||||
RTS_ASSERT(0);\
|
||||
}\
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
#define RTS_ISP_CMD_SET_OSD_LIB_CHAR_ATTR ((0x08 << 8) | 0x01)
|
||||
#define RTS_ISP_CMD_GET_OSD_LIB_CHAR_ATTR ((0x08 << 8) | 0x81)
|
||||
#define RTS_ISP_CMD_SET_OSD_CHINESE_ADDR ((0x08 << 8) | 0x02)
|
||||
#define RTS_ISP_CMD_GET_OSD_CHINESE_ADDR ((0x08 << 8) | 0x82)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_DATE_EN ((0x08 << 8) | 0x03)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_DATE_EN ((0x08 << 8) | 0x83)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_DATE_DISP_CFG ((0x08 << 8) | 0x04)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_DATE_DISP_CFG ((0x08 << 8) | 0x84)
|
||||
#define RTS_ISP_CMD_SET_OSD_TIME_FMT ((0x08 << 8) | 0x05)
|
||||
#define RTS_ISP_CMD_GET_OSD_TIME_FMT ((0x08 << 8) | 0x85)
|
||||
#define RTS_ISP_CMD_SET_OSD_CUR_TIME ((0x08 << 8) | 0x06)
|
||||
#define RTS_ISP_CMD_SET_OSD_CUR_DATE ((0x08 << 8) | 0x07)
|
||||
#define RTS_ISP_CMD_SET_OSD_NEXT_DATE ((0x08 << 8) | 0x08)
|
||||
#define RTS_ISP_CMD_SET_OSD_BLK_EN ((0x08 << 8) | 0x09)
|
||||
#define RTS_ISP_CMD_GET_OSD_BLK_EN ((0x08 << 8) | 0x89)
|
||||
#define RTS_ISP_CMD_SET_OSD_BLK_ATTR ((0x08 << 8) | 0x0a)
|
||||
#define RTS_ISP_CMD_GET_OSD_BLK_ATTR ((0x08 << 8) | 0x8a)
|
||||
#define RTS_ISP_CMD_WRITE_OSD_MEM ((0x08 << 8) | 0x0b)
|
||||
#define RTS_ISP_CMD_READ_OSD_MEM ((0x08 << 8) | 0x8b)
|
||||
#define RTS_ISP_CMD_GET_OSD_MEM_SIZE ((0x08 << 8) | 0x8c)
|
||||
|
||||
struct rts_isp_osd_lib_char_attr {
|
||||
uint8_t osd_char_width;
|
||||
uint8_t osd_char_height;
|
||||
enum rts_osd_char_rotation osd_char_rotation;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_timedate_enable {
|
||||
uint8_t timeenable : 1,
|
||||
dateenable : 1;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_timedata_disp_cfg {
|
||||
uint8_t time_blkidx;
|
||||
uint8_t time_startpos;
|
||||
uint8_t time_length;
|
||||
uint8_t date_blkidx;
|
||||
uint8_t date_startpos;
|
||||
uint8_t date_length;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_time_fmt {
|
||||
enum {
|
||||
osd_hour_fmt_24 = 0,
|
||||
osd_hour_fmt_12 = 1
|
||||
} hour_fmt;
|
||||
enum {
|
||||
osd_ampm_fmt_none = 0,
|
||||
osd_ampm_fmt_n1 = 1,
|
||||
osd_ampm_fmt_n2 = 2,
|
||||
osd_ampm_fmt_n3 = 3,
|
||||
osd_ampm_fmt_p8 = 4,
|
||||
osd_ampm_fmt_p9 = 5,
|
||||
osd_ampm_fmt_p10 = 6,
|
||||
osd_ampm_fmt_p11 = 7
|
||||
} ampm_fmt;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_time_t {
|
||||
uint8_t hour;
|
||||
uint8_t minute;
|
||||
uint8_t second;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_date_t {
|
||||
uint16_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_date_ex {
|
||||
uint8_t content[32];
|
||||
uint8_t length;
|
||||
};
|
||||
|
||||
struct rts_isp_osd_blk_attr {
|
||||
struct rts_isp_rect_t rect;
|
||||
enum {
|
||||
addressing_direct = 0,
|
||||
addressing_indirect
|
||||
} addressing_method;
|
||||
uint16_t byte_addr;
|
||||
uint8_t char_width;
|
||||
uint8_t char_height;
|
||||
uint8_t h_gap : 4,
|
||||
v_gap : 4;
|
||||
uint8_t char_num;
|
||||
uint8_t row_num;
|
||||
enum {
|
||||
bg_noshow = 0,
|
||||
bg_show = 1,
|
||||
} bg_enable;
|
||||
struct rts_isp_color_yuv bg_color;
|
||||
struct rts_isp_color_yuv char_color;
|
||||
uint8_t flick_enable : 1,
|
||||
flick_freq : 3;
|
||||
uint8_t char_color_thd;
|
||||
uint8_t char_color_inc;
|
||||
uint8_t char_color_alpha;
|
||||
uint8_t char_stroke_enable: 1,
|
||||
char_stroke_direct: 1;
|
||||
uint8_t char_stroke_inc;
|
||||
};
|
||||
|
||||
int rts_isp_set_osd_lib_char_attr(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_lib_char_attr *pattr);
|
||||
int rts_isp_get_osd_lib_char_attr(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_lib_char_attr *pattr);
|
||||
int rts_isp_set_osd_chinese_addr(int fd, uint8_t strmidx, uint16_t byte_addr);
|
||||
int rts_isp_get_osd_chinese_addr(int fd, uint8_t strmidx,
|
||||
uint16_t *pbyte_addr);
|
||||
int rts_isp_set_osd_time_date_en(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_timedate_enable *penable);
|
||||
int rts_isp_get_osd_time_date_en(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_timedate_enable *penable);
|
||||
int rts_isp_set_osd_time_date_display_cfg(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_timedata_disp_cfg *pcfg);
|
||||
int rts_isp_get_osd_time_date_display_cfg(int fd, uint8_t strmidx,
|
||||
struct rts_isp_osd_timedata_disp_cfg *pcfg);
|
||||
int rts_isp_set_osd_time_fmt(int fd, struct rts_isp_osd_time_fmt *pfmt);
|
||||
int rts_isp_get_osd_time_fmt(int fd, struct rts_isp_osd_time_fmt *pfmt);
|
||||
int rts_isp_set_osd_cur_time(int fd, struct rts_isp_osd_time_t *ptime);
|
||||
int rts_isp_set_osd_cur_date_ex(int fd, struct rts_isp_osd_date_ex *pdate);
|
||||
int rts_isp_set_osd_cur_date(int fd, struct rts_isp_osd_date_t *pdate);
|
||||
int rts_isp_set_osd_next_date_ex(int fd, struct rts_isp_osd_date_ex *pdate);
|
||||
int rts_isp_set_osd_next_date(int fd, struct rts_isp_osd_date_t *pdate);
|
||||
int rts_isp_get_osd_count(int fd);
|
||||
int rts_isp_set_osd_blk_enable(int fd, uint8_t strmidx, uint8_t blkidx,
|
||||
int enable);
|
||||
int rts_isp_get_osd_blk_enable(int fd, uint8_t strmidx, uint8_t blkidx,
|
||||
int *penable);
|
||||
int rts_isp_disable_osd(int fd, uint8_t strmidx);
|
||||
int rts_isp_set_osd_blk_attr(int fd, uint8_t strmidx, uint8_t blkidx,
|
||||
struct rts_isp_osd_blk_attr *pattr);
|
||||
int rts_isp_get_osd_blk_attr(int fd, uint8_t strmidx, uint8_t blkidx,
|
||||
struct rts_isp_osd_blk_attr *pattr);
|
||||
int rts_isp_write_osd_mem(int fd, uint8_t strmidx,
|
||||
struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_read_osd_mem(int fd, uint8_t strmidx,
|
||||
struct rts_isp_mem_rw *pmem);
|
||||
int rts_isp_get_osd_mem_size(int fd, uint8_t strmidx, uint16_t *psize);
|
||||
|
||||
|
||||
int rts_test();
|
||||
#endif
|
||||
144
sdk/component/common/drivers/video/realtek/common/isp_api.h
Normal file
144
sdk/component/common/drivers/video/realtek/common/isp_api.h
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
#ifndef ISP_API_V2_H
|
||||
#define ISP_API_V2_H
|
||||
|
||||
#define ISP_API_VER 2
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define HW_TIMESTAMP_BUF_SIZE 96//stream_num(3)*hw_slot_num(4)*buffer_zie(8)
|
||||
//#define MAX_FPS 30 //Only support the follow fps [30 15 10 5 1]
|
||||
|
||||
#define _MMF_DBG_ISP_ 0x00000004
|
||||
|
||||
#define ISP_PIN_SEL_S0 (0)
|
||||
#define ISP_PIN_SEL_S1 (1)
|
||||
|
||||
#define ISP_MAX_BUFFER_COUNT 6
|
||||
#define ISP_DISABLE 0
|
||||
#define ISP_ENABLE 1
|
||||
|
||||
#define ISP_FORMAT_YUV420_SEMIPLANAR 0x01
|
||||
#define ISP_FORMAT_YUV422_SEMIPLANAR 0x02
|
||||
#define ISP_FORMAT_BAYER_PATTERN 0x03
|
||||
|
||||
//Sensor Clock setting
|
||||
#define ISP_FREQ_74_25 (0)
|
||||
#define ISP_FREQ_37_125 (1)
|
||||
#define ISP_FREQ_54 (2)
|
||||
#define ISP_FREQ_27 (3)
|
||||
#define ISP_FREQ_24 (4)
|
||||
#define ISP_FREQ_12 (5)
|
||||
|
||||
#define LDC_OFF (0)
|
||||
#define LDC_ON (1)
|
||||
|
||||
|
||||
|
||||
extern uint32_t ConfigDebugMmfErr;
|
||||
|
||||
#define ISP_PRINTK rt_printf
|
||||
#define ISP_DBG_ERROR(...) \
|
||||
do { \
|
||||
if (ConfigDebugMmfErr&_MMF_DBG_ISP_) \
|
||||
ISP_PRINTK("\n\r" ISP_ERR_PREFIX __VA_ARGS__); \
|
||||
}while(0)
|
||||
|
||||
// for h264 encoder (V1)
|
||||
// TODO: Remove this after V2 stable
|
||||
struct isp_info{
|
||||
uint32_t streamid;
|
||||
uint32_t hw_slot;
|
||||
uint32_t sw_slot;
|
||||
};
|
||||
|
||||
#define MOTION_SIZE 5
|
||||
|
||||
typedef struct isp_init_cfg_s {
|
||||
int pin_idx;
|
||||
void (*motion_detection[MOTION_SIZE])(void*);
|
||||
void *motion_detection_arg[MOTION_SIZE];
|
||||
unsigned char *isp_addr;
|
||||
int clk;
|
||||
int ldc;
|
||||
int fps;
|
||||
} isp_init_cfg_t;
|
||||
|
||||
typedef struct isp_cfg_s{
|
||||
int isp_id;
|
||||
int format;
|
||||
int width;
|
||||
int height;
|
||||
int fps;
|
||||
int hw_slot_num;
|
||||
int boot_mode;
|
||||
int bayer_type;
|
||||
}isp_cfg_t;
|
||||
|
||||
typedef struct isp_info_s{
|
||||
int ddr_overflow_flag, isp_overflow_flag;
|
||||
int ddr_overflow_cnt,uv_overflow_cnt,y_overflow_cnt;
|
||||
|
||||
int is_stream_on;
|
||||
}isp_info_t;
|
||||
|
||||
typedef struct isp_stream_s{
|
||||
|
||||
void (*frame_complete)(void*);
|
||||
void *frame_complete_arg;
|
||||
void *priv;
|
||||
|
||||
isp_cfg_t cfg;
|
||||
isp_info_t info;
|
||||
}isp_stream_t;
|
||||
|
||||
typedef struct isp_buf_s{
|
||||
uint32_t slot_id;
|
||||
uint32_t y_addr;
|
||||
uint32_t uv_addr;
|
||||
|
||||
uint32_t timestamp;
|
||||
}isp_buf_t;
|
||||
|
||||
typedef struct isp_global_data_s{
|
||||
isp_stream_t* stream[3];
|
||||
uint32_t inited; // 0: not init , 1: inited
|
||||
|
||||
unsigned char framerate[8];
|
||||
char* hw_ts_buf;
|
||||
|
||||
int instance_cnt;
|
||||
|
||||
int pin_idx;
|
||||
int clk;
|
||||
int ldc;
|
||||
int sensor_fps;
|
||||
}isp_global_data_t;
|
||||
|
||||
extern int video_subsys_init(isp_init_cfg_t *ctx);
|
||||
|
||||
extern isp_stream_t* isp_stream_create(isp_cfg_t *cfg);
|
||||
extern isp_stream_t* isp_stream_destroy(isp_stream_t* stream);
|
||||
extern int isp_stream_poll(isp_stream_t* stream);
|
||||
extern int isp_stream_get_status(int isp_id);
|
||||
extern int isp_stream_control(isp_stream_t* stream, uint32_t cmd, uint32_t arg);
|
||||
extern void isp_stream_apply(isp_stream_t* stream);
|
||||
extern void isp_stream_cancel(isp_stream_t* stream);
|
||||
extern void isp_stream_set_complete_callback(isp_stream_t* stream, void (*cb)(void*), void* arg);
|
||||
extern void isp_stream_start(isp_stream_t* stream);
|
||||
extern void isp_stream_stop(isp_stream_t* stream);
|
||||
|
||||
extern void isp_mcu_lock(void);
|
||||
extern void isp_mcu_lock(void);
|
||||
extern int video_subsys_deinit(void *parm);
|
||||
//extern int video_sensor_check(int SensorName);
|
||||
extern uint8_t isp_i2c_read_byte(int addr);
|
||||
extern uint8_t isp_i2c_write_byte(int addr, uint8_t data);
|
||||
extern uint8_t isp_power_sequence_write(int index, uint8_t data);//index: 0=reset, 1=power down, 2=power control, value: 0=low, 1=high
|
||||
|
||||
#define MODE_EXCHANGE 0 // exchange used frame and ready frame's buf.y_addr/uv_addr
|
||||
#define MODE_SNAPSHOT 1 // only get ready frame from ISP
|
||||
#define MODE_SKIP 2 // enqueue ready frame to ISP
|
||||
#define MODE_SETUP 3 // enqueue buffer to ISP
|
||||
extern void isp_handle_buffer(isp_stream_t* stream, isp_buf_t* buf, int mode);
|
||||
|
||||
#endif
|
||||
153
sdk/component/common/drivers/video/realtek/common/isp_api_v1.h
Normal file
153
sdk/component/common/drivers/video/realtek/common/isp_api_v1.h
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
#ifndef _ISP_API_V1_H_
|
||||
#define _ISP_API_V1_H_
|
||||
|
||||
#define ISP_API_VER 1
|
||||
|
||||
#include "hal_api.h"
|
||||
#include "rtl8195bhp_isp.h"
|
||||
//#include "rtl8195bhp_isp_reg_type.h"
|
||||
#include "hal_isp.h"
|
||||
#include "osdep_service.h"
|
||||
|
||||
#include "hal.h"
|
||||
#include "rtl8195bhp_isp_reg_type.h"
|
||||
#include "encoder_buffer_handler.h"
|
||||
|
||||
#define ISP_MAX_BUFFER_COUNT 6
|
||||
#define ISP_DISABLE 0
|
||||
#define ISP_ENABLE 1
|
||||
|
||||
#define MAX_STREAM_NUM 3
|
||||
#define ISP_SIMULATE 1
|
||||
|
||||
#define STREAM_ZERO 0
|
||||
#define STREAM_ONE 1
|
||||
#define STREAM_TWO 2
|
||||
|
||||
#define ISP_DEBUG_SHOW 1
|
||||
|
||||
//Flip setting
|
||||
|
||||
#define ISP_CT_ROLL_SET ((0x04 << 8) | 0x01)
|
||||
#define ISP_CT_ROLL_GET ((0x04 << 8) | 0x81)
|
||||
#define stream_normal 0
|
||||
#define stream_horizontal_flip 1
|
||||
#define stream_vertical_flip 2
|
||||
#define stream_horiVerti_flip 3
|
||||
|
||||
#define ISP_FORMAT_YUV420_SEMIPLANAR 0x01
|
||||
#define ISP_FORMAT_YUV422_SEMIPLANAR 0x02
|
||||
#define ISP_FORMAT_BAYER_PATTERN 0x03
|
||||
|
||||
#define MAX_FPS 30 //Only support the follow fps [30 15 10 5 1]
|
||||
|
||||
#define HW_TIMESTAMP_BUF_SIZE 96//stream_num(3)*hw_slot_num(4)*buffer_zie(8)
|
||||
|
||||
struct isp_info{
|
||||
uint32_t streamid;
|
||||
uint32_t hw_slot;
|
||||
uint32_t sw_slot;
|
||||
};
|
||||
|
||||
typedef struct _isp_state{
|
||||
u32 timer_1;
|
||||
u32 timer_2;
|
||||
u32 drop_frame;
|
||||
u32 isp_frame;
|
||||
u32 drop_frame_total;
|
||||
u32 isp_frame_total;
|
||||
}isp_state;
|
||||
|
||||
struct stream_handle{
|
||||
struct enc_buf_data enc_data[ISP_MAX_BUFFER_COUNT];
|
||||
struct enc_list_handle enc_list;
|
||||
isp_state isp_state_var;
|
||||
int value;
|
||||
int width;
|
||||
int height;
|
||||
int fps;
|
||||
int streamid;
|
||||
int slot_num;
|
||||
int buff_num;
|
||||
int isp_overflow_flag;
|
||||
int y_overflow_cnt;
|
||||
int uv_overflow_cnt;
|
||||
int ddr_overflow_cnt;
|
||||
int snapshot_flag;
|
||||
int IsStreamOn;
|
||||
int format;
|
||||
};
|
||||
|
||||
|
||||
struct stream_manage_handle{
|
||||
struct stream_handle *isp_stream[MAX_STREAM_NUM];
|
||||
_sema isp_cmd_done_sema;//For common semaphore
|
||||
int initial_status;
|
||||
int isp_simulate;
|
||||
char *hw_ts_buf;
|
||||
};
|
||||
|
||||
//The buff_num must bigger than hw slot num
|
||||
int mcu_init_wait_cmd_done();
|
||||
|
||||
void isp_open();
|
||||
void isp_initial();
|
||||
//void isp_config(int streamid,int hw_slot_num,int buff_num,int fps,int width ,int height);
|
||||
void isp_config(int streamid,int hw_slot_num,int buff_num,int fps,int width ,int height, int format);
|
||||
void isp_start(uint8_t streamid);
|
||||
void video_init();
|
||||
void isp_start_stream(uint8_t streamid);
|
||||
void isp_stop_stream(uint8_t streamid);
|
||||
void isp_snapshot_setting(int streamid);
|
||||
void isp_snapshot_buf(int streamid);
|
||||
void isp_reset_parm(uint8_t streamid,uint32_t fps,uint32_t width,uint32_t height,uint32_t format);
|
||||
void isp_get_slot_id_info(u8 streamid, u8 slot_id, u32 *y_addr, u32 *uv_addr);//To get the slot id address
|
||||
|
||||
void isp_set_flip(int a_dValue);
|
||||
void isp_get_flip(int *a_pdValue);
|
||||
void isp_set_brightness(int a_dValue);
|
||||
void isp_get_brightness(int *a_pdValue);
|
||||
void isp_set_contrast(int a_dValue);
|
||||
void isp_get_contrast(int *a_pdValue);
|
||||
void isp_set_hue(int a_dValue);
|
||||
void isp_get_hue(int *a_pdValue);
|
||||
void isp_set_saturation(int a_dValue);
|
||||
void isp_get_saturation(int *a_pdValue);
|
||||
void isp_set_sharpness(int a_dValue);
|
||||
void isp_get_sharpness(int *a_pdValue);
|
||||
void isp_set_gamma(int a_dValue);
|
||||
void isp_get_gamma(int *a_pdValue);
|
||||
void isp_set_gray_mode(int a_dValue);
|
||||
void isp_get_gray_mode(int *a_pdValue);
|
||||
|
||||
void isp_set_exposure_mode(int a_dValue);
|
||||
void isp_get_exposure_mode(int *a_pdValue);
|
||||
void isp_set_exposure_priority(int a_dValue);
|
||||
void isp_get_exposure_priority(int *a_pdValue);
|
||||
void isp_set_exposure_time(int a_dValue);
|
||||
void isp_get_exposure_time(int *a_pdValue);
|
||||
void isp_set_zoom(int a_dValue);
|
||||
void isp_get_zoom(int *a_pdValue);
|
||||
void isp_set_pan_tilt(int a_dValuePan, int a_dValueTilt);
|
||||
void isp_get_pan_tilt(int *a_pdValuePan, int *a_pdValueTilt);
|
||||
|
||||
|
||||
void isp_set_AWB_ctrl(int a_dValue);
|
||||
void isp_get_AWB_ctrl(int *a_pdValue);
|
||||
void isp_set_WB_temp(int a_dValue);
|
||||
void isp_get_WB_temp(int *a_pdValue);
|
||||
void isp_set_power_line_freq(int a_dValue);
|
||||
void isp_get_power_line_freq(int *a_pdValue);
|
||||
void isp_set_AE_gain(int a_dValueAnalogGain, int a_dValueDigitalGain, int a_dValueISPDigitalGain);
|
||||
void isp_get_AE_gain(int *a_pdValueAnalogGain, int *a_pdValueDigitalGain, int *a_pdValueISPDigitalGain);
|
||||
void isp_set_WDR_mode(int a_dValue);
|
||||
void isp_get_WDR_mode(int *a_pdValue);
|
||||
void isp_set_WDR_level(int a_dValue);
|
||||
void isp_get_WDR_level(int *a_pdValue);
|
||||
|
||||
int isp_get_stream_status(uint8_t streamid);
|
||||
|
||||
int isp_poll(int streamid, int timout_ms);
|
||||
void isp_get_buffer(int streamid, struct enc_buf_data* *p_enc_data);
|
||||
void isp_put_buffer(int streamid, struct enc_buf_data* enc_data);
|
||||
#endif
|
||||
40
sdk/component/common/drivers/video/realtek/common/isp_boot.h
Normal file
40
sdk/component/common/drivers/video/realtek/common/isp_boot.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef ISP_BOOT_H
|
||||
#define ISP_BOOT_H
|
||||
|
||||
#define ISP_FORMAT_YUV420_SEMIPLANAR 0x01
|
||||
#define ISP_FORMAT_YUV422_SEMIPLANAR 0x02
|
||||
#define ISP_FORMAT_BAYER_PATTERN 0x03
|
||||
|
||||
#define HW_SLOT_NUM 2
|
||||
//#define MAX_FPS 30
|
||||
|
||||
#define ISP_TIMEOUT 2000
|
||||
#define ISP_FAST_BOOT (1)
|
||||
#define ISP_NORMAL_BOOT (0)
|
||||
|
||||
#define ISP_INTERFACE_PARALLEL (0)
|
||||
#define ISP_INTERFACE_MIPI (1)
|
||||
|
||||
typedef struct isp_boot_stream_cfg{
|
||||
uint32_t pin_idx;
|
||||
uint32_t isp_id;
|
||||
uint32_t hw_slot_num;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t fps;
|
||||
uint32_t format;
|
||||
uint32_t interface;
|
||||
uint32_t mode;
|
||||
uint32_t clk;
|
||||
uint32_t ldc;
|
||||
uint32_t sensor_fps;
|
||||
}isp_boot_stream_t;
|
||||
|
||||
typedef struct isp_boot_cfg{
|
||||
isp_boot_stream_t isp_config;
|
||||
uint32_t isp_buffer[HW_SLOT_NUM];
|
||||
uint32_t boot_enable;
|
||||
uint32_t mcu_fw_addr;
|
||||
}isp_boot_cfg_t;
|
||||
|
||||
#endif
|
||||
60
sdk/component/common/drivers/video/realtek/common/isp_cmd.h
Normal file
60
sdk/component/common/drivers/video/realtek/common/isp_cmd.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#ifndef ISP_CMD_H
|
||||
#define ISP_CMD_H
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <platform_stdlib.h>
|
||||
#include "freertos_service.h"
|
||||
#include "osdep_service.h"
|
||||
//#define ISP_DEBUG
|
||||
|
||||
#define _func_enter_
|
||||
#define _func_exit_
|
||||
#define _PASS 1
|
||||
|
||||
#define ISP_ENABLE 1
|
||||
#define ISP_DISABLE 0
|
||||
|
||||
#define ISP_SUCCESSFUL 1
|
||||
#define ISP_FAILED 0
|
||||
|
||||
#define ISP_CMD_BUF_SIZE 32
|
||||
#define ISP_CMD_TIMEOUT 1000
|
||||
|
||||
typedef struct isp_ADAPTER _isp_adapter,*PISPADAPTER;
|
||||
|
||||
struct isp_cmd_data{
|
||||
unsigned short cmdcode;
|
||||
unsigned char index;
|
||||
unsigned char length;
|
||||
unsigned short param;
|
||||
unsigned short addr;
|
||||
unsigned char *buf;
|
||||
unsigned int error_type;
|
||||
};
|
||||
|
||||
struct isp_cmd_obj {
|
||||
_list list;
|
||||
struct isp_cmd_data isp_cmd;
|
||||
};
|
||||
|
||||
typedef struct _isp_cmd_context{
|
||||
struct list_head isp_cmd_list;
|
||||
struct isp_cmd_obj isp_cmd;
|
||||
_mutex cmd_mutex;
|
||||
_sema cmd_done_sema;
|
||||
_sema cmd_wakeup_sema;
|
||||
_lock cmd_lock;
|
||||
xTaskHandle isp_cmd_task;
|
||||
int cmdthd_running;
|
||||
int callback_running;
|
||||
int blocked;
|
||||
int running;
|
||||
}isp_cmd_context;
|
||||
|
||||
u8 isp_send_cmd(struct isp_cmd_data *isp_data);
|
||||
//u32 isp_atcmd_deinital();
|
||||
//u32 isp_atcmd_initial();
|
||||
u32 isp_atcmd_deinital(void *parm);
|
||||
u32 isp_atcmd_initial(void *parm);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef _ISP_CMD_API_H_
|
||||
#define _ISP_CMD_API_H_
|
||||
|
||||
#define ISP_CT_ROLL_SET ((0x04 << 8) | 0x01)
|
||||
#define ISP_CT_ROLL_GET ((0x04 << 8) | 0x81)
|
||||
|
||||
extern void isp_set_flip(int a_dValue);
|
||||
extern void isp_get_flip(int *a_pdValue);
|
||||
extern void isp_set_brightness(int a_dValue);
|
||||
extern void isp_get_brightness(int *a_pdValue);
|
||||
extern void isp_set_contrast(int a_dValue);
|
||||
extern void isp_get_contrast(int *a_pdValue);
|
||||
extern void isp_set_hue(int a_dValue);
|
||||
extern void isp_get_hue(int *a_pdValue);
|
||||
extern void isp_set_saturation(int a_dValue);
|
||||
extern void isp_get_saturation(int *a_pdValue);
|
||||
extern void isp_set_sharpness(int a_dValue);
|
||||
extern void isp_get_sharpness(int *a_pdValue);
|
||||
extern void isp_set_gamma(int a_dValue);
|
||||
extern void isp_get_gamma(int *a_pdValue);
|
||||
extern void isp_set_gray_mode(int a_dValue);
|
||||
extern void isp_get_gray_mode(int *a_pdValue);
|
||||
|
||||
extern void isp_set_exposure_mode(int a_dValue);
|
||||
extern void isp_get_exposure_mode(int *a_pdValue);
|
||||
extern void isp_set_exposure_time(int a_dValue);
|
||||
extern void isp_get_exposure_time(int *a_pdValue);
|
||||
extern void isp_set_zoom(int a_dValue);
|
||||
extern void isp_get_zoom(int *a_pdValue);
|
||||
extern void isp_set_pan_tilt(int a_dValuePan, int a_dValueTilt);
|
||||
extern void isp_get_pan_tilt(int *a_pdValuePan, int *a_pdValueTilt);
|
||||
|
||||
|
||||
extern void isp_set_AWB_ctrl(int a_dValue);
|
||||
extern void isp_get_AWB_ctrl(int *a_pdValue);
|
||||
extern void isp_set_power_line_freq(int a_dValue);
|
||||
extern void isp_get_power_line_freq(int *a_pdValue);
|
||||
extern void isp_set_AE_gain(int a_dValueAnalogGain, int a_dValueDigitalGain, int a_dValueISPDigitalGain);
|
||||
extern void isp_get_AE_gain(int *a_pdValueAnalogGain, int *a_pdValueDigitalGain, int *a_pdValueISPDigitalGain);
|
||||
extern void isp_set_WDR_mode(int a_dValue);
|
||||
extern void isp_get_WDR_mode(int *a_pdValue);
|
||||
extern void isp_set_WDR_level(int a_dValue);
|
||||
extern void isp_get_WDR_level(int *a_pdValue);
|
||||
|
||||
extern void isp_cmd_set_all_stream_fps(int fps);
|
||||
extern void isp_cmd_stop_preview(int streamid);
|
||||
extern void isp_cmd_set_start_preview(int streamid, u32 yuv_width, u32 yuv_height);
|
||||
extern void isp_cmd_set_output_format(int streamid,int format);
|
||||
extern void isp_cmd_set_format(int streamid,int format);
|
||||
extern void isp_cmd_set_ldc(int enable);
|
||||
extern void isp_cmd_get_ldc(unsigned char *buf);
|
||||
extern void isp_cmd_set_stream_fps(unsigned char *buf);
|
||||
extern void isp_cmd_set_power_line_freq(int a_dValue);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#ifndef JPEG_ENCODER
|
||||
#define JPEG_ENCODER
|
||||
#include "freertos_service.h"
|
||||
#include "memory_encoder.h"
|
||||
#include "encoder_buffer_handler.h"
|
||||
#include "isp_api.h"
|
||||
|
||||
|
||||
struct jpeg_parameter {
|
||||
u32 width; /* Number of pixels/line in input image */
|
||||
u32 height; /* Number of lines in input image */
|
||||
u32 qLevel; /* Quantization level (0 - 9) */
|
||||
u32 frameType; /* Input frame YUV / RGB format */
|
||||
u32 start;
|
||||
u32 ratenum;
|
||||
u32 jpeg_full_header;
|
||||
};
|
||||
|
||||
struct jpeg_context {
|
||||
void* encoder;
|
||||
struct jpeg_parameter jpeg_parm;
|
||||
struct encoder_list_head encoder_jpeg_lh;
|
||||
uint32_t source_addr;
|
||||
uint32_t y_addr;
|
||||
uint32_t uv_addr;
|
||||
uint32_t dest_addr;
|
||||
uint32_t dest_len;
|
||||
uint32_t dest_actual_len;
|
||||
struct isp_info isp_info_value;
|
||||
struct mem_info mem_info_value;
|
||||
void (*snapshot_cb)(void);
|
||||
void (*change_parm_cb)(void*);
|
||||
};
|
||||
|
||||
void *jpeg_open();
|
||||
int jpeg_encode(void *ctx);
|
||||
int jpeg_release(void *ctx);
|
||||
int jpeg_initial(void *ctx,struct jpeg_parameter *jpeg_parm);
|
||||
int jpeg_init_param(struct jpeg_parameter *jpeg_parm);
|
||||
void jpeg_info();
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
#ifndef _VIDEO_COMMON_API_H_
|
||||
#define _VIDEO_COMMON_API_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define VIDEO_240P_WIDTH 320
|
||||
#define VIDEO_240P_HEIGHT 240
|
||||
#define VIDEO_480P_WIDTH 640
|
||||
#define VIDEO_480P_HEIGHT 480
|
||||
#define VIDEO_720P_WIDTH 1280
|
||||
#define VIDEO_720P_HEIGHT 720
|
||||
#define VIDEO_1080P_WIDTH 1920
|
||||
#define VIDEO_1080P_HEIGHT 1080
|
||||
|
||||
typedef struct {
|
||||
uint8_t* output_buffer;
|
||||
uint32_t output_buffer_size;
|
||||
uint32_t output_size;
|
||||
} VIDEO_BUFFER;
|
||||
|
||||
void gpio_ircut_switch(void);
|
||||
|
||||
#endif //#ifndef _VIDEO_COMMON_API_H_
|
||||
25
sdk/component/common/drivers/video/realtek/common/voe_api.h
Normal file
25
sdk/component/common/drivers/video/realtek/common/voe_api.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef _VOE_API_H_
|
||||
#define _VOE_API_H_
|
||||
#include "osdep_service.h"
|
||||
#if 0
|
||||
typedef struct _h1v6_parm{
|
||||
//_sema sem_irq_h264;
|
||||
_sema sem_irq_cmd;
|
||||
_sema sem_irq_jpeg;
|
||||
_sema sem_irq_h264;
|
||||
//_sema sem_irq_cmd;
|
||||
int sem_status;
|
||||
}h1v6_parm;
|
||||
#endif
|
||||
#if 1
|
||||
typedef struct _h1v6_parm{
|
||||
_sema sem_irq_h264;
|
||||
_sema sem_irq_jpeg;
|
||||
_sema sem_irq_cmd;
|
||||
_sema sem_res_h264;
|
||||
_sema sem_res_jpeg;
|
||||
_sema sem_res_all;
|
||||
}h1v6_parm;
|
||||
#endif
|
||||
u32 voe_run(void);
|
||||
#endif
|
||||
|
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* umsc_os_wrap_via_osdep_api.h
|
||||
*
|
||||
* Created on: Sep 5, 2014
|
||||
* Author: jimmysqf
|
||||
*/
|
||||
|
||||
#ifndef ISP_WRAP_OSDEP_API__H
|
||||
#define ISP_WRAP_OSDEP_API__H
|
||||
|
||||
#include "basic_types.h"
|
||||
#include "osdep_api.h"
|
||||
|
||||
#define GFP_KERNEL 1
|
||||
#define GFP_ATOMIC 1
|
||||
|
||||
#define EAGAIN 11 /* Try again */
|
||||
#define ENOMEM 12 /* Out of memory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define EBUSY 16 /* Device or resource busy */
|
||||
|
||||
|
||||
typedef unsigned int gfp_t;
|
||||
|
||||
/* misc items */
|
||||
#ifndef ssize_t
|
||||
#define ssize_t SSIZE_T
|
||||
#endif
|
||||
#ifndef size_t
|
||||
#define size_t SIZE_T
|
||||
#endif
|
||||
|
||||
#ifndef __user
|
||||
#define __user
|
||||
#endif
|
||||
|
||||
#ifndef loff_t
|
||||
#define loff_t long
|
||||
#endif
|
||||
#ifndef __u8
|
||||
#define __u8 u8
|
||||
#endif
|
||||
#ifndef __u16
|
||||
#define __u16 u16
|
||||
#endif
|
||||
#ifndef __u32
|
||||
#define __u32 u32
|
||||
#endif
|
||||
#ifndef __u64
|
||||
#define __u64 u64
|
||||
#endif
|
||||
#ifndef __s8
|
||||
#define __s8 s8
|
||||
#endif
|
||||
#ifndef __s16
|
||||
#define __s16 s16
|
||||
#endif
|
||||
#ifndef __s32
|
||||
#define __s32 s32
|
||||
#endif
|
||||
#ifndef __s64
|
||||
#define __s64 s64
|
||||
#endif
|
||||
|
||||
typedef __u16 __le16;
|
||||
typedef __u16 __be16;
|
||||
typedef __u32 __le32;
|
||||
typedef __u32 __be32;
|
||||
typedef __u64 __le64;
|
||||
typedef __u64 __be64;
|
||||
typedef __u16 __sum16;
|
||||
typedef __u32 __wsum;
|
||||
|
||||
|
||||
#ifndef cpu_to_le32
|
||||
|
||||
#define cpu_to_le32(x) rtk_cpu_to_le32(x)
|
||||
#endif
|
||||
#ifndef le32_to_cpu
|
||||
|
||||
#define le32_to_cpu(x) rtk_le32_to_cpu(x)
|
||||
#endif
|
||||
#ifndef cpu_to_le16
|
||||
|
||||
#define cpu_to_le16(x) rtk_cpu_to_le16(x)
|
||||
#endif
|
||||
#ifndef le16_to_cpu
|
||||
|
||||
#define le16_to_cpu(x) rtk_le16_to_cpu(x)
|
||||
#endif
|
||||
#ifndef cpu_to_be32
|
||||
|
||||
#define cpu_to_be32(x) rtk_cpu_to_be32(x)
|
||||
#endif
|
||||
#ifndef be32_to_cpu
|
||||
|
||||
#define be32_to_cpu(x) rtk_be32_to_cpu(x)
|
||||
#endif
|
||||
#ifndef cpu_to_be16
|
||||
|
||||
#define cpu_to_be16(x) rtk_cpu_to_be16(x)
|
||||
#endif
|
||||
#ifndef be16_to_cpu
|
||||
|
||||
#define be16_to_cpu(x) rtk_be16_to_cpu(x)
|
||||
#endif
|
||||
|
||||
#ifndef DIV_ROUND_UP
|
||||
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
||||
#endif
|
||||
#ifndef BITS_PER_LONG
|
||||
#define BITS_PER_LONG (32)
|
||||
#endif
|
||||
#ifndef BITS_PER_LONG_LONG
|
||||
#define BITS_PER_LONG_LONG (32)
|
||||
#endif
|
||||
#ifndef BIT
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#endif
|
||||
#ifndef BIT_ULL
|
||||
#define BIT_ULL(nr) (1ULL << (nr))
|
||||
#endif
|
||||
#ifndef BIT_MASK
|
||||
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
|
||||
#endif
|
||||
#ifndef BIT_WORD
|
||||
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
|
||||
#endif
|
||||
#ifndef BIT_ULL_MASK
|
||||
#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
|
||||
#endif
|
||||
#ifndef BIT_ULL_WORD
|
||||
#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
|
||||
#endif
|
||||
#ifndef BITS_PER_BYTE
|
||||
#define BITS_PER_BYTE (8)
|
||||
#endif
|
||||
#ifndef BITS_TO_LONGS
|
||||
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
|
||||
#endif
|
||||
|
||||
#ifndef min
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef min_t
|
||||
#define min_t(type, x, y) ({ \
|
||||
type __min1 = (x); \
|
||||
type __min2 = (y); \
|
||||
__min1 < __min2 ? __min1 : __min2; })
|
||||
#endif
|
||||
#ifndef max_t
|
||||
#define max_t(type, x, y) ({ \
|
||||
type __max1 = (x); \
|
||||
type __max2 = (y); \
|
||||
__max1 > __max2 ? __max1 : __max2; })
|
||||
#endif
|
||||
|
||||
/**
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @p(ptr): the pointer to the member.
|
||||
* @t(type): the type of the container struct this is embedded in.
|
||||
* @m(member): the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) \
|
||||
((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* test_bit - Determine whether a bit is set
|
||||
* @nr: bit number to test
|
||||
* @addr: Address to start counting from
|
||||
*/
|
||||
static inline int test_bit(int nr, const volatile unsigned long *addr)
|
||||
{
|
||||
return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
|
||||
}
|
||||
/**
|
||||
* set_bit - Atomically set a bit in memory
|
||||
* @nr: the bit to set
|
||||
* @addr: the address to start counting from
|
||||
*
|
||||
* This function is atomic and may not be reordered. See __set_bit()
|
||||
* if you do not require the atomic guarantees.
|
||||
*
|
||||
* Note: there are no guarantees that this function will not be reordered
|
||||
* on non x86 architectures, so if you are writing portable code,
|
||||
* make sure not to rely on its reordering guarantees.
|
||||
*
|
||||
* Note that @nr may be almost arbitrarily large; this function is not
|
||||
* restricted to acting on a single-word quantity.
|
||||
*/
|
||||
static inline void set_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
|
||||
SaveAndCli();
|
||||
*p |= mask;
|
||||
RestoreFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* clear_bit - Clears a bit in memory
|
||||
* @nr: Bit to clear
|
||||
* @addr: Address to start counting from
|
||||
*
|
||||
* clear_bit() is atomic and may not be reordered. However, it does
|
||||
* not contain a memory barrier, so if it is used for locking purposes,
|
||||
* you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
|
||||
* in order to ensure changes are visible on other processors.
|
||||
*/
|
||||
static inline void clear_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
|
||||
SaveAndCli();
|
||||
*p &= ~mask;
|
||||
RestoreFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* change_bit - Toggle a bit in memory
|
||||
* @nr: Bit to change
|
||||
* @addr: Address to start counting from
|
||||
*
|
||||
* change_bit() is atomic and may not be reordered. It may be
|
||||
* reordered on other architectures than x86.
|
||||
* Note that @nr may be almost arbitrarily large; this function is not
|
||||
* restricted to acting on a single-word quantity.
|
||||
*/
|
||||
static inline void change_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
|
||||
SaveAndCli();
|
||||
*p ^= mask;
|
||||
RestoreFlags();
|
||||
}
|
||||
|
||||
/**
|
||||
* test_and_set_bit - Set a bit and return its old value
|
||||
* @nr: Bit to set
|
||||
* @addr: Address to count from
|
||||
*
|
||||
* This operation is atomic and cannot be reordered.
|
||||
* It may be reordered on other architectures than x86.
|
||||
* It also implies a memory barrier.
|
||||
*/
|
||||
static inline int test_and_set_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
unsigned long old;
|
||||
|
||||
SaveAndCli();
|
||||
old = *p;
|
||||
*p = old | mask;
|
||||
RestoreFlags();
|
||||
return (old & mask) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* test_and_clear_bit - Clear a bit and return its old value
|
||||
* @nr: Bit to clear
|
||||
* @addr: Address to count from
|
||||
*
|
||||
* This operation is atomic and cannot be reordered.
|
||||
* It can be reorderdered on other architectures other than x86.
|
||||
* It also implies a memory barrier.
|
||||
*/
|
||||
static inline int test_and_clear_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
unsigned long old;
|
||||
|
||||
SaveAndCli();
|
||||
old = *p;
|
||||
*p = old & ~mask;
|
||||
RestoreFlags();
|
||||
|
||||
return (old & mask) != 0;
|
||||
}
|
||||
/**
|
||||
* test_and_change_bit - Change a bit and return its old value
|
||||
* @nr: Bit to change
|
||||
* @addr: Address to count from
|
||||
*
|
||||
* This operation is atomic and cannot be reordered.
|
||||
* It also implies a memory barrier.
|
||||
*/
|
||||
static inline int test_and_change_bit(int nr, volatile unsigned long *addr)
|
||||
{
|
||||
unsigned long mask = BIT_MASK(nr);
|
||||
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
|
||||
unsigned long old;
|
||||
|
||||
SaveAndCli();
|
||||
old = *p;
|
||||
*p = old ^ mask;
|
||||
RestoreFlags();
|
||||
|
||||
return (old & mask) != 0;
|
||||
}
|
||||
|
||||
static inline u16 get_unaligned_be16(const void *p)
|
||||
{
|
||||
const u8 *_p = p;
|
||||
return _p[0] << 8 | _p[1];
|
||||
}
|
||||
|
||||
static inline u32 get_unaligned_be32(const void *p)//add by devin
|
||||
{
|
||||
const u8 *_p = p;
|
||||
return _p[0] << 24 | _p[1] <<16 | _p[2] <<8 | _p[0];
|
||||
}
|
||||
|
||||
static inline u16 __get_unaligned_le16(const u8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8;
|
||||
}
|
||||
|
||||
static inline u32 __get_unaligned_le32(const u8 *p)
|
||||
{
|
||||
return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24;
|
||||
}
|
||||
|
||||
static inline u16 get_unaligned_le16(const void *p)
|
||||
{
|
||||
return __get_unaligned_le16((const u8 *)p);
|
||||
}
|
||||
|
||||
static inline u32 get_unaligned_le32(const void *p)
|
||||
{
|
||||
return __get_unaligned_le32((const u8 *)p);
|
||||
}
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
#endif
|
||||
|
||||
#endif /* US_OS_WRAP_VIA_OSDEP_API_H_ */
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _RTL8195B_H264_PSEUDO_H_
|
||||
#define _RTL8195B_H264_PSEUDO_H_
|
||||
|
||||
#define H264_PSEUDO_FRAME_RATE 30
|
||||
|
||||
void h264_pseudo_init();
|
||||
void h264_pseudo_set_isr(h264_enc_handle isr, void *data);
|
||||
|
||||
void h264_pseudo_get_frame(uint8_t **frame, uint32_t *frame_len);
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,589 @@
|
|||
#ifndef RTL8195B_ISP__H
|
||||
#define RTL8195B_ISP__H
|
||||
//RTS_CAMERA.H
|
||||
#include "osdep_api.h"
|
||||
#include "isp_wrap_osdep_api.h"
|
||||
|
||||
#define ISP_DEBUG
|
||||
|
||||
#ifdef ISP_DEBUG
|
||||
#define rtsprintk printf
|
||||
#else
|
||||
#define rtsprintk
|
||||
#endif
|
||||
|
||||
//CAMERA_RTSOC.H
|
||||
enum mcu_lock_status {
|
||||
MCU_LCK_STS_OK = 0,
|
||||
MCU_LCK_STS_ERROR = 1,
|
||||
MCU_LCK_STS_NO_MCU_DEV = 2,
|
||||
MCU_LCK_STS_RESERVED
|
||||
};
|
||||
|
||||
#ifdef CONFIG_RTS_MCU_FW_IN_DDR
|
||||
static inline int rtscam_soc_acquire_mcu_lock(unsigned int timeout)
|
||||
{
|
||||
return MCU_LCK_STS_OK;
|
||||
}
|
||||
|
||||
static inline int rtscam_soc_release_mcu_lock(void)
|
||||
{
|
||||
return MCU_LCK_STS_OK;
|
||||
}
|
||||
#else
|
||||
//int rtscam_soc_acquire_mcu_lock(unsigned int timeout);
|
||||
//int rtscam_soc_release_mcu_lock(void);
|
||||
#endif
|
||||
|
||||
#define RTSCAM_SOC_CAP_FLAG_TDNR (1<<0)
|
||||
#define RTSCAM_SOC_CAP_FLAG_LDC (1<<1)
|
||||
#define RTSCAM_SOC_CAP_FLAG_DEHAZE (1<<2)
|
||||
|
||||
struct rtscam_soc_pdata {
|
||||
u32 capibility;
|
||||
};
|
||||
//RTS_CAMERA_SOC.H
|
||||
#define RTSCAM_SOC_VIDEO_NR_B 51
|
||||
|
||||
#define RTSCAM_SOC_CMD_TIMEOUT_MIN 300
|
||||
#define RTSCAM_SOC_CMD_TIMEOUT_MAX 5000
|
||||
#define RTSCAM_SOC_CMD_TIMEOUT RTSCAM_SOC_CMD_TIMEOUT_MIN
|
||||
|
||||
#define RTSCAM_SOC_CMD_DATA_REG_NUM 8
|
||||
#define RTSCAM_SOC_CMD_DIRECTION_MASK 0x80
|
||||
|
||||
#define RTSCAM_SOC_CMD_STATUS_STATUS_BIT 31
|
||||
#define RTSCAM_SOC_CMD_STATUS_RESULT_BIT 30
|
||||
#define RTSCAM_SOC_CMD_STATUS_ERROR_BIT 16
|
||||
#define RTSCAM_SOC_CMD_STATUS_ERROR_MASK 0xff0000
|
||||
|
||||
#define RTSCAM_SOC_MAX_STREAM_NUM 5
|
||||
#define RTSCAM_SOC_MJPEG_STRM_IDX (RTSCAM_SOC_MAX_STREAM_NUM - 1)
|
||||
#define RTSCAM_SOC_TD_INDEX 5
|
||||
#define RTSCAM_SOC_LDC_INDEX 6
|
||||
|
||||
#define RTSCAM_SOC_MAX_SLOT_NUM 4
|
||||
#define RTSCAM_SOC_HW_SLOT_NUM 2
|
||||
|
||||
#define RTSCAM_SOC_FPS_UNIT 10000000
|
||||
|
||||
#define RTSCAM_SOC_MIN_W 320
|
||||
#define RTSCAM_SOC_MIN_H 240
|
||||
#define RTSCAM_SOC_STEP_W 16
|
||||
#define RTSCAM_SOC_STEP_H 8
|
||||
|
||||
#define RTSCAM_SOC_MTD_NUM 5
|
||||
|
||||
#define RTSCAM_SOC_FRAME_HEADER_LENGTH 8
|
||||
|
||||
#define RTSCAM_SOC_ISP_FUNC_TD_BIT 0
|
||||
#define RTSCAM_SOC_ISP_FUNC_LDC_BIT 1
|
||||
|
||||
enum rtscam_soc_cmd_data_dir {
|
||||
host_to_device = 0,
|
||||
device_to_host = 1
|
||||
};
|
||||
|
||||
enum RTS_CPU_LOCK_MCU_MASK {
|
||||
CPU_LOCK_MCU_REQUEST = 0x1,
|
||||
CPU_LOCK_MCU_DONE = 0x2,
|
||||
CPU_LOCK_MCU_RELEASE = 0x4,
|
||||
CPU_LOCK_MCU_CACHE_MISS = 0x8,
|
||||
};
|
||||
|
||||
enum hclk_src_type {
|
||||
HCLK_SRC_480M = 0x00,
|
||||
HCLK_SRC_288M = 0x01,
|
||||
HCLK_SRC_324M = 0x02,
|
||||
HCLK_SRC_297M = 0x03,
|
||||
};
|
||||
|
||||
#define RTS_CMDCODE_GET_DEVICE_DES ((0x01 << 8) | 0x81)
|
||||
#define RTS_CMDCODE_GET_FRAME_INTERVAL_DES ((0x01 << 8) | 0x82)
|
||||
#define RTS_CMDCODE_GET_VS_FMT_DES ((0x01 << 8) | 0x83)
|
||||
#define RTS_CMDCODE_GET_ISP_PROCESS_DES ((0x01 << 8) | 0x84)
|
||||
#define RTS_CMDCODE_GET_CAMERA_DES ((0x01 << 8) | 0x85)
|
||||
#define RTS_CMDCODE_GET_RTK_EXT_CTL_DES ((0x01 << 8) | 0x86)
|
||||
#define RTS_CMDCODE_GET_HCLK_CFG_DES ((0x01 << 8) | 0x87)
|
||||
#define RTS_CMDCODE_GET_FW_VERSION ((0x01 << 8) | 0x88)
|
||||
#define RTS_CMDCODE_GET_SNR_POWER ((0x01 << 8) | 0x89)
|
||||
#define RTS_CMDCODE_GET_API_VERSION ((0x01 << 8) | 0x8a)
|
||||
|
||||
#define RTS_CMDCODE_SET_FPS ((0x02 << 8) | 0x01)
|
||||
#define RTS_CMDCODE_START_PREVIEW ((0x02 << 8) | 0x02)
|
||||
#define RTS_CMDCODE_STOP_PREVIEW ((0x02 << 8) | 0x03)
|
||||
#define RTS_CMDCODE_PAUSE_VIDEO ((0x02 << 8) | 0x05)
|
||||
#define RTS_CMDCODE_RESUME_VIDEO ((0x02 << 8) | 0x06)
|
||||
#define RTS_CMDCODE_SET_FORMAT ((0x02 << 8) | 0x07)
|
||||
|
||||
#define RTS_CMDCODE_GET_SNR_FMT ((0x06 << 8) | 0x81)
|
||||
#define RTS_CMDCODE_SET_ISP_FUNC ((0x0a << 8) | 0x01)
|
||||
#define RTS_CMDCODE_GET_ISP_FUNC ((0x0a << 8) | 0x81)
|
||||
|
||||
#define BSP_SPI_FLASH_PADDR 0
|
||||
#define RTS_MTD_MCU_FW_OFFSET 0
|
||||
|
||||
struct rtscam_soc_device_descriptor {
|
||||
u8 length;
|
||||
u8 type;
|
||||
u16 hwversion;
|
||||
u16 fwversion;
|
||||
u8 streamnum;
|
||||
u8 frmivalnum;
|
||||
};
|
||||
|
||||
struct rtscam_soc_frmival_descriptor {
|
||||
u8 frmivalnum;
|
||||
u32 *frmivals;
|
||||
};
|
||||
|
||||
struct rtscam_soc_stream_format_descriptor {
|
||||
u8 streamid;
|
||||
u8 length;
|
||||
u8 type;
|
||||
u8 format;
|
||||
u16 width;
|
||||
u16 height;
|
||||
};
|
||||
|
||||
struct rtscam_soc_unit_descriptor {
|
||||
u8 length;
|
||||
u8 type;
|
||||
u8 controlsize;
|
||||
u8 bmcontrols[32];
|
||||
|
||||
unsigned int ncontrols;
|
||||
struct rtscam_video_ctrl *controls;
|
||||
};
|
||||
|
||||
struct rtscam_soc_hclk_descriptor {
|
||||
u8 length;
|
||||
u8 type;
|
||||
u8 src_type;
|
||||
u8 ssc_flag;
|
||||
};
|
||||
|
||||
struct rtscam_soc_fw_version_t {
|
||||
u8 header;
|
||||
u8 length;
|
||||
u32 magictag;
|
||||
u16 ic_name;
|
||||
u16 vid;
|
||||
u16 pid;
|
||||
u32 fw_ver;
|
||||
u32 cus_ver;
|
||||
u8 reserved[16];
|
||||
};
|
||||
|
||||
struct rtscam_soc_snr_power {
|
||||
u8 power_io;
|
||||
u8 power_analog;
|
||||
u8 power_core;
|
||||
};
|
||||
|
||||
struct rtscam_soc_api_version {
|
||||
u8 main;
|
||||
u8 sub;
|
||||
};
|
||||
|
||||
/* A.1 Descriptor Types */
|
||||
#define RTSCAM_SOC_UNDEFINED_TYPE 0x0
|
||||
#define RTSCAM_SOC_DEVICE_TYPE 0x1
|
||||
#define RTSCAM_SOC_VS_INTERFACE_TYPE 0x2
|
||||
#define RTSCAM_SOC_ISP_PROCESSING_TYPE 0x3
|
||||
#define RTSCAM_SOC_CAMERA_TYPE 0x4
|
||||
#define RTSCAM_SOC_RTK_EXT_CTL_TYPE 0x5
|
||||
#define RTSCAM_SOC_HCLK_CFG_TYPE 0x6
|
||||
|
||||
/* A.2 Video Stream Data Types */
|
||||
#define RTSCAM_SOC_VS_UNDEFINED 0x0
|
||||
#define RTSCAM_SOC_VS_FORMAT_UNCOMPRESSED 0x4
|
||||
#define RTSCAM_SOC_VS_FRAME_UNCOMPRESSED 0x5
|
||||
#define RTSCAM_SOC_VS_FORMAT_MJPEG 0x6
|
||||
#define RTSCAM_SOC_VS_FRAME_MJPEG 0x7
|
||||
#define RTSCAM_SOC_VS_FORMAT_H264 0x13
|
||||
#define RTSCAM_SOC_VS_FRAME_H264 0x14
|
||||
|
||||
/* format type */
|
||||
#define RTSCAM_SOC_FORMAT_TYPE_YUV420_SEMIPLANAR 0x01
|
||||
#define RTSCAM_SOC_FORMAT_TYPE_YUV422_SEMIPLANAR 0x02
|
||||
#define RTSCAM_SOC_FORMAT_TYPE_MJPG 0x04
|
||||
|
||||
/* A.4 ISP Processing Control Selectors */
|
||||
#define RTSCAM_SOC_PU_CONTROL_UNDEFINED 0x00
|
||||
#define RTSCAM_SOC_PU_BACKLIGHT_COMPENSATION_CONTROL 0x01
|
||||
#define RTSCAM_SOC_PU_BRIGHTNESS_CONTROL 0x02
|
||||
#define RTSCAM_SOC_PU_CONTRAST_CONTROL 0x03
|
||||
#define RTSCAM_SOC_PU_GAIN_CONTROL 0x04
|
||||
#define RTSCAM_SOC_PU_POWER_LINE_FREQUENCY_CONTROL 0x05
|
||||
#define RTSCAM_SOC_PU_HUE_CONTROL 0x06
|
||||
#define RTSCAM_SOC_PU_SATURATION_CONTROL 0x07
|
||||
#define RTSCAM_SOC_PU_SHARPNESS_CONTROL 0x08
|
||||
#define RTSCAM_SOC_PU_GAMMA_CONTROL 0x09
|
||||
#define RTSCAM_SOC_PU_WHITE_BALANCE_TEMPERATURE_CONTROL 0x0A
|
||||
#define RTSCAM_SOC_PU_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0x0B
|
||||
#define RTSCAM_SOC_PU_WHITE_BALANCE_COMPONENT_CONTROL 0x0C
|
||||
#define RTSCAM_SOC_PU_WHITE_BALANCE_COMPONENT_AUTO_CONTROL 0x0D
|
||||
#define RTSCAM_SOC_PU_DIGITAL_MULTIPLIER_CONTROL 0x0E
|
||||
#define RTSCAM_SOC_PU_DIGITAL_MULTIPLIER_LIMIT_CONTROL 0x0F
|
||||
#define RTSCAM_SOC_PU_HUE_AUTO_CONTROL 0x10
|
||||
#define RTSCAM_SOC_PU_ANALOG_VIDEO_STANDARD_CONTROL 0x11
|
||||
#define RTSCAM_SOC_PU_ANALOG_LOCK_STATUS_CONTROL 0x12
|
||||
#define RTSCAM_SOC_PU_CONTRAST_AUTO_CONTROL 0x13
|
||||
|
||||
/* A.4 Camera Control Selectors */
|
||||
#define RTSCAM_SOC_CT_CONTROL_UNDEFINED 0x00
|
||||
#define RTSCAM_SOC_CT_SCANNING_MODE_CONTROL 0x01
|
||||
#define RTSCAM_SOC_CT_AE_MODE_CONTROL 0x02
|
||||
#define RTSCAM_SOC_CT_AE_PRIORITY_CONTROL 0x03
|
||||
#define RTSCAM_SOC_CT_EXPOSURE_TIME_ABSOLUTE_CONTROL 0x04
|
||||
#define RTSCAM_SOC_CT_EXPOSURE_TIME_RELATIVE_CONTROL 0x05
|
||||
#define RTSCAM_SOC_CT_FOCUS_ABSOLUTE_CONTROL 0x06
|
||||
#define RTSCAM_SOC_CT_FOCUS_RELATIVE_CONTROL 0x07
|
||||
#define RTSCAM_SOC_CT_FOCUS_AUTO_CONTROL 0x08
|
||||
#define RTSCAM_SOC_CT_IRIS_ABSOLUTE_CONTROL 0x09
|
||||
#define RTSCAM_SOC_CT_IRIS_RELATIVE_CONTROL 0x0A
|
||||
#define RTSCAM_SOC_CT_ZOOM_ABSOLUTE_CONTROL 0x0B
|
||||
#define RTSCAM_SOC_CT_ZOOM_RELATIVE_CONTROL 0x0C
|
||||
#define RTSCAM_SOC_CT_PANTILT_ABSOLUTE_CONTROL 0x0D
|
||||
#define RTSCAM_SOC_CT_PANTILT_RELATIVE_CONTROL 0x0E
|
||||
#define RTSCAM_SOC_CT_ROLL_ABSOLUTE_CONTROL 0x0F
|
||||
#define RTSCAM_SOC_CT_ROLL_RELATIVE_CONTROL 0x10
|
||||
#define RTSCAM_SOC_CT_PRIVACY_CONTROL 0x11
|
||||
#define RTSCAM_SOC_CT_FOCUS_SIMPLE_CONTROL 0x12
|
||||
#define RTSCAM_SOC_CT_WINDOW_CONTROL 0x13
|
||||
#define RTSCAM_SOC_CT_REGION_OF_INTEREST_CONTROL 0x14
|
||||
|
||||
/* A.6 Rtk Extended Control Selectors */
|
||||
#define RTSCAM_SOC_RTK_EXT_ISP_SPECIAL_EFFECT_CTL 0x01
|
||||
#define RTSCAM_SOC_RTK_EXT_EVCOM_CTL 0x02
|
||||
#define RTSCAM_SOC_RTK_EXT_CTE_CTL 0x03
|
||||
#define RTSCAM_SOC_RTK_EXT_AE_LOCK_CTL 0x04
|
||||
#define RTSCAM_SOC_RTK_EXT_AWB_LOCK_CTL 0x05
|
||||
#define RTSCAM_SOC_RTK_EXT_AF_LOCK_CTL 0x06
|
||||
#define RTSCAM_SOC_RTK_EXT_LED_TORCH_CTL 0x07
|
||||
#define RTSCAM_SOC_RTK_EXT_LED_FLASH_CTL 0x08
|
||||
#define RTSCAM_SOC_RTK_EXT_ISO_CTL 0x09
|
||||
#define RTSCAM_SOC_RTK_EXT_PHOTO_SCENEMODE_CTL 0x0A
|
||||
#define RTSCAM_SOC_RTK_EXT_ROI_MODE_CTL 0x13
|
||||
/* CT_REGION_OF_INTEREST_CONTROL defined in UVC1.5 */
|
||||
#define RTSCAM_SOC_RTK_EXT_ROI_CTL 0x14
|
||||
#define RTSCAM_SOC_RTK_EXT_3ASTS_CTL 0x15
|
||||
#define RTSCAM_SOC_RTK_EXT_BURSTMODE_CTL 0x16
|
||||
#define RTSCAM_SOC_RTK_EXT_STILLMODE_CTL 0x17
|
||||
#define RTSCAM_SOC_RTK_EXT_STILLSETTING_CTL 0x18
|
||||
#define RTSCAM_SOC_RTK_EXT_IDEAEYE_SENSITIVITY_CTL 0x19
|
||||
#define RTSCAM_SOC_RTK_EXT_IDEAEYE_STATUS_CTL 0x1A
|
||||
#define RTSCAM_SOC_RTK_EXT_IDEAEYE_MODE_CTL 0x1B
|
||||
|
||||
//RTS_CAERA_SOC_REG.H
|
||||
|
||||
/* register address */
|
||||
#define RTS_REG_DATA_HOST_TO_MCU_BASE 0x00000000
|
||||
#define RTS_REG_DATA0_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*0)
|
||||
#define RTS_REG_DATA1_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*1)
|
||||
#define RTS_REG_DATA2_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*2)
|
||||
#define RTS_REG_DATA3_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*3)
|
||||
#define RTS_REG_DATA4_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*4)
|
||||
#define RTS_REG_DATA5_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*5)
|
||||
#define RTS_REG_DATA6_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*6)
|
||||
#define RTS_REG_DATA7_HOST_TO_MCU (RTS_REG_DATA_HOST_TO_MCU_BASE+4*7)
|
||||
#define RTS_REG_DATA_MCU_TO_HOST_BASE 0x00000020
|
||||
#define RTS_REG_DATA0_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*0)
|
||||
#define RTS_REG_DATA1_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*1)
|
||||
#define RTS_REG_DATA2_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*2)
|
||||
#define RTS_REG_DATA3_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*3)
|
||||
#define RTS_REG_DATA4_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*4)
|
||||
#define RTS_REG_DATA5_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*5)
|
||||
#define RTS_REG_DATA6_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*6)
|
||||
#define RTS_REG_DATA7_MCU_TO_HOST (RTS_REG_DATA_MCU_TO_HOST_BASE+4*7)
|
||||
#define RTS_REG_CMD_HOST_TO_MCU_BASE 0x00000040
|
||||
#define RTS_REG_CMD0_HOST_TO_MCU (RTS_REG_CMD_HOST_TO_MCU_BASE+4*0)
|
||||
#define RTS_REG_CMD1_HOST_TO_MCU (RTS_REG_CMD_HOST_TO_MCU_BASE+4*1)
|
||||
#define RTS_REG_MCU_CMD_STATUS 0x00000048
|
||||
|
||||
#define RTS_REG_ISP_IMAGE_BASE 0x00000100
|
||||
#define RTS_REG_YUV_FRAME_Y_START_ADDRESS_BASE RTS_REG_ISP_IMAGE_BASE
|
||||
#define RTS_REG_YUV_FRAME_UV_START_ADDRESS_BASE (RTS_REG_ISP_IMAGE_BASE+0x00000080)
|
||||
#define RTS_REG_MJPEG_FRAME_BUFFER_START_ADDRESS_BASE (RTS_REG_ISP_IMAGE_BASE+0x00000110)
|
||||
#define RTS_REG_MJPEG_FRAME_BUFFER_LENGTH (RTS_REG_ISP_IMAGE_BASE+0x00000130)
|
||||
#define RTS_REG_YUV_FRAME_OVERFLOW_COUNT (RTS_REG_ISP_IMAGE_BASE+0x00000158)
|
||||
#define RTS_REG_MJPEG_FRAME_OVERFLOW_COUNT (RTS_REG_ISP_IMAGE_BASE+0x0000015C)
|
||||
#define RTS_REG_FRAME_BUFFER_COUNT (RTS_REG_ISP_IMAGE_BASE+0x00000160)
|
||||
#define RTS_REG_ISP_CONTROL (RTS_REG_ISP_IMAGE_BASE+0x00000164)
|
||||
#define RTS_REG_YUV_ISP_BUF_CONFIG_BASE (RTS_REG_ISP_IMAGE_BASE+0x0000016C)
|
||||
#define RTS_REG_YUV_ISP_Y_BUF_CONFIG_S0 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*0)
|
||||
#define RTS_REG_YUV_ISP_UV_BUF_CONFIG_S0 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*1)
|
||||
#define RTS_REG_YUV_ISP_Y_BUF_CONFIG_S1 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*2)
|
||||
#define RTS_REG_YUV_ISP_UV_BUF_CONFIG_S1 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*3)
|
||||
#define RTS_REG_YUV_ISP_Y_BUF_CONFIG_S2 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*4)
|
||||
#define RTS_REG_YUV_ISP_UV_BUF_CONFIG_S2 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*5)
|
||||
#define RTS_REG_YUV_ISP_Y_BUF_CONFIG_S3 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*6)
|
||||
#define RTS_REG_YUV_ISP_UV_BUF_CONFIG_S3 (RTS_REG_YUV_ISP_BUF_CONFIG_BASE+4*7)
|
||||
#define RTS_REG_MJPEG_ISP_BUF_CONFIG (RTS_REG_ISP_IMAGE_BASE+0x0000018C)
|
||||
#define RTS_REG_TD_ISP_BUF_CONFIG (RTS_REG_ISP_IMAGE_BASE+0x00000190)
|
||||
#define RTS_REG_STREAM_FRAME_INTERVAL_CONFIG (RTS_REG_ISP_IMAGE_BASE+0x00000198)
|
||||
#define RTS_REG_PTS_VALUE_CONFIG (RTS_REG_ISP_IMAGE_BASE+0x000001A0)
|
||||
#define RTS_REG_YUV_FRAME_BUFFER_STATUS_BASE (RTS_REG_ISP_IMAGE_BASE+0x000001A4)
|
||||
#define RTS_REG_MJPEG_STREAM_FRAME_BUFFER_STATUS (RTS_REG_ISP_IMAGE_BASE+0x000001B4)
|
||||
#define RTS_REG_TD_BUFFER_START_ADDRESS (RTS_REG_ISP_IMAGE_BASE+0x000001B8)
|
||||
#define RTS_REG_TD_BUFFER_LENGTH (RTS_REG_ISP_IMAGE_BASE+0x000001BC)
|
||||
#define RTS_REG_YUV_Cur_Frame_Index_Offset (RTS_REG_ISP_IMAGE_BASE+0x000001C0)
|
||||
#define RTS_REG_MJPEG_Cur_Frame_Index (RTS_REG_ISP_IMAGE_BASE+0x000001D0)
|
||||
#define RTS_REG_YUV_ISP_Y_BUFFER_OVERFLOW_COUNT (RTS_REG_ISP_IMAGE_BASE+0x000001D4)
|
||||
#define RTS_REG_YUV_ISP_UV_BUFFER_OVERFLOW_COUNT (RTS_REG_ISP_IMAGE_BASE+0x000001D8)
|
||||
#define RTS_REG_MJPEG_TD_ISP_BUFFER_OVERFLOW_COUNT (RTS_REG_ISP_IMAGE_BASE+0x000001DC)
|
||||
#define RTS_REG_MJPEG_FRAME_RECVED_LENGTH (RTS_REG_ISP_IMAGE_BASE+0x000001E0)
|
||||
#define RTS_REG_LDC_MAP_TABLE_START (RTS_REG_ISP_IMAGE_BASE+0x000001E0)
|
||||
#define RTS_REG_LDC_MAP_TABLE_SIZE (RTS_REG_ISP_IMAGE_BASE+0x000001E4)
|
||||
#define RTS_REG_ISP_HEADER_ADDR (RTS_REG_ISP_IMAGE_BASE+0x000001F0)
|
||||
#define RTS_REG_ISP_OCP_IF_DUMMY (RTS_REG_ISP_IMAGE_BASE+0x00000200)
|
||||
|
||||
#define RTS_REG_SPI_BASE 0x00000400
|
||||
#define RTS_REG_MCU_SPI_BASE_ADDR RTS_REG_SPI_BASE
|
||||
#define RTS_REG_CPU_LOCK_MCU (RTS_REG_SPI_BASE+0x00000004)
|
||||
|
||||
#define RTS_REG_ISP_INT_BASE 0x00000500
|
||||
#define RTS_REG_INT_EN_MCU_TO_HOST RTS_REG_ISP_INT_BASE
|
||||
#define RTS_REG_INT_EN_ISP_TO_HOST (RTS_REG_ISP_INT_BASE+0x00000004)
|
||||
#define RTS_REG_INT_FLAG_MCU_TO_HOST (RTS_REG_ISP_INT_BASE+0x00000008)
|
||||
#define RTS_REG_INT_FLAG_ISP_HOST (RTS_REG_ISP_INT_BASE+0x0000000C)
|
||||
|
||||
//RTS_CAMERA.H
|
||||
|
||||
struct rtscam_video_format_xlate {
|
||||
__u8 index;
|
||||
bool is_yuv;
|
||||
__u8 rts_code;
|
||||
__u8 bpp;
|
||||
};
|
||||
|
||||
struct rtscam_video_device {
|
||||
//struct v4l2_device v4l2_dev;
|
||||
//struct device *dev; /*initialized by user*/
|
||||
|
||||
//struct vb2_alloc_ctx *alloc_ctx; /*initialized by user*/
|
||||
//const struct vb2_mem_ops *mem_ops; /*initialized by user*/
|
||||
unsigned streamnum; /*initialized by user*/
|
||||
struct rtscam_video_stream *streams; /*initialized by user*/
|
||||
//struct rtscam_video_ops *ops; /*initialized by user*/
|
||||
//const char *drv_name; /*initialized by user*/
|
||||
//const char *dev_name; /*initialized by user*/
|
||||
int video_nr; /*initialized by user*/
|
||||
u32 type; /*initialized by user*/
|
||||
|
||||
//struct mutex dev_lock;
|
||||
|
||||
//struct mutex ctrl_lock;
|
||||
//struct list_head controls;
|
||||
|
||||
int streaming_count;
|
||||
//atomic_t *memory_use; /*initialized by user*/
|
||||
|
||||
//atomic_t use_count;
|
||||
|
||||
unsigned long flags;
|
||||
void *priv; /*initialized by user*/
|
||||
int initialized; /*initialized by user*/
|
||||
};
|
||||
|
||||
struct rtscam_video_stream {
|
||||
struct rtscam_video_device *icd;
|
||||
|
||||
__u8 streamid; /*initialized by user*/
|
||||
|
||||
//struct video_device *vdev;
|
||||
//struct vb2_queue vb2_vidp;
|
||||
//struct v4l2_prio_state prio; /* V4L2 priority state */
|
||||
//atomic_t active;
|
||||
|
||||
//spinlock_t lock;
|
||||
//struct mutex stream_lock;
|
||||
//struct mutex queue_lock;
|
||||
//struct list_head capture;
|
||||
|
||||
//struct rtscam_video_format *user_formats; /*initialized by user*/
|
||||
|
||||
__u8 rts_code;
|
||||
__u32 user_format;
|
||||
__u32 user_width;
|
||||
__u32 user_height;
|
||||
__u32 user_numerator;
|
||||
__u32 user_denominator;
|
||||
|
||||
__u32 bytesperline;
|
||||
__u32 sizeimage;
|
||||
|
||||
unsigned long sequence;
|
||||
|
||||
//atomic_t use_count;
|
||||
|
||||
//struct file *memory_owner;
|
||||
};
|
||||
|
||||
struct rtscam_soc_snr_fmt {
|
||||
u16 width;
|
||||
u16 height;
|
||||
u8 snr_fmt;
|
||||
};
|
||||
|
||||
struct rtscam_soc_dev {
|
||||
unsigned int base;
|
||||
|
||||
unsigned long iostart;
|
||||
unsigned int iosize;
|
||||
|
||||
int initialized;
|
||||
//atomic_t init_count;
|
||||
|
||||
//atomic_t mcu_count;
|
||||
int mcu_state;
|
||||
|
||||
//struct completion cmd_completion;
|
||||
//struct mutex cmd_lock;
|
||||
_Mutex cmd_lock;
|
||||
|
||||
struct rtscam_soc_device_descriptor dev_desc;
|
||||
struct rtscam_soc_unit_descriptor entities[3];
|
||||
struct rtscam_soc_hclk_descriptor hclk_desc;
|
||||
|
||||
struct rtscam_soc_api_version api_version;
|
||||
|
||||
u32 sensor_frmival;
|
||||
|
||||
struct rtscam_video_device rvdev;
|
||||
|
||||
//struct rtscam_soc_slot_info slot_info[RTSCAM_SOC_MAX_STREAM_NUM];
|
||||
//struct rtscam_soc_skip_info skip_info[RTSCAM_SOC_MAX_STREAM_NUM];
|
||||
|
||||
unsigned long mtd_status;
|
||||
|
||||
struct rtscam_soc_fw_version_t fw_version;
|
||||
|
||||
int td_enable;
|
||||
|
||||
int ldc_enable;
|
||||
|
||||
u32 isp_capibility;
|
||||
|
||||
u32 mcu_timeout;
|
||||
};
|
||||
|
||||
enum rtscam_size_type {
|
||||
RTSCAM_SIZE_DISCRETE = 0,
|
||||
RTSCAM_SIZE_STEPWISE = 1,
|
||||
RTSCAM_SIZE_CONTINUOUS = 2,
|
||||
};
|
||||
|
||||
struct rtscam_frame_size {
|
||||
__u32 width;
|
||||
__u32 height;
|
||||
};
|
||||
|
||||
|
||||
enum rtscam_state {
|
||||
RTSCAM_STATE_PASSIVE = 0,
|
||||
RTSCAM_STATE_ACTIVE = 1
|
||||
};
|
||||
|
||||
/* Ctrl flags */
|
||||
#define RTS_CTRL_FLAG_SET_CUR (1 << 0)
|
||||
#define RTS_CTRL_FLAG_GET_CUR (1 << 1)
|
||||
#define RTS_CTRL_FLAG_GET_MIN (1 << 2)
|
||||
#define RTS_CTRL_FLAG_GET_MAX (1 << 3)
|
||||
#define RTS_CTRL_FLAG_GET_RES (1 << 4)
|
||||
#define RTS_CTRL_FLAG_GET_LEN (1 << 5)
|
||||
#define RTS_CTRL_FLAG_GET_INFO (1 << 6)
|
||||
#define RTS_CTRL_FLAG_GET_DEF (1 << 7)
|
||||
/* Control should be saved at suspend and restored at resume. */
|
||||
#define RTS_CTRL_FLAG_RESTORE (1 << 8)
|
||||
#define RTS_CTRL_FLAG_AUTO_UPDATE (1 << 9)
|
||||
|
||||
#define RTS_CTRL_FLAG_GET_RANGE \
|
||||
(RTS_CTRL_FLAG_GET_CUR | RTS_CTRL_FLAG_GET_MIN | \
|
||||
RTS_CTRL_FLAG_GET_MAX | RTS_CTRL_FLAG_GET_RES | \
|
||||
RTS_CTRL_FLAG_GET_DEF)
|
||||
|
||||
#define RTS_CTRL_DATA_TYPE_RAW 0
|
||||
#define RTS_CTRL_DATA_TYPE_SIGNED 1
|
||||
#define RTS_CTRL_DATA_TYPE_UNSIGNED 2
|
||||
#define RTS_CTRL_DATA_TYPE_BOOLEAN 3
|
||||
#define RTS_CTRL_DATA_TYPE_ENUM 4
|
||||
#define RTS_CTRL_DATA_TYPE_BITMASK 5
|
||||
|
||||
#define RTS_CTRL_DATA_CURRENT 0
|
||||
#define RTS_CTRL_DATA_BACKUP 1
|
||||
#define RTS_CTRL_DATA_MIN 2
|
||||
#define RTS_CTRL_DATA_MAX 3
|
||||
#define RTS_CTRL_DATA_RES 4
|
||||
#define RTS_CTRL_DATA_DEF 5
|
||||
#define RTS_CTRL_DATA_LAST 6
|
||||
|
||||
#define RTS_CTRL_SET_CUR 0x01
|
||||
#define RTS_CTRL_GET_CUR 0x81
|
||||
#define RTS_CTRL_GET_MIN 0x82
|
||||
#define RTS_CTRL_GET_MAX 0x83
|
||||
#define RTS_CTRL_GET_RES 0x84
|
||||
#define RTS_CTRL_GET_LEN 0x85
|
||||
#define RTS_CTRL_GET_INFO 0x86
|
||||
#define RTS_CTRL_GET_DEF 0x87
|
||||
|
||||
struct rtscam_video_ctrl_info {
|
||||
__u8 index;
|
||||
__u8 unit;
|
||||
__u8 selector;
|
||||
__u8 size;
|
||||
__u32 flags;
|
||||
};
|
||||
|
||||
struct rtscam_video_ctrl_menu {
|
||||
__u32 value;
|
||||
__u8 name[32];
|
||||
};
|
||||
|
||||
struct rtscam_queryctrl{
|
||||
__u32 id;
|
||||
__u32 type;
|
||||
__s32 minimum;
|
||||
__s32 maximum;
|
||||
__s32 step;
|
||||
__s32 default_value;
|
||||
__u32 flags;
|
||||
__u32 info;
|
||||
__u32 len;
|
||||
};
|
||||
|
||||
struct rtscam_control {
|
||||
__u32 id;
|
||||
__s32 value;
|
||||
__u32 type;
|
||||
};
|
||||
|
||||
struct rtscam_soc_cmd_stru {
|
||||
__u16 cmdcode;
|
||||
__u8 index;
|
||||
__u8 length;
|
||||
__u16 param;
|
||||
__u16 addr;
|
||||
__u8 *buf;
|
||||
__u32 error_type;
|
||||
};
|
||||
|
||||
struct rtscam_soc_stream_format{
|
||||
__u16 width;
|
||||
__u16 height;
|
||||
__u32 format;
|
||||
};
|
||||
|
||||
int rtscam_soc_exec_command(struct rtscam_soc_dev *rsocdev,struct rtscam_soc_cmd_stru *cmd);
|
||||
|
||||
#define RTSCAM_S_CTRL 0
|
||||
#define RTSCAM_G_CTRL 1
|
||||
#define RTSCAM_QUERYCTRL 2
|
||||
|
||||
#define RTSCAM_L_BYTE(a) ((a) & 0xff)
|
||||
#define RTSCAM_H_BYTE(a) (((a) >> 8) & 0xff)
|
||||
#define RTSCAM_L_WORD(a) ((a) & 0xffff)
|
||||
#define RTSCAM_H_WORD(a) (((a) >> 16) & 0xffff)
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue