resize_util.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. ##
  3. ## Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  4. ##
  5. ## Use of this source code is governed by a BSD-style license
  6. ## that can be found in the LICENSE file in the root of the source
  7. ## tree. An additional intellectual property rights grant can be found
  8. ## in the file PATENTS. All contributing project authors may
  9. ## be found in the AUTHORS file in the root of the source tree.
  10. ##
  11. ## This file tests the libvpx resize_util example code. To add new tests to
  12. ## this file, do the following:
  13. ## 1. Write a shell function (this is your test).
  14. ## 2. Add the function to resize_util_tests (on a new line).
  15. ##
  16. . $(dirname $0)/tools_common.sh
  17. # Environment check: $YUV_RAW_INPUT is required.
  18. resize_util_verify_environment() {
  19. if [ ! -e "${YUV_RAW_INPUT}" ]; then
  20. echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
  21. return 1
  22. fi
  23. }
  24. # Resizes $YUV_RAW_INPUT using the resize_util example. $1 is the output
  25. # dimensions that will be passed to resize_util.
  26. resize_util() {
  27. local resizer="${LIBVPX_BIN_PATH}/resize_util${VPX_TEST_EXE_SUFFIX}"
  28. local output_file="${VPX_TEST_OUTPUT_DIR}/resize_util.raw"
  29. local frames_to_resize="10"
  30. local target_dimensions="$1"
  31. # resize_util is available only when CONFIG_SHARED is disabled.
  32. if [ -z "$(vpx_config_option_enabled CONFIG_SHARED)" ]; then
  33. if [ ! -x "${resizer}" ]; then
  34. elog "${resizer} does not exist or is not executable."
  35. return 1
  36. fi
  37. eval "${VPX_TEST_PREFIX}" "${resizer}" "${YUV_RAW_INPUT}" \
  38. "${YUV_RAW_INPUT_WIDTH}x${YUV_RAW_INPUT_HEIGHT}" \
  39. "${target_dimensions}" "${output_file}" ${frames_to_resize} \
  40. ${devnull}
  41. [ -e "${output_file}" ] || return 1
  42. fi
  43. }
  44. # Halves each dimension of $YUV_RAW_INPUT using resize_util().
  45. resize_down() {
  46. local target_width=$((${YUV_RAW_INPUT_WIDTH} / 2))
  47. local target_height=$((${YUV_RAW_INPUT_HEIGHT} / 2))
  48. resize_util "${target_width}x${target_height}"
  49. }
  50. # Doubles each dimension of $YUV_RAW_INPUT using resize_util().
  51. resize_up() {
  52. local target_width=$((${YUV_RAW_INPUT_WIDTH} * 2))
  53. local target_height=$((${YUV_RAW_INPUT_HEIGHT} * 2))
  54. resize_util "${target_width}x${target_height}"
  55. }
  56. resize_util_tests="resize_down
  57. resize_up"
  58. run_tests resize_util_verify_environment "${resize_util_tests}"