⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umc_mp4_parser.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 3 页
字号:
    else    {        dr->GetUInt(&temp);        tkhd->creation_time = temp;        dr->GetUInt(&temp);        tkhd->modification_time = temp;        dr->GetUInt(&tkhd->track_id);        dr->MovePosition(4); //RESERVED        dr->GetUInt(&temp);        tkhd->duration = temp;    }    dr->MovePosition(16 + 9 * 4); //RESERVED    dr->GetUInt(&temp);    tkhd->track_width = (float)(temp >> 16);    dr->GetUInt(&temp);    tkhd->track_height = (float)(temp >> 16);    return 0;}// MDIA// The media declaration container contains all the objects that declare information about the media data within a// track.//int SplitterMP4::Read_mdia(DataReader *dr, T_mdia_data *mdia, T_atom_mp4 *trak_atom){    T_atom_mp4 leaf_atom;    do    {        if ( Read_Atom(dr, &leaf_atom) != 0 )        {            return 1;        }        if ( Compare_Atom(&leaf_atom, "mdhd") )        {            Read_mdhd(dr, &(mdia->mdhd));        }        else if ( Compare_Atom(&leaf_atom, "hdlr") )        {            Read_hdlr(dr, &(mdia->hdlr));            Atom_Skip(dr, &leaf_atom);        }        else if ( Compare_Atom(&leaf_atom, "minf") )        {            Read_minf(dr, &(mdia->minf), &leaf_atom);        }        else        {            Atom_Skip(dr, &leaf_atom);        }    } while ( (dr->GetPosition() < trak_atom->end) && (dr->GetPosition() != 0) );    return 0;}// HDLR Box// This box within a Media Box declares the process by which the media-data in the track is presented, and thus,// the nature of the media in a track. For example, a video track would be handled by a video handler.//int SplitterMP4::Read_hdlr(DataReader *dr, T_hdlr_data *hdlr){    unsigned int len;    dr->GetByte(&hdlr->version);    hdlr->flags = Get_24(dr);    dr->MovePosition(4); // RESERVED    len = 4;    dr->GetData(hdlr->component_type, (vm_var32*) &len);    dr->MovePosition(12); // RESERVED    return 0;}// MDHD Box// The media header declares overall information that is media-independent, and relevant to characteristics of// the media in a track.//int SplitterMP4::Read_mdhd(DataReader *dr, T_mdhd_data *mdhd){    unsigned int temp;    dr->GetByte(&mdhd->version);    mdhd->flags = Get_24(dr);    if ( mdhd->version )    {        dr->GetVar64(&mdhd->creation_time);        dr->GetVar64(&mdhd->modification_time);        dr->GetUInt(&mdhd->time_scale);        dr->GetVar64(&mdhd->duration);    }    else    {        dr->GetUInt(&temp);        mdhd->creation_time = temp;        dr->GetUInt(&temp);        mdhd->modification_time = temp;        dr->GetUInt(&mdhd->time_scale);        dr->GetUInt(&temp);        mdhd->duration = temp;    }    dr->GetShort(&mdhd->language);    dr->GetShort(&mdhd->quality);    // RESERVED    return 0;}// MINF Box// This box contains all the objects that declare characteristic information of the media in the track.//int SplitterMP4::Read_minf(DataReader *dr, T_minf_data *minf, T_atom_mp4 *parent_atom){    T_atom_mp4 leaf_atom;    do    {        if ( Read_Atom(dr, &leaf_atom) != 0 )        {            return 1;        }        if ( Compare_Atom(&leaf_atom, "vmhd") )        {            minf->is_video = 1;            Read_vmhd(dr, &(minf->vmhd));        }        else if ( Compare_Atom(&leaf_atom, "smhd") )        {            minf->is_audio = 1;            Read_smhd(dr, &(minf->smhd));        }        else if ( Compare_Atom(&leaf_atom, "hmhd") )        {            minf->is_hint = 1;            Read_hmhd(dr, &(minf->hmhd));        }        else if ( Compare_Atom(&leaf_atom, "dinf") )        {            Read_dinf(dr, &(minf->dinf), &leaf_atom);        }        else if ( Compare_Atom(&leaf_atom, "stbl") )        {            Read_stbl(dr, minf, &(minf->stbl), &leaf_atom);        }        else        {            Atom_Skip(dr, &leaf_atom);        }    } while ( (dr->GetPosition() < parent_atom->end) && (dr->GetPosition() != 0) );    return 0;}// HMHD Box// The hint media header contains general information, independent of the protocol, for hint tracks.//int SplitterMP4::Read_hmhd(DataReader *dr, T_hmhd_data *hmhd){    dr->GetByte(&hmhd->version);    hmhd->flags = Get_24(dr);    dr->GetShort(&hmhd->maxPDUsize);    dr->GetShort(&hmhd->avgPDUsize);    dr->GetUInt(&hmhd->maxbitrate);    dr->GetUInt(&hmhd->avgbitrate);    dr->GetUInt(&hmhd->slidingavgbitrate);    return 0;}// VMHD Box// The video media header contains general presentation information, independent of the coding, for video// media.//int SplitterMP4::Read_vmhd(DataReader *dr, T_vmhd_data *vmhd){    dr->GetByte(&vmhd->version);    vmhd->flags = Get_24(dr);    dr->MovePosition(8);    // RESERVED    return 0;}// SMHD Box// The sound media header contains general presentation information, independent of the coding, for audio// media. This header is used for all tracks containing audio.//int SplitterMP4::Read_smhd(DataReader *dr, T_smhd_data *smhd){    dr->GetByte(&smhd->version);    smhd->flags = Get_24(dr);    dr->MovePosition(4); // RESERVED    return 0;}// STBL Box// The sample table contains all the time and data indexing of the media samples in a track. Using the tables// here, it is possible to locate samples in time, determine their type (e.g. I-frame or not), and determine their// size, container, and offset into that container.//int SplitterMP4::Read_stbl(DataReader *dr, T_minf_data *minf, T_stbl_data *stbl, T_atom_mp4 *parent_atom){    T_atom_mp4 leaf_atom;    do    {        if ( Read_Atom(dr, &leaf_atom) != 0 )        {            return 1;        }        if ( Compare_Atom(&leaf_atom, "stsd") )        {            Read_stsd(dr, minf, &(stbl->stsd));            Atom_Skip(dr, &leaf_atom);        }        else if ( Compare_Atom(&leaf_atom, "stts") )        {            Read_stts(dr, &(stbl->stts));        }        else if ( Compare_Atom(&leaf_atom, "stsc") )        {            Read_stsc(dr, &(stbl->stsc));        }        else if ( Compare_Atom(&leaf_atom, "stsz") )        {            Read_stsz(dr, &(stbl->stsz));        }        else if ( Compare_Atom(&leaf_atom, "stco") )        {            Read_stco(dr, &(stbl->stco));        }        else if ( Compare_Atom(&leaf_atom, "co64") )        {            Read_co64(dr, &(stbl->co64));        }        else if ( Compare_Atom(&leaf_atom, "ctts") )        {            Read_ctts(dr, &(stbl->ctts));        }        else        {            Atom_Skip(dr, &leaf_atom);        }    } while ( (dr->GetPosition() < parent_atom->end) && (dr->GetPosition() != 0) );    return 0;}// CO64 Box// The chunk offset table gives the index of each chunk into the containing file. Use of 64-bit offsets.//int SplitterMP4::Read_co64(DataReader *dr, T_co64_data *co64){    unsigned int i;    dr->GetByte(&co64->version);    co64->flags = Get_24(dr);    dr->GetUInt(&co64->total_entries);    co64->table = (T_co64_table_data*)ippsMalloc_8u(sizeof(T_co64_table_data) * co64->total_entries);    // Check memory allocation    if (NULL == co64->table) {        return 0;    }    // Zeroed allocated table    memset(co64->table,  0, sizeof(T_co64_table_data) * co64->total_entries);    for ( i = 0; i < co64->total_entries; i++ )    {        dr->GetVar64(&co64->table[i].offset);    }    return 0;}// CTTS Box// This box provides the offset between decoding time and composition time.//int SplitterMP4::Read_ctts(DataReader *dr, T_ctts_data *ctts){    unsigned int i;    dr->GetByte(&ctts->version);    ctts->flags = Get_24(dr);    dr->GetUInt(&ctts->total_entries);    ctts->table = (T_ctts_table_data*)ippsMalloc_8u(sizeof(T_ctts_table_data) * ctts->total_entries);    // Check memory allocation    if (NULL == ctts->table) {        return 0;    }    // Zeroed allocated table    memset(ctts->table,  0, sizeof(T_ctts_table_data) * ctts->total_entries);    for ( i = 0; i < ctts->total_entries; i++ )    {        dr->GetUInt(&ctts->table[i].sample_count);        dr->GetUInt(&ctts->table[i].sample_offset);    }    return 0;}// STCO Box// The chunk offset table gives the index of each chunk into the containing file. Use of 32-bit offsets.//int SplitterMP4::Read_stco(DataReader *dr, T_stco_data *stco){    unsigned int i;    dr->GetByte(&stco->version);    stco->flags = Get_24(dr);    dr->GetUInt(&stco->total_entries);    stco->table = (T_stco_table_data*)ippsMalloc_8u(sizeof(T_stco_table_data) * stco->total_entries);    // Check memory allocation    if (NULL == stco->table) {        return 0;    }    // Zeroed allocated table    memset(stco->table,  0, sizeof(T_stco_table_data) * stco->total_entries);    for ( i = 0; i < stco->total_entries; i++ )    {        dr->GetUInt(&stco->table[i].offset);    }    return 0;}// STSZ Box// This box contains the sample count and a table giving the size in bytes of each sample. This allows the media// data itself to be unframed. The total number of samples in the media is always indicated in the sample count.//int SplitterMP4::Read_stsz(DataReader *dr, T_stsz_data *stsz){    unsigned int i;    dr->GetByte(&stsz->version);    stsz->flags = Get_24(dr);    dr->GetUInt(&stsz->sample_size);    dr->GetUInt(&stsz->total_entries);    stsz->entries_allocated = stsz->total_entries;    if ( !stsz->sample_size )    {        stsz->table = (T_stsz_table_data*)ippsMalloc_8u(sizeof(T_stsz_table_data) * stsz->entries_allocated);        // Check memory allocation        if (NULL == stsz->table) {            return 0;        }        // Zeroed allocated table        memset(stsz->table,  0, sizeof(T_stsz_table_data) * stsz->total_entries);        for ( i = 0; i < stsz->total_entries; i++ )        {            dr->GetUInt(&stsz->table[i].size);            if ( stsz->table[i].size > stsz->entries_allocated )            {                stsz->entries_allocated = stsz->table[i].size;            }        }    }    return 0;}// STSC Box// Samples within the media data are grouped into chunks. Chunks can be of different sizes, and the samples// within a chunk can have different sizes. This table can be used to find the chunk that contains a sample, its// position, and the associated sample description.//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -