Skip to content

Commit 5450a6d

Browse files
committed
change meta API - missing one from my previous denoiser work
1 parent 42e3b18 commit 5450a6d

File tree

1 file changed

+20
-16
lines changed
  • examples_tests/39.DenoiserTonemapper

1 file changed

+20
-16
lines changed

examples_tests/39.DenoiserTonemapper/main.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ void main()
440440
const auto imageIDString = makeImageIDString(i, colorFileNameBundle);
441441

442442
auto color_image_bundle = am->getAsset(colorFileNameBundle[i].value(), lp); decltype(color_image_bundle) albedo_image_bundle, normal_image_bundle;
443-
if (color_image_bundle.isEmpty())
443+
if (color_image_bundle.getContents().empty())
444444
{
445445
os::Printer::log("ERROR (" + std::to_string(__LINE__) + " line): Could not load the image from file: " + imageIDString + "!", ELL_ERROR);
446446
continue;
@@ -453,7 +453,7 @@ void main()
453453

454454
auto getImageAssetGivenChannelName = [](asset::SAssetBundle& assetBundle, const std::optional<std::string>& channelName) -> core::smart_refctd_ptr<ICPUImage>
455455
{
456-
if (assetBundle.isEmpty())
456+
if (assetBundle.getContents().empty())
457457
return nullptr;
458458

459459
// calculate a score for how much each channel name matches the requested
@@ -464,14 +464,16 @@ void main()
464464
for (auto& asset : contents)
465465
{
466466
assert(asset);
467+
468+
const auto* bundleMeta = assetBundle.getMetadata();
469+
const auto* exrmeta = static_cast<const COpenEXRMetadata*>(bundleMeta);
470+
const auto* metadata = static_cast<const COpenEXRMetadata::CImage*>(exrmeta->getAssetSpecificMetadata(core::smart_refctd_ptr_static_cast<ICPUImage>(asset).get()));
467471

468-
auto metadata = asset->getMetadata();
469-
const auto exrmeta = static_cast<const COpenEXRImageMetadata*>(metadata);
470-
if (strcmp(metadata->getLoaderName(), COpenEXRImageMetadata::LoaderName) != 0)
472+
if (strcmp(exrmeta->getLoaderName(), COpenEXRMetadata::LoaderName) != 0)
471473
continue;
472474
else
473475
{
474-
const auto& assetMetaChannelName = exrmeta->getName();
476+
const auto& assetMetaChannelName = metadata->m_name;
475477
auto found = assetMetaChannelName.find(channelName.value());
476478
if (found >= firstChannelNameOccurence)
477479
continue;
@@ -487,7 +489,7 @@ void main()
487489
decltype(color)& albedo = getImageAssetGivenChannelName(albedo_image_bundle,albedoChannelNameBundle[i]);
488490
decltype(color)& normal = getImageAssetGivenChannelName(normal_image_bundle,normalChannelNameBundle[i]);
489491

490-
auto putImageIntoImageToDenoise = [&](core::smart_refctd_ptr<ICPUImage>&& queriedImage, E_IMAGE_INPUT defaultEII, const std::optional<std::string>& actualWantedChannel)
492+
auto putImageIntoImageToDenoise = [&](asset::SAssetBundle& queriedBundle, core::smart_refctd_ptr<ICPUImage>&& queriedImage, E_IMAGE_INPUT defaultEII, const std::optional<std::string>& actualWantedChannel)
491493
{
492494
outParam.image[defaultEII] = nullptr;
493495
if (!queriedImage)
@@ -506,22 +508,24 @@ void main()
506508
return;
507509
}
508510

509-
auto metadata = queriedImage->getMetadata();
510-
auto exrmeta = static_cast<const COpenEXRImageMetadata*>(metadata);
511-
if (strcmp(metadata->getLoaderName(),COpenEXRImageMetadata::LoaderName)!=0)
511+
const auto* bundleMeta = queriedBundle.getMetadata();
512+
const auto* exrmeta = static_cast<const COpenEXRMetadata*>(bundleMeta);
513+
const auto* metadata = static_cast<const COpenEXRMetadata::CImage*>(exrmeta->getAssetSpecificMetadata(queriedImage.get()));
514+
515+
if (strcmp(exrmeta->getLoaderName(), COpenEXRMetadata::LoaderName)!=0)
512516
os::Printer::log("WARNING (" + std::to_string(__LINE__) + "): "+ imageIDString+" is not an EXR file, so there are no multiple layers of channels.", ELL_WARNING);
513517
else if (!actualWantedChannel.has_value())
514518
os::Printer::log("WARNING (" + std::to_string(__LINE__) + "): User did not specify channel choice for "+ imageIDString+" using the default (first).", ELL_WARNING);
515-
else if (exrmeta->getName()!=actualWantedChannel.value())
519+
else if (metadata->m_name!=actualWantedChannel.value())
516520
{
517-
os::Printer::log("WARNING (" + std::to_string(__LINE__) + "): Using best fit channel \""+exrmeta->getName()+"\" for requested \""+actualWantedChannel.value()+"\" out of "+ imageIDString+"!", ELL_WARNING);
521+
os::Printer::log("WARNING (" + std::to_string(__LINE__) + "): Using best fit channel \""+ metadata->m_name +"\" for requested \""+actualWantedChannel.value()+"\" out of "+ imageIDString+"!", ELL_WARNING);
518522
}
519523
outParam.image[defaultEII] = std::move(queriedImage);
520524
};
521525

522-
putImageIntoImageToDenoise(std::move(color), EII_COLOR, colorChannelNameBundle[i]);
523-
putImageIntoImageToDenoise(std::move(albedo), EII_ALBEDO, albedoChannelNameBundle[i]);
524-
putImageIntoImageToDenoise(std::move(normal), EII_NORMAL, normalChannelNameBundle[i]);
526+
putImageIntoImageToDenoise(color_image_bundle, std::move(color), EII_COLOR, colorChannelNameBundle[i]);
527+
putImageIntoImageToDenoise(albedo_image_bundle, std::move(albedo), EII_ALBEDO, albedoChannelNameBundle[i]);
528+
putImageIntoImageToDenoise(normal_image_bundle, std::move(normal), EII_NORMAL, normalChannelNameBundle[i]);
525529
}
526530
// check inputs and set-up
527531
for (size_t i=0; i<inputFilesAmount; i++)
@@ -1055,7 +1059,7 @@ void main()
10551059
CONVERSION_FILTER::state_type state;
10561060

10571061
auto ditheringBundle = am->getAsset("../../media/blueNoiseDithering/LDR_RGBA.png", {});
1058-
const auto ditheringStatus = ditheringBundle.isEmpty();
1062+
const auto ditheringStatus = ditheringBundle.getContents().empty();
10591063
if (ditheringStatus)
10601064
{
10611065
os::Printer::log("ERROR (" + std::to_string(__LINE__) + " line): Could not load the dithering image!", ELL_ERROR);

0 commit comments

Comments
 (0)