vpxdec.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 vpxdec. To add new tests to this file, do the following:
  12. ## 1. Write a shell function (this is your test).
  13. ## 2. Add the function to vpxdec_tests (on a new line).
  14. ##
  15. . $(dirname $0)/tools_common.sh
  16. # Environment check: Make sure input is available.
  17. vpxdec_verify_environment() {
  18. if [ ! -e "${VP8_IVF_FILE}" ] || [ ! -e "${VP9_WEBM_FILE}" ] || \
  19. [ ! -e "${VP9_FPM_WEBM_FILE}" ] || \
  20. [ ! -e "${VP9_LT_50_FRAMES_WEBM_FILE}" ] || \
  21. [ ! -e "${VP9_RAW_FILE}" ]; then
  22. elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
  23. return 1
  24. fi
  25. if [ -z "$(vpx_tool_path vpxdec)" ]; then
  26. elog "vpxdec not found. It must exist in LIBVPX_BIN_PATH or its parent."
  27. return 1
  28. fi
  29. }
  30. # Wrapper function for running vpxdec with pipe input. Requires that
  31. # LIBVPX_BIN_PATH points to the directory containing vpxdec. $1 is used as the
  32. # input file path and shifted away. All remaining parameters are passed through
  33. # to vpxdec.
  34. vpxdec_pipe() {
  35. local decoder="$(vpx_tool_path vpxdec)"
  36. local input="$1"
  37. shift
  38. cat "${input}" | eval "${VPX_TEST_PREFIX}" "${decoder}" - "$@" ${devnull}
  39. }
  40. # Wrapper function for running vpxdec. Requires that LIBVPX_BIN_PATH points to
  41. # the directory containing vpxdec. $1 one is used as the input file path and
  42. # shifted away. All remaining parameters are passed through to vpxdec.
  43. vpxdec() {
  44. local decoder="$(vpx_tool_path vpxdec)"
  45. local input="$1"
  46. shift
  47. eval "${VPX_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull}
  48. }
  49. vpxdec_can_decode_vp8() {
  50. if [ "$(vp8_decode_available)" = "yes" ]; then
  51. echo yes
  52. fi
  53. }
  54. vpxdec_can_decode_vp9() {
  55. if [ "$(vp9_decode_available)" = "yes" ]; then
  56. echo yes
  57. fi
  58. }
  59. vpxdec_vp8_ivf() {
  60. if [ "$(vpxdec_can_decode_vp8)" = "yes" ]; then
  61. vpxdec "${VP8_IVF_FILE}" --summary --noblit
  62. fi
  63. }
  64. vpxdec_vp8_ivf_pipe_input() {
  65. if [ "$(vpxdec_can_decode_vp8)" = "yes" ]; then
  66. vpxdec_pipe "${VP8_IVF_FILE}" --summary --noblit
  67. fi
  68. }
  69. vpxdec_vp9_webm() {
  70. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  71. [ "$(webm_io_available)" = "yes" ]; then
  72. vpxdec "${VP9_WEBM_FILE}" --summary --noblit
  73. fi
  74. }
  75. vpxdec_vp9_webm_frame_parallel() {
  76. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  77. [ "$(webm_io_available)" = "yes" ]; then
  78. for threads in 2 3 4 5 6 7 8; do
  79. vpxdec "${VP9_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \
  80. --frame-parallel
  81. done
  82. fi
  83. }
  84. vpxdec_vp9_webm_less_than_50_frames() {
  85. # ensure that reaching eof in webm_guess_framerate doesn't result in invalid
  86. # frames in actual webm_read_frame calls.
  87. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  88. [ "$(webm_io_available)" = "yes" ]; then
  89. local decoder="$(vpx_tool_path vpxdec)"
  90. local expected=10
  91. local num_frames=$(${VPX_TEST_PREFIX} "${decoder}" \
  92. "${VP9_LT_50_FRAMES_WEBM_FILE}" --summary --noblit 2>&1 \
  93. | awk '/^[0-9]+ decoded frames/ { print $1 }')
  94. if [ "$num_frames" -ne "$expected" ]; then
  95. elog "Output frames ($num_frames) != expected ($expected)"
  96. return 1
  97. fi
  98. fi
  99. }
  100. # Ensures VP9_RAW_FILE correctly produces 1 frame instead of causing a hang.
  101. vpxdec_vp9_raw_file() {
  102. # Ensure a raw file properly reports eof and doesn't cause a hang.
  103. if [ "$(vpxdec_can_decode_vp9)" = "yes" ]; then
  104. local decoder="$(vpx_tool_path vpxdec)"
  105. local expected=1
  106. [ -x /usr/bin/timeout ] && local TIMEOUT="/usr/bin/timeout 30s"
  107. local num_frames=$(${TIMEOUT} ${VPX_TEST_PREFIX} "${decoder}" \
  108. "${VP9_RAW_FILE}" --summary --noblit 2>&1 \
  109. | awk '/^[0-9]+ decoded frames/ { print $1 }')
  110. if [ -z "$num_frames" ] || [ "$num_frames" -ne "$expected" ]; then
  111. elog "Output frames ($num_frames) != expected ($expected)"
  112. return 1
  113. fi
  114. fi
  115. }
  116. vpxdec_tests="vpxdec_vp8_ivf
  117. vpxdec_vp8_ivf_pipe_input
  118. vpxdec_vp9_webm
  119. vpxdec_vp9_webm_frame_parallel
  120. vpxdec_vp9_webm_less_than_50_frames
  121. vpxdec_vp9_raw_file"
  122. run_tests vpxdec_verify_environment "${vpxdec_tests}"