-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
heif: PR review comment fixes, additional tests
- Loading branch information
Showing
3 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
/****************************************************************************** | ||
* | ||
* Project: HEIF Driver | ||
* Author: Even Rouault <even.rouault at spatialys.com> | ||
* Author: Brad Hards <[email protected]> | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 2023, Even Rouault <even.rouault at spatialys.com> | ||
* Copyright (c) 2023, Brad Hards <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
|
@@ -133,14 +133,13 @@ GDALHEIFDataset::CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, int, | |
pfnProgress = GDALDummyProgress; | ||
|
||
int nBands = poSrcDS->GetRasterCount(); | ||
if (nBands == 0) | ||
if ((nBands != 3) && (nBands != 4)) | ||
{ | ||
CPLError(CE_Failure, CPLE_NotSupported, | ||
"Driver does not support source dataset with zero bands.\n"); | ||
"Driver only supports source dataset with 3 or 4 bands.\n"); | ||
return nullptr; | ||
} | ||
|
||
// TODO: sanity checks | ||
// TODO: more sanity checks | ||
|
||
heif_context *ctx = heif_context_alloc(); | ||
heif_encoder *encoder; | ||
|
@@ -165,6 +164,14 @@ GDALHEIFDataset::CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, int, | |
|
||
for (auto &&poBand : poSrcDS->GetBands()) | ||
{ | ||
if (poBand->GetRasterDataType() != GDT_Byte) | ||
{ | ||
heif_image_release(image); | ||
heif_encoder_release(encoder); | ||
heif_context_free(ctx); | ||
CPLError(CE_Failure, CPLE_AppDefined, "Unsupported data type.\n"); | ||
return nullptr; | ||
} | ||
heif_channel channel; | ||
auto mapError = | ||
mapColourInterpretation(poBand->GetColorInterpretation(), &channel); | ||
|