📄 qt.h
字号:
/*-----------------------------------------------------------------------------\
@ModuleName :: qt.h
@Description :: Header file for Quick Time Wrapper for MJPEG, H263, MPEG-4 bitstream
For info about Quick Time File Format see QTFF reference at
http://developer.apple.com/techpubs/quicktime/qtdevdocs/QTFF/qtff.html
@Copyright :: Copyright 2001- Texas Instruments, Inc.
@History ::
-------------------------------------------------------------------------------
Dec. 26, 2001 Kedar C (kedarc@ti.com) Start
\-----------------------------------------------------------------------------*/
#ifndef __QT_H__
#define __QT_H__
/* include files */
#include <util/util.h>
#define QT_DEBUG 0
/* consts and externs */
/* QT Atom configuration values */
#define MP4_CHUNK_OFFSET 18
#define QT_MAX_SAMPLES ( 64*KB )
#define QT_ESDS_ATOM_MAX_SIZE 64
#define QT_CHUNK_OFFSET 8
#define QT_VIDEO_TRACK_ID 1
#define QT_AUDIO_TRACK_ID 1
#define QT_NEXT_TRACK_ID ( 2 )
#define QT_TIMESCALE 500
#define QT_MEDIA_TIME_START 0
#define QT_MEDIA_RATE_NORMAL 0x10000 /* 1.0 */
#define QT_GRAPHICS_MODE_DITHER_COPY 0x0040
#define QT_OPCOLOR 0x8000
#define QT_DATA_FORMAT QT_MJPEGA_FORMAT
#define QT_MJPEGA_FORMAT ( (Uint32)('m'<<24 ) + ('j'<<16) + ('p'<< 8) + ('a') )
#define QT_H263_FORMAT ( (Uint32)('h'<<24 ) + ('2'<<16) + ('6'<< 8) + ('3') )
#define QT_MP4_FORMAT ( (Uint32)('m'<<24 ) + ('p'<<16) + ('4'<< 8) + ('v') )
#define QT_ULAW_FORMAT ( (Uint32)('u'<<24 ) + ('l'<<16) + ('a'<< 8) + ('w') )
#define QT_TEMPORAL_QUALITY 512
#define QT_SPATIAL_QUALITY 768
#define QT_H_RES 72
#define QT_V_RES 72
#define QT_FRAMES_PER_SAMPLE 1
#define QT_COLOR_DEPTH_24BIT 24
#define QT_SINGLE_FIELD 1
#define QT_FIELD_ORDER_UNKNOWN 0
/* QT Atom tags */
#define QT_MDAT_TAG MAKE_TAG('m', 'd', 'a', 't')
#define QT_MOOV_TAG MAKE_TAG('m', 'o', 'o', 'v')
#define QT_MVHD_TAG MAKE_TAG('m', 'v', 'h', 'd')
#define QT_UDTA_TAG MAKE_TAG('u', 'd', 't', 'a')
#define QT_TRAK_TAG MAKE_TAG('t', 'r', 'a', 'k')
#define QT_TKHD_TAG MAKE_TAG('t', 'k', 'h', 'd')
#define QT_EDTS_TAG MAKE_TAG('e', 'd', 't', 's')
#define QT_HDLR_TAG MAKE_TAG('h', 'd', 'l', 'r')
#define QT_MDIA_TAG MAKE_TAG('m', 'd', 'i', 'a')
#define QT_ELST_TAG MAKE_TAG('e', 'l', 's', 't')
#define QT_MINF_TAG MAKE_TAG('m', 'i', 'n', 'f')
#define QT_VMHD_TAG MAKE_TAG('v', 'm', 'h', 'd')
#define QT_STBL_TAG MAKE_TAG('s', 't', 'b', 'l')
#define QT_STTS_TAG MAKE_TAG('s', 't', 't', 's')
#define QT_STSD_TAG MAKE_TAG('s', 't', 's', 'd')
#define QT_STSZ_TAG MAKE_TAG('s', 't', 's', 'z')
#define QT_STCO_TAG MAKE_TAG('s', 't', 'c', 'o')
/* QT field offsets from start of respective Atoms, used by the QT Parser */
#define QT_TIMESCALE_OFFSET 20
#define QT_DURATION_OFFSET 24
#define QT_WIDTH_OFFSET (21*4)
#define QT_HEIGHT_OFFSET (22*4)
#define QT_ELST_ENTRIES_OFFSET 12
#define QT_GRAPHICS_MODE_OFFSET 12
#define QT_GRAPHICS_OPCOLOR_OFFSET 14
#define QT_COMP_TYPE_OFFSET 12
#define QT_COMP_SUB_TYPE_OFFSET 16
#define QT_SAMPLE_DURATION_OFFSET 20
#define QT_SAMPLE_SIZE_OFFSET 12
#define QT_SAMPLE_COUNT_OFFSET 16
#define QT_SAMPLE_SIZE_TABLE_OFFSET 20
#define QT_CHUNK_OFFSET_TABLE_OFFSET 16
#define QT_DATA_FORMAT_OFFSET 20
#define QT_TEMPORAL_QUALITY_OFFSET 20
#define QT_SPATIAL_QUALITY_OFFSET 24
#define QT_H_RES_OFFSET 32
#define QT_V_RES_OFFSET 36
#define QT_FRAMES_PER_SAMPLE_OFFSET 44
#define QT_COLOR_DEPTH_24BIT_OFFSET 78
#define QT_FIELD_COUNT_OFFSET 90
#define QT_FIELD_ORDER_OFFSET 90
/* MJPEG/JPEG Markers */
#define MJPEG_SOI BYTE_SWAP16(0xFFD8)
#define MJPEG_APP1 BYTE_SWAP16(0xFFE1)
#define MJPEG_TAG ( (Uint32)('m'<<24) + ('j'<<16) + ('p'<<8) + 'g' ) /* 'mjpg' */
#define JPEG_DQT 0xFFDB
#define JPEG_DHT 0xFFC4
#define JPEG_SOF 0xFFC0
#define JPEG_SOS 0xFFDA
/* struct definitions */
/* Byte Stream structure */
typedef struct {
Uint8 *databuf;
int ptr8;
} Bytestream;
typedef struct {
Uint8 IncludeAudio;
Uint32 AudioDataSize;
Uint8 AudioChannels;
Uint32 SamplingRate;
Uint32 ChunkOffset;
} QTAudioParams ;
/* QT Configuration structure */
typedef struct {
Uint32 Videosize;
Uint32 Timescale;
Uint32 Duration;
Uint32 FrameRate;
Uint16 Width;
Uint16 Height;
Uint32 MediaTime;
Uint32 MediaRate;
Uint16 GraphicsMode;
Uint16 Opcolor;
Uint32 DataFormat; /* 'mjpa' */
Uint32 TemporalQuality;
Uint32 SpatialQuality;
Uint16 Hres;
Uint16 Vres;
Uint16 FramePerSample;
Uint16 ColorDepth;
Uint8 FieldCount;
Uint8 FieldOrdering;
Uint32 SampleDuration;
Uint16 KeyFrameInterval;
Uint32 ChunkOffset;
BOOL SsizeConst;
Uint32 Scount; /* sample count */
Uint32 *Ssize; /* sample size array */
/* used for MPEG-4 only */
Uint8 ESDSAtomInfo[QT_ESDS_ATOM_MAX_SIZE];
QTAudioParams audioPrmQT;
} QTParams;
/* MJPEG Format A Header */
typedef struct {
Uint16 APP1;
Uint16 app1Size;
Uint32 reserved;
Uint32 mjpgTag;
Uint32 field;
Uint32 paddedField;
Uint32 nextField;
Uint32 DQT;
Uint32 DHT;
Uint32 SOF;
Uint32 SOS;
Uint32 data;
} MJPEGAHeader;
/* function prototypes */
/* QT routines */
STATUS QTInitParams(QTParams *prmQT, Uint32 videoDataFormat );
STATUS QTMakeMJPEGAHeader(Uint8 *start, Uint32 size, MJPEGAHeader *mjpa );
Uint32 QTMakeMovieAtom(QTParams *prmQT, Uint8 *atomBuff);
void QTMakeVideoTrakAtom(Bytestream *stream, QTParams *prmQT);
void QTMakeAudioTrakAtom(Bytestream *stream, QTParams *prmQT);
void MovieHeaderAtom(Bytestream *stream, Uint32 Time_Scale, Uint32 Duration );
void TrackHeaderAtom(Bytestream *stream, Uint32 Track_ID, Uint32 duration, Uint16 disp_width, Uint16 disp_height);
void TrackEditAtom(Bytestream *stream, Uint32 Track_Duration, Uint32 Media_Time, Uint32 Media_Rate);
void TrackUserDataAtom(Bytestream *stream);
void TrackMediaHeaderAtom(Bytestream *stream, Uint32 Time_scale, Uint32 Duration);
void TrackMediaHeaderReferenceAtom(Bytestream *stream, int comp_type, int comp_subtype, Uint32 comp_flag, Uint32 comp_mask);
void TrackMediaVideoMediaInfoHeaderAtom(Bytestream *stream, Uint16 GraphicsMode, Uint16 Opcolor);
void TrackMediaDataInformationAtom(Bytestream *stream);
void TrackMediaVideoSampleDescriptionAtom(Bytestream *stream,
Uint16 Width, Uint16 Height, Uint32 dataformat,
Uint32 TemporalQuality, Uint32 SpatialQuality, Uint32 Hres,
Uint32 Vres, Uint16 FramePerSample, Uint16 ColorDepth,
Uint8 FieldCount, Uint8 FieldOrdering,
Uint32 chunk_offset, Uint8 *esds_atom_info
);
void TrackMediaTimetoSampleAtom(Bytestream *stream, Uint32 Scount, Uint32 Sduration);
void TrackMediaSampleSizeAtom(Bytestream *stream, int sample_size, Uint32 Scount, Uint32 *Ssize);
void TrackMediaSampletoChunkAtom(Bytestream *stream, Uint32 Scount);
void TrackMediaChunkOffsetAtom(Bytestream *stream, Uint32 Scount, Uint32 Coffset, Uint32 *Ssize);
void TrackMediaSampleSyncAtom( Bytestream *stream, Uint32 frame_count, Uint32 data_format, Uint16 key_frame_interval );
void TrackMediaSoundMediaInfoHeaderAtom(Bytestream *stream);
void TrackMediaSoundSampleDescriptionAtom(Bytestream *stream,
int NumChannels, int sample_size, long sample_rate);
/* utility routines */
void put_bytes(Bytestream *stream, short nbytes, Uint32 code);
Uint32 GetMovieFrameRate( Uint32 videoDataFormat );
Uint16 GetMovieWidth( Uint32 videoDataFormat );
Uint16 GetMovieHeight( Uint32 videoDataFormat );
Uint16 GetMovieKeyFrameInterval(Uint32 videoDataFormat );
#endif /* __QT_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -