📄 qt_parse.c
字号:
Uint32 size :: Size of Atom
TKHD_Info *tkhd :: TKHD Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseTKHDAtom( Uint8 *start , Uint32 size, TKHD_Info *tkhd) {
tkhd->width = get_word32( start + QT_WIDTH_OFFSET ) >> 16;
tkhd->height = get_word32( start + QT_HEIGHT_OFFSET ) >> 16;
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseMDIAAtom
@Description ::
Parse the Media Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
MDIA_Info *mdia :: MDIA Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseMDIAAtom( Uint8 *start , Uint32 size, MDIA_Info *mdia) {
Uint32 tag;
Uint8 *cur;
Uint8 *end;
end = start + size;
cur = start + 8;
while(cur < end) {
size = get_word32( cur );
tag = get_word32( cur + 4 );
switch( tag ) {
case QT_HDLR_TAG :
QTParseHDLRAtom( cur , size, &mdia->hdlr);
break;
case QT_MINF_TAG :
QTParseMINFAtom( cur , size, &mdia->minf);
break;
default :
/* tag not supported or no useful info in tag */
break;
}
cur += size;
}
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseHDLRAtom
@Description ::
Parse the Media Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
HDLR_Info *hdlr :: HDLR Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseHDLRAtom( Uint8 *start , Uint32 size, HDLR_Info *hdlr) {
if(get_word32( start + QT_COMP_TYPE_OFFSET ) == COMP_TYPE_MHLR) {
hdlr->compType = get_word32( start + QT_COMP_TYPE_OFFSET );
hdlr->compSubType = get_word32( start + QT_COMP_SUB_TYPE_OFFSET );
}
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseMINFAtom
@Description ::
Parse the Media Information Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
MINF_Info *moov :: MINF Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseMINFAtom( Uint8 *start , Uint32 size, MINF_Info *minf) {
Uint32 tag;
Uint8 *cur;
Uint8 *end;
end = start + size;
cur = start + 8;
while(cur < end) {
size = get_word32( cur );
tag = get_word32( cur + 4 );
switch( tag ) {
case QT_STBL_TAG :
QTParseSTBLAtom( cur , size, &minf->stbl);
break;
default :
/* tag not supported or no useful info in tag */
break;
}
cur += size;
}
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseSTBLAtom
@Description ::
Parse the Sample Table Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
STBL_Info *moov :: STBL Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseSTBLAtom( Uint8 *start , Uint32 size, STBL_Info *stbl) {
Uint32 tag;
Uint8 *cur;
Uint8 *end;
end = start + size;
cur = start + 8;
while(cur < end) {
size = get_word32( cur );
tag = get_word32( cur + 4 );
switch( tag ) {
case QT_STTS_TAG :
QTParseSTTSAtom( cur , size, &stbl->stts);
break;
case QT_STSD_TAG :
QTParseSTSDAtom( cur , size, &stbl->stsd);
break;
case QT_STSZ_TAG :
QTParseSTSZAtom( cur , size, &stbl->stsz);
break;
case QT_STCO_TAG :
QTParseSTCOAtom( cur , size, &stbl->stco);
break;
default :
/* tag not supported or no useful info in tag */
break;
}
cur += size;
}
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseSTTSAtom
@Description ::
Parse the Sample to Time Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
STTS_Info *stts :: STTS Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseSTTSAtom( Uint8 *start , Uint32 size, STTS_Info *stts) {
/* assume first entry in time-to-sample table gives sample duration */
stts->sampleDuration = get_word32( start + QT_SAMPLE_DURATION_OFFSET ) ;
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseSTSDAtom
@Description ::
Parse the Sample Time to Sample Duration Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
STSD_Info *stsd :: STSD Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseSTSDAtom( Uint8 *start , Uint32 size, STSD_Info *stsd) {
/* assume only 1 sample description entry exists */
stsd->dataformat = get_word32( start + QT_DATA_FORMAT_OFFSET );
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseSTSZAtom
@Description ::
Parse the Sample to Size Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
STSZ_Info *stsz :: STSZ Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseSTSZAtom( Uint8 *start , Uint32 size, STSZ_Info *stsz) {
Uint32 sSize;
sSize = get_word32(start + QT_SAMPLE_SIZE_OFFSET );
if( sSize == 0) {
Uint32 i;
stsz->sampleSizeConst = FALSE;
stsz->sampleCount = get_word32(start + QT_SAMPLE_COUNT_OFFSET );
if(stsz->sampleSizeTable!=NULL) {
for(i=0; i<stsz->sampleCount; i++ )
stsz->sampleSizeTable[i] = get_word32(start + QT_SAMPLE_SIZE_TABLE_OFFSET + i*4 );
}
} else {
stsz->sampleSizeConst = TRUE;
stsz->sampleCount = 0;
if(stsz->sampleSizeTable!=NULL) {
stsz->sampleSizeTable[0] = sSize;
}
}
return E_PASS;
}
/*-----------------------------------------------------------------------------\
@RoutineName :: QTParseSTCOAtom
@Description ::
Parse the Chunk Offset Atom
@Parameters ::
Uint8 *start :: Pointer to start of Atom
Uint32 size :: Size of Atom
STCO_Info *stco :: STCO Info
@Return ::
E_PASS, success
E_DEVICE, failure
\-----------------------------------------------------------------------------*/
STATUS QTParseSTCOAtom( Uint8 *start , Uint32 size, STCO_Info *stco) {
// assumes there is only one chunk
stco->chunkOffset = get_word32(start + QT_CHUNK_OFFSET_TABLE_OFFSET );
return E_PASS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -