Initial commit: TXW82x FPV v2.7.0.7-42229 SDK + project sources

This commit is contained in:
2026-07-06 11:30:13 +08:00
commit e76462eeb7
3451 changed files with 1415300 additions and 0 deletions

View File

@@ -0,0 +1,727 @@
#include "sys_config.h"
#include "typesdef.h"
#include "lib/video/dvp/cmos_sensor/csi.h"
#include "lib/video/dvp/cmos_sensor/csi_V2.h"
#include "devid.h"
#include "hal/gpio.h"
#include "osal/irq.h"
#include "osal/string.h"
#include "dev/vpp/hgvpp.h"
#include "dev/csi/hgdvp.h"
#include "lib/lcd/lcd.h"
#include "hal/jpeg.h"
#include "lib/video/isp/isp_dev.h"
#include "app_iic/app_iic.h"
#include "lib/video/vpp/vpp_dev.h"
#include "lib/heap/av_heap.h"
#ifdef PIN_FROM_PARAM
#include "pin_param.h"
#endif
#define RESET_HIGH() {gpio_set_val(rsn,1);}
#define RESET_LOW() {gpio_set_val(rsn,0);}
#define IIC_CLK 120000UL
uint8 u8SensorwriteID,u8SensorreadID;
uint8 u8Addrbytnum,u8Databytnum;
static uint8 g_byDevWriteAddr;
static uint8 g_byDevReadAddr;
_Sensor_Ident_ *devSensorInit=NULL;
SNSER snser;
struct dvp_device *dvp_test;
struct i2c_device *iic_test;
struct vpp_device *vpp_test;
static const _Sensor_Ident_ *devSensorInitTable[] = {
#if DEV_SENSOR_GC0308
&gc0308_init,
#endif
#if DEV_SENSOR_BF20A6
&bf20a6_init,
#endif
#if DEV_SENSOR_GC0309
&gc0309_init,
#endif
#if DEV_SENSOR_GC0311
&gc0311_init,
#endif
#if DEV_SENSOR_GC0312
&gc0312_init,
#endif
#if DEV_SENSOR_GC0328
&gc0328_init,
#endif
#if DEV_SENSOR_GC0329
&gc0329_init,
#endif
#if DEV_SENSOR_BF3A03
&bf3a03_init,
#endif
#if DEV_SENSOR_BF3703
&bf3703_init,
#endif
#if DEV_SENSOR_OV2640
&ov2640_init,
#endif
#if DEV_SENSOR_OV7725
&ov7725_init,
#endif
#if DEV_SENSOR_OV7670
&ov7670_init,
#endif
#if DEV_SENSOR_BF2013
&bf2013_init,
#endif
#if DEV_SENSOR_XC7016_H63
&xc7016_h63_init,
#endif
#if DEV_SENSOR_XC7011_H63
&xc7011_h63_init,
#endif
#if DEV_SENSOR_XC7011_GC1054
&xc7011_gc1054_init,
#endif
#if DEV_SENSOR_XCG532
&xcg532_init,
#endif
#if DEV_SENSOR_GC2145
&gc2145_init,
#endif
#if DEV_SENSOR_SP0718
&sp0718_init,
#endif
#if DEV_SENSOR_SP0A19
&sp0a19_init,
#endif
#if DEV_SENSOR_BF3720
&bf3720_init,
#endif
#if DEV_SENSOR_SC1346
&sc1346_init,
#endif
NULL,
};
static const _Sensor_Adpt_ *devSensorOPTable[] = {
#if DEV_SENSOR_GC0308
&gc0308_cmd,
#endif
#if DEV_SENSOR_BF20A6
&bf20a6_cmd,
#endif
#if DEV_SENSOR_GC0309
&gc0309_cmd,
#endif
#if DEV_SENSOR_GC0311
&gc0311_cmd,
#endif
#if DEV_SENSOR_GC0312
&gc0312_cmd,
#endif
#if DEV_SENSOR_GC0328
&gc0328_cmd,
#endif
#if DEV_SENSOR_GC0329
&gc0329_cmd,
#endif
#if DEV_SENSOR_BF3A03
&bf3a03_cmd,
#endif
#if DEV_SENSOR_BF3703
&bf3703_cmd,
#endif
#if DEV_SENSOR_OV2640
&ov2640_cmd,
#endif
#if DEV_SENSOR_OV7725
&ov7725_cmd,
#endif
#if DEV_SENSOR_OV7670
&ov7670_cmd,
#endif
#if DEV_SENSOR_BF2013
&bf2013_cmd,
#endif
#if DEV_SENSOR_XC7016_H63
&xc7016_h63_cmd,
#endif
#if DEV_SENSOR_XC7011_H63
&xc7011_h63_cmd,
#endif
#if DEV_SENSOR_XC7011_GC1054
&xc7011_gc1054_cmd,
#endif
#if DEV_SENSOR_XCG532
&xcg532_cmd,
#endif
#if DEV_SENSOR_GC2145
&gc2145_cmd,
#endif
#if DEV_SENSOR_SP0718
&sp0718_cmd,
#endif
#if DEV_SENSOR_SP0A19
&sp0a19_cmd,
#endif
#if DEV_SENSOR_BF3720
&bf3720_cmd,
#endif
#if DEV_SENSOR_SC1346
&sc1346_cmd,
#endif
};
const _Sensor_Ident_ null_init={0x00,0x00,0x00,0x00,0x00,0x00};
volatile uint8 mipi_dvp_devid0;
volatile uint8 mipi_dvp_devid1;
/*******************************************************************************
* Function Name : Delay_Cnt
* Description : delay cnt nop
* Input : nop number
* Output : None
* Return : None
*******************************************************************************/
extern void Delay_nopCnt(uint32 cnt);
/*******************************************************************************
* Function Name : sensor_reset
* Description : for sensor reset before start
* Input : nop number
* Output : None
* Return : None
*******************************************************************************/
__weak void sensor_reset(void){
uint8_t rsn,pdn;
pdn = PIN_DVP_PDN;//get_func_io("dvp", "PDN");
if(pdn != 255){
gpio_iomap_output(pdn,GPIO_IOMAP_OUTPUT);
gpio_set_val(pdn,0);
os_sleep_ms(100);
gpio_set_val(pdn,1);
os_sleep_ms(1);
gpio_set_val(pdn,1);
}
rsn = PIN_DVP_RESET;//get_func_io("dvp", "RSN");
if(rsn != 255){
gpio_iomap_output(rsn,GPIO_IOMAP_OUTPUT);
}
else{
os_sleep_ms(200);
return;
}
RESET_HIGH();
os_sleep_ms(50);
RESET_LOW();
os_sleep_ms(200);
RESET_HIGH();
os_sleep_ms(50);
}
void i2c_SetSetting(struct i2c_setting *p_i2c_setting)
{
if(!p_i2c_setting)
return;
g_byDevWriteAddr = p_i2c_setting->u8DevWriteAddr;
g_byDevReadAddr = p_i2c_setting->u8DevReadAddr;
return;
}
int sensorCheckId(uint8_t devid,const _Sensor_Ident_ *p_sensor_ident,const _Sensor_Adpt_ *p_sensor_adpt)
{
int8 u8Buf[3];
uint8_t tablebuf[16];
uint32 id= 0;
uint32 i = 0;
uint32 k = 0;
u8SensorwriteID = p_sensor_ident->w_cmd;
u8SensorreadID =p_sensor_ident->r_cmd;
u8Addrbytnum = p_sensor_ident->addr_num;
u8Databytnum = p_sensor_ident->data_num;
tablebuf[0] = p_sensor_ident->addr_num;
tablebuf[1] = p_sensor_ident->data_num;
//i2c_ioctl(p_iic,IIC_SET_DEVICE_ADDR,u8SensorwriteID>>1);
tablebuf[2] = u8SensorwriteID>>1;
//id = i2c_sensor_read(p_iic,u8Buf,p_sensor_ident->addr_num,p_sensor_ident->data_num,u8SensorwriteID,u8SensorreadID);
if(p_sensor_adpt->preset){
for(i=0;;i+=p_sensor_ident->data_num+p_sensor_ident->addr_num){
if((p_sensor_adpt->preset[i]==0xFF)&&(p_sensor_adpt->preset[i+1]==0xFF)){
os_printf("preset table num:%d\r\n",i);
break;
}
for(k = 0;k < (p_sensor_ident->addr_num + p_sensor_ident->data_num);k++){
tablebuf[3+k] = p_sensor_adpt->preset[i+k];
}
wake_up_iic_queue(devid,tablebuf,0,1,(uint8_t*)NULL);
while(iic_devid_finish(devid) != 1){
os_sleep_ms(1);
}
//i2c_write(iic_test, (int8*)&p_sensor_adpt->preset[i],p_sensor_ident->addr_num, (int8*)&p_sensor_adpt->preset[i+p_sensor_ident->addr_num], p_sensor_ident->data_num);
}
}
u8Buf[0] = p_sensor_ident->id_reg;
if(p_sensor_ident->addr_num == 2)
{
u8Buf[0] = p_sensor_ident->id_reg>>8;
u8Buf[1] = p_sensor_ident->id_reg;
}
k = 0;
tablebuf[3+k] = u8Buf[0];
k++;
if(p_sensor_ident->addr_num == 2){
tablebuf[3+k] = u8Buf[1];
k++;
}
tablebuf[3+k] = tablebuf[4+k] = tablebuf[5+k] = tablebuf[6+k] = 0;
//i2c_read(p_iic,u8Buf,p_sensor_ident->addr_num,(int8*)&id,p_sensor_ident->data_num);
wake_up_iic_queue(devid,tablebuf,0,0,(uint8_t*)NULL);
while(iic_devid_finish(devid) != 1){
os_sleep_ms(1);
}
id = tablebuf[3+k] | (tablebuf[4+k]<<8) | (tablebuf[5+k]<<16) | (tablebuf[6+k]<<24);
os_printf("SID: %x, %x, %x, %x,%x\r\n",id,p_sensor_ident->id,u8SensorwriteID,u8SensorreadID,p_sensor_ident->id_reg);
if(id == p_sensor_ident->id){
iic_devid_set_addr(devid,u8SensorwriteID>>1);
return 1;
}
else
return -1;
}
/*******************************************************************************
* Function Name : Sensor_ReadRegister
* Description : read sensor register
* Input : *pbdata :sensor register addr
u8AddrLength:sensor register addr length
u8DataLength:sensor register data length
* Output : None
* Return : u32i2cReadResult:the result from sensor register
*******************************************************************************/
static _Sensor_Adpt_ * sensorAutoCheck(uint8_t devid,uint8 *init_buf)
{
uint8 i;
_Sensor_Adpt_ * devSensor_Struct=NULL;
for(i=0;devSensorInitTable[i] != NULL;i++)
{
sensor_reset();
if(sensorCheckId(devid,devSensorInitTable[i],devSensorOPTable[i])>=0)
{
os_printf("id =%x num:%d \n",devSensorInitTable[i]->id,i);
devSensorInit = (_Sensor_Ident_ *) devSensorInitTable[i];
//#if CMOS_AUTO_LOAD
// devSensor_Struct = sensor_adpt_load(devSensorInit->id,devSensorInit->w_cmd,devSensorInit->r_cmd,init_buf);
//#else
devSensor_Struct = (_Sensor_Adpt_ *) devSensorOPTable[i];
//#endif
break;
}
}
if(devSensor_Struct == NULL)
{
os_printf("Er: unkown!");
devSensorInit = (_Sensor_Ident_ *)&null_init;
return NULL; // index 0 is test only
}
return devSensor_Struct;
}
volatile uint8 yuv_buf_head[16]__attribute__ ((section(".sbss")));;
__psram_data uint8 psram_ybuf_src[IMAGE_H*IMAGE_W+IMAGE_H*IMAGE_W/2] __aligned(4);
//__psram_data uint8 psram_ubuf_src[IMAGE_H*IMAGE_W/4] __aligned(4);
//__psram_data uint8 psram_vbuf_src[IMAGE_H*IMAGE_W/4] __aligned(4);
__psram_data volatile uint8 psram_buf_head[16];
#if ONLY_Y
__psram_data uint8 psram_buf[IMAGE_H][IMAGE_W] __aligned(4);
#endif
__psram_data uint8 psram_buf_tail[2032];
volatile uint32 line_buf = 0;
extern volatile uint32 done_dvp;
volatile uint32 vs_isr;
volatile uint32 vpp_get_src = 0;
void dvp_line_isr(uint32 irq,uint32 image_h,uint32 param){
}
void dvp_fhfie_isr(uint32 irq,uint32 dev,uint32 param){
os_printf("fh\r\n");
}
void dvp_fovie_isr(uint32 irq,uint32 dev,uint32 param){
//dvp_vpp_reset();
os_printf("------------------------------------------------------------------------------dvp fv\r\n");
}
void dvp_sip_isr(uint32 irq,uint32 dev,uint32 param){
//dvp_vpp_reset();
os_printf("sip reset DVP\r\n");
}
void dvp_line_isr_test(uint32 irq,uint32 image_h,uint32 param){
return;
}
struct hgdvp_hw *dvp_watch;
bool csi_yuv_mode(){
struct i2c_device *iic_dev;
static _Sensor_Adpt_ *p_sensor_cmd = NULL;
struct i2c_setting i2c_setting;
int8 idbuf[8];
uint8_t itk=0;
uint32 i=0;
uint32 k = 0;
uint8 adr_num,dat_num;
uint8 sen_w_cmd,sen_r_cmd,id_c = 0;
uint16 image_w,image_h;
uint8_t tablebuf[16];
dvp_test = (struct dvp_device *)dev_get(HG_DVP_DEVID);
iic_dev = (struct i2c_device *)dev_get(HG_I2C1_DEVID);
dvp_init(dvp_test);
dvp_close(dvp_test);
//1:init iic
os_printf("csi_test start,iic init\r\n");
mipi_dvp_devid0 = register_iic_queue(iic_dev,MACRO_PIN(PIN_DVP0_IIC_CLK),MACRO_PIN(PIN_DVP0_IIC_SDA),0);
gpio_iomap_output(MACRO_PIN(PIN_DVP_MCLK), GPIO_IOMAP_OUT_DVP_MCLK_OUT);
os_printf("iic init finish,sensor reset & set sensor clk into 6M\r\n");
//2:init sensor
dvp_set_baudrate(dvp_test,6000000);
os_sleep_ms(3);
os_printf("set sensor finish ,Auto Check sensor id\r\n");
p_sensor_cmd = snser.p_sensor_cmd = sensorAutoCheck(mipi_dvp_devid0,NULL);
if(p_sensor_cmd == NULL){
// i2c_close(iic_test);
return FALSE;
}
sensor_info_add(SENSOR_TYPE_MASTER, (DUAL_EN) ? (ISP_INPUT_DAT_SRC_ORG_DMA) : (ISP_INPUT_DAT_SRC_DVP), (uint32)p_sensor_cmd->sensor_isp, mipi_dvp_devid0, u8SensorwriteID);
os_printf("Auto Check sensor id finish\r\n");
i2c_setting.u8DevWriteAddr = p_sensor_cmd->w_cmd;
i2c_setting.u8DevReadAddr = p_sensor_cmd->r_cmd;
i2c_SetSetting(&i2c_setting);
os_printf("mclk:%dMHz\r\n",p_sensor_cmd->mclk);
dvp_set_baudrate(dvp_test,p_sensor_cmd->mclk);
os_printf("init:%x u8Addrbytnum:%d,u8Databytnum:%d\r\n",(uint32)p_sensor_cmd->init,u8Addrbytnum,u8Databytnum);
if(p_sensor_cmd->init!=NULL)
{
os_printf("SENSER....init\r\n");
for(i=0;;i+=u8Addrbytnum+u8Databytnum)
{
if((p_sensor_cmd->init[i]==0xFF)&&(p_sensor_cmd->init[i+1]==0xFF)){
os_printf("init table num:%d\r\n",i);
break;
}
if((p_sensor_cmd->init[i]==0xFE)&&(p_sensor_cmd->init[i+1]==0xFE)){
if(p_sensor_cmd->init[i+2]==0x01){
os_sleep_ms(100);
}
}
else{
for(itk = 0;itk < u8Addrbytnum+u8Databytnum;itk++){
idbuf[itk] = p_sensor_cmd->init[i+itk];
}
tablebuf[0] = u8Addrbytnum;
tablebuf[1] = u8Databytnum;
tablebuf[2] = u8SensorwriteID>>1;
for(k = 0;k < (tablebuf[0] + tablebuf[1]);k++){
tablebuf[3+k] = idbuf[k];
}
wake_up_iic_queue(mipi_dvp_devid0,tablebuf,0,1,(uint8_t*)NULL);
while(iic_devid_finish(mipi_dvp_devid0) != 1){
os_sleep_ms(1);
}
//i2c_write(iic_test, (int8*)&idbuf[0], u8Addrbytnum, (int8*)&idbuf[u8Addrbytnum], u8Databytnum);
if(i==0)
{
os_sleep_ms(1);
}
}
}
if(p_sensor_cmd->p_xc7016_adapt.sensor_init_table != NULL)
{
adr_num = p_sensor_cmd->p_xc7016_adapt.addr_num;
dat_num = p_sensor_cmd->p_xc7016_adapt.data_num;
sen_w_cmd = u8SensorwriteID;
sen_r_cmd = u8SensorreadID;
u8SensorwriteID = p_sensor_cmd->p_xc7016_adapt.w_cmd;
u8SensorreadID = p_sensor_cmd->p_xc7016_adapt.r_cmd;
idbuf[0] = p_sensor_cmd->p_xc7016_adapt.id_reg;
//id_c = i2c_sensor_read(iic_test,idbuf,adr_num,dat_num,u8SensorwriteID,u8SensorreadID);
//i2c_ioctl(iic_test,IIC_SET_DEVICE_ADDR,u8SensorwriteID>>1);
tablebuf[0] = adr_num;
tablebuf[1] = dat_num;
tablebuf[2] = u8SensorwriteID>>1;
iic_devid_set_addr(mipi_dvp_devid0,u8SensorwriteID>>1);
k = 0;
tablebuf[3+k] = idbuf[0];
k++;
if(adr_num == 2){
tablebuf[3+k] = idbuf[1];
k++;
}
tablebuf[3+k] = tablebuf[4+k] = tablebuf[5+k] = tablebuf[6+k] = 0;
wake_up_iic_queue(mipi_dvp_devid0,tablebuf,0,0,(uint8_t*)NULL);
while(iic_devid_finish(mipi_dvp_devid0) != 1){
os_sleep_ms(1);
}
//i2c_read(iic_test,idbuf,adr_num,(int8*)&id_c,dat_num);
id_c = tablebuf[3+k] | (tablebuf[4+k]<<8) | (tablebuf[5+k]<<16) | (tablebuf[6+k]<<24);
os_printf("\r\nchildren SID: %x %x %x\r\n",id_c,u8SensorwriteID,u8SensorreadID);
for(i=0;;i+=adr_num+dat_num)
{
if((p_sensor_cmd->p_xc7016_adapt.sensor_init_table[i]==0xFF)&&(p_sensor_cmd->p_xc7016_adapt.sensor_init_table[i+1]==0xFF)){
os_printf("sensor table num:%d\r\n",i);
break;
}
for(itk = 0;itk < adr_num+dat_num;itk++){
idbuf[itk] = p_sensor_cmd->p_xc7016_adapt.sensor_init_table[i+itk];
}
tablebuf[0] = u8Addrbytnum;
tablebuf[1] = u8Databytnum;
tablebuf[2] = u8SensorwriteID>>1;
for(k = 0;k < (tablebuf[0] + tablebuf[1]);k++){
tablebuf[3+k] = idbuf[k];
}
wake_up_iic_queue(mipi_dvp_devid0,tablebuf,0,1,(uint8_t*)NULL);
while(iic_devid_finish(mipi_dvp_devid0) != 1){
os_sleep_ms(1);
}
//i2c_write(iic_test, (int8*)&idbuf[0], adr_num, (int8*)&idbuf[adr_num], dat_num);
if(i==0)
{
os_sleep_ms(1);
}
}
u8SensorwriteID = sen_w_cmd;
u8SensorreadID = sen_r_cmd;
i2c_ioctl(iic_test,IIC_SET_DEVICE_ADDR,u8SensorwriteID>>1);
for(i=0;;i+=u8Addrbytnum+u8Databytnum)
{
if((p_sensor_cmd->p_xc7016_adapt.bypass_off[i]==0xFF)&&(p_sensor_cmd->p_xc7016_adapt.bypass_off[i+1]==0xFF)){
os_printf("bypass table num:%d\r\n",i);
break;
}
for(itk = 0;itk < u8Addrbytnum+u8Databytnum;itk++){
idbuf[itk] = p_sensor_cmd->p_xc7016_adapt.bypass_off[i+itk];
}
tablebuf[0] = u8Addrbytnum;
tablebuf[1] = u8Databytnum;
tablebuf[2] = u8SensorwriteID>>1;
for(k = 0;k < (tablebuf[0] + tablebuf[1]);k++){
tablebuf[3+k] = idbuf[k];
}
wake_up_iic_queue(mipi_dvp_devid0,tablebuf,0,1,(uint8_t*)NULL);
while(iic_devid_finish(mipi_dvp_devid0) != 1){
os_sleep_ms(1);
}
//i2c_write(iic_test, (int8*)&idbuf[0], u8Addrbytnum, (int8*)&idbuf[u8Addrbytnum], u8Databytnum);
if(i==0)
{
os_sleep_ms(1);
}
}
}
}
os_printf("SENSR ident ok:%d*%d\r\n",p_sensor_cmd->pixelw,p_sensor_cmd->pixelh);
#if SCEN_EN
image_h = p_sensor_cmd->pixelh/2;
image_w = p_sensor_cmd->pixelw/2;
#else
image_h = p_sensor_cmd->pixelh;
image_w = p_sensor_cmd->pixelw;
#endif
video_msg.dvp_iw = image_w;
video_msg.dvp_ih = image_h;
// video_msg.dvp_ow = image_w;
// video_msg.dvp_oh = image_h;
video_msg.dvp_type = 1;
video_msg.video_type_cur = ISP_VIDEO_0;
video_msg.video_type_last = ISP_VIDEO_0;
video_msg.video_num++;
//3:init csi
os_printf("csi init start --\r\n");
os_printf("csi set size ====>%d*%d\r\n",image_w,image_h);
dvp_set_vsync_rst_offline(dvp_test,0,30*1000/32);
#if SCEN_EN
dvp_set_half_size(dvp_test,1);
#endif
dvp_set_size(dvp_test,0,0,p_sensor_cmd->pixelw,p_sensor_cmd->pixelh);
dvp_set_hsync_polarity(dvp_test,p_sensor_cmd->hsyn);
dvp_set_vsync_polarity(dvp_test,p_sensor_cmd->vsyn);
dvp_set_format(dvp_test,IMAGE_FORMAT);
dvp_8BITS_map(dvp_test,0);
//dvp_set_exchange_d5_d6(dvp_test,0);
os_printf("csi IRQ init\r\n");
dvp_request_irq(dvp_test,HSIP_ISR, (dvp_irq_hdl )&dvp_sip_isr,0);
dvp_request_irq(dvp_test,FOVIE_ISR,(dvp_irq_hdl )&dvp_fovie_isr,0);
//dvp_open(dvp_test);
os_printf("csi IRQ init finish,start get data\r\n");
return TRUE;
}
bool csi_cfg(){
bool ret;
ret = csi_yuv_mode();
return ret;
}
bool csi_open(){
dvp_open(dvp_test);
return 1;
}
bool csi_close(){
dvp_close(dvp_test);
return 1;
}
void get_single_dvp(uint16_t *w,uint16_t *h)
{
if(w)
{
*w = video_msg.dvp_iw;
}
if(h)
{
*h = video_msg.dvp_ih;
}
return;
}

