📄 avirecord.c
字号:
/********************************************************************************
Copyright (c) 2002 Sunplus Technology Co., Ltd.
Module Name: avirecord.c
Function : AVI recording function
Environment: Keil C51 Compiler
Creation : 2002/03/18 yichang
***********************************************************************************/
#include "general.h"
#include "main.h"
#include "sdramhw.h"
#include "image.h"
#include "doslink.h"
#include "dosusr.h"
#include "ui.h"
#include "quantdef.h"
//#include "avioption.h"
#include "cardfunc.h"
#include "dosvar.h"
#include "uiflow.h"
//patch4.4@yichang@for valid signal begin
extern void DELAY_1ms(void);
//patch4.4@yichang@for valid signal end
#if (SMC_OPTION || NANDF_OPTION)
#include "smcfunc.h"
#endif
#if (CFC_OPTION)
#include "cffunc.h"
#endif
#if (SDF_OPTION)
#include "sdfunc.h"
#endif
//patch4.2@richie@ds0511 begin
#if (DOSRAM_OPTION)
#include "dramfunc.h"
#endif
//patch4.2@richie@ds0511 end
//patch3.2@ada@0401 For Multi-Frame Play Back
#include "initio.h"
//Joe@2003.3.3 19:50 add begin
#include "JoeToEvb.h"
//Joe@2003.3.3 19:50 add end
#include "unistd.h"
//patch4.2@yichang@0522
//patch4.4@yichang@move definition to other file, begin
//#define K_MAX_AVI_CHUNCKS (ULONG)( ((ULONG)4194304 - K_SDRAM_Idx1BufAddr) / 8 )
//patch4.4@yichang@move definition to other file, end
xdata USHORT G_AVIWidth;
xdata USHORT G_AVIHeight;
//patch4.2@andrew@0520 for video ae/awb
extern BYTE VIDEO;
extern bit AE_START;
//patch4.3@rihie@vz
extern xdata UCHAR G_ucZoomFactor;
//patch5.0@richie@sdram mapping begin
//patch4.5@richie@smooth zoom begin
extern xdata USHORT G_usZoomX;
//patch4.5@richie@smooth zoom end
//patch5.0@richie@sdram mapping end
//patch4.3@richie@zo v begin
extern xdata USHORT G_usZoomOSDTimer;
sbit PWR_DET = P3^4;
//version4.0@yichang@0513 use function call to reduce code
//-----------------------------------------------------------------------------
//WriteAudID2Dram(ULONG addr)
//-----------------------------------------------------------------------------
void WriteAudID2Dram(ULONG addr) USING_0
{
L2_DRAMSetStartAddr(addr, K_SDRAM_NoPrefetch );
L2_DRAMWriteWord(0x30,0x31);
L2_DRAMWriteWord(0x77,0x62);
L2_DRAMWriteWord(0x00,0x02);
L2_DRAMWriteWord(0x00,0x00);
}
//version4.0@yichang@0513 use function call to reduce code
//-----------------------------------------------------------------------------
//WriteVidIndex2Dram(ULONG MoviOfset, ULONG size , ULONG AVIIdxAddr)
//-----------------------------------------------------------------------------
void WriteVidIndex2Dram(ULONG MoviOfset, ULONG size , ULONG AVIIdxAddr) USING_0
{
//patch5.0@cytsai@AVI index begin
// Video chunk 0x1C00 ~ 0x1C0F
XBYTE[0x1C00] = 0x30; XBYTE[0x1C01] = 0x30;
XBYTE[0x1C02] = 0x64; XBYTE[0x1C03] = 0x63;
XBYTE[0x1C04] = 0x10; XBYTE[0x1C05] = 0x00;
XBYTE[0x1C06] = 0x00; XBYTE[0x1C07] = 0x00;
XBYTE[0x1C08] = (UCHAR)MoviOfset; XBYTE[0x1C09] = (UCHAR)(MoviOfset>>8);
XBYTE[0x1C0A] = (UCHAR)(MoviOfset>>16); XBYTE[0x1C0B] = (UCHAR)(MoviOfset>>24);
XBYTE[0x1C0C] = (UCHAR)size; XBYTE[0x1C0D] = (UCHAR)(size>>8);
XBYTE[0x1C0E] = (UCHAR)(size>>16); XBYTE[0x1C0F] = (UCHAR)(size>>24);
L2_SetSRAMDMA(0x0C00);
L2_SetDRAMDMA(AVIIdxAddr);
L2_DoDMA(1,0,16,0,0);
//patch5.0@cytsai@AVI index end
}
//version4.0@yichang@0513 use function call to reduce code
//-----------------------------------------------------------------------------
//void WriteAudIndex2Dram(ULONG MoviOfset, ULONG AVIIdxAddr)
//-----------------------------------------------------------------------------
void WriteAudIndex2Dram(ULONG MoviOfset, ULONG AVIIdxAddr) USING_0
{
//patch5.0@cytsai@AVI index begin
// Audio chunk 0x1C00 ~ 0x1C0F
XBYTE[0x1C00] = 0x30; XBYTE[0x1C01] = 0x31;
XBYTE[0x1C02] = 0x77; XBYTE[0x1C03] = 0x62;
XBYTE[0x1C04] = 0x00; XBYTE[0x1C05] = 0x00;
XBYTE[0x1C06] = 0x00; XBYTE[0x1C07] = 0x00;
XBYTE[0x1C0C] = 0x00; XBYTE[0x1C0D] = 0x02;
XBYTE[0x1C0E] = 0x00; XBYTE[0x1C0F] = 0x00;
XBYTE[0x1C08] = (UCHAR)MoviOfset; XBYTE[0x1C09] = (UCHAR)(MoviOfset>>8);
XBYTE[0x1C0A] = (UCHAR)(MoviOfset>>16); XBYTE[0x1C0B] = (UCHAR)(MoviOfset>>24);
L2_SetSRAMDMA(0x0C00);
L2_SetDRAMDMA(AVIIdxAddr);
L2_DoDMA(1,0,16,0,0);
//patch5.0@cytsai@AVI index end
}
//version4.0@yichang@0513 use function call to reduce code
//-----------------------------------------------------------------------------
//CopyAudio2Sram512(ULONG AudioAddr, ULONG SramAddr)
//-----------------------------------------------------------------------------
void CopyAudio2Sram512(ULONG AudioAddr, ULONG SramAddr) USING_0
{
L2_SetDRAMDMA(AudioAddr);
L2_SetSRAMDMA(SramAddr);
L2_SetDRAMAudDMACnt(1); // Enable DRAMAuddMACnt
L2_DoDMA(0,1,512,0,0);
L2_SetDRAMAudDMACnt(0);
}
//version4.0@yichang@0513 use function call to reduce code
//-----------------------------------------------------------------------------
//AudioPageLink(USHORT fHandle, ULONG pageAddr, USHORT SecNu)
//-----------------------------------------------------------------------------
void AudioPageLink(USHORT fHandle, ULONG pageAddr, USHORT SecNu) USING_0
{
USHORT offset;
ULONG UsedDramAddr;
offset = SecNu;
UsedDramAddr = pageAddr + offset/2;
offset = 512-offset;
L2_SetDRAMDMA(UsedDramAddr);
//patch4.4@yichang@change SRAM address begin
//L2_SetSRAMDMA(0x0A00);
L2_SetSRAMDMA(0x0C00);
//patch4.4@yichang@change SRAM address end
L2_DoDMA(1,0,offset,0,0);
M_Card_File_Write(fHandle, K_File_SrcDataDram2Card, 512, pageAddr, 0);
//SecAddr++;
//patch4.4@yichang@change SRAM address begin
//UsedDramAddr = 0x0A00+offset;
UsedDramAddr = 0x0C00+offset;
//patch4.4@yichang@change SRAM address end
offset = 512-offset;
L2_SetSRAMDMA(UsedDramAddr);
L2_SetDRAMDMA(pageAddr);
L2_DoDMA(1,0,offset,0,0);
}
//patch4.3@richie@zo v begin
//version4.0@yichang@0513 for AVI recording initialization
//-----------------------------------------------------------------------------
//void L1_InitAVIPreview(void)
//-----------------------------------------------------------------------------
void L1_InitAVIPreview(void) USING_0
{
USHORT imgHeight,imgWidth,imgOffX,imgOffY,jpegHeight;
UCHAR aviFactor;
UCHAR osdStr[5];
//patch4.4@yichang@for valid signal begin
UCHAR i;
//patch4.4@yichang@for valid signal end
//Joe@2003.2.21 12:58 add begin
//L2_TurnOnOffDisplay(0);
UI_ClearFOSD(25, 8, 0x00);
UI_PreviewStatusOSD();
//Joe@2003.2.21 12:58 add end
aviFactor = G_ucZoomFactor;
//Joe@2003.2.21 14:50 mask begin
/*
//patch4.4@yichang@for valid signal begin
while(((XBYTE[0x2DA0] & 0x04) == 0x04));
{
L2_CtrlScreen(2);
}
//patch4.4@yichang@for valid signal end
*/
//Joe@2003.2.21 14:50 mask end
L2_SetDisplayType(G_DisplayType);
L2_SetCamMode(0);
//patch5.0@richie@sdram mapping begin
L2_SetAFBAddr(K_SDRAM_AviPvwBufAddrA);
L2_SetBFBAddr(K_SDRAM_AviPvwBufAddrB);
L2_SetRFBAddr(K_SDRAM_AviPvwBufAddrA);
//patch5.0@richie@sdram mapping end
//patch5.0@richie@avi size begin
L2_SetACDSPWidth(G_usVideoClip_Width);
L2_SetBCDSPWidth(G_usVideoClip_Width);
L2_SetRCDSPWidth(G_usVideoClip_Width);
//patch5.0@richie@avi size end
//patch4.4@yichang@for valid signal begin
//L2_TurnOnOffDisplay(0);
//patch4.4@yichang@for valid signal end
L2_SetDisplayMode(1,1);
L2_WaitVD(0, 1);
//patch5.0@richie@avi size begin
//remove avi zoom
//if (aviFactor == 0)
//patch5.0@richie@avi size end
{
imgWidth = G_MHSize;
imgHeight = G_MVSize;
jpegHeight = imgHeight - 13;
if (jpegHeight >= 480) jpegHeight = 480;
else if (jpegHeight >= 360) jpegHeight = 360;
else if (jpegHeight >= 320) jpegHeight = 320;
else if (jpegHeight >= 300) jpegHeight = 300;
else if (jpegHeight >= 288) jpegHeight = 288;
else if (jpegHeight >= 280) jpegHeight = 280;
else if (jpegHeight >= 270) jpegHeight = 270;
else if (jpegHeight >= 264) jpegHeight = 264;
else if (jpegHeight >= 240) jpegHeight = 240;
else if (jpegHeight >= 220) jpegHeight = 220;
else if (jpegHeight >= 210) jpegHeight = 210;
else if (jpegHeight >= 200) jpegHeight = 200;
else if (jpegHeight >= 180) jpegHeight = 180;
else if (jpegHeight >= 160) jpegHeight = 160;
else if (jpegHeight >= 120) jpegHeight = 120;
//patch4.4@richie@zv begin
//mark following codes
//imgWidth = ((jpegHeight / 3) * 4) + 16;
//imgHeight = jpegHeight + 13;
//imgOffX = ((G_MHSize - imgWidth) / 2);
//imgOffX = (imgOffX >> 1) << 1;
//imgOffY = ((G_MVSize - imgHeight) / 2);
//imgOffY = (imgOffY >> 1) << 1;
//patch5.0@richie@avi size begin
//@avi???
//@size 448x336
/*
if (G_usVideoClip_Height == 336)
{
jpegHeight = 420;
}
*/
if (G_usVideoClip_Height == 144)
{
//jpegHeight need smaller than 288 * 2
if (jpegHeight > 288)
jpegHeight = 288;
}
//patch5.0@richie@avi size end
//change to following codes to resolve the ratio problem
imgWidth = imgWidth - (((imgHeight - 13 - jpegHeight) * 4) / 3);
imgHeight = jpegHeight + 13;
imgOffX = (((G_MHSize - imgWidth) / 2) >> 1) << 1;
imgOffY = (((G_MVSize - imgHeight) / 2) >> 1) << 1;
//patch4.4@richie@zv end
}
//patch5.0@richie@avi size begin
//remove avi zoom
/*
else
{
//patch4.4@richie@zv begin
//change to following codes to resolve the ratio problem
float zfH,zfV;
USHORT osdNum;
//patch5.0@richie@avi size begin
zfH = (float)(G_MHSize - 16) / (float)(G_usVideoClip_Width);
zfV = (float)(G_MVSize - 13) / (float)((G_usVideoClip_Height * 2) / 3);
printf("Zoom factor = %f,%f\n",zfH,zfV);
if (zfH > zfV)
{
imgWidth = (USHORT)((float)(G_MHSize - 16) / zfV) + 16;
imgHeight = ((G_usVideoClip_Height * 2) / 3) + 13;
}
else
{
imgWidth = G_usVideoClip_Width + 16;
imgHeight = (USHORT)((float)(G_MVSize - 13) / zfH) + 13;
}
//patch5.0@richie@avi size end
imgOffX = (((G_MHSize - imgWidth) / 2) >> 1) << 1;
imgOffY = (((G_MVSize - imgHeight) / 2) >> 1) << 1;
//imgWidth = K_VIDEOCLIP_Width + 16;
//imgHeight = K_VIDEOCLIP_Height + 13;
jpegHeight = imgHeight - 13;
if (jpegHeight >= 480) jpegHeight = 480;
else if (jpegHeight >= 360) jpegHeight = 360;
else if (jpegHeight >= 320) jpegHeight = 320;
else if (jpegHeight >= 300) jpegHeight = 300;
else if (jpegHeight >= 288) jpegHeight = 288;
else if (jpegHeight >= 280) jpegHeight = 280;
else if (jpegHeight >= 270) jpegHeight = 270;
else if (jpegHeight >= 264) jpegHeight = 264;
else if (jpegHeight >= 240) jpegHeight = 240;
else if (jpegHeight >= 220) jpegHeight = 220;
else if (jpegHeight >= 210) jpegHeight = 210;
else if (jpegHeight >= 200) jpegHeight = 200;
else if (jpegHeight >= 180) jpegHeight = 180;
else if (jpegHeight >= 160) jpegHeight = 160;
else if (jpegHeight >= 120) jpegHeight = 120;
//imgOffX = ((G_MHSize - K_VIDEOCLIP_Width) / 2);
//imgOffX = (imgOffX >> 1) << 1;
//imgOffY = ((G_MVSize - K_VIDEOCLIP_Height) / 2);
//imgOffY = (imgOffY >> 1) << 1;
//patch5.0@richie@avi size begin
if (G_usVideoClip_Height == 120)
{
//jpegHeight need smaller than 120 * 2
if (jpegHeight > 240)
jpegHeight = 240;
}
//patch5.0@richie@avi size end
//show zoom icon
//osdStr[0] = 'A' - 49;
//osdStr[1] = 'A' - 48;
//osdStr[2] = '\0';
//L2_SetColorPalette(2, 255, 255, 255);
//UI_PrintOSDString(osdStr, 3, 0, 2);
if (zfH > zfV)
osdNum = (USHORT)(zfV * (float)100);
else
osdNum = (USHORT)(zfH * (float)100);
osdStr[0] = (osdNum / 100) + '0';
osdStr[1] = '.';
osdStr[2] = ((osdNum % 100) / 10) + '0';
osdStr[3] = (osdNum % 10) + '0';
osdStr[4] = '\0';
G_usZoomOSDTimer = 10000;
L2_SetColorPalette(2, 255, 255, 255);
UI_PrintOSDString(osdStr, 2, 0, 2);
//show zoom icon
//patch4.4@richie@zv end
}
*/
//patch5.0@richie@avi size end
//printf("aviFactor = %bd\n",aviFactor);
//printf("imgOffX = %d\n",imgOffX);
//printf("imgOffY = %d\n",imgOffY);
//printf("imgWidth = %d\n",imgWidth);
//printf("imgHeight = %d\n",imgHeight);
//printf("jpegHeight = %d\n",jpegHeight);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -