faint!!
在quicktime的文件格式中没有说明怎么描述mpeg4格式的video sample
我现在不知道怎么扩充video decrible!
常规的Video Sample Description的大小是86 bytes,而mpeg4格式的video增加了69bytes来描述esds atom,要命的我怎么知道esds atom的定义和用法阿!!!!
how to describe the mpeg4's sample?
how to get the specific "esds" atom?
a frame ,a sequence of audio data called a sample in streaming media?
----------------------------
yes!
quicktime stores media data in samples,a sample is a single element in a sequence of time-ordered data,but samples are stored in a series of chunks in a media.Chunks are a collection of data sample in a media that allowed optimized data access!
// a kind of media information atom,
//store the handler's specific information for a trak's media data.
// can use this information to map from media time to media data and to process the media data
class vmhdAtom:public baseAtom
{
public:
char m_version;
char m_flags[3];
INT16 m_graphicMode;
INT16 m_opcolor[3];
//constructor
vmhdAtom(int type=_MKTAG('v','m','h','d'))
{
m_size=GetConvertedSize(sizeof(*this));
m_type=type;
m_version=0;
//used to distinguish between movies created with quicktime1.0 and the newer
m_flags[2]=1;// the newer creator
//0x40:Dither the image (if needed),otherwise do a copy.
m_graphicMode=0x4000;
for(int i=0;i<3;i++)
m_opcolor[i]=0x8;
}
//the data handler compoent uses the atom to interpret the media data, asscociated with the hdlr atom
class dinfAtom:public baseAtom
{
public:
drefAtom m_drefAtom;
//constructor
dinfAtom(int type=_MKTAG('d','i','n','f'))
{
m_size=GetConvertedSize(sizeof(*this)-4);//0x24000000-->converted
m_type=type;
}
class SampleDesTable:public baseAtom
{
public:
char m_reserved[6];
//contain the index of the data reference to use to retrieve data associated with
//samples that use this sample des atom
INT16 m_dataReferenceIndex;
//constructor
SampleDesTable()
{
m_size=0;//later
m_type=0;//specifiy later
ZeroMemory(m_reserved,6);
}
// should add the specific media type data here,eg.pointer holder
void Mov_Write_Atom(FILE *pFile)
{
//important
//according the m_type to write the sample data
}
};
typedef st_sub_drefAtom st_sub_stsdAtom;
//sample description atom must contain at least one entry
//beacuse it contains the data reference index field that indicates which data
//reference atom to use to retrieve the meida samples
class stsdAtom:public baseAtom
{
//varies depending on the media type
public:
char m_version;
char m_flags[3];
UINT m_entries;
SampleDesTable *m_pSampleDesTable;//stsc atom has the table index as ID
//constructor
stsdAtom(int type=_MKTAG('s','t','s','d'))
{
m_size=GetConvertedSize(sizeof(*this)-4);//recalculate in later
m_type=type;
m_version=0;
ZeroMemory(m_flags,3);
m_entries=GetConvertedSize(1);// at least one entries in the atom
m_pSampleDesTable=0;
}
UINT GetAtomSize()
{
return sizeof(*this)-4;
}
void Mov_Write_Atom(FILE *pFile)
{
//should change the m_entries to the converted one
st_sub_stsdAtom *psub=(st_sub_stsdAtom*)this;
fwrite(psub,sizeof(st_sub_stsdAtom),1,pFile);
if(m_pSampleDesTable)
{
//write the table item
}
}
};
// used to index from time to sample number
struct TimeSampleTable
{
UINT m_sampleCount;
UINT m_sampleDuration;
};
typedef st_sub_drefAtom st_sub_sttsAtom;
//stts atom stores duration information for media's samples
//providing a mapping from a time in a media to the corresponding data sample
//if a video has a constant frame rate,the table will have only one entry
class sttsAtom:public baseAtom
{
public:
char m_version;
char m_flags[3];
UINT m_entries;
TimeSampleTable *m_pTimeSampleTable;
//indentify the key frames in the media,
//key frames define starting points for portions of a temporally compressed
//each entry in the table identifies a sample that is a key frame for the media,
//if no sync sample exists,then all the samples are key frames
class stssAtom:public baseAtom
{
public:
char m_version;
char m_flags[3];
UINT m_entries;
//each sample number corresponds to a key frame
UINT *m_pSampleTable;//??
//constructor
stssAtom(int type=_MKTAG('s','t','s','s'))
{
m_size=GetConvertedSize(sizeof(*this)-4);//recalculate later
m_type=type;
m_entries=0;
m_pSampleTable=0;
}
//identify the chunk for each sample in a media
struct SampleChunkTable
{
UINT m_firstChunk;
UINT m_sampleCount;//samples per chunk
UINT m_sampleDesID;//??how to get this ID
};
typedef unsigned short UINT16;
typedef signed short INT16;
typedef unsigned char UINT8;
typedef unsigned int UINT32;
typedef unsigned __int64 UINT64;
typedef signed char INT8;
typedef signed int INT32;
typedef signed __int64 INT64;
typedef unsigned int UINT;
UINT g_trackID=1;//cannt be zero
/*
the function of creating the time information of quicktime
*/
//convert the size to the high-->low sequence,
//when write it to file,according quicktime file format
UINT GetConvertedSize(UINT m_size)
{
UINT tempSize=0;
char byte=0;
if(m_size>=0)
{
tempSize=char(m_size>>24);
byte=char(m_size>>16);
tempSize+=byte<<8;
byte=char(m_size>>8);
tempSize+=byte<<16;
byte=char(m_size);
tempSize+=byte<<24;
}
return tempSize;
}
/****************************************************************
================information======================
Find a video sample:
1.Determines the time in the media time corrdinate system,see mdhd Atom,find the time base and get the time
2.Examine the time-to-sample atom to get the sample number that contains the data for the specified time
3.Scan the chunk-to-sample atom to discover which chunk contains the sample
4.Extracts the offset to the chunk from the chunk offset atom
5.Finds the offset within the chunk and the sample's size by using the sample size atom
// the 'wide' atom is exactly 8 bytes in size,and consists solely of its size and type field!
class freeAtom:public baseAtom
{
public:
char *pFreeBuffer;
freeAtom(int type=_MKTAG('f','r','e','e'))
{
m_size=GetConvertedSize(sizeof(*this)-4);
m_type=type;
pFreeBuffer=0;
}
//we can only understand the data in this atom by using media-data stored in the movie atom
class mdatAtom:public baseAtom
{
public:
char *pDataBuffer;
//This atom identifies the media handler component that is to be used to interpret the media data.
//Note that the atom tells you the kind of media this media atom contains
//¡ªfor example, video or sound. The layout of the media information atom is
//specific to the media handler that is to interpret the media.
class hdlrAtom:public baseAtom
{
public:
char m_version;
char m_flags[3];
UINT m_componentType;//mhlr?dhlr---> used for media atom
UINT m_subType;//'vide' ?'soun'
UINT m_manufacturer;
UINT m_componentFlags;
UINT m_componentFlagsMask;
//the header size is 24 bytes
//mp4:C string,not pascal string
/*
parse:
int len=0;
while(get_byte(pFile)&&++len<(atom_size-24)));//just skip
-------------------------------------------------------------
mov:pascal string
parse:
len=get_byte(pFile);
buffer=new char[len+1];
get_buffer(pFile,buffer,len);
buffer[len]='\0';
delete[] buffer;
*/
char *m_pComponentName;