tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

aomenc.sh (8634B)


      1 #!/bin/sh
      2 ## Copyright (c) 2016, Alliance for Open Media. All rights reserved.
      3 ##
      4 ## This source code is subject to the terms of the BSD 2 Clause License and
      5 ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
      6 ## was not distributed with this source code in the LICENSE file, you can
      7 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
      8 ## Media Patent License 1.0 was not distributed with this source code in the
      9 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
     10 ##
     11 ## This file tests aomenc using hantro_collage_w352h288.yuv as input. To add
     12 ## new tests to this file, do the following:
     13 ##   1. Write a shell function (this is your test).
     14 ##   2. Add the function to aomenc_tests (on a new line).
     15 ##
     16 . $(dirname $0)/tools_common.sh
     17 
     18 # Environment check: Make sure input is available.
     19 aomenc_verify_environment() {
     20  if [ ! -e "${YUV_RAW_INPUT}" ]; then
     21    elog "The file ${YUV_RAW_INPUT##*/} must exist in LIBAOM_TEST_DATA_PATH."
     22    return 1
     23  fi
     24  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     25    if [ ! -e "${Y4M_NOSQ_PAR_INPUT}" ]; then
     26      elog "The file ${Y4M_NOSQ_PAR_INPUT##*/} must exist in"
     27      elog "LIBAOM_TEST_DATA_PATH."
     28      return 1
     29    fi
     30  fi
     31  if [ -z "$(aom_tool_path aomenc)" ]; then
     32    elog "aomenc not found. It must exist in LIBAOM_BIN_PATH or its parent."
     33    return 1
     34  fi
     35 }
     36 
     37 aomenc_can_encode_av1() {
     38  if [ "$(av1_encode_available)" = "yes" ]; then
     39    echo yes
     40  fi
     41 }
     42 
     43 # Utilities that echo aomenc input file parameters.
     44 y4m_input_non_square_par() {
     45  echo ""${Y4M_NOSQ_PAR_INPUT}""
     46 }
     47 
     48 y4m_input_720p() {
     49  echo ""${Y4M_720P_INPUT}""
     50 }
     51 
     52 # Wrapper function for running aomenc with pipe input. Requires that
     53 # LIBAOM_BIN_PATH points to the directory containing aomenc. $1 is used as the
     54 # input file path and shifted away. All remaining parameters are passed through
     55 # to aomenc.
     56 aomenc_pipe() {
     57  local encoder="$(aom_tool_path aomenc)"
     58  local input="$1"
     59  shift
     60  cat "${input}" | eval "${AOM_TEST_PREFIX}" "${encoder}" - \
     61    --test-decode=fatal \
     62    "$@" ${devnull}
     63 }
     64 
     65 # Wrapper function for running aomenc. Requires that LIBAOM_BIN_PATH points to
     66 # the directory containing aomenc. $1 one is used as the input file path and
     67 # shifted away. All remaining parameters are passed through to aomenc.
     68 aomenc() {
     69  local encoder="$(aom_tool_path aomenc)"
     70  local input="$1"
     71  shift
     72  eval "${AOM_TEST_PREFIX}" "${encoder}" "${input}" \
     73    --test-decode=fatal \
     74    "$@" ${devnull}
     75 }
     76 
     77 aomenc_av1_ivf() {
     78  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     79    local output="${AV1_IVF_FILE}"
     80    if [ -e "${AV1_IVF_FILE}" ]; then
     81      output="${AOM_TEST_OUTPUT_DIR}/av1_test.ivf"
     82    fi
     83    aomenc $(yuv_raw_input) \
     84      $(aomenc_encode_test_fast_params) \
     85      --ivf \
     86      --output="${output}" || return 1
     87 
     88    if [ ! -e "${output}" ]; then
     89      elog "Output file does not exist."
     90      return 1
     91    fi
     92  fi
     93 }
     94 
     95 aomenc_av1_ivf_rt() {
     96  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
     97    local output="${AV1_IVF_FILE}"
     98    if [ -e "${AV1_IVF_FILE}" ]; then
     99      output="${AOM_TEST_OUTPUT_DIR}/av1_test.ivf"
    100    fi
    101    aomenc $(yuv_raw_input) \
    102      $(aomenc_encode_test_rt_params) \
    103      --ivf \
    104      --output="${output}" || return 1
    105 
    106    if [ ! -e "${output}" ]; then
    107      elog "Output file does not exist."
    108      return 1
    109    fi
    110  fi
    111 }
    112 
    113 aomenc_av1_ivf_use_16bit_internal() {
    114  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    115    local output="${AV1_IVF_FILE}"
    116    if [ -e "${AV1_IVF_FILE}" ]; then
    117      output="${AOM_TEST_OUTPUT_DIR}/av1_test_16bit.ivf"
    118    fi
    119    aomenc $(yuv_raw_input) \
    120      $(aomenc_encode_test_fast_params) \
    121      --ivf \
    122      --use-16bit-internal \
    123      --output="${output}" || return 1
    124 
    125    if [ ! -e "${output}" ]; then
    126      elog "Output file does not exist."
    127      return 1
    128    fi
    129  fi
    130 }
    131 
    132 aomenc_av1_obu_annexb() {
    133   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    134    local output="${AV1_OBU_ANNEXB_FILE}"
    135    if [ -e "${AV1_OBU_ANNEXB_FILE}" ]; then
    136      output="${AOM_TEST_OUTPUT_DIR}/av1_test.annexb.obu"
    137    fi
    138    aomenc $(yuv_raw_input) \
    139      $(aomenc_encode_test_fast_params) \
    140      --obu \
    141      --annexb=1 \
    142      --output="${output}" || return 1
    143 
    144    if [ ! -e "${output}" ]; then
    145      elog "Output file does not exist."
    146      return 1
    147    fi
    148  fi
    149 }
    150 
    151 aomenc_av1_obu_section5() {
    152   if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    153    local output="${AV1_OBU_SEC5_FILE}"
    154    if [ -e "${AV1_OBU_SEC5_FILE}" ]; then
    155      output="${AOM_TEST_OUTPUT_DIR}/av1_test.section5.obu"
    156    fi
    157    aomenc $(yuv_raw_input) \
    158      $(aomenc_encode_test_fast_params) \
    159      --obu \
    160      --output="${output}" || return 1
    161 
    162    if [ ! -e "${output}" ]; then
    163      elog "Output file does not exist."
    164      return 1
    165    fi
    166  fi
    167 }
    168 
    169 aomenc_av1_webm() {
    170  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
    171     [ "$(webm_io_available)" = "yes" ]; then
    172    local output="${AV1_WEBM_FILE}"
    173    if [ -e "${AV1_WEBM_FILE}" ]; then
    174      output="${AOM_TEST_OUTPUT_DIR}/av1_test.webm"
    175    fi
    176    aomenc $(yuv_raw_input) \
    177      $(aomenc_encode_test_fast_params) \
    178      --output="${output}" || return 1
    179 
    180    if [ ! -e "${output}" ]; then
    181      elog "Output file does not exist."
    182      return 1
    183    fi
    184  fi
    185 }
    186 
    187 aomenc_av1_webm_1pass() {
    188  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
    189     [ "$(webm_io_available)" = "yes" ]; then
    190    local output="${AOM_TEST_OUTPUT_DIR}/av1_test.webm"
    191    aomenc $(yuv_raw_input) \
    192      $(aomenc_encode_test_fast_params) \
    193      --passes=1 \
    194      --output="${output}" || return 1
    195 
    196    if [ ! -e "${output}" ]; then
    197      elog "Output file does not exist."
    198      return 1
    199    fi
    200  fi
    201 }
    202 
    203 aomenc_av1_ivf_lossless() {
    204  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    205    local output="${AOM_TEST_OUTPUT_DIR}/av1_lossless.ivf"
    206    aomenc $(yuv_raw_input) \
    207      $(aomenc_encode_test_fast_params) \
    208      --ivf \
    209      --output="${output}" \
    210      --lossless=1 || return 1
    211 
    212    if [ ! -e "${output}" ]; then
    213      elog "Output file does not exist."
    214      return 1
    215    fi
    216  fi
    217 }
    218 
    219 aomenc_av1_ivf_minq0_maxq0() {
    220  if [ "$(aomenc_can_encode_av1)" = "yes" ]; then
    221    local output="${AOM_TEST_OUTPUT_DIR}/av1_lossless_minq0_maxq0.ivf"
    222    aomenc $(yuv_raw_input) \
    223      $(aomenc_encode_test_fast_params) \
    224      --ivf \
    225      --output="${output}" \
    226      --min-q=0 \
    227      --max-q=0 || return 1
    228 
    229    if [ ! -e "${output}" ]; then
    230      elog "Output file does not exist."
    231      return 1
    232    fi
    233  fi
    234 }
    235 
    236 aomenc_av1_webm_lag5_frames10() {
    237  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
    238     [ "$(webm_io_available)" = "yes" ]; then
    239    local lag_total_frames=10
    240    local lag_frames=5
    241    local output="${AOM_TEST_OUTPUT_DIR}/av1_lag5_frames10.webm"
    242    aomenc $(yuv_raw_input) \
    243      $(aomenc_encode_test_fast_params) \
    244      --limit=${lag_total_frames} \
    245      --lag-in-frames=${lag_frames} \
    246      --output="${output}" || return 1
    247 
    248    if [ ! -e "${output}" ]; then
    249      elog "Output file does not exist."
    250      return 1
    251    fi
    252  fi
    253 }
    254 
    255 # TODO(fgalligan): Test that DisplayWidth is different than video width.
    256 aomenc_av1_webm_non_square_par() {
    257  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
    258     [ "$(webm_io_available)" = "yes" ]; then
    259    local output="${AOM_TEST_OUTPUT_DIR}/av1_non_square_par.webm"
    260    aomenc $(y4m_input_non_square_par) \
    261      $(aomenc_encode_test_fast_params) \
    262      --output="${output}" || return 1
    263 
    264    if [ ! -e "${output}" ]; then
    265      elog "Output file does not exist."
    266      return 1
    267    fi
    268  fi
    269 }
    270 
    271 aomenc_av1_webm_cdf_update_mode() {
    272  if [ "$(aomenc_can_encode_av1)" = "yes" ] && \
    273     [ "$(webm_io_available)" = "yes" ]; then
    274    for mode in 0 1 2; do
    275      local output="${AOM_TEST_OUTPUT_DIR}/cdf_mode_${mode}.webm"
    276      aomenc $(yuv_raw_input) \
    277        $(aomenc_encode_test_fast_params) \
    278        --cdf-update-mode=${mode} \
    279        --output="${output}" || return 1
    280 
    281      if [ ! -e "${output}" ]; then
    282        elog "Output file does not exist."
    283        return 1
    284      fi
    285    done
    286  fi
    287 }
    288 
    289 if [ "$(realtime_only_build)" = "yes" ]; then
    290  aomenc_tests="aomenc_av1_ivf_rt"
    291 else
    292  aomenc_tests="aomenc_av1_ivf
    293                aomenc_av1_ivf_rt
    294                aomenc_av1_obu_annexb
    295                aomenc_av1_obu_section5
    296                aomenc_av1_webm
    297                aomenc_av1_webm_1pass
    298                aomenc_av1_ivf_lossless
    299                aomenc_av1_ivf_minq0_maxq0
    300                aomenc_av1_ivf_use_16bit_internal
    301                aomenc_av1_webm_lag5_frames10
    302                aomenc_av1_webm_non_square_par
    303                aomenc_av1_webm_cdf_update_mode"
    304 fi
    305 
    306 run_tests aomenc_verify_environment "${aomenc_tests}"