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-05-13 13:33:37 Functions: 3 3 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             :  * Permission is hereby granted, free of charge, to any person obtaining a
      10             :  * copy of this software and associated documentation files (the "Software"),
      11             :  * to deal in the Software without restriction, including without limitation
      12             :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      13             :  * and/or sell copies of the Software, and to permit persons to whom the
      14             :  * Software is furnished to do so, subject to the following conditions:
      15             :  *
      16             :  * The above copyright notice and this permission notice shall be included
      17             :  * in all copies or substantial portions of the Software.
      18             :  *
      19             :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      20             :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      21             :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      22             :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      23             :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      24             :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      25             :  * DEALINGS IN THE SOFTWARE.
      26             :  ****************************************************************************/
      27             : 
      28             : #include "exrdrivercore.h"
      29             : 
      30             : /************************************************************************/
      31             : /*                     EXRDriverIdentify()                              */
      32             : /************************************************************************/
      33             : 
      34       48069 : int EXRDriverIdentify(GDALOpenInfo *poOpenInfo)
      35             : 
      36             : {
      37       48069 :     if (STARTS_WITH_CI(poOpenInfo->pszFilename, "EXR:"))
      38           2 :         return true;
      39             : 
      40             :     // Check magic number
      41        2858 :     return poOpenInfo->fpL != nullptr && poOpenInfo->nHeaderBytes >= 4 &&
      42        2682 :            poOpenInfo->pabyHeader[0] == 0x76 &&
      43         147 :            poOpenInfo->pabyHeader[1] == 0x2f &&
      44       51072 :            poOpenInfo->pabyHeader[2] == 0x31 &&
      45       48214 :            poOpenInfo->pabyHeader[3] == 0x01;
      46             : }
      47             : 
      48             : /************************************************************************/
      49             : /*                      EXRDriverSetCommonMetadata()                    */
      50             : /************************************************************************/
      51             : 
      52        1228 : void EXRDriverSetCommonMetadata(GDALDriver *poDriver)
      53             : {
      54        1228 :     poDriver->SetDescription(DRIVER_NAME);
      55        1228 :     poDriver->SetMetadataItem(GDAL_DCAP_RASTER, "YES");
      56        1228 :     poDriver->SetMetadataItem(GDAL_DMD_LONGNAME,
      57        1228 :                               "Extended Dynamic Range Image File Format");
      58        1228 :     poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/raster/exr.html");
      59        1228 :     poDriver->SetMetadataItem(GDAL_DMD_EXTENSION, "exr");
      60        1228 :     poDriver->SetMetadataItem(
      61             :         GDAL_DMD_CREATIONOPTIONLIST,
      62             :         "<CreationOptionList>"
      63             :         "   <Option name='COMPRESS' type='string-select' default='ZIP'>"
      64             :         "     <Value>NONE</Value>"
      65             :         "     <Value>RLE</Value>"
      66             :         "     <Value>ZIPS</Value>"
      67             :         "     <Value>ZIP</Value>"
      68             :         "     <Value>PIZ</Value>"
      69             :         "     <Value>PXR24</Value>"
      70             :         "     <Value>B44</Value>"
      71             :         "     <Value>B44A</Value>"
      72             :         "     <Value>DWAA</Value>"
      73             :         "     <Value>DWAB</Value>"
      74             :         "   </Option>"
      75             :         "   <Option name='PIXEL_TYPE' type='string-select'>"
      76             :         "     <Value>HALF</Value>"
      77             :         "     <Value>FLOAT</Value>"
      78             :         "     <Value>UINT</Value>"
      79             :         "   </Option>"
      80             :         "   <Option name='TILED' type='boolean' description='Use tiling' "
      81             :         "default='YES'/>"
      82             :         "   <Option name='BLOCKXSIZE' type='int' description='Tile width' "
      83             :         "default='256'/>"
      84             :         "   <Option name='BLOCKYSIZE' type='int' description='Tile height' "
      85             :         "default='256'/>"
      86             :         "   <Option name='OVERVIEWS' type='boolean' description='Whether to "
      87             :         "create overviews' default='NO'/>"
      88             :         "   <Option name='OVERVIEW_RESAMPLING' type='string' "
      89             :         "description='Resampling method' default='CUBIC'/>"
      90             :         "   <Option name='PREVIEW' type='boolean' description='Create a "
      91             :         "preview' default='NO'/>"
      92             :         "   <Option name='AUTO_RESCALE' type='boolean' description='Whether to "
      93             :         "rescale Byte RGB(A) values to 0-1' default='YES'/>"
      94             :         "   <Option name='DWA_COMPRESSION_LEVEL' type='int' description='DWA "
      95             :         "compression level'/>"
      96        1228 :         "</CreationOptionList>");
      97        1228 :     poDriver->SetMetadataItem(GDAL_DMD_SUBDATASETS, "YES");
      98        1228 :     poDriver->SetMetadataItem(GDAL_DCAP_VIRTUALIO, "YES");
      99             : 
     100        1228 :     poDriver->pfnIdentify = EXRDriverIdentify;
     101        1228 :     poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES");
     102        1228 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES");
     103        1228 :     poDriver->SetMetadataItem(GDAL_DCAP_CREATECOPY, "YES");
     104        1228 : }
     105             : 
     106             : /************************************************************************/
     107             : /*                     DeclareDeferredEXRPlugin()                       */
     108             : /************************************************************************/
     109             : 
     110             : #ifdef PLUGIN_FILENAME
     111        1522 : void DeclareDeferredEXRPlugin()
     112             : {
     113        1522 :     if (GDALGetDriverByName(DRIVER_NAME) != nullptr)
     114             :     {
     115         301 :         return;
     116             :     }
     117        1221 :     auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME);
     118             : #ifdef PLUGIN_INSTALLATION_MESSAGE
     119             :     poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE,
     120             :                               PLUGIN_INSTALLATION_MESSAGE);
     121             : #endif
     122        1221 :     EXRDriverSetCommonMetadata(poDriver);
     123        1221 :     GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver);
     124             : }
     125             : #endif

Generated by: LCOV version 1.14