changeset 2:1636a6250528

Final version
author Eugenio Oñate Hospital <eo301@eecs.qmul.ac.uk>
date Sun, 26 Aug 2012 13:39:26 +0100
parents 19490164927c
children f229b0971899
files .DS_Store Examples work!/example_01.ima Examples work!/example_02.ima IM AF Player - Debug/IM_AF_PlayerUI.exe IM AF Player - Debug/IM_AF_PlayerUI.ilk IM AF Player - Debug/IM_AF_PlayerUI.pdb IM AF Player - Debug/example_01.ima IM AF Player - Debug/example_02.ima IM AF Player - Debug/iKlaxRuleAnalyzer.dll IM AF Player - Debug/saoc2mps.exe IM_AF Decoder/.DS_Store IM_AF Decoder/IM_AF_Decoder.c IM_AF Decoder/IM_AF_Decoder.h IM_AF Decoder/IM_AF_Decoder.vcproj IM_AF Decoder/vssver2.scc IM_AF Encoder/.DS_Store IM_AF Encoder/Bass.wav IM_AF Encoder/Drumbox.wav IM_AF Encoder/IM_AM Encoder.xcodeproj/project.xcworkspace/xcuserdata/eugin.xcuserdatad/UserInterfaceState.xcuserstate IM_AF Encoder/IM_AM Encoder/Example_Acoustic.ima IM_AF Encoder/IM_AM Encoder/Example_Electro.ima IM_AF Encoder/IM_AM Encoder/Example_Rock.ima IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h IM_AF Encoder/IM_AM Encoder/example1.ima IM_AF Encoder/IM_AM Encoder/main.c IM_AF Encoder/IM_AM Encoder/string.g.h IM_AF Encoder/string.h IM_AF Report/.DS_Store IM_AF Report/Content_v5.docx IM_AF Report/DestinationForm2012.doc IM_AF Report/IMAF presentationv2.pptx ISOFileFormat99SanJose.pdf IST_37_10_0233IMPlayer.pdf mp4Atoms code/.DS_Store mp4Atoms code/MP4Atoms.c mp4Atoms code/MP4Atoms.h
diffstat 36 files changed, 326 insertions(+), 3849 deletions(-) [+]
line wrap: on
line diff
Binary file .DS_Store has changed
Binary file Examples work!/example_01.ima has changed
Binary file Examples work!/example_02.ima has changed
Binary file IM AF Player - Debug/IM_AF_PlayerUI.exe has changed
Binary file IM AF Player - Debug/IM_AF_PlayerUI.ilk has changed
Binary file IM AF Player - Debug/IM_AF_PlayerUI.pdb has changed
Binary file IM AF Player - Debug/example_01.ima has changed
Binary file IM AF Player - Debug/example_02.ima has changed
Binary file IM AF Player - Debug/iKlaxRuleAnalyzer.dll has changed
Binary file IM AF Player - Debug/saoc2mps.exe has changed
Binary file IM_AF Decoder/.DS_Store has changed
--- a/IM_AF Decoder/IM_AF_Decoder.c	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,718 +0,0 @@
-#include "MP4Movies.h"
-#include "MP4LinkedList.h"
-#include "MP4InputStream.h"
-#include "IM_AF_Decoder.h"
-
-#ifndef BAILWITHERROR
-#define BAILWITHERROR(v) \
-	{ \
-	err = (v); \
-	goto bail; \
-	}
-#endif
-
-typedef struct IMAFDecoder
-{
-	u8 *InputMafFilename;
-	FILE *InputFp;
-	u32 TrackCount;
-//	u32 CompletedTrackCount;
-	u32 HasTimedTextTrack;
-
-	MP4Movie moov;
-	MP4Track trak;
-	MP4Media media;
-	u32 MovieTimescale;
-	u32 MovieDuration;
-
-	// Multi audio track
-	MP4LinkedList TrackReaderList;	// for all Track
-	MP4LinkedList TrackSampleList;	// for all Track Sample
-
-	MP4TrackReader TimedTextTrackReader;
-	MP4Handle TimedTextSampleH;
-	MP4Handle TextH;
-	u32 TimedTextTrackIndex;
-	TextSampleStyleParam *TextParam;
-
-	unsigned int HasSaocTrack;
-}IMAFDecoder;
-
-void InitTextSampleStyleParam(TextSampleStyleParam *TextParam)
-{
-	if(TextParam)
-	{
-		if(TextParam->styl_text_styles)
-			free(TextParam->styl_text_styles);
-		if(TextParam->krok_highlight_end_time)
-			free(TextParam->krok_highlight_end_time);
-		if(TextParam->krok_startcharoffset)
-			free(TextParam->krok_startcharoffset);
-		if(TextParam->krok_endcharoffset)
-			free(TextParam->krok_endcharoffset);
-		if(TextParam->font)
-			free(TextParam->font);
-		memset(TextParam, 0, sizeof(TextSampleStyleParam));
-	}
-}
-	
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_Create(IMAF_DecoderH *IMafDecoder, IMAF_Decoder_Param *param)
-{
-	IMAFDecoder *decoder = NULL;
-	MP4Err err;
-	u32 i;
-	u32 sample_desc_type;
-	MP4TrackReader reader;
-	MP4Handle sampleH;
-	u32 minorVersion;
-
-	decoder = calloc(1, sizeof(IMAFDecoder));
-
-	if(param == NULL || param->InputMafFilename == NULL)
-	{
-		err = MP4BadParamErr;
-		goto bail;
-	}
-	else
-		decoder->InputMafFilename = _strdup(param->InputMafFilename);
-
-	err = MP4OpenMovieFile( &decoder->moov, decoder->InputMafFilename, MP4OpenMovieInPlace ); if (err) goto bail;
-	err = MP4GetMovieTrackCount( decoder->moov, &decoder->TrackCount); if(err) goto bail;
-
-	//Timed Text
-	for(i=0; i<decoder->TrackCount; i++)
-	{
-		err = MP4GetMovieIndTrack( decoder->moov, i+1, &decoder->trak ); if (err) goto bail;
-		err = MP4GetTrackMedia( decoder->trak, &decoder->media ); if (err) goto bail;
-		err = MP4GetMediaSampleDescriptionType(decoder->media, &sample_desc_type); if(err) goto bail;
-		if(sample_desc_type == 'tx3g')
-		{
-			decoder->HasTimedTextTrack = 1;
-			decoder->TimedTextTrackIndex = i;
-			break;
-		}
-	}
-
-	param->HasTimedTextTrack = decoder->HasTimedTextTrack;
-	param->NumberOfAudioTrack = decoder->TrackCount - decoder->HasTimedTextTrack;
-
-	err = MP4GetMovieTimeScale(decoder->moov, &decoder->MovieTimescale); if(err) goto bail;
-	param->MovieTimescale = decoder->MovieTimescale;
-
-	err = MP4GetMovieDuration(decoder->moov, (u64*)&decoder->MovieDuration); if(err) goto bail;
-	param->MovieDuration = decoder->MovieDuration;
-
-	// Create TrackReader for all Track
-	err = MP4MakeLinkedList( &decoder->TrackReaderList); if(err) goto bail;
-	err = MP4MakeLinkedList( &decoder->TrackSampleList); if(err) goto bail;
-	for(i=0; i<decoder->TrackCount; i++)
-	{
-		err = MP4GetMovieIndTrack( decoder->moov, i+1, &decoder->trak ); if (err) goto bail;
-		if(decoder->HasTimedTextTrack && decoder->TimedTextTrackIndex == i)
-		{
-			err = MP4CreateTrackReader( decoder->trak, &reader ); if (err) goto bail;
-			decoder->TimedTextTrackReader = reader;
-		}
-		else
-		{
-			err = MP4CreateTrackReader( decoder->trak, &reader ); if (err) goto bail;
-			err = MP4AddListEntry( reader, decoder->TrackReaderList); if (err) goto bail;
-
-			err = MP4NewHandle(0, &sampleH); if(err) goto bail;
-			err = MP4AddListEntry( sampleH, decoder->TrackSampleList); if (err) goto bail;
-		}
-	}
-
-	err = MP4NewHandle(0, &decoder->TimedTextSampleH); if(err) goto bail;
-	err = MP4NewHandle(0, &decoder->TextH); if(err) goto bail;
-
-	decoder->TextParam = calloc(1, sizeof(TextSampleStyleParam));
-
-	 err = ISOGetMovieBrand(decoder->moov, &param->MajorBrand, &minorVersion); if(err) goto bail;
-	 err = ISOGetNbCompatableBrands(decoder->moov, &param->NumberOfCompatibleBrands); if(err) goto bail;
-	 if(param->NumberOfCompatibleBrands)
-	 {
-		 param->CompatibleBrands = calloc(param->NumberOfCompatibleBrands, sizeof(u32));
-		err = ISOGetCompatableBrands(decoder->moov, param->CompatibleBrands); if(err) goto bail;
-	 }
-	 else
-		 param->CompatibleBrands = NULL;
-
-
-	*IMafDecoder = decoder;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetAudioTrackInfos(IMAF_DecoderH IMafDecoder, unsigned int *AudioTrackObjectTypeArray
-														  ,unsigned int *AudioTrackIdArray, IMAF_AudioParam *AudioParamArray)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	u32 i;
-	u32 outObjectType, sample_desc_type;
-	u32 hasTimedText = 0;
-	u32 trackID;
-	unsigned int nBitsPerSample;
-	unsigned int nChannels;
-	unsigned int nSamplingFrequency;
-	for(i=0; i<decoder->TrackCount - decoder->HasTimedTextTrack; i++)
-	{
-		err = MP4GetMovieIndTrack( decoder->moov, i+1, &decoder->trak ); if (err) goto bail;
-		err = MP4GetTrackMedia( decoder->trak, &decoder->media ); if (err) goto bail;
-		err = MP4GetMediaSampleDescriptionType(decoder->media, &sample_desc_type); if(err) goto bail;
-		if(sample_desc_type == 'mp4a')
-		{
-			err = MP4GetTrackID(decoder->trak, &trackID); if(err) goto bail;
-			AudioTrackIdArray[i - hasTimedText] = trackID;
-			err = MP4GetMediaDecoderType( decoder->media, 1, &outObjectType, NULL, NULL, NULL ); if(err) goto bail;
-			if(outObjectType == AUDIO_OBJECT_TYPE_INDICATION_MP3 || outObjectType == AUDIO_OBJECT_TYPE_INDICATION_AAC
-				|| outObjectType == AUDIO_OBJECT_TYPE_INDICATION_SAOC|| outObjectType == AUDIO_OBJECT_TYPE_INDICATION_PCM)
-			{
-				AudioTrackObjectTypeArray[i - hasTimedText] = outObjectType;
-				if(outObjectType = AUDIO_OBJECT_TYPE_INDICATION_SAOC)
-					decoder->HasSaocTrack = 1;
-			}
-			else
-				BAILWITHERROR(MP4BadDataErr)
-
-			err = MP4GetSampleRateChannelBitsPerSample(decoder->media, &nSamplingFrequency, &nChannels, &nBitsPerSample); if(err) goto bail;
-			AudioParamArray[i].nSamplingFrequency = nSamplingFrequency;
-			AudioParamArray[i].nChannels = nChannels;
-			AudioParamArray[i].nBitsPerSample = nBitsPerSample;
-		}
-		else
-		{
-			hasTimedText = 1;
-		}
-	}
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetGroupContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *GroupCount)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	err = MP4GetGroupContainerInfo(decoder->moov, GroupCount); if(err) goto bail;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetGroupByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_Group *grup)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	unsigned int *element_ID;
-	char *group_name;
-	char *group_description;
-
-	err = MP4GetGroupByIndex(decoder->moov, i, 
-		&grup->group_ID,
-		&grup->num_elements,
-		&element_ID,
-		&grup->group_activation_mode,
-		&grup->group_activation_elements_number,
-		&grup->group_reference_volume,
-		&group_name,
-		&group_description); if(err) goto bail;
-
-	grup->element_ID =(u32*) calloc( grup->num_elements, sizeof(u32) );
-	memcpy(grup->element_ID, element_ID, sizeof(u32)*grup->num_elements);
-	if(group_name)
-		grup->group_name = _strdup(group_name);
-	else
-		grup->group_name = NULL;
-	if(group_description)
-		grup->group_description = _strdup(group_description);
-	else
-		grup->group_description = NULL;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetPresetContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *num_preset, unsigned int *default_preset_ID)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	err = MP4GetPresetContainerInfo(decoder->moov, num_preset, default_preset_ID); if(err) goto bail;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetPresetByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_Preset *prst)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	u32 *preset_element_ID;
-	u32 *preset_volume_element;
-	u32 *num_input_channel;
-	u32 *updated_sample_number;
-	char *preset_name;
-	u32 ii;
-	u32 element_count;
-
-	err = MP4GetPresetByIndex(decoder->moov, i,
-						&prst->preset_ID,
-						&prst->num_preset_elements,
-						&preset_element_ID,	
-						&prst->preset_type,           
-						&prst->preset_global_volume,
-						&preset_volume_element,
-						&num_input_channel ,
-						&prst->output_channel_type ,
-						&prst->num_output_channel ,
-						&prst->num_updates ,
-						&updated_sample_number,
-						&preset_name); if(err) goto bail;
-
-	prst->preset_element_ID =(u32*) calloc( prst->num_preset_elements, sizeof(u32) );
-	memcpy(prst->preset_element_ID, preset_element_ID, sizeof(u32)*prst->num_preset_elements);
-	if(prst->preset_type == 0)
-	{
-		element_count = prst->num_preset_elements;
-		prst->preset_volume_element =(u32*) calloc( element_count, sizeof(u32) );
-		for(ii=0; ii<element_count; ii++)
-			prst->preset_volume_element[ii] = preset_volume_element[ii]*2;
-	}
-	else if(prst->preset_type == 1)
-	{
-		element_count = prst->num_preset_elements*num_input_channel[0]*prst->num_output_channel;
-		prst->preset_volume_element =(u32*) calloc( element_count, sizeof(u32) );
-		for(ii=0; ii<element_count; ii++)
-			prst->preset_volume_element[ii] = preset_volume_element[ii]*2;
-	}
-	else if(prst->preset_type == 2)
-	{
-		element_count = prst->num_preset_elements * prst->num_updates;
-		prst->preset_volume_element =(u32*) calloc( element_count, sizeof(u32) );
-		for(ii=0; ii<element_count; ii++)
-			prst->preset_volume_element[ii] = preset_volume_element[ii]*2;
-	}
-	else if(prst->preset_type == 3)
-	{
-		element_count = prst->num_updates*prst->num_preset_elements*num_input_channel[0]*prst->num_output_channel;
-		prst->preset_volume_element =(u32*) calloc( element_count, sizeof(u32) );
-		for(ii=0; ii<element_count; ii++)
-			prst->preset_volume_element[ii] = preset_volume_element[ii]*2;
-	}
-
-	if(num_input_channel)
-	{
-		prst->num_input_channel =(u32*) calloc( prst->num_preset_elements, sizeof(u32) );
-		memcpy(prst->num_input_channel, num_input_channel, sizeof(u32)*prst->num_preset_elements);
-	}
-	else
-		prst->num_input_channel = NULL;
-	if(updated_sample_number)
-	{
-		prst->updated_sample_number =(u32*) calloc( prst->num_updates, sizeof(u32) );
-		memcpy(prst->updated_sample_number, updated_sample_number, sizeof(u32)*prst->num_updates);
-	}
-	else
-		prst->updated_sample_number = NULL;
-	if(preset_name)
-		prst->preset_name = _strdup(preset_name);
-	else
-		prst->preset_name = NULL;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetRuleContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *num_selection_rules, unsigned int *num_mixing_rules)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	
-	err = MP4GetRuleContainerInfo(decoder->moov, num_selection_rules, num_mixing_rules); if(err) goto bail;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetSelectionRuleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_SelectionRule *rusc)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	char *selection_rule_description;
-	err = MP4GetSelectionRuleByIndex(decoder->moov, i,
-										&rusc->selection_rule_ID,
-										&rusc->selection_rule_type,
-										&rusc->element_ID,
-										&rusc->min_num_elements,
-										&rusc->max_num_elements,
-										&rusc->key_element_ID,
-										&selection_rule_description); if(err) goto bail;
-
-	if(selection_rule_description)
-		rusc->selection_rule_description = _strdup(selection_rule_description);
-	else
-		rusc->selection_rule_description = NULL;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetMixingRuleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_MixingRule *rumx)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	char *mixing_rule_description;
-	err = MP4GetMixingRuleByIndex(decoder->moov, i,
-		&rumx->mixing_rule_ID,
-		&rumx->mixing_rule_type,
-		&rumx->element_ID,
-		&rumx->min_volume,
-		&rumx->max_volume,
-		&rumx->key_element_ID,
-		&mixing_rule_description); if(err) goto bail;
-
-	if(mixing_rule_description)
-		rumx->mixing_rule_description = _strdup(mixing_rule_description);
-	else
-		rumx->mixing_rule_description = NULL;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_SeekSample(IMAF_DecoderH IMafDecoder, unsigned int mediaTime)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	u32 timescale, i;
-	MP4TrackReader reader;
-
-	err = MP4GetMediaTimeScale(decoder->media, &timescale); if(err) goto bail;
-	mediaTime /= 1000;		//in miliseconds
-	mediaTime *= timescale;
-
-	for(i=0; i<decoder->TrackCount - decoder->HasTimedTextTrack; i++)
-	{
-		err = MP4GetListEntry(decoder->TrackReaderList, i, (char**)&reader); if(err) goto bail;
-		err = MP4TrackReaderSeekToSyncSample( reader, mediaTime); if(err) goto bail;
-	}
-	if(decoder->TimedTextTrackReader)
-	{
-		err = MP4TrackReaderSeekToSyncSample( decoder->TimedTextTrackReader, mediaTime); if(err) goto bail;
-	}
-	
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetNextAudioSampleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i,
-																unsigned char **SampleData, unsigned int *SampleDataSize, unsigned int *CurrentTime, unsigned int *sampleNumber)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	MP4TrackReader reader;
-	MP4Handle sampleH;
-	u32 unitSize;
-	u32 sampleFlags;
-	u32 cts;
-	u32 dts;
-	
-	if(i >= decoder->TrackCount - decoder->HasTimedTextTrack)
-		BAILWITHERROR(MP4BadParamErr)
-	err = MP4GetListEntry(decoder->TrackReaderList, i, (char**)&reader); if(err) goto bail;
-	err = MP4GetListEntry(decoder->TrackSampleList, i, (char**)&sampleH); if(err) goto bail;
-	err = MP4TrackReaderGetNextAccessUnitWithSampleNumber( reader, sampleH, &unitSize,&sampleFlags, &cts, &dts, sampleNumber);
-
-	if ( err )
-	{
-		if ( err == MP4EOF )
-		{
-			*SampleData = NULL;
-			*SampleDataSize = 0;
-			*CurrentTime = 0;
-			err = MP4NoErr;
-		}
-		else
-			goto bail;
-	}
-
-	*CurrentTime = dts;
-	*SampleData = *sampleH;
-	*SampleDataSize = unitSize;
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetNextTextSample(IMAF_DecoderH IMafDecoder, 
-				unsigned char **SampleData, unsigned int *SampleDataSize, unsigned int *CurrentTime, TextSampleStyleParam **param)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	u32 unitSize;
-	u32 sampleFlags;
-	u32 cts;
-	u32 dts;
-	u32 i;
-	u8 *TextSample;
-	MP4InputStreamPtr is;
-	u32 TextModifiersSize, TotalAtomSize;
-	MP4AtomPtr entry;
-	TextStyleAtomPtr styl;
-	TextHighlightAtomPtr hlit;
-	TextHighlightColorAtomPtr hclr;
-	TextKaraokeAtomPtr krok;
-	TextSampleEntryValue tx3g_value;
-	
-	
-	err = MP4TrackReaderGetNextAccessUnit(decoder->TimedTextTrackReader, decoder->TimedTextSampleH, &unitSize, &sampleFlags, &cts, &dts);
-
-	if ( err )
-	{
-		if ( err == MP4EOF )
-		{
-			*SampleData = NULL;
-			*SampleDataSize = 0;
-			*CurrentTime = 0;
-			return MP4EOF;
-		}
-		else
-			goto bail;
-	}
-
-	err = MP4TrackReaderGetTextSampleEntryValues(decoder->TimedTextTrackReader, &tx3g_value); if(err) goto bail;
-
-#if 0	//only text
-	*CurrentTime = dts;
-	*SampleData = *decoder->TimedTextSampleH;
-	*SampleDataSize = unitSize;
-#else
-	*CurrentTime = dts;
-	TextSample = *decoder->TimedTextSampleH;
-	*SampleDataSize = TextSample[0]<<8 | TextSample[1];
-	TextSample+=2;
-	MP4SetHandleSize(decoder->TextH, *SampleDataSize+1);
-	memcpy(*decoder->TextH, TextSample, *SampleDataSize);
-	TextSample += *SampleDataSize;
-	(*decoder->TextH)[*SampleDataSize] = '\0';
-	*SampleData = *decoder->TextH;
-
-	//Extract Text Style
-	InitTextSampleStyleParam(decoder->TextParam);
-	decoder->TextParam->displayFlags=								tx3g_value.displayFlags;
-	decoder->TextParam->horizontal_justification=				tx3g_value.horizontal_justification;
-	decoder->TextParam->vertical_justification=					tx3g_value.vertical_justification;
-	decoder->TextParam->background_color_r=					tx3g_value.background_color_r;
-	decoder->TextParam->background_color_g=					tx3g_value.background_color_g;
-	decoder->TextParam->background_color_b=					tx3g_value.background_color_b;
-	decoder->TextParam->background_color_a=					tx3g_value.background_color_a;
-	decoder->TextParam->default_text_box_top=					tx3g_value.default_text_box_top;
-	decoder->TextParam->default_text_box_left=					tx3g_value.default_text_box_left;
-	decoder->TextParam->default_text_box_bottom=			tx3g_value.default_text_box_bottom;
-	decoder->TextParam->default_text_box_right=				tx3g_value.default_text_box_right;
-	decoder->TextParam->default_style_startChar=				tx3g_value.default_style_startChar;
-	decoder->TextParam->default_style_endChar=				tx3g_value.default_style_endChar;
-	decoder->TextParam->default_style_font_ID=					tx3g_value.default_style_font_ID;
-	decoder->TextParam->default_style_face_style_flags=  	tx3g_value.default_style_face_style_flags;
-	decoder->TextParam->default_style_font_size=				tx3g_value.default_style_font_size;
-	decoder->TextParam->default_style_text_color_r=			tx3g_value.default_style_text_color_r;
-	decoder->TextParam->default_style_text_color_g=			tx3g_value.default_style_text_color_g;
-	decoder->TextParam->default_style_text_color_b=			tx3g_value.default_style_text_color_b;
-	decoder->TextParam->default_style_text_color_a=			tx3g_value.default_style_text_color_a;
-	decoder->TextParam->font_ID=										tx3g_value.font_ID;
-	decoder->TextParam->font_name_length=						tx3g_value.font_name_length;
-	decoder->TextParam->font=												_strdup(tx3g_value.font);
-	free(tx3g_value.font);
-
-	TotalAtomSize= 0;
-	TextModifiersSize = unitSize - 2 - *SampleDataSize;
-	err = MP4CreateMemoryInputStream(TextSample, TextModifiersSize, &is ); if (err) goto bail;
-	is->debugging = 0;
-	while(TextModifiersSize>TotalAtomSize)
-	{
-		err = MP4ParseAtom( is, &entry ); if (err) goto bail;
-		TotalAtomSize += entry->size;
-		if(entry->type == 'styl')
-		{
-			StyleRecordStructPtr styleRecord;
-			styl = (TextStyleAtomPtr)entry;
-			decoder->TextParam->styl_entry_count = styl->entry_count;
-			decoder->TextParam->styl_text_styles = (StyleRecord*)calloc(styl->entry_count, sizeof(styleRecord));
-			for(i=0; i<styl->entry_count; i++)
-			{
-				err = MP4GetListEntry(styl->styleRecordList, i, (char**)&styleRecord); if(err) goto bail;
-				memcpy(&decoder->TextParam->styl_text_styles[i], styleRecord, sizeof(StyleRecord));
-			}
-		}
-		else if(entry->type == 'hlit')
-		{
-			hlit = (TextHighlightAtomPtr)entry;
-			decoder->TextParam->hlit_startcharoffset = hlit->startcharoffset;
-			decoder->TextParam->hlit_endcharoffset = hlit->endcharoffset;
-		}
-		else if(entry->type == 'hclr')
-		{
-			hclr = (TextHighlightColorAtomPtr)entry;
-			decoder->TextParam->hclr_highlight_color_r = hclr->highlight_color_r;
-			decoder->TextParam->hclr_highlight_color_g = hclr->highlight_color_g;
-			decoder->TextParam->hclr_highlight_color_b = hclr->highlight_color_b;
-			decoder->TextParam->hclr_highlight_color_a = hclr->highlight_color_a;
-		}
-		else if(entry->type == 'krok')
-		{
-			krok = (TextKaraokeAtomPtr)entry;
-			decoder->TextParam->krok_highlight_start_time = krok->highlight_start_time;
-			decoder->TextParam->krok_entry_count = krok->entry_count;
-			decoder->TextParam->krok_highlight_end_time = calloc(krok->entry_count, sizeof(u32));
-			decoder->TextParam->krok_startcharoffset= calloc(krok->entry_count, sizeof(u32));
-			decoder->TextParam->krok_endcharoffset = calloc(krok->entry_count, sizeof(u32));
-			for(i=0; i<krok->entry_count; i++)
-			{
-				decoder->TextParam->krok_highlight_end_time[i] =krok->highlight_end_time[i];
-				decoder->TextParam->krok_startcharoffset[i] = krok->startcharoffset[i];
-				decoder->TextParam->krok_endcharoffset[i] = krok->endcharoffset[i];
-			}
-		}
-		else
-		{
-			BAILWITHERROR(MP4NotImplementedErr)
-		}
-
-		entry->destroy(entry);
-	}
-
-	if (is) {
-		is->destroy( is );
-		is = NULL;
-	}
-
-	*param = decoder->TextParam;
-#endif
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetDsiByIndex(IMAF_DecoderH IMafDecoder,  unsigned int i, char** dsi, unsigned int *dsiSize)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	MP4TrackReader reader;
-	MP4Handle specificInfoH;
-
-	err = MP4GetListEntry(decoder->TrackReaderList, i, (char**)&reader); if(err) goto bail;
-
-	err = MP4NewHandle(0, &specificInfoH); if(err) goto bail;
-	err = MP4TrackReaderGetCurrentDecoderSpecificInfo(reader, specificInfoH); if(err) goto bail;
-	err = MP4GetHandleSize(specificInfoH, dsiSize);
-	*dsi = (u8*)malloc(*dsiSize);
-	memcpy(*dsi, *specificInfoH, *dsiSize);
-	err = MP4DisposeHandle(specificInfoH); if(err) goto bail;
-	
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetSongImage(IMAF_DecoderH IMafDecoder, unsigned char **image, unsigned int *imageSize)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-	u8 *content_type;
-
-	err = MP4GetMovieIndTrack( decoder->moov, 1, &decoder->trak ); if (err) goto bail;
-	err = MP4GetTrackMedia( decoder->trak, &decoder->media ); if (err) goto bail;
-	err = MP4_GetImageByItemId(decoder->moov, decoder->media, image, imageSize, &content_type, 1); if(err) goto bail;
-
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetMetadata(IMAF_DecoderH IMafDecoder, unsigned char **Meta, unsigned int *MetaSize)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	err = MP4GetMetaXml(decoder->moov, Meta, MetaSize); if(err) goto bail;
-bail:
-	TEST_RETURN( err );
-	return err;
-}
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_Destroy(IMAF_DecoderH IMafDecoder)
-{
-	IMAFDecoder *decoder = (IMAFDecoder*) IMafDecoder;
-	IMAF_Err err;
-
-	if(decoder)
-	{
-		if(decoder->InputMafFilename)
-		{
-			free(decoder->InputMafFilename);
-			decoder->InputMafFilename = NULL;
-		}
-
-		if(decoder->TrackReaderList)
-		{
-			u32 i;
-			MP4TrackReader reader;
-			MP4Handle sampleH;
-			for(i=0; i<decoder->TrackCount - decoder->HasTimedTextTrack; i++)
-			{
-				err = MP4GetListEntry(decoder->TrackReaderList, i, (char**)&reader); if(err) goto bail;
-				err = MP4DisposeTrackReader(reader); if(err) goto bail;
-				err = MP4GetListEntry(decoder->TrackSampleList, i, (char**)&sampleH); if(err) goto bail;
-				err = MP4DisposeHandle(sampleH); if(err) goto bail;
-			}
-			err = MP4DeleteLinkedList(decoder->TrackReaderList); if(err) goto bail;
-			err = MP4DeleteLinkedList(decoder->TrackSampleList); if(err) goto bail;
-			decoder->TrackReaderList = NULL;
-			decoder->TrackSampleList = NULL;
-		}
-
-		if(decoder->TimedTextSampleH)
-			MP4DisposeHandle(decoder->TimedTextSampleH);
-		if(decoder->TextH)
-			MP4DisposeHandle(decoder->TextH);
-		if(decoder->TimedTextTrackReader)
-			MP4DisposeTrackReader(decoder->TimedTextTrackReader);
-		if(decoder->TextParam)
-		{
-			InitTextSampleStyleParam(decoder->TextParam);
-			free(decoder->TextParam);
-		}
-
-		if(decoder->moov)
-		{
-			err = MP4DisposeMovie( decoder->moov ); if(err) goto bail;
-		}
-		free(decoder);
-	}
-
-bail:
-	return err;
-}
-
-IMAF_DECODER_API char* IMAF_Decoder_GetLastError(IMAF_Err err)
-{
-	return MP4GetLastError(err);
-}
\ No newline at end of file
--- a/IM_AF Decoder/IM_AF_Decoder.h	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-#ifndef IM_AF_Decoder_h__
-#define IM_AF_Decoder_h__
-
-#define IMAF_DECODER_API
-
-typedef int IMAF_Err;
-typedef void* IMAF_DecoderH;
-
-typedef struct IMAF_Decoder_Param
-{
-	unsigned char *InputMafFilename;					//in
-	unsigned int NumberOfAudioTrack;					//out
-	unsigned int MovieTimescale;							//out
-	unsigned int MovieDuration;							//out
-	unsigned int HasTimedTextTrack;					//out
-	unsigned int MajorBrand;									//out
-	unsigned int NumberOfCompatibleBrands;		//out
-	unsigned int *CompatibleBrands;					//out
-}IMAF_Decoder_Param;
-
-typedef struct IMAF_AudioParam
-{
-	unsigned int nBitsPerSample;
-	unsigned int nChannels;
-	unsigned int nSamplingFrequency;
-}IMAF_AudioParam;
-
-typedef struct IMAF_Group
-{
-	unsigned int group_ID;
-	unsigned int num_elements;
-	unsigned int *element_ID;
-	unsigned int group_activation_mode;
-	unsigned int group_activation_elements_number;
-	unsigned int group_reference_volume;		// 0~100 (0~1.0)
-	char *group_name;
-	char *group_description;
-}IMAF_Group;
-
-typedef struct IMAF_Preset
-{
-	unsigned int preset_ID;
-	unsigned int num_preset_elements;
-	unsigned int *preset_element_ID;	//array
-	unsigned int preset_type;
-	unsigned int preset_global_volume;
-	unsigned int *preset_volume_element;
-	unsigned int *num_input_channel;
-	unsigned int output_channel_type;
-	unsigned int num_output_channel;
-	unsigned int num_updates;
-	unsigned int *updated_sample_number;
-	char *preset_name;
-}IMAF_Preset;
-
-typedef struct IMAF_SelectionRule
-{
-	unsigned int selection_rule_ID;
-	unsigned int selection_rule_type;
-	unsigned int element_ID;
-	unsigned int min_num_elements;
-	unsigned int max_num_elements;
-	unsigned int key_element_ID;
-	char *selection_rule_description;
-}IMAF_SelectionRule;
-
-typedef struct IMAF_MixingRule
-{
-	unsigned int  mixing_rule_ID;
-	unsigned int  mixing_rule_type;
-	unsigned int  element_ID;
-	unsigned int  min_volume;
-	unsigned int  max_volume;
-	unsigned int  key_element_ID;
-	char *mixing_rule_description;
-}IMAF_MixingRule;
-
-typedef struct StyleRecord
-{
-	unsigned int startChar;
-	unsigned int endChar;
-	unsigned int fontID;
-	unsigned int face_style_flags;
-	unsigned int font_size;
-	unsigned int text_color_r;
-	unsigned int text_color_g;
-	unsigned int text_color_b;
-	unsigned int text_color_a;
-}StyleRecord;
-
-typedef struct TextSampleStyleParam
-{
-	//tx3g
-	unsigned int displayFlags;
-	unsigned int horizontal_justification;
-	unsigned int vertical_justification;
-	unsigned int background_color_r;
-	unsigned int background_color_g;
-	unsigned int background_color_b;
-	unsigned int background_color_a;
-	unsigned int default_text_box_top;
-	unsigned int default_text_box_left;
-	unsigned int default_text_box_bottom;
-	unsigned int default_text_box_right;
-	unsigned int default_style_startChar;
-	unsigned int default_style_endChar;
-	unsigned int default_style_font_ID;
-	unsigned int default_style_face_style_flags;
-	unsigned int default_style_font_size;
-	unsigned int default_style_text_color_r;
-	unsigned int default_style_text_color_g;
-	unsigned int default_style_text_color_b;
-	unsigned int default_style_text_color_a;
-	unsigned int font_ID;
-	unsigned int font_name_length;
-	unsigned char *font;
-	//styl
-	unsigned int styl_entry_count;
-	StyleRecord *styl_text_styles;
-	//hlit
-	unsigned int hlit_startcharoffset;
-	unsigned int hlit_endcharoffset;
-	//hclr
-	unsigned int hclr_highlight_color_r;
-	unsigned int hclr_highlight_color_g;
-	unsigned int hclr_highlight_color_b;
-	unsigned int hclr_highlight_color_a;
-	//krok
-	unsigned int krok_highlight_start_time;
-	unsigned int krok_entry_count;
-	unsigned int *krok_highlight_end_time;
-	unsigned int *krok_startcharoffset;
-	unsigned int *krok_endcharoffset;
-	//dlay
-	//href
-	//tbox
-	//blnk
-	//twrp
-}TextSampleStyleParam;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_Create(IMAF_DecoderH *IMafDecoder, IMAF_Decoder_Param *param);
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetAudioTrackInfos(IMAF_DecoderH IMafDecoder, unsigned int *AudioTrackObjectTypeArray
-														  ,unsigned int *AudioTrackIdArray, IMAF_AudioParam *AudioParamArray);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetGroupContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *GroupCount);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetGroupByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_Group *grup);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetPresetContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *num_preset, unsigned int *default_preset_ID);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetPresetByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_Preset *prst);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetRuleContainerInfo(IMAF_DecoderH IMafDecoder, unsigned int *num_selection_rules, unsigned int *num_mixing_rules);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetSelectionRuleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_SelectionRule *rusc);
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_GetMixingRuleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i, IMAF_MixingRule *rumx);
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_SeekSample(IMAF_DecoderH IMafDecoder, unsigned int mediaTime);
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetNextAudioSampleByIndex(IMAF_DecoderH IMafDecoder, unsigned int i,
-																unsigned char **SampleData, unsigned int *SampleDataSize, unsigned int *CurrentTime, unsigned int *sampleNumber);
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetNextTextSample(IMAF_DecoderH IMafDecoder, 
-														unsigned char **SampleData, unsigned int *SampleDataSize, unsigned int *CurrentTime, TextSampleStyleParam **param);
-
-// only for AAC track
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetDsiByIndex(IMAF_DecoderH IMafDecoder,  unsigned int i, char** dsi, unsigned int *dsiSize);
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetSongImage(IMAF_DecoderH IMafDecoder, unsigned char **image, unsigned int *imageSize);
-
-IMAF_DECODER_API IMAF_Err IMAFDecoder_GetMetadata(IMAF_DecoderH IMafDecoder, unsigned char **Meta, unsigned int *MetaSize);
-
-IMAF_DECODER_API IMAF_Err IMAF_Decoder_Destroy(IMAF_DecoderH IMafDecoder);
-
-IMAF_DECODER_API char* IMAF_Decoder_GetLastError(IMAF_Err err);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // IM_AF_Decoder_h__
\ No newline at end of file
--- a/IM_AF Decoder/IM_AF_Decoder.vcproj	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,171 +0,0 @@
-<?xml version="1.0" encoding="ks_c_5601-1987"?>
-<VisualStudioProject
-	ProjectType="Visual C++"
-	Version="8.00"
-	Name="IM_AF_Decoder"
-	ProjectGUID="{0DCFBC3F-77B5-4DAF-B2F3-B1D7B6041600}"
-	RootNamespace="IM_AF_Decoder"
-	Keyword="Win32Proj"
-	>
-	<Platforms>
-		<Platform
-			Name="Win32"
-		/>
-	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
-	<Configurations>
-		<Configuration
-			Name="Debug|Win32"
-			OutputDirectory="$(SolutionDir)\lib\vc8_$(ConfigurationName)"
-			IntermediateDirectory="vc8_$(ConfigurationName)"
-			ConfigurationType="4"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				Optimization="0"
-				AdditionalIncludeDirectories="..\libisomedia;..\libisomedia\w32"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
-				MinimalRebuild="true"
-				BasicRuntimeChecks="3"
-				RuntimeLibrary="1"
-				UsePrecompiledHeader="0"
-				ProgramDataBaseFileName="$(IntDir)\$(ProjectName)_vc80.pdb"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="false"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-		<Configuration
-			Name="Release|Win32"
-			OutputDirectory="$(SolutionDir)\lib\vc8_$(ConfigurationName)"
-			IntermediateDirectory="vc8_$(ConfigurationName)"
-			ConfigurationType="4"
-			CharacterSet="2"
-			WholeProgramOptimization="1"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="..\libisomedia;..\libisomedia\w32"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
-				RuntimeLibrary="0"
-				UsePrecompiledHeader="0"
-				ProgramDataBaseFileName="$(IntDir)\$(ProjectName)_vc80.pdb"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="false"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLibrarianTool"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
-		</Configuration>
-	</Configurations>
-	<References>
-	</References>
-	<Files>
-		<Filter
-			Name="¼Ò½º ÆÄÀÏ"
-			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
-			<File
-				RelativePath=".\IM_AF_Decoder.c"
-				>
-			</File>
-		</Filter>
-		<Filter
-			Name="Çì´õ ÆÄÀÏ"
-			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
-			<File
-				RelativePath=".\IM_AF_Decoder.h"
-				>
-			</File>
-		</Filter>
-	</Files>
-	<Globals>
-	</Globals>
-</VisualStudioProject>
Binary file IM_AF Decoder/vssver2.scc has changed
Binary file IM_AF Encoder/.DS_Store has changed
Binary file IM_AF Encoder/Bass.wav has changed
Binary file IM_AF Encoder/Drumbox.wav has changed
Binary file IM_AF Encoder/IM_AM Encoder.xcodeproj/project.xcworkspace/xcuserdata/eugin.xcuserdatad/UserInterfaceState.xcuserstate has changed
Binary file IM_AF Encoder/IM_AM Encoder/Example_Acoustic.ima has changed
Binary file IM_AF Encoder/IM_AM Encoder/Example_Electro.ima has changed
Binary file IM_AF Encoder/IM_AM Encoder/Example_Rock.ima has changed
--- a/IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h	Thu Jul 26 16:52:19 2012 +0100
+++ b/IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h	Sun Aug 26 13:39:26 2012 +0100
@@ -14,7 +14,7 @@
 /* for FILE typedef, */
 #include <stdio.h>
 
-#define maxtracks 10
+#define maxtracks 8
 #define maxpreset 10
 #define maxrules 10
 
@@ -22,7 +22,7 @@
 typedef unsigned int u32;
 typedef unsigned short u16;
 
-typedef struct nametrack {
+typedef struct nametrack { // Stores the different titles of the tracks
     char title[20];
 }nametrack[maxtracks];
 
@@ -32,7 +32,7 @@
     u32 type;          // ftyp 
     u32 major_brand;   // brand identifier
     u32 minor_version; // informative integer for the mirror version
-    u32 compatible_brands[2]; //list, to the end of the box, of brands
+    u32 compatible_brands[2]; //list of brands
 }FileTypeBox;
 
 typedef struct MoiveBox //extends Box('moov') 
@@ -209,7 +209,7 @@
                         u32 version;
                         u32 sample_size; // =0
                         u32 sample_count;
-                        u32 entry_size[8000];
+                        u32 entry_size[9000];
                     }SampleSizeBox;
                     struct SampleToChunk{
                         u32 size;
@@ -231,23 +231,6 @@
             }MediaInformationBox;
         }MediaBox;
     }TrackBox[maxtracks]; // max 10 tracks
-/*   struct GroupContainerBox // extends Box('grco')
-    {
-        u16 num_groups; 
-        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; 
-            u16 group_activation_elements_number; 
-            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')
     {
         u32 size;
@@ -270,14 +253,7 @@
             struct presVolumElem{
                 unsigned char preset_volume_element;
             }presVolumElem[maxtracks];
-  /*          u16 num_updates;
-            struct updateSample{
-                u16 update_sample_number;
-                struct presVolumElem2{
-                    unsigned char preset_volume_element2;
-                }presVolumElem2[maxtracks];
-            }updateSample[5];
-  */          char preset_name[14];
+           char preset_name[14];
         }PresetBox[maxpreset];
     }PresetContainerBox;
     
@@ -303,7 +279,7 @@
             unsigned char mixing_type;
             u32 element_ID;
             u32 key_elem_ID;
-            char mix_description[11];
+            char mix_description[17];
         }MixingRules;
     }RulesContainer;
 }MovieBox; 
@@ -315,42 +291,6 @@
     unsigned char data;  
 }MediaDataBox;
 
-/*typedef struct MetaBox // extends FullBox('meta',version=0,0)
-{
-    struct HandlerBox theHandler; 
-    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; 
-        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
 
 
Binary file IM_AF Encoder/IM_AM Encoder/example1.ima has changed
--- a/IM_AF Encoder/IM_AM Encoder/main.c	Thu Jul 26 16:52:19 2012 +0100
+++ b/IM_AF Encoder/IM_AM Encoder/main.c	Sun Aug 26 13:39:26 2012 +0100
@@ -23,8 +23,6 @@
 int presetcontainer(MovieBox *moov, int,nametrack namet);
 int rulescontainer(MovieBox *moov);
 void writemoovbox(MovieBox moov, int numtrack,int totaltracks, FILE *imf);
-//void groupscontainer(MovieBox *moov);
-//void metadata(MetaBox *meta);
 int readTrack(MovieBox *moov, int, char name[20]);
 int byterevers(int);
 
@@ -44,13 +42,13 @@
     /* Obtain current time as seconds elapsed since the Epoch. */
     time_t clock = time(NULL);
     
-    printf("Welcome to the IM_AF encoder\n");
+    printf("\nWelcome to the IM_AF encoder\n");
     printf("This program will allow you to create an IM_AF file.\n");
     printf("How many tracks there will be in your IMAF file?\n");
     scanf("%d",&totaltracks); 
     fflush(stdin);
     while (totaltracks > maxtracks) {
-        printf("Sorry, for this version the number maximum ot tracks is 10\n");
+        printf("Sorry, for this version the number maximum ot tracks is %d\n",maxtracks);
         printf("How many tracks there will be in your IMAF file:\n");
         scanf("%d",&totaltracks); 
     }
@@ -69,14 +67,17 @@
 
     //Media Data Box - Contains the audio
     FILE *song;
-    char nametrack[20], pathdir[60] ="/Users/eugin/Desktop/IM_AF Encoder/Electro/";
+    char nametrack[20];
+    //Specify the path directory where there are the songs.
+    //If change folder, change the path here (3 times) and in readTrack function!!!
+    char pathdir[60] ="/Users/eugin/Desktop/IM_AF Encoder/Rock/";
     int numtr, ex = 0;
     for (numtr=0; numtr<totaltracks; numtr++) {
         
         printf("Name of the track number: %d\n", numtr+1);
         fflush(stdin);
         scanf("%s", nametrack);
-        strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/Electro/");
+        strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/Rock/");
         strcat(pathdir, nametrack);
         ex = 0;
         //Check if the track exist and then open it.
@@ -86,51 +87,50 @@
                 printf("Name does not exist. Try again:\n");
                 fflush(stdin);
                 scanf("%s", nametrack);
-                strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/Electro/");
+                strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/Rock/");
                 strcat(pathdir, nametrack);
             }else{
                 ex = 1;
             }
         }
         strcpy(namet[numtr].title, nametrack);
+        
+        //Extract the samples from the audio file
         sizemdat = mdatbox(&mdat, totaltracks, imf, song, numtr);
+        
+        //Close the audio file
         fclose(song);
     }
-    
+   
     //For each track write track information
     u32 sizeTRAK = 0;
     char name[20];
     durationTrack = (sizemdat*8)/128;
-    printf("Duration: %d\n",durationTrack);
     
     for (numtrack = 0; numtrack < totaltracks; numtrack++) {
         strcpy(name,namet[numtrack].title);
         sizeTRAK =  trackstructure(&moov, numtrack, clock, durationTrack,sizemdat, name)+ sizeTRAK;
     }
     
-    //Groups
- //   groupscontainer(&moov);
-    
     //Presets
     u32 sizePRCO;
-    sizePRCO = presetcontainer(&moov, totaltracks, namet);
+    sizePRCO = presetcontainer(&moov, totaltracks, namet); // Creates the preset, returns the size of the box.
     
     //Rules
     u32 sizeRUCO;
-    sizeRUCO = rulescontainer(&moov);
+    sizeRUCO = rulescontainer(&moov); // Creates the rules, returns the size of the box.
     
     //Movie Header - Overall declarations
     moovheaderbox(&moov, clock, sizeTRAK, sizePRCO, totaltracks, durationTrack, sizeRUCO);
     
-    writemoovbox(moov,numtrack, totaltracks, imf);
-    
-    //Metadata
-    //metadata(&meta);
-    //fwrite(&meta, sizeof(MetaBox),1, imf);
+    //Writes the movie box into the file
+    writemoovbox(moov,numtrack, totaltracks, imf); 
     
     //Close File
     fclose(imf); 
-        
+    
+    printf("\nFile is created successfully, and ready to use!\n");
+    
     return 0;
 }
 
@@ -153,84 +153,75 @@
 int mdatbox(MediaDataBox *mdat, int totaltracks, FILE *imf, FILE *song, int numtr){
 
     int d, cnt, j, find = 0;
-    int  dat = 0, dat1 = 0, dat2 = 0, dat3 = 0, num_samples = 0;
+    int  dat = 0, dat1 = 0, dat2 = 0, dat3 = 0;
     u32 size = 0, swap, sizeMDAT =0;
-    
+    //Positonate the pointer at the end of the file to know the size of it
     fseek(song, 0, SEEK_END);
     size = ftell(song);
+    //Positionate the pointer at first
     fseek(song, 0, SEEK_SET);
     d=0;
     cnt = 0;
+    //Find the header of the first frame (the beginning), when find it d=1 and jump out the loop.
+    // The header is 32 bytes. We find in groups of 8 bytes
+    // Contemplate all possible options of headers
     while (d == 0) {
         find = 0;
         fread(&dat, sizeof(unsigned char), 1, song);
         cnt++;
         
         if (dat == 0xFF) {
-            cnt++;
+            cnt++;                                              // cnt : stores the position of the pointer.  
             fread(&dat1, sizeof(unsigned char), 1, song);
             cnt++;
             fread(&dat2, sizeof(unsigned char), 1, song);
             cnt++;
             fread(&dat3, sizeof(unsigned char), 1, song);
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 64 ) {
-                num_samples ++;
-                // printf("Data %d Position: %d\n",dat3, cnt);
-                find = 1;
-                d=1;
+                find = 1;                                       // find: if the header is found
+                d=1;                                            // d: jump out the loop
             }
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 96 ) {
-                num_samples ++;
                 d=1;
                 find = 1;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 64 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 96 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }     
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 100 ) {
-                num_samples ++;
                 d=1;
                 find = 1;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 100 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 64 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 96 ) {
-                num_samples ++;
                 d=1;
                 find = 1;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 64 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 96 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }     
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 100 ) {
-                num_samples ++;
                 d=1;
                 find = 1;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 100 ) {
-                num_samples ++;
                 find = 1;
                 d=1;
             }
@@ -243,10 +234,9 @@
             d = 1;
         }
     }
-    size =  size - (cnt - 4);
+    size =  size - (cnt - 4);       // Calculate the size of the samples. size = pos. end of file - pos. first header. 
     if (numtr == 0) {
-        sizeMDAT = size*totaltracks + 8;
-     //   printf("Size file mdat %d\n",sizeMDAT);
+        sizeMDAT = size*totaltracks + 8;    // size of the whole media box 
         swap = byterevers(sizeMDAT);
         fwrite(&swap, sizeof(u32), 1, imf);
         swap = byterevers('mdat');
@@ -254,7 +244,7 @@
         fwrite(&mdat->type, sizeof(u32), 1, imf);
     }
     fseek(song, cnt - 4, SEEK_SET);
-    for (j=0; j<size; j++) {
+    for (j=0; j<size; j++) {                //read all the samples of one track and writes them in the IM AF file
         fread(&mdat->data, sizeof(char), 1, song);
         fwrite(&mdat->data, sizeof(char), 1, imf);
     }
@@ -268,15 +258,15 @@
     u32 sizeSTSD, sizeSTSZ, swap, num_samples, dat=0;
 
     //Sample Description Box//
-    sizeSTSD = sampledescription(moov, numtrack);
-
+    sizeSTSD = sampledescription(moov, numtrack); 
+     
     //Sample size box//
     swap = byterevers('stsz');
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     SampleSizeBox.type = swap;
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     SampleSizeBox.version = 0;
-    //Read Track: Fram size and Decoder Times// 
+    //Read Track: Frame size and Decoder Times 
     num_samples = readTrack(moov, numtrack, name);
     sizeSTSZ = num_samples*4 + 20;
     swap = byterevers(sizeSTSZ);
@@ -391,19 +381,6 @@
     SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
     DecoderConfigDescriptor.avgBitrate = swap;
     
-    //Decoder Specific Info//
-  /*  moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
-    SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
-    DecoderConfigDescriptor.DecoderSpecificInfo.tag = 5;
-    moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
-    SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
-    DecoderConfigDescriptor.DecoderSpecificInfo.length = 2;
-    SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
-    DecoderConfigDescriptor.DecoderSpecificInfo.decSpecificInfoData[0] = 0xC;
-    moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
-    SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
-    DecoderConfigDescriptor.DecoderSpecificInfo.decSpecificInfoData[1] = 0x8;
-  */  
     //SLConfig Descriptor//
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     SampleDescriptionBox.AudioSampleEntry.ESbox.ES_Descriptor.
@@ -473,23 +450,24 @@
     
     FILE *song;
     int d=0, cnt = 0, i=0, j=0, cnt2 = 0, find = 0, swap, num_entr = 0;
-    int  dat = 0, dat1 = 0, dat2 = 0, dat3 = 0, num_samples = 0, end =0, pos = 0;
-    u32 size[8000];
-    char pathdir[60] = "/Users/eugin/Desktop/IM_AF Encoder/Electro/";
-  //  printf("Name: %s\n",name);
+    int  dat = 0, dat1 = 0, dat2 = 0, dat3 = 0, num_frame = 0, end =0, pos = 0;
+    u32 size[9000];
+    //Change path directory here
+    char pathdir[60] = "/Users/eugin/Desktop/IM_AF Encoder/Rock/";
     strcat(pathdir, name);
-    
+    //Open the audio file with the name introduced by the user
     song = fopen (pathdir,"rb"); 
     if (song == NULL) {
         printf("Error opening input file\n");
         system("pause");
         exit(1);
     }
-    
+    //Calculate the size of the track
     fseek(song, 0, SEEK_END);
     end = ftell(song);
     fseek(song, 0, SEEK_SET);
     d=0, i=0;
+    //Search for each frame one by one, and extratcs the information
     while (d == 0) {
         find = 0;
         fread(&dat, sizeof(unsigned char), 1, song);
@@ -503,94 +481,91 @@
             cnt++;
             fread(&dat3, sizeof(unsigned char), 1, song);
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 64 ) {
-                pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
-                cnt2 = pos;
-         //       printf("Data %d Position: %d\n",dat3, num_samples,pos);
+                pos = cnt - 4;                      //Pos of the beginning of the frame
+                size[num_frame] = pos - cnt2;     //Size of one frame
+                cnt2 = pos;                         //Pos of the next frame
                 find = 1;
-                num_samples ++;
+                num_frame ++;                     //Number of frames
             }
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 96 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 64 ) {
-               pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                pos = cnt - 4;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
-         //       printf("Data %d Position: %d\n",dat3, num_samples,pos);
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 96 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFB && dat2 == 146 && dat3 == 100 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFB && dat2 == 144 && dat3 == 100 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 64 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
-                //       printf("Data %d Position: %d\n",dat3, num_samples,pos);
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 96 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 64 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
-                //       printf("Data %d Position: %d\n",dat3, num_samples,pos);
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 96 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 146 && dat3 == 100 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
             if (dat1 == 0xFA && dat2 == 144 && dat3 == 100 ) {
                 pos = cnt - 4;
-                size[num_samples] = pos - cnt2;
+                size[num_frame] = pos - cnt2;
                 cnt2 = pos;
                 find = 1;
-                num_samples ++;
+                num_frame ++;
             }
-            if (find == 0) { // Keep reading next data.
+            if (find == 0) { //In case it does not find the header.
+                             //It keeps reading next data without jump any position
                 fseek(song, -3, SEEK_CUR);
                 cnt = cnt - 3;
             }
@@ -598,28 +573,36 @@
         
         if (cnt == end) {
             pos = cnt;
-            size[num_samples] = pos - cnt2;
+            size[num_frame] = pos - cnt2;
             d = 1;
         }
     }
-    
+
     //Save Samples size//
-    swap = byterevers(num_samples);
+    swap = byterevers(num_frame);
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     SampleSizeBox.sample_count = swap;
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     SampleSizeBox.sample_size = 0;
     
-    for (i=0; i< num_samples; i++) {
+    for (i=0; i< num_frame; i++) {
         swap = byterevers(size[i+1]);
         moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
         SampleSizeBox.entry_size[i] = swap;
     }
     
-  //  printf("Num of samples %d\n",num_samples);
+    //Save Decoding Times//
+    //Writes manually the duration of each frame. 
+    //Follows the following structure: 
+    //  7 frames of 26 ms
+    //  1 frame  of 27 ms
+    //      ...
+    // And each 13 rows it writes
+    //  8 frames of 26 ms
+    //  1 frame  of 27 ms
+    //It is done for adjusting the different durations of each frame.
+    //                  as they vary between 26.125 ms and 26.075 ms
     
-    //Save Decoding Times//
-
     swap = byterevers(1);
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     TimeToSampleBox.sample_count[0] = swap;
@@ -628,7 +611,7 @@
     int t=0,k=1, l =0;
     num_entr = 1;
     j = 0;
-    for (i = 1; i< num_samples; i++) {
+    for (i = 1; i< num_frame; i++) {
         if (j == 8 && l == 0) {
             swap = byterevers(7);
             moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
@@ -683,7 +666,7 @@
         j++;
     }
 
-    dat = num_samples - dat;
+    dat = num_frame - dat;
     
     swap = byterevers(dat);
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
@@ -692,13 +675,12 @@
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     TimeToSampleBox.sample_delta[num_entr] =swap; 
     num_entr++;
- //   printf("Num entries: %d\n", num_entr);
     swap = byterevers(num_entr);
     moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.
     TimeToSampleBox.entry_count = swap;
     
     fclose(song);
-    return num_samples;
+    return num_frame;
 
 }
 
@@ -854,15 +836,15 @@
 int presetcontainer(MovieBox *moov, int totaltracks, nametrack namet){
     
     int swap, i,j,flag, vol=0; 
-//    char num_output_channel = 2; // Stereo
     unsigned char numpres=0, prestype=0,defaultPreset;
     char namepres1[14] = "static_track "; // 13  
     u32 sizePRST = 0;
 
-    printf("Presets:\n");
+    printf("\nPresets:\n");
     printf("Static track volume preset: invariant volume related to each track \n");
     printf("          --------------------------------------\n");
     numpres = 1;
+    
     //Preset Box//
     for (i=0; i<numpres; i++) {
         printf("Preset number %d: %s\n",i+1,namepres1);
@@ -872,16 +854,6 @@
         moov->PresetContainerBox.PresetBox[i].size = swap;
         prestype = 0;
 
-  /*      if (i == 1) {
-            printf("Preset number %d: %s\n",i+1,namepres2);
-            strcpy(moov->PresetContainerBox.PresetBox[i].preset_name, namepres2);
-            sizePRST2 = 16 + 14 + 4*totaltracks + 2 + 2*5*totaltracks;
-            swap = byterevers(sizePRST2);
-            moov->PresetContainerBox.PresetBox[i].size = swap;
-            prestype = 2;
-            
-        }
- */     
         moov->PresetContainerBox.PresetBox[i].num_preset_elements = totaltracks;
         swap = byterevers('prst');
         moov->PresetContainerBox.PresetBox[i].type = swap;
@@ -899,32 +871,34 @@
             swap = byterevers(j+1);
             moov->PresetContainerBox.PresetBox[i].presElemId[j].preset_element_ID = swap;
         }
-        
+        //Enter values (two options):
+        // In loop
         for (j=0; j<totaltracks; j++) {
-            printf("Enter volume for %s\n",namet[j].title);
+            vol = 70 - 10*(j+1);
+        //    vol = 20*(j+1);
+            printf("Enter volume for %s = %d\n",namet[j].title,vol*2);
         //     scanf("%d",&vol);
         //     printf("Vol: %d\n",vol);
-            vol = 100;
             moov->PresetContainerBox.PresetBox[i].presVolumElem[j].preset_volume_element = vol; //*0.02 
         }
 
- /*       if(prestype == 2){ // dynamic track volume preset
-            moov->PresetContainerBox.PresetBox[i].num_updates = 5; 
-            ups = 1;
-            for(l=0; l<moov->PresetContainerBox.PresetBox[i].num_updates; l++){
-                moov->PresetContainerBox.PresetBox[i].updateSample[l].update_sample_number = ups;
-                for(j=0; j<totaltracks; j++){
-                    printf("Sample position: %d\n",ups);
-                    printf("Enter volume for %s\n",namet[j].title);
-             //       scanf("%d",&vol);
-                    moov->PresetContainerBox.PresetBox[i].updateSample[l].presVolumElem2[j].
-                    preset_volume_element2 = 0x64;
-                }
-                ups = ups + 200; 
-            }
-         }
-  */  
-    }
+        // Or one by one
+/*        moov->PresetContainerBox.PresetBox[i].presVolumElem[0].preset_volume_element = 20;
+        printf("Enter volume for %s = %d\n",namet[j].title,moov->PresetContainerBox.
+               PresetBox[i].presVolumElem[0].preset_volume_element*2);
+        moov->PresetContainerBox.PresetBox[i].presVolumElem[1].preset_volume_element = 40;
+        printf("Enter volume for %s = %d\n",namet[j].title,moov->PresetContainerBox.
+               PresetBox[i].presVolumElem[1].preset_volume_element*2);
+        moov->PresetContainerBox.PresetBox[i].presVolumElem[2].preset_volume_element = 20;
+        printf("Enter volume for %s = %d\n",namet[j].title,moov->PresetContainerBox.
+               PresetBox[i].presVolumElem[2].preset_volume_element*2);
+        moov->PresetContainerBox.PresetBox[i].presVolumElem[3].preset_volume_element = 50;
+        printf("Enter volume for %s = %d\n",namet[j].title,moov->PresetContainerBox.
+               PresetBox[i].presVolumElem[3].preset_volume_element*2);
+        moov->PresetContainerBox.PresetBox[i].presVolumElem[4].preset_volume_element = 52;
+        printf("Enter volume for %s = %d\n",namet[j].title,moov->PresetContainerBox.
+               PresetBox[i].presVolumElem[4].preset_volume_element*2);
+ */   }
     
     //Preset Container//
     u32 sizePRCO = sizePRST + 10;
@@ -944,10 +918,12 @@
     u32 sizeRUSC, elementID, key_elem, sizeRUMX;
     
     moov->RulesContainer.num_selection_rules = 256; //u16 invert
-    moov->RulesContainer.num_mixing_rules = 256;
+ //   moov->RulesContainer.num_selection_rules = 0; 
+    moov->RulesContainer.num_mixing_rules = 256; //u16 invert
     
     //Selection Rules
     sizeRUSC = 19 + 14;
+ //   sizeRUSC = 0;
     swap = byterevers(sizeRUSC);
     moov->RulesContainer.SelectionRules.size = swap; 
     swap = byterevers('rusc');
@@ -955,27 +931,33 @@
     moov->RulesContainer.SelectionRules.version = 0;
     moov->RulesContainer.SelectionRules.selection_rule_ID = 256;
     moov->RulesContainer.SelectionRules.selection_rule_type = 2; 
-    elementID = 1;
+    elementID = 3;
     swap = byterevers(elementID);
     moov->RulesContainer.SelectionRules.element_ID = swap;  
     strcpy(moov->RulesContainer.SelectionRules.rule_description,"Not mute rule");
+    printf("\nRules:\n");
+    printf("Rule 1: Not mute for channel %d\n",elementID);
     
     //Mixing Rule
-    sizeRUMX = 23 + 11;
+    sizeRUMX = 23 + 17;
     swap = byterevers(sizeRUMX);
     moov->RulesContainer.MixingRules.size = swap;
     swap = byterevers('rumx');
     moov->RulesContainer.MixingRules.type = swap;
     moov->RulesContainer.MixingRules.version = 0;
-    moov->RulesContainer.MixingRules.mixing_rule_ID = 512; // Upper rule
-    moov->RulesContainer.MixingRules.mixing_type = 1;
+    moov->RulesContainer.MixingRules.mixing_rule_ID = 512; 
+ //  moov->RulesContainer.MixingRules.mixing_type = 0; // Equivalence rule
+    moov->RulesContainer.MixingRules.mixing_type = 2; // Upper rule
     elementID = 1;
     swap = byterevers(elementID);
     moov->RulesContainer.MixingRules.element_ID = swap;
     key_elem = 2;
     swap = byterevers(key_elem);
     moov->RulesContainer.MixingRules.key_elem_ID = swap;
-    strcpy(moov->RulesContainer.MixingRules.mix_description, "Upper rule");
+    strcpy(moov->RulesContainer.MixingRules.mix_description, "Lower rule");
+    printf("Rule 2: Lower rule between channel %d and %d\n",elementID,key_elem);
+ //   strcpy(moov->RulesContainer.MixingRules.mix_description, "Equivalence rule");
+  //  printf("Rule 2: Equivalence rule\n");
     
     //Rule container
     u32 sizeRUCO = 12 + sizeRUSC + sizeRUMX;
@@ -1029,138 +1011,16 @@
     moov->MovieHeaderBox.pre_defined[3] = 0;
     moov->MovieHeaderBox.pre_defined[4] = 0;
     moov->MovieHeaderBox.pre_defined[5] = 0;
-    //    moov->MovieHeaderBox.next_track_ID = getnextID();
     swap = byterevers (totaltracks + 1);
     moov->MovieHeaderBox.next_track_ID = swap;
     
     //MovieBox
     u32 sizeMOOV = sizeMVHD + sizeTRAK + sizePRCO + sizeRUCO + 8;
-    printf("Size moovie: %d, size trak: %d\n",sizeMOOV, sizeTRAK);
     swap = byterevers (sizeMOOV); //Size movie: Taking into account number tracks
     moov->size = swap;
     swap = byterevers ('moov');
     moov->type = swap;
 }
-/*
-void groupscontainer(MovieBox *moov){
-    
-    int num, flg, i, j, numelem;
-    char selectmode, groupname[30];
-    char* fmt = "%[^\n]%*c";
-    
-    printf("Define the number of groups:\n");
-    fflush(stdin);
-    scanf("%d",&num);
-    
-    moov->GroupContainerBox.num_groups = num;
-    
-    for (i=0; i<num; i++) {
-        
-        printf("Select mode of group %d:\n",i+1);
-        printf("Mode |   Display  |   Edit\n");
-        printf("---- |   -------  |   ----\n");
-        printf(" 1   |   disable  |   disable\n");
-        printf(" 2   |   enable   |   disable\n");
-        scanf("%d",&flg);
-        getchar();
-        fflush(stdin);
-        
-        moov->GroupContainerBox.GroupBox[i].flags = flg;  
-        moov->GroupContainerBox.GroupBox[i].group_ID = 2147483648 + 1; // From 0x80000000 to 0xFFFFFFFF
-
-        printf("Enter the name for group %d:\n", i+1);
-        scanf(fmt,moov->GroupContainerBox.GroupBox[i].group_name);
-        strcpy(groupname,moov->GroupContainerBox.GroupBox[i].group_name);
-        
-        printf("Enter a brief description for group %s:\n", groupname);
-        scanf(fmt,moov->GroupContainerBox.GroupBox[i].group_description);
-        moov->GroupContainerBox.GroupBox[i].num_elements = numelem;
-        
-        printf("Number of elements involved in group %d:\n", i+1);
-        fflush(stdin);
-        scanf("%d",&numelem);
-
-                
-        for (j=0; j<numelem; j++) {
-            printf("Enter name for element %d of group %s\n",j+1,groupname);
-            scanf("%s",moov->GroupContainerBox.GroupBox[i].element_ID[j]);
-           // moov->GroupContainerBox.GroupBox[i].element_ID[j] = getelemID(); //Can be track or group
-        }
-        //printf("Select group activation mode:\n");
-        //scanf("%d",selectmode);
-        selectmode = 0;
-        moov->GroupContainerBox.GroupBox[i].group_activation_mode = selectmode; //Depends on rules. For now just 0.
-     //   if (selectmode == 2) {
-     //       moov->GroupContainerBox.GroupBox[i].group_activation_elements_number = 0;
-     //   }
-        moov->GroupContainerBox.GroupBox[i].group_reference_volume = 1;
-    }
-
-}
-*/
-/*
-void metadata(MetaBox *meta){
-
-    int find = 0, i, j;
-    char coc[4]; 
-    
-    meta->theHandler.pre_defined = 0;
-    printf("Enter type of metadata:\n");
-    printf("'soun' 'hint' 'meta'\n");
-    fflush(stdin);
-    scanf("%s", &coc);
-    while (find == 0) {
-        if (strcmp("soun", coc)==0) {
-            meta->theHandler.handler_type = 'soun';
-            find = 1;
-        }
-        if (strcmp("hint", coc)==0) {
-            meta->theHandler.handler_type = 'hint';
-            find = 1;
-        }
-        if (strcmp("meta", coc)==0) {
-            meta->theHandler.handler_type = 'meta';
-            find = 1;
-        }
-        if (find == 0) {
-            printf("Type unknown, please enter type:\n");
-            printf("'soun' 'hint' 'meta'\n");
-            scanf("%s", &coc);
-        }
-    }
-    printf("%d\n", meta->theHandler.handler_type);
-    meta->theHandler.reserved[0] = 0;
-    meta->theHandler.reserved[1] = 0;
-    meta->theHandler.reserved[2] = 0;
-    printf("Name:\n");
-    fflush(stdin);
-    scanf("%s", meta->theHandler.name);
-    //In case items are stored online: 
-    //meta->dinfo = ....;
-    
-    //Item location box
-    //Size = Index_Size(4), base_offset_size(4),length(4),offset(4) = 16 bits
-    //Each one has size 0, 4 or 8.
-    //Assume same size for all = 8.It can be different
-    meta->ItemLocationBox.Size = 0x4444;
-    meta->ItemLocationBox.item_count = 0;
-    for (i=0; i<meta->ItemLocationBox.item_count; i++) {
-        //Check the value!!! I don't understand.
-        meta->ItemLocationBox.c_method = 0x0001; //=0 Taken from field, 1(idat) or 2(item)
-    }
-    //These values have to be rechecked 
-    meta->ItemLocationBox.data_reference_index = 0; //In this file
-    meta->ItemLocationBox.base_offset = 0; //Check value!!!
-    meta->ItemLocationBox.extent_count = 1; 
-    for (j=0; j<meta->ItemLocationBox.extent_count; j++) {
-        meta->ItemLocationBox.extent_index = 1;
-    }
-    meta->ItemLocationBox.extent_offset = 0;
-    meta->ItemLocationBox.extent_length = 0;
-    
-    //Rest of the parameters
-}
-*/
 
 void writemoovbox(MovieBox moov, int numtrack,int totaltracks, FILE *imf){
     //Write movie box//
@@ -1428,7 +1288,7 @@
     fwrite(&moov.RulesContainer.MixingRules.mixing_type,sizeof(unsigned char), 1, imf);
     fwrite(&moov.RulesContainer.MixingRules.element_ID, sizeof(u32), 1, imf);
     fwrite(&moov.RulesContainer.MixingRules.key_elem_ID, sizeof(u32), 1, imf);
-    for(i=0; i<11; i++){
+    for(i=0; i<17; i++){
         fwrite(&moov.RulesContainer.MixingRules.mix_description[i],
                sizeof(char), 1, imf);
     }
--- a/IM_AF Encoder/IM_AM Encoder/string.g.h	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * string.h
- *
- * Definitions for memory and string functions.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.1.1.1 $
- * $Author: brandon6684 $
- * $Date: 2001/12/18 22:54:03 $
- *
- */
-/* Appropriated for Reactos Crtdll by Ariadne */
-/* changed prototype for _strerror */
-/* moved prototype for swab from string.h to stdlib.h */
-
-
-#ifndef _STRING_H_
-#define	_STRING_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-    
-    /*
-     * Define size_t, wchar_t and NULL
-     */
-#define __need_size_t
-#define __need_wchar_t
-#define	__need_NULL
-#include <crtdll/stddef.h>
-    
-    char * ___strtok; // removed extern specifier 02-06-98, BD
-    
-    /*
-     * Prototypes of the ANSI Standard C library string functions.
-     */
-    void*	memchr (const void* p, int cSearchFor, size_t sizeSearch);
-    int 	memcmp (const void* p1, const void* p2, size_t sizeSearch);
-    void* 	memcpy (void* pCopyTo, const void* pSource, size_t sizeSource);
-    void*	memmove (void* pMoveTo, const void* pSource, size_t sizeSource);
-    void*	memset (void* p, int cFill, size_t sizeRepeatCount);
-    char*	strcat (char* szAddTo, const char* szAdd);
-    char*	strchr (const char* szSearch, int cFor);
-    int	strcmp (const char* sz1, const char* sz2);
-    int	strcoll (const char* sz1, const char* sz2); /* Compare using locale */
-    char*	strcpy (char* szCopyTo, const char* szSource);
-    size_t	strcspn (const char* szGetPrefix, const char* szNotIncluding);
-    char*	strerror (int nError); /* NOTE: NOT an old name wrapper. */
-    char *  _strerror(const char *s);
-    size_t	strlen (const char* sz);
-    size_t	strnlen (const char* sz, size_t count); // not exported
-    char*	strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
-    int	strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-    char*	strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
-    char*	strpbrk (const char* szSearch, const char* szAnyOf);
-    char*	strrchr (const char* szSearch, int cFor);
-    size_t	strspn (const char* szGetPrefix, const char *szIncluding);
-    char*	strstr (const char* szSearch, const char *szFor);
-    char*	strtok (char* szTokenize, const char* szDelimiters);
-    size_t	strxfrm (char* szTransformed, const char *szSource,
-                     size_t sizeTransform);
-    
-#ifndef __STRICT_ANSI__
-    /*
-     * Extra non-ANSI functions provided by the CRTDLL library
-     */
-    void*	_memccpy (void* pCopyTo, const void* pSource, int cTerminator,
-                      size_t sizeMaxCopy);
-    int 	_memicmp (const void* p1, const void* p2, size_t sizeSearch);
-    char* 	_strdup (const char *szDuplicate);
-    int	_strcmpi (const char* sz1, const char* sz2);
-    int	_stricmp (const char* sz1, const char* sz2);
-    int	_stricoll (const char* sz1, const char* sz2);
-    char*	_strlwr (char* szToConvert);
-    int	_strnicmp (const char* sz1, const char* sz2,
-                   size_t sizeMaxCompare);
-    char*	_strnset (char* szToFill, int cFill, size_t sizeMaxFill);
-    char*	_strrev (char* szToReverse);
-    char*	_strset (char* szToFill, int cFill);
-    char*	_strupr (char* szToConvert);
-    
-    
-#endif	/* Not __STRICT_ANSI__ */
-    
-    
-    /*
-     * Unicode versions of the standard calls.
-     */
-    wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd);
-    wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor);
-    int	wcscmp (const wchar_t* ws1, const wchar_t* ws2);
-    int	wcscoll (const wchar_t* ws1, const wchar_t* ws2);
-    wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource);
-    size_t	wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding);
-    /* Note: No wcserror in CRTDLL. */
-    size_t	wcslen (const wchar_t* ws);
-    wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd);
-    int	wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare);
-    wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource,
-                     size_t sizeMaxCopy);
-    wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf);
-    wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor);
-    size_t	wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding);
-    wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor);
-    wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters);
-    size_t	wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource,
-                    size_t sizeTransform);
-    
-    
-#ifndef	__STRICT_ANSI__
-    /*
-     * Unicode versions of non-ANSI functions provided by CRTDLL.
-     */
-    
-    /* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
-#define		_wcscmpi	_wcsicmp
-    
-    wchar_t* _wcsdup (const wchar_t* wsToDuplicate);
-    int	_wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
-    int	_wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
-    wchar_t* _wcslwr (wchar_t* wsToConvert);
-    int	_wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
-                   size_t sizeMaxCompare);
-    wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
-    wchar_t* _wcsrev (wchar_t* wsToReverse);
-    wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill);
-    wchar_t* _wcsupr (wchar_t* wsToConvert);
-    
-#endif	/* Not __STRICT_ANSI__ */
-    
-    
-#ifndef	__STRICT_ANSI__
-#ifndef	_NO_OLDNAMES
-    
-    /*
-     * Non-underscored versions of non-ANSI functions. They live in liboldnames.a
-     * and provide a little extra portability. Also a few extra UNIX-isms like
-     * strcasecmp.
-     */
-    
-    void*	memccpy (void* pCopyTo, const void* pSource, int cTerminator,
-                     size_t sizeMaxCopy);
-    int	memicmp (const void* p1, const void* p2, size_t sizeSearch);
-#define	strdup(szDuplicate)	_strdup(szDuplicate)
-    int	strcmpi (const char* sz1, const char* sz2);
-    int	stricmp (const char* sz1, const char* sz2);
-    int	strcasecmp (const char* sz1, const char* sz2);
-    int	stricoll (const char* sz1, const char* sz2);
-    char*	strlwr (char* szToConvert);
-    int	strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-    int	strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
-    char*	strnset (char* szToFill, int cFill, size_t sizeMaxFill);
-    char*	strrev (char* szToReverse);
-    char*	strset (char* szToFill, int cFill);
-    char*	strupr (char* szToConvert);
-    
-    
-    /* NOTE: There is no _wcscmpi, but this is for compatibility. */
-    int	wcscmpi	(const wchar_t* ws1, const wchar_t* ws2);
-    wchar_t* wcsdup (const wchar_t* wsToDuplicate);
-    int	wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
-    int	wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
-    wchar_t* wcslwr (wchar_t* wsToConvert);
-    int	wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
-                  size_t sizeMaxCompare);
-    wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
-    wchar_t* wcsrev (wchar_t* wsToReverse);
-    wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill);
-    wchar_t* wcsupr (wchar_t* wsToConvert);
-    
-#endif	/* Not _NO_OLDNAMES */
-#endif	/* Not strict ANSI */
-    
-#endif
-    
-#ifdef __cplusplus
-}; /* extern "c" */
-#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IM_AF Encoder/string.h	Sun Aug 26 13:39:26 2012 +0100
@@ -0,0 +1,192 @@
+/*
+ * string.h
+ *
+ * Definitions for memory and string functions.
+ *
+ * This file is part of the Mingw32 package.
+ *
+ * Contributors:
+ *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
+ *
+ *  THIS SOFTWARE IS NOT COPYRIGHTED
+ *
+ *  This source code is offered for use in the public domain. You may
+ *  use, modify or distribute it freely.
+ *
+ *  This code is distributed in the hope that it will be useful but
+ *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
+ *  DISCLAMED. This includes but is not limited to warranties of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $Revision: 1.1.1.1 $
+ * $Author: brandon6684 $
+ * $Date: 2001/12/18 22:54:03 $
+ *
+ */
+/* Appropriated for Reactos Crtdll by Ariadne */
+/* changed prototype for _strerror */
+/* moved prototype for swab from string.h to stdlib.h */
+
+
+#ifndef _STRING_H_
+#define	_STRING_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+    
+    /*
+     * Define size_t, wchar_t and NULL
+     */
+#define __need_size_t
+#define __need_wchar_t
+#define	__need_NULL
+#include <crtdll/stddef.h>
+    
+    char * ___strtok; // removed extern specifier 02-06-98, BD
+    
+    /*
+     * Prototypes of the ANSI Standard C library string functions.
+     */
+    void*	memchr (const void* p, int cSearchFor, size_t sizeSearch);
+    int 	memcmp (const void* p1, const void* p2, size_t sizeSearch);
+    void* 	memcpy (void* pCopyTo, const void* pSource, size_t sizeSource);
+    void*	memmove (void* pMoveTo, const void* pSource, size_t sizeSource);
+    void*	memset (void* p, int cFill, size_t sizeRepeatCount);
+    char*	strcat (char* szAddTo, const char* szAdd);
+    char*	strchr (const char* szSearch, int cFor);
+    int	strcmp (const char* sz1, const char* sz2);
+    int	strcoll (const char* sz1, const char* sz2); /* Compare using locale */
+    char*	strcpy (char* szCopyTo, const char* szSource);
+    size_t	strcspn (const char* szGetPrefix, const char* szNotIncluding);
+    char*	strerror (int nError); /* NOTE: NOT an old name wrapper. */
+    char *  _strerror(const char *s);
+    size_t	strlen (const char* sz);
+    size_t	strnlen (const char* sz, size_t count); // not exported
+    char*	strncat (char* szAddTo, const char* szAdd, size_t sizeMaxAdd);
+    int	strncmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+    char*	strncpy (char* szCopyTo, const char* szSource, size_t sizeMaxCopy);
+    char*	strpbrk (const char* szSearch, const char* szAnyOf);
+    char*	strrchr (const char* szSearch, int cFor);
+    size_t	strspn (const char* szGetPrefix, const char *szIncluding);
+    char*	strstr (const char* szSearch, const char *szFor);
+    char*	strtok (char* szTokenize, const char* szDelimiters);
+    size_t	strxfrm (char* szTransformed, const char *szSource,
+                     size_t sizeTransform);
+    
+#ifndef __STRICT_ANSI__
+    /*
+     * Extra non-ANSI functions provided by the CRTDLL library
+     */
+    void*	_memccpy (void* pCopyTo, const void* pSource, int cTerminator,
+                      size_t sizeMaxCopy);
+    int 	_memicmp (const void* p1, const void* p2, size_t sizeSearch);
+    char* 	_strdup (const char *szDuplicate);
+    int	_strcmpi (const char* sz1, const char* sz2);
+    int	_stricmp (const char* sz1, const char* sz2);
+    int	_stricoll (const char* sz1, const char* sz2);
+    char*	_strlwr (char* szToConvert);
+    int	_strnicmp (const char* sz1, const char* sz2,
+                   size_t sizeMaxCompare);
+    char*	_strnset (char* szToFill, int cFill, size_t sizeMaxFill);
+    char*	_strrev (char* szToReverse);
+    char*	_strset (char* szToFill, int cFill);
+    char*	_strupr (char* szToConvert);
+    
+    
+#endif	/* Not __STRICT_ANSI__ */
+    
+    
+    /*
+     * Unicode versions of the standard calls.
+     */
+    wchar_t* wcscat (wchar_t* wsAddTo, const wchar_t* wsAdd);
+    wchar_t* wcschr (const wchar_t* wsSearch, wchar_t wcFor);
+    int	wcscmp (const wchar_t* ws1, const wchar_t* ws2);
+    int	wcscoll (const wchar_t* ws1, const wchar_t* ws2);
+    wchar_t* wcscpy (wchar_t* wsCopyTo, const wchar_t* wsSource);
+    size_t	wcscspn (const wchar_t* wsGetPrefix, const wchar_t* wsNotIncluding);
+    /* Note: No wcserror in CRTDLL. */
+    size_t	wcslen (const wchar_t* ws);
+    wchar_t* wcsncat (wchar_t* wsAddTo, const wchar_t* wsAdd, size_t sizeMaxAdd);
+    int	wcsncmp(const wchar_t* ws1, const wchar_t* ws2, size_t sizeMaxCompare);
+    wchar_t* wcsncpy(wchar_t* wsCopyTo, const wchar_t* wsSource,
+                     size_t sizeMaxCopy);
+    wchar_t* wcspbrk(const wchar_t* wsSearch, const wchar_t* wsAnyOf);
+    wchar_t* wcsrchr(const wchar_t* wsSearch, wchar_t wcFor);
+    size_t	wcsspn(const wchar_t* wsGetPrefix, const wchar_t* wsIncluding);
+    wchar_t* wcsstr(const wchar_t* wsSearch, const wchar_t* wsFor);
+    wchar_t* wcstok(wchar_t* wsTokenize, const wchar_t* wsDelimiters);
+    size_t	wcsxfrm(wchar_t* wsTransformed, const wchar_t *wsSource,
+                    size_t sizeTransform);
+    
+    
+#ifndef	__STRICT_ANSI__
+    /*
+     * Unicode versions of non-ANSI functions provided by CRTDLL.
+     */
+    
+    /* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */
+#define		_wcscmpi	_wcsicmp
+    
+    wchar_t* _wcsdup (const wchar_t* wsToDuplicate);
+    int	_wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
+    int	_wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
+    wchar_t* _wcslwr (wchar_t* wsToConvert);
+    int	_wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
+                   size_t sizeMaxCompare);
+    wchar_t* _wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
+    wchar_t* _wcsrev (wchar_t* wsToReverse);
+    wchar_t* _wcsset (wchar_t* wsToFill, wchar_t wcToFill);
+    wchar_t* _wcsupr (wchar_t* wsToConvert);
+    
+#endif	/* Not __STRICT_ANSI__ */
+    
+    
+#ifndef	__STRICT_ANSI__
+#ifndef	_NO_OLDNAMES
+    
+    /*
+     * Non-underscored versions of non-ANSI functions. They live in liboldnames.a
+     * and provide a little extra portability. Also a few extra UNIX-isms like
+     * strcasecmp.
+     */
+    
+    void*	memccpy (void* pCopyTo, const void* pSource, int cTerminator,
+                     size_t sizeMaxCopy);
+    int	memicmp (const void* p1, const void* p2, size_t sizeSearch);
+#define	strdup(szDuplicate)	_strdup(szDuplicate)
+    int	strcmpi (const char* sz1, const char* sz2);
+    int	stricmp (const char* sz1, const char* sz2);
+    int	strcasecmp (const char* sz1, const char* sz2);
+    int	stricoll (const char* sz1, const char* sz2);
+    char*	strlwr (char* szToConvert);
+    int	strnicmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+    int	strncasecmp (const char* sz1, const char* sz2, size_t sizeMaxCompare);
+    char*	strnset (char* szToFill, int cFill, size_t sizeMaxFill);
+    char*	strrev (char* szToReverse);
+    char*	strset (char* szToFill, int cFill);
+    char*	strupr (char* szToConvert);
+    
+    
+    /* NOTE: There is no _wcscmpi, but this is for compatibility. */
+    int	wcscmpi	(const wchar_t* ws1, const wchar_t* ws2);
+    wchar_t* wcsdup (const wchar_t* wsToDuplicate);
+    int	wcsicmp (const wchar_t* ws1, const wchar_t* ws2);
+    int	wcsicoll (const wchar_t* ws1, const wchar_t* ws2);
+    wchar_t* wcslwr (wchar_t* wsToConvert);
+    int	wcsnicmp (const wchar_t* ws1, const wchar_t* ws2,
+                  size_t sizeMaxCompare);
+    wchar_t* wcsnset (wchar_t* wsToFill, wchar_t wcFill, size_t sizeMaxFill);
+    wchar_t* wcsrev (wchar_t* wsToReverse);
+    wchar_t* wcsset (wchar_t* wsToFill, wchar_t wcToFill);
+    wchar_t* wcsupr (wchar_t* wsToConvert);
+    
+#endif	/* Not _NO_OLDNAMES */
+#endif	/* Not strict ANSI */
+    
+#endif
+    
+#ifdef __cplusplus
+}; /* extern "c" */
+#endif
\ No newline at end of file
Binary file IM_AF Report/.DS_Store has changed
Binary file IM_AF Report/Content_v5.docx has changed
Binary file IM_AF Report/DestinationForm2012.doc has changed
Binary file IM_AF Report/IMAF presentationv2.pptx has changed
Binary file ISOFileFormat99SanJose.pdf has changed
Binary file IST_37_10_0233IMPlayer.pdf has changed
Binary file mp4Atoms code/.DS_Store has changed
--- a/mp4Atoms code/MP4Atoms.c	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,769 +0,0 @@
-/*
-This software module was originally developed by Apple Computer, Inc.
-in the course of development of MPEG-4. 
-This software module is an implementation of a part of one or 
-more MPEG-4 tools as specified by MPEG-4. 
-ISO/IEC gives users of MPEG-4 free license to this
-software module or modifications thereof for use in hardware 
-or software products claiming conformance to MPEG-4.
-Those intending to use this software module in hardware or software
-products are advised that its use may infringe existing patents.
-The original developer of this software module and his/her company,
-the subsequent editors and their companies, and ISO/IEC have no
-liability for use of this software module or modifications thereof
-in an implementation.
-Copyright is not released for non MPEG-4 conforming
-products. Apple Computer, Inc. retains full right to use the code for its own
-purpose, assign or donate the code to a third party and to
-inhibit third parties from using the code for non 
-MPEG-4 conforming products.
-This copyright notice must be included in all copies or
-derivative works. Copyright (c) 1999.
-*/
-/*
-	$Id: MP4Atoms.c,v 1.1.1.1 2003/12/24 00:52:30 mikeseven Exp $
-*/
-
-#include "MP4Atoms.h"
-#include <ctype.h>
-
-
-//static MP4AtomPtr MP4BaseAtomClassPtr = 0;
-
-char* MP4BaseAtomGetName( MP4AtomPtr self )
-{
-	return self->name;
-}
-
-void  MP4BaseAtomDestroy( MP4AtomPtr self )
-{
-	free( self );
-}
-
-MP4Err MP4BaseAtomCreateFromInputStream( MP4AtomPtr self, MP4AtomPtr proto, MP4InputStreamPtr inputStream )
-{
-	self->type = proto->type;
-	memcpy( self->uuid, proto->uuid, 16 );
-	self->size      = proto->size;
-	self->size64    = proto->size64;
-	self->bytesRead = proto->bytesRead;
-	self->streamOffset = proto->streamOffset;
-	return MP4NoErr;
-}
-
-MP4Err MP4CreateBaseAtom( MP4AtomPtr self )
-{
-	MP4Err err;
-	err = MP4NoErr;
-	
-//	if ( self == NULL )
-//		BAILWITHERROR( MP4BadParamErr )
-//	if ( MP4BaseAtomClassPtr == NULL )
-//	{
-//		MP4BaseAtomClassPtr = (MP4AtomPtr) calloc( 1, sizeof(MP4Atom) );
-//		TESTMALLOC( MP4BaseAtomClassPtr );
-//
-//		MP4BaseAtomClassPtr->name                = "base";
-//		MP4BaseAtomClassPtr->createFromInputStream = (cisfunc) baseAtomCreateFromInputStream;
-//		MP4BaseAtomClassPtr->getName             = baseAtomGetName;
-//		MP4BaseAtomClassPtr->destroy             = baseAtomDestroy;
-//		MP4BaseAtomClassPtr->super               = MP4BaseAtomClassPtr;
-//	}
-//	*self = *MP4BaseAtomClassPtr;
-//bail:
-	TEST_RETURN( err );
-
-	return err;
-}
-
-//static MP4FullAtomPtr MP4FullAtomClassPtr = 0;
-
-void  MP4FullAtomDestroy( MP4AtomPtr self )
-{
-	MP4BaseAtomDestroy( self );
-}
-
-MP4Err MP4FullAtomCreateFromInputStream( MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr inputStream )
-{
-	MP4FullAtomPtr self;
-	MP4Err err;
-	u32 val;
-	self = (MP4FullAtomPtr) s;
-
-	err = MP4BaseAtomCreateFromInputStream( s, proto, inputStream ); if (err) goto bail;
-	err = inputStream->read32( inputStream, &val, NULL ); if (err) goto bail;
-	DEBUG_SPRINTF( "atom version = %d", (val >> 24) );
-	DEBUG_SPRINTF( "atom flags = 0x%06x", (val & 0xFFFFFF) );
-	self->bytesRead += 4;
-	self->version = val >> 24;
-	self->flags = val & 0xffffff;
-bail:
-	TEST_RETURN( err );
-
-	return err;
-}
-
-MP4Err MP4CreateFullAtom( MP4AtomPtr s )
-{
-//	MP4FullAtomPtr self;
-	MP4Err err = MP4NoErr;
-//	self = (MP4FullAtomPtr) s;
-//	
-//	err = MP4NoErr;
-//	
-//	if ( MP4FullAtomClassPtr == NULL )
-//	{
-//		MP4FullAtomClassPtr = (MP4FullAtomPtr) calloc( 1, sizeof(MP4FullAtom) );
-//		TESTMALLOC( MP4FullAtomClassPtr );
-//		err = MP4CreateBaseAtom( (MP4AtomPtr) MP4FullAtomClassPtr ); if (err) goto bail;
-//		MP4FullAtomClassPtr->createFromInputStream = (cisfunc) fullAtomCreateFromInputStream;
-//		MP4FullAtomClassPtr->destroy = fullAtomDestroy;
-//		MP4FullAtomClassPtr->super     = (MP4AtomPtr) MP4FullAtomClassPtr;
-//		MP4FullAtomClassPtr->name      = "full";
-//		MP4FullAtomClassPtr->version   = 0;
-//		MP4FullAtomClassPtr->flags     = 0;
-//	}
-//	*self = *MP4FullAtomClassPtr;
-//bail:
-	TEST_RETURN( err );
-
-	return err;
-}
-
-MP4Err MP4CreateAtom( u32 atomType, MP4AtomPtr *outAtom, u32 extended_type )
-{
-	MP4Err err;
-	MP4AtomPtr newAtom;
-	
-	err = MP4NoErr;
-	
-	switch ( atomType )
-	{
-		case MP4HintTrackReferenceAtomType:
-		case MP4StreamDependenceAtomType:
-		case MP4ODTrackReferenceAtomType:
-		case MP4SyncTrackReferenceAtomType:
-			err = MP4CreateTrackReferenceTypeAtom( atomType, (MP4TrackReferenceTypeAtomPtr*) &newAtom );
-			break;
-			
-		case MP4FreeSpaceAtomType:
-		case MP4SkipAtomType:
-			err = MP4CreateFreeSpaceAtom( (MP4FreeSpaceAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MediaDataAtomType:
-			err = MP4CreateMediaDataAtom( (MP4MediaDataAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MovieAtomType:
-			err = MP4CreateMovieAtom( (MP4MovieAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MovieHeaderAtomType:
-			err = MP4CreateMovieHeaderAtom( (MP4MovieHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MediaHeaderAtomType:
-			err = MP4CreateMediaHeaderAtom( (MP4MediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4VideoMediaHeaderAtomType:
-			err = MP4CreateVideoMediaHeaderAtom( (MP4VideoMediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4SoundMediaHeaderAtomType:
-			err = MP4CreateSoundMediaHeaderAtom( (MP4SoundMediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MPEGMediaHeaderAtomType:
-			err = MP4CreateMPEGMediaHeaderAtom( (MP4MPEGMediaHeaderAtomPtr*) &newAtom );
-			break;
-		
-		case MP4ObjectDescriptorMediaHeaderAtomType:
-			err = MP4CreateObjectDescriptorMediaHeaderAtom( (MP4ObjectDescriptorMediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4ClockReferenceMediaHeaderAtomType:
-			err = MP4CreateClockReferenceMediaHeaderAtom( (MP4ClockReferenceMediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4SceneDescriptionMediaHeaderAtomType:
-			err = MP4CreateSceneDescriptionMediaHeaderAtom( (MP4SceneDescriptionMediaHeaderAtomPtr*) &newAtom );
-			break;
-
-		case MP4HintMediaHeaderAtomType:
-			err = MP4CreateHintMediaHeaderAtom( (MP4HintMediaHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4SampleTableAtomType:
-			err = MP4CreateSampleTableAtom( (MP4SampleTableAtomPtr*) &newAtom );
-			break;
-
-		case MP4DataInformationAtomType:
-			err = MP4CreateDataInformationAtom( (MP4DataInformationAtomPtr*) &newAtom );
-			break;
-
-		case MP4DataEntryURLAtomType:
-			err = MP4CreateDataEntryURLAtom( (MP4DataEntryURLAtomPtr*) &newAtom );
-			break;
-			
-		case MP4CopyrightAtomType:
-			err = MP4CreateCopyrightAtom( (MP4CopyrightAtomPtr*) &newAtom );
-			break;
-			
-		case MP4DataEntryURNAtomType:
-			err = MP4CreateDataEntryURNAtom( (MP4DataEntryURNAtomPtr*) &newAtom );
-			break;
-			
-		case MP4HandlerAtomType:
-			err = MP4CreateHandlerAtom( (MP4HandlerAtomPtr*) &newAtom );
-			break;
-			
-		case MP4ObjectDescriptorAtomType:
-			err = MP4CreateObjectDescriptorAtom( (MP4ObjectDescriptorAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackAtomType:
-			err = MP4CreateTrackAtom( (MP4TrackAtomPtr*) &newAtom );
-			break;
-
-		case MP4MPEGSampleEntryAtomType:
-			err = MP4CreateMPEGSampleEntryAtom( (MP4MPEGSampleEntryAtomPtr*) &newAtom );
-			break;
-
-		case MP4VisualSampleEntryAtomType:
-			err = MP4CreateVisualSampleEntryAtom( (MP4VisualSampleEntryAtomPtr*) &newAtom );
-			break;
-
-		case MP4AudioSampleEntryAtomType:
-			err = MP4CreateAudioSampleEntryAtom( (MP4AudioSampleEntryAtomPtr*) &newAtom );
-			break;
-
-		case MP4GenericSampleEntryAtomType:
-			err = MP4CreateGenericSampleEntryAtom( (MP4GenericSampleEntryAtomPtr*) &newAtom );
-			break;
-
-		case MP4EditAtomType:
-			err = MP4CreateEditAtom( (MP4EditAtomPtr*) &newAtom );
-			break;
-
-		case MP4UserDataAtomType:
-			err = MP4CreateUserDataAtom( (MP4UserDataAtomPtr*) &newAtom );
-			break;
-
-		case MP4DataReferenceAtomType:
-			err = MP4CreateDataReferenceAtom( (MP4DataReferenceAtomPtr*) &newAtom );
-			break;
-
-		case MP4SampleDescriptionAtomType:
-			err = MP4CreateSampleDescriptionAtom( (MP4SampleDescriptionAtomPtr*) &newAtom );
-			break;
-
-		case MP4TimeToSampleAtomType:
-			err = MP4CreateTimeToSampleAtom( (MP4TimeToSampleAtomPtr*) &newAtom );
-			break;
-
-		case MP4CompositionOffsetAtomType:
-			err = MP4CreateCompositionOffsetAtom( (MP4CompositionOffsetAtomPtr*) &newAtom );
-			break;
-
-		case MP4ShadowSyncAtomType:
-			err = MP4CreateShadowSyncAtom( (MP4ShadowSyncAtomPtr*) &newAtom );
-			break;
-
-		case MP4EditListAtomType:
-			err = MP4CreateEditListAtom( (MP4EditListAtomPtr*) &newAtom );
-			break;
-
-		case MP4SampleToChunkAtomType:
-			err = MP4CreateSampleToChunkAtom( (MP4SampleToChunkAtomPtr*) &newAtom );
-			break;
-
-		case MP4SampleSizeAtomType:
-		case MP4CompactSampleSizeAtomType:
-			err = MP4CreateSampleSizeAtom( (MP4SampleSizeAtomPtr*) &newAtom );
-			break;
-
-		case MP4ChunkOffsetAtomType:
-			err = MP4CreateChunkOffsetAtom( (MP4ChunkOffsetAtomPtr*) &newAtom );
-			break;
-
-		case MP4SyncSampleAtomType:
-			err = MP4CreateSyncSampleAtom( (MP4SyncSampleAtomPtr*) &newAtom );
-			break;
-			
-		case MP4DegradationPriorityAtomType:
-			err = MP4CreateDegradationPriorityAtom( (MP4DegradationPriorityAtomPtr*) &newAtom );
-			break;
-
-		case MP4ChunkLargeOffsetAtomType:
-			err = MP4CreateChunkLargeOffsetAtom( (MP4ChunkLargeOffsetAtomPtr*) &newAtom );
-			break;
-
-		case MP4ESDAtomType:
-			err = MP4CreateESDAtom( (MP4ESDAtomPtr*) &newAtom );
-			break;
-
-		case MP4MediaInformationAtomType:
-			err = MP4CreateMediaInformationAtom( (MP4MediaInformationAtomPtr*) &newAtom );
-			break;
-
-		case MP4TrackHeaderAtomType:
-			err = MP4CreateTrackHeaderAtom( (MP4TrackHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackReferenceAtomType:
-			err = MP4CreateTrackReferenceAtom( (MP4TrackReferenceAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MediaAtomType:
-			err = MP4CreateMediaAtom( (MP4MediaAtomPtr*) &newAtom );
-			break;
-			
-		case MP4PaddingBitsAtomType:
-			err = MP4CreatePaddingBitsAtom( (MP4PaddingBitsAtomPtr*) &newAtom );
-			break;
-		
-		case ISOFileTypeAtomType:
-			err = MJ2CreateFileTypeAtom( (ISOFileTypeAtomPtr*) &newAtom );
-			break;
-			
-		/* Movie Fragment stuff */
-		case MP4MovieExtendsAtomType:
-			err = MP4CreateMovieExtendsAtom( (MP4MovieExtendsAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackExtendsAtomType:
-			err = MP4CreateTrackExtendsAtom( (MP4TrackExtendsAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MovieFragmentAtomType:
-			err = MP4CreateMovieFragmentAtom( (MP4MovieFragmentAtomPtr*) &newAtom );
-			break;
-			
-		case MP4MovieFragmentHeaderAtomType:
-			err = MP4CreateMovieFragmentHeaderAtom( (MP4MovieFragmentHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackFragmentAtomType:
-			err = MP4CreateTrackFragmentAtom( (MP4TrackFragmentAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackFragmentHeaderAtomType:
-			err = MP4CreateTrackFragmentHeaderAtom( (MP4TrackFragmentHeaderAtomPtr*) &newAtom );
-			break;
-			
-		case MP4TrackRunAtomType:
-			err = MP4CreateTrackRunAtom( (MP4TrackRunAtomPtr*) &newAtom );
-			break;
-		
-/*		
-		case M2TSSampleEntryAtomType:
-			err = MP4CreateM2tsSampleEntryAtom( (M2tsSampleEntryAtomPtr*) &newAtom);
-			break;
-		case M2EncryptedTSSampleEntryAtomType:
-			err = MP4CreateM2tsSampleEntryAtom( (M2tsSampleEntryAtomPtr*) &newAtom);
-			newAtom->type = M2EncryptedTSSampleEntryAtomType;
-			break;
-*/
-
-		case MP4MetaAtomType:
-			err = MP4CreateMetaAtom( (MP4MetaAtomPtr*) &newAtom);
-			break;
-
-		case MP4ItemLocationAtomType:
-			err = MP4CreateItemLocationAtom( (MP4ItemLocationAtomPtr*) &newAtom);
-			break;
-
-		case MP4ItemInformationEntryAtomType:
-			err = MP4CreateItemInfoEntryAtom( (MP4ItemInfoEntryAtomPtr*) &newAtom);
-			break;
-
-		case MP4ItemInformationAtomType:
-			err = MP4CreateItemInfoAtom( (MP4ItemInfoAtomPtr*) &newAtom);
-			break;
-
-		case MP4XMLAtomType:
-			err = MP4CreateXMLAtom( (MP4XMLAtomPtr*) &newAtom);
-			break;
-
-		case MP4BinaryXMLAtomType:
-			err = MP4CreateBinaryXMLAtom( (MP4BinaryXMLAtomPtr*) &newAtom);
-			break;
-
-
-		case MPEG2TSReceptionSampleEntryAtomType:
-			err = MP4CreateMPEG2TSReceptionSampleEntryAtom( (MPEG2TSReceptionSampleEntryAtomPtr*) &newAtom);
-			break;
-		case ProtectedMPEG2TransportStreamEntryAtomType:
-			err = MP4CreateMPEG2TSReceptionSampleEntryAtom( (MPEG2TSReceptionSampleEntryAtomPtr*) &newAtom);
-			newAtom->type = ProtectedMPEG2TransportStreamEntryAtomType;
-			break;
-
-			
-		case PATAtomType:
-			err = MP4CreatePATAtom( (PATAtomPtr*) &newAtom);
-			break;
-
-		case PMTAtomType:
-			err = MP4CreatePMTAtom( (PMTAtomPtr*) &newAtom);
-			break;
-
-		case TSTimingAtomType:
-			err = MP4CreateTSTimingAtom( (TSTimingAtomPtr*) &newAtom);
-			break;
-
-
-		case ProtectionSchemeInfoAtomType:
-			err = MP4CreateProtectionSchemeInfoAtom( (ProtectionSchemeInfoAtomPtr*) &newAtom);
-			break;
-
-		case OriginalFormatAtomType:
-			err = MP4CreateOriginalFormatAtom( (OriginalFormatAtomPtr*) &newAtom);
-			break;
-
-		case PackageKeyInfoAtomType:
-			err = MP4CreatePackageKeyInfoAtom( (PackageKeyInfoAtomPtr*) &newAtom);
-			break;
-
-		case ControlWordInfoAtomType:
-			err = MP4CreateControlWordInfoAtom( (ControlWordInfoAtomPtr*) &newAtom);
-			break;
-
-		case KeyMessageReceptionSampleEntryAtomType:
-			err = MP4CreateKeyMessageReceptionSampleEntryAtom( (KeyMessageReceptionSampleEntryAtomPtr*) &newAtom);
-			break;
-
-		case GroupAtomType:
-			err = MP4CreateGroupAtom( (GroupAtomPtr*) &newAtom);
-			break;
-
-		case GroupContainerAtomType:
-			err = MP4CreateGroupContainerAtom( (GroupContainerAtomPtr*) &newAtom);
-			break;
-
-		case PresetAtomType:
-			err = MP4CreatePresetAtom( (PresetAtomPtr*) &newAtom);
-			break;
-
-		case PresetContainerAtomType:
-			err = MP4CreatePresetContainerAtom( (PresetContainerAtomPtr*) &newAtom);
-			break;
-
-		case SelectionRuleAtomType:
-			err = MP4CreateSelectionRuleAtom( (SelectionRuleAtomPtr*) &newAtom);
-			break;
-
-		case MixingRuleAtomType:
-			err = MP4CreateMixingRuleAtom( (MixingRuleAtomPtr*) &newAtom);
-			break;
-
-		case RuleContainerAtomType:
-			err = MP4CreateRuleContainerAtom( (RuleContainerAtomPtr*) &newAtom);
-			break;
-
-		case FontTableAtomType:
-			err = MP4CreateFontTableAtom( (FontTableAtomPtr*) &newAtom);
-			break;
-
-		case TextSampleEntryAtomType:
-			err = MP4CreateTextSampleEntryAtom( (TextSampleEntryAtomPtr*) &newAtom);
-			break;
-
-		case TextStyleAtomType:
-			err = MP4CreateTextStyleAtom( (TextStyleAtomPtr*) &newAtom);
-			break;
-
-		case TextHighlightAtomType:
-			err = MP4CreateTextHighlightAtom( (TextHighlightAtomPtr*) &newAtom);
-			break;
-
-		case TextHighlightColorAtomType:
-			err = MP4CreateTextHighlightColorAtom( (TextHighlightColorAtomPtr*) &newAtom);
-			break;
-
-		case TextKaraokeAtomType:
-			err = MP4CreateTextKaraokeAtom( (TextKaraokeAtomPtr*) &newAtom);
-			break;
-
-		case MP4ExtendedAtomType:
-			switch(extended_type)
-			{
-/*
-				case MP4ContentReferenceIDAtomType:
-					err = MP4CreateContentReferenceAtom( (MP4ContentReferenceIDAtomPtr*) &newAtom);
-					break;
-*/
-				default:
-					err = MP4CreateUnknownAtom( (MP4UnknownAtomPtr*) &newAtom );
-					break;
-			}
-			break;
-
-
-		default:
-			err = MP4CreateUnknownAtom( (MP4UnknownAtomPtr*) &newAtom );
-			break;
-	}
-	if ( err == MP4NoErr )
-		*outAtom = newAtom;
-	return err;
-}
-
-void MP4TypeToString( u32 inType, char* ioStr )
-{
-	u32 i;
-	int ch;
-	
-	for ( i = 0; i < 4; i++, ioStr++ )
-	{
-		ch = inType >> (8*(3-i)) & 0xff;
-		if ( isprint(ch) )
-			*ioStr = ch;
-		else
-			*ioStr = '.';
-	}
-	*ioStr = 0;
-}
-
-MP4Err MP4ParseAtomUsingProtoList( MP4InputStreamPtr inputStream, u32* protoList, u32 defaultAtom, MP4AtomPtr *outAtom  )
-{
-	MP4AtomPtr atomProto;
-	MP4Err     err;
-	long       bytesParsed;
-	MP4Atom	   protoAtom;
-	MP4AtomPtr newAtom;
-	char       typeString[ 8 ];
-	char       msgString[ 80 ];
-	u64        beginAvail;
-	u64        consumedBytes;
-	u32        useDefaultAtom;
-	u32		extended_type = 0;
-	
-	atomProto = &protoAtom;
-	err = MP4NoErr;
-	bytesParsed = 0L;
-	
-	if ((inputStream == NULL) || (outAtom == NULL) )
-		BAILWITHERROR( MP4BadParamErr )
-	*outAtom = NULL;
-	beginAvail = inputStream->available;
-	useDefaultAtom = 0;
-	inputStream->msg( inputStream, "{" );
-	inputStream->indent++;
-//	err = MP4CreateBaseAtom( atomProto ); if ( err ) goto bail;
-	
-	atomProto->streamOffset = inputStream->getStreamOffset( inputStream );
-
-	/* atom size */
-	err = inputStream->read32( inputStream, &atomProto->size, NULL ); if ( err ) goto bail;
-	if ( atomProto->size == 0 ) {
-		/* BAILWITHERROR( MP4NoQTAtomErr )  */
-		if(inputStream->available + 4 > 0xFFFFFFFF)
-			atomProto->size64 = inputStream->available + 4;
-		else
-			atomProto->size = (u32)inputStream->available + 4;
-	}
-	if( atomProto->size != 1)
-		if ((atomProto->size - 4) > inputStream->available)
-			BAILWITHERROR( MP4BadDataErr )
-	bytesParsed += 4L;
-	
-	sprintf( msgString, "atom size is %d", atomProto->size );
-	inputStream->msg( inputStream, msgString );
-
-	/* atom type */
-	err = inputStream->read32( inputStream, &atomProto->type, NULL ); if ( err ) goto bail;
-	bytesParsed += 4L;
-	MP4TypeToString( atomProto->type, typeString );
-	sprintf( msgString, "atom type is '%s'", typeString );
-
-	inputStream->msg( inputStream, msgString );
-	if ( atomProto->type == MP4ExtendedAtomType )
-	{
-		err = inputStream->readData( inputStream, 16, (char*) atomProto->uuid, NULL );	if ( err ) goto bail;
-		bytesParsed += 16L;
-		extended_type = MP4_FOUR_CHAR_CODE(atomProto->uuid[0], atomProto->uuid[1], atomProto->uuid[2], atomProto->uuid[3]);
-	}
-	
-	/* large atom */
-	if ( atomProto->size == 1 )
-	{
-		u32 size;
-		err = inputStream->read32( inputStream, &size, NULL ); if ( err ) goto bail;
-		//if ( size )
-		//	BAILWITHERROR( MP4NoLargeAtomSupportErr )
-		atomProto->size64 = size;
-        atomProto->size64 <<= 32;
-		err = inputStream->read32( inputStream, &size, NULL ); if ( err ) goto bail;
-		atomProto->size64 |= size;
-		//atomProto->size = size;
-		bytesParsed += 8L;
-	}
-
-	atomProto->bytesRead = bytesParsed;
-	if( atomProto->size != 1)
-		if ( ((long) atomProto->size) < bytesParsed )
-			BAILWITHERROR( MP4BadDataErr )
-	if ( protoList )
-	{
-		while ( *protoList  )
-		{
-			if ( *protoList == atomProto->type )
-				break;
-			protoList++;
-		}
-		if ( *protoList == 0 )
-		{
-			useDefaultAtom = 1;
-		}
-	}
-	err = MP4CreateAtom( useDefaultAtom ? defaultAtom : atomProto->type, &newAtom, extended_type ); if ( err ) goto bail;
-	sprintf( msgString, "atom name is '%s'", newAtom->name );
-	inputStream->msg( inputStream, msgString );
-	err = newAtom->createFromInputStream( newAtom, atomProto, (char*) inputStream ); if ( err ) goto bail;
-	consumedBytes = beginAvail - inputStream->available;
-	if ( consumedBytes != atomProto->size )
-	{
-		sprintf( msgString, "##### atom size is %d but parse used %d bytes ####", atomProto->size, consumedBytes );
-		inputStream->msg( inputStream, msgString );
-	}
-	*outAtom = newAtom;
-	inputStream->indent--;
-	inputStream->msg( inputStream, "}" );
-bail:
-	TEST_RETURN( err );
-
-	return err;
-}
-
-MP4Err MP4ParseAtom( MP4InputStreamPtr inputStream, MP4AtomPtr *outAtom  )
-{
-#if 0
-	MP4AtomPtr atomProto;
-	MP4Err     err;
-	long       bytesParsed;
-	MP4Atom	   protoAtom;
-	MP4AtomPtr newAtom;
-	char       typeString[ 8 ];
-	char       msgString[ 80 ];
-	u32        beginAvail;
-	u32        consumedBytes;
-	atomProto = &protoAtom;
-	err = MP4NoErr;
-	bytesParsed = 0L;
-	
-	if ((inputStream == NULL) || (outAtom == NULL) )
-		BAILWITHERROR( MP4BadParamErr )
-	*outAtom = NULL;
-	beginAvail = inputStream->available;
-
-	inputStream->msg( inputStream, "{" );
-	inputStream->indent++;
-	err = MP4CreateBaseAtom( atomProto ); if ( err ) goto bail;
-
-	/* atom size */
-	err = inputStream->read32( inputStream, &atomProto->size, NULL ); if ( err ) goto bail;
-	if ( atomProto->size == 0 ) {
-		/* BAILWITHERROR( MP4NoQTAtomErr )  */
-		atomProto->size = inputStream->available + 4;
-	}
-	
-	if ( (atomProto->size < 0) || ((atomProto->size - 4) > inputStream->available) )  BAILWITHERROR( MP4BadDataErr )
-	bytesParsed += 4L;
-	
-	sprintf( msgString, "atom size is %d", atomProto->size );
-	inputStream->msg( inputStream, msgString );
-
-	/* atom type */
-	err = inputStream->read32( inputStream, &atomProto->type, NULL ); if ( err ) goto bail;
-	bytesParsed += 4L;
-	MP4TypeToString( atomProto->type, typeString );
-	sprintf( msgString, "atom type is '%s'", typeString );
-	inputStream->msg( inputStream, msgString );
-	if ( atomProto->type == MP4ExtendedAtomType )
-	{
-		err = inputStream->readData( inputStream, 16, (char*) atomProto->uuid, NULL );	if ( err ) goto bail;
-		bytesParsed += 16L;
-	}
-	
-	/* large atom */
-	if ( atomProto->size == 1 )
-	{
-		u32 size;
-		err = inputStream->read32( inputStream, &size, NULL ); if ( err ) goto bail;
-		if ( size )
-			BAILWITHERROR( MP4NoLargeAtomSupportErr )
-		atomProto->size64 = size;
-        atomProto->size64 <<= 32;
-		err = inputStream->read32( inputStream, &size, NULL ); if ( err ) goto bail;
-		atomProto->size64 |= size;
-		atomProto->size = size;
-		bytesParsed += 8L;
-	}
-
-	atomProto->bytesRead = bytesParsed;
-	if ( atomProto->size - bytesParsed < 0 )
-		BAILWITHERROR( MP4BadDataErr )
-	err = MP4CreateAtom( atomProto->type, &newAtom ); if ( err ) goto bail;
-	sprintf( msgString, "atom name is '%s'", newAtom->name );
-	inputStream->msg( inputStream, msgString );
-	err = newAtom->createFromInputStream( newAtom, atomProto, (char*) inputStream ); if ( err ) goto bail;
-	consumedBytes = beginAvail - inputStream->available;
-	if ( consumedBytes != atomProto->size )
-	{
-		sprintf( msgString, "##### atom size is %d but parse used %d bytes ####", atomProto->size, consumedBytes );
-		inputStream->msg( inputStream, msgString );
-	}
-	*outAtom = newAtom;
-	inputStream->indent--;
-	inputStream->msg( inputStream, "}" );
-bail:
-	TEST_RETURN( err );
-#else
-	MP4Err err = MP4ParseAtomUsingProtoList( inputStream, NULL, 0, outAtom  );
-
-#endif
-	return err;
-}
-
-MP4Err MP4CalculateBaseAtomFieldSize( struct MP4Atom* self )
-{
-	self->size = 8;
-	return MP4NoErr;
-}
-
-MP4Err MP4CalculateFullAtomFieldSize( struct MP4FullAtom* self )
-{
-	MP4Err err = MP4CalculateBaseAtomFieldSize( (MP4AtomPtr) self );
-	self->size += 4;
-	return err;
-}
-
-MP4Err MP4SerializeCommonBaseAtomFields( struct MP4Atom* self, char* buffer )
-{
-	MP4Err err;
-	err = MP4NoErr;
-	self->bytesWritten = 0;
-	if( !self->size ) BAILWITHERROR(MP4BadDataErr)
-	if( !self->type ) BAILWITHERROR(MP4BadDataErr)
-	PUT32( size );
-	PUT32( type );
-bail:
-	TEST_RETURN( err );
-
-	return err;
-}
-
-MP4Err MP4SerializeCommonFullAtomFields( struct MP4FullAtom* self, char* buffer )
-{
-	MP4Err err;
-	err = MP4SerializeCommonBaseAtomFields( (MP4AtomPtr) self, buffer ); if (err) goto bail;
-	buffer += self->bytesWritten;
-	PUT8( version );
-	PUT24( flags );
-bail:
-	TEST_RETURN( err );
-
-	return err;
-}
--- a/mp4Atoms code/MP4Atoms.h	Thu Jul 26 16:52:19 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1486 +0,0 @@
-/*
-This software module was originally developed by Apple Computer, Inc.
-in the course of development of MPEG-4. 
-This software module is an implementation of a part of one or 
-more MPEG-4 tools as specified by MPEG-4. 
-ISO/IEC gives users of MPEG-4 free license to this
-software module or modifications thereof for use in hardware 
-or software products claiming conformance to MPEG-4.
-Those intending to use this software module in hardware or software
-products are advised that its use may infringe existing patents.
-The original developer of this software module and his/her company,
-the subsequent editors and their companies, and ISO/IEC have no
-liability for use of this software module or modifications thereof
-in an implementation.
-Copyright is not released for non MPEG-4 conforming
-products. Apple Computer, Inc. retains full right to use the code for its own
-purpose, assign or donate the code to a third party and to
-inhibit third parties from using the code for non 
-MPEG-4 conforming products.
-This copyright notice must be included in all copies or
-derivative works. Copyright (c) 1999.
-*/
-/*
-	$Id: MP4Atoms.h,v 1.1.1.1 2003/12/24 00:52:30 mikeseven Exp $
-*/
-
-#ifndef INCLUDED_MP4ATOMS_H
-#define INCLUDED_MP4ATOMS_H
-
-#include "MP4Movies.h"
-#include "MP4Impl.h"
-#include "MP4InputStream.h"
-#include "MP4LinkedList.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ISOErr MP4GetCurrentTime( u64 *outTime );
-
-enum
-{
-	MP4AudioSampleEntryAtomType            = MP4_FOUR_CHAR_CODE( 'm', 'p', '4', 'a' ),
-	MP4ChunkLargeOffsetAtomType            = MP4_FOUR_CHAR_CODE( 'c', 'o', '6', '4' ),
-	MP4ChunkOffsetAtomType                 = MP4_FOUR_CHAR_CODE( 's', 't', 'c', 'o' ),
-	MP4ClockReferenceMediaHeaderAtomType   = MP4_FOUR_CHAR_CODE( 'c', 'r', 'h', 'd' ),
-	MP4CompositionOffsetAtomType           = MP4_FOUR_CHAR_CODE( 'c', 't', 't', 's' ),
-	MP4CopyrightAtomType                   = MP4_FOUR_CHAR_CODE( 'c', 'p', 'r', 't' ),
-	MP4DataEntryURLAtomType                = MP4_FOUR_CHAR_CODE( 'u', 'r', 'l', ' ' ),
-	MP4DataEntryURNAtomType                = MP4_FOUR_CHAR_CODE( 'u', 'r', 'n', ' ' ),
-	MP4DataInformationAtomType             = MP4_FOUR_CHAR_CODE( 'd', 'i', 'n', 'f' ),
-	MP4DataReferenceAtomType               = MP4_FOUR_CHAR_CODE( 'd', 'r', 'e', 'f' ),
-	MP4DegradationPriorityAtomType         = MP4_FOUR_CHAR_CODE( 's', 't', 'd', 'p' ),
-	MP4ESDAtomType                         = MP4_FOUR_CHAR_CODE( 'e', 's', 'd', 's' ),
-	MP4EditAtomType                        = MP4_FOUR_CHAR_CODE( 'e', 'd', 't', 's' ),
-	MP4EditListAtomType                    = MP4_FOUR_CHAR_CODE( 'e', 'l', 's', 't' ),
-	MP4ExtendedAtomType                    = MP4_FOUR_CHAR_CODE( 'u', 'u', 'i', 'd' ),
-	MP4FreeSpaceAtomType                   = MP4_FOUR_CHAR_CODE( 'f', 'r', 'e', 'e' ),
-	MP4GenericSampleEntryAtomType		   = MP4_FOUR_CHAR_CODE( '!', 'g', 'n', 'r' ),
-	MP4HandlerAtomType                     = MP4_FOUR_CHAR_CODE( 'h', 'd', 'l', 'r' ),
-	MP4HintMediaHeaderAtomType             = MP4_FOUR_CHAR_CODE( 'h', 'm', 'h', 'd' ),
-	MP4HintTrackReferenceAtomType          = MP4_FOUR_CHAR_CODE( 'h', 'i', 'n', 't' ),
-	MP4MPEGMediaHeaderAtomType             = MP4_FOUR_CHAR_CODE( 'n', 'm', 'h', 'd' ),
-	MP4MPEGSampleEntryAtomType             = MP4_FOUR_CHAR_CODE( 'm', 'p', '4', 's' ),
-	MP4MediaAtomType                       = MP4_FOUR_CHAR_CODE( 'm', 'd', 'i', 'a' ),
-	MP4MediaDataAtomType                   = MP4_FOUR_CHAR_CODE( 'm', 'd', 'a', 't' ),
-	MP4MediaHeaderAtomType                 = MP4_FOUR_CHAR_CODE( 'm', 'd', 'h', 'd' ),
-	MP4MediaInformationAtomType            = MP4_FOUR_CHAR_CODE( 'm', 'i', 'n', 'f' ),
-	MP4MovieAtomType                       = MP4_FOUR_CHAR_CODE( 'm', 'o', 'o', 'v' ),
-	MP4MovieHeaderAtomType                 = MP4_FOUR_CHAR_CODE( 'm', 'v', 'h', 'd' ),
-	MP4ObjectDescriptorAtomType            = MP4_FOUR_CHAR_CODE( 'i', 'o', 'd', 's' ),
-	MP4ObjectDescriptorMediaHeaderAtomType = MP4_FOUR_CHAR_CODE( 'o', 'd', 'h', 'd' ),
-	MP4ODTrackReferenceAtomType            = MP4_FOUR_CHAR_CODE( 'm', 'p', 'o', 'd' ),
-	MP4SampleDescriptionAtomType           = MP4_FOUR_CHAR_CODE( 's', 't', 's', 'd' ),
-	MP4SampleSizeAtomType                  = MP4_FOUR_CHAR_CODE( 's', 't', 's', 'z' ),
-	MP4CompactSampleSizeAtomType           = MP4_FOUR_CHAR_CODE( 's', 't', 'z', '2' ),
-	MP4SampleTableAtomType                 = MP4_FOUR_CHAR_CODE( 's', 't', 'b', 'l' ),
-	MP4SampleToChunkAtomType               = MP4_FOUR_CHAR_CODE( 's', 't', 's', 'c' ),
-	MP4SceneDescriptionMediaHeaderAtomType = MP4_FOUR_CHAR_CODE( 's', 'd', 'h', 'd' ),
-	MP4ShadowSyncAtomType                  = MP4_FOUR_CHAR_CODE( 's', 't', 's', 'h' ),
-	MP4SkipAtomType                        = MP4_FOUR_CHAR_CODE( 's', 'k', 'i', 'p' ),
-	MP4SoundMediaHeaderAtomType            = MP4_FOUR_CHAR_CODE( 's', 'm', 'h', 'd' ),
-	MP4StreamDependenceAtomType            = MP4_FOUR_CHAR_CODE( 'd', 'p', 'n', 'd' ),
-	MP4SyncSampleAtomType                  = MP4_FOUR_CHAR_CODE( 's', 't', 's', 's' ),
-	MP4SyncTrackReferenceAtomType          = MP4_FOUR_CHAR_CODE( 's', 'y', 'n', 'c' ),
-	MP4TimeToSampleAtomType                = MP4_FOUR_CHAR_CODE( 's', 't', 't', 's' ),
-	MP4TrackAtomType                       = MP4_FOUR_CHAR_CODE( 't', 'r', 'a', 'k' ),
-	MP4TrackHeaderAtomType                 = MP4_FOUR_CHAR_CODE( 't', 'k', 'h', 'd' ),
-	MP4TrackReferenceAtomType              = MP4_FOUR_CHAR_CODE( 't', 'r', 'e', 'f' ),
-	MP4UserDataAtomType                    = MP4_FOUR_CHAR_CODE( 'u', 'd', 't', 'a' ),
-	MP4VideoMediaHeaderAtomType            = MP4_FOUR_CHAR_CODE( 'v', 'm', 'h', 'd' ),
-	MP4VisualSampleEntryAtomType           = MP4_FOUR_CHAR_CODE( 'm', 'p', '4', 'v' ),
-	MP4PaddingBitsAtomType                 = MP4_FOUR_CHAR_CODE( 'p', 'a', 'd', 'b' ),
-	MP4MovieExtendsAtomType                = MP4_FOUR_CHAR_CODE( 'm', 'v', 'e', 'x' ),
-	MP4TrackExtendsAtomType                = MP4_FOUR_CHAR_CODE( 't', 'r', 'e', 'x' ),
-	MP4MovieFragmentAtomType               = MP4_FOUR_CHAR_CODE( 'm', 'o', 'o', 'f' ),
-	MP4MovieFragmentHeaderAtomType         = MP4_FOUR_CHAR_CODE( 'm', 'f', 'h', 'd' ),
-	MP4TrackFragmentAtomType               = MP4_FOUR_CHAR_CODE( 't', 'r', 'a', 'f' ),
-	MP4TrackFragmentHeaderAtomType         = MP4_FOUR_CHAR_CODE( 't', 'f', 'h', 'd' ),
-	MP4TrackRunAtomType    		           = MP4_FOUR_CHAR_CODE( 't', 'r', 'u', 'n' ),
-
-	ISOFileTypeAtomType					   = MP4_FOUR_CHAR_CODE( 'f', 't', 'y', 'p' ),
-
-	MP4MetaAtomType						   = MP4_FOUR_CHAR_CODE( 'm', 'e', 't', 'a' ),
-	MP4PrimaryItemAtomType				   = MP4_FOUR_CHAR_CODE( 'p', 'i', 't', 'm' ),
-	MP4ItemLocationAtomType				   = MP4_FOUR_CHAR_CODE( 'i', 'l', 'o', 'c' ),
-	MP4ItemProtectionAtomType			   = MP4_FOUR_CHAR_CODE( 'i', 'p', 'r', 'o' ),
-	MP4ItemInformationEntryAtomType		   = MP4_FOUR_CHAR_CODE( 'i', 'n', 'f', 'e' ),
-	MP4ItemInformationAtomType			   = MP4_FOUR_CHAR_CODE( 'i', 'i', 'n', 'f' ),
-	MP4IPMPControlAtomType				   = MP4_FOUR_CHAR_CODE( 'i', 'p', 'm', 'c' ),
-	MP4XMLAtomType						   = MP4_FOUR_CHAR_CODE( 'x', 'm', 'l', ' ' ),
-	MP4BinaryXMLAtomType				   = MP4_FOUR_CHAR_CODE( 'b', 'x', 'm', 'l' ),
-
-	MPEG2TSReceptionSampleEntryAtomType = MP4_FOUR_CHAR_CODE('r', 'm', '2', 't'),
-	ProtectedMPEG2TransportStreamEntryAtomType = MP4_FOUR_CHAR_CODE('p', 'm', '2', 't'),
-	PATAtomType = MP4_FOUR_CHAR_CODE('t', 'P', 'A', 'T'),
-	PMTAtomType = MP4_FOUR_CHAR_CODE('t', 'P', 'M', 'T'),
-	TSTimingAtomType = MP4_FOUR_CHAR_CODE('t', 's', 't', 'i'),
-
-	OriginalFormatAtomType = MP4_FOUR_CHAR_CODE('f', 'r', 'm', 'a'),
-	ProtectionSchemeInfoAtomType = MP4_FOUR_CHAR_CODE('s', 'i', 'n', 'f'),
-
-	PackageKeyInfoAtomType = MP4_FOUR_CHAR_CODE('p', 'k', 'i', 'b'),
-	ControlWordInfoAtomType = MP4_FOUR_CHAR_CODE('c', 'w', 'i', 'b'),
-	KeyMessageReceptionSampleEntryAtomType = MP4_FOUR_CHAR_CODE('k', 'e', 'y', 'm'),
-
-	GroupAtomType = MP4_FOUR_CHAR_CODE('g', 'r', 'u', 'p'),
-	GroupContainerAtomType = MP4_FOUR_CHAR_CODE('g', 'r', 'c', 'o'),
-	PresetAtomType = MP4_FOUR_CHAR_CODE('p', 'r', 's', 't'),
-	PresetContainerAtomType = MP4_FOUR_CHAR_CODE('p', 'r', 'c', 'o'),
-	SelectionRuleAtomType = MP4_FOUR_CHAR_CODE('r', 'u', 's', 'c'),
-	MixingRuleAtomType = MP4_FOUR_CHAR_CODE('r', 'u', 'm', 'x'),
-	RuleContainerAtomType = MP4_FOUR_CHAR_CODE('r', 'u', 'c', 'o'),
-	TextSampleEntryAtomType = MP4_FOUR_CHAR_CODE('t', 'x', '3', 'g'),
-	FontTableAtomType = MP4_FOUR_CHAR_CODE('f', 't', 'a', 'b'),
-	TextStyleAtomType =  MP4_FOUR_CHAR_CODE('s', 't', 'y', 'l'),
-	TextHighlightAtomType =  MP4_FOUR_CHAR_CODE('h', 'l', 'i', 't'),
-	TextHighlightColorAtomType =  MP4_FOUR_CHAR_CODE('h', 'c', 'l', 'r'),
-	TextKaraokeAtomType =  MP4_FOUR_CHAR_CODE('k', 'r', 'o', 'k'),
-};
-
-#define MP4_BASE_ATOM    \
-	u32	   type;         \
-	u8   uuid[16];       \
-	u32    size;         \
-	u64    size64;       \
-	u32    bytesRead;    \
-	u32    bytesWritten; \
-	u64	  streamOffset; \
-	char   *name;        \
-	struct MP4Atom* super; \
-	MP4Err (*createFromInputStream)( struct MP4Atom* self, struct MP4Atom* proto, /*struct MP4InputStreamRecord* */ char *inputStream ); \
-	char*  (*getName)( struct MP4Atom* self ); \
-	MP4Err (*serialize)( struct MP4Atom* self, char* buffer ); \
-	MP4Err (*calculateSize)( struct MP4Atom* self ); \
-	void   (*destroy)( struct MP4Atom* self );
-
-#define MP4_FULL_ATOM \
-	MP4_BASE_ATOM     \
-	u32 version;      \
-	u32 flags;
-
-
-typedef struct MP4Atom
-{
-	MP4_BASE_ATOM
-} MP4Atom, *MP4AtomPtr;
-
-typedef struct MP4FullAtom
-{
-	MP4_FULL_ATOM
-} MP4FullAtom, *MP4FullAtomPtr;
-
-typedef MP4Err (*cisfunc)( struct MP4Atom* self, struct MP4Atom* proto, char *inputStream );
-
-typedef struct MP4PrivateMovieRecord
-{
-      u32  referenceCount;
-      struct FileMappingObjectRecord *fileMappingObject;
-      struct MP4InputStreamRecord *inputStream;
-      MP4AtomPtr moovAtomPtr;		/* might be a moof or a moov */
-      MP4AtomPtr true_moov;
-      
-      MP4AtomPtr mdat;				/* first, primary, mdat */
-      MP4LinkedList mdatList;		/* all the others we find */
-      /*MP4Track initialBIFS;*/
-      /*MP4Track initialOD; */
-      u32 fileType;					/* the file type: MPEG-4, Motion JPEG-2000, or QuickTime */
-      MP4AtomPtr ftyp;              /* the file type atom */
-	  MP4AtomPtr jp2h;              /* for JPEG-2000, the JP2 header atom */
-	  MP4AtomPtr sgnt;              /* for JPEG-2000, the signature atom */
-      void *inMemoryDataHandler;
-      MP4Handle prepend_handle;
-      MP4LinkedList	movieFragments;
-	  /*default sync track when, reading (set by the user)*/
-	  u32 defaultSyncTrackID;
-
-	  MP4AtomPtr meta;
-
-	  u32 NextItemId;
-
-} MP4PrivateMovieRecord, *MP4PrivateMovieRecordPtr;
-
-MP4Err MP4CreateAtom( u32 atomType, MP4AtomPtr *outAtom, u32 extended_type );
-MP4Err MP4CreateBaseAtom( MP4AtomPtr self );
-MP4Err MP4CreateFullAtom( MP4AtomPtr s );
-MP4Err MP4ParseAtom( struct MP4InputStreamRecord* inputStream, MP4AtomPtr *outAtom );
-MP4Err MP4ParseAtomUsingProtoList( struct MP4InputStreamRecord* inputStream, u32* protoList, u32 defaultAtom, MP4AtomPtr *outAtom  );
-MP4Err MP4SerializeCommonBaseAtomFields( struct MP4Atom* self, char* buffer );
-MP4Err MP4SerializeCommonFullAtomFields( struct MP4FullAtom* self, char* buffer );
-MP4Err MP4CalculateBaseAtomFieldSize( struct MP4Atom* self );
-MP4Err MP4CalculateFullAtomFieldSize( struct MP4FullAtom* self );
-
-char* MP4BaseAtomGetName( MP4AtomPtr self );
-void  MP4BaseAtomDestroy( MP4AtomPtr self );
-typedef struct MP4InputStreamRecord *MP4InputStreamPtr2;
-MP4Err MP4BaseAtomCreateFromInputStream( MP4AtomPtr self, MP4AtomPtr proto, MP4InputStreamPtr2 inputStream );
-MP4Err MP4FullAtomCreateFromInputStream( MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr2 inputStream );
-void  MP4FullAtomDestroy( MP4AtomPtr self );
-
-void MP4TypeToString( u32 inType, char* ioStr );
-
-typedef struct MP4MediaDataAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*addData)( struct MP4MediaDataAtom *self, MP4Handle dataH );
-	MP4Err (*writeToFile)( struct MP4MediaDataAtom *self, FILE *fd );
-	MP4Err (*addMdat)( struct MP4MediaDataAtom *self, struct MP4MediaDataAtom *other_mdat );
-
-	char *data;
-	u64 dataSize;
-	u64 dataOffset;
-} MP4MediaDataAtom, *MP4MediaDataAtomPtr;
-
-typedef struct MP4UnknownAtom
-{
-	MP4_BASE_ATOM
-	char *data;
-	u32 dataSize;
-} MP4UnknownAtom, *MP4UnknownAtomPtr;
-
-#define COMMON_MOVIE_ATOM_FIELDS \
-	MP4Err (*mdatMoved)( struct MP4MovieAtom* self, u64 mdatBase, u64 mdatEnd, u64 mdatOffset ); \
-	MP4Err (*calculateDuration)( struct MP4MovieAtom* self ); \
-	\
-	MP4AtomPtr iods;	
-	/* the initial object descriptor */
-
-typedef struct MP4MovieAtom
-{
-	MP4_BASE_ATOM
-	COMMON_MOVIE_ATOM_FIELDS
-	MP4Err (*setupTracks)( struct MP4MovieAtom* self, MP4PrivateMovieRecordPtr moov );
-	u32    (*getTrackCount)( struct MP4MovieAtom* self );
-	MP4Err (*getIndTrack)( struct MP4MovieAtom* self, u32 trackNumber, MP4AtomPtr *outTrack );
-	MP4Err (*addAtom)( struct MP4MovieAtom* self, MP4AtomPtr atom );
-	MP4Err (*getNextTrackID)( struct MP4MovieAtom* self, u32 *outID );
-	MP4Err (*addTrack)( struct MP4MovieAtom* self, MP4AtomPtr track );
-	MP4Err (*newTrack)( struct MP4MovieAtom* self, u32 newTrackFlags, MP4AtomPtr *outTrack );
-	MP4Err (*newTrackWithID)( struct MP4MovieAtom* self, u32 newTrackFlags, u32 newTrackID, MP4AtomPtr *outTrack );
-	MP4Err (*setTimeScale)( struct MP4MovieAtom* self, u32 timeScale );
-	MP4Err (*getTimeScale)( struct MP4MovieAtom* self, u32 *outTimeScale );
-	MP4Err (*setMatrix)( struct MP4MovieAtom* self, u32 matrix[9] );
-	MP4Err (*getMatrix)( struct MP4MovieAtom* self, u32 outMatrix[9] );
-	MP4Err (*setPreferredRate)( struct MP4MovieAtom* self, u32 rate );
-	MP4Err (*getPreferredRate)( struct MP4MovieAtom* self, u32 *outRate );
-	MP4Err (*setPreferredVolume)( struct MP4MovieAtom* self, s16 volume );
-	MP4Err (*getPreferredVolume)( struct MP4MovieAtom* self, s16 *outVolume );
-	MP4Err (*settrackfragment) (struct MP4MovieAtom *self, u32 trackID, MP4AtomPtr fragment );
-	MP4Err (*getTrackExtendsAtom)( struct MP4MovieAtom* self, u32 trackID, MP4AtomPtr *outTrack );
-	MP4Err (*getTrackMedia)( struct MP4MovieAtom* self, u32 trackID, MP4AtomPtr *outMedia );
-	MP4Err (*mdatArrived)( struct MP4MovieAtom *self, MP4AtomPtr mdat );
-	MP4Err (*getSampleDescriptionIndex)(struct MP4MovieAtom *self, u32 trackID, u32* sd_index );
-
-	MP4AtomPtr mvhd;              /* the movie header */
-	MP4AtomPtr udta;		      /* user data */
-	MP4AtomPtr mvex;			  /* movie extends atom */
-	MP4PrivateMovieRecordPtr moov;
-	MP4LinkedList atomList;
-	MP4LinkedList trackList;
-
-	MP4AtomPtr grco;
-	MP4AtomPtr prco;
-	MP4AtomPtr ruco;
-} MP4MovieAtom, *MP4MovieAtomPtr;
-
-typedef struct MP4MovieHeaderAtom
-{
-	MP4_FULL_ATOM
-	u64	creationTime;
-	u64	modificationTime;
-	u32 timeScale;
-	u64 duration;
-	u32 preferredRate;
-	u32 preferredVolume;
-	char reserved[10];
-	u32	matrixA;
-	u32 matrixB;
-	u32 matrixU;
-	u32 matrixC;
-	u32 matrixD;
-	u32 matrixV;
-	u32 matrixX;
-	u32 matrixY;
-	u32 matrixW;
-	u32 pre_defined1;
-	u32 pre_defined2;
-	u32 pre_defined3;
-	u32 pre_defined4;
-	u32 pre_defined5;
-	u32 pre_defined6;
-	u32	nextTrackID;
-} MP4MovieHeaderAtom, *MP4MovieHeaderAtomPtr;
-
-typedef struct MP4ObjectDescriptorAtom
-{
-	MP4_FULL_ATOM
-    MP4Err (*setDescriptor)( struct MP4Atom* self, /*struct MP4DescriptorRecord */ char * desc );
-	u32  ODSize;
-	struct MP4DescriptorRecord* descriptor;
-} MP4ObjectDescriptorAtom, *MP4ObjectDescriptorAtomPtr;
-
-typedef struct MP4TrackAtom
-{
-	MP4_BASE_ATOM
-	MP4PrivateMovieRecordPtr moov;
-	MP4Err (*addAtom)( struct MP4TrackAtom* self, MP4AtomPtr atom );
-	MP4Err (*setMoov)( struct MP4TrackAtom *self, MP4PrivateMovieRecordPtr moov );
-	MP4Err (*setMdat)( struct MP4TrackAtom *self, MP4AtomPtr mdat );
-	MP4Err (*newMedia)( struct MP4TrackAtom *self, MP4Media *outMedia, u32 mediaType, u32 timeScale, MP4Handle dataURL );
-	MP4Err (*setEnabled)( struct MP4TrackAtom *self, u32 enabled );
-	MP4Err (*getEnabled)( struct MP4TrackAtom *self, u32 *outEnabled );
-	MP4Err (*calculateDuration)( struct MP4TrackAtom *self, u32 movieTimeScale );
-	MP4Err (*getDuration)( struct MP4TrackAtom *self, u32 *outDuration );
-	MP4Err (*setMatrix)( struct MP4TrackAtom* self, u32 matrix[9] );
-	MP4Err (*getMatrix)( struct MP4TrackAtom* self, u32 outMatrix[9] );
-	MP4Err (*setLayer)( struct MP4TrackAtom* self, s16 layer );
-	MP4Err (*getLayer)( struct MP4TrackAtom* self, s16 *outLayer );
-	MP4Err (*setDimensions)( struct MP4TrackAtom* self, u32 width, u32 height );
-	MP4Err (*getDimensions)( struct MP4TrackAtom* self, u32 *outWidth, u32 *outHeight );
-	MP4Err (*setVolume)( struct MP4TrackAtom* self, s16 volume );
-	MP4Err (*getVolume)( struct MP4TrackAtom* self, s16 *outVolume );
-	MP4Err (*mdatMoved)( struct MP4TrackAtom* self, u64 mdatBase, u64 mdatEnd, u64 mdatOffset );
-	MP4Err (*mdatArrived)( struct MP4TrackAtom *self, MP4AtomPtr mdat );
-	MP4Err (*settrackfragment) (struct MP4TrackAtom *self, u32 trackID, MP4AtomPtr fragment );
-
-	u32 newTrackFlags;
-	MP4AtomPtr mdat;
-	MP4AtomPtr udta;
-	MP4AtomPtr trackHeader;
-	MP4AtomPtr trackMedia;
-	MP4AtomPtr trackEditAtom;
-	MP4AtomPtr trackReferences;
-	MP4LinkedList atomList;
-} MP4TrackAtom, *MP4TrackAtomPtr;
-
-typedef struct MP4TrackHeaderAtom
-{
-	MP4_FULL_ATOM
-	u64	creationTime;
-	u64	modificationTime;
-	u32 trackID;
-	u32 reserved1;
-	u64 duration;
-	char reserved2[8];
-	u32 layer;
-	u32 alternateGroup;
-	u32	volume;
-	u32 reserved3;
-	u32	matrixA;
-	u32 matrixB;
-	u32 matrixU;
-	u32 matrixC;
-	u32 matrixD;
-	u32 matrixV;
-	u32 matrixX;
-	u32 matrixY;
-	u32 matrixW;
-	u32 trackWidth;
-	u32 trackHeight;
-} MP4TrackHeaderAtom, *MP4TrackHeaderAtomPtr;
-
-typedef struct MP4TrackReferenceAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*addAtom)( struct MP4TrackReferenceAtom *self, MP4AtomPtr atom );
-	MP4Err (*findAtomOfType)( struct MP4TrackReferenceAtom *self, u32 atomType, MP4AtomPtr *outAtom );
-	MP4LinkedList atomList;
-} MP4TrackReferenceAtom, *MP4TrackReferenceAtomPtr;
-
-typedef struct MP4MediaAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*setupNew)( struct MP4MediaAtom *self, MP4AtomPtr track, u32 mediaType, u32 timeScale, MP4Handle dataHandlerH );
-	MP4Err (*addSampleReference)( struct MP4MediaAtom *self, u64 dataOffset, u32 sampleCount,
-				    MP4Handle durationsH, MP4Handle sizesH, MP4Handle sampleEntryH,
-				    MP4Handle decodingOffsetsH, MP4Handle syncSamplesH, MP4Handle padsH );
-	MP4Err (*addSamples)( struct MP4MediaAtom *self, MP4Handle sampleH, u32 sampleCount,
-				    MP4Handle durationsH, MP4Handle sizesH, MP4Handle sampleEntryH,
-				    MP4Handle decodingOffsetsH, MP4Handle syncSamplesH, MP4Handle padsH );
-	MP4Err (*calculateDuration)( struct MP4MediaAtom *self );
-	MP4Err (*mdatMoved)( struct MP4MediaAtom* self, u64 mdatBase, u64 mdatEnd, u64 mdatOffset );
-	MP4Err (*setfieldsize)( struct MP4MediaAtom* self, u32 fieldsize );
-	MP4Err (*settrackfragment) (struct MP4MediaAtom *self, MP4AtomPtr fragment );
-	
-	
-	MP4AtomPtr mediaTrack;
-	MP4AtomPtr mediaHeader;
-	MP4AtomPtr handler;
-	MP4AtomPtr information;		/* might be a minf or traf */
-	MP4LinkedList atomList;
-	MP4AtomPtr	true_minf;
-} MP4MediaAtom, *MP4MediaAtomPtr;
-
-typedef struct MP4MediaHeaderAtom
-{
-	MP4_FULL_ATOM
-	u64	creationTime;
-	u64	modificationTime;
-	u32 timeScale;
-	u64 duration;
-	u32 packedLanguage;
-	u32	pre_defined;
-} MP4MediaHeaderAtom, *MP4MediaHeaderAtomPtr;
-
-typedef struct MP4HandlerAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*setName)( struct MP4Atom* s, char* name);
-	u32 nameLength;
-	u32	pre_defined;
-	u32	handlerType;
-	u32 reserved1;
-	u32 reserved2;
-	u32 reserved3;
-	char *nameUTF8;
-} MP4HandlerAtom, *MP4HandlerAtomPtr;
-
-#define COMMON_MINF_ATOM_FIELDS \
-	MP4Err (*addSampleReference)( struct MP4MediaInformationAtom *self, u64 dataOffset, u32 sampleCount, \
-				    MP4Handle durationsH, MP4Handle sizesH, MP4Handle sampleEntryH, \
-				    MP4Handle decodingOffsetsH, MP4Handle syncSamplesH, MP4Handle padsH ); \
-	MP4Err (*addSamples)( struct MP4MediaInformationAtom *self, MP4Handle sampleH, \
-					u32 sampleCount, MP4Handle durationsH, MP4Handle sizesH, \
-					MP4Handle sampleEntryH, \
-				    MP4Handle decodingOffsetsH, MP4Handle syncSamplesH, MP4Handle padsH ); \
-	MP4Err (*mdatMoved)( struct MP4MediaInformationAtom* self, u64 mdatBase, u64 mdatEnd, u64 mdatOffset );
-
-typedef struct MP4MediaInformationAtom
-{
-	MP4_FULL_ATOM
-	COMMON_MINF_ATOM_FIELDS
-	MP4Err (*closeDataHandler)( MP4AtomPtr self );
-	MP4Err (*openDataHandler)( MP4AtomPtr self, u32 dataEntryIndex );
-	MP4Err (*setupNewMedia)( struct MP4MediaInformationAtom *self, u32 mediaType, MP4Handle dataH, MP4AtomPtr mdat );
-	MP4Err (*getMediaDuration)( struct MP4MediaInformationAtom *self, u32 *outDuration );
-	MP4Err (*setfieldsize)( struct MP4MediaInformationAtom* self, u32 fieldsize);
-	MP4Err (*testDataEntry)( struct MP4MediaInformationAtom *self, u32 dataEntryIndex );
-	MP4Err (*mdatArrived)( struct MP4MediaInformationAtom *self, MP4AtomPtr mdat );
-	MP4AtomPtr dataInformation;
-	MP4AtomPtr sampleTable;
-	MP4AtomPtr mediaHeader;
-	struct MP4InputStreamRecord* inputStream;
-	void       *dataHandler;
-	u32         dataEntryIndex;
-	MP4LinkedList atomList;
-} MP4MediaInformationAtom, *MP4MediaInformationAtomPtr;
-
-typedef struct MP4VideoMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-	u32 graphicsMode;
-	u32 opColorRed;
-	u32 opColorGreen;
-	u32 opColorBlue;
-} MP4VideoMediaHeaderAtom, *MP4VideoMediaHeaderAtomPtr;
-
-typedef struct MP4SoundMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-	u32 balance;
-	u32 reserved;
-} MP4SoundMediaHeaderAtom, *MP4SoundMediaHeaderAtomPtr;
-
-typedef struct MP4HintMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-	u32	maxPDUSize;
-	u32 avgPDUSize;
-	u32 maxBitrate;
-	u32 avgBitrate;
-	u32 slidingAverageBitrate;
-} MP4HintMediaHeaderAtom, *MP4HintMediaHeaderAtomPtr;
-
-typedef struct MP4MPEGMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-} MP4MPEGMediaHeaderAtom, *MP4MPEGMediaHeaderAtomPtr;
-
-typedef struct MP4ObjectDescriptorMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-} MP4ObjectDescriptorMediaHeaderAtom, *MP4ObjectDescriptorMediaHeaderAtomPtr;
-
-typedef struct MP4ClockReferenceMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-} MP4ClockReferenceMediaHeaderAtom, *MP4ClockReferenceMediaHeaderAtomPtr;
-
-typedef struct MP4SceneDescriptionMediaHeaderAtom
-{
-	MP4_FULL_ATOM
-} MP4SceneDescriptionMediaHeaderAtom, *MP4SceneDescriptionMediaHeaderAtomPtr;
-
-typedef struct MP4DataInformationAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*getOffset)( struct MP4DataInformationAtom *self, u32 dataReferenceIndex, u64 *outOffset );
-	MP4Err (*addSampleReference)( struct MP4DataInformationAtom *self, u32 sampleCount, u32 dataReferenceIndex, u64 dataOffset, MP4Handle sizesH );
-	MP4Err (*addSamples)( struct MP4DataInformationAtom *self, u32 sampleCount, u32 dataReferenceIndex, MP4Handle sampleH );
-	MP4Err (*addAtom)( struct MP4DataInformationAtom *self, MP4AtomPtr atom );
-
-	MP4AtomPtr dataReference;
-	MP4LinkedList atomList;
-} MP4DataInformationAtom, *MP4DataInformationAtomPtr;
-
-#define COMMON_DATAENTRY_ATOM_FIELDS \
-	MP4Err (*getOffset)( struct MP4DataEntryAtom *self, u64 *outOffset ); \
-	MP4Err (*addSampleReference)( struct MP4DataEntryAtom *self, u64 dataOffset, MP4Handle sizesH ); \
-	MP4Err (*addSamples)( struct MP4DataEntryAtom *self, MP4Handle sampleH ); \
-	\
-	MP4AtomPtr mdat; \
-	u64   offset; \
-	u32   locationLength; \
-	char* location;
-
-typedef struct MP4DataEntryAtom
-{
-	MP4_FULL_ATOM
-	COMMON_DATAENTRY_ATOM_FIELDS
-} MP4DataEntryAtom, *MP4DataEntryAtomPtr;
-
-typedef struct MP4DataEntryURLAtom
-{
-	MP4_FULL_ATOM
-	COMMON_DATAENTRY_ATOM_FIELDS
-} MP4DataEntryURLAtom, *MP4DataEntryURLAtomPtr;
-
-typedef struct MP4DataEntryURNAtom
-{
-	MP4_FULL_ATOM
-	COMMON_DATAENTRY_ATOM_FIELDS
-	u32   nameLength;
-	char* nameURN;
-} MP4DataEntryURNAtom, *MP4DataEntryURNAtomPtr;
-
-typedef struct MP4DataReferenceAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*addDataEntry)( struct MP4DataReferenceAtom *self, MP4AtomPtr entry );
-	MP4Err (*getOffset)( struct MP4DataReferenceAtom *self, u32 dataReferenceIndex, u64 *outOffset );
-	MP4Err (*addSampleReference)( struct MP4DataReferenceAtom *self, u32 sampleCount, u32 dataReferenceIndex, u64 dataOffset, MP4Handle sizesH );
-	MP4Err (*addSamples)( struct MP4DataReferenceAtom *self, u32 sampleCount, u32 dataReferenceIndex, MP4Handle sampleH );
-	u32    (*getEntryCount)( struct MP4DataReferenceAtom *self );
-	MP4Err (*getEntry)( struct MP4DataReferenceAtom *self, u32 dataReferenceIndex, struct MP4DataEntryAtom **outEntry );	
-	MP4LinkedList atomList;
-
-} MP4DataReferenceAtom, *MP4DataReferenceAtomPtr;
-
-typedef struct MP4SampleTableAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*setupNew)( struct MP4SampleTableAtom *self );
-	MP4Err (*calculateDuration)( struct MP4SampleTableAtom *self, u32 *outDuration );
-	MP4Err (*setSampleEntry)( struct MP4SampleTableAtom *self, MP4AtomPtr entry );
-	MP4Err (*getCurrentDataReferenceIndex)( struct MP4SampleTableAtom *self, u32 *outDataReferenceIndex );
-	MP4Err (*addSamples)( struct MP4SampleTableAtom *self,
-							u32 sampleCount, u64 sampleOffset, MP4Handle durationsH,
-							MP4Handle sizesH, MP4Handle compositionOffsetsH, 
-							MP4Handle syncSamplesH, MP4Handle padsH, MP4Handle sampleEntryH );
-    MP4Err (*setfieldsize)( struct MP4SampleTableAtom* self, u32 fieldsize);
-    u32    (*getCurrentSampleEntryIndex)( struct MP4SampleTableAtom *self );
-	MP4Err (*setDefaultSampleEntry)( struct MP4SampleTableAtom *self, u32 index );
-
-    
-	MP4AtomPtr TimeToSample;
-	MP4AtomPtr CompositionOffset;
-	MP4AtomPtr SyncSample;
-	MP4AtomPtr SampleDescription;
-	MP4AtomPtr SampleSize;
-	MP4AtomPtr SampleToChunk;
-	MP4AtomPtr ChunkOffset;
-	MP4AtomPtr ShadowSync;
-	MP4AtomPtr DegradationPriority;
-	MP4AtomPtr PaddingBits;
-
-	MP4LinkedList atomList;
-	
-	MP4AtomPtr currentSampleEntry;
-	u32		   currentSampleEntryIndex;
-
-} MP4SampleTableAtom, *MP4SampleTableAtomPtr;
-
-typedef struct
-{
-	u32 sampleCount;
-	s32 sampleDuration;
-} sttsEntry, *sttsEntryPtr;
-
-typedef struct MP4TimeToSampleAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*getTimeForSampleNumber)( MP4AtomPtr self, u32 sampleNumber, u64 *outSampleCTS, s32 *outSampleDuration );
-	MP4Err (*findSamples)( MP4AtomPtr self, u64 desiredTime,
-							s64 *outPriorSample, s64 *outExactSample, s64 *outNextSample,
-							u32 *outSampleNumber, s32 *outSampleDuration );
-	MP4Err (*getTotalDuration)( struct MP4TimeToSampleAtom *self, u32 *outDuration );
-	MP4Err (*addSamples)( struct MP4TimeToSampleAtom *self, u32 sampleCount, MP4Handle durationsH );
-	
-	MP4LinkedList entryList;
-	void *currentEntry;
-	void *foundEntry;
-	u32   foundEntryNumber;
-	u32   foundEntrySampleNumber;
-	u64   foundEntryTime;
-} MP4TimeToSampleAtom, *MP4TimeToSampleAtomPtr;
-
-typedef struct MP4CompositionOffsetAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*addSamples)(struct MP4CompositionOffsetAtom *self, u32 sampleNumber,  u32 sampleCount, MP4Handle offsetsH );
-	MP4Err (*getOffsetForSampleNumber)( MP4AtomPtr self, u32 sampleNumber, s32 *outOffset );
-	MP4LinkedList entryList;
-	void *currentEntry;
-	u32 finalSampleNumber;
-} MP4CompositionOffsetAtom, *MP4CompositionOffsetAtomPtr;
-
-#define COMMON_SAMPLE_ENTRY_FIELDS \
-	char reserved1[ 6 ];		   \
-	u32 dataReferenceIndex;
-
-typedef struct GenericSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	MP4AtomPtr ESDAtomPtr;
-} GenericSampleEntryAtom, *GenericSampleEntryAtomPtr;
-
-typedef struct MP4GenericSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	char *data;
-	u32 dataSize;
-} MP4GenericSampleEntryAtom, *MP4GenericSampleEntryAtomPtr;
-
-typedef struct MP4MPEGSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	MP4AtomPtr ESDAtomPtr;
-} MP4MPEGSampleEntryAtom, *MP4MPEGSampleEntryAtomPtr;
-
-typedef struct MP4VisualSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	MP4AtomPtr ESDAtomPtr;
-	char	  reserved2[ 16 ];     /* uint(32)[4] */
-	/* u32			reserved3;         uint(32) = 0x01400f0 */
-	u32			width;
-	u32			height;
-	u32        reserved4;          /* uint(32) = 0x0048000 */
-	u32			reserved5;			/* uint(32) = 0x0048000 */
-	u32			reserved6; /* uint(32) = 0 */
-	u32			reserved7;           /* uint(16) = 1 */
-	u32			nameLength;
-	char		name31[31];
-	u32			reserved8; /* uint(16) = 24 */
-	s32			reserved9; /* int(16) = -1 */
-	
-} MP4VisualSampleEntryAtom, *MP4VisualSampleEntryAtomPtr;
-
-typedef struct MP4AudioSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	MP4AtomPtr ESDAtomPtr;
-	char	  reserved2[ 8 ];     /* uint(32)[2] */
-	u32			nChannels;         /* uint(16) = 2 */
-	u32			nBitsPerSample;          /* uint(16) = 16 */
-	u32			reserved5;			/* uint(32) = 0 */
-	u32			timeScale;			/* uint(16) copied from track! */
-	u32			reserved6; /* uint(16) = 0 */
-	
-} MP4AudioSampleEntryAtom, *MP4AudioSampleEntryAtomPtr;
-
-typedef struct MP4SampleDescriptionAtom
-{
-	MP4_FULL_ATOM
-
-	MP4Err (*addEntry)( struct MP4SampleDescriptionAtom *self, MP4AtomPtr entry );
-	u32    (*getEntryCount)( struct MP4SampleDescriptionAtom *self );
-	MP4Err (*getEntry)( struct MP4SampleDescriptionAtom *self, u32 entryNumber,  struct GenericSampleEntryAtom **outEntry );
-
-	MP4LinkedList atomList;
-} MP4SampleDescriptionAtom, *MP4SampleDescriptionAtomPtr;
-
-
-typedef struct MP4ESDAtom
-{
-	MP4_FULL_ATOM
-	u32 descriptorLength;
-	struct MP4DescriptorRecord* descriptor;
-} MP4ESDAtom, *MP4ESDAtomPtr;
-
-typedef struct MP4SampleSizeAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*getSampleSize)( MP4AtomPtr self, u32 sampleNumber, u32 *outSize );
-	MP4Err (*getSampleSizeAndOffset)( MP4AtomPtr self, u32 sampleNumber, u32 *outSize, u32 startingSampleNumber, u32 *outOffsetSize );
-	MP4Err (*addSamples)( struct MP4SampleSizeAtom *self, u32 sampleCount, MP4Handle sizesH );
-    MP4Err (*setfieldsize)( struct MP4SampleSizeAtom* self, u32 fieldsize);
-    
-	u32	sampleSize;
-	u32	sampleCount;
-	u32 fieldsize;
-	u32 *sizes;
-} MP4SampleSizeAtom, *MP4SampleSizeAtomPtr;
-
-typedef MP4SampleSizeAtom MP4CompactSampleSizeAtom;
-typedef MP4SampleSizeAtomPtr MP4CompactSampleSizeAtomPtr;
-
-typedef struct MP4PaddingBitsAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*getSamplePad)( MP4AtomPtr self, u32 sampleNumber, u8 *outPad );
-	MP4Err (*addSamplePads)( struct MP4PaddingBitsAtom *self, u32 sampleCount, MP4Handle padsH );
-
-	u32	sampleCount;
-	u8  *pads;
-} MP4PaddingBitsAtom, *MP4PaddingBitsAtomPtr;
-
-#define COMMON_CHUNK_OFFSET_FIELDS \
-	u32 (*getChunkCount)( MP4AtomPtr self); \
-	MP4Err (*getChunkOffset)( MP4AtomPtr self, u32 chunkIndex, u64 *outOffset ); \
-	MP4Err (*addOffset)(struct MP4ChunkOffsetAtom *self, u64 offset ); \
-	MP4Err (*updateOffset)(struct MP4ChunkOffsetAtom *self, u32 chunkIndex, u64 offset ); \
-	u32	entryCount;
-
-typedef struct MP4ChunkOffsetAtom
-{
-	MP4_FULL_ATOM
-	COMMON_CHUNK_OFFSET_FIELDS
-
-	u32 *offsets;
-} MP4ChunkOffsetAtom, *MP4ChunkOffsetAtomPtr;
-
-typedef struct MP4ChunkLargeOffsetAtom
-{
-	MP4_FULL_ATOM
-	COMMON_CHUNK_OFFSET_FIELDS	
-
-	u64 *offsets;
-} MP4ChunkLargeOffsetAtom, *MP4ChunkLargeOffsetAtomPtr;
-
-typedef struct
-{
-	u32 firstChunk;
-	u32 samplesPerChunk;
-	u32	sampleDescriptionIndex;
-} stscEntry, *stscEntryPtr;
-
-typedef struct MP4SampleToChunkAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*lookupSample)( MP4AtomPtr self, u32 sampleNumber, u32 *outChunkNumber, u32 *outSampleDescriptionIndex, u32 *outFirstSampleNumberInChunk );
-	MP4Err (*setEntry)( struct MP4SampleToChunkAtom *self, u32 firstChunkNumber, u32 sampleCount, u32 sampleDescriptionIndex );
-	u32    (*getEntryCount)( struct MP4SampleToChunkAtom *self );
-	MP4Err (*mdatMoved)( struct MP4SampleToChunkAtom *self, u64 mdatBase, u64 mdatEnd, u64 mdatOffset,
-						 struct MP4SampleDescriptionAtom *stsd, 
-	                     struct MP4DataReferenceAtom *dref, struct MP4ChunkOffsetAtom *stco );
-	MP4Err (*UpdateEntry)( struct MP4SampleToChunkAtom *self, u32 firstChunkNumber);
-	MP4LinkedList entryList;
-
-	u32   foundEntryNumber;
-	u32   foundEntryFirstSampleNumber;
-
-} MP4SampleToChunkAtom, *MP4SampleToChunkAtomPtr;
-
-typedef struct MP4SyncSampleAtom
-{
-	MP4_FULL_ATOM
-	MP4Err (*addSamples)(struct MP4SyncSampleAtom *self, u32 beginningSampleNumber, u32 sampleCount, MP4Handle syncSamplesH );
-	MP4Err (*isSyncSample)( MP4AtomPtr self, u32 sampleNumber, u32 *outSync );
-	u32	entryCount;
-	u32 *sampleNumbers;
-    u32 nonSyncFlag;
-} MP4SyncSampleAtom, *MP4SyncSampleAtomPtr;
-
-typedef struct MP4ShadowSyncAtom
-{
-	MP4_FULL_ATOM
-	u32	entryCount;
-	void *entries;
-} MP4ShadowSyncAtom, *MP4ShadowSyncAtomPtr;
-
-typedef struct MP4DegradationPriorityAtom
-{
-	MP4_FULL_ATOM
-	u32	entryCount;
-	u16 *priorities;
-} MP4DegradationPriorityAtom, *MP4DegradationPriorityAtomPtr;
-
-typedef struct MP4FreeSpaceAtom
-{
-	MP4_BASE_ATOM
-	char *data;
-	u32 dataSize;
-} MP4FreeSpaceAtom, *MP4FreeSpaceAtomPtr;
-
-typedef struct MP4EditAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*addAtom)( struct MP4EditAtom *self, MP4AtomPtr atom );
-	MP4Err (*getEffectiveDuration)( struct MP4EditAtom *self, u32 *outDuration );
-
-	MP4LinkedList atomList;
-	MP4AtomPtr editListAtom;
-} MP4EditAtom, *MP4EditAtomPtr;
-
-typedef struct MP4EditListAtom
-{
-	MP4_FULL_ATOM
-	
-	MP4Err (*setTrackOffset)( struct MP4EditListAtom *self, u32 trackStartTime, u64 trackDuration );
-	MP4Err (*getTrackOffset)( struct MP4EditListAtom *self, u32 *outTrackStartTime );
-	
-	MP4Err (*isEmptyEdit)( struct MP4EditListAtom *self, u32 segmentNumber, u32 *outIsEmpty );
-	
-	MP4Err (*insertSegment)( struct MP4EditListAtom *self,
-								s32 trackStartTime,
-								u32 mediaStartTime,
-								u64 segmentDuration,
-								u32 mediaRate );
-								
-	MP4Err (*getEffectiveDuration)( struct MP4EditListAtom *self, u32 *outDuration );
-	MP4Err (*getIndSegmentTime)( MP4AtomPtr self,
-								 u32 segmentIndex,          /* one based */
-								 u64 *outSegmentMovieTime,
-								 s64 *outSegmentMediaTime,
-								 u64 *outSegmentDuration    /* in movie's time scale */
-							   );
-	MP4Err (*getTimeAndRate)( MP4AtomPtr self, u64 movieTime, u32 movieTimeScale,
-							  u32 mediaTimeScale, s64 *outMediaTime, u32 *outMediaRate,
-							  u64 *outPriorSegmentEndTime, u64 *outNextSegmentBeginTime );
-	u32    (*getEntryCount)( struct MP4EditListAtom *self );
-	MP4LinkedList entryList;
-} MP4EditListAtom, *MP4EditListAtomPtr;
-
-typedef struct MP4UserDataAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*addUserData) (struct MP4UserDataAtom *self, MP4Handle userDataH, u32 userDataType, u32 *outIndex );
-	MP4Err (*getEntryCount) (struct MP4UserDataAtom *self, u32 userDataType, u32 *outCount );
-	MP4Err (*getIndType) (struct MP4UserDataAtom *self, u32 typeIndex, u32 *outType );
-	MP4Err (*getItem) (struct MP4UserDataAtom *self, MP4Handle userDataH, u32 userDataType, u32 itemIndex );
-	MP4Err (*getTypeCount) (struct MP4UserDataAtom *self, u32 *outCount );
-	MP4LinkedList recordList;
-} MP4UserDataAtom, *MP4UserDataAtomPtr;
-
-typedef struct MP4CopyrightAtom
-{
-	MP4_FULL_ATOM
-	u32 packedLanguageCode;
-	char* notice;
-} MP4CopyrightAtom, *MP4CopyrightAtomPtr;
-
-typedef struct MP4TrackReferenceTypeAtom
-{
-	MP4_BASE_ATOM
-	MP4Err (*addTrackID)( struct MP4TrackReferenceTypeAtom *self, u32 trackID );
-	u32 trackIDCount;
-	u32 *trackIDs;
-} MP4TrackReferenceTypeAtom, *MP4TrackReferenceTypeAtomPtr;
-
-
-
-
-
-/* track fragment stuff */
-
-enum {
-	fragment_difference_sample_flag = 0x10000
-};
-
-typedef struct MP4MovieFragmentAtom
-{
-	MP4_BASE_ATOM
-	COMMON_MOVIE_ATOM_FIELDS
-
-	MP4Err (*addAtom)( struct MP4MovieFragmentAtom *self, MP4AtomPtr atom );
-	MP4Err (*mergeFragments)( struct MP4MovieFragmentAtom* self, MP4MovieAtomPtr moov );
-	MP4AtomPtr mfhd;              	/* the movie fragment header */
-	MP4PrivateMovieRecordPtr moov;
-	MP4LinkedList atomList;			/* the track fragments */
-} MP4MovieFragmentAtom, *MP4MovieFragmentAtomPtr;
-
-typedef struct MP4MovieFragmentHeaderAtom
-{
-	MP4_FULL_ATOM
-	u32 sequence_number;
-} MP4MovieFragmentHeaderAtom, *MP4MovieFragmentHeaderAtomPtr;
-
-typedef struct MP4MovieExtendsAtom
-{
-	MP4_FULL_ATOM
-	MP4LinkedList atomList;		/* track extends list */
-	MP4Err (*addAtom)( struct MP4MovieExtendsAtom *self, MP4AtomPtr atom );
-	MP4Err (*maketrackfragments) (struct MP4MovieExtendsAtom *self, MP4MovieFragmentAtomPtr moof, MP4MovieAtomPtr moov, MP4MediaDataAtomPtr mdat );
-	MP4Err (*getTrackExtendsAtom)( struct MP4MovieExtendsAtom* self, u32 trackID, MP4AtomPtr *outTrack );
-	MP4Err (*setSampleDescriptionIndexes)( struct MP4MovieExtendsAtom* self, MP4AtomPtr moov );
-} MP4MovieExtendsAtom, *MP4MovieExtendsAtomPtr;
-
-typedef struct MP4TrackExtendsAtom
-{
-	MP4_FULL_ATOM
-	u32 trackID;
-	u32 default_sample_description_index;
-	u32 default_sample_duration;
-	u32 default_sample_size;
-	u32 default_sample_flags;
-} MP4TrackExtendsAtom, *MP4TrackExtendsAtomPtr;
-
-typedef struct MP4TrackFragmentHeaderAtom
-{
-	MP4_FULL_ATOM
-	u32 trackID;
-	u64 base_data_offset;
-	u32 sample_description_index;
-	u32 default_sample_duration;
-	u32 default_sample_size;
-	u32 default_sample_flags;
-} MP4TrackFragmentHeaderAtom, *MP4TrackFragmentHeaderAtomPtr;
-
-typedef struct MP4TrackFragmentAtom
-{
-	MP4_FULL_ATOM
-	COMMON_MINF_ATOM_FIELDS
-	MP4AtomPtr	  tfhd;
-	
-	MP4Err (*mergeRuns)( struct MP4TrackFragmentAtom *self, MP4MediaAtomPtr mdia );
-	MP4Err (*calculateDataSize)( struct MP4TrackFragmentAtom *self, u32* outSize);
-	
-	u32 default_sample_description_index;	/* all copied from the matching trex */
-	u32 default_sample_duration;
-	u32 default_sample_size;
-	u32 default_sample_flags;
-	
-	MP4MediaDataAtomPtr mdat;
-	u32 samples_use_mdat;		/* 0 -- not yet decided, 1=yes, 2=no */
-
-	MP4LinkedList atomList;		/* track runs */
-} MP4TrackFragmentAtom, *MP4TrackFragmentAtomPtr;
-
-enum {
-	tfhd_base_data_offset_present 			= 0x01,
-	tfhd_sample_description_index_present 	= 0x02,
-	tfhd_default_sample_duration_present 	= 0x08,
-	tfhd_default_sample_size_present 		= 0x10,
-	tfhd_default_sample_flags_present 		= 0x20,
-	tfhd_duration_is_empty			 		= 0x10000
-};
-
-typedef struct MP4TrackRunEntry
-{
-	u32 sample_duration;
-	u32 sample_size;
-	u32 sample_flags;
-	u32 sample_composition_time_offset;
-} MP4TrackRunEntry, *MP4TrackRunEntryPtr;
-
-enum {
-	trun_data_offset_present 				= 0x01,
-	trun_first_sample_flags_present 		= 0x04,
-	trun_sample_duration_present 			= 0x100,
-	trun_sample_size_present 				= 0x200,
-	trun_sample_flags_present 				= 0x400,
-	trun_sample_composition_times_present	= 0x800
-};
-
-#define trun_all_sample_flags (trun_sample_duration_present + trun_sample_size_present +trun_sample_flags_present + trun_sample_composition_times_present)
-
-typedef struct MP4TrackRunAtom
-{
-	MP4_FULL_ATOM
-	u32 samplecount;
-	s32 data_offset;
-	u32 first_sample_flags;
-	MP4TrackRunEntryPtr entries;
-	
-	void (*calculateDefaults) (struct MP4TrackRunAtom *self, MP4TrackFragmentHeaderAtomPtr tfhd, u32 flags_index );
-	void (*setFlags) (struct MP4TrackRunAtom *self, MP4TrackFragmentHeaderAtomPtr tfhd );
-} MP4TrackRunAtom, *MP4TrackRunAtomPtr;
-
-enum
-{
-	MJ2JPEG2000Brand						= MP4_FOUR_CHAR_CODE( 'j', 'p', '2', ' ' ),		/* brand for JPEG-2000 */
-	ISOQuickTimeBrand						= MP4_FOUR_CHAR_CODE( 'q', 't', ' ', ' ' ),		/* brand for QuickTime */
-	ISOMpeg4V1Brand							= MP4_FOUR_CHAR_CODE( 'm', 'p', '4', '1' ),		/* brand for MPEG-4 version 1 */
-	ISOMpeg4V2Brand							= MP4_FOUR_CHAR_CODE( 'm', 'p', '4', '2' ),		/* brand for MPEG-4 version 2 */
-	ISOISOBrand								= MP4_FOUR_CHAR_CODE( 'i', 's', 'o', 'm' ),		/* conforming brand for all files */
-	ISOUnknownBrand							= MP4_FOUR_CHAR_CODE( ' ', ' ', ' ', ' ' ),		/* default 'brand' */
-	DVBTransportStreamBrand			= MP4_FOUR_CHAR_CODE('d', 'v', 't', '1'),	/* brand for DVB Transport Stream */
-	IM_AF_im01_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '0', '1'),	/* brand for IM-AF */
-	IM_AF_im02_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '0', '2'),	/* brand for IM-AF */
-	IM_AF_im03_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '0', '3'),	/* brand for IM-AF */
-	IM_AF_im04_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '0', '4'),	/* brand for IM-AF */
-	IM_AF_im11_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '1', '1'),	/* brand for IM-AF */
-	IM_AF_im12_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '1', '2'),	/* brand for IM-AF */
-	IM_AF_im21_Brand		= MP4_FOUR_CHAR_CODE('i', 'm', '2', '1'),	/* brand for IM-AF */
-};
-
-typedef struct ISOFileTypeAtom
-{
-	MP4_BASE_ATOM
-	
-	ISOErr (*addStandard)(struct ISOFileTypeAtom *self, u32 standard );
-	ISOErr (*setBrand)(struct ISOFileTypeAtom *self, u32 standard, u32 minorversion );
-	ISOErr (*getBrand)(struct ISOFileTypeAtom *self, u32* standard, u32* minorversion );
-	u32    (*getStandard)(struct ISOFileTypeAtom *self, u32 standard );
-	u32 brand;											/* the brand of this file */
-	u32 minorVersion;									/* the minor version of this file */
-	u32 itemCount;										/* the number of items in the compatibility list */
-	u32 *compatibilityList;								/* standards this file conforms to */
-} ISOFileTypeAtom, *ISOFileTypeAtomPtr;
-
-typedef	struct MP4PrimaryItemAtom
-{
-	MP4_FULL_ATOM
-		u16 item_ID;
-}MP4PrimaryItemAtom, *MP4PrimaryItemAtomPtr;
-
-typedef struct MP4ItemExtentEntry
-{
-	u64 extent_offset;
-	u64 extent_length;
-	//	u64 original_extent_offset;
-} MP4ItemExtentEntry, *MP4ItemExtentEntryPtr;
-
-typedef struct MP4ItemLocationEntry
-{
-	u16 item_ID;
-	u16 data_reference_index;
-	u64 base_offset;
-	//	u64 original_base_offset;
-	MP4LinkedList extent_entries;
-} MP4ItemLocationEntry, *MP4ItemLocationEntryPtr;
-
-typedef struct MP4ItemLocationAtom
-{
-	MP4_FULL_ATOM
-
-		MP4Err (*ShiftOffset)( struct MP4ItemLocationAtom* self, u64 offset);
-
-	u8 offset_size;
-	u8 length_size;
-	u8 base_offset_size;
-	MP4LinkedList location_entries;
-} MP4ItemLocationAtom, *MP4ItemLocationAtomPtr;
-
-typedef struct MP4ItemInfoEntryAtom
-{
-	MP4_FULL_ATOM
-		u16 item_ID;
-	u16 item_protection_index;
-	u8  *item_name;
-	u8  *content_type;
-	u8  *content_encoding;
-	// needed to actually read the resource file, but not written in the MP21 file.
-	//	u8  *full_path;
-} MP4ItemInfoEntryAtom, *MP4ItemInfoEntryAtomPtr;
-
-typedef struct MP4ItemInfoAtom
-{
-	MP4_FULL_ATOM
-		MP4LinkedList item_infos;
-} MP4ItemInfoAtom, *MP4ItemInfoAtomPtr;
-
-typedef struct MP4XMLAtom
-{
-	MP4_FULL_ATOM
-		u32 xml_length;
-	u8 *xml;
-} MP4XMLAtom, *MP4XMLAtomPtr;
-
-typedef struct MP4BinaryXMLAtom
-{
-	MP4_FULL_ATOM
-		u32 data_length;
-	u8 *data;
-} MP4BinaryXMLAtom, *MP4BinaryXMLAtomPtr;
-
-typedef struct MP4MetaAtom
-{
-	MP4_FULL_ATOM
-
-	MP4Err (*addAtom)( struct MP4MetaAtom* self, MP4AtomPtr atom );
-	MP4Err (*ShiftOffset)( struct MP4MetaAtom* self, u64 offset);
-
-	MP4AtomPtr theHandler;
-	MP4AtomPtr primary_resource;
-	MP4AtomPtr file_locations;
-	MP4AtomPtr item_locations;
-	MP4AtomPtr protections;
-	MP4AtomPtr item_infos;
-	MP4AtomPtr IPMP_control;
-	MP4LinkedList atomList;
-} MP4MetaAtom, *MP4MetaAtomPtr;
-
-#define MPEG2TSEntry_FIELDS	\
-	MP4_BASE_ATOM	\
-	COMMON_SAMPLE_ENTRY_FIELDS	\
-	u32 hinttrackversion;	\
-	u32 highestcompatibleversion;	\
-	u32 precedingbyteslen;	\
-	u32 trailingbyteslen;	\
-	u32 precomputed_only_flag;	/* 1 bit*/	\
-	u32 reserved2;	/* 7 bit*/ 	\
-	MP4LinkedList atomList;	\
-	
-typedef struct MPEG2TSReceptionSampleEntryAtom
-{
-	MPEG2TSEntry_FIELDS
-	MP4Err (*addAtom)( struct MPEG2TSReceptionSampleEntryAtom* self, MP4AtomPtr atom );	\
-}MPEG2TSReceptionSampleEntryAtom, *MPEG2TSReceptionSampleEntryAtomPtr;
-
-typedef struct PATAtom
-{
-	MP4_BASE_ATOM
-	u16 PID;
-	u32 sectiondata_length;
-	u8 *sectiondata;
-}PATAtom, *PATAtomPtr;
-
-typedef struct PMTAtom
-{
-	MP4_BASE_ATOM
-	u16 PID;
-	u32 sectiondata_length;
-	u8 *sectiondata;
-}PMTAtom, *PMTAtomPtr;
-
-typedef struct TSTimingAtom
-{
-	MP4_BASE_ATOM
-	u8 timing_derivation_method;		// 1 bit
-	u8 reserved;	//	2 bit
-	u16 PID;		//13 bit
-}TSTimingAtom, *TSTimingAtomPtr;
-
-typedef struct OriginalFormatAtom
-{
-	MP4_BASE_ATOM
-	u32 data_format;
-}OriginalFormatAtom, *OriginalFormatAtomPtr;
-
-typedef struct ProtectionSchemeInfoAtom
-{
-	MP4_BASE_ATOM
-	MP4AtomPtr original_format;
-	// ³ª¸ÓÁö ¿É¼Ç ¹Ú½ºµéÀº DTV¿¡¼­ »ç¿ëÇÏÁö ¾Ê´Â´Ù.
-
-	MP4Err (*addAtom)( struct ProtectionSchemeInfoAtom* self, MP4AtomPtr atom );
-}ProtectionSchemeInfoAtom, *ProtectionSchemeInfoAtomPtr;
-
-typedef struct PackageKeyInfoAtom
-{
-	MP4_BASE_ATOM
-	u8 key_type;		// 2 bit
-	u8 encryption_type;	//	2 bit
-	u8 key_length;		//4 bit
-	u8 padding_type; // 3bit
-	u8 reserved; //5 bit
-}PackageKeyInfoAtom, *PackageKeyInfoAtomPtr;
-
-typedef struct ControlWordInfoAtom
-{
-	MP4_BASE_ATOM
-	u8 encryption_type;		// 2 bit
-	u8 key_length;	//	3 bit
-	u8 mode;		//3 bit
-}ControlWordInfoAtom, *ControlWordInfoAtomPtr;
-
-typedef struct KeyMessageReceptionSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	u8 key_sample_type;
-	u8 key_sample_version;
-	u8 key_uuid[16];
-	
-	MP4LinkedList atomList;
-	MP4Err (*addAtom)( struct KeyMessageReceptionSampleEntryAtom* self, MP4AtomPtr atom );
-} KeyMessageReceptionSampleEntryAtom, *KeyMessageReceptionSampleEntryAtomPtr;
-
-typedef struct GroupAtom
-{
-	MP4_FULL_ATOM
-	u32 group_ID;
-	u16 num_elements;
-	u32 *element_ID;	//array
-	u8 group_activation_mode;
-	u16 group_activation_elements_number;
-	s16 group_reference_volume;
-	char *group_name;
-	char *group_description;
-} GroupAtom, *GroupAtomPtr;
-
-typedef struct GroupContainerAtom
-{
-	MP4_BASE_ATOM
-	u16 num_groups;
-	MP4LinkedList atomList;
-	MP4Err (*addAtom)( struct GroupContainerAtom* self, MP4AtomPtr atom );
-} GroupContainerAtom, *GroupContainerAtomPtr;
-
-typedef struct PresetAtom
-{
-	MP4_FULL_ATOM
-	u32 preset_ID;
-	u32 num_preset_elements;
-	u32 *preset_element_ID;	//array
-	u32 preset_type;
-	u32 preset_global_volume;
-	u32 *preset_volume_element;
-	u32 *num_input_channel;
-	u32 output_channel_type;
-	u32 num_output_channel;
-	u32 num_updates;
-	u32 *updated_sample_number;
-	char *preset_name;
-} PresetAtom, *PresetAtomPtr;
-
-typedef struct PresetContainerAtom
-{
-	MP4_BASE_ATOM
-	u32 num_preset;
-	u32 default_preset_ID;
-	MP4LinkedList atomList;
-	MP4Err (*addAtom)( struct PresetContainerAtom* self, MP4AtomPtr atom );
-} PresetContainerAtom, *PresetContainerAtomPtr;
-
-typedef struct SelectionRuleAtom
-{
-	MP4_FULL_ATOM
-	u16 selection_rule_ID;
-	u8 selection_rule_type;
-	u32 element_ID;
-	u16 min_num_elements;
-	u16 max_num_elements;
-	u32 key_element_ID;
-	char *selection_rule_description;
-} SelectionRuleAtom, *SelectionRuleAtomPtr;
-
-typedef struct MixingRuleAtom
-{
-	MP4_FULL_ATOM
-	u16 mixing_rule_ID;
-	u8 mixing_rule_type;
-	u32 element_ID;
-	s16 min_volume;
-	s16 max_volume;
-	u32 key_element_ID;
-	char *mixing_rule_description;
-} MixingRuleAtom, *MixingRuleAtomPtr;
-
-typedef struct RuleContainerAtom
-{
-	MP4_BASE_ATOM
-	u32 num_selection_rules;
-	u32 num_mixing_rules;
-	MP4LinkedList rusc_atomList;
-	MP4LinkedList rumx_atomList;
-	MP4Err (*addAtom)( struct RuleContainerAtom* self, MP4AtomPtr atom );
-} RuleContainerAtom, *RuleContainerAtomPtr;
-
-enum
-{
-	FACE_STYLE_BOLD = 1,
-	FACE_STYLE_ITALIC = 2,
-	FACE_STYLE_UNDERLINE = 4,
-};
-
-typedef struct StyleRecordStruct
-{
-	u32 startChar;				//16
-	u32 endChar;				//16
-	u32 font_ID;					//16
-	u32 face_style_flags;	//8
-	u32 font_size;				//8
-	u32 text_color_r;			//8
-	u32 text_color_g;			//8
-	u32 text_color_b;			//8
-	u32 text_color_a;			//8
-}StyleRecordStruct,  *StyleRecordStructPtr;
-
-typedef struct FontRecordStruct
-{
-	u32 font_ID;		//16
-	u32 font_name_length;	//8
-	u8 *font;
-}FontRecordStruct, *FontRecordStructPtr;
-
-typedef struct FontTableAtom
-{
-	MP4_BASE_ATOM
-	u32 entry_count;		//16
-	MP4LinkedList fontRecordList;
-}FontTableAtom, *FontTableAtomPtr;
-
-typedef struct BoxRecordStruct
-{
-	u32 top;			//16
-	u32 left;			//16
-	u32 bottom;		//16
-	u32 right;			//16
-}BoxRecordStruct;
-
-enum
-{
-	DISPLAY_FLAG_SCROLL_IN = 0x20,	
-	DISPLAY_FLAG_SCROLL_OUT = 0x40,
-	DISPLAY_FLAG_SCROLL_DIRECTION = 0x180,
-	DISPLAY_FLAG_CONTINUOUS_KARAOKE = 0x800,
-	DISPLAY_FLAG_WRITE_TEXT_VERTICALLY = 0X20000,
-	DISPLAY_FLAG_FILL_TEXT_REGION = 0x40000,
-};
-
-typedef struct TextSampleEntryAtom
-{
-	MP4_BASE_ATOM
-	COMMON_SAMPLE_ENTRY_FIELDS
-	u32 displayFlags;						//32
-	u32 horizontal_justification;		//8
-	u32 vertical_justification;			//8
-	u32 background_color_r;			//8
-	u32 background_color_g;		//8
-	u32 background_color_b;		//8
-	u32 background_color_a;		//8
-	BoxRecordStruct default_text_box;
-	StyleRecordStruct default_style;
-	MP4AtomPtr fontTableAtomPtr;
-	MP4LinkedList atomList;
-	MP4Err (*addAtom)( struct TextSampleEntryAtom* self, MP4AtomPtr atom );
-}TextSampleEntryAtom, *TextSampleEntryAtomPtr;
-
-typedef struct TextStyleAtom
-{
-	MP4_BASE_ATOM
-	unsigned int entry_count;				//16
-	MP4LinkedList styleRecordList;		//StyleRecordStruct
-}TextStyleAtom, *TextStyleAtomPtr;
-
-typedef struct TextHighlightAtom
-{
-	MP4_BASE_ATOM
-	unsigned int startcharoffset;				//16
-	unsigned int endcharoffset;				//16
-}TextHighlightAtom, *TextHighlightAtomPtr;
-
-typedef struct TextHighlightColorAtom
-{
-	MP4_BASE_ATOM
-	unsigned int highlight_color_r;			//8
-	unsigned int highlight_color_g;		//8
-	unsigned int highlight_color_b;		//8
-	unsigned int highlight_color_a;		//8
-}TextHighlightColorAtom, *TextHighlightColorAtomPtr;
-
-typedef struct TextKaraokeAtom
-{
-	MP4_BASE_ATOM
-	unsigned int highlight_start_time;			//32
-	unsigned int entry_count;						//16
-	unsigned int *highlight_end_time;			//32
-	unsigned int *startcharoffset;					//16
-	unsigned int *endcharoffset;					//16
-}TextKaraokeAtom, *TextKaraokeAtomPtr;
-
-MP4Err MP4CreateAudioSampleEntryAtom( MP4AudioSampleEntryAtomPtr *outAtom );
-MP4Err MP4CreateChunkLargeOffsetAtom( MP4ChunkLargeOffsetAtomPtr *outAtom );
-MP4Err MP4CreateChunkOffsetAtom( MP4ChunkOffsetAtomPtr *outAtom );
-MP4Err MP4CreateClockReferenceMediaHeaderAtom( MP4ClockReferenceMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateCompositionOffsetAtom( MP4CompositionOffsetAtomPtr *outAtom );
-MP4Err MP4CreateCopyrightAtom( MP4CopyrightAtomPtr *outAtom );
-MP4Err MP4CreateDataEntryURLAtom( MP4DataEntryURLAtomPtr *outAtom );
-MP4Err MP4CreateDataEntryURNAtom( MP4DataEntryURNAtomPtr *outAtom );
-MP4Err MP4CreateDataInformationAtom( MP4DataInformationAtomPtr *outAtom );
-MP4Err MP4CreateDataReferenceAtom( MP4DataReferenceAtomPtr *outAtom );
-MP4Err MP4CreateDegradationPriorityAtom( MP4DegradationPriorityAtomPtr *outAtom );
-MP4Err MP4CreateESDAtom( MP4ESDAtomPtr *outAtom );
-MP4Err MP4CreateEditAtom( MP4EditAtomPtr *outAtom );
-MP4Err MP4CreateEditListAtom( MP4EditListAtomPtr *outAtom );
-MP4Err MP4CreateFreeSpaceAtom( MP4FreeSpaceAtomPtr *outAtom );
-MP4Err MP4CreateGenericSampleEntryAtom( MP4GenericSampleEntryAtomPtr *outAtom );
-MP4Err MP4CreateHandlerAtom( MP4HandlerAtomPtr *outAtom );
-MP4Err MP4CreateHintMediaHeaderAtom( MP4HintMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateMPEGMediaHeaderAtom( MP4MPEGMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateMPEGSampleEntryAtom( MP4MPEGSampleEntryAtomPtr *outAtom );
-MP4Err MP4CreateMediaAtom( MP4MediaAtomPtr *outAtom );
-MP4Err MP4CreateMediaDataAtom( MP4MediaDataAtomPtr *outAtom );
-MP4Err MP4CreateMediaHeaderAtom( MP4MediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateMediaInformationAtom( MP4MediaInformationAtomPtr *outAtom );
-MP4Err MP4CreateMovieAtom( MP4MovieAtomPtr *outAtom );
-MP4Err MP4CreateMovieHeaderAtom( MP4MovieHeaderAtomPtr *outAtom );
-MP4Err MP4CreateObjectDescriptorAtom( MP4ObjectDescriptorAtomPtr *outAtom );
-MP4Err MP4CreateObjectDescriptorMediaHeaderAtom( MP4ObjectDescriptorMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateSampleDescriptionAtom( MP4SampleDescriptionAtomPtr *outAtom );
-MP4Err MP4CreateSampleSizeAtom( MP4SampleSizeAtomPtr *outAtom );
-MP4Err MP4CreateSampleTableAtom( MP4SampleTableAtomPtr *outAtom );
-MP4Err MP4CreateSampleToChunkAtom( MP4SampleToChunkAtomPtr *outAtom );
-MP4Err MP4CreateSceneDescriptionMediaHeaderAtom( MP4SceneDescriptionMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateShadowSyncAtom( MP4ShadowSyncAtomPtr *outAtom );
-MP4Err MP4CreateSoundMediaHeaderAtom( MP4SoundMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateSyncSampleAtom( MP4SyncSampleAtomPtr *outAtom );
-MP4Err MP4CreateTimeToSampleAtom( MP4TimeToSampleAtomPtr *outAtom );
-MP4Err MP4CreateTrackAtom( MP4TrackAtomPtr *outAtom );
-MP4Err MP4CreateTrackHeaderAtom( MP4TrackHeaderAtomPtr *outAtom );
-MP4Err MP4CreateTrackReferenceAtom( MP4TrackReferenceAtomPtr *outAtom );
-MP4Err MP4CreateTrackReferenceTypeAtom( u32 atomType, MP4TrackReferenceTypeAtomPtr *outAtom );
-MP4Err MP4CreateUnknownAtom( MP4UnknownAtomPtr *outAtom );
-MP4Err MP4CreateUserDataAtom( MP4UserDataAtomPtr *outAtom );
-MP4Err MP4CreateVideoMediaHeaderAtom( MP4VideoMediaHeaderAtomPtr *outAtom );
-MP4Err MP4CreateVisualSampleEntryAtom( MP4VisualSampleEntryAtomPtr *outAtom );
-
-MP4Err MP4CreateMovieExtendsAtom( MP4MovieExtendsAtomPtr *outAtom );
-MP4Err MP4CreateTrackExtendsAtom( MP4TrackExtendsAtomPtr *outAtom );
-MP4Err MP4CreateMovieFragmentAtom( MP4MovieFragmentAtomPtr *outAtom );
-MP4Err MP4CreateMovieFragmentHeaderAtom( MP4MovieFragmentHeaderAtomPtr *outAtom );
-MP4Err MP4CreateTrackFragmentAtom( MP4TrackFragmentAtomPtr *outAtom );
-MP4Err MP4CreateTrackFragmentHeaderAtom( MP4TrackFragmentHeaderAtomPtr *outAtom );
-MP4Err MP4CreateTrackRunAtom( MP4TrackRunAtomPtr *outAtom );
-MP4Err MP4CreatePaddingBitsAtom( MP4PaddingBitsAtomPtr *outAtom );
-
-ISOErr MJ2CreateFileTypeAtom( ISOFileTypeAtomPtr *outAtom );
-MP4Err MP4CreatePrimaryItemAtom( MP4PrimaryItemAtomPtr *outAtom );
-MP4Err MP4CreateItemLocationAtom( MP4ItemLocationAtomPtr *outAtom );
-MP4Err MP4CreateItemInfoEntryAtom( MP4ItemInfoEntryAtomPtr *outAtom );
-MP4Err MP4CreateItemInfoAtom( MP4ItemInfoAtomPtr *outAtom );
-MP4Err MP4CreateXMLAtom( MP4XMLAtomPtr *outAtom );
-MP4Err MP4CreateBinaryXMLAtom( MP4BinaryXMLAtomPtr *outAtom );
-MP4Err MP4CreateMetaAtom( MP4MetaAtomPtr *outAtom );
-
-MP4Err MP4CreateMPEG2TSReceptionSampleEntryAtom( MPEG2TSReceptionSampleEntryAtomPtr *outAtom );
-MP4Err MP4CreatePATAtom( PATAtomPtr *outAtom );
-MP4Err MP4CreatePMTAtom( PMTAtomPtr *outAtom );
-MP4Err MP4CreateTSTimingAtom( TSTimingAtomPtr *outAtom );
-
-MP4Err MP4CreateProtectionSchemeInfoAtom( ProtectionSchemeInfoAtomPtr *outAtom );
-MP4Err MP4CreateOriginalFormatAtom( OriginalFormatAtomPtr *outAtom );
-
-MP4Err MP4CreatePackageKeyInfoAtom( PackageKeyInfoAtomPtr *outAtom );
-MP4Err MP4CreateControlWordInfoAtom( ControlWordInfoAtomPtr *outAtom );
-MP4Err MP4CreateKeyMessageReceptionSampleEntryAtom( KeyMessageReceptionSampleEntryAtomPtr *outAtom );
-
-MP4Err MP4CreateGroupAtom( GroupAtomPtr *outAtom );
-MP4Err MP4CreateGroupContainerAtom( GroupContainerAtomPtr *outAtom );
-MP4Err MP4CreatePresetAtom( PresetAtomPtr *outAtom );
-MP4Err MP4CreatePresetContainerAtom( PresetContainerAtomPtr *outAtom );
-MP4Err MP4CreateSelectionRuleAtom( SelectionRuleAtomPtr *outAtom );
-MP4Err MP4CreateMixingRuleAtom( MixingRuleAtomPtr *outAtom );
-MP4Err MP4CreateRuleContainerAtom( RuleContainerAtomPtr *outAtom );
-
-MP4Err MP4CreateFontTableAtom( FontTableAtomPtr *outAtom );
-MP4Err MP4CreateTextSampleEntryAtom( TextSampleEntryAtomPtr *outAtom );
-MP4Err MP4CreateTextStyleAtom( TextStyleAtomPtr *outAtom );
-MP4Err MP4CreateTextHighlightAtom( TextHighlightAtomPtr *outAtom );
-MP4Err MP4CreateTextHighlightColorAtom( TextHighlightColorAtomPtr *outAtom );
-MP4Err MP4CreateTextKaraokeAtom( TextKaraokeAtomPtr *outAtom );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif