📄 libmp4.h
字号:
#define MP4_TEXT_DISPLAY_FLAG_COLOR_HILITE (1<<16)#define MP4_TEXT_DISPLAY_FLAG_WRITE_VERTICALLY (1<<17)typedef struct{ uint32_t i_reserved1; uint16_t i_reserved2; uint16_t i_data_reference_index; uint32_t i_display_flags; // TextDescription and Tx3gDescription int8_t i_justification_horizontal; // left(0), centered(1), right(-1) int8_t i_justification_vertical; // top(0), centered(1), bottom(-1) uint16_t i_background_color[4]; uint16_t i_text_box_top; uint16_t i_text_box_left; uint16_t i_text_box_bottom; uint16_t i_text_box_right; // TODO to complete} MP4_Box_data_sample_text_t;typedef struct MP4_Box_data_sample_hint_s{ uint8_t i_reserved1[6]; uint16_t i_data_reference_index; uint8_t *p_data;} MP4_Box_data_sample_hint_t;typedef struct MP4_Box_data_moviehintinformation_rtp_s{ uint32_t i_description_format; unsigned char *psz_text;} MP4_Box_data_moviehintinformation_rtp_t;typedef struct MP4_Box_data_stsd_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; /* it contains SampleEntry handled as if it was Box */} MP4_Box_data_stsd_t;typedef struct MP4_Box_data_stsz_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_sample_size; uint32_t i_sample_count; uint32_t *i_entry_size; /* array , empty if i_sample_size != 0 */} MP4_Box_data_stsz_t;typedef struct MP4_Box_data_stz2_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_sample_size; /* 24 bits */ uint8_t i_field_size; uint32_t i_sample_count; uint32_t *i_entry_size; /* array: unsigned int(i_field_size) entry_size */} MP4_Box_data_stz2_t;typedef struct MP4_Box_data_stsc_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; uint32_t *i_first_chunk; /* theses are arrays */ uint32_t *i_samples_per_chunk; uint32_t *i_sample_description_index;} MP4_Box_data_stsc_t;typedef struct MP4_Box_data_co64_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; uint64_t *i_chunk_offset;} MP4_Box_data_co64_t;typedef struct MP4_Box_data_stss_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; uint32_t *i_sample_number;} MP4_Box_data_stss_t;typedef struct MP4_Box_data_stsh_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; uint32_t *i_shadowed_sample_number; uint32_t *i_sync_sample_number;} MP4_Box_data_stsh_t;typedef struct MP4_Box_data_stdp_s{ uint8_t i_version; uint32_t i_flags; uint16_t *i_priority;} MP4_Box_data_stdp_t;typedef struct MP4_Box_data_padb_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_sample_count; uint16_t *i_reserved1; /* 1bit */ uint16_t *i_pad2; /* 3bits */ uint16_t *i_reserved2; /* 1bit */ uint16_t *i_pad1; /* 3bits */} MP4_Box_data_padb_t;typedef struct MP4_Box_data_elst_s{ uint8_t i_version; uint32_t i_flags; uint32_t i_entry_count; uint64_t *i_segment_duration; int64_t *i_media_time; uint16_t *i_media_rate_integer; uint16_t *i_media_rate_fraction;} MP4_Box_data_elst_t;typedef struct MP4_Box_data_cprt_s{ uint8_t i_version; uint32_t i_flags; /* 1 pad bit */ unsigned char i_language[3]; unsigned char *psz_notice;} MP4_Box_data_cprt_t;/* DecoderConfigDescriptor */typedef struct MP4_descriptor_decoder_config_s{ uint8_t i_objectTypeIndication; uint8_t i_streamType; int b_upStream; int i_buffer_sizeDB; int i_max_bitrate; int i_avg_bitrate; int i_decoder_specific_info_len; uint8_t *p_decoder_specific_info; /* some other stuff */} MP4_descriptor_decoder_config_t;typedef struct MP4_descriptor_SL_config_s{ int i_dummy; /* ANSI C forbids empty structures */} MP4_descriptor_SL_config_t;typedef struct MP4_descriptor_ES_s{ uint16_t i_ES_ID; int b_stream_dependence; int b_url; int b_OCRstream; int i_stream_priority; int i_depend_on_ES_ID; /* if b_stream_dependence set */ unsigned char *psz_URL; uint16_t i_OCR_ES_ID; /* if b_OCRstream */ MP4_descriptor_decoder_config_t *p_decConfigDescr; MP4_descriptor_SL_config_t *p_slConfigDescr; /* some other stuff ... */} MP4_descriptor_ES_t;/* ES descriptor */typedef struct MP4_Box_data_esds_s{ uint8_t i_version; uint32_t i_flags; MP4_descriptor_ES_t es_descriptor;} MP4_Box_data_esds_t;typedef struct MP4_Box_data_dcom_s{ uint32_t i_algorithm; /* fourcc */} MP4_Box_data_dcom_t;typedef struct MP4_Box_data_cmvd_s{ uint32_t i_uncompressed_size; uint32_t i_compressed_size; int b_compressed; /* Set to 1 if compressed data, 0 if uncompressed */ uint8_t *p_data;} MP4_Box_data_cmvd_t;typedef struct MP4_Box_data_cmov_s{ struct MP4_Box_s *p_moov; /* uncompressed moov */} MP4_Box_data_cmov_t;typedef struct{ uint8_t i_version; uint32_t i_flags; uint32_t i_ref_type; char *psz_ref;} MP4_Box_data_rdrf_t;typedef struct{ uint8_t i_version; uint32_t i_flags; uint32_t i_rate;} MP4_Box_data_rmdr_t;typedef struct{ uint8_t i_version; uint32_t i_flags; uint32_t i_gestaltType; uint32_t i_val1; uint32_t i_val2; uint16_t i_checkType; /* 0: val1 is version min 1: gestalt value & val2 == val1 */} MP4_Box_data_rmvc_t;typedef struct{ uint8_t i_version; uint32_t i_flags;} MP4_Box_data_rmcd_t;typedef struct{ uint32_t i_quality;} MP4_Box_data_rmqu_t;typedef struct{ char *psz_text;} MP4_Box_data_0xa9xxx_t;typedef struct{ uint8_t i_version; uint8_t i_profile; uint8_t i_profile_compatibility; uint8_t i_level; uint8_t i_reserved1; /* 6 bits */ uint8_t i_length_size; uint8_t i_reserved2; /* 3 bits */ uint8_t i_sps; uint16_t *i_sps_length; uint8_t **sps; uint8_t i_pps; uint16_t *i_pps_length; uint8_t **pps; /* XXX: Hack raw avcC atom payload */ int i_avcC; uint8_t *p_avcC;} MP4_Box_data_avcC_t;/*typedef struct MP4_Box_data__s{ uint8_t i_version; uint32_t i_flags;} MP4_Box_data__t;*/typedef union MP4_Box_data_s{ MP4_Box_data_ftyp_t *p_ftyp; MP4_Box_data_mvhd_t *p_mvhd; MP4_Box_data_tkhd_t *p_tkhd; MP4_Box_data_mdhd_t *p_mdhd; MP4_Box_data_hdlr_t *p_hdlr; MP4_Box_data_vmhd_t *p_vmhd; MP4_Box_data_smhd_t *p_smhd; MP4_Box_data_hmhd_t *p_hmhd; MP4_Box_data_url_t *p_url; MP4_Box_data_urn_t *p_urn; MP4_Box_data_dref_t *p_dref; MP4_Box_data_stts_t *p_stts; MP4_Box_data_ctts_t *p_ctts; MP4_Box_data_stsd_t *p_stsd; MP4_Box_data_sample_vide_t *p_sample_vide; MP4_Box_data_sample_soun_t *p_sample_soun; MP4_Box_data_sample_text_t *p_sample_text; MP4_Box_data_sample_hint_t *p_sample_hint; MP4_Box_data_esds_t *p_esds; MP4_Box_data_avcC_t *p_avcC; MP4_Box_data_stsz_t *p_stsz; MP4_Box_data_stz2_t *p_stz2; MP4_Box_data_stsc_t *p_stsc; MP4_Box_data_co64_t *p_co64; MP4_Box_data_stss_t *p_stss; MP4_Box_data_stsh_t *p_stsh; MP4_Box_data_stdp_t *p_stdp; MP4_Box_data_padb_t *p_padb; MP4_Box_data_elst_t *p_elst; MP4_Box_data_cprt_t *p_cprt; MP4_Box_data_dcom_t *p_dcom; MP4_Box_data_cmvd_t *p_cmvd; MP4_Box_data_cmov_t *p_cmov; MP4_Box_data_moviehintinformation_rtp_t p_moviehintinformation_rtp; MP4_Box_data_rdrf_t *p_rdrf; MP4_Box_data_rmdr_t *p_rmdr; MP4_Box_data_rmqu_t *p_rmqu; MP4_Box_data_rmvc_t *p_rmvc; MP4_Box_data_0xa9xxx_t *p_0xa9xxx; void *p_data; /* for unknow type */} MP4_Box_data_t;/* the most basic structure */typedef struct MP4_Box_s{ off_t i_pos; /* absolute position */ uint32_t i_type; uint32_t i_shortsize; UUID_t i_uuid; /* Set if i_type == "uuid" */ uint64_t i_size; /* always set so use it */ MP4_Box_data_t data; /* union of pointers on extended data depending on i_type (or i_usertype) */ struct MP4_Box_s *p_father; /* pointer on the father Box */ struct MP4_Box_s *p_first; /* pointer on the first child Box */ struct MP4_Box_s *p_last; struct MP4_Box_s *p_next; /* pointer on the next boxes at the same level */} MP4_Box_t;/***************************************************************************** * MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory ***************************************************************************** * The first box is a virtual box "root" and is the father for all first * level boxes *****************************************************************************/MP4_Box_t *MP4_BoxGetRoot( stream_t * );/***************************************************************************** * MP4_FreeBox : free memory allocated after read with MP4_ReadBox * or MP4_BoxGetRoot, this means also children boxes * XXX : all children have to be allocated by a malloc !! and * p_box is freed *****************************************************************************/void MP4_BoxFree( stream_t *, MP4_Box_t *p_box );/***************************************************************************** * MP4_DumpBoxStructure: print the structure of the p_box ***************************************************************************** * Usefull while debugging *****************************************************************************/void MP4_BoxDumpStructure( stream_t *p_input, MP4_Box_t *p_box );/***************************************************************************** * MP4_BoxGet: find a box given a path relative to p_box ***************************************************************************** * Path Format: . .. / as usual * [number] to specifie box number ex: trak[12] * * ex: /moov/trak[12] * ../mdia *****************************************************************************/MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, char *psz_fmt, ... );/***************************************************************************** * MP4_BoxCount: find number of box given a path relative to p_box ***************************************************************************** * Path Format: . .. / as usual * [number] to specifie box number ex: trak[12] * * ex: /moov/trak * ../mdia *****************************************************************************/int MP4_BoxCount( MP4_Box_t *p_box, char *psz_fmt, ... );int MP4_ReadBoxCommon( stream_t *p_stream, MP4_Box_t *p_box );int MP4_ReadBox_sample_vide( stream_t *p_stream, MP4_Box_t *p_box );void MP4_FreeBox_sample_vide( MP4_Box_t *p_box );#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -