1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
20 #include <stdio.h>
21
30
61
62 #define OFFSET(x) offsetof(TestContext, x)
63
64 #define TEST_FLAG_COOL 01
65 #define TEST_FLAG_LAME 02
66 #define TEST_FLAG_MU 04
67
97 };
98
100 {
101 return "test";
102 }
103
109 };
110
112 {
113 vfprintf(stdout, fmt, vl);
114 }
115
117 {
119
122
123 printf(
"Testing default values\n");
124 {
128
136 printf(
"width=%d height=%d\n", test_ctx.
w, test_ctx.
h);
143 printf(
"binary=%x %x %x %x\n", ((uint8_t*)test_ctx.
binary)[0], ((uint8_t*)test_ctx.
binary)[1], ((uint8_t*)test_ctx.
binary)[2], ((uint8_t*)test_ctx.
binary)[3]);
148
150
152 }
153
154 printf(
"\nTesting av_opt_is_set_to_default()\n");
155 {
160
162
166 }
171 }
173 }
174
175 printf(
"\nTesting av_opt_get/av_opt_set()\n");
176 {
182
184
186
193
195 continue;
196
198 if (ret1 >= 0) {
200 if (ret2 >= 0)
202 }
203
204 printf(
"name: %-11s get: %-16s set: %-16s get: %-16s %s\n", o->
name,
208 ret1 >= 0 && ret2 >= 0 && ret3 >= 0 && !strcmp(value1, value2) ? "OK" : "Mismatch");
211 }
214 }
215
216 printf(
"\nTest av_opt_serialize()\n");
217 {
219 char *buf;
221
223
228 memset(&test_ctx, 0, sizeof(test_ctx));
235 }
236 }
238 }
239
240 printf(
"\nTesting av_set_options_string()\n");
241 {
243 static const char *
const options[] = {
244 "",
245 ":",
246 "=",
247 "foo=:",
248 ":=foo",
249 "=foo",
250 "foo=",
251 "foo",
252 "foo=val",
253 "foo==val",
254 "toggle=:",
255 "string=:",
256 "toggle=1 : foo",
257 "toggle=100",
258 "toggle==1",
259 "flags=+mu-lame : num=42: toggle=0",
260 "num=42 : string=blahblah",
261 "rational=0 : rational=1/2 : rational=1/-1",
262 "rational=-1/0",
263 "size=1024x768",
264 "size=pal",
265 "size=bogus",
266 "pix_fmt=yuv420p",
267 "pix_fmt=2",
268 "pix_fmt=bogus",
269 "sample_fmt=s16",
270 "sample_fmt=2",
271 "sample_fmt=bogus",
272 "video_rate=pal",
273 "video_rate=25",
274 "video_rate=30000/1001",
275 "video_rate=30/1.001",
276 "video_rate=bogus",
277 "duration=bogus",
278 "duration=123.45",
279 "duration=1\\:23\\:45.67",
280 "color=blue",
281 "color=0x223300",
282 "color=0x42FF07AA",
283 "cl=FL+FR",
284 "cl=foo",
285 "bin=boguss",
286 "bin=111",
287 "bin=ffff",
288 "num64=bogus",
289 "num64=44",
290 "num64=44.4",
291 "num64=-1",
292 "num64=101",
293 "flt=bogus",
294 "flt=2",
295 "flt=2.2",
296 "flt=-1",
297 "flt=101",
298 "dbl=bogus",
299 "dbl=2",
300 "dbl=2.2",
301 "dbl=-1",
302 "dbl=101",
303 "bool1=true",
304 "bool2=auto",
305 "dict1='happy=\\:-):sad=\\:-('",
306 };
307
310
312
314 int silence_log = !strcmp(
options[
i],
"rational=-1/0");
// inf formating differs between platforms
316 if (silence_log)
320 else
323 }
325 }
326
327 printf(
"\nTesting av_opt_set_from_string()\n");
328 {
330 static const char *
const options[] = {
331 "",
332 "5",
333 "5:hello",
334 "5:hello:size=pal",
335 "5:size=pal:hello",
336 ":",
337 "=",
338 " 5 : hello : size = pal ",
339 "a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42"
340 };
341 static const char *
const shorthand[] = {
"num",
"string",
NULL };
342
345
347
352 else
354 }
356 }
357
358 return 0;
359 }