Mercurial > hg > enc-imaf
view IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h @ 0:138a3cea9792
Different files related to my project, including the encoder (I made it) and decoder. Also I added the mp4atoms as an example.
MP4atoms belong to the IMAF player library.
author | Eugenio Oñate Hospital <eo301@eecs.qmul.ac.uk> |
---|---|
date | Wed, 04 Jul 2012 22:16:23 +0100 |
parents | |
children | 19490164927c |
line wrap: on
line source
// // IM_AF Encoder.h // IM_AM Encoder // // Created by eugenio oƱate hospital on 14/06/12. // Copyright (c) 2012 SAE. All rights reserved. // #ifndef IM_AM_Encoder_IM_AF_Encoder_h #define IM_AM_Encoder_IM_AF_Encoder_h /* for va_list typedef */ #include <stdarg.h> /* for FILE typedef, */ #include <stdio.h> typedef long long u64; typedef long long s64; typedef unsigned int u32; typedef unsigned short u16; #define maxtracks 10 typedef struct namestrack{ char title[20]; }namestrack[maxtracks]; typedef struct FileTypeBox // extends Box('ftyp') { u32 major_brand; // brand identifier u32 minor_version; // informative integer for the mirror version u32 compatible_brands[5]; //list, to the end of the box, of brands }FileTypeBox; typedef struct MoiveBox //extends Box('moov') { struct MovieHeaderBox // extends FullBox('mvhs', version, 0) { u32 creation_time; u32 modification_time; u32 timescale; // specifies the time-scale for the entire presentation (units per second) u32 duration; u32 rate; // typically 1.0 u32 volume; // typically full volume u16 reserved; // =0 u32 reserved2 [2]; //=0 u32 matrix [9]; // information matrix for video (u,v,w) u32 pre_defined[6]; // =0 u32 next_track_ID; //non zero value for the next track ID }MovieHeaderBox; //max 10 tracks struct TrackBox // extends Box('trak') { struct TrackHeaderBox // extends FullBox('tkhd', version, flags) { u32 creation_time; u32 modification_time; u32 track_ID; // identifies this track and are never re -used and cannot be zero u32 reserved; // =0 u32 duration; u32 reserved2[2]; // =0 u16 layer; // =0 // for video u16 alternate_group; // =0 u16 volume; // full volume is 1 = 0x0100 u16 reserved3;// =0 u32 matrix[9]; // for video u32 width; // video u32 height; // video }TrackHeaderBox; struct TrackReferenceBox // extends Box('tref') { u32 reference_type; //shall be set to one of the following values: hint, cdsc, hind... u32 track_ID; // provides a reference from the container track to another track }TrackReferenceBox; struct EditListBox //extends FullBox('elst',version,0) { u32 segment_duration; u32 media_time; u16 media_rate_integer; u16 media_rate_fraction; }EditListBox; struct MediaBox // extends Box('mdia') { struct MediaHeaderBox // extends FullBox('mdhd', version,0) { u32 creation_time; u32 modification_time; u32 timescale; u32 duration; u16 language[3]; // [pad,5x3] = 16 bits and pad = 0 u16 pre_defined; // =0 }MediaHeaderBox; struct HandlerBox // extends FullBox('hdlr', version =0, 0) { u32 pre_defined; // =0 u32 handler_type; // = 'soun' for audio track, text or hint u32 reserved[3]; // =0 char name[20]; // string in UTF-8 characters which gives a human-readable name for track }HandlerBox; struct MediaInformationBox //extends Box('minf') { // smhd in sound track only!! struct SoundMediaHeaderBox // extends FullBox('smhd', version =0, 0) { u16 balance; // =0 place mono tracks in stereo. 0 is center u16 reserved; // =0 }SoundMediaHeaderBox; // hmhd in hint track only!! struct HintMediaHeaderBox //extends FullBox('hmhd', version =0, 0) { u16 maxPDUsize; //size of largest PDU in this (hint) stream u16 avgPDUsize; // average size of a PDU over the entire presentation u32 maxbitrate; //max rate in bits/sec over any window of one second u32 avgbitrate; // rate in bits/sec over entire presentation u32 reserved; // =0 }HintMediaHeaderBox; //struct NullMediaHeaderBox // extends FullBox ('nmhd', version=0, flags) //{}NullMediaHeaderBox; struct DataInformationBox //extends Box('dinf') { struct DataEntryUrlBox //extends FullBox('url', version=0, flags) { u32 flags; char *location; // UTF8 char }DataEntryUrlBox; struct DataEntryUrnBox // extends FullBox('urn', version=0,flag) { char *name; char *location; }DataEntryUrnBox; //struct DataReferenceBox // extends FullBox('dref',version=0,flag) //{ // u32 entry_count; // counts the actual entries. See bucle in page 44. //}DataReferenceBox; }DataInformationBox; struct SampleTableBox // extends Box('stbl') { struct SampleEntry { u32 format; char reserved[6]; //=0 u16 data_reference_index; // index of data reference to use to retrieve data // associated with samples that use this sample descrip. // Data ref are stored in Data Ref Box }SampleEntry; struct HintSampleEntry // extends SampleEntry(protocol) { char data; }HintSampleEntry; struct BitRateBox // extends Box('btrt') { u32 bufferSizeDB; // size of the decoding buffer u32 maxBitrate; u32 avgBitrate; }BitRateBox; struct MetaDataSampleEntry{}MetaDataSampleEntry; struct XMLMetaDataSampleEntry // extends MetaDataSampleEntry ('metx') { char *namespace; // string of the schema for the timed XML metadata. Identify // the type of metadata. }XMLMetaDataSampleEntry; struct TextMetaDataSampleEntry // extends MetaDataSampleEntry('mett') { char *mime_format; }TextMetaDataSampleEntry; struct URIBox // extends FullBox('uri',version=0,0) { char *theURI; }URIBox; struct URIInitBox { char *uri_initialization_data; }URIInitBox; struct URIMetaSampleEntry { struct URIBox the_label; }URIMetaSampleEntry; //Audio Sequences struct AudioSampleEntry // extends SampleEntry(codingname) { u32 reserved[2]; // =0 u16 channelcount; // =2 number of channels 1 mono 2 stereo u16 samplesize; // =16 u16 pre_defined; // =0 u16 reserved2; //=0 u32 samplerate; // {default samplerate of media}<<16 = 16.16 }AudioSampleEntry; struct SampleDescriptionBox // unsigned int(32) handler_type { u32 handler_type; u32 entry_count; // number of entries }SampleDescriptionBox; struct TimeToSampleBox // extends FullBox('stts',version =0,0) { u32 entry_count; int i; u32 sample_count; u32 sample_delta; }TimeToSampleBox; struct SampleToChunkBox // extends FullBox('stsc',version = 0,0) { //chunk -> contiguous set of samples for one track u32 entry_count; u32 first_chunk; // index of the first chunk in this run of chunks that share the // same samples-per-chunk and sample-descriprion-index. // The index of the first chunk in a track = 1. u32 samples_per_chunk; // number of samples in each o these chunks. u32 sample_description_index; // index of the sample entry that describes the samples // in this chunk. }SampleToChunkBox; struct SampleSizeBox // extends FullBox('stsz',version=0,0) { u32 samples_size; //default samples size. u32 sample_count; // gives the number of samples in the track. //Table to store the samples size table if samples have different sizes. u32 entry_size; }SampleSizeBox; struct CompactSampleSizeBox // extends FullBox('stz2',version=0,0) { u32 field_size; // 24 bits = 0 + 8 bits = field_size // int(field_size) 4,8 or 16 if 4 is used then 1 byte two values u32 sample_count; int entry_size; }CompactSampleSizeBox; struct ChunkOffsetBox // extends FullBox('stco',version=0,0) { u32 entry_count; u32 chunk_offset; // gives the offset of the start of a chunk into its containing // media file }ChunkOffsetBox; struct ChunkLargeOffsetBox // extends('co64',version=0,0) { u32 entry_count; u64 chunk_offset; }ChunkLargeOffsetBox; }SampleTableBox; }MediaInformationBox; }MediaBox; }TrackBox[maxtracks]; // max 10 tracks struct GroupContainerBox // extends Box('grco') { u16 num_groups; // number the groups contained in the Group Container Box struct GroupBox //extended FullBox('grup', version=0,flags) { int flags; //display disable & edit disable. See page 9 ISO23000-12 u32 group_ID; //uniquely identifies a group u16 num_elements; //num elementes involved in the group u32 element_ID[10]; //size [num_elements] char group_activation_mode; //flag that defines the way the elementes of the group are activated. u16 group_activation_elements_number; // activate only if group_activation_mode == 2. Default=0 u16 group_reference_volume; // reference group volume char group_name[30]; // string UTF-8 char group_description[100]; // string }GroupBox[10]; }GroupContainerBox; struct PresetContainerBox // extends Box('prco') { char num_preset; char default_preset_ID; // indicates preset ID activated at initial conditionwithout //user interaction. Its default value takes the smallest preset_ID. struct PresetBox //extends FullBox('prst',version=0,flags) { int flags; char preset_ID; char num_preset_elements; u32 preset_element_ID[10]; //size [num_preset_elements] char preset_type; u16 preset_global_volume; //IF preset_type == 1 u16 preset_volume_element[10]; // insdie IF char num_input_channel[10];// size [num_preset_elements] //IF preset_type == 2 u16 num_updates; u16 update_sample_number; // indicates the sample number when the preset_volume is update //IF preset_type == 3 char output_channel_type; char preset_name[30]; }PresetBox[10]; }PresetContainerBox; // HERE it would be the RULES! }MovieBox; typedef struct MediaDataBox // extends Box('mdat') { u32 data; // +/- 16Mbytes }MediaDataBox[10]; typedef struct FreeSpaceBox // extends Box(free_type) { //may be free or skip u32 data; }FreeSpaceBox; typedef struct MetaBox // extends FullBox('meta',version=0,0) { struct HandlerBox theHandler; //The structure of the metabox is declare by the Handler. struct DataEntryUrlBox dinfo; struct ItemLocationBox // extends FullBox('iloc',version,0) { u16 Size; u16 item_count; //counts the number of resources in the following array u16 item_ID; u16 c_method; //reserved(12)=0 + contruction_method(4) only if version == 1 u16 data_reference_index; int base_offset; // size depends int(8*base_offset_size). // base value for offset calculations. u16 extent_count; // Count number of extents into which the resources is fragmented. int extent_index; // size index_size*8, only if version == 1 && indez_size > 0 int extent_offset; // size offset_size*8 int extent_length; // size length_size*8 }ItemLocationBox; // struct ItemInfoExtension. I dont use it struct XMLBox // extends('xml', version=0,0) { char *xml; // string }XMLBox; struct BinaryXMLBox // extends('bxml', version=0,0) { char *data; //to end of box }BinaryXMLBox; struct PrimaryItemBox { u16 Item_ID; //ID of primary item }PrimaryItemBox; }MetaBox; #endif