Skip to content

Commit

Permalink
Fix avifgainmaputil trying to create images with pixel format 0. (AOM…
Browse files Browse the repository at this point in the history
  • Loading branch information
maryla-uc authored Nov 21, 2023
1 parent 8250cb9 commit 98d31ad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions apps/avifgainmaputil/swapbase_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions apps/avifgainmaputil/tonemap_command.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 98d31ad

Please sign in to comment.