LCOV - code coverage report
Current view: top level - frmts/exr - exrdrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 30 30 100.0 %
Date: 2024-11-21 22:18:42 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  EXR read/write Driver
       4             :  * Author:   Even Rouault <even.rouault at spatialys.com>
       5             :  *
       6             :  ******************************************************************************
       7             :  * Copyright (c) 2020, Even Rouault <even.rouault at spatialys.com>
       8             :  *
       9             :  * SPDX-License-Identifier: MIT
      10             :  ****************************************************************************/
      11             : 
      12             : #include "exrdrivercore.h"
      13             : 
      14             : /************************************************************************/
      15             : /*                     EXRDriverIdentify()                              */
      16             : /************************************************************************/
      17             : 
      18       50668 : int EXRDriverIdentify(GDALOpenInfo *poOpenInfo)
      19             : 
      20             : {
      21       50668 :     if (STARTS_WITH_CI(poOpenInfo->pszFilename, "EXR:"))
      22           2 :         return true;
      23             : 
      24             :     // Check magic number
      25        3049 :     return poOpenInfo->fpL != nullptr && poOpenInfo->nHeaderBytes >= 4 &&
      26        2861 :            poOpenInfo->pabyHeader[0] == 0x76 &&
      27         147 :            poOpenInfo->pabyHeader[1] == 0x2f &&
      28       53862 :            poOpenInfo->pabyHeader[2] == 0x31 &&
      29       50813 :            poOpenInfo->pabyHeader[3] == 0x01;
      30             : }
      31             : 
      32             : /************************************************************************/
      33             : /*                      EXRDriverSetCommonMetadata()                    */
      34             : /************************************************************************/
      35             : 
      36        1302 : void EXRDriverSetCommonMetadata(GDALDriver *poDriver)
      37             : {
      38        1302 :     poDriver->SetDescription(DRIVER_NAME);
      39        1302 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      40        1302 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      41        1302 :                               "Extended Dynamic Range Image File Format");
      42        1302 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/exr.html");
      43        1302 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "exr");
      44        1302 :     poDriver->SetMetadataItem(
      45             :         GDAL_DMD_CREATIONOPTIONLIST,
      46             :         "<CreationOptionList>"
      47             :         "   <Option name='COMPRESS' type='string-select' default='ZIP'>"
      48             :         "     <Value>NONE</Value>"
      49             :         "     <Value>RLE</Value>"
      50             :         "     <Value>ZIPS</Value>"
      51             :         "     <Value>ZIP</Value>"
      52             :         "     <Value>PIZ</Value>"
      53             :         "     <Value>PXR24</Value>"
      54             :         "     <Value>B44</Value>"
      55             :         "     <Value>B44A</Value>"
      56             :         "     <Value>DWAA</Value>"
      57             :         "     <Value>DWAB</Value>"
      58             :         "   </Option>"
      59             :         "   <Option name='PIXEL_TYPE' type='string-select'>"
      60             :         "     <Value>HALF</Value>"
      61             :         "     <Value>FLOAT</Value>"
      62             :         "     <Value>UINT</Value>"
      63             :         "   </Option>"
      64             :         "   <Option name='TILED' type='boolean' description='Use tiling' "
      65             :         "default='YES'/>"
      66             :         "   <Option name='BLOCKXSIZE' type='int' description='Tile width' "
      67             :         "default='256'/>"
      68             :         "   <Option name='BLOCKYSIZE' type='int' description='Tile height' "
      69             :         "default='256'/>"
      70             :         "   <Option name='OVERVIEWS' type='boolean' description='Whether to "
      71             :         "create overviews' default='NO'/>"
      72             :         "   <Option name='OVERVIEW_RESAMPLING' type='string' "
      73             :         "description='Resampling method' default='CUBIC'/>"
      74             :         "   <Option name='PREVIEW' type='boolean' description='Create a "
      75             :         "preview' default='NO'/>"
      76             :         "   <Option name='AUTO_RESCALE' type='boolean' description='Whether to "
      77             :         "rescale Byte RGB(A) values to 0-1' default='YES'/>"
      78             :         "   <Option name='DWA_COMPRESSION_LEVEL' type='int' description='DWA "
      79             :         "compression level'/>"
      80        1302 :         "</CreationOptionList>");
      81        1302 :     poDriver->SetMetadataItem(GDAL_DMD_SUBDATASETS, "YES");
      82        1302 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      83             : 
      84        1302 :     poDriver->pfnIdentify = EXRDriverIdentify;
      85        1302 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
      86        1302 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
      87        1302 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES");
      88        1302 : }
      89             : 
      90             : /************************************************************************/
      91             : /*                     DeclareDeferredEXRPlugin()                       */
      92             : /************************************************************************/
      93             : 
      94             : #ifdef PLUGIN_FILENAME
      95        1595 : void DeclareDeferredEXRPlugin()
      96             : {
      97        1595 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
      98             :     {
      99         302 :         return;
     100             :     }
     101        1293 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     102             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     103             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     104             :                               PLUGIN_INSTALLATION_MESSAGE);
     105             : #endif
     106        1293 :     EXRDriverSetCommonMetadata(poDriver);
     107        1293 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     108             : }
     109             : #endif

Generated by: LCOV version 1.14