test_webp.c (3045B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_webp.c 22 * @brief testcase for the webp plugin 23 * @author Christian Grothoff 24 */ 25 #include "platform.h" 26 #include "test_lib.h" 27 28 29 /** 30 * Shorthand for a UTF-8 solution entry. 31 */ 32 #define UTF8(t, s) { (t), EXTRACTOR_METAFORMAT_UTF8, "text/plain", \ 33 (s), strlen (s) + 1, 0 } 34 35 36 /** 37 * Main function for the webp testcase. 38 * 39 * @param argc number of arguments (ignored) 40 * @param argv arguments (ignored) 41 * @return 0 on success 42 */ 43 int 44 main (int argc, char *argv[]) 45 { 46 /* testdata/webp_test.webp is an extended (VP8X) animated WebP with 47 every optional chunk the container defines. The canvas size comes 48 from the VP8X header, the codec from the sub-chunk inside the first 49 animation frame, and the duration from summing the three frame 50 durations (100 + 150 + 250 ms), so the assertions below only hold 51 if the whole chunk walk works. */ 52 struct SolutionData webp_sol[] = { 53 UTF8 (EXTRACTOR_METATYPE_MIMETYPE, 54 "image/webp"), 55 UTF8 (EXTRACTOR_METATYPE_FORMAT, 56 "WebP (extended)"), 57 UTF8 (EXTRACTOR_METATYPE_CODEC, 58 "VP8L (lossless)"), 59 UTF8 (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, 60 "40x24"), 61 UTF8 (EXTRACTOR_METATYPE_ATTRIBUTES, 62 "alpha, animation, ICC profile, EXIF, XMP"), 63 /* a bare number, as the heif plugin reports it: whether there is an 64 alpha channel is asserted through ATTRIBUTES above */ 65 UTF8 (EXTRACTOR_METATYPE_COLOR_DEPTH, 66 "8"), 67 UTF8 (EXTRACTOR_METATYPE_COLOR_PROFILE, 68 "ICC profile, 136 bytes"), 69 UTF8 (EXTRACTOR_METATYPE_ENTRY_COUNT, 70 "3"), 71 UTF8 (EXTRACTOR_METATYPE_DURATION, 72 "500 ms"), 73 UTF8 (EXTRACTOR_METATYPE_COMMENT, 74 "animation: 3 frames, looping forever, background #ff204080 BGRA"), 75 UTF8 (EXTRACTOR_METATYPE_COMMENT, 76 "contains an EXIF chunk"), 77 UTF8 (EXTRACTOR_METATYPE_COMMENT, 78 "contains an XMP chunk"), 79 { 0, 0, NULL, NULL, 0, -1 } 80 }; 81 struct ProblemSet ps[] = { 82 { "testdata/webp_test.webp", 83 webp_sol }, 84 { NULL, NULL } 85 }; 86 87 (void) argc; 88 (void) argv; 89 return ET_main ("webp", ps); 90 } 91 92 93 /* end of test_webp.c */