📄 mpeg4contrl.c
字号:
if (aviTimerCounter > FFD_FFW_INTERVAL)
{
if (!step)
step = AVI_FFD_FFW_SKIP_FRAME_NUM + 15 * (ffd_ffw_times / 4);
else
step = step / ((avih.dwMicroSecPerFrame + 500) / 1000);
/***********************************************************
Get next I chunk. Param 4 is the minimum video chunk number
between current I chunk and the I chunk we are going to get,
it will be increased as time growth.
************************************************************/
if (AviVideoGetNextIChunk(&aviPointer, &chunkInfo, 0, step) < 0)
{
//AviVideoGetPreIChunk(&aviPointer, &chunkInfo, 0, 2);
return -1;
}
aviPlayState = AVI_STATE_FFD;
/* send ffd/ffw msg to dsp. */
SendOperationMsg(VIDEO_OPERATION_FFD_FFW);
dispFrameNum = aviPointer.VideoChunkNum - 1;
ffd_ffw_times ++;
#ifndef SEEK_TABLE
/* If we have a seek table, it has no use for us to sync audio to video each time. */
AviSynAudio2Video();
#endif
aviTimerCounter = 0;
/* show all frame in yuv buffer out. */
while (IsYuvReady(curFrame))
AviShowVideoFrame();
/* Slow down display speed when ffd/ffw. */
dispInterval = FFD_FFW_DISPLAY_SPEED;
return 0;
}
return 0;
}
/********************************************************************************************
Func:
AviFFW()
Description:
Avi fast forward.
Param:
step length.
Return:
None.
Author:
ljn
Date:
2007-11-19 10:22
Log:
********************************************************************************************/
int AviFFW(unsigned int step)
{
/* do nothing when video is stoped. */
if ((aviPlayState == AVI_STATE_STOP) || (aviPlayState == AVI_STATE_INITIALIZING))
return 0;
if (aviPlayState == AVI_STATE_PAUSE)
AviPlayPause();
if (aviTimerCounter > FFD_FFW_INTERVAL)
{
/* step length. */
if (!step)
step = AVI_FFD_FFW_SKIP_FRAME_NUM + 15 * (ffd_ffw_times / 4);
else
step = step / ((avih.dwMicroSecPerFrame + 500) / 1000);
/* Get Previous I chunk. */
AviVideoGetPreIChunk(&aviPointer, &chunkInfo, 0, step);
aviPlayState = AVI_STATE_FFW;
/* send ffd/ffw msg to dsp. */
SendOperationMsg(VIDEO_OPERATION_FFD_FFW);
dispFrameNum = aviPointer.VideoChunkNum - 1;
ffd_ffw_times ++;
aviTimerCounter = 0;
/* show all frame in yuv buffer out. */
while (IsYuvReady(curFrame))
AviShowVideoFrame();
/* Slow down display speed when ffd/ffw. */
dispInterval = FFD_FFW_DISPLAY_SPEED;
}
return 0;
}
/********************************************************************************************
Func:
AviResume()
Description:
Avi Resume.
Param:
None.
Return:
None.
Author:
ljn
Date:
2007-11-19 15:59
Log:
********************************************************************************************/
void AviResume(void *param)
{
int i;
/* do nothing if current state is not ffd or ffw. */
if ((aviPlayState != AVI_STATE_FFD) && (aviPlayState != AVI_STATE_FFW))
return ;
#if 0
SendOperationMsg(VIDEO_OPERATION_PLAY);
AviVideoGetNextIChunk(&aviPointer, &videoChunkInfo, 0, 2);
//aviPlayState = AVI_STATE_PALYING;
#else
/* stop video frames display. */
Timer_PowerOffDeinit(0);
DisableDecoder();
while (IsYuvReady(curFrame))
AviShowVideoFrame();
AviShareDataInit();
if (aviPlayState == AVI_STATE_FFD)
/* FFD */
AviVideoGetNextIChunk(&aviPointer, &chunkInfo, 0, AVI_FFD_FFW_RESUME_FLAG);
else
/* FFW */
AviVideoGetPreIChunk(&aviPointer, &chunkInfo, 0, AVI_FFD_FFW_RESUME_FLAG);
#endif
OSSchedLock();
AviSynAudio2Video();
OSSchedUnlock();
dispFrameNum = aviPointer.VideoChunkNum - 1;
if (stream_supported_flag.VideoCodecLib == VIDEO_CODEC_LIB_DIV3) /* restart decoder. */
{
VideoDecoderLoad(aviVideoBufRemain, "DIV3");
}
else if (stream_supported_flag.VideoCodecLib == VIDEO_CODEC_LIB_MJPG)
{
VideoDecoderLoad(aviVideoBufRemain, "MJPG");
}
else
{
VideoDecoderLoad(aviVideoBufRemain, "MPEG4");
}
dispInterval = TIMER_ISR_NUM_PER_FRAME; /* display speed resume. */
timerIsrTimes = 5;
lcdUpdateTimer = 4;
ffd_ffw_times = 0;
aviPlayState = AVI_STATE_PALYING;
/* start video frames display control. */
AviFrameDispCtrl(0);
}
int AviGetAudioData(char *buffer, DWORD size)
{
if ((aviPlayState == AVI_STATE_STOP))
return 0;
if (AviAudioGetDataToSDRAM(&aviPointer, buffer, &size) >= 0)
{
isAudioPlayEnd = FALSE;
return size;
}
else
{
isAudioPlayEnd = TRUE;
return 0;
}
}
void AviGetTimeInfoMs(unsigned int *curTime, unsigned int *totalTime)
{
/*******************************************************************
[NOTE] The time that get with this fuction is not very precision, it
is just for user interface.
********************************************************************/
int curFrmNum;
if ((aviPlayState == AVI_STATE_FFD) || (aviPlayState == AVI_STATE_FFW))
{
curFrmNum = aviPointer.VideoChunkNum;
}
else
{
curFrmNum = dispFrameNum;
}
/* get current ms time. */
*curTime = ((long long)(curFrmNum) * (long long)(avih.dwMicroSecPerFrame) + 500) / 1000;
/**********************************************************
[NOTICE] It may be wrong to get total time from avi header.
***********************************************************/
*totalTime = ((long long)(avih.dwTotalFrames) * (long long)(avih.dwMicroSecPerFrame) + 500) / 1000;
}
unsigned int AviGetCurTime(void)
{
/*******************************************************************
[NOTE] The time that get with this fuction is not very precision, it
is just for user interface.
********************************************************************/
int curFrmNum;
if ((aviPlayState == AVI_STATE_FFD) || (aviPlayState == AVI_STATE_FFW))
{
curFrmNum = aviPointer.VideoChunkNum;
}
else
{
if (isAudioPlayEnd == TRUE)
curFrmNum = avih.dwTotalFrames;
else
curFrmNum = dispFrameNum;
}
/* get current ms time. */
return ((long long)(curFrmNum) * (long long)(avih.dwMicroSecPerFrame) + 500) / 1000;
}
unsigned int AviGetTotalTime(void)
{
return ((long long)(avih.dwTotalFrames) * (long long)(avih.dwMicroSecPerFrame) + 500) / 1000;
}
int AviPlayPause(void)
{
if ((aviPlayState == AVI_STATE_STOP) || (aviPlayState == AVI_STATE_INITIALIZING))
return FALSE;
if (aviPlayState == AVI_STATE_PAUSE)
{
/* Start frame display timer. */
AviFrameDispCtrl(0);
aviPlayState = AVI_STATE_PALYING;
return FALSE;
}
else
{
/* Stop frame display timer. We may set DSP idle here to save power. */
Timer_PowerOffDeinit(0);
aviPlayState = AVI_STATE_PAUSE;
return TRUE;
}
}
int AviVideoSeek(long msTime)
{
if ((aviPlayState != AVI_STATE_PALYING) && (aviPlayState != AVI_STATE_PAUSE) && (aviPlayState != AVI_STATE_INITIALIZING))
return 0;
/* seek video chunk to time. */
if (AviSeekIChunk2Time(msTime))
return -1;
if (aviPlayState != AVI_STATE_INITIALIZING)
{
/* stop video frames display. */
Timer_PowerOffDeinit(0);
DisableDecoder();
AviShareDataInit();
/* update displayed frame number */
dispFrameNum = aviPointer.VideoChunkNum - 1;
/* syn audio to video. */
OSSchedLock();
AviSynAudio2Video();
OSSchedUnlock();
if (stream_supported_flag.VideoCodecLib == VIDEO_CODEC_LIB_DIV3) /* restart decoder. */
{
VideoDecoderLoad(aviVideoBufRemain, "DIV3");
}
else if (stream_supported_flag.VideoCodecLib == VIDEO_CODEC_LIB_MJPG)
{
VideoDecoderLoad(aviVideoBufRemain, "MJPG");
}
else
{
VideoDecoderLoad(aviVideoBufRemain, "MPEG4");
}
timerIsrTimes = 5;
lcdUpdateTimer = 4;
/* start video frames display . */
AviFrameDispCtrl(0);
}
return 0;
}
int AviGetCurYUVInfo(char **pYuv, long *pWidth, long *pHeight)
{
if (lastYuvBufId < 0)
return 0;
*pYuv = yuvBuf + lastYuvBufId * YUV_BUFFER_SIZE;
*pWidth = (avih.dwWidth + 15) & 0xfff0;
*pHeight = (avih.dwHeight + 15) & 0xfff0;
return 1;
}
int AviGetYuvAddr(char **pYuv)
{
if (lastYuvBufId < 0)
return 0;
*pYuv = yuvBuf + lastYuvBufId * YUV_BUFFER_SIZE;
return 1;
}
int AviGetResolution(long *pWidth, long *pHeight)
{
*pWidth = (avih.dwWidth + 15) & 0xfff0;
*pHeight = (avih.dwHeight + 15) & 0xfff0;
return 0;
}
short AviGetDecStatus(void)
{
if ((aviPlayState == AVI_STATE_STOP) || (aviPlayState == AVI_STATE_INITIALIZING))
return 0;
else
return GetDecStatus();
}
#ifdef TVOUT_PANEL
extern DWDMALLP gLLPList[ ][480]; // LCD刷屏接口用
extern BACKGRND gScreen[2];
extern void ReCreat(void);
void AVITVoutChange(void)
{
TVOUTPARA TVoutPara;
TVoutPara.Type = TV_VEDIO;
TVoutPara.Mode = TV_PAL50;
TVoutPara.Size = TV_LARGE;
TVoutPara.Switch = LCD_TVOUT;
if (Screen_GetType() == TVOUT)
{
TVoutPara.Oddtion.Status = TV_Standby;
Screen_SetTvout(TVOUT_Status, &TVoutPara, 0, 0);
#ifdef MCU_PANEL
Screen_Configure(gLcdW, gLcdH, MCULCD, &TVoutPara);
#else
Screen_Configure(gLcdW, gLcdH, RGBLCD, &TVoutPara);
#endif
Screen_CreatRGB(&gScreen[0], &gLLPList[0][0], (uint32)gGuiDspLcdTransScreen0, gLcdW, gLcdH);
Screen_CreatRGB(&gScreen[1], &gLLPList[1][0], (uint32)gGuiDspLcdTransScreen1, gLcdW, gLcdH);
AviCreateVideoScreen(&avih);
}
else
{
//Screen_MCUIFUpdateFinish();
while (Screen_GetMCUIFStatus() == BUSY);
BL_SetBright(BL_DARK);
Screen_Display(OFF);
Screen_Configure(TVOUT_VIDEO_W, TVOUT_VIDEO_H, TVOUT, &TVoutPara);
AviCreateVideoScreen(&avih);
}
ReCreat();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -