📄 movfile.c
字号:
if ((sumLength + (FOURBYTE << 1)) >= boxSize)
{
return MOV_FILE_BOX_PARSE_SUCCESS;
}
}//for
}//else
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadMdat()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadMdat(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadPdin()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadPdin(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadMoof()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadMoof(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadMfra()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadMfra(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadFree()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadFree(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovReadSkip()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC int MovReadSkip(MOV_FILE *videoFile, MovFileinf *pFileinf, LONG boxSize)
{
ASSERT((videoFile != NULL)
&& (pFileinf != NULL));
MovFseek(videoFile, boxSize - (FOURBYTE << 1), SEEK_CUR);
return MOV_FILE_BOX_PARSE_SUCCESS;
}
/********************************************************************************************
* Func:
* MovGetAudioSampleSize()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetAudioSampleSize(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 audioSampleNo)
{
uint32 sampleSize = 0x0;
ASSERT(pFileinf != NULL);
if (pFileinf->audioSampleSize == 0x0)
{
sampleSize = sAudioSampleSizeIndex[audioSampleNo - 1];
sampleSize = BYTESWAP(sampleSize);
return sampleSize;
}
else
{
return pFileinf->audioSampleSize;
}
}
/********************************************************************************************
* Func:
* MovGetVideoSampleSize()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetVideoSampleSize(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 videoSampleNo)
{
uint32 sampleSize = 0x0;
ASSERT(pFileinf != NULL);
if (pFileinf->videoSampleSize == 0x0)
{
sampleSize = sVideoSampleSizeIndex[videoSampleNo - 1];
sampleSize = BYTESWAP(sampleSize);
return sampleSize;
}
else
{
return pFileinf->videoSampleSize;
}
}
/********************************************************************************************
* Func:
* MovGetAudioChunkOffset()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetAudioChunkOffset(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 audioChunkNo)
{
uint32 chunkOffset = 0x0;
chunkOffset = sAudioChunkOffsetIndex[audioChunkNo - 1];
chunkOffset = BYTESWAP(chunkOffset);
return chunkOffset;
}
/********************************************************************************************
* Func:
* MovGetVideoChunkOffset()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetVideoChunkOffset(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 videoChunkNo)
{
uint32 chunkOffset = 0x0;
chunkOffset = sVideoChunkOffsetIndex[videoChunkNo - 1];
chunkOffset = BYTESWAP(chunkOffset);
return chunkOffset;
}
/********************************************************************************************
* Func:
* MovGetVideoChunkSize()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetVideoChunkSize(MOV_FILE *videoFile,
MovFileinf *pFileinf,
const uint32 *beginSampleNo,
const uint32 *endSampleNo)
{
uint32 count = 0x0;
uint32 chunkSize = 0x0;
uint32 sampleSize = 0x0;
ASSERT((pFileinf != NULL)
&& (beginSampleNo != NULL)
&& (endSampleNo != NULL));
if (pFileinf->videoSampleSize == 0x0)
{
for (count=*beginSampleNo; count<=*endSampleNo; count++)
{
sampleSize = sVideoSampleSizeIndex[count - 1];
sampleSize = BYTESWAP(sampleSize);
chunkSize += sampleSize;
}
}
else
{
chunkSize = (*endSampleNo + 1 - *beginSampleNo) * pFileinf->videoSampleSize;
}
return chunkSize;
}
/********************************************************************************************
* Func:
* MovGetAudioChunkSize()
* Description:
*
* Param:
*
* Return:
*
*
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC uint32 MovGetAudioChunkSize(MOV_FILE *videoFile,
MovFileinf *pFileinf,
const uint32 *beginSampleNo,
const uint32 *endSampleNo)
{
uint32 count = 0x0;
uint32 chunkSize = 0x0;
uint32 sampleSize = 0x0;
ASSERT((pFileinf != NULL)
&& (beginSampleNo != NULL)
&& (endSampleNo != NULL));
if (pFileinf->audioSampleSize == 0x0)
{
for (count = *beginSampleNo; count <= *endSampleNo; count++)
{
sampleSize = sAudioSampleSizeIndex[count - 1];
sampleSize = BYTESWAP(sampleSize);
chunkSize += sampleSize;
}
}
else
{
chunkSize = (*endSampleNo + 1 - *beginSampleNo) * pFileinf->audioSampleSize;
}
return chunkSize;
}
/********************************************************************************************
* Func:
* MovVideoGetSampleToChunk()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC void MovVideoGetSampleToChunk(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 sampleNo,
uint32 *chunkNo,
uint32 *index)
{
if ((pFileinf->videoSampleNum == pFileinf->videoChunkNum)
&&(pFileinf->videoSampleToChunkNo == 0x1))
{
*chunkNo = sampleNo;
*index = 1;
}
else
{
{
uint32 firstChunkNo = 0x0;
uint32 samplesPerChunk = 0x0;
uint32 nextChunkNo = 0x0;
uint32 nextSamplesPerChunk = 0x0;
uint32 samplesCount = 0x0;
uint32 saveChunkNo = 0x0;
uint32 savesamplesPerChunk = 0x0;
uint32 loop = 0x1;
firstChunkNo = sVideoSampleToChunkIndex[((loop - 1) * 0x3)];
firstChunkNo = BYTESWAP(firstChunkNo);
samplesPerChunk = sVideoSampleToChunkIndex[((loop - 1) * 0x3) + 0x1];
samplesPerChunk = BYTESWAP(samplesPerChunk);
do
{
if (loop < pFileinf->videoSampleToChunkNo)
{
loop++;
nextChunkNo = sVideoSampleToChunkIndex[((loop - 1) * 0x3)];
nextChunkNo = BYTESWAP(nextChunkNo);
nextSamplesPerChunk = sVideoSampleToChunkIndex[((loop - 1) * 0x3) + 0x1];
nextSamplesPerChunk = BYTESWAP(nextSamplesPerChunk);
samplesCount += samplesPerChunk * (nextChunkNo - firstChunkNo);
saveChunkNo = firstChunkNo;
savesamplesPerChunk = samplesPerChunk;
firstChunkNo = nextChunkNo;
samplesPerChunk = nextSamplesPerChunk;
}
else
{
saveChunkNo = firstChunkNo;
savesamplesPerChunk = samplesPerChunk;
nextChunkNo = pFileinf->videoChunkNum + 1;
samplesCount += samplesPerChunk * (nextChunkNo - firstChunkNo);
//break;
}
}while (sampleNo > samplesCount);
*chunkNo = saveChunkNo
+ ((nextChunkNo-saveChunkNo) - (samplesCount - sampleNo) / savesamplesPerChunk - 1);
*index = savesamplesPerChunk
- (samplesCount - sampleNo) % savesamplesPerChunk;
}
}
return ;
}
/********************************************************************************************
* Func:
* MovAudioGetSampleToChunk()
* Description:
*
* Param:
*
* Return:
* 0: OK.
* -1: Error.
* Author:
* guosl
* Date:
* 2008-5-16 10:30
* Log:
*
********************************************************************************************/
STATIC void MovAudioGetSampleToChunk(MOV_FILE *videoFile,
MovFileinf *pFileinf,
uint32 sampleNo,
uint32 *chunkNo,
uint32 *index)
{
if ((pFileinf->audioSampleNum == pFileinf->audioChunkNum)
&&(pFileinf->audioSampleToChunkNo == 0x1))
{
*chunkNo = sampleNo;
*index = 1;
}
else
{
{
uint32 firstChunkNo = 0x0;
uint32 samplesPerChunk = 0x0;
uint32 nextChunkNo = 0x0;
uint32 nextSamplesPerChunk = 0x0;
uint32 samplesCount = 0x0;
uint32 saveChunkNo = 0x0;
uint32 savesamplesPerChunk = 0x0;
uint32 loop = 0x1;
firstChunkNo = sAudioSampleToChunkIndex[((loop - 1) * 0x3)];
firstChunkNo = BYTESWAP(firstChunkNo);
samplesPerChunk = sAudioSampleToChunkIndex[((loop - 1) * 0x3) + 0x1];
samplesPerChunk = BYTESWAP(samplesPerChunk);
do
{
if (loop < pFileinf->audioSampl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -