decode_with_drops.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 decode_with_drops example. 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 decode_with_drops_tests (on a new line).
  15. ##
  16. . $(dirname $0)/tools_common.sh
  17. # Environment check: Make sure input is available:
  18. # $VP8_IVF_FILE and $VP9_IVF_FILE are required.
  19. decode_with_drops_verify_environment() {
  20. if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_IVF_FILE}" ]; then
  21. echo "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
  22. return 1
  23. fi
  24. }
  25. # Runs decode_with_drops on $1, $2 is interpreted as codec name and used solely
  26. # to name the output file. $3 is the drop mode, and is passed directly to
  27. # decode_with_drops.
  28. decode_with_drops() {
  29. local decoder="${LIBVPX_BIN_PATH}/decode_with_drops${VPX_TEST_EXE_SUFFIX}"
  30. local input_file="$1"
  31. local codec="$2"
  32. local output_file="${VPX_TEST_OUTPUT_DIR}/decode_with_drops_${codec}"
  33. local drop_mode="$3"
  34. if [ ! -x "${decoder}" ]; then
  35. elog "${decoder} does not exist or is not executable."
  36. return 1
  37. fi
  38. eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
  39. "${drop_mode}" ${devnull}
  40. [ -e "${output_file}" ] || return 1
  41. }
  42. # Decodes $VP8_IVF_FILE while dropping frames, twice: once in sequence mode,
  43. # and once in pattern mode.
  44. # Note: This test assumes that $VP8_IVF_FILE has exactly 29 frames, and could
  45. # break if the file is modified.
  46. decode_with_drops_vp8() {
  47. if [ "$(vp8_decode_available)" = "yes" ]; then
  48. # Test sequence mode: Drop frames 2-28.
  49. decode_with_drops "${VP8_IVF_FILE}" "vp8" "2-28"
  50. # Test pattern mode: Drop 3 of every 4 frames.
  51. decode_with_drops "${VP8_IVF_FILE}" "vp8" "3/4"
  52. fi
  53. }
  54. # Decodes $VP9_IVF_FILE while dropping frames, twice: once in sequence mode,
  55. # and once in pattern mode.
  56. # Note: This test assumes that $VP9_IVF_FILE has exactly 20 frames, and could
  57. # break if the file is modified.
  58. decode_with_drops_vp9() {
  59. if [ "$(vp9_decode_available)" = "yes" ]; then
  60. # Test sequence mode: Drop frames 2-28.
  61. decode_with_drops "${VP9_IVF_FILE}" "vp9" "2-19"
  62. # Test pattern mode: Drop 3 of every 4 frames.
  63. decode_with_drops "${VP9_IVF_FILE}" "vp9" "3/4"
  64. fi
  65. }
  66. decode_with_drops_tests="decode_with_drops_vp8
  67. decode_with_drops_vp9"
  68. run_tests decode_with_drops_verify_environment "${decode_with_drops_tests}"