File: test_cmd_gainmap.sh

package info (click to toggle)
libavif 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 21,648 kB
  • sloc: ansic: 30,743; cpp: 14,606; xml: 1,507; sh: 1,296; java: 307; makefile: 57
file content (50 lines) | stat: -rwxr-xr-x 1,809 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------------
#
# tests for command lines (gain maps)

source $(dirname "$0")/cmd_test_common.sh || exit

# Input file paths.
INPUT_JPEG_GAINMAP="${TESTDATA_DIR}/paris_exif_xmp_gainmap_bigendian.jpg"
# Output file names.
ENCODED_FILE="avif_test_cmd_gainmap_encoded.avif"
OUT_MSG="avif_test_cmd_gainmap_out_msg.txt"

# Cleanup
cleanup() {
  pushd ${TMP_DIR}
    rm -- "${ENCODED_FILE}" "${OUT_MSG}"
  popd
}
trap cleanup EXIT

pushd ${TMP_DIR}
  # The default gain map quality is 60.
  "${AVIFENC}" -s 10 "${INPUT_JPEG_GAINMAP}" "${ENCODED_FILE}" > "${OUT_MSG}"
  grep " gain map quality \[60 " "${OUT_MSG}"
  size_q60=$(stat --printf="%s" "${ENCODED_FILE}")
  "${AVIFENC}" -s 10 --qgain-map 85 "${INPUT_JPEG_GAINMAP}" "${ENCODED_FILE}" > "${OUT_MSG}"
  grep " gain map quality \[85 " "${OUT_MSG}"
  size_q85=$(stat --printf="%s" "${ENCODED_FILE}")
  test "$size_q85" -gt "$size_q60"
  # With --ignore-gain-map, no gain map should be encoded
  "${AVIFENC}" -s 10 --qgain-map 85 --ignore-gain-map "${INPUT_JPEG_GAINMAP}" "${ENCODED_FILE}" > "${OUT_MSG}"
  grep "gain map quality" "${OUT_MSG}" && exit 1
  grep "Gain map *: Absent" "${OUT_MSG}"
popd

exit 0