View File

@@ -0,0 +1,460 @@
#include "basic_include.h"
#include "lib/multimedia/msi.h"
#include "stream_define.h"
#include "lib/video/dvp/jpeg/jpg.h"
#include "dev/jpg/hgjpg.h"
#include "lib/heap/av_heap.h"
#include "lib/heap/av_psram_heap.h"
/***********************************************************
* 可以存放mjpg的公用函数组件
**********************************************************/
#define HARDWARE_JPG_NUM 2
// data申请空间函数
#define STREAM_MALLOC av_psram_malloc
#define STREAM_FREE av_psram_free
#define STREAM_ZALLOC av_psram_zalloc
// 结构体申请空间函数
#define STREAM_LIBC_MALLOC av_malloc
#define STREAM_LIBC_FREE av_free
#define STREAM_LIBC_ZALLOC av_zalloc
/*****************************************************************
* 增加mjpg模块锁,主要用于复用的时候需要对mjeg模块锁
****************************************************************/
typedef struct
{
os_event_t jpg_event;
uint8_t init;
uint8_t lock_value;
uint8_t last_lock_value;
} jpg_mutex;
enum
{
JPG_LOCK = BIT(0),
};
static jpg_mutex *jpg_mutex_table[HARDWARE_JPG_NUM];
int32 jpg_mutex_init()
{
int32_t ret = 0;
int32_t res = 0;
jpg_mutex *mutex = (jpg_mutex *) STREAM_LIBC_ZALLOC(sizeof(jpg_mutex) * 2);
jpg_mutex_table[0] = &mutex[0];
jpg_mutex_table[1] = &mutex[1];
res = os_event_init(&jpg_mutex_table[0]->jpg_event);
ret |= res;
if (!res)
{
jpg_mutex_table[0]->init = 1;
os_event_set(&jpg_mutex_table[0]->jpg_event, JPG_LOCK, NULL);
}
res = os_event_init(&jpg_mutex_table[1]->jpg_event);
ret |= res;
if (!res)
{
jpg_mutex_table[1]->init = 1;
os_event_set(&jpg_mutex_table[1]->jpg_event, JPG_LOCK, NULL);
}
os_printf("%s:%d\tret:%d\n", __FUNCTION__, __LINE__, ret);
return ret;
}
/************************************************************************
* jpgid: 硬件jpg模块ID,0:jpg0 1:jpg1
* value: 设置lock的值,只有一致才能释放
* last_value: 如果不为NULL,则返回上一次的锁值
***********************************************************************/
int32_t jpg_mutex_lock(uint32_t jpgid, uint8_t value, uint8_t *last_value)
{
ASSERT(jpgid < HARDWARE_JPG_NUM);
jpg_mutex *mutex = jpg_mutex_table[jpgid];
ASSERT(mutex && mutex->init == 1);
uint32_t rflags;
if (mutex->lock_value || value == 0)
{
if (last_value)
{
*last_value = mutex->last_lock_value;
}
return 1;
}
// 如果获取到锁,就将lock_value设置value
int32_t ret = os_event_wait(&mutex->jpg_event, JPG_LOCK, &rflags, OS_EVENT_WMODE_CLEAR, 0);
if (ret == 0)
{
if (last_value)
{
*last_value = mutex->last_lock_value;
}
mutex->lock_value = value;
}
return ret;
}
/********************************************************
* jpgid: 硬件jpg模块ID,0:jpg0 1:jpg1
* value: 设置lock的值,只有一致才能释放
******************************************************/
int32_t jpg_mutex_unlock(uint32_t jpgid, int32_t value)
{
ASSERT(jpgid < HARDWARE_JPG_NUM);
jpg_mutex *mutex = jpg_mutex_table[jpgid];
ASSERT(mutex && mutex->init == 1);
int32_t ret = 1;
// 只有相同的值才支持解锁
if (mutex->lock_value == value)
{
ret = os_event_set(&mutex->jpg_event, JPG_LOCK, NULL);
if (ret == 0)
{
mutex->last_lock_value = mutex->lock_value;
mutex->lock_value = 0;
}
}
return ret;
}
int32_t jpg_mutex_unlock_check(uint32_t jpgid, int32_t value)
{
ASSERT(jpgid < HARDWARE_JPG_NUM);
jpg_mutex *mutex = jpg_mutex_table[jpgid];
ASSERT(mutex && mutex->init == 1);
int32_t ret = 1;
// 只有相同的值才支持解锁
if (mutex->lock_value == value)
{
ret = os_event_set(&mutex->jpg_event, JPG_LOCK, NULL);
if (ret == 0)
{
mutex->lock_value = 0;
}
}
return ret;
}
struct jpg_mem_list_s;
#define JPG_MEM_LIST_COUNT (4)
struct jpg_mem_chunk
{
struct jpg_mem_chunk *next;
uint8_t del : 1, jpg_mem_map : 5, rev : 2;
uint8_t count;
uint16_t len;
struct jpg_mem_list_s *jpg_mem_list;
uint32_t t_bitmap; // 当前chunk的内存位图
uint32_t bitmap; // 内存位图
struct jpg_mem *mem[32];
};
// 内存池列表,最多N个内存池
struct jpg_mem_list_s
{
uint32_t bitmap; // 1代表有空间,0代表没有空间
uint32_t total_count; // 记录当前内存池最大的空间数量,动态增加以及动态释放
// 剩余总共内存块数量,如果有,就判断bitmap,从最低位开始寻找,释放空间优先释放高位的内存块,低位内存块尽量在完全没用的时候才释放(防止频繁申请),可以通过一个超时机制去释放(影响立刻申请空间的模块,也可以实现一个立刻释放的命令)
uint32_t remain_block_count;
struct jpg_mem_chunk *last_chunk; // 记录上一次申请空间的chunk,如果释放,还需要检查是否是最低位的,尽量从最低位的chunk申请(利于释放空间)
struct jpg_mem_chunk *chunk[JPG_MEM_LIST_COUNT];
};
// 32byte对齐,所以前面留32byte作为其他数据保存作用
struct jpg_mem
{
struct jpg_mem_chunk *chunk; // chunk的地址,相当于申请空间的chunk
struct jpg_mem *next;
uint32_t bitmap; // 固定只有一个bit被置位(代表内存块的位置)
uint32_t rev[5];
};
static struct jpg_mem_list_s jpg_mem_list;
// mjpg的内存管理,暂时不支持动态扩展,相当于预先分配
// 正常应该是可以后面动态添加以及删除
struct jpg_mem_chunk *jpg_mem_manage_init(uint8_t chunk_block)
{
if (chunk_block > 32)
{
chunk_block = 32;
}
if (!chunk_block)
{
return NULL;
}
uint8_t ret = 1;
// 先去申请空间,清除cache问题,然后再挂接到链表中
uint32_t malloc_count = 0;
struct jpg_mem_chunk *chunk = NULL;
chunk = (struct jpg_mem_chunk *) STREAM_ZALLOC(sizeof(struct jpg_mem_chunk));
if (!chunk)
{
goto jpg_mem_manage_init_end;
}
chunk->len = 16 * 1024;
for (malloc_count = 0; malloc_count < chunk_block; malloc_count++)
{
chunk->mem[malloc_count] = (struct jpg_mem *) STREAM_MALLOC(16 * 1024 + sizeof(struct jpg_mem));
if (chunk->mem[malloc_count])
{
sys_dcache_invalid_range((uint32_t *) chunk->mem[malloc_count], 16 * 1024 + sizeof(struct jpg_mem));
chunk->t_bitmap |= BIT(malloc_count);
chunk->mem[malloc_count]->bitmap = BIT(malloc_count);
chunk->mem[malloc_count]->chunk = chunk;
}
}
chunk->bitmap = chunk->t_bitmap;
chunk->count = malloc_count + 1;
// 没有申请到空间,返回错误
if (!chunk->bitmap)
{
goto jpg_mem_manage_init_end;
}
ret = 0;
jpg_mem_manage_init_end:
if (ret)
{
if (chunk)
{
STREAM_FREE(chunk);
chunk = NULL;
}
}
return chunk;
}
// 释放一个chunk
static void free_jpg_chunk(struct jpg_mem_chunk *chunk)
{
if (chunk)
{
// 不一致,不能释放,报错
ASSERT(chunk->t_bitmap == chunk->bitmap);
for (int i = 0; i < chunk->count; i++)
{
ASSERT(chunk->mem[i]);
STREAM_FREE(chunk->mem[i]);
chunk->mem[i] = NULL;
}
STREAM_FREE(chunk);
}
}
// 增加一个内存块到列表
uint8_t add_jpg_block(uint8_t chunk_block)
{
uint8_t ret = 1;
uint8_t map = 0;
struct jpg_mem_chunk *chunk = jpg_mem_manage_init(chunk_block);
if (chunk)
{
// 检查最低位是否有0,代表空闲
if (jpg_mem_list.bitmap)
{
map = __builtin_ctz(~jpg_mem_list.bitmap);
}
os_printf("jpg_block map:%d\n", map);
// list没有满,则可以添加
if (map < JPG_MEM_LIST_COUNT)
{
uint32_t flags = disable_irq();
jpg_mem_list.chunk[map] = chunk;
jpg_mem_list.bitmap |= BIT(map);
jpg_mem_list.total_count = chunk->count;
jpg_mem_list.remain_block_count += chunk->count;
chunk->jpg_mem_list = &jpg_mem_list;
chunk->jpg_mem_map = map;
enable_irq(flags);
ret = 0;
}
// 释放chunk
else
{
free_jpg_chunk(chunk);
}
}
return ret;
}
// 获取一个有内存块的chunk
static struct jpg_mem_chunk *get_free_chunk()
{
struct jpg_mem_chunk *chunk;
uint8_t map;
// os_printf("jpg_mem_list.last_chunk:%X\n", jpg_mem_list.last_chunk);
if (jpg_mem_list.last_chunk)
{
chunk = jpg_mem_list.last_chunk;
}
else
{
if (jpg_mem_list.bitmap)
{
map = __builtin_ctz(jpg_mem_list.bitmap);
chunk = jpg_mem_list.chunk[map];
}
else
{
chunk = NULL;
}
}
return chunk;
}
void *get_jpg_node(uint16_t *len)
{
struct jpg_mem *buf = NULL;
uint32_t flags = disable_irq();
struct jpg_mem_chunk *next_chunk = get_free_chunk();
uint8_t map;
uint8_t change = 1;
if (next_chunk && next_chunk->bitmap)
{
map = __builtin_ctz(next_chunk->bitmap);
buf = next_chunk->mem[map];
buf->next = NULL;
buf += 1;
next_chunk->bitmap &= (~BIT(map));
// os_printf("next_chunk->bitmap:%X\n", next_chunk->bitmap);
if (!next_chunk->bitmap)
{
next_chunk->jpg_mem_list->bitmap &= (~BIT(next_chunk->jpg_mem_map));
next_chunk->jpg_mem_list->last_chunk = NULL;
}
else
{
if (next_chunk->jpg_mem_list->last_chunk)
{
if (next_chunk->jpg_mem_list->last_chunk->jpg_mem_map < next_chunk->jpg_mem_map)
{
change = 0;
}
}
if (change)
{
next_chunk->jpg_mem_list->last_chunk = next_chunk;
}
}
if (len)
{
*len = next_chunk->len;
}
}
else
{
if (len)
{
*len = 0;
}
}
enable_irq(flags);
if (buf)
{
// os_printf("malloc map:%X\tbuf:%X\taddr:%X\n",BIT(map),buf,RETURN_ADDR());
}
else
{
os_printf("%s:%d err\n", __FUNCTION__, __LINE__);
}
return (void *) buf;
}
uint16_t get_node_len(void *buf)
{
struct jpg_mem *node = (struct jpg_mem *) buf;
if (node)
{
node -= 1;
return node->chunk->len;
}
else
{
return 0;
}
}
// 获取node是否有足够的保留空间来填充额外的数据
void *get_node_rev(void *buf, uint32_t rev_len)
{
struct jpg_mem *node = (struct jpg_mem *) buf;
if (node)
{
node -= 1;
if (sizeof(node->rev) > rev_len)
{
return node->rev;
}
}
return NULL;
}
void free_jpg_node(void *buf)
{
// os_printf("buf:%X\n",buf);
struct jpg_mem *free_buf = (struct jpg_mem *) buf;
struct jpg_mem_chunk *chunk;
free_buf -= 1;
chunk = free_buf->chunk;
uint8_t change = 1;
// 正常应该要检查是否符合,这里默认传入的地址是正确的
uint32_t flags = disable_irq();
// uint32_t map = free_buf->bitmap;
chunk->bitmap |= free_buf->bitmap;
chunk->jpg_mem_list->bitmap |= BIT(chunk->jpg_mem_map);
// os_printf("chunk->bitmap:%X\n", chunk->bitmap);
if (chunk->jpg_mem_list->last_chunk)
{
if (chunk->jpg_mem_list->last_chunk->jpg_mem_map < chunk->jpg_mem_map)
{
change = 0;
}
}
if (change)
{
chunk->jpg_mem_list->last_chunk = chunk;
}
enable_irq(flags);
// os_printf("free map:%X\tbuf:%X\n",map,buf);
// 正常应该要检查当前chunk是否要被释放,如果需要被释放,是要考虑释放空间
}
// 将一个节点放到另一个节点
void *push_node(void *head, void *next)
{
struct jpg_mem *h = (struct jpg_mem *) head;
struct jpg_mem *n = (struct jpg_mem *) next;
if (head)
{
h -= 1;
n -= 1;
h->next = n;
}
// os_printf("head:%X\tnext:%X\n",head,next);
return next;
}
// pop一个节点头出去
void *pop_node(void *head)
{
if (!head)
{
return NULL;
}
struct jpg_mem *h = (struct jpg_mem *) head;
h -= 1;
if (!h->next)
{
return NULL;
}
return h->next + 1;
}

