File: | build-analysis/../src/plugins/mp4/mp4ff/mp4util.c |
Warning: | line 76, column 7 Assigned value is garbage or undefined |
1 | /* |
2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
3 | ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com |
4 | ** |
5 | ** This program is free software; you can redistribute it and/or modify |
6 | ** it under the terms of the GNU General Public License as published by |
7 | ** the Free Software Foundation; either version 2 of the License, or |
8 | ** (at your option) any later version. |
9 | ** |
10 | ** This program is distributed in the hope that it will be useful, |
11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | ** GNU General Public License for more details. |
14 | ** |
15 | ** You should have received a copy of the GNU General Public License |
16 | ** along with this program; if not, write to the Free Software |
17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | ** |
19 | ** Any non-GPL usage of this software or parts of this software is strictly |
20 | ** forbidden. |
21 | ** |
22 | ** The "appropriate copyright message" mentioned in section 2c of the GPLv2 |
23 | ** must read: "Code from FAAD2 is copyright (c) Nero AG, www.nero.com" |
24 | ** |
25 | ** Commercial non-GPL licensing of this software is possible. |
26 | ** For more info contact Nero AG through Mpeg4AAClicense@nero.com. |
27 | ** |
28 | ** $Id: mp4util.c,v 1.20 2007/11/01 12:33:29 menno Exp $ |
29 | **/ |
30 | |
31 | #include "mp4ffint.h" |
32 | #include <stdlib.h> |
33 | |
34 | int32_t mp4ff_read_data(mp4ff_t *f, uint8_t *data, uint32_t size) |
35 | { |
36 | int32_t result; |
37 | uint32_t read = 0; |
38 | |
39 | while (read < size) { |
40 | result = f->stream->read(f->stream->user_data, data+read, size-read); |
41 | if (result <= 0) { |
42 | break; |
43 | } |
44 | read += result; |
45 | } |
46 | |
47 | f->current_position += read; |
48 | |
49 | return read; |
50 | } |
51 | |
52 | int32_t mp4ff_truncate(mp4ff_t * f) |
53 | { |
54 | return f->stream->truncate(f->stream->user_data); |
55 | } |
56 | |
57 | int32_t mp4ff_write_data(mp4ff_t *f, uint8_t *data, uint32_t size) |
58 | { |
59 | int32_t result = 1; |
60 | |
61 | result = f->stream->write(f->stream->user_data, data, size); |
62 | |
63 | f->current_position += size; |
64 | |
65 | return result; |
66 | } |
67 | |
68 | int32_t mp4ff_write_int32(mp4ff_t *f,const uint32_t data) |
69 | { |
70 | uint32_t result; |
71 | uint32_t a, b, c, d; |
72 | int8_t temp[4]; |
73 | |
74 | *(uint32_t*)temp = data; |
75 | a = (uint8_t)temp[0]; |
76 | b = (uint8_t)temp[1]; |
Assigned value is garbage or undefined | |
77 | c = (uint8_t)temp[2]; |
78 | d = (uint8_t)temp[3]; |
79 | |
80 | result = (a<<24) | (b<<16) | (c<<8) | d; |
81 | |
82 | return mp4ff_write_data(f,(uint8_t*)&result,sizeof(result)); |
83 | } |
84 | |
85 | int32_t mp4ff_set_position(mp4ff_t *f, const int64_t position) |
86 | { |
87 | f->stream->seek(f->stream->user_data, position); |
88 | f->current_position = position; |
89 | |
90 | return 0; |
91 | } |
92 | |
93 | int64_t mp4ff_position(const mp4ff_t *f) |
94 | { |
95 | return f->current_position; |
96 | } |
97 | |
98 | uint64_t mp4ff_read_int64(mp4ff_t *f) |
99 | { |
100 | uint8_t data[8]; |
101 | uint64_t result = 0; |
102 | int8_t i; |
103 | |
104 | mp4ff_read_data(f, data, 8); |
105 | |
106 | for (i = 0; i < 8; i++) |
107 | { |
108 | result |= ((uint64_t)data[i]) << ((7 - i) * 8); |
109 | } |
110 | |
111 | return result; |
112 | } |
113 | |
114 | uint32_t mp4ff_read_int32(mp4ff_t *f) |
115 | { |
116 | uint32_t result; |
117 | uint32_t a, b, c, d; |
118 | uint8_t data[4]; |
119 | |
120 | mp4ff_read_data(f, data, 4); |
121 | a = data[0]; |
122 | b = data[1]; |
123 | c = data[2]; |
124 | d = data[3]; |
125 | |
126 | result = (a<<24) | (b<<16) | (c<<8) | d; |
127 | return (uint32_t)result; |
128 | } |
129 | |
130 | uint32_t mp4ff_read_int24(mp4ff_t *f) |
131 | { |
132 | uint32_t result; |
133 | uint32_t a, b, c; |
134 | uint8_t data[4]; |
135 | |
136 | mp4ff_read_data(f, data, 3); |
137 | a = data[0]; |
138 | b = data[1]; |
139 | c = data[2]; |
140 | |
141 | result = (a<<16) | (b<<8) | c; |
142 | return (uint32_t)result; |
143 | } |
144 | |
145 | uint16_t mp4ff_read_int16(mp4ff_t *f) |
146 | { |
147 | uint32_t result; |
148 | uint32_t a, b; |
149 | uint8_t data[2]; |
150 | |
151 | mp4ff_read_data(f, data, 2); |
152 | a = data[0]; |
153 | b = data[1]; |
154 | |
155 | result = (a<<8) | b; |
156 | return (uint16_t)result; |
157 | } |
158 | |
159 | char * mp4ff_read_string(mp4ff_t * f,uint32_t length) |
160 | { |
161 | char * str = malloc(length + 1); |
162 | if (str!=0) |
163 | { |
164 | if ((uint32_t)mp4ff_read_data(f,(uint8_t *)str,length)!=length) |
165 | { |
166 | free(str); |
167 | str = 0; |
168 | } |
169 | else |
170 | { |
171 | str[length] = 0; |
172 | } |
173 | } |
174 | return str; |
175 | } |
176 | |
177 | uint8_t mp4ff_read_char(mp4ff_t *f) |
178 | { |
179 | uint8_t output; |
180 | mp4ff_read_data(f, &output, 1); |
181 | return output; |
182 | } |
183 | |
184 | uint32_t mp4ff_read_mp4_descr_length(mp4ff_t *f) |
185 | { |
186 | uint8_t b; |
187 | uint8_t numBytes = 0; |
188 | uint32_t length = 0; |
189 | |
190 | do |
191 | { |
192 | b = mp4ff_read_char(f); |
193 | numBytes++; |
194 | length = (length << 7) | (b & 0x7F); |
195 | } while ((b & 0x80) && numBytes < 4); |
196 | |
197 | return length; |
198 | } |