annotate libmpdemux/parse_mp4.c @ 28982:a73861318395

Initialize pointer arrays which may be freed before being initialized.
author benoit
date Fri, 20 Mar 2009 16:29:47 +0000
parents df67d03dde3b
children 88512570a249
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28106
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
1 /*
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
2 * MP4 file format parser code
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
3 *
28110
fc04fa771074 license header consistency cosmetics
diego
parents: 28106
diff changeset
4 * Copyright (C) 2002 Felix Buenemann <atmosfear at users.sourceforge.net>
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
5 * Code inspired by libmp4 from http://mpeg4ip.sourceforge.net/.
28106
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
6 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
7 * This file is part of MPlayer.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
8 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
9 * MPlayer is free software; you can redistribute it and/or modify
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
10 * it under the terms of the GNU General Public License as published by
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
12 * (at your option) any later version.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
13 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
14 * MPlayer is distributed in the hope that it will be useful,
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
17 * GNU General Public License for more details.
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
18 *
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
19 * You should have received a copy of the GNU General Public License along
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
20 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
22 */
28106
4932a522100e Replace informal GPL notes by standard GPL header.
diego
parents: 22605
diff changeset
23
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
24 #include <stdio.h>
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
25 #include <inttypes.h>
28594
df67d03dde3b Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents: 28110
diff changeset
26 #if HAVE_MALLOC_H
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
27 #include <malloc.h>
5403
dba4cecbb4d1 FreeBSD warning fix
nexus
parents: 5333
diff changeset
28 #endif
5404
534580bc88a8 FreeBSD require stdlib.h
nexus
parents: 5403
diff changeset
29 #include <stdlib.h>
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
30 #include "parse_mp4.h"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
31 #include "mp_msg.h"
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 18666
diff changeset
32 #include "stream/stream.h"
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
33
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
34 //#define MP4_DUMPATOM
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
35
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
36 #define MP4_DL MSGL_V
5303
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
37 #define freereturn(a,b) free(a); return b
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
38
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
39 int mp4_read_descr_len(stream_t *s) {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
40 uint8_t b;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
41 uint8_t numBytes = 0;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
42 uint32_t length = 0;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
43
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
44 do {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
45 b = stream_read_char(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
46 numBytes++;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
47 length = (length << 7) | (b & 0x7F);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
48 } while ((b & 0x80) && numBytes < 4);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
49
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
50 //printf("MP4 read desc len: %d\n", length);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
51 return length;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
52 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
53
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
54 /* parse the data part of MP4 esds atoms */
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
55 int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
56 /* create memory stream from data */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
57 stream_t *s = new_memory_stream(data, datalen);
18666
492c6d674c3e decoderConfigLen can be larger than 255 bytes
nicodvb
parents: 6929
diff changeset
58 uint16_t len;
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
59 #ifdef MP4_DUMPATOM
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
60 {int i;
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
61 printf("ESDS Dump (%dbyte):\n", datalen);
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
62 for(i = 0; i < datalen; i++)
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
63 printf("%02X ", data[i]);
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
64 printf("\nESDS Dumped\n");}
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
65 #endif
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
66 memset(esds, 0, sizeof(esds_t));
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
67
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
68 esds->version = stream_read_char(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
69 esds->flags = stream_read_int24(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
70 mp_msg(MSGT_DEMUX, MP4_DL,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
71 "ESDS MPEG4 version: %d flags: 0x%06X\n",
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
72 esds->version, esds->flags);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
73
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
74 /* get and verify ES_DescrTag */
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
75 if (stream_read_char(s) == MP4ESDescrTag) {
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
76 /* read length */
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
77 len = mp4_read_descr_len(s);
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
78
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
79 esds->ESId = stream_read_word(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
80 esds->streamPriority = stream_read_char(s);
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
81 mp_msg(MSGT_DEMUX, MP4_DL,
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
82 "ESDS MPEG4 ES Descriptor (%dBytes):\n"
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
83 " -> ESId: %d\n"
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
84 " -> streamPriority: %d\n",
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
85 len, esds->ESId, esds->streamPriority);
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
86
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
87 if (len < (5 + 15)) {
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
88 freereturn(s,1);
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
89 }
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
90 } else {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
91 esds->ESId = stream_read_word(s);
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
92 mp_msg(MSGT_DEMUX, MP4_DL,
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
93 "ESDS MPEG4 ES Descriptor (%dBytes):\n"
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
94 " -> ESId: %d\n", 2, esds->ESId);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
95 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
96
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
97 /* get and verify DecoderConfigDescrTab */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
98 if (stream_read_char(s) != MP4DecConfigDescrTag) {
5303
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
99 freereturn(s,1);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
100 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
101
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
102 /* read length */
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
103 len = mp4_read_descr_len(s);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
104
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
105 esds->objectTypeId = stream_read_char(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
106 esds->streamType = stream_read_char(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
107 esds->bufferSizeDB = stream_read_int24(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
108 esds->maxBitrate = stream_read_dword(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
109 esds->avgBitrate = stream_read_dword(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
110 mp_msg(MSGT_DEMUX, MP4_DL,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
111 "ESDS MPEG4 Decoder Config Descriptor (%dBytes):\n"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
112 " -> objectTypeId: %d\n"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
113 " -> streamType: 0x%02X\n"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
114 " -> bufferSizeDB: 0x%06X\n"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
115 " -> maxBitrate: %.3fkbit/s\n"
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
116 " -> avgBitrate: %.3fkbit/s\n",
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
117 len, esds->objectTypeId, esds->streamType,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
118 esds->bufferSizeDB, esds->maxBitrate/1000.0,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
119 esds->avgBitrate/1000.0);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
120
6929
a3aac765967d allow early exit from esds parsing, so decoder info (type & bitrate) are
arpi
parents: 5404
diff changeset
121 esds->decoderConfigLen=0;
a3aac765967d allow early exit from esds parsing, so decoder info (type & bitrate) are
arpi
parents: 5404
diff changeset
122
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
123 if (len < 15) {
6929
a3aac765967d allow early exit from esds parsing, so decoder info (type & bitrate) are
arpi
parents: 5404
diff changeset
124 freereturn(s,0);
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
125 }
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
126
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
127 /* get and verify DecSpecificInfoTag */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
128 if (stream_read_char(s) != MP4DecSpecificDescrTag) {
6929
a3aac765967d allow early exit from esds parsing, so decoder info (type & bitrate) are
arpi
parents: 5404
diff changeset
129 freereturn(s,0);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
130 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
131
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
132 /* read length */
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
133 esds->decoderConfigLen = len = mp4_read_descr_len(s);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
134
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
135 esds->decoderConfig = malloc(esds->decoderConfigLen);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
136 if (esds->decoderConfig) {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
137 stream_read(s, esds->decoderConfig, esds->decoderConfigLen);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
138 } else {
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
139 esds->decoderConfigLen = 0;
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
140 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
141 mp_msg(MSGT_DEMUX, MP4_DL,
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
142 "ESDS MPEG4 Decoder Specific Descriptor (%dBytes)\n", len);
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
143
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
144 /* get and verify SLConfigDescrTag */
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
145 if(stream_read_char(s) != MP4SLConfigDescrTag) {
6929
a3aac765967d allow early exit from esds parsing, so decoder info (type & bitrate) are
arpi
parents: 5404
diff changeset
146 freereturn(s,0);
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
147 }
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
148
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
149 /* Note: SLConfig is usually constant value 2, size 1Byte */
5333
c4f6ab72300a eeh 10l, removed one line too much :(
atmos4
parents: 5332
diff changeset
150 esds->SLConfigLen = len = mp4_read_descr_len(s);
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
151 esds->SLConfig = malloc(esds->SLConfigLen);
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
152 if (esds->SLConfig) {
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
153 stream_read(s, esds->SLConfig, esds->SLConfigLen);
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
154 } else {
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
155 esds->SLConfigLen = 0;
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
156 }
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
157 mp_msg(MSGT_DEMUX, MP4_DL,
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
158 "ESDS MPEG4 Sync Layer Config Descriptor (%dBytes)\n"
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
159 " -> predefined: %d\n", len, esds->SLConfig[0]);
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
160
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
161 /* will skip the remainder of the atom */
5303
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
162 freereturn(s,0);
5301
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
163
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
164 }
d72c3169a343 Improved MP4 parsing (finally)
atmos4
parents:
diff changeset
165
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
166 /* cleanup all mem occupied by mp4_parse_esds */
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
167 void mp4_free_esds(esds_t *esds) {
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
168 if(esds->decoderConfigLen)
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
169 free(esds->decoderConfig);
5332
a3874da21700 Fix some silly logical bugs and fix memory cleanup in case mp4_parse_es returned with an error by memsetting the esds struct to 0 on init.
atmos4
parents: 5305
diff changeset
170 if(esds->SLConfigLen)
5305
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
171 free(esds->SLConfig);
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
172 }
77ac28af44ec - Add parsing of Sync Layer Descriptor
atmos4
parents: 5303
diff changeset
173
5303
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
174 #undef freereturn
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
175 #undef MP4_DL
534f16f50c17 10l fix memory allocation
atmos4
parents: 5301
diff changeset
176