View File

@@ -0,0 +1,549 @@
#include "sys_config.h"
#include "typesdef.h"
#if JPG_EN
#ifndef DQT_NUM
#define DQT_NUM 12
#endif
const uint16 htable[] __attribute__ ((aligned(4))) ={
#if 1
0x100,0x101,0x204,0x30b,0x41a,0x678,0x7f8,0x9f6,
0xf82,0xf83,0x30c,0x41b,0x679,0x8f6,0xaf6,0xf84,
0xf85,0xf86,0xf87,0xf88,0x41c,0x7f9,0x9f7,0xbf4,
0xf89,0xf8a,0xf8b,0xf8c,0xf8d,0xf8e,0x53a,0x8f7,
0xbf5,0xf8f,0xf90,0xf91,0xf92,0xf93,0xf94,0xf95,
0x53b,0x9f8,0xf96,0xf97,0xf98,0xf99,0xf9a,0xf9b,
0xf9c,0xf9d,0x67a,0xaf7,0xf9e,0xf9f,0xfa0,0xfa1,
0xfa2,0xfa3,0xfa4,0xfa5,0x67b,0xbf6,0xfa6,0xfa7,
0xfa8,0xfa9,0xfaa,0xfab,0xfac,0xfad,0x7fa,0xbf7,
0xfae,0xfaf,0xfb0,0xfb1,0xfb2,0xfb3,0xfb4,0xfb5,
0x8f8,0xec0,0xfb6,0xfb7,0xfb8,0xfb9,0xfba,0xfbb,
0xfbc,0xfbd,0x8f9,0xfbe,0xfbf,0xfc0,0xfc1,0xfc2,
0xfc3,0xfc4,0xfc5,0xfc6,0x8fa,0xfc7,0xfc8,0xfc9,
0xfca,0xfcb,0xfcc,0xfcd,0xfce,0xfcf,0x9f9,0xfd0,
0xfd1,0xfd2,0xfd3,0xfd4,0xfd5,0xfd6,0xfd7,0xfd8,
0x9fa,0xfd9,0xfda,0xfdb,0xfdc,0xfdd,0xfde,0xfdf,
0xfe0,0xfe1,0xaf8,0xfe2,0xfe3,0xfe4,0xfe5,0xfe6,
0xfe7,0xfe8,0xfe9,0xfea,0xfeb,0xfec,0xfed,0xfee,
0xfef,0xff0,0xff1,0xff2,0xff3,0xff4,0xff5,0xff6,
0xff7,0xff8,0xff9,0xffa,0xffb,0xffc,0xffd,0xffe,
0x30a,0xaf9,0xfff,0xfff,0xfff,0xfff,0xfff,0xfff,
0xfd0,0xfd1,0xfd2,0xfd3,0xfd4,0xfd5,0xfd6,0xfd7,
0x101,0x204,0x30a,0x418,0x419,0x538,0x678,0x8f4,
0x9f6,0xbf4,0x30b,0x539,0x7f6,0x8f5,0xaf6,0xbf5,
0xf88,0xf89,0xf8a,0xf8b,0x41a,0x7f7,0x9f7,0xbf6,
0xec2,0xf8c,0xf8d,0xf8e,0xf8f,0xf90,0x41b,0x7f8,
0x9f8,0xbf7,0xf91,0xf92,0xf93,0xf94,0xf95,0xf96,
0x53a,0x8f6,0xf97,0xf98,0xf99,0xf9a,0xf9b,0xf9c,
0xf9d,0xf9e,0x53b,0x9f9,0xf9f,0xfa0,0xfa1,0xfa2,
0xfa3,0xfa4,0xfa5,0xfa6,0x679,0xaf7,0xfa7,0xfa8,
0xfa9,0xfaa,0xfab,0xfac,0xfad,0xfae,0x67a,0xaf8,
0xfaf,0xfb0,0xfb1,0xfb2,0xfb3,0xfb4,0xfb5,0xfb6,
0x7f9,0xfb7,0xfb8,0xfb9,0xfba,0xfbb,0xfbc,0xfbd,
0xfbe,0xfbf,0x8f7,0xfc0,0xfc1,0xfc2,0xfc3,0xfc4,
0xfc5,0xfc6,0xfc7,0xfc8,0x8f8,0xfc9,0xfca,0xfcb,
0xfcc,0xfcd,0xfce,0xfcf,0xfd0,0xfd1,0x8f9,0xfd2,
0xfd3,0xfd4,0xfd5,0xfd6,0xfd7,0xfd8,0xfd9,0xfda,
0x8fa,0xfdb,0xfdc,0xfdd,0xfde,0xfdf,0xfe0,0xfe1,
0xfe2,0xfe3,0xaf9,0xfe4,0xfe5,0xfe6,0xfe7,0xfe8,
0xfe9,0xfea,0xfeb,0xfec,0xde0,0xfed,0xfee,0xfef,
0xff0,0xff1,0xff2,0xff3,0xff4,0xff5,0xec3,0xff6,
0xff7,0xff8,0xff9,0xffa,0xffb,0xffc,0xffd,0xffe,
0x100,0x9fa,0xfff,0xfff,0xfff,0xfff,0xfff,0xfff,
0xfd0,0xfd1,0xfd2,0xfd3,0xfd4,0xfd5,0xfd6,0xfd7,
0x100,0x202,0x203,0x204,0x205,0x206,0x30e,0x41e,
0x53e,0x67e,0x7fe,0x8fe,0xfff,0xfff,0xfff,0xfff,
0x100,0x101,0x102,0x206,0x30e,0x41e,0x53e,0x67e,
0x7fe,0x8fe,0x9fe,0xafe,0xfff,0xfff,0xfff,0xfff,
#else
0x0001,0x0101,0x0402,0x0b03,0x1a04,0x7806,0xf807,0xf609,
0x820f,0x830f,0x0c03,0x1b04,0x7906,0xf608,0xf60a,0x840f,
0x850f,0x860f,0x870f,0x880f,0x1c04,0xf907,0xf709,0xf40b,
0x890f,0x8a0f,0x8b0f,0x8c0f,0x8d0f,0x8e0f,0x3a05,0xf708,
0xf50b,0x8f0f,0x900f,0x910f,0x920f,0x930f,0x940f,0x950f,
0x3b05,0xf809,0x960f,0x970f,0x980f,0x990f,0x9a0f,0x9b0f,
0x9c0f,0x9d0f,0x7a06,0xf70a,0x9e0f,0x9f0f,0xa00f,0xa10f,
0xa20f,0xa30f,0xa40f,0xa50f,0x7b06,0xf60b,0xa60f,0xa70f,
0xa80f,0xa90f,0xaa0f,0xab0f,0xac0f,0xad0f,0xfa07,0xf70b,
0xae0f,0xaf0f,0xb00f,0xb10f,0xb20f,0xb30f,0xb40f,0xb50f,
0xf808,0xc00e,0xb60f,0xb70f,0xb80f,0xb90f,0xba0f,0xbb0f,
0xbc0f,0xbd0f,0xf908,0xbe0f,0xbf0f,0xc00f,0xc10f,0xc20f,
0xc30f,0xc40f,0xc50f,0xc60f,0xfa08,0xc70f,0xc80f,0xc90f,
0xca0f,0xcb0f,0xcc0f,0xcd0f,0xce0f,0xcf0f,0xf909,0xd00f,
0xd10f,0xd20f,0xd30f,0xd40f,0xd50f,0xd60f,0xd70f,0xd80f,
0xfa09,0xd90f,0xda0f,0xdb0f,0xdc0f,0xdd0f,0xde0f,0xdf0f,
0xe00f,0xe10f,0xf80a,0xe20f,0xe30f,0xe40f,0xe50f,0xe60f,
0xe70f,0xe80f,0xe90f,0xea0f,0xeb0f,0xec0f,0xed0f,0xee0f,
0xef0f,0xf00f,0xf10f,0xf20f,0xf30f,0xf40f,0xf50f,0xf60f,
0xf70f,0xf80f,0xf90f,0xfa0f,0xfb0f,0xfc0f,0xfd0f,0xfe0f,
0x0a03,0xf90a,0xff0f,0xff0f,0xff0f,0xff0f,0xff0f,0xff0f,
0xd00f,0xd10f,0xd20f,0xd30f,0xd40f,0xd50f,0xd60f,0xd70f,
0x0101,0x0402,0x0a03,0x1804,0x1904,0x3805,0x7806,0xf408,
0xf609,0xf40b,0x0b03,0x3905,0xf607,0xf508,0xf60a,0xf50b,
0x880f,0x890f,0x8a0f,0x8b0f,0x1a04,0xf707,0xf709,0xf60b,
0xc20e,0x8c0f,0x8d0f,0x8e0f,0x8f0f,0x900f,0x1b04,0xf807,
0xf809,0xf70b,0x910f,0x920f,0x930f,0x940f,0x950f,0x960f,
0x3a05,0xf608,0x970f,0x980f,0x990f,0x9a0f,0x9b0f,0x9c0f,
0x9d0f,0x9e0f,0x3b05,0xf909,0x9f0f,0xa00f,0xa10f,0xa20f,
0xa30f,0xa40f,0xa50f,0xa60f,0x7906,0xf70a,0xa70f,0xa80f,
0xa90f,0xaa0f,0xab0f,0xac0f,0xad0f,0xae0f,0x7a06,0xf80a,
0xaf0f,0xb00f,0xb10f,0xb20f,0xb30f,0xb40f,0xb50f,0xb60f,
0xf907,0xb70f,0xb80f,0xb90f,0xba0f,0xbb0f,0xbc0f,0xbd0f,
0xbe0f,0xbf0f,0xf708,0xc00f,0xc10f,0xc20f,0xc30f,0xc40f,
0xc50f,0xc60f,0xc70f,0xc80f,0xf808,0xc90f,0xca0f,0xcb0f,
0xcc0f,0xcd0f,0xce0f,0xcf0f,0xd00f,0xd10f,0xf908,0xd20f,
0xd30f,0xd40f,0xd50f,0xd60f,0xd70f,0xd80f,0xd90f,0xda0f,
0xfa08,0xdb0f,0xdc0f,0xdd0f,0xde0f,0xdf0f,0xe00f,0xe10f,
0xe20f,0xe30f,0xf90a,0xe40f,0xe50f,0xe60f,0xe70f,0xe80f,
0xe90f,0xea0f,0xeb0f,0xec0f,0xe00d,0xed0f,0xee0f,0xef0f,
0xf00f,0xf10f,0xf20f,0xf30f,0xf40f,0xf50f,0xc30e,0xf60f,
0xf70f,0xf80f,0xf90f,0xfa0f,0xfb0f,0xfc0f,0xfd0f,0xfe0f,
0x0001,0xfa09,0xff0f,0xff0f,0xff0f,0xff0f,0xff0f,0xff0f,
0xd00f,0xd10f,0xd20f,0xd30f,0xd40f,0xd50f,0xd60f,0xd70f,
0x0001,0x0202,0x0302,0x0402,0x0502,0x0602,0x0e03,0x1e04,
0x3e05,0x7e06,0xfe07,0xfe08,0xff0f,0xff0f,0xff0f,0xff0f,
0x0001,0x0101,0x0201,0x0602,0x0e03,0x1e04,0x3e05,0x7e06,
0xfe07,0xfe08,0xfe09,0xfe0a,0xff0f,0xff0f,0xff0f,0xff0f,
#endif
};
uint8 dhtable[] __attribute__ ((aligned(4)))={
0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x00, 0x02, 0x01, 0x03,
0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04,
0x00, 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00,
0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06,
0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32,
0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1,
0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72,
0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a,
0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35,
0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55,
0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65,
0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75,
0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85,
0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2,
0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4,
0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0x00, 0x03,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
0x0a, 0x0b, 0x00, 0x02, 0x01, 0x02, 0x04, 0x04,
0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01,
0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04,
0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07,
0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14,
0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16,
0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19,
0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36,
0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56,
0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85,
0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94,
0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3,
0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2,
0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba,
0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9,
0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
0xf7, 0xf8, 0xf9, 0xfa,
};
const char quality_tab[DQT_NUM][128] __attribute__ ((aligned(4))) = {
// {
// 0x08, 0x06, 0x06, 0x07, 0x06, 0x05, 0x08, 0x07,
// 0x07, 0x07, 0x09, 0x09, 0x08, 0x0A, 0x0C, 0x14,
// 0x0D, 0x0C, 0x0B, 0x0B, 0x0C, 0x19, 0x12, 0x13,
// 0x0F, 0x14, 0x1D, 0x1A, 0x1F, 0x1E, 0x1D, 0x1A,
// 0x1C, 0x1C, 0x20, 0x24, 0x2E, 0x27, 0x20, 0x22,
// 0x2C, 0x23, 0x1C, 0x1C, 0x28, 0x37, 0x29, 0x2C,
// 0x30, 0x31, 0x34, 0x34, 0x34, 0x1F, 0x27, 0x39,
// 0x3D, 0x38, 0x32, 0x3C, 0x2E, 0x33, 0x34, 0x32,
// 0x09, 0x09, 0x09, 0x0C, 0x0B, 0x0C, 0x18, 0x0D,
// 0x0D, 0x18, 0x32, 0x21, 0x1C, 0x21, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
// 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32
// },
{
16, 10, 9, 16, 24, 38, 50, 60,
11, 11, 14, 18, 25, 55, 59, 53,
14, 12, 16, 24, 38, 55, 68, 54,
14, 17, 20, 28, 50, 85, 78, 60,
17, 20, 36, 54, 65, 106, 99, 74,
24, 34, 53, 62, 79, 100, 109, 89,
47, 62, 76, 85, 99, 117, 116, 98,
70, 89, 91, 95, 108, 97, 99, 96,
17, 17, 24, 45, 96, 96, 96, 96,
17, 20, 25, 63, 96, 96, 96, 96,
24, 25, 54, 96, 96, 96, 96, 96,
45, 63, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96,
96, 96, 96, 96, 96, 96, 96, 96
},
{
//Quantizaton table 0(luminance table) addr=0x20000 len=64 default:QT45
18, 12, 11, 18, 27, 44, 57, 68,
13, 13, 16, 21, 29, 64, 67, 61,
16, 14, 18, 27, 44, 63, 77, 62,
16, 19, 24, 32, 57, 97, 89, 69,
20, 24, 41, 62, 75, 121, 114, 85,
27, 39, 61, 71, 90, 115, 125, 102,
54, 71, 87, 97, 114, 134, 133, 112,
80, 102, 105, 109, 124, 111, 114, 110,
//Quantizaton table 1 (chrominance table) addr=0x20040 len = 64 default:QT45
19, 20, 27, 52, 110, 110, 110, 110,
20, 23, 29, 73, 110, 110, 110, 110,
27, 29, 62, 110, 110, 110, 110, 110,
52, 73, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110
},
{
20, 14, 13, 20, 30, 50, 64, 76,
15, 15, 18, 24, 33, 73, 75, 69,
18, 16, 20, 30, 50, 71, 86, 70,
18, 21, 28, 36, 64, 109, 100, 78,
23, 28, 46, 70, 85, 136, 129, 96,
30, 44, 69, 80, 101, 130, 141, 115,
61, 80, 98, 109, 129, 151, 150, 126,
90, 115, 119, 123, 140, 125, 129, 124,
21, 23, 30, 59, 124, 124, 124, 124,
23, 26, 33, 83, 124, 124, 124, 124,
30, 33, 70, 124, 124, 124, 124, 124,
59, 83, 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
},
{
23, 16, 14, 23, 34, 57, 72, 87,
17, 17, 20, 27, 37, 82, 85, 78,
20, 18, 23, 34, 57, 81, 98, 80,
20, 24, 31, 41, 72, 124, 114, 88,
26, 31, 53, 80, 97, 155, 146, 109,
34, 50, 78, 91, 115, 148, 160, 131,
70, 91, 111, 124, 146, 172, 170, 143,
102, 131, 135, 139, 159, 142, 146, 141,
24, 26, 34, 67, 141, 141, 141, 141,
26, 30, 37, 94, 141, 141, 141, 141,
34, 37, 80, 141, 141, 141, 141, 141,
67, 94, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141
},
{
27, 18, 17, 27, 40, 66, 85, 101,
20, 20, 23, 32, 43, 96, 100, 91,
23, 22, 27, 40, 66, 95, 115, 93,
23, 28, 37, 48, 85, 144, 133, 103,
30, 37, 61, 93, 113, 181, 171, 128,
40, 58, 91, 106, 134, 173, 188, 153,
81, 106, 129, 144, 171, 201, 199, 168,
120, 153, 158, 163, 186, 166, 171, 164,
28, 30, 40, 78, 164, 164, 164, 164,
30, 35, 43, 110, 164, 164, 164, 164,
40, 43, 93, 164, 164, 164, 164, 164,
78, 110, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164
},
{
32, 22, 20, 32, 48, 80, 102, 122,
24, 24, 28, 38, 52, 116, 120, 110,
28, 26, 32, 48, 80, 114, 138, 112,
28, 34, 44, 58, 102, 174, 160, 124,
36, 44, 74, 112, 136, 218, 206, 154,
48, 70, 110, 128, 162, 208, 226, 184,
98, 128, 156, 174, 206, 242, 240, 202,
144, 184, 190, 196, 224, 200, 206, 198,
34, 36, 48, 94, 198, 198, 198, 198,
36, 42, 52, 132, 198, 198, 198, 198,
48, 52, 112, 198, 198, 198, 198, 198,
94, 132, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198
},
{
39, 26, 24, 39, 58, 97, 124, 148,
29, 29, 34, 46, 63, 141, 146, 134,
34, 31, 39, 58, 97, 138, 168, 136,
34, 41, 53, 70, 124, 212, 195, 151,
43, 53, 90, 136, 165, 255, 251, 187,
58, 85, 134, 156, 197, 253, 255, 224,
119, 156, 190, 212, 251, 255, 255, 246,
175, 224, 231, 238, 225, 243, 251, 241,
41, 43, 58, 114, 241, 241, 241, 241,
43, 51, 63, 160, 241, 241, 241, 241,
58, 63, 136, 241, 241, 241, 241, 241,
114, 160, 241, 241, 241, 241, 241, 241,
241, 241, 241, 241, 241, 241, 241, 241,
241, 241, 241, 241, 241, 241, 241, 241,
241, 241, 241, 241, 241, 241, 241, 241,
241, 241, 241, 241, 241, 241, 241, 241
},
{
47, 31, 29, 47, 70, 118, 151, 180,
35, 35, 41, 56, 76, 171, 177, 163,
41, 37, 47, 70, 118, 168, 204, 165,
41, 49, 64, 85, 151, 255, 237, 184,
52, 64, 109, 165, 201, 255, 255, 227,
70, 103, 163, 190, 240, 255, 255, 255,
145, 190, 231, 255, 255, 255, 255, 255,
213, 255, 255, 255, 255, 255, 255, 255,
49, 52, 70, 138, 255, 255, 255, 255,
52, 62, 76, 195, 255, 255, 255, 255,
70, 76, 165, 255, 255, 255, 255, 255,
138, 195, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
},
{
57, 37, 35, 57, 85, 143, 184, 219,
42, 42, 49, 68, 92, 208, 215, 198,
49, 45, 57, 85, 143, 204, 248, 201,
49, 59, 78, 103, 184, 255, 255, 224,
63, 78, 132, 201, 244, 255, 255, 255,
85, 125, 198, 231, 255, 255, 255, 255,
176, 231, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
59, 63, 85, 168, 255, 255, 255, 255,
63, 75, 92, 237, 255, 255, 255, 255,
85, 92, 201, 255, 255, 255, 255, 255,
168, 237, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
},
{
69, 45, 42, 69, 103, 174, 224, 255,
51, 51, 59, 82, 112, 253, 255, 241,
59, 54, 69, 103, 174, 248, 255, 244,
59, 71, 95, 125, 224, 255, 255, 255,
76, 95, 160, 244, 255, 255, 255, 255,
103, 152, 241, 255, 255, 255, 255, 255,
214, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
71, 76, 103, 204, 255, 255, 255, 255,
76, 91, 112, 255, 255, 255, 255, 255,
103, 112, 244, 255, 255, 255, 255, 255,
204, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
},
{
84, 54, 51, 84, 125, 212, 255, 255,
62, 62, 71, 99, 136, 255, 255, 255,
71, 65, 84, 125, 212, 255, 255, 255,
71, 86, 115, 152, 255, 255, 255, 255,
92, 115, 195, 255, 255, 255, 255, 255,
125, 185, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
86, 92, 125, 248, 255, 255, 255, 255,
92, 110, 136, 255, 255, 255, 255, 255,
125, 136, 255, 255, 255, 255, 255, 255,
248, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
},
{
102, 65, 62, 102, 152, 255, 255, 255,
75, 75, 86, 120, 165, 255, 255, 255,
86, 79, 102, 152, 255, 255, 255, 255,
86, 104, 140, 185, 255, 255, 255, 255,
112, 140, 237, 255, 255, 255, 255, 255,
152, 225, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
104, 112, 152, 255, 255, 255, 255, 255,
112, 134, 165, 255, 255, 255, 255, 255,
152, 165, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255,
255, 255, 255, 255, 255, 255, 255, 255
}
};
#if 0
char quality0[128] __attribute__ ((aligned(4)))= {
0x08, 0x06, 0x06, 0x07, 0x06, 0x05, 0x08, 0x07,
0x07, 0x07, 0x09, 0x09, 0x08, 0x0A, 0x0C, 0x14,
0x0D, 0x0C, 0x0B, 0x0B, 0x0C, 0x19, 0x12, 0x13,
0x0F, 0x14, 0x1D, 0x1A, 0x1F, 0x1E, 0x1D, 0x1A,
0x1C, 0x1C, 0x20, 0x24, 0x2E, 0x27, 0x20, 0x22,
0x2C, 0x23, 0x1C, 0x1C, 0x28, 0x37, 0x29, 0x2C,
0x30, 0x31, 0x34, 0x34, 0x34, 0x1F, 0x27, 0x39,
0x3D, 0x38, 0x32, 0x3C, 0x2E, 0x33, 0x34, 0x32,
0x09, 0x09, 0x09, 0x0C, 0x0B, 0x0C, 0x18, 0x0D,
0x0D, 0x18, 0x32, 0x21, 0x1C, 0x21, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32,
};
/*QT45*/
char quality1[128] __attribute__ ((aligned(4)))= {
//Quantizaton table 0(luminance table) addr=0x20000 len=64 default:QT45
18, 12, 11, 18, 27, 44, 57, 68,
13, 13, 16, 21, 29, 64, 67, 61,
16, 14, 18, 27, 44, 63, 77, 62,
16, 19, 24, 32, 57, 97, 89, 69,
20, 24, 41, 62, 75, 121, 114, 85,
27, 39, 61, 71, 90, 115, 125, 102,
54, 71, 87, 97, 114, 134, 133, 112,
80, 102, 105, 109, 124, 111, 114, 110,
//Quantizaton table 1 (chrominance table) addr=0x20040 len = 64 default:QT45
19, 20, 27, 52, 110, 110, 110, 110,
20, 23, 29, 73, 110, 110, 110, 110,
27, 29, 62, 110, 110, 110, 110, 110,
52, 73, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
110, 110, 110, 110, 110, 110, 110, 110,
};
/*QT40*/
char quality2[128] __attribute__ ((aligned(4)))= {
20, 14, 13, 20, 30, 50, 64, 76,
15, 15, 18, 24, 33, 73, 75, 69,
18, 16, 20, 30, 50, 71, 86, 70,
18, 21, 28, 36, 64, 109, 100, 78,
23, 28, 46, 70, 85, 136, 129, 96,
30, 44, 69, 80, 101, 130, 141, 115,
61, 80, 98, 109, 129, 151, 150, 126,
90, 115, 119, 123, 140, 125, 129, 124,
21, 23, 30, 59, 124, 124, 124, 124,
23, 26, 33, 83, 124, 124, 124, 124,
30, 33, 70, 124, 124, 124, 124, 124,
59, 83, 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,
};
/*QT35*/
char quality3[128] __attribute__ ((aligned(4)))= {
23, 16, 14, 23, 34, 57, 72, 87,
17, 17, 20, 27, 37, 82, 85, 78,
20, 18, 23, 34, 57, 81, 98, 80,
20, 24, 31, 41, 72, 124, 114, 88,
26, 31, 53, 80, 97, 155, 146, 109,
34, 50, 78, 91, 115, 148, 160, 131,
70, 91, 111, 124, 146, 172, 170, 143,
102, 131, 135, 139, 159, 142, 146, 141,
24, 26, 34, 67, 141, 141, 141, 141,
26, 30, 37, 94, 141, 141, 141, 141,
34, 37, 80, 141, 141, 141, 141, 141,
67, 94, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
141, 141, 141, 141, 141, 141, 141, 141,
};
/*QT30*/
char quality4[128] __attribute__ ((aligned(4)))= {
27, 18, 17, 27, 40, 66, 85, 101,
20, 20, 23, 32, 43, 96, 100, 91,
23, 22, 27, 40, 66, 95, 115, 93,
23, 28, 37, 48, 85, 144, 133, 103,
30, 37, 61, 93, 113, 181, 171, 128,
40, 58, 91, 106, 134, 173, 188, 153,
81, 106, 129, 144, 171, 201, 199, 168,
120, 153, 158, 163, 186, 166, 171, 164,
28, 30, 40, 78, 164, 164, 164, 164,
30, 35, 43, 110, 164, 164, 164, 164,
40, 43, 93, 164, 164, 164, 164, 164,
78, 110, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
164, 164, 164, 164, 164, 164, 164, 164,
};
/*QT25*/
char quality5[128] __attribute__ ((aligned(4)))= {
32, 22, 20, 32, 48, 80, 102, 122,
24, 24, 28, 38, 52, 116, 120, 110,
28, 26, 32, 48, 80, 114, 138, 112,
28, 34, 44, 58, 102, 174, 160, 124,
36, 44, 74, 112, 136, 218, 206, 154,
48, 70, 110, 128, 162, 208, 226, 184,
98, 128, 156, 174, 206, 242, 240, 202,
144, 184, 190, 196, 224, 200, 206, 198,
34, 36, 48, 94, 198, 198, 198, 198,
36, 42, 52, 132, 198, 198, 198, 198,
48, 52, 112, 198, 198, 198, 198, 198,
94, 132, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
198, 198, 198, 198, 198, 198, 198, 198,
};
#endif
#endif

File diff suppressed because it is too large Load Diff