diff --git a/apps/avifgainmaputil/swapbase_command.cc b/apps/avifgainmaputil/swapbase_command.cc index 752f892ff7..5333b02428 100644 --- a/apps/avifgainmaputil/swapbase_command.cc +++ b/apps/avifgainmaputil/swapbase_command.cc @@ -54,9 +54,13 @@ avifResult SwapBaseCommand::Run() { : std::max(decoder->image->depth, decoder->image->gainMap.image->depth); } - ImagePtr new_base( - avifImageCreate(decoder->image->width, decoder->image->height, depth, - (avifPixelFormat)arg_image_read_.pixel_format.value())); + avifPixelFormat pixel_format = + (avifPixelFormat)arg_image_read_.pixel_format.value(); + if (pixel_format == AVIF_PIXEL_FORMAT_NONE) { + pixel_format = AVIF_PIXEL_FORMAT_YUV444; + } + ImagePtr new_base(avifImageCreate( + decoder->image->width, decoder->image->height, depth, pixel_format)); // The gain map's cicp values are those of the 'tmap' item and describe the // image obtained by fully applying the gain map. See ISO/IEC JTC 1/SC 29/WG 3 // m64379v1 4.1.1: A tmap derived item shall be associated with a colr item diff --git a/apps/avifgainmaputil/tonemap_command.cc b/apps/avifgainmaputil/tonemap_command.cc index 19b3c2fc03..496a9d1c53 100644 --- a/apps/avifgainmaputil/tonemap_command.cc +++ b/apps/avifgainmaputil/tonemap_command.cc @@ -132,9 +132,13 @@ avifResult TonemapCommand::Run() { if (depth == 0) { depth = tone_mapping_to_sdr ? 8 : decoder->image->depth; } - ImagePtr tone_mapped( - avifImageCreate(decoder->image->width, decoder->image->height, depth, - (avifPixelFormat)arg_image_read_.pixel_format.value())); + avifPixelFormat pixel_format = + (avifPixelFormat)arg_image_read_.pixel_format.value(); + if (pixel_format == AVIF_PIXEL_FORMAT_NONE) { + pixel_format = AVIF_PIXEL_FORMAT_YUV444; + } + ImagePtr tone_mapped(avifImageCreate( + decoder->image->width, decoder->image->height, depth, pixel_format)); if (tone_mapped == nullptr) { return AVIF_RESULT_OUT_OF_MEMORY; }