libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

test_heif.c (4058B)


      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_heif.c
     22  * @brief testcase for the heif 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 heif 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/heif_test.heic carries two 'ispe' properties: the
     47      thumbnail's 16x12 comes first in 'ipco', the primary item's 96x64
     48      second.  Asserting on 96x64 is what proves the 'pitm' -> 'ipma' ->
     49      'ipco' association walk works rather than "report the first
     50      'ispe' you trip over". */
     51   struct SolutionData heif_heic_sol[] = {
     52     UTF8 (EXTRACTOR_METATYPE_MIMETYPE,
     53           "image/heic"),
     54     UTF8 (EXTRACTOR_METATYPE_FORMAT,
     55           "heic"),
     56     UTF8 (EXTRACTOR_METATYPE_COMPATIBLE_BRANDS,
     57           "mif1,heic,miaf,MiHB"),
     58     UTF8 (EXTRACTOR_METATYPE_CODEC,
     59           "HEVC (hvc1)"),
     60     UTF8 (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
     61           "96x64"),
     62     UTF8 (EXTRACTOR_METATYPE_COLOR_DEPTH,
     63           "10"),
     64     UTF8 (EXTRACTOR_METATYPE_ORIENTATION,
     65           "rotate 90 degrees counter-clockwise"),
     66     UTF8 (EXTRACTOR_METATYPE_ORIENTATION,
     67           "mirrored horizontally"),
     68     UTF8 (EXTRACTOR_METATYPE_COLOR_PROFILE,
     69           "nclx: primaries 9, transfer 16, matrix 9, full range"),
     70     UTF8 (EXTRACTOR_METATYPE_COMMENT,
     71           "HDR: PQ transfer function (SMPTE ST 2084)"),
     72     UTF8 (EXTRACTOR_METATYPE_ENTRY_COUNT,
     73           "3"),
     74     UTF8 (EXTRACTOR_METATYPE_COMMENT,
     75           "2 image items, 1 thumbnail, 0 auxiliary, 1 metadata item"),
     76     UTF8 (EXTRACTOR_METATYPE_COMMENT,
     77           "contains an Exif metadata item"),
     78     { 0, 0, NULL, NULL, 0, -1 }
     79   };
     80   /* testdata/heif_test.avif has the generic major brand 'mif1' and only
     81      names 'avif' among its compatible brands, so both the MIME type and
     82      the codec have to come from that list.  It also has no 'pixi', so
     83      the bit depth has to come out of the 'av1C' configuration record. */
     84   struct SolutionData heif_avif_sol[] = {
     85     UTF8 (EXTRACTOR_METATYPE_MIMETYPE,
     86           "image/avif"),
     87     UTF8 (EXTRACTOR_METATYPE_FORMAT,
     88           "mif1"),
     89     UTF8 (EXTRACTOR_METATYPE_COMPATIBLE_BRANDS,
     90           "mif1,miaf,MA1B,avif"),
     91     UTF8 (EXTRACTOR_METATYPE_CODEC,
     92           "AV1 (av01)"),
     93     UTF8 (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
     94           "128x72"),
     95     UTF8 (EXTRACTOR_METATYPE_COLOR_DEPTH,
     96           "8"),
     97     UTF8 (EXTRACTOR_METATYPE_COLOR_PROFILE,
     98           "nclx: primaries 1, transfer 13, matrix 6, full range"),
     99     UTF8 (EXTRACTOR_METATYPE_ENTRY_COUNT,
    100           "1"),
    101     UTF8 (EXTRACTOR_METATYPE_COMMENT,
    102           "1 image item, 0 thumbnails, 0 auxiliary, 0 metadata items"),
    103     { 0, 0, NULL, NULL, 0, -1 }
    104   };
    105   struct ProblemSet ps[] = {
    106     { "testdata/heif_test.heic",
    107       heif_heic_sol },
    108     { "testdata/heif_test.avif",
    109       heif_avif_sol },
    110     { NULL, NULL }
    111   };
    112 
    113   (void) argc;
    114   (void) argv;
    115   return ET_main ("heif", ps);
    116 }
    117 
    118 
    119 /* end of test_heif.c */