Skip to content

Commit 34288c5

Browse files
authored
Merge pull request #34 from podborski/mebx
Merging this PR as it was open for quite a while now. The mebx files produced with this code have been verified by multiple MPEG members.
2 parents 7eaf048 + bd84c72 commit 34288c5

28 files changed

+2369
-183
lines changed

IsoLib/libisomediafile/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ add_library(
141141
src/MP4MovieFile.c
142142
src/MP4Movies.c
143143
src/MP4ObjectDescriptor.c
144+
src/MP4MebxTrackReader.c
144145
src/MP4ODTrackReader.c
145146
src/MP4OrdinaryTrackReader.c
146147
src/MP4SLPacket.c
@@ -208,6 +209,12 @@ add_library(
208209
src/VolumetricVisualSampleEntryAtom.c
209210
src/HapticSampleEntryAtom.c
210211
src/XMLMetaSampleEntry.c
212+
src/BoxedMetadataSampleEntry.c
213+
src/MetadataKeyDeclarationBox.c
214+
src/MetadataKeyTableBox.c
215+
src/MetadataKeyBox.c
216+
src/MetadataLocaleBox.c
217+
src/MetadataSetupBox.c
211218
src/GroupsListBox.c
212219
src/EntityToGroupBox.c
213220

IsoLib/libisomediafile/src/AudioSampleEntryAtom.c

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,19 @@
1+
/* This software module was originally developed by Apple Computer, Inc. in the course of
2+
* development of MPEG-4. This software module is an implementation of a part of one or more MPEG-4
3+
* tools as specified by MPEG-4. ISO/IEC gives users of MPEG-4 free license to this software module
4+
* or modifications thereof for use in hardware or software products claiming conformance to MPEG-4.
5+
* Those intending to use this software module in hardware or software products are advised that its
6+
* use may infringe existing patents. The original developer of this software module and his/her
7+
* company, the subsequent editors and their companies, and ISO/IEC have no liability for use of
8+
* this software module or modifications thereof in an implementation. Copyright is not released for
9+
* non MPEG-4 conforming products. Apple Computer, Inc. retains full right to use the code for its
10+
* own purpose, assign or donate the code to a third party and to inhibit third parties from using
11+
* the code for non MPEG-4 conforming products. This copyright notice must be included in all copies
12+
* or derivative works. Copyright (c) 1999.
13+
*/
14+
115
/*
2-
This software module was originally developed by Apple Computer, Inc.
3-
in the course of development of MPEG-4.
4-
This software module is an implementation of a part of one or
5-
more MPEG-4 tools as specified by MPEG-4.
6-
ISO/IEC gives users of MPEG-4 free license to this
7-
software module or modifications thereof for use in hardware
8-
or software products claiming conformance to MPEG-4.
9-
Those intending to use this software module in hardware or software
10-
products are advised that its use may infringe existing patents.
11-
The original developer of this software module and his/her company,
12-
the subsequent editors and their companies, and ISO/IEC have no
13-
liability for use of this software module or modifications thereof
14-
in an implementation.
15-
Copyright is not released for non MPEG-4 conforming
16-
products. Apple Computer, Inc. retains full right to use the code for its own
17-
purpose, assign or donate the code to a third party and to
18-
inhibit third parties from using the code for non
19-
MPEG-4 conforming products.
20-
This copyright notice must be included in all copies or
21-
derivative works. Copyright (c) 1999.
22-
*/
23-
/*
24-
$Id: AudioSampleEntryAtom.c,v 1.1.1.1 2002/09/20 08:53:34 julien Exp $
16+
$Id: AudioSampleEntryAtom.c,v 1.1.1.1 2002/09/20 08:53:34 julien Exp $
2517
*/
2618

2719
#include "MP4Atoms.h"
@@ -102,10 +94,46 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
10294
GET32(reserved5);
10395
GET16(timeScale);
10496
GET16(reserved6);
105-
GETATOM_LIST(ExtensionAtomList);
97+
98+
/* parse boxes and check if we encounter QTFF sample description */
99+
while(self->bytesRead < self->size)
100+
{
101+
MP4AtomPtr atm;
102+
u64 currentOffset = 0;
103+
u64 available = inputStream->available;
104+
u32 indent = inputStream->indent;
105+
MP4FileMappingInputStreamPtr fm = (MP4FileMappingInputStreamPtr)inputStream;
106+
currentOffset = fm->current_offset;
107+
err = MP4ParseAtom(inputStream, &atm);
108+
109+
if(self->bytesRead + atm->size > self->size && self->reserved2[1] == 1)
110+
{
111+
/* most likely we are parsing QTFF SoundDescriptionV1, rewind and parse 16 more bytes */
112+
atm->destroy(atm);
113+
inputStream->available = available;
114+
inputStream->indent = indent;
115+
fm->current_offset = currentOffset;
116+
117+
GET32(qtSamplesPerPacket);
118+
GET32(qtbytesPerPacket);
119+
GET32(qtbytesPerFrame);
120+
GET32(qtbytesPerSample);
121+
}
122+
else if(err == MP4NoErr)
123+
{
124+
self->bytesRead += atm->size;
125+
if(((atm->type) == MP4FreeSpaceAtomType) || ((atm->type) == MP4SkipAtomType))
126+
atm->destroy(atm);
127+
else
128+
{
129+
err = MP4AddListEntry((void *)atm, self->ExtensionAtomList);
130+
if(err) goto bail;
131+
}
132+
}
133+
}
134+
106135
bail:
107136
TEST_RETURN(err);
108-
109137
return err;
110138
}
111139

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/* This software module was originally developed by Apple Computer, Inc. in the course of
2+
* development of MPEG-4. This software module is an implementation of a part of one or more MPEG-4
3+
* tools as specified by MPEG-4. ISO/IEC gives users of MPEG-4 free license to this software module
4+
* or modifications thereof for use in hardware or software products claiming conformance to MPEG-4.
5+
* Those intending to use this software module in hardware or software products are advised that its
6+
* use may infringe existing patents. The original developer of this software module and his/her
7+
* company, the subsequent editors and their companies, and ISO/IEC have no liability for use of
8+
* this software module or modifications thereof in an implementation. Copyright is not released for
9+
* non MPEG-4 conforming products. Apple Computer, Inc. retains full right to use the code for its
10+
* own purpose, assign or donate the code to a third party and to inhibit third parties from using
11+
* the code for non MPEG-4 conforming products. This copyright notice must be included in all copies
12+
* or derivative works. Copyright (c) 2022.
13+
*/
14+
15+
#include "MP4Atoms.h"
16+
#include <stdlib.h>
17+
#include <string.h>
18+
19+
static void destroy(MP4AtomPtr s)
20+
{
21+
MP4Err err = MP4NoErr;
22+
MP4BoxedMetadataSampleEntryPtr self = (MP4BoxedMetadataSampleEntryPtr)s;
23+
if(self == NULL) BAILWITHERROR(MP4BadParamErr)
24+
25+
DESTROY_ATOM_LIST_F(ExtensionAtomList)
26+
27+
if(self->super) self->super->destroy(s);
28+
bail:
29+
TEST_RETURN(err);
30+
return;
31+
}
32+
33+
static MP4Err serialize(struct MP4Atom *s, char *buffer)
34+
{
35+
MP4Err err;
36+
MP4BoxedMetadataSampleEntryPtr self = (MP4BoxedMetadataSampleEntryPtr)s;
37+
38+
err = MP4SerializeCommonBaseAtomFields(s, buffer);
39+
if(err) goto bail;
40+
buffer += self->bytesWritten;
41+
42+
PUTBYTES(self->reserved, 6);
43+
PUT16(dataReferenceIndex);
44+
SERIALIZE_ATOM_LIST(ExtensionAtomList);
45+
46+
assert(self->bytesWritten == self->size);
47+
bail:
48+
TEST_RETURN(err);
49+
return err;
50+
}
51+
52+
static MP4Err calculateSize(struct MP4Atom *s)
53+
{
54+
MP4Err err;
55+
MP4BoxedMetadataSampleEntryPtr self = (MP4BoxedMetadataSampleEntryPtr)s;
56+
57+
err = MP4CalculateBaseAtomFieldSize(s);
58+
if(err) goto bail;
59+
self->size += (6 + 2);
60+
ADD_ATOM_LIST_SIZE(ExtensionAtomList);
61+
bail:
62+
TEST_RETURN(err);
63+
return err;
64+
}
65+
66+
static MP4Err addAtom(MP4BoxedMetadataSampleEntryPtr self, MP4AtomPtr atom)
67+
{
68+
MP4Err err;
69+
if(atom == NULL) BAILWITHERROR(MP4BadParamErr);
70+
if(atom->type == MP4MetadataKeyTableBoxType)
71+
{
72+
if(self->keyTable != 0) BAILWITHERROR(MP4BadParamErr);
73+
self->keyTable = (MP4MetadataKeyTableBoxPtr)atom;
74+
}
75+
76+
err = MP4AddListEntry(atom, self->ExtensionAtomList);
77+
if(err) goto bail;
78+
79+
bail:
80+
TEST_RETURN(err);
81+
return err;
82+
}
83+
84+
static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStreamPtr inputStream)
85+
{
86+
MP4Err err;
87+
MP4BoxedMetadataSampleEntryPtr self = (MP4BoxedMetadataSampleEntryPtr)s;
88+
89+
if(self == NULL) BAILWITHERROR(MP4BadParamErr)
90+
err = self->super->createFromInputStream(s, proto, (char *)inputStream);
91+
if(err) goto bail;
92+
93+
GETBYTES(6, reserved);
94+
GET16(dataReferenceIndex);
95+
96+
while(self->bytesRead < self->size)
97+
{
98+
MP4AtomPtr atom;
99+
err = MP4ParseAtom((MP4InputStreamPtr)inputStream, &atom);
100+
if(err) goto bail;
101+
self->bytesRead += atom->size;
102+
if(((atom->type) == MP4FreeSpaceAtomType) || ((atom->type) == MP4SkipAtomType))
103+
atom->destroy(atom);
104+
else
105+
{
106+
err = self->addAtom(self, atom);
107+
if(err) goto bail;
108+
}
109+
}
110+
111+
if(self->bytesRead != self->size) BAILWITHERROR(MP4BadDataErr)
112+
113+
bail:
114+
TEST_RETURN(err);
115+
return err;
116+
}
117+
118+
MP4Err MP4CreateMP4BoxedMetadataSampleEntry(MP4BoxedMetadataSampleEntryPtr *outAtom)
119+
{
120+
MP4Err err;
121+
MP4BoxedMetadataSampleEntryPtr self;
122+
123+
self = (MP4BoxedMetadataSampleEntryPtr)calloc(1, sizeof(MP4BoxedMetadataSampleEntry));
124+
TESTMALLOC(self)
125+
126+
err = MP4CreateBaseAtom((MP4AtomPtr)self);
127+
if(err) goto bail;
128+
err = MP4MakeLinkedList(&self->ExtensionAtomList);
129+
if(err) goto bail;
130+
131+
self->type = MP4BoxedMetadataSampleEntryType;
132+
self->name = "BoxedMetadataSampleEntryType (mebx)";
133+
self->createFromInputStream = (cisfunc)createFromInputStream;
134+
self->destroy = destroy;
135+
self->calculateSize = calculateSize;
136+
self->serialize = serialize;
137+
self->addAtom = addAtom;
138+
139+
*outAtom = self;
140+
bail:
141+
TEST_RETURN(err);
142+
return err;
143+
}

IsoLib/libisomediafile/src/CompatibleSchemeTypeAtom.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
/*
2-
* This software module was originally developed by InterDigital, Inc.
3-
* in the course of development of MPEG-4.
4-
* This software module is an implementation of a part of one or
5-
* more MPEG-4 tools as specified by MPEG-4.
6-
* ISO/IEC gives users of MPEG-4 free license to this
7-
* software module or modifications thereof for use in hardware
8-
* or software products claiming conformance to MPEG-4 only for evaluation and testing purposes.
9-
* Those intending to use this software module in hardware or software
10-
* products are advised that its use may infringe existing patents.
11-
* The original developer of this software module and his/her company,
12-
* the subsequent editors and their companies, and ISO/IEC have no
13-
* liability for use of this software module or modifications thereof
14-
* in an implementation.
15-
*
16-
* Copyright is not released for non MPEG-4 conforming
17-
* products. InterDigital, Inc. retains full right to use the code for its own
18-
* purpose, assign or donate the code to a third party and to
19-
* inhibit third parties from using the code for non
20-
* MPEG-4 conforming products.
21-
*
22-
* This copyright notice must be included in all copies or
23-
* derivative works.
1+
/* This software module was originally developed by InterDigital, Inc. in the course of development
2+
* of MPEG-4. This software module is an implementation of a part of one or more MPEG-4 tools as
3+
* specified by MPEG-4. ISO/IEC gives users of MPEG-4 free license to this software module or
4+
* modifications thereof for use in hardware or software products claiming conformance to MPEG-4
5+
* only for evaluation and testing purposes. Those intending to use this software module in hardware
6+
* or software products are advised that its use may infringe existing patents. The original
7+
* developer of this software module and his/her company, the subsequent editors and their
8+
* companies, and ISO/IEC have no liability for use of this software module or modifications thereof
9+
* in an implementation. Copyright is not released for non MPEG-4 conforming products. InterDigital,
10+
* Inc. retains full right to use the code for its own purpose, assign or donate the code to a third
11+
* party and to inhibit third parties from using the code for non MPEG-4 conforming products. This
12+
* copyright notice must be included in all copies or derivative works.
2413
*/
2514

2615
/**
@@ -71,7 +60,6 @@ static MP4Err serialize(struct MP4Atom *s, char *buffer)
7160
assert(self->bytesWritten == self->size);
7261
bail:
7362
TEST_RETURN(err);
74-
7563
return err;
7664
}
7765

@@ -94,7 +82,6 @@ static MP4Err calculateSize(struct MP4Atom *s)
9482

9583
bail:
9684
TEST_RETURN(err);
97-
9885
return err;
9986
}
10087

@@ -114,7 +101,7 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
114101
GET32(scheme_type);
115102
GET32(scheme_version);
116103

117-
bytesToRead = self->size - self->bytesRead;
104+
bytesToRead = (long)self->size - self->bytesRead;
118105
if(bytesToRead < 0) BAILWITHERROR(MP4BadDataErr);
119106

120107
if(bytesToRead > 0)
@@ -148,7 +135,6 @@ static MP4Err createFromInputStream(MP4AtomPtr s, MP4AtomPtr proto, MP4InputStre
148135

149136
bail:
150137
TEST_RETURN(err);
151-
152138
return err;
153139
}
154140

@@ -175,6 +161,5 @@ MP4Err MP4CreateCompatibleSchemeTypeAtom(MP4CompatibleSchemeTypeAtomPtr *outAtom
175161

176162
bail:
177163
TEST_RETURN(err);
178-
179164
return err;
180165
}

0 commit comments

Comments
 (0)