📄 mmidc_preview.c
字号:
/*****************************************************************************
** File Name: mmidc_preview.c *
** Author: *
** Date: 2005-8 *
** Copyright: 2003 Spreadtrum, Incorporated. All Rights Reserved. *
** Description: This file is used to describe dc preview *
*****************************************************************************
** Important Edit History *
** --------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 08/2005 Bruce.Chi Create *
*****************************************************************************/
#ifndef _MMIDC_PREVIEW_C_
#define _MMIDC_PREVIEW_C_
/**--------------------------------------------------------------------------*
** Include Files *
**--------------------------------------------------------------------------*/
#include "mmidc_internal.h"
#include "mmidc_osd_img.h"
#include "mmi_nv.h"
#include "mmidisplay_data.h"
#include "mmi_id.h"
#include "mmi_textfun.h"
#include "window_parse.h"
#include "block_mem.h"
#include "mmiset.h"
#include "mmimpeg4.h"
#ifdef _MMI_OCR
#include "mmiocr.h"
#endif
/**--------------------------------------------------------------------------*
** MACRO DEFINITION *
**--------------------------------------------------------------------------*/
#define PARTSCREEN_CIRCLE_OSD_IMG_HEIGHT 16//主屏半屏预览,OSD MENU图片的高度
#define CR_BLACK_INDEX 0XC1 //(0xC0 | 0x1), 0xC0 means overwrite, refer to declearation of DC_SetOsdImage, 0x1 means index of color in pallete
#define CR_WHITE_INDEX 0XC2 //(0xC0 | 0x2), 0xC0 means overwrite, refer to declearation of DC_SetOsdImage, 0x2 means index of color in pallete
#define MMIDC_OSD_CHAR_BLACK 0x00FF0000 //Reserve(8bit), Y(8), U(8), V(8)
#define MMIDC_OSD_CHAR_WHITE 0x007F0000
/**--------------------------------------------------------------------------*
** STATIC DEFINITION *
**--------------------------------------------------------------------------*/
MMIDC_SETTING_INFO_T s_mmidc_setting_info;
static MMIDC_SETTING_SAVE_INFO_T s_mmidc_nv_info;
static BOOLEAN s_is_dc_suspend_mp3;
static BOOLEAN s_is_dc_open;
static BOOLEAN s_dc_is_init = FALSE;
/*
#ifndef WIN32
__align(16)
#endif
static uint32 s_dc_context[MMIDC_MAX_PHOTO_SIZE / sizeof(uint32)];
*/
LOCAL uint8 *s_dc_context_ptr = PNULL;
LOCAL BOOLEAN s_is_from_dc = TRUE;
LOCAL uint8 s_zoom_level = 0;
/*---------------------------------------------------------------------------*/
/* TYPE AND CONSTANT */
/*---------------------------------------------------------------------------*/
typedef struct
{
DC_SENSOR_MODE_E e_preview_nomal_sensor_mode;//nomal preview sensor mode
DC_SENSOR_MODE_E e_preview_af_sensor_mode; //af preview sensor mode
DC_SENSOR_MODE_E e_capture_sensor_mode; //capture sensor mode
int32 i_sensor_width; //normal preview trim rect
int32 i_sensor_height;
int32 i_cap_trim_width; //capture sensor trim rect
int32 i_cap_trim_height;
int32 i_target_width; //capture target
int32 i_target_height;
int32 i_sensor_af_widht; //af preview trim rect
int32 i_sensor_af_height;
}DC_SENSOR_MODE_AND_SIZE;
#ifndef MMI_ENABLE_AUTO_FOCUS
static const DC_SENSOR_MODE_AND_SIZE s_dc_sensor_mode_and_size[MMIDC_PHOTO_SIZE_MAX] =
{
#ifdef MMIDC_80X64_SUPPORT
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 80, 64, 80, 64, 320, 240}, //this may have bug, modify later
#endif
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 640, 480, 320, 240, 320, 240},
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 640, 480, 640, 480, 320, 240},
#ifdef MMIDC_03M_INTERPOLATION
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 640, 480, 1280, 960, 320, 240},
#endif
#ifdef MMIDC_1024X960_SOPPORT
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 640, 480, 1024, 960, 1024, 960, 320, 240},
#endif
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 640 , 480, 1280, 1024, 1280, 1024, 320, 240},
#ifdef MMIDC_INTERPOLATION
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 640, 480, 1280, 960, 1600, 1200, 320, 240},
#endif
};
#else
static const DC_SENSOR_MODE_AND_SIZE s_dc_sensor_mode_and_size[MMIDC_PHOTO_SIZE_MAX] =
{
#ifdef MMIDC_80X64_SUPPORT
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 80, 64, 80, 64, 80, 64, 192, 240}, //this may have bug, modify later
#endif
{SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_320X240_NORMAL, 192, 240, 320, 240, 320, 240, 192, 240},
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 192, 240, 640, 480, 640, 480, 192, 240},
#ifdef MMIDC_1024X960_SOPPORT
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 192, 240, 1024, 960, 1024, 960, 192, 240},
#endif
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 192, 240, 1280, 1024, 1280, 1024, 192, 240},
#ifdef MMIDC_INTERPOLATION
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_1280X1024_NORMAL, 192, 240, 1280, 960, 1600, 1200, 192, 240},
#endif
};
#endif
typedef struct
{
DC_SENSOR_MODE_E e_preview_nomal_sensor_mode;//nomal preview sensor mode
DC_SENSOR_MODE_E e_preview_af_sensor_mode; //af preview sensor mode
DC_SENSOR_MODE_E e_capture_sensor_mode; //capture sensor mode
int32 i_sensor_width; //normal preview trim rect
int32 i_sensor_height;
int32 i_preview_disp_width; //normal preview display rect
int32 i_preview_disp_height;
int32 i_target_width; //record target
int32 i_target_height;
int32 i_sensor_af_widht; //af preview trim rect
int32 i_sensor_af_height;
}DV_SENSOR_MODE_AND_SIZE;
#ifdef _LCD_QVGA_
static const DV_SENSOR_MODE_AND_SIZE s_dv_sensor_mode_and_size[MMIVC_VIDEO_SIZE_MAX] =
{
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 128, 96, 128, 96, 128, 96, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 160, 128, 160, 128, 160, 128, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 176, 144, 176, 144, 176, 144, 320, 240},
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 240, 320, 320, 240, 320, 240}
};
#elif defined(LCD_176_220)
static const DV_SENSOR_MODE_AND_SIZE s_dv_sensor_mode_and_size[MMIVC_VIDEO_SIZE_MAX] =
{
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 128, 96, 128, 96, 128, 96, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 160, 128, 160, 128, 160, 128, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 176, 144, 176, 144, 176, 144, 320, 240},
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 176, 220, 320, 240, 320, 240}
};
#elif defined(LCD_128_160)
static const DV_SENSOR_MODE_AND_SIZE s_dv_sensor_mode_and_size[MMIVC_VIDEO_SIZE_MAX] =
{
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 128, 96, 128, 96, 128, 96, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 160, 128, 106, 84, 160, 128, 320, 240},
{SENSOR_MODE_176X144_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_176X144_NORMAL, 176, 144, 116, 96, 176, 144, 320, 240},
{SENSOR_MODE_640X480_NORMAL, SENSOR_MODE_320X240_NORMAL, SENSOR_MODE_640X480_NORMAL, 640, 480, 128, 160, 320, 240, 320, 240}
};
#endif
LOCAL const RECT_T s_dc_sensor_capture_zoom_size[5] =
{
{0, 0, 640, 480}, {0, 0, 544, 400},{0, 0, 432, 336},{0, 0, 368, 280},{0, 0, 320,240}
};
/**--------------------------------------------------------------------------*
** EXTERNAL DECLARE *
**--------------------------------------------------------------------------*/
extern uint8 g_ksp_Lang;
/**-------------------------------------------------------------------------*
** GLOBAL DEFINITION *
**--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* LOCAL FUNCTION DECLARE */
/*---------------------------------------------------------------------------*/
#ifdef MMI_NOR_VERSION
/*****************************************************************************/
// Description : Free YUV ext buffer
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
PUBLIC void FreeYUVExtBuffer (void);
#endif
/*****************************************************************************/
// Description : Set default value of dc setting saved in nv
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
LOCAL void DCSetting_SetDefaultNVValue(MMIDC_SETTING_SAVE_INFO_T *setting_save_ptr);
/*****************************************************************************/
// Description : use DC Driver interface to exit DC module
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
LOCAL BOOLEAN DCAdap_Exit(void);
/*****************************************************************************/
// Description : use DC Driver interface to open DC
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
BOOLEAN DCAdap_DCOpen(void);
/*****************************************************************************/
// Description : use DC Driver interface to set preview parameter
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
LOCAL BOOLEAN DCAdap_SetPreviewParam(const MMIDC_SETTING_INFO_T *setting_ptr);
/*****************************************************************************/
// Description : use DC Driver interface to set sensor effect
// Global resource dependence :
// Author: bruce.chi
// Note: 这个函数用于Stop了Preview以后,再次Start
/*****************************************************************************/
LOCAL BOOLEAN DCAdap_SetALLSensorEffect(MMIDC_SETTING_INFO_T *setting_ptr);
/*****************************************************************************/
// Description : use DC Driver interface to stop preview
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
BOOLEAN DCAdap_StopPreview(void);
/*****************************************************************************/
// Description : use DC Driver interface to get sensor effect(brightness) sequence
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
DC_SENSOR_MODE_E DCAdap_GetSensorBrightnessSequence(const MMIDC_SETTING_INFO_T *setting_ptr);
/*****************************************************************************/
// Description : use DC Driver interface to get sensor effect(contrast) sequence
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
DC_SENSOR_MODE_E DCAdap_GetSensorContrastSequence(const MMIDC_SETTING_INFO_T *setting_ptr);
/*****************************************************************************/
// Description : use DC Driver interface to get sensor effect(sepia) sequence
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
DC_SENSOR_MODE_E DCAdap_GetSensorSepiaSequence(const MMIDC_SETTING_INFO_T *setting_ptr);
/*****************************************************************************/
// Description : right trunk a number with 16
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 right_trunk_16(uint16 in_num);
/*****************************************************************************/
// Description : left trunk a number with 2
// Global resource dependence :
// Author:bruce.chi
// Note:
/*****************************************************************************/
__inline LOCAL uint16 left_trunk_2(uint16 in_num);
/*****************************************************************************/
// Description : get sensor width and height according to e_photo_size
// Global resource dependence : none
// Author:
// Note:
/*****************************************************************************/
LOCAL void GetDCSensorRect(MMIDC_PHOTO_SIZE_E e_photo_size, int32 *sensor_width_ptr, int32 *sensor_height_ptr);
/*****************************************************************************/
// Description : get sensor width and height according to e_photo_size
// Global resource dependence : none
// Author:
// Note:
/*****************************************************************************/
LOCAL void GetDVSensorRect(MMIVC_VIDEO_SIZE_E e_photo_size, int32 *sensor_width_ptr, int32 *sensor_height_ptr);
/*****************************************************************************/
// Description : get capture trim rect according to e_photo_size
// Global resource dependence : none
// Author:
// Note:
/*****************************************************************************/
LOCAL void GetDCCapTrimRect(MMIDC_PHOTO_SIZE_E e_photo_size, int32 *trim_width_ptr, int32 *trim_height_ptr);
__inline LOCAL uint16 right_trunk_8(uint16 in_num);
/*****************************************************************************/
// Description : initialize digit camera
// Global resource dependence : s_mmidc_setting_info
// Author: bruce.chi
// Note:
/*****************************************************************************/
void MMIDC_Init(void)
{
MN_RETURN_RESULT_E nv_result = 0;
s_dc_is_init = FALSE;
//read setting info from NV
MMINV_READ(MMINV_DC_SETTING_INFO, &s_mmidc_nv_info, nv_result);
if (nv_result != MN_RETURN_SUCCESS)
{
SCI_MEMSET(&s_mmidc_nv_info, 0, sizeof(s_mmidc_nv_info));
//write to NV
DCSetting_SetDefaultNVValue(&s_mmidc_nv_info);
MMINV_WRITE(MMINV_DC_SETTING_INFO, &s_mmidc_nv_info);
}
DCSaveInfo_FindPhotoFileInFFS();
//init global
s_is_dc_suspend_mp3 = FALSE;
s_is_dc_open = FALSE;
s_dc_is_init = TRUE;
}
/*****************************************************************************/
// Description : exit digit camera
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
void MMIDC_Exit(void)
{
DCAdap_Exit();
}
/*****************************************************************************/
// Description : Set default value of dc setting saved in nv
// Global resource dependence :
// Author: bruce.chi
// Note:
/*****************************************************************************/
LOCAL void DCSetting_SetDefaultNVValue(MMIDC_SETTING_SAVE_INFO_T *setting_save_ptr)
{
DC_ASSERT_LOW(setting_save_ptr != PNULL);
setting_save_ptr->b_shutter_voice = TRUE;
#ifdef MMIDC_FLASH
setting_save_ptr->b_flash_enabled = TRUE;
#else
setting_save_ptr->b_flash_enabled = FALSE;
#endif
setting_save_ptr->e_quality = MMIDC_QUALITY_NORMAL;
#ifdef MMIDC_03M_SUPPORT
setting_save_ptr->e_photo_size = MMIDC_PHOTO_SIZE_640X480;
#else
setting_save_ptr->e_photo_size = MMIDC_PHOTO_SIZE_1280X1024;
#endif
setting_save_ptr->e_dv_format = DV_MJPEG_FORMAT;
setting_save_ptr->e_storage_dev = FS_UDISK;
setting_save_ptr->e_af = MMIDC_AF_OFF;
}
/*****************************************************************************/
// Description : save some useful info in s_mmidc_setting_info to s_mmidc_nv_info then save in NV
// Global resource dependence :
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -