view IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h @ 8:c51c0b844461 tip

Ok
author Eugenio Oñate Hospital <eo301@eecs.qmul.ac.uk>
date Tue, 28 Aug 2012 12:20:04 +0100
parents 1636a6250528
children
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 FILE typedef, */
#include <stdio.h>

#define maxtracks 8
#define maxpreset 10
#define maxrules 10

typedef long long u64;
typedef unsigned int u32;
typedef unsigned short u16;

typedef struct nametrack { // Stores the different titles of the tracks
    char title[20];
}nametrack[maxtracks];

typedef struct FileTypeBox 
{
    u32 size;
    u32 type;          // ftyp 
    u32 major_brand;   // brand identifier
    u32 minor_version; // informative integer for the mirror version
    u32 compatible_brands[2]; //list of brands
}FileTypeBox;

typedef struct MoiveBox //extends Box('moov') 
{
    u32 size;
    u32 type;       // moov
    
    struct MovieHeaderBox 
    {
        u32 size;
        u32 type; // mvhd
        u32 version; // version + flag
        u32 creation_time; 
        u32 modification_time;
        u32 timescale; // specifies the time-scale 
        u32 duration;
        u32 rate;  // typically 1.0
        u16 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; 
    
   struct TrackBox 
    {
        u32 size;
        u32 type;
        struct TrackHeaderBox 
        {
            u32 size;
            u32 type;
            u32 version; // version + flag
            u32 creation_time;
            u32 modification_time;
            u32 track_ID;  
            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 MediaBox // extends Box('mdia')
        {
            u32 size;
            u32 type;
            struct MediaHeaderBox // extends FullBox('mdhd', version,0)
            {
                u32 size;
                u32 type;
                u32 version; // version + flag
                u32 creation_time;
                u32 modification_time;
                u32 timescale;
                u32 duration;
                u16 language; // [pad,5x3] = 16 bits and pad = 0
                u16 pre_defined; // =0
            }MediaHeaderBox;
           struct HandlerBox  
            {
                u32 size;
                u32 type;
                u32 version; // version = 0 + flag
                u32 pre_defined; // =0
                u32 handler_type; // = 'soun' for audio track, text or hint
                u32 reserved[3]; // =0
               unsigned char data[5]; // Does not work! only 4 bytes
                
            }HandlerBox;    
             struct MediaInformationBox //extends Box('minf')
            {
                u32 size;
                u32 type;
                // smhd in sound track only!!
               struct SoundMediaHeaderBox 
                {
                    u32 size;
                    u32 type;
                    u32 version;
                    u16 balance; // =0 place mono tracks in stereo. 0 is center
                    u16 reserved; // =0
                }SoundMediaHeaderBox;

               struct DataInformationBox //extends Box('dinf')
                {
                    u32 size;
                    u32 type;
                    struct DataReferenceBox 
                    {
                        u32 size;
                        u32 type;
                        u32 flags;
                        u32 entry_count; // counts the actual entries. 
                        struct DataEntryUrlBox //extends FullBox('url', version=0, flags)
                        {
                            u32 size;
                            u32 type;
                            u32 flags;
                        }DataEntryUrlBox;
                    }DataReferenceBox;
                }DataInformationBox;
                struct SampleTableBox // extends Box('stbl')
                {
                    u32 size;
                    u32 type;
                    struct TimeToSampleBox{
                        u32 size;
                        u32 type;
                        u32 version;
                        u32 entry_count;
                        u32 sample_count[3000];
                        u32 sample_delta[3000];
                    }TimeToSampleBox;
                    struct SampleDescriptionBox // stsd
                    {
                        u32 size;
                        u32 type;
                        u32 version;
                        u32 entry_count; // = 1 number of entries
                    //    unsigned char esds[88];
                        struct AudioSampleEntry{
                            u32 size;
                            u32 type;   //mp4a
                            char reserved[6];
                            u16 data_reference_index; // = 1
                            u32 reserved2[2];
                            u16 channelcount; // = 2
                            u16 samplesize; // = 16
                            u32 reserved3;
                            u32 samplerate; // 44100 << 16
                     //       unsigned char esds[81];
                            struct ESbox{
                                u32 size;
                                u32 type;
                                u32 version;
                                struct ES_Descriptor{
                                    unsigned char tag;
                                    unsigned char length;
                                    u16 ES_ID;
                                    unsigned char mix;
                                    struct DecoderConfigDescriptor{
                                        unsigned char tag;
                                        unsigned char length;
                                        unsigned char objectProfileInd;
                                        u32 mix; 
                                        u32 maxBitRate;
                                        u32 avgBitrate;
                                     /*   struct DecoderSpecificInfo{
                                            unsigned char tag;
                                            unsigned length;
                                           // unsigned char decSpecificInfosize;
                                            unsigned char decSpecificInfoData[2];
                                        }DecoderSpecificInfo;
                                   */ }DecoderConfigDescriptor;
                                    struct SLConfigDescriptor{
                                        unsigned char tag;
                                        unsigned char length;
                                        unsigned char predifined;
                                    }SLConfigDescriptor;
                                  }ES_Descriptor;
                            }ESbox;
                        }AudioSampleEntry;
                    }SampleDescriptionBox;
                    struct SampleSizeBox{
                        u32 size;
                        u32 type;
                        u32 version;
                        u32 sample_size; // =0
                        u32 sample_count;
                        u32 entry_size[9000];
                    }SampleSizeBox;
                    struct SampleToChunk{
                        u32 size;
                        u32 type;
                        u32 version;
                        u32 entry_count;
                        u32 first_chunk;
                        u32 samples_per_chunk;
                        u32 sample_description_index;
                    }SampleToChunk;
                    struct ChunkOffsetBox{
                        u32 size;
                        u32 type;
                        u32 version;
                        u32 entry_count;
                        u32 chunk_offset[maxtracks];
                    }ChunkOffsetBox;
                }SampleTableBox;
            }MediaInformationBox;
        }MediaBox;
    }TrackBox[maxtracks]; // max 10 tracks
    struct PresetContainerBox // extends Box('prco')
    {
        u32 size;
        u32 type;
        unsigned char num_preset;
        unsigned char default_preset_ID; 
        struct PresetBox //extends FullBox('prst',version=0,flags)
        {
            u32 size;
            u32 type;
            u32 flags;
            unsigned char preset_ID;
            unsigned char num_preset_elements;
            struct presElemId{
                u32 preset_element_ID;
            }presElemId[maxtracks];
            unsigned char preset_type;
            unsigned char preset_global_volume;
            //IF preset_type == 1
            struct presVolumElem{
                unsigned char preset_volume_element;
            }presVolumElem[maxtracks];
           char preset_name[14];
        }PresetBox[maxpreset];
    }PresetContainerBox;
    
    struct RulesContainer{
        u32 size;
        u32 type;
        u16 num_selection_rules;
        u16 num_mixing_rules;
        struct SelectionRules{
            u32 size;
            u32 type;
            u32 version;
            u16 selection_rule_ID;
            unsigned char selection_rule_type;
            u32 element_ID;
            char rule_description[14];
        }SelectionRules;
        struct MixingRules{
            u32 size;
            u32 type;
            u32 version;
            u16 mixing_rule_ID;
            unsigned char mixing_type;
            u32 element_ID;
            u32 key_elem_ID;
            char mix_description[17];
        }MixingRules;
    }RulesContainer;
}MovieBox; 

typedef struct MediaDataBox // extends Box('mdat')
{
    u32 size;
    u32 type;
    unsigned char data;  
}MediaDataBox;

#endif