Skip to content

Commit

Permalink
Fix avif_fuzztest_enc_dec_anim for AVIF_ADD_IMAGE_FLAG_SINGLE (AOMedi…
Browse files Browse the repository at this point in the history
…aCodec#1940)

BUG=oss-fuzz:65696
  • Loading branch information
vrabaud authored Jan 15, 2024
1 parent fb3dc68 commit 5740873
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/gtest/avif_fuzztest_enc_dec_anim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,26 @@ void EncodeDecodeAnimation(ImagePtr frame,
int total_duration = 0;

// Encode.
for (const FrameOptions& options : frame_options) {
for (size_t i = 0; i < frame_options.size(); ++i) {
const FrameOptions& options = frame_options[i];
total_duration += options.duration;
const avifResult result = avifEncoderAddImage(
encoder.get(), frame.get(), options.duration, options.flags);
// AVIF_ADD_IMAGE_FLAG_SINGLE can only be used on one image.
if ((frame_options[0].flags & AVIF_ADD_IMAGE_FLAG_SINGLE) && i > 0) {
ASSERT_EQ(result, AVIF_RESULT_ENCODE_COLOR_FAILED)
<< avifResultToString(result) << " " << encoder->diag.error;
return;
}
// AVIF_ADD_IMAGE_FLAG_SINGLE can only be used on the first image.
// It also cannot be set for layered images.
if ((options.flags & AVIF_ADD_IMAGE_FLAG_SINGLE) &&
(i > 0 || encoder->extraLayerCount > 0)) {
ASSERT_EQ(result, AVIF_RESULT_INVALID_ARGUMENT)
<< avifResultToString(result) << " " << encoder->diag.error;
return;
}

ASSERT_EQ(result, AVIF_RESULT_OK)
<< avifResultToString(result) << " " << encoder->diag.error;
}
Expand Down

0 comments on commit 5740873

Please sign in to comment.