Skip to content

Commit

Permalink
test_cmd_icc_profile.sh: Move --cicp tests earlier
Browse files Browse the repository at this point in the history
The --cicp tests do not use ImageMagick, so run those tests before
checking for the presence of ImageMagick.

Also run popd before exiting with 0 if ImageMagick is not present.

A follow-up to the pull request
AOMediaCodec#1463.
  • Loading branch information
wantehchang committed Jul 13, 2023
1 parent c048001 commit 89fe4a5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/test_cmd_icc_profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ cleanup() {
trap cleanup EXIT

pushd ${TMP_DIR}
# Check --cicp flag works
"${AVIFENC}" --cicp 9/12/8 -s 8 "${INPUT_COLOR_PNG}" -o "${ENCODED_FILE}"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Color Primaries.* 9$"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Transfer Char.* 12$"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Matrix Coeffs.* 8$"

# We use third-party tool (ImageMagick) to independently check
# our generated ICC profile is valid and correct.
if command -v magick &> /dev/null
Expand All @@ -74,6 +80,7 @@ pushd ${TMP_DIR}
touch "${ENCODED_FILE}"
touch "${DECODED_FILE}"
touch "${CORRECTED_FILE}"
popd
exit 0
fi

Expand All @@ -90,12 +97,6 @@ pushd ${TMP_DIR}
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}"
"${IMAGEMAGICK}" "${DECODED_FILE}" -profile "${SRGB_ICC}" "${CORRECTED_FILE}"
"${ARE_IMAGES_EQUAL}" "${REFERENCE_GRAY_PNG}" "${CORRECTED_FILE}" 0 45

# Check --cicp flag works
"${AVIFENC}" --cicp 9/12/8 -s 8 "${INPUT_COLOR_PNG}" -o "${ENCODED_FILE}"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Color Primaries.* 9$"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Transfer Char.* 12$"
"${AVIFDEC}" "${ENCODED_FILE}" "${DECODED_FILE}" | grep "Matrix Coeffs.* 8$"
popd

exit 0

0 comments on commit 89fe4a5

Please sign in to comment.