Mercurial > hg > enc-imaf
changeset 0:138a3cea9792
Different files related to my project, including the encoder (I made it) and decoder. Also I added the mp4atoms as an example.
MP4atoms belong to the IMAF player library.
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Decoder/IM_AF_Decoder.c Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,718 @@ +#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, ¶m->MajorBrand, &minorVersion); if(err) goto bail; + err = ISOGetNbCompatableBrands(decoder->moov, ¶m->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, ×cale); 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Decoder/IM_AF_Decoder.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,179 @@ +#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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Decoder/IM_AF_Decoder.vcproj Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,171 @@ +<?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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder.xcodeproj/project.pbxproj Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,236 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4A773E3B158A37CC00E2DE6C /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 4A773E3A158A37CC00E2DE6C /* main.c */; }; + 4A773E3D158A37CC00E2DE6C /* IM_AM_Encoder.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A773E3C158A37CC00E2DE6C /* IM_AM_Encoder.1 */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 4A773E34158A37CC00E2DE6C /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 4A773E3D158A37CC00E2DE6C /* IM_AM_Encoder.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4A2EDBC71594935300A00D85 /* string.g.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = string.g.h; sourceTree = "<group>"; }; + 4A7662A5159A21DB004344F5 /* Drumbox.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Drumbox.wav; sourceTree = SOURCE_ROOT; }; + 4A7662A6159A21DB004344F5 /* GTR.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = GTR.wav; sourceTree = SOURCE_ROOT; }; + 4A7662A7159A21DB004344F5 /* Kik.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Kik.wav; sourceTree = SOURCE_ROOT; }; + 4A7662A8159A21DB004344F5 /* vocal.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = vocal.wav; sourceTree = SOURCE_ROOT; }; + 4A773E36158A37CC00E2DE6C /* IM_AM Encoder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "IM_AM Encoder"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4A773E3A158A37CC00E2DE6C /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; }; + 4A773E3C158A37CC00E2DE6C /* IM_AM_Encoder.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = IM_AM_Encoder.1; sourceTree = "<group>"; }; + 4A773E44158A384000E2DE6C /* IM_AF Encoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "IM_AF Encoder.h"; sourceTree = "<group>"; }; + 4A773E45158A3F1F00E2DE6C /* stdio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = stdio.h; path = ../stdio.h; sourceTree = "<group>"; }; + 4AA6EB54158CF0CC000DCEBC /* stdlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdlib.h; sourceTree = "<group>"; }; + 4AE74F40158A43760005EBF9 /* stdarg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stdarg.h; sourceTree = SOURCE_ROOT; }; + 4AE74F41158A43760005EBF9 /* stddef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stddef.h; sourceTree = SOURCE_ROOT; }; + 4AEBEFCC1598DB430043303A /* Bass.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = Bass.wav; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4A773E33158A37CC00E2DE6C /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4A773E2B158A37CC00E2DE6C = { + isa = PBXGroup; + children = ( + 4A773E39158A37CC00E2DE6C /* IM_AM Encoder */, + 4A773E37158A37CC00E2DE6C /* Products */, + ); + sourceTree = "<group>"; + }; + 4A773E37158A37CC00E2DE6C /* Products */ = { + isa = PBXGroup; + children = ( + 4A773E36158A37CC00E2DE6C /* IM_AM Encoder */, + ); + name = Products; + sourceTree = "<group>"; + }; + 4A773E39158A37CC00E2DE6C /* IM_AM Encoder */ = { + isa = PBXGroup; + children = ( + 4A7662A5159A21DB004344F5 /* Drumbox.wav */, + 4A7662A6159A21DB004344F5 /* GTR.wav */, + 4A7662A7159A21DB004344F5 /* Kik.wav */, + 4A7662A8159A21DB004344F5 /* vocal.wav */, + 4AEBEFCC1598DB430043303A /* Bass.wav */, + 4AE74F40158A43760005EBF9 /* stdarg.h */, + 4AE74F41158A43760005EBF9 /* stddef.h */, + 4A773E45158A3F1F00E2DE6C /* stdio.h */, + 4AA6EB54158CF0CC000DCEBC /* stdlib.h */, + 4A2EDBC71594935300A00D85 /* string.g.h */, + 4A773E3A158A37CC00E2DE6C /* main.c */, + 4A773E3C158A37CC00E2DE6C /* IM_AM_Encoder.1 */, + 4A773E44158A384000E2DE6C /* IM_AF Encoder.h */, + ); + path = "IM_AM Encoder"; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4A773E35158A37CC00E2DE6C /* IM_AM Encoder */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4A773E40158A37CC00E2DE6C /* Build configuration list for PBXNativeTarget "IM_AM Encoder" */; + buildPhases = ( + 4A773E32158A37CC00E2DE6C /* Sources */, + 4A773E33158A37CC00E2DE6C /* Frameworks */, + 4A773E34158A37CC00E2DE6C /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "IM_AM Encoder"; + productName = "IM_AM Encoder"; + productReference = 4A773E36158A37CC00E2DE6C /* IM_AM Encoder */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4A773E2D158A37CC00E2DE6C /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0420; + ORGANIZATIONNAME = SAE; + }; + buildConfigurationList = 4A773E30158A37CC00E2DE6C /* Build configuration list for PBXProject "IM_AM Encoder" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4A773E2B158A37CC00E2DE6C; + productRefGroup = 4A773E37158A37CC00E2DE6C /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4A773E35158A37CC00E2DE6C /* IM_AM Encoder */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4A773E32158A37CC00E2DE6C /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4A773E3B158A37CC00E2DE6C /* main.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4A773E3E158A37CC00E2DE6C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 4A773E3F158A37CC00E2DE6C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + CLANG_ENABLE_OBJC_ARC = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; + }; + name = Release; + }; + 4A773E41158A37CC00E2DE6C /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 4A773E42158A37CC00E2DE6C /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4A773E30158A37CC00E2DE6C /* Build configuration list for PBXProject "IM_AM Encoder" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4A773E3E158A37CC00E2DE6C /* Debug */, + 4A773E3F158A37CC00E2DE6C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4A773E40158A37CC00E2DE6C /* Build configuration list for PBXNativeTarget "IM_AM Encoder" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4A773E41158A37CC00E2DE6C /* Debug */, + 4A773E42158A37CC00E2DE6C /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4A773E2D158A37CC00E2DE6C /* Project object */; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder.xcodeproj/project.xcworkspace/contents.xcworkspacedata Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Workspace + version = "1.0"> + <FileRef + location = "self:IM_AM Encoder.xcodeproj"> + </FileRef> +</Workspace>
Binary file IM_AF Encoder/IM_AM Encoder.xcodeproj/project.xcworkspace/xcuserdata/eugin.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder.xcodeproj/xcuserdata/eugin.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Bucket + type = "1" + version = "1.0"> + <FileBreakpoints> + <FileBreakpoint + shouldBeEnabled = "No" + ignoreCount = "0" + continueAfterRunningActions = "No" + isPathRelative = "1" + filePath = "IM_AM Encoder/IM_AF Encoder.h" + timestampString = "362491526.773334" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "47" + endingLineNumber = "47"> + </FileBreakpoint> + <FileBreakpoint + shouldBeEnabled = "No" + ignoreCount = "0" + continueAfterRunningActions = "No" + isPathRelative = "1" + filePath = "IM_AM Encoder/IM_AF Encoder.h" + timestampString = "363006066.446204" + startingColumnNumber = "9223372036854775807" + endingColumnNumber = "9223372036854775807" + startingLineNumber = "244" + endingLineNumber = "244"> + </FileBreakpoint> + </FileBreakpoints> +</Bucket>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder.xcodeproj/xcuserdata/eugin.xcuserdatad/xcschemes/IM_AM Encoder.xcscheme Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,84 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "4A773E35158A37CC00E2DE6C" + BuildableName = "IM_AM Encoder" + BlueprintName = "IM_AM Encoder" + ReferencedContainer = "container:IM_AM Encoder.xcodeproj"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" + shouldUseLaunchSchemeArgsEnv = "YES" + buildConfiguration = "Debug"> + <Testables> + </Testables> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "4A773E35158A37CC00E2DE6C" + BuildableName = "IM_AM Encoder" + BlueprintName = "IM_AM Encoder" + ReferencedContainer = "container:IM_AM Encoder.xcodeproj"> + </BuildableReference> + </MacroExpansion> + </TestAction> + <LaunchAction + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Debug" + debugDocumentVersioning = "YES" + allowLocationSimulation = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "4A773E35158A37CC00E2DE6C" + BuildableName = "IM_AM Encoder" + BlueprintName = "IM_AM Encoder" + ReferencedContainer = "container:IM_AM Encoder.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + <AdditionalOptions> + </AdditionalOptions> + </LaunchAction> + <ProfileAction + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + buildConfiguration = "Release" + debugDocumentVersioning = "YES"> + <BuildableProductRunnable> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "4A773E35158A37CC00E2DE6C" + BuildableName = "IM_AM Encoder" + BlueprintName = "IM_AM Encoder" + ReferencedContainer = "container:IM_AM Encoder.xcodeproj"> + </BuildableReference> + </BuildableProductRunnable> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder.xcodeproj/xcuserdata/eugin.xcuserdatad/xcschemes/xcschememanagement.plist Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>SchemeUserState</key> + <dict> + <key>IM_AM Encoder.xcscheme</key> + <dict> + <key>orderHint</key> + <integer>0</integer> + </dict> + </dict> + <key>SuppressBuildableAutocreation</key> + <dict> + <key>4A773E35158A37CC00E2DE6C</key> + <dict> + <key>primary</key> + <true/> + </dict> + </dict> +</dict> +</plist>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder/IM_AF Encoder.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,347 @@ +// +// IM_AF Encoder.h +// IM_AM Encoder +// +// Created by eugenio oñate hospital on 14/06/12. +// Copyright (c) 2012 SAE. All rights reserved. +// + +#ifndef IM_AM_Encoder_IM_AF_Encoder_h +#define IM_AM_Encoder_IM_AF_Encoder_h + +/* for va_list typedef */ +#include <stdarg.h> +/* for FILE typedef, */ +#include <stdio.h> + +typedef long long u64; +typedef long long s64; +typedef unsigned int u32; +typedef unsigned short u16; +#define maxtracks 10 + +typedef struct namestrack{ + char title[20]; +}namestrack[maxtracks]; + +typedef struct FileTypeBox // extends Box('ftyp') +{ + u32 major_brand; // brand identifier + u32 minor_version; // informative integer for the mirror version + u32 compatible_brands[5]; //list, to the end of the box, of brands +}FileTypeBox; + +typedef struct MoiveBox //extends Box('moov') +{ + struct MovieHeaderBox // extends FullBox('mvhs', version, 0) + { + u32 creation_time; + u32 modification_time; + u32 timescale; // specifies the time-scale for the entire presentation (units per second) + u32 duration; + u32 rate; // typically 1.0 + u32 volume; // typically full volume + u16 reserved; // =0 + u32 reserved2 [2]; //=0 + u32 matrix [9]; // information matrix for video (u,v,w) + u32 pre_defined[6]; // =0 + u32 next_track_ID; //non zero value for the next track ID + }MovieHeaderBox; //max 10 tracks + + struct TrackBox // extends Box('trak') + { + struct TrackHeaderBox // extends FullBox('tkhd', version, flags) + { + u32 creation_time; + u32 modification_time; + u32 track_ID; // identifies this track and are never re -used and cannot be zero + u32 reserved; // =0 + u32 duration; + u32 reserved2[2]; // =0 + u16 layer; // =0 // for video + u16 alternate_group; // =0 + u16 volume; // full volume is 1 = 0x0100 + u16 reserved3;// =0 + u32 matrix[9]; // for video + u32 width; // video + u32 height; // video + }TrackHeaderBox; + struct TrackReferenceBox // extends Box('tref') + { + u32 reference_type; //shall be set to one of the following values: hint, cdsc, hind... + u32 track_ID; // provides a reference from the container track to another track + }TrackReferenceBox; + struct EditListBox //extends FullBox('elst',version,0) + { + u32 segment_duration; + u32 media_time; + u16 media_rate_integer; + u16 media_rate_fraction; + }EditListBox; + struct MediaBox // extends Box('mdia') + { + struct MediaHeaderBox // extends FullBox('mdhd', version,0) + { + u32 creation_time; + u32 modification_time; + u32 timescale; + u32 duration; + u16 language[3]; // [pad,5x3] = 16 bits and pad = 0 + u16 pre_defined; // =0 + }MediaHeaderBox; + struct HandlerBox // extends FullBox('hdlr', version =0, 0) + { + u32 pre_defined; // =0 + u32 handler_type; // = 'soun' for audio track, text or hint + u32 reserved[3]; // =0 + char name[20]; // string in UTF-8 characters which gives a human-readable name for track + }HandlerBox; + struct MediaInformationBox //extends Box('minf') + { + // smhd in sound track only!! + struct SoundMediaHeaderBox // extends FullBox('smhd', version =0, 0) + { + u16 balance; // =0 place mono tracks in stereo. 0 is center + u16 reserved; // =0 + }SoundMediaHeaderBox; + // hmhd in hint track only!! + struct HintMediaHeaderBox //extends FullBox('hmhd', version =0, 0) + { + u16 maxPDUsize; //size of largest PDU in this (hint) stream + u16 avgPDUsize; // average size of a PDU over the entire presentation + u32 maxbitrate; //max rate in bits/sec over any window of one second + u32 avgbitrate; // rate in bits/sec over entire presentation + u32 reserved; // =0 + }HintMediaHeaderBox; + //struct NullMediaHeaderBox // extends FullBox ('nmhd', version=0, flags) + //{}NullMediaHeaderBox; + struct DataInformationBox //extends Box('dinf') + { + struct DataEntryUrlBox //extends FullBox('url', version=0, flags) + { + u32 flags; + char *location; // UTF8 char + }DataEntryUrlBox; + struct DataEntryUrnBox // extends FullBox('urn', version=0,flag) + { + char *name; + char *location; + }DataEntryUrnBox; + //struct DataReferenceBox // extends FullBox('dref',version=0,flag) + //{ + // u32 entry_count; // counts the actual entries. See bucle in page 44. + //}DataReferenceBox; + }DataInformationBox; + struct SampleTableBox // extends Box('stbl') + { + struct SampleEntry + { + u32 format; + char reserved[6]; //=0 + u16 data_reference_index; // index of data reference to use to retrieve data + // associated with samples that use this sample descrip. + // Data ref are stored in Data Ref Box + }SampleEntry; + struct HintSampleEntry // extends SampleEntry(protocol) + { + char data; + }HintSampleEntry; + struct BitRateBox // extends Box('btrt') + { + u32 bufferSizeDB; // size of the decoding buffer + u32 maxBitrate; + u32 avgBitrate; + }BitRateBox; + struct MetaDataSampleEntry{}MetaDataSampleEntry; + struct XMLMetaDataSampleEntry // extends MetaDataSampleEntry ('metx') + { + char *namespace; // string of the schema for the timed XML metadata. Identify + // the type of metadata. + }XMLMetaDataSampleEntry; + struct TextMetaDataSampleEntry // extends MetaDataSampleEntry('mett') + { + char *mime_format; + }TextMetaDataSampleEntry; + struct URIBox // extends FullBox('uri',version=0,0) + { + char *theURI; + }URIBox; + struct URIInitBox + { + char *uri_initialization_data; + }URIInitBox; + struct URIMetaSampleEntry + { + struct URIBox the_label; + }URIMetaSampleEntry; + //Audio Sequences + struct AudioSampleEntry // extends SampleEntry(codingname) + { + u32 reserved[2]; // =0 + u16 channelcount; // =2 number of channels 1 mono 2 stereo + u16 samplesize; // =16 + u16 pre_defined; // =0 + u16 reserved2; //=0 + u32 samplerate; // {default samplerate of media}<<16 = 16.16 + }AudioSampleEntry; + struct SampleDescriptionBox // unsigned int(32) handler_type + { + u32 handler_type; + u32 entry_count; // number of entries + }SampleDescriptionBox; + struct TimeToSampleBox // extends FullBox('stts',version =0,0) + { + u32 entry_count; + int i; + u32 sample_count; + u32 sample_delta; + }TimeToSampleBox; + struct SampleToChunkBox // extends FullBox('stsc',version = 0,0) + { //chunk -> contiguous set of samples for one track + u32 entry_count; + u32 first_chunk; // index of the first chunk in this run of chunks that share the + // same samples-per-chunk and sample-descriprion-index. + // The index of the first chunk in a track = 1. + u32 samples_per_chunk; // number of samples in each o these chunks. + u32 sample_description_index; // index of the sample entry that describes the samples + // in this chunk. + }SampleToChunkBox; + struct SampleSizeBox // extends FullBox('stsz',version=0,0) + { + u32 samples_size; //default samples size. + u32 sample_count; // gives the number of samples in the track. + //Table to store the samples size table if samples have different sizes. + u32 entry_size; + }SampleSizeBox; + struct CompactSampleSizeBox // extends FullBox('stz2',version=0,0) + { + u32 field_size; // 24 bits = 0 + 8 bits = field_size + // int(field_size) 4,8 or 16 if 4 is used then 1 byte two values + u32 sample_count; + int entry_size; + }CompactSampleSizeBox; + struct ChunkOffsetBox // extends FullBox('stco',version=0,0) + { + u32 entry_count; + u32 chunk_offset; // gives the offset of the start of a chunk into its containing + // media file + }ChunkOffsetBox; + struct ChunkLargeOffsetBox // extends('co64',version=0,0) + { + u32 entry_count; + u64 chunk_offset; + }ChunkLargeOffsetBox; + }SampleTableBox; + }MediaInformationBox; + }MediaBox; + }TrackBox[maxtracks]; // max 10 tracks + struct GroupContainerBox // extends Box('grco') + { + u16 num_groups; // number the groups contained in the Group Container Box + struct GroupBox //extended FullBox('grup', version=0,flags) + { + int flags; //display disable & edit disable. See page 9 ISO23000-12 + u32 group_ID; //uniquely identifies a group + u16 num_elements; //num elementes involved in the group + u32 element_ID[10]; //size [num_elements] + char group_activation_mode; //flag that defines the way the elementes of the group are activated. + u16 group_activation_elements_number; // activate only if group_activation_mode == 2. Default=0 + u16 group_reference_volume; // reference group volume + char group_name[30]; // string UTF-8 + char group_description[100]; // string + }GroupBox[10]; + }GroupContainerBox; + struct PresetContainerBox // extends Box('prco') + { + char num_preset; + char default_preset_ID; // indicates preset ID activated at initial conditionwithout + //user interaction. Its default value takes the smallest preset_ID. + struct PresetBox //extends FullBox('prst',version=0,flags) + { + int flags; + char preset_ID; + char num_preset_elements; + u32 preset_element_ID[10]; //size [num_preset_elements] + char preset_type; + u16 preset_global_volume; + //IF preset_type == 1 + u16 preset_volume_element[10]; // insdie IF + char num_input_channel[10];// size [num_preset_elements] + //IF preset_type == 2 + u16 num_updates; + u16 update_sample_number; // indicates the sample number when the preset_volume is update + //IF preset_type == 3 + char output_channel_type; + char preset_name[30]; + }PresetBox[10]; + }PresetContainerBox; + // HERE it would be the RULES! +}MovieBox; + +typedef struct MediaDataBox // extends Box('mdat') +{ + u32 data; // +/- 16Mbytes +}MediaDataBox[10]; + +typedef struct FreeSpaceBox // extends Box(free_type) +{ //may be free or skip + u32 data; +}FreeSpaceBox; + +typedef struct MetaBox // extends FullBox('meta',version=0,0) +{ + struct HandlerBox theHandler; //The structure of the metabox is declare by the Handler. + struct DataEntryUrlBox dinfo; + struct ItemLocationBox // extends FullBox('iloc',version,0) + { + u16 Size; + u16 item_count; //counts the number of resources in the following array + u16 item_ID; + u16 c_method; //reserved(12)=0 + contruction_method(4) only if version == 1 + u16 data_reference_index; + int base_offset; // size depends int(8*base_offset_size). + // base value for offset calculations. + u16 extent_count; // Count number of extents into which the resources is fragmented. + int extent_index; // size index_size*8, only if version == 1 && indez_size > 0 + int extent_offset; // size offset_size*8 + int extent_length; // size length_size*8 + }ItemLocationBox; + // struct ItemInfoExtension. I dont use it + struct XMLBox // extends('xml', version=0,0) + { + char *xml; // string + }XMLBox; + + struct BinaryXMLBox // extends('bxml', version=0,0) + { + char *data; //to end of box + }BinaryXMLBox; + + struct PrimaryItemBox + { + u16 Item_ID; //ID of primary item + }PrimaryItemBox; + +}MetaBox; + +#endif + + + + + + + + + + + + + + + + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder/IM_AM_Encoder.1 Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 14/06/12 \" DATE +.Dt IM_AM Encoder 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm IM_AM Encoder, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .It Diagnostic Tag +.\" Diagnostic informtion here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder/main.c Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,586 @@ +// +// main.c +// IM_AM Enco§er +// +// Created by eugenio oñate hospital on 14/06/12. +// Copyright (c) 2012 QM. All rights reserved. +// + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include "IM_AF Encoder.h" +#define maxtracks 10 + + +/*Prototype*/ + +void filetypebx(FileTypeBox *ftyp); +void mdatbox(MediaDataBox *mdat, int, namestrack *namet, FILE *imf); +void moovheaderbox(MovieBox *moov, int, int); +void trackstructure(MovieBox *moov, int, int, namestrack namet); +void samplecontainer(MovieBox *moov, int); +void groupscontainer(MovieBox *moov); +void presetcontainer(MovieBox *moov); +void metadata(MetaBox *meta); +int getflags(); +u32 getdurationtrack(); +int getentrycount(); +char setnametrack(); +int getnextID(); +int getelemID(); + + +int main () +{ + //variables + FileTypeBox ftyp; + MediaDataBox mdat; + MovieBox moov; + MetaBox meta; + namestrack namet; + FILE *imf; + int numtrack,totaltracks=0, flags; +// char typetrack[6]; + + /* Obtain current time as seconds elapsed since the Epoch. */ + time_t clock = time(NULL); + + printf("Welcome 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); + //totaltracks = 1; + while (totaltracks > maxtracks) { + printf("Sorry, for this version the number maximum ot tracks is 10\n"); + printf("How many tracks there will be in your IMAF file:\n"); + scanf("%d",&totaltracks); + } + + //Create the file + imf = fopen ("/Users/eugin/Desktop/IM_AF Encoder/IM_AM Encoder/example1.ima","wb"); + if (imf == NULL) { + printf("Error opening input file\n"); + system("pause"); + exit(1); + } + + //Define the File Type Box + filetypebx(&ftyp); + fwrite(&ftyp, sizeof(FileTypeBox),1, imf); + + //Movie Header - Overall declarations + moovheaderbox(&moov, clock, numtrack); + + //For each track write track information + + for (numtrack = 0; numtrack < totaltracks; numtrack++) { + //flags = getflags(); + flags = 1; + if (flags == 1){ // Track enable + + trackstructure(&moov, numtrack, clock, namet); + } + } + + //Groups + groupscontainer(&moov); + + //Presets + presetcontainer(&moov); + + //Write the information in FILE and close it + fwrite(&moov, sizeof(MovieBox),1, imf); + + //Metadata + metadata(&meta); + fwrite(&meta, sizeof(MetaBox),1, imf); + + //Media Data Box - Contains the audio + mdatbox(&mdat, totaltracks, &namet, imf); + + //Close File + fclose(imf); + + //Testing the code....... + imf = fopen ("/Users/eugin/Desktop/IM_AF Encoder/IM_AM Encoder/example1.ima","rb"); + fread(&ftyp,sizeof(FileTypeBox),1,imf); + fclose(imf); + printf("minor version %d\n",ftyp.compatible_brands[0]); + return 0; +} + +void filetypebx(FileTypeBox *ftyp){ + + ftyp->major_brand = 'im01'; + ftyp->minor_version = '0'; + ftyp->compatible_brands[0] = 'im01'; + ftyp->compatible_brands[1] = 'isom'; + ftyp->compatible_brands[2] = 'im03'; + ftyp->compatible_brands[3] = 'im12'; + ftyp->compatible_brands[4] = 'im21'; +} + +void mdatbox(MediaDataBox *mdat, int totaltracks, namestrack *namet, FILE *imf){ + + int exist, i, cnt, sz; + FILE *song; + char nametrack[20], pathdir[60] ="/Users/eugin/Desktop/IM_AF Encoder/"; + + for (i=0; i<totaltracks; i++) { + strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/"); + printf("Name of the track number: %d\n", i+1); + fflush(stdin); + scanf("%s", nametrack); + strcat(pathdir, nametrack); + exist = 0; + //Check if the track exist and then open it. + while (exist == 0){ + song = fopen(pathdir, "rb"); + if((song)==NULL) { + printf("Name does not exist. Try again:\n"); + fflush(stdin); + scanf("%s", nametrack); + strcpy(pathdir, "/Users/eugin/Desktop/IM_AF Encoder/"); + strcat(pathdir, nametrack); + printf("%s\n",pathdir); + }else{ + exist = 1; + } + } + strcpy (namet[i]->title, nametrack); + fseek(song, 0L, SEEK_END); + sz = ftell(song); + printf("%d \n",sz); + //Read track + fseek (song, 0, SEEK_SET); + + for (cnt = 0; cnt < 200000; cnt++) { + // printf("%d\n", cnt); + fread(&mdat[i]->data, sizeof(u32),1,song); + fwrite(&mdat, sizeof(MediaDataBox),1, imf); + } + fclose(song); + } + +} + +void moovheaderbox (MovieBox *moov,int clock, int numtrack){ + + moov->MovieHeaderBox.creation_time = clock; + moov->MovieHeaderBox.modification_time = clock; + moov->MovieHeaderBox.timescale = 60; +// moov->MovieHeaderBox.duration = getdurationtrack(); + moov->MovieHeaderBox.duration = 10; + moov->MovieHeaderBox.rate = 1; + moov->MovieHeaderBox.volume = 1; + moov->MovieHeaderBox.reserved=0; + moov->MovieHeaderBox.reserved2[0] = 0; + moov->MovieHeaderBox.reserved2[1] = 0; + moov->MovieHeaderBox.matrix[0] = 0x00010000; + moov->MovieHeaderBox.matrix[1] = 0; + moov->MovieHeaderBox.matrix[2] = 0; + moov->MovieHeaderBox.matrix[3] = 0; + moov->MovieHeaderBox.matrix[4] = 0x00010000; + moov->MovieHeaderBox.matrix[5] = 0; + moov->MovieHeaderBox.matrix[6] = 0; + moov->MovieHeaderBox.matrix[7] = 0; + moov->MovieHeaderBox.matrix[8] = 0x40000000; + moov->MovieHeaderBox.pre_defined[0] = 0; + moov->MovieHeaderBox.pre_defined[1] = 0; + moov->MovieHeaderBox.pre_defined[2] = 0; + moov->MovieHeaderBox.pre_defined[3] = 0; + moov->MovieHeaderBox.pre_defined[4] = 0; + moov->MovieHeaderBox.pre_defined[5] = 0; +// moov->MovieHeaderBox.next_track_ID = getnextID(); + moov->MovieHeaderBox.next_track_ID = numtrack + 2; +} + +void trackstructure (MovieBox *moov, int numtrack, int clock, namestrack namet){ + + //Track Header// + moov->TrackBox[numtrack].TrackHeaderBox.creation_time = clock; + moov->TrackBox[numtrack].TrackHeaderBox.modification_time = clock; + moov->TrackBox[numtrack].TrackHeaderBox.track_ID = numtrack + 1; //From 0x00000001 - 0x7FFFFFFF (dec 2147483647) + moov->TrackBox[numtrack].TrackHeaderBox.reserved = 0; + // moov->TrackBox[numtrack].TrackHeaderBox.duration = getdurationtrack(); + moov->TrackBox[numtrack].TrackHeaderBox.reserved2[0] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.reserved2[1] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.layer = 0; + moov->TrackBox[numtrack].TrackHeaderBox.alternate_group = 0; + moov->TrackBox[numtrack].TrackHeaderBox.volume = 1; + moov->TrackBox[numtrack].TrackHeaderBox.reserved3 = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[0] = 0x00010000; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[1] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[2] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[3] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[4] = 0x00010000; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[5] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[6] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[7] = 0; + moov->TrackBox[numtrack].TrackHeaderBox.matrix[8] = 0x40000000; + moov->TrackBox[numtrack].TrackHeaderBox.width = 0; //just for video + moov->TrackBox[numtrack].TrackHeaderBox.height = 0; //just for video + + //Track reference box + //No hint tracks at the moment. + moov->TrackBox[numtrack].TrackReferenceBox.reference_type = 'cdsc'; + moov->TrackBox[numtrack].TrackReferenceBox.track_ID = numtrack + 1; + + /* //Edit list box + int entry_count,i; + + entry_count = getentrycount(); + for (i=1; i<entry_count; i++) { + moov->TrackBox[numtrack].EditListBox.segment_duration = 0; + } + */ + + //Media Box// + + //Media Header Box// + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.creation_time = clock; + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.modification_time = clock; + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.timescale = 60; +// moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.duration = getdurationtrack(); + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.language[0] = 'a'; + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.language[1] = 'n'; + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.language[2] = 'g'; + moov->TrackBox[numtrack].MediaBox.MediaHeaderBox.pre_defined = 0; + + //Handler Box// + moov->TrackBox[numtrack].MediaBox.HandlerBox.pre_defined = 0; + //If we want to introduce another type of track change here: + moov->TrackBox[numtrack].MediaBox.HandlerBox.handler_type = 'soun'; + moov->TrackBox[numtrack].MediaBox.HandlerBox.reserved[0] = 0; + moov->TrackBox[numtrack].MediaBox.HandlerBox.reserved[1] = 0; + moov->TrackBox[numtrack].MediaBox.HandlerBox.reserved[2] = 0; + //Use the name from Media Data Box to store it in HandlerBox.name: + strcpy(moov->TrackBox[numtrack].MediaBox.HandlerBox.name, namet[numtrack].title); + + //Media Information Box// + + //Sound Header Box // + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SoundMediaHeaderBox.balance = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SoundMediaHeaderBox.reserved = 0; + + //Hint Header Box// + //In case of hint track follow the box + /*moov->TrackBox[numtrack].MediaBox.MediaInformationBox.HintMediaHeaderBox.maxPDUsize = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.HintMediaHeaderBox.avgPDUsize = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.HintMediaHeaderBox.maxbitrate = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.HintMediaHeaderBox.avgbitrate = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.HintMediaHeaderBox.reserved = 0; + */ + + //Data information Box// + //In case we want add tracks located in the web + + int flag = 1; // means that the media data is in the same file.No string, not even empty one + //shall ve suplied in the entry field. + + //If track is in URL add info here. + //Just admit URL data + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.DataInformationBox.DataEntryUrlBox.flags = 1; + if(flag == 0){ + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.DataInformationBox.DataEntryUrlBox.location = 0; + //moov->TrackBox[numtrack].MediaBox.MediaInformationBox.DataInformationBox.DataEntryUrnBox.name = 0; + //moov->TrackBox[numtrack].MediaBox.MediaInformationBox.DataInformationBox.DataEntryUrnBox.location = 0; + } + + //el samplecontainer(moov, numtrack); + +} + +void samplecontainer(MovieBox *moov, int numtrack){ + + //Sample Table Box // + int numdatareferences = 0; + + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[0] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[1] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[2] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[3] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[4] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.SampleEntry.reserved[5] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox. + SampleEntry.format = 'wav'; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox. + SampleEntry.data_reference_index = numdatareferences; //Find more info + //No hinttrack at the moment. + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.HintSampleEntry.data = 0; + + //BitRate + + // moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox. + // BitRateBox.bufferSizeDB = sizetrack(); + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.BitRateBox + .maxBitrate = 1411000; //In this case wav at 1441Kbps + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox.BitRateBox + .avgBitrate = 1411000; + + //Sample description box + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .SampleDescriptionBox.handler_type = 'soun'; //Just audio! + + int i, entry; + entry=1; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .SampleDescriptionBox.entry_count = entry; //Check this later!!! + + //No metadata and hint tracks, neither URI at the moment + for (i=0; i<=entry; i++) { + switch (moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .SampleDescriptionBox.handler_type) { + case 'soun': //For audio tracks + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.reserved[0] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.reserved[1] = 0; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.channelcount = 1; //The tracks are mono. + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.samplesize = 16; + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.pre_defined = 0; + //Ask Panos!! + moov->TrackBox[numtrack].MediaBox.MediaInformationBox.SampleTableBox + .AudioSampleEntry.samplerate = 441000; //44.1Khz + break; + case 'hint': //Hint tracks + //HintSampleEntry(); + break; + case 'meta': //Metadata tracks + // MetadataSampleEntry(); + default: + break; + } + } + +} + +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 presetcontainer(MovieBox *moov){ + + int i, j, k, l, m, numpres=0, flag=0; + int num_output_channel = 2; // Stereo + char numelempres=0, prestype=0, namepres[30]; + u16 globalvol=0, voltrack=0, num_updates =0 ; + char* fmt = "%[^\n]%*c"; + + printf("Define the number of presets: (10 max)\n"); + scanf("%d",&numpres); + moov->PresetContainerBox.num_preset = numpres; + moov->PresetContainerBox.default_preset_ID = 0; // Indicates initial preset activated. + getchar(); + fflush(stdin); + for (i=0; i<numpres; i++) { + + printf("Enter name for the preset %d\n",i+1 ); + fflush(stdin); + scanf(fmt,namepres); + strcpy(moov->PresetContainerBox.PresetBox[i].preset_name, namepres); + + printf("Select mode of preset %s:\n",namepres); + printf("Mode | Display | Edit\n"); + printf("---- | ------- | -------\n"); + printf(" 1 | disable | disable\n"); + printf(" 2 | enable | disable\n"); + printf(" 3 | enable | enable\n"); + scanf("%d",&flag); + + moov->PresetContainerBox.PresetBox[i].preset_ID = numpres+1; + + printf("Select type for preset %s:\n",namepres); + printf("preset_type | Meaning\n"); + printf("----------- | ---------------------------\n"); + printf(" 0 | static track volume preset\n"); + printf(" 1 | static object volume preset\n"); + printf(" 2 | dynamic track volume preset\n"); + printf(" 3 | dynamic object volume preset\n"); + //scanf(" %c", &prestype); + prestype = 0; + moov->PresetContainerBox.PresetBox[i].preset_type = prestype; + + printf("Select the playback volume gain of preset output %d\n",i+1); + printf(" index | 0 | 1 | 2 | 3 | ... | 149 | 150 |\n"); + printf("value(ratio) | 0 |0.01 |0.02 |0.03 | ... |1.49 |1.50 |\n"); + scanf("%d",&globalvol); + printf("Gloval volume %d\n",globalvol); + moov->PresetContainerBox.PresetBox[i].preset_global_volume = globalvol; + + printf("Enter number of elements in the preset: (10 max)\n"); + scanf(" %c", &numelempres); + moov->PresetContainerBox.PresetBox[i].num_preset_elements = numelempres; + + moov->PresetContainerBox.PresetBox[i].preset_element_ID[j] = numelempres +1; + + printf("Select the playback volume gain of element %d\n",k+1); + printf(" index | 0 | 1 | 2 | 3 | ... | 199 | 200 |\n"); + printf("value(ratio) | 0 |0.02 |0.04 |0.06 | ... |3.98 |4.00 |\n"); + scanf("%d",&voltrack); + + if(prestype == 0){ + for (j=1; j<numelempres; j++) { + moov->PresetContainerBox.PresetBox[i].preset_volume_element[j] = voltrack; + } + } + if(prestype == 1){ + moov->PresetContainerBox.PresetBox[i].num_input_channel[j] = 2; //All tracks stereo + moov->PresetContainerBox.PresetBox[i].output_channel_type = 2; + for (j=1; j<numelempres; j++) { + for (m=0; m<moov->PresetContainerBox.PresetBox[i].num_input_channel[j]; m++){ + for (k=0; k<num_output_channel; k++){ + moov->PresetContainerBox.PresetBox[i].preset_volume_element[j] = voltrack; + } + } + } + } + if(prestype == 2){ // dynamic track volume preset + moov->PresetContainerBox.PresetBox[i].num_updates = num_updates; //No updates for the moment + for(l=0; l<num_updates; l++){ + moov->PresetContainerBox.PresetBox[i].update_sample_number = 0; + for(j=0; j<numelempres; j++){ + moov->PresetContainerBox.PresetBox[i].preset_volume_element[j] = voltrack; + } + } + } + if(prestype == 3){ // dynamic object volume preset + moov->PresetContainerBox.PresetBox[i].num_updates = num_updates; //No updates for the moment + moov->PresetContainerBox.PresetBox[i].num_input_channel[j] = 2; //All tracks stereo + moov->PresetContainerBox.PresetBox[i].output_channel_type = 2; + for(l=0; l<num_updates; l++){ + moov->PresetContainerBox.PresetBox[i].update_sample_number = 0; + for(j=0; j<numelempres; j++){ + for (k=0; k<num_output_channel; k++){ + moov->PresetContainerBox.PresetBox[i].preset_volume_element[j] = voltrack; + } + } + } + } + } +} + +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 +} + + + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder/stdlib.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,210 @@ +/* + * stdlib.h + * + * Definitions for common types, variables, and 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:00 $ + * + */ +/* Appropriated for Reactos Crtdll by Ariadne */ +/* added splitpath */ +/* changed definition of environ and argc */ +/* moved prototype for swab from string.h to stdlib.h */ +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + /* + * This seems like a convenient place to declare these variables, which + * give programs using WinMain (or main for that matter) access to main-ish + * argc and argv. environ is a pointer to a table of environment variables. + * NOTE: Strings in _argv and environ are ANSI strings. + */ + extern int* __argc_dll; + extern char*** __argv_dll; + extern char*** _environ_dll; +#define __argc (*__argc_dll) +#define __argv (*__argv_dll) +#define _environ (*_environ_dll) + + +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#include <crtdll/stddef.h> + +#include <crtdll/mbstring.h> + +#ifndef __ATTRIB_NORETURN +#ifdef __GNUC__ +#define _ATTRIB_NORETURN __attribute__ ((noreturn)) +#else /* Not __GNUC__ */ +#define _ATTRIB_NORETURN +#endif /* __GNUC__ */ +#endif + + double atof (const char* szNumber); + int atoi (const char* szNumber); + long atol (const char* szNumber); + + + double strtod (const char* szNumber, char** pszAfterNumber); + double wcstod (const wchar_t* wsNumber, wchar_t** pwsAfterNumber); + long strtol (const char* szNumber, char** pszAfterNumber, int nBase); + long wcstol (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, int nBase); + + unsigned long strtoul (const char* szNumber, char** pszAfterNumber, + int nBase); + unsigned long wcstoul (const wchar_t* wsNumber, wchar_t** pwsAfterNumber, + int nBase); + + size_t wcstombs (char* mbsDest, const wchar_t* wsConvert, size_t size); + int wctomb (char* mbDest, wchar_t wc); + + int mblen (const char* mbs, size_t sizeString); + size_t mbstowcs (wchar_t* wcaDest, const char* mbsConvert, + size_t size); + int mbtowc (wchar_t* wcDest, const char* mbConvert, size_t size); + + + /* + * RAND_MAX is the maximum value that may be returned by rand. + * The minimum is zero. + */ +#define RAND_MAX 0x7FFF + + int rand (void); + void srand (unsigned int nSeed); + + + void* calloc (size_t sizeObjCnt, size_t sizeObject); + void* malloc (size_t sizeObject); + void* realloc (void* pObject, size_t sizeNew); + void free (void* pObject); + + /* These values may be used as exit status codes. */ +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE -1 + + void abort (void) _ATTRIB_NORETURN; + void exit (int nStatus) _ATTRIB_NORETURN; + int atexit (void (*pfuncExitProcessing)(void)); + + int system (const char* szCommand); // impl in process + char* getenv (const char* szVarName); // impl in stdio + + typedef int (*_pfunccmp_t)(const void*, const void*); + + void* bsearch (const void* pKey, const void* pBase, size_t cntObjects, + size_t sizeObject, _pfunccmp_t pfuncCmp); + void qsort (const void* pBase, size_t cntObjects, size_t sizeObject, + _pfunccmp_t pfuncCmp); + + int abs (int n); + long labs (long n); + + /* + * div_t and ldiv_t are structures used to return the results of div and + * ldiv. + * + * NOTE: div and ldiv appear not to work correctly unless + * -fno-pcc-struct-return is specified. This is included in the + * mingw32 specs file. + */ + typedef struct { int quot, rem; } div_t; + typedef struct { long quot, rem; } ldiv_t; + typedef struct { long long quot, rem; } lldiv_t; + + div_t div (int nNumerator, int nDenominator); + ldiv_t ldiv (long lNumerator, long lDenominator); + lldiv_t lldiv (long long lNumerator, long long lDenominator); + + +#ifndef __STRICT_ANSI__ + + /* + * NOTE: Officially the three following functions are obsolete. The Win32 API + * functions SetErrorMode, Beep and Sleep are their replacements. + */ + void _beep (unsigned int, unsigned int); + void _seterrormode (int nMode); + void _sleep (unsigned long ulTime); + + void _exit (int nStatus) _ATTRIB_NORETURN; + + int _putenv (const char* szNameEqValue); + void _searchenv (const char* szFileName, const char* szVar, + char* szFullPathBuf); + + void _splitpath( const char *path, char *drive, char *dir, + char *fname, char *ext ); + + char* _itoa (int nValue, char* sz, int nRadix); + char* _ltoa (long lnValue, char* sz, int nRadix); + + char* _ecvt (double dValue, int nDig, int* pnDec, int* pnSign); + char* _fcvt (double dValue, int nDig, int* pnDec, int* pnSign); + char* _gcvt (double dValue, int nDec, char* caBuf); + + char* _fullpath (char* caBuf, const char* szPath, size_t sizeMax); + + void _swab (const char* caFrom, char* caTo, size_t sizeToCopy); + + unsigned int _rotl( unsigned int value, int shift ); + unsigned int _rotr( unsigned int value, int shift ); + unsigned long _lrotl( unsigned long value, int shift ); + unsigned long _lrotr( unsigned long value, int shift ); + + + + +#ifndef _NO_OLDNAMES +#define beep _beep +#define seterrormode _seterrormode +#define sleep _sleep +#define putenv _putenv +#define searchenv _searchenv +#define splitpath _splitpath + +#define itoa _itoa +#define ltoa _ltoa + +#define ecvt _ecvt +#define fcvt _fcvt +#define gcvt _gcvt + +#define swab _swab +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + + /* + * Undefine the no return attribute used in some function definitions + */ +#undef _ATTRIB_NORETURN + +#ifdef __cplusplus +} +#endif + +#endif /* _STDLIB_H_ */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/IM_AM Encoder/string.g.h Wed Jul 04 22:16:23 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/stdarg.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,50 @@ +/*===---- stdarg.h - Variable argument handling ----------------------------=== + * + * Copyright (c) 2008 Eli Friedman + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDARG_H +#define __STDARG_H + +#ifndef _VA_LIST +typedef __builtin_va_list va_list; +#define _VA_LIST +#endif +#define va_start(ap, param) __builtin_va_start(ap, param) +#define va_end(ap) __builtin_va_end(ap) +#define va_arg(ap, type) __builtin_va_arg(ap, type) + +/* GCC always defines __va_copy, but does not define va_copy unless in c99 mode + * or -ansi is not specified, since it was not part of C90. + */ +#define __va_copy(d,s) __builtin_va_copy(d,s) + +#if __STDC_VERSION__ >= 199900L || __cplusplus >= 201103L || !defined(__STRICT_ANSI__) +#define va_copy(dest, src) __builtin_va_copy(dest, src) +#endif + +/* Hack required to make standard headers work, at least on Ubuntu */ +#define __GNUC_VA_LIST 1 +typedef __builtin_va_list __gnuc_va_list; + +#endif /* __STDARG_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/stddef.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,64 @@ +/*===---- stddef.h - Basic type definitions --------------------------------=== + * + * Copyright (c) 2008 Eli Friedman + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===-----------------------------------------------------------------------=== + */ + +#ifndef __STDDEF_H +#define __STDDEF_H + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef __typeof__(((int*)0)-((int*)0)) ptrdiff_t; +#endif +#ifndef _SIZE_T +#define _SIZE_T +typedef __typeof__(sizeof(int)) size_t; +#endif +#ifndef __cplusplus +#ifndef _WCHAR_T +#define _WCHAR_T +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif + +#undef NULL +#ifdef __cplusplus +#undef __null // VC++ hack. +#define NULL __null +#else +#define NULL ((void*)0) +#endif + +#define offsetof(t, d) __builtin_offsetof(t, d) + +#endif /* __STDDEF_H */ + +/* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use +__WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */ +#if defined(__need_wint_t) +#if !defined(_WINT_T) +#define _WINT_T +typedef __WINT_TYPE__ wint_t; +#endif /* _WINT_T */ +#undef __need_wint_t +#endif /* __need_wint_t */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IM_AF Encoder/stdio.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,516 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdio.h 8.5 (Berkeley) 4/29/95 + * $FreeBSD$ + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#include <sys/cdefs.h> +#include <sys/_null.h> +#include <sys/_types.h> + +typedef __off_t fpos_t; + +#ifndef _SIZE_T_DECLARED +typedef __size_t size_t; +#define _SIZE_T_DECLARED +#endif + +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +#ifndef _OFF_T_DECLARED +#define _OFF_T_DECLARED +typedef __off_t off_t; +#endif +#ifndef _SSIZE_T_DECLARED +#define _SSIZE_T_DECLARED +typedef __ssize_t ssize_t; +#endif +#endif + +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE +#ifndef _VA_LIST_DECLARED +typedef __va_list va_list; +#define _VA_LIST_DECLARED +#endif +#endif + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + * + * Certain members of __sFILE are accessed directly via macros or + * inline functions. To preserve ABI compat, these members must not + * be disturbed. These members are marked below with (*). + */ +typedef struct __sFILE { + unsigned char *_p; /* (*) current position in (some) buffer */ + int _r; /* (*) read space left for getc() */ + int _w; /* (*) write space left for putc() */ + short _flags; /* (*) flags, below; this FILE is free if 0 */ + short _file; /* (*) fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* (*) the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* (*) 0 or -_bf._size, for inline putc */ + + /* operations */ + void *_cookie; /* (*) cookie passed to io functions */ + int (*_close)(void *); + int (*_read)(void *, char *, int); + fpos_t (*_seek)(void *, fpos_t, int); + int (*_write)(void *, const char *, int); + + /* separate buffer for long sequences of ungetc() */ + struct __sbuf _ub; /* ungetc buffer */ + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + /* separate buffer for fgetln() when line crosses buffer boundary */ + struct __sbuf _lb; /* buffer for fgetln() */ + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + fpos_t _offset; /* current lseek offset */ + + struct pthread_mutex *_fl_mutex; /* used for MT-safety */ + struct pthread *_fl_owner; /* current owner */ + int _fl_count; /* recursive lock count */ + int _orientation; /* orientation for fwide() */ + __mbstate_t _mbstate; /* multibyte conversion state */ +} FILE; + +#ifndef _STDSTREAM_DECLARED +__BEGIN_DECLS +extern FILE *__stdinp; +extern FILE *__stdoutp; +extern FILE *__stderrp; +__END_DECLS +#define _STDSTREAM_DECLARED +#endif + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ +/* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimization */ +#define __SNPT 0x0800 /* do not do fseek() optimization */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ +#define __SALC 0x4000 /* allocate string space dynamically */ +#define __SIGN 0x8000 /* ignore this file in _fwalk */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and is the number of streams that + * stdio can provide without attempting to allocate further resources + * (which could fail). Do not use this for anything. + */ +/* must be == _POSIX_STREAM_MAX <limits.h> */ +#ifndef FOPEN_MAX +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ +#endif +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#if __XSI_VISIBLE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#define TMP_MAX 308915776 + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin __stdinp +#define stdout __stdoutp +#define stderr __stderrp + +__BEGIN_DECLS +/* + * Functions defined in ANSI C standard. + */ +void clearerr(FILE *); +int fclose(FILE *); +int feof(FILE *); +int ferror(FILE *); +int fflush(FILE *); +int fgetc(FILE *); +int fgetpos(FILE * __restrict, fpos_t * __restrict); +char *fgets(char * __restrict, int, FILE * __restrict); +FILE *fopen(const char * __restrict, const char * __restrict); +int fprintf(FILE * __restrict, const char * __restrict, ...); +int fputc(int, FILE *); +int fputs(const char * __restrict, FILE * __restrict); +size_t fread(void * __restrict, size_t, size_t, FILE * __restrict); +FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict); +int fscanf(FILE * __restrict, const char * __restrict, ...); +int fseek(FILE *, long, int); +int fsetpos(FILE *, const fpos_t *); +long ftell(FILE *); +size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict); +int getc(FILE *); +int getchar(void); +char *gets(char *); +void perror(const char *); +int printf(const char * __restrict, ...); +int putc(int, FILE *); +int putchar(int); +int puts(const char *); +int remove(const char *); +int rename(const char *, const char *); +void rewind(FILE *); +int scanf(const char * __restrict, ...); +void setbuf(FILE * __restrict, char * __restrict); +int setvbuf(FILE * __restrict, char * __restrict, int, size_t); +int sprintf(char * __restrict, const char * __restrict, ...); +int sscanf(const char * __restrict, const char * __restrict, ...); +FILE *tmpfile(void); +char *tmpnam(char *); +int ungetc(int, FILE *); +int vfprintf(FILE * __restrict, const char * __restrict, + __va_list); +int vprintf(const char * __restrict, __va_list); +int vsprintf(char * __restrict, const char * __restrict, + __va_list); + +#if __ISO_C_VISIBLE >= 1999 +int snprintf(char * __restrict, size_t, const char * __restrict, + ...) __printflike(3, 4); +int vfscanf(FILE * __restrict, const char * __restrict, __va_list) +__scanflike(2, 0); +int vscanf(const char * __restrict, __va_list) __scanflike(1, 0); +int vsnprintf(char * __restrict, size_t, const char * __restrict, + __va_list) __printflike(3, 0); +int vsscanf(const char * __restrict, const char * __restrict, __va_list) +__scanflike(2, 0); +#endif + +/* + * Functions defined in all versions of POSIX 1003.1. + */ +#if __BSD_VISIBLE || __POSIX_VISIBLE <= 199506 +/* size for cuserid(3); UT_NAMESIZE + 1, see <utmp.h> */ +#define L_cuserid 17 /* legacy */ +#endif + +#if __POSIX_VISIBLE +#define L_ctermid 1024 /* size for ctermid(3); PATH_MAX */ + +char *ctermid(char *); +FILE *fdopen(int, const char *); +int fileno(FILE *); +#endif /* __POSIX_VISIBLE */ + +#if __POSIX_VISIBLE >= 199209 +int pclose(FILE *); +FILE *popen(const char *, const char *); +#endif + +#if __POSIX_VISIBLE >= 199506 +int ftrylockfile(FILE *); +void flockfile(FILE *); +void funlockfile(FILE *); + +/* + * These are normally used through macros as defined below, but POSIX + * requires functions as well. + */ +int getc_unlocked(FILE *); +int getchar_unlocked(void); +int putc_unlocked(int, FILE *); +int putchar_unlocked(int); +#endif +#if __BSD_VISIBLE +void clearerr_unlocked(FILE *); +int feof_unlocked(FILE *); +int ferror_unlocked(FILE *); +int fileno_unlocked(FILE *); +#endif + +#if __POSIX_VISIBLE >= 200112 +int fseeko(FILE *, __off_t, int); +__off_t ftello(FILE *); +#endif + +#if __BSD_VISIBLE || __XSI_VISIBLE > 0 && __XSI_VISIBLE < 600 +int getw(FILE *); +int putw(int, FILE *); +#endif /* BSD or X/Open before issue 6 */ + +#if __XSI_VISIBLE +char *tempnam(const char *, const char *); +#endif + +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +ssize_t getdelim(char ** __restrict, size_t * __restrict, int, + FILE * __restrict); +int renameat(int, const char *, int, const char *); +int vdprintf(int, const char * __restrict, __va_list); + +/* + * Every programmer and his dog wrote functions called getline() and dprintf() + * before POSIX.1-2008 came along and decided to usurp the names, so we + * don't prototype them by default unless one of the following is true: + * a) the app has requested them specifically by defining _WITH_GETLINE or + * _WITH_DPRINTF, respectively + * b) the app has requested a POSIX.1-2008 environment via _POSIX_C_SOURCE + * c) the app defines a GNUism such as _BSD_SOURCE or _GNU_SOURCE + */ +#ifndef _WITH_GETLINE +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#define _WITH_GETLINE +#elif defined(_POSIX_C_SOURCE) +#if _POSIX_C_SOURCE >= 200809 +#define _WITH_GETLINE +#endif +#endif +#endif + +#ifdef _WITH_GETLINE +ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict); +#endif + +#ifndef _WITH_DPRINTF +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +#define _WITH_DPRINTF +#elif defined(_POSIX_C_SOURCE) +#if _POSIX_C_SOURCE >= 200809 +#define _WITH_DPRINTF +#endif +#endif +#endif + +#ifdef _WITH_DPRINTF +int (dprintf)(int, const char * __restrict, ...); +#endif + +#endif /* __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 */ + +/* + * Routines that are purely local. + */ +#if __BSD_VISIBLE +int asprintf(char **, const char *, ...) __printflike(2, 3); +char *ctermid_r(char *); +void fcloseall(void); +char *fgetln(FILE *, size_t *); +const char *fmtcheck(const char *, const char *) __format_arg(2); +int fpurge(FILE *); +void setbuffer(FILE *, char *, int); +int setlinebuf(FILE *); +int vasprintf(char **, const char *, __va_list) +__printflike(2, 0); + +/* + * The system error table contains messages for the first sys_nerr + * positive errno values. Use strerror() or strerror_r() from <string.h> + * instead. + */ +extern __const int sys_nerr; +extern __const char *__const sys_errlist[]; + +/* + * Stdio function-access interface. + */ +FILE *funopen(const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + fpos_t (*)(void *, fpos_t, int), + int (*)(void *)); +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) + +/* + * Portability hacks. See <sys/types.h>. + */ +#ifndef _FTRUNCATE_DECLARED +#define _FTRUNCATE_DECLARED +int ftruncate(int, __off_t); +#endif +#ifndef _LSEEK_DECLARED +#define _LSEEK_DECLARED +__off_t lseek(int, __off_t, int); +#endif +#ifndef _MMAP_DECLARED +#define _MMAP_DECLARED +void *mmap(void *, size_t, int, int, int, __off_t); +#endif +#ifndef _TRUNCATE_DECLARED +#define _TRUNCATE_DECLARED +int truncate(const char *, __off_t); +#endif +#endif /* __BSD_VISIBLE */ + +/* + * Functions internal to the implementation. + */ +int __srget(FILE *); +int __swbuf(int, FILE *); + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +static __inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ +(--(p)->_w < 0 ? \ +(p)->_w >= (p)->_lbfsize ? \ +(*(p)->_p = (c)), *(p)->_p != '\n' ? \ +(int)*(p)->_p++ : \ +__swbuf('\n', p) : \ +__swbuf((int)(c), p) : \ +(*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +extern int __isthreaded; + +#define feof(p) (!__isthreaded ? __sfeof(p) : (feof)(p)) +#define ferror(p) (!__isthreaded ? __sferror(p) : (ferror)(p)) +#define clearerr(p) (!__isthreaded ? __sclearerr(p) : (clearerr)(p)) + +#if __POSIX_VISIBLE +#define fileno(p) (!__isthreaded ? __sfileno(p) : (fileno)(p)) +#endif + +#define getc(fp) (!__isthreaded ? __sgetc(fp) : (getc)(fp)) +#define putc(x, fp) (!__isthreaded ? __sputc(x, fp) : (putc)(x, fp)) + +#define getchar() getc(stdin) +#define putchar(x) putc(x, stdout) + +#if __BSD_VISIBLE +/* + * See ISO/IEC 9945-1 ANSI/IEEE Std 1003.1 Second Edition 1996-07-12 + * B.8.2.7 for the rationale behind the *_unlocked() macros. + */ +#define feof_unlocked(p) __sfeof(p) +#define ferror_unlocked(p) __sferror(p) +#define clearerr_unlocked(p) __sclearerr(p) +#define fileno_unlocked(p) __sfileno(p) +#endif +#if __POSIX_VISIBLE >= 199506 +#define getc_unlocked(fp) __sgetc(fp) +#define putc_unlocked(x, fp) __sputc(x, fp) + +#define getchar_unlocked() getc_unlocked(stdin) +#define putchar_unlocked(x) putc_unlocked(x, stdout) +#endif + +__END_DECLS +#endif /* !_STDIO_H_ */ \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mp4Atoms code/MP4Atoms.c Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,769 @@ +/* +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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mp4Atoms code/MP4Atoms.h Wed Jul 04 22:16:23 2012 +0100 @@ -0,0 +1,1486 @@ +/* +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