MP4.h
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:8k
- /****************************************************************************************
- * Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: MP4.h $
- *
- * Description:
- * ============
- * Management of MP4 Clips
- *
- * Log:
- * ====
- * $Revision: #1 $
- * $Change: 24403 $
- * Last Modified by $Author: robin.jiang $ at $DateTime: 2004/08/02 15:02:11 $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/MP4.h $
- *
- * 1 8/2/2004 RobinJ
- * Created
- *
- ****************************************************************************************/
- #ifdef IS_MP4_CAPABLE
- #include "Config.h" // Global Configuration - do not remove!
- #ifndef __MP4_H_
- #define __MP4_H_
- #include "IncludeSysDefs.h"
- #include "PlaycoreFileSysFileSystem.h"
- #include "Decoderdecoder.h"
- /////////////////////////////////////////////////////////////////////////////
- // Constants and Enumerations
- #define MP4_ESDS_ID "esds"
- #define MP4_ES_DESCR_Tag 0x03
- #define MP4_DEC_CONFIG_DESCR_Tag 0x04
- #define MP4_DEC_SPECIFIC_DESCR_Tag 0x05
- #define MP4_VIDEO_TRACK_HANDLER_TYPE "vide"
- #define MP4_AUDIO_TRACK_HANDLER_TYPE "soun"
- #define MP4_SUBPICTURE_TRACK_HANDLER_TYPE "subp"
- #define MP4_SUBTITLE_TRACK_HANDLER_TYPE "subt"
- #define MP4_ODSM_TRACK_HANDLE_TYPE "odsm"
- #define MP4_BIFS_TRACK_HANDLE_TYPE "sdsm"
- #define MP4_USER_TYPE_ID "uuid"
- #define MP4_FILE_TYPE_ID "ftyp"
- #define MP4_MOVIE_ID "moov" // contrainer
- #define MP4_MOVIE_HEADER_ID "mvhd" // FULLBOX
- #define MP4_TRACK_ID "trak" // contrainer
- #define MP4_TRACK_HEADER_ID "tkhd" // FULLBOX
- #define MP4_TRACK_REFERENCE_ID "tref"
- #define MP4_EDIT__ID "edts" // contrainer
- #define MP4_EDIT_LIST_ID "elst" //FULLBOX
- #define MP4_MEDIA_ID "mdia" // contrainer
- #define MP4_MEDIA_HEADER_ID "mdhd" // FULLBOX
- #define MP4_HANDLER_REFERENCE_ID "hdlr" // FULLBOX
- #define MP4_MEDIA_INFOMATION_ID "minf" // container
- #define MP4_VIDEO_MEDIA_HEADER_ID "vmhd" //FULLBOX
- #define MP4_SOUND_MEDIA_HEADER_ID "smhd" // FULLBOX
- #define MP4_HINT_MEDIA_HEADER_ID "hmhd" // FULLBOX
- #define MP4_DATA_INFOMATION_ID "dinf" //container
- #define MP4_DATA_URL_ID "url " // FULLBOX
- #define MP4_DATA_URN_ID "urn " // FULLBOX
- #define MP4_DATA_REFERENCE_ID "dref" // FULLBOX
- #define MP4_SAMPLE_TABLE_ID "stbl" // container
- #define MP4_SAMPLE_DESCRIPTION_ID "stsd" // FULLBOX
- #define MP4_DECODING_TIME_TO_SAMPLE_ID "stts" // FULLBOX
- #define MP4_COMPOSITION_TIME_TO_SAMPLE_ID "ctts" // FULLBOX
- #define MP4_SAMPLE_TO_CHUNK_ID "stsc" // FULLBOX
- #define MP4_SAMPLE_SIZE_ID "stsz" // FULLBOX
- #define MP4_COMPACT_SAMPLE_SIZE_ID "stz2" // FULLBOX
- #define MP4_CHUNK_OFFSET_ID "stco" // FULLBOX
- #define MP4_64BIT_CHUNK_OFFSET_ID "co64" // FULLBOX
- #define MP4_SYNC_SAMPLE_ID "stss" // FULLBOX
- #define MP4_SHADOW_SYNC_SAMPLE_ID "stsh" // FULLBOX
- #define MP4_PADDING_BITS_ID "padb" // FULLBOX
- #define MP4_DEGRADATION_PRIORITY_ID "stdp" // FULLBOX
- #define MP4_MOVIE_EXTENDS_ID "mvex"
- #define MP4_TRACK_EXTENDS_ID "trex" // FULLBOX
- #define MP4_MOVIE_FRAGMENT_ID "moof"
- #define MP4_MOVIE_FRAGMENT_HEADER_ID "mfhd" // FULLBOX
- #define MP4_TRACK_FRAGEMENT_ID "traf"
- #define MP4_TRACK_FRAGMENT_HEADER_ID "tfhd" // FULLBOX
- #define MP4_TRACK_FRAGMENT_RUN_ID "trun" // FULLBOX
- #define MP4_MEDIA_DATA_ID "mdat"
- #define MP4_FREE_ID "free"
- #define MP4_SKIP_ID "skip"
- #define MP4_USER_DATA_ID "udta"
- #define MP4_COPYRIGHT_ID "cprt" // FULLBOX
- #define MP4_CHAPTER_LIST_ID "chpl"
- #define MP4_NERO_DRM_ID "ndrm"
- #define NERO_DIGITAL_MOBIE "ndsm"
- #define NERO_DIGITAL_PORTABLE "ndsp"
- #define NERO_DIGITAL_STANDARD "ndss"
- #define NERO_DIGITAL_CINEMA "ndsc"
- #define NERO_DIGITAL_HDTV "ndsh"
- #define NERO_DIGITAL_MOBIE_AVC "ndxm"
- #define NERO_DIGITAL_PORTABLE_AVC "ndxp"
- #define NERO_DIGITAL_STANDARD_AVC "ndxs"
- #define NERO_DIGITAL_CINEMA_AVC "ndxc"
- #define NERO_DIGITAL_HDTV_AVC "ndxh"
- typedef enum
- {
- CODEC_TYPE_VIDEO = 1,
- CODEC_TYPE_AUDIO,
- CODEC_TYPE_SUBPICTURE,
- CODEC_TYPE_SUBTITLE,
- CODEC_TYPE_RESERVED,
- CODEC_TYPE_UNKNOWN
- } MP4_CODEC_TYPE;
- /////////////////////////////////////////////////////////////////////////////
- // Common Structures
- typedef struct
- {
- UINT32 ulType;
- UINT32 ulSize;
- } MP4Box;
- typedef struct
- {
- DWORD dwSTSCOffsetInFile;
- DWORD dwSTSCStartAddr; // sample to chunk
- DWORD dwSTSCEntryCount;
- DWORD dwSTCOOffsetInFile;
- DWORD dwSTCOStartAddr; // chunk offset
- DWORD dwSTCOEntryCount;
-
- DWORD dwSTSZOffsetInFile; // sample size
- DWORD dwSTSZSampleSize; //
- DWORD dwSTSZEntryCount;
- DWORD dwSTSSOffsetInFile;
- DWORD dwSTSSStartAddr; // sync sample
- DWORD dwSTSSEntryCount;
- DWORD dwSTTSOffsetInFile;
- DWORD dwSTTSStartAddr; // time to sample
- DWORD dwSTTSEntryCount;
-
- DWORD dwChunkSizeStartAddr; // store chunk offset & addr
- DWORD dwSyncEntryStartAddr; // store sync entry, if subtitle, use store sample offset/size/time
- BOOL bCompactSampeSize;
- BOOL bCO64;
- BOOL bPackSTSC;
- BOOL bPackSTCO;
- BOOL bPackSTSZ;
- } MP4StreamSampleTableAddr;
- typedef struct
- {
- MP4StreamSampleTableAddr mp4StreamSampleTableAddr;
- } MP4StreamSampleTableAddrEX;
- #define STSC 0x1
- #define STCO 0x2
- #define STSZ 0x4
- #define STSS 0x8
- #define STTS 0x10
- #define AUDIO_SAMPLETABLE_VALID (STSC | STCO | STSZ | STTS)
- #define VIDEO_SAMPLETABLE_VALID (AUDIO_SAMPLETABLE_VALID | STSS)
- #define SUB_SAMPLETABLE_VALID (AUDIO_SAMPLETABLE_VALID | STTS)
- #define SAMPLE_TABLE_START_ADDR ((IS_DVD_PHYSICAL_MEDIA ? (OSD_BUFFER_SIZE_DVD_AUX + VCB_SIZE_DVD_AUX) : (OSD_BUFFER_SIZE_CD_AUX + VCB_SIZE_CD_AUX) ) * 512UL)
- #define MAX_SAMPLE_TABLE_BUFFER_SIZE 256
- #define MP4_CHUNK_OFFSET_BUFF_SIZE 4
- #define MP4_CHUNK_SIZE_BUFF_SIZE 4
- #define MP4_SYNC_SAMPLE_BUFF_SIZE 4
- #define MP4_SYNC_ENTRY_BUFF_SIZE 2
- #define MP4_SUBTITLE_SAMPLE_ENTRY_BUFF_SIZE 2
- #define MP4_NOT_USED_STREAM_ID 0xff
- #define MP4_NO_DUMMY_CHUNK 1
- #define MP4_PACK_STCO 1
- // RB_1124_2004, ensure the max chunk size less than VCB size
- #ifdef SDRAM_2X16MBITS
- #define MP4_MAX_CHUNK_SIZE 0x20000UL // 128KB
- #else
- #define MP4_MAX_CHUNK_SIZE 0x80000UL // 512KB
- #endif
-
- typedef struct
- {
- #ifndef MP4_NO_DUMMY_CHUNK
- DWORD dwStreamChunkSizeAddr;
- #endif
- DWORD dwStreamChunkOffsetAddr;
- DWORD dwStreamChunkTotal;
- DWORD dwStreamChunkNumber;
- // BOOL bStreamChunkFlag;
- DWORD dwStreamChunkOffset;
- DWORD OffsetBuff[MP4_CHUNK_SIZE_BUFF_SIZE];
- #ifndef MP4_NO_DUMMY_CHUNK
- DWORD SizeBuff[MP4_CHUNK_SIZE_BUFF_SIZE];
- #endif
-
- #ifdef MP4_PACK_STCO
- DWORD dwPrevChunkOffset;
- BOOL bPackSTCO;
- #endif
- } MP4StreamChunkSizeBuff;
- typedef struct
- {
- DWORD dwSampleCount;
- DWORD dwSampleDelta;
- } MP4TimeToSampleEntry;
- typedef struct
- {
- DWORD dwFirstChunk;
- DWORD dwSamplePerChunk;
- DWORD dwIndex;
- } MP4SampleToChunkEntry;
- typedef struct
- {
- DWORD dwChunkOffset;
- DWORD dwSampleSize;
- DWORD dwSampleEndTime;
- } MP4SubtitleSampleEntry;
- typedef struct
- {
- DWORD dwSyncSampleNumber;
- DWORD dwSyncChunkOffset;
- DWORD dwOffsetofChunk;
- DWORD dwSyncSampleSize;
- // DWORD dwSyncSampleOffset;
- } MP4VideoSyncEntry;
- typedef struct
- {
- DWORD dwSyncChunkOffset;
- DWORD dwOffsetofChunk;
- // DWORD dwSyncSampleOffset;
- } MP4AudioSyncEntry;
- /////////////////////////////////////////////////////////////////////////////
- // Public Services
- BOOL MP4Clip_isKindOf(LPCWSTR i_pszFilename);
- void MP4Clip_continueScanning(void);
- void MP4Clip_construct(struct Clip_TAG *o_pThis, const FindData *i_pFileInfo);
- void MP4Clip_performErrorHandling(const struct Clip_TAG *i_pThis);
- void MP4Clip_subtitleArrived();
- #endif // __MP4_H_
- #endif