vpxdec.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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}" ] ; then
  21. elog "Libvpx test data must exist in LIBVPX_TEST_DATA_PATH."
  22. return 1
  23. fi
  24. if [ -z "$(vpx_tool_path vpxdec)" ]; then
  25. elog "vpxdec not found. It must exist in LIBVPX_BIN_PATH or its parent."
  26. return 1
  27. fi
  28. }
  29. # Wrapper function for running vpxdec with pipe input. Requires that
  30. # LIBVPX_BIN_PATH points to the directory containing vpxdec. $1 is used as the
  31. # input file path and shifted away. All remaining parameters are passed through
  32. # to vpxdec.
  33. vpxdec_pipe() {
  34. local readonly decoder="$(vpx_tool_path vpxdec)"
  35. local readonly input="$1"
  36. shift
  37. cat "${input}" | eval "${VPX_TEST_PREFIX}" "${decoder}" - "$@" ${devnull}
  38. }
  39. # Wrapper function for running vpxdec. Requires that LIBVPX_BIN_PATH points to
  40. # the directory containing vpxdec. $1 one is used as the input file path and
  41. # shifted away. All remaining parameters are passed through to vpxdec.
  42. vpxdec() {
  43. local readonly decoder="$(vpx_tool_path vpxdec)"
  44. local readonly input="$1"
  45. shift
  46. eval "${VPX_TEST_PREFIX}" "${decoder}" "$input" "$@" ${devnull}
  47. }
  48. vpxdec_can_decode_vp8() {
  49. if [ "$(vp8_decode_available)" = "yes" ]; then
  50. echo yes
  51. fi
  52. }
  53. vpxdec_can_decode_vp9() {
  54. if [ "$(vp9_decode_available)" = "yes" ]; then
  55. echo yes
  56. fi
  57. }
  58. vpxdec_vp8_ivf() {
  59. if [ "$(vpxdec_can_decode_vp8)" = "yes" ]; then
  60. vpxdec "${VP8_IVF_FILE}" --summary --noblit
  61. fi
  62. }
  63. vpxdec_vp8_ivf_pipe_input() {
  64. if [ "$(vpxdec_can_decode_vp8)" = "yes" ]; then
  65. vpxdec_pipe "${VP8_IVF_FILE}" --summary --noblit
  66. fi
  67. }
  68. vpxdec_vp9_webm() {
  69. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  70. [ "$(webm_io_available)" = "yes" ]; then
  71. vpxdec "${VP9_WEBM_FILE}" --summary --noblit
  72. fi
  73. }
  74. vpxdec_vp9_webm_frame_parallel() {
  75. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  76. [ "$(webm_io_available)" = "yes" ]; then
  77. for threads in 2 3 4 5 6 7 8; do
  78. vpxdec "${VP9_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \
  79. --frame-parallel
  80. done
  81. fi
  82. }
  83. vpxdec_vp9_webm_less_than_50_frames() {
  84. # ensure that reaching eof in webm_guess_framerate doesn't result in invalid
  85. # frames in actual webm_read_frame calls.
  86. if [ "$(vpxdec_can_decode_vp9)" = "yes" ] && \
  87. [ "$(webm_io_available)" = "yes" ]; then
  88. local readonly decoder="$(vpx_tool_path vpxdec)"
  89. local readonly expected=10
  90. local readonly num_frames=$(${VPX_TEST_PREFIX} "${decoder}" \
  91. "${VP9_LT_50_FRAMES_WEBM_FILE}" --summary --noblit 2>&1 \
  92. | awk '/^[0-9]+ decoded frames/ { print $1 }')
  93. if [ "$num_frames" -ne "$expected" ]; then
  94. elog "Output frames ($num_frames) != expected ($expected)"
  95. return 1
  96. fi
  97. fi
  98. }
  99. vpxdec_tests="vpxdec_vp8_ivf
  100. vpxdec_vp8_ivf_pipe_input
  101. vpxdec_vp9_webm
  102. vpxdec_vp9_webm_frame_parallel
  103. vpxdec_vp9_webm_less_than_50_frames"
  104. run_tests vpxdec_verify_environment "${vpxdec_tests}"