Skip to content
Commits on Source (127)
......@@ -10,6 +10,8 @@ variables:
LONG_TEST_SUITE: "tests/codec_be_on_mr_nonselection tests/renderer --param_file scripts/config/self_test_ltv.prm --use_ltv"
LONG_TEST_SUITE_NO_RENDERER: "tests/codec_be_on_mr_nonselection --param_file scripts/config/self_test_ltv.prm --use_ltv"
SHORT_TEST_SUITE: "tests/codec_be_on_mr_nonselection"
SHORT_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_basop_encoder.prm"
LONG_TEST_SUITE_ENCODER: "tests/codec_be_on_mr_nonselection/test_param_file.py --param_file scripts/config/self_test_ltv_basop_encoder.prm"
TEST_SUITE: ""
DUT_ENCODER_PATH: "./IVAS_cod"
DUT_DECODER_PATH: "./IVAS_dec"
......@@ -28,6 +30,8 @@ variables:
CI_REGRESSION_THRESH_ODG: "-0.05"
GIT_CLEAN_FLAGS: -ffdxq
INSTR_DIR: "scripts/c-code_instrument"
BUILD_WITH_DEBUG_MODE_INFO: ""
ENCODER_TEST: ""
MANUAL_PIPELINE_TYPE:
description: "Type for the manual pipeline run. Use 'pytest-compare' to run comparison test against reference float codec."
value: 'default'
......@@ -38,7 +42,7 @@ variables:
- 'pytest-compare-to-input'
- 'pytest-saturation-smoke-test'
- 'evs-26444'
- 'sanitizer-stv'
- 'sanitizer'
- 'pytest-renderer'
- 'complexity'
- 'coverage'
......@@ -79,7 +83,7 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'evs-26444'
variables:
IVAS_PIPELINE_NAME: 'EVS 26.444 test: $CI_COMMIT_BRANCH'
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer-stv'
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'sanitizer'
variables:
IVAS_PIPELINE_NAME: 'Short testvectors sanitizers'
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == 'pytest-renderer'
......@@ -117,11 +121,18 @@ stages:
echo "Commit time was $CI_COMMIT_TIMESTAMP"
date | xargs echo "System time is"
.activate-debug-mode-info-if-set: &activate-debug-mode-info-if-set
- if [ "$BUILD_WITH_DEBUG_MODE_INFO" = "true" ]; then
- sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUGGING\ *\)\*\//\1/g" lib_com/options.h
- sed -i.bak -e "s/\/\*\ *\(#define\ *DEBUG_MODE_INFO\ *\)\*\//\1/g" lib_com/options.h
- fi
.build-reference-binaries: &build-reference-binaries
- current_commit_sha=$(git rev-parse HEAD)
### build reference binaries
- git checkout $REFERENCE_BRANCH
- git pull
- *activate-debug-mode-info-if-set
- make clean
- make -j
- mv ./IVAS_cod ./$REF_ENCODER_PATH
......@@ -136,6 +147,7 @@ stages:
### build reference binaries
- *build-reference-binaries
### build dut binaries
- *activate-debug-mode-info-if-set
- make clean
- make -j
......@@ -147,7 +159,9 @@ stages:
- python3 tests/create_short_testvectors.py
# create references
- exit_code=0
- python3 -m pytest $TEST_SUITE -v --update_ref 1 --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
- enc_stats_arg=""
- if [ "$ENCODER_TEST" = "true" ]; then enc_stats_arg="--enc_stats"; fi
- python3 -m pytest $TEST_SUITE -v --update_ref 1 $enc_stats_arg --create_ref -n auto --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
.update-scripts-repo: &update-scripts-repo
- cd $SCRIPTS_DIR
......@@ -291,11 +305,17 @@ stages:
- if [ $LEVEL_SCALING != "1.0" ];then
- *apply-testv-scaling
- fi
- if [ "$ENCODER_TEST" = "true" ]; then BUILD_WITH_DEBUG_MODE_INFO="true"; fi
- *build-and-create-reference-outputs
- comp_args="--mld --ssnr --odg"
- if [ "$ENCODER_TEST" = "true" ]; then comp_args="${comp_args} --enc_stats"; fi
- echo "$comp_args"
### run pytest
- exit_code=0
- python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml --mld --ssnr --odg -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
- python3 -m pytest --tb=no $TEST_SUITE -v --create_cut --html=report.html --self-contained-html --junit-xml=report-junit.xml $comp_args -n auto --testcase_timeout $testcase_timeout --ref_encoder_path $REF_ENCODER_PATH --ref_decoder_path $REF_DECODER_PATH --dut_encoder_path $DUT_ENCODER_PATH --dut_decoder_path $DUT_DECODER_PATH || exit_code=$?
- zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
- python3 scripts/parse_xml_report.py report-junit.xml $CSV_ARTIFACT_NAME
......@@ -474,14 +494,14 @@ stages:
.ivas-pytest-sanitizers-anchor: &ivas-pytest-sanitizers-anchor
stage: test
needs: ["build-codec-linux-make"]
timeout: "90 minutes"
timeout: "300 minutes"
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
when: never
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
- if: $CI_PIPELINE_SOURCE == 'schedule' && $IVAS_PYTEST_MSAN
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer-stv"
- if: $CI_PIPELINE_SOURCE == 'web' && $MANUAL_PIPELINE_TYPE == "sanitizer"
script:
- *print-common-info
- *update-scripts-repo
......@@ -491,7 +511,7 @@ stages:
- make -j CLANG=$CLANG_NUM
- if [[ $CLANG_NUM == 3 ]]; then export UBSAN_OPTIONS="suppressions=scripts/ubsan.supp,report_error_type=1"; fi
- testcase_timeout=$TESTCASE_TIMEOUT_STV_SANITIZERS
- python3 -m pytest $SHORT_TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH
- python3 -m pytest $TEST_SUITE -v --tb=no --update_ref 1 --html=report.html --self-contained-html --junit-xml=report-junit.xml --testcase_timeout $testcase_timeout --ref_encoder_path $DUT_ENCODER_PATH --ref_decoder_path $DUT_DECODER_PATH
artifacts:
name: "$CI_JOB_NAME--sha-$CI_COMMIT_SHORT_SHA--results"
when: always
......@@ -683,6 +703,24 @@ build-codec-linux-instrumented-make:
- bash scripts/prepare_instrumentation.sh -m MEM_ONLY -p BASOP
- make -j -C $INSTR_DIR
build-codec-linux-debugging-make:
rules:
- if: $CI_PIPELINE_SOURCE == 'web'
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main" # only have MR pipelines for MRs to main
- if: $CI_PIPELINE_SOURCE == 'schedule'
- if: $CI_PIPELINE_SOURCE == 'push'
when: never
extends:
- .build-job-linux
timeout: "7 minutes"
variables:
BUILD_WITH_DEBUG_MODE_INFO: "true"
script:
- *print-common-info
- *activate-debug-mode-info-if-set
- make -j
# ---------------------------------------------------------------
# Short test jobs that run in merge request pipelines
# ---------------------------------------------------------------
......@@ -696,7 +734,7 @@ build-codec-linux-instrumented-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
# - TEST_SUITE="$SHORT_TEST_SUITE"
# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=1.0
# <<: *ivas-pytest-on-merge-request-anchor
......@@ -707,7 +745,7 @@ build-codec-linux-instrumented-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
# - TEST_SUITE="$SHORT_TEST_SUITE"
# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=0.3162
# <<: *ivas-pytest-on-merge-request-anchor
......@@ -718,7 +756,7 @@ build-codec-linux-instrumented-make:
# before_script:
# - USE_LTV=0
# - DUT_DECODER_PATH=./IVAS_dec_ref
# - TEST_SUITE="$SHORT_TEST_SUITE"
# - TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
# - LEVEL_SCALING=3.162
# <<: *ivas-pytest-on-merge-request-anchor
......@@ -771,8 +809,9 @@ ivas-pytest-compare_to_ref-short-enc:
- .test-job-linux
before_script:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$SHORT_TEST_SUITE"
- TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
......@@ -783,8 +822,9 @@ ivas-pytest-compare_to_ref-short-enc-lev-10:
- .test-job-linux
before_script:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$SHORT_TEST_SUITE"
- TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
......@@ -795,8 +835,9 @@ ivas-pytest-compare_to_ref-short-enc-lev+10:
- .test-job-linux
before_script:
- USE_LTV=0
- ENCODER_TEST="true"
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$SHORT_TEST_SUITE"
- TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
......@@ -806,6 +847,7 @@ ivas-pytest-enc-msan:
before_script:
- CLANG_NUM=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE=$LONG_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-enc-asan:
......@@ -814,6 +856,7 @@ ivas-pytest-enc-asan:
before_script:
- CLANG_NUM=2
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE=$LONG_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-enc-usan:
......@@ -822,6 +865,7 @@ ivas-pytest-enc-usan:
before_script:
- CLANG_NUM=3
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE=$SHORT_TEST_SUITE_ENCODER
<<: *ivas-pytest-sanitizers-anchor
### jobs that test flt encoder -> fx decoder
......@@ -858,6 +902,7 @@ ivas-pytest-compare_to_ref-short-dec-lev+10:
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
### jobs that compare the output synthesis to the input files directly
ivas-pytest-compare-to-input-short-dec:
extends:
- .rules-pytest-to-input-short
......@@ -876,32 +921,35 @@ ivas-pytest-compare-to-input-short-enc:
before_script:
- USE_LTV=0
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$SHORT_TEST_SUITE"
- TEST_SUITE="$SHORT_TEST_SUITE_ENCODER"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-compare-to-input-anchor
ivas-pytest-dec-msan-short:
ivas-pytest-dec-msan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=1
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
- TEST_SUITE=$LONG_TEST_SUITE_SELF_TEST
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-asan-short:
ivas-pytest-dec-asan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=2
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
- TEST_SUITE=$LONG_TEST_SUITE_SELF_TEST
<<: *ivas-pytest-sanitizers-anchor
ivas-pytest-dec-usan-short:
ivas-pytest-dec-usan:
extends:
- .test-job-linux
before_script:
- CLANG_NUM=3
- DUT_ENCODER_PATH=./$REF_ENCODER_PATH
- TEST_SUITE=$SHORT_TEST_SUITE
<<: *ivas-pytest-sanitizers-anchor
# ---------------------------------------------------------------
......@@ -915,7 +963,7 @@ ivas-pytest-compare_ref-long-enc:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$LONG_TEST_SUITE"
- TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=1.0
<<: *ivas-pytest-anchor
......@@ -937,7 +985,7 @@ ivas-pytest-compare_ref-long-enc-lev-10:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$LONG_TEST_SUITE"
- TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=0.3162
<<: *ivas-pytest-anchor
......@@ -959,7 +1007,7 @@ ivas-pytest-compare_ref-long-enc-lev+10:
before_script:
- USE_LTV=1
- DUT_DECODER_PATH=./$REF_DECODER_PATH
- TEST_SUITE="$LONG_TEST_SUITE"
- TEST_SUITE="$LONG_TEST_SUITE_ENCODER"
- LEVEL_SCALING=3.162
<<: *ivas-pytest-anchor
......
......@@ -142,9 +142,7 @@
<ClCompile Include="..\lib_com\cng_exc_fx.c" />
<ClCompile Include="..\lib_com\codec_tcx_common.c" />
<ClCompile Include="..\lib_com\complex_basop.c" />
<ClCompile Include="..\lib_com\control.c" />
<ClCompile Include="..\lib_com\core_com_config.c" />
<ClCompile Include="..\lib_com\count.c" />
<ClCompile Include="..\lib_com\deemph.c" />
<ClCompile Include="..\lib_com\delay_comp.c" />
<ClCompile Include="..\lib_com\disclaimer.c" />
......@@ -160,7 +158,6 @@
<ClCompile Include="..\lib_com\env_adj.c" />
<ClCompile Include="..\lib_com\env_stab.c" />
<ClCompile Include="..\lib_com\env_stab_trans.c" />
<ClCompile Include="..\lib_com\est_tilt.c" />
<ClCompile Include="..\lib_com\est_tilt_fx.c" />
<ClCompile Include="..\lib_com\fd_cng_com_fx.c" />
<ClCompile Include="..\lib_com\fft.c" />
......@@ -172,19 +169,16 @@
<ClCompile Include="..\lib_com\fft_rel_fx.c" />
<ClCompile Include="..\lib_com\fill_spectrum.c" />
<ClCompile Include="..\lib_com\findpulse.c" />
<ClCompile Include="..\lib_com\fine_gain_bits.c" />
<ClCompile Include="..\lib_com\fine_gain_bits_fx.c" />
<ClCompile Include="..\lib_com\float_to_fix_ops.c" />
<ClCompile Include="..\lib_com\frame_ener_fx.c" />
<ClCompile Include="..\lib_com\gain_inov_fx.c" />
<ClCompile Include="..\lib_com\get_gain_fx.c" />
<ClCompile Include="..\lib_com\gs_bitallocation.c" />
<ClCompile Include="..\lib_com\gs_bitallocation_fx.c" />
<ClCompile Include="..\lib_com\gs_bitallocation_ivas_fx.c" />
<ClCompile Include="..\lib_com\gs_gains.c" />
<ClCompile Include="..\lib_com\gs_gains_fx.c" />
<ClCompile Include="..\lib_com\gs_inact_switching_fx.c" />
<ClCompile Include="..\lib_com\gs_noisefill.c" />
<ClCompile Include="..\lib_com\gs_noisefill_fx.c" />
<ClCompile Include="..\lib_com\gs_preech_fx.c" />
<ClCompile Include="..\lib_com\guided_plc_util_fx.c" />
......@@ -278,7 +272,6 @@
<ClCompile Include="..\lib_com\rom_basic_math.c" />
<ClCompile Include="..\lib_com\rom_basop_util.c" />
<ClCompile Include="..\lib_com\rom_com.c" />
<ClCompile Include="..\lib_com\ivas_sns_com.c" />
<ClCompile Include="..\lib_com\rom_com_fx.c" />
<ClCompile Include="..\lib_com\scale_mem_fx.c" />
<ClCompile Include="..\lib_com\stab_est_fx.c" />
......
......@@ -10,9 +10,6 @@
<ClCompile Include="..\lib_com\ivas_sba_config.c">
<Filter>common_ivas_c</Filter>
</ClCompile>
<ClCompile Include="..\lib_com\ivas_sns_com.c">
<Filter>common_ivas_c</Filter>
</ClCompile>
<ClCompile Include="..\lib_com\ivas_mc_com.c">
<Filter>common_ivas_c</Filter>
</ClCompile>
......@@ -79,9 +76,6 @@
<ClCompile Include="..\lib_com\ivas_lfe_com.c">
<Filter>common_ivas_c</Filter>
</ClCompile>
<ClCompile Include="..\lib_com\control.c">
<Filter>common_all_c</Filter>
</ClCompile>
<ClCompile Include="..\lib_com\enh64.c">
<Filter>common_all_c</Filter>
</ClCompile>
......@@ -386,15 +380,11 @@
<ClCompile Include="..\lib_com\enr_1_az.c" />
<ClCompile Include="..\lib_com\env_adj.c" />
<ClCompile Include="..\lib_com\env_stab.c" />
<ClCompile Include="..\lib_com\est_tilt.c" />
<ClCompile Include="..\lib_com\fft.c" />
<ClCompile Include="..\lib_com\fft_rel.c" />
<ClCompile Include="..\lib_com\fill_spectrum.c" />
<ClCompile Include="..\lib_com\findpulse.c" />
<ClCompile Include="..\lib_com\fine_gain_bits.c" />
<ClCompile Include="..\lib_com\gs_bitallocation.c" />
<ClCompile Include="..\lib_com\gs_gains.c" />
<ClCompile Include="..\lib_com\gs_noisefill.c" />
<ClCompile Include="..\lib_com\hq2_core_com.c" />
<ClCompile Include="..\lib_com\hq_conf.c" />
<ClCompile Include="..\lib_com\ifft_rel.c" />
......@@ -424,7 +414,6 @@
<ClCompile Include="..\lib_com\tools.c" />
<ClCompile Include="..\lib_com\wtda.c" />
<ClCompile Include="..\lib_com\gs_bitallocation_ivas_fx.c" />
<ClCompile Include="..\lib_com\count.c" />
<ClCompile Include="..\lib_com\ivas_stereo_ica_com_fx.c" />
<ClCompile Include="..\lib_com\frame_ener_fx.c" />
<ClCompile Include="..\lib_com\get_gain_fx.c" />
......
......@@ -159,7 +159,9 @@ HISTORY:
#include <stdio.h>
#include <stdlib.h>
#include "options.h"
#include "stl.h"
#ifdef BASOP_NOGLOB
#include <assert.h>
#endif /* BASOP_NOGLOB */
......@@ -170,10 +172,6 @@ HISTORY:
#pragma warning( disable : 4310 )
#endif
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif
/*___________________________________________________________________________
| |
......@@ -2825,6 +2823,11 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow )
{
var_out = shr_o( var1, var2, Overflow );
#ifdef FIX_1049_SHR_RO_COMPLEXITY
#ifdef WMOPS
multiCounter[currCounter].shr--;
#endif
#endif
if ( var2 > 0 )
{
if ( ( var1 & ( (Word16) 1 << ( var2 - 1 ) ) ) != 0 )
......@@ -2833,6 +2836,15 @@ Word16 shr_ro( Word16 var1, Word16 var2, Flag *Overflow )
}
}
}
#ifdef FIX_1049_SHR_RO_COMPLEXITY
#ifdef WMOPS
multiCounter[currCounter].shr_r++;
#endif
BASOP_CHECK();
#endif
return ( var_out );
}
Word16 shr_r_sat( Word16 var1, Word16 var2 )
......
......@@ -43,7 +43,6 @@
#include "rom_com.h"
#include "rom_basic_math.h"
#include "basop_settings.h"
#include "control.h"
#include "cnst.h"
......@@ -1556,7 +1555,7 @@ Word16 findIndexOfMinWord32( Word32 *x, const Word16 len )
Word16 imult1616( Word16 x, Word16 y )
{
assert( (int) x * (int) y < 32768 && (int) x * (int) y >= -32768 );
return extract_l( L_mult0( x, y ) );
return i_mult( x, y );
}
Word32 imult3216( Word32 x, Word16 y )
......
......@@ -9,22 +9,9 @@
*****************************************************************************/
#include "typedef.h"
#include "basop32.h"
#include "complex_basop.h"
#include "stl.h"
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* if WMOPS */
#define WMC_TOOL_SKIP
#ifdef COMPLEX_OPERATOR
......
......@@ -10,8 +10,6 @@
#ifndef _COMPLEX_BASIC_OP_H
#define _COMPLEX_BASIC_OP_H
#include "typedef.h"
#include "basop32.h"
#include "stl.h"
#ifdef COMPLEX_OPERATOR
......
/*
===========================================================================
File: CONTROL.C v.2.3 - 30.Nov.2009
===========================================================================
ITU-T STL BASIC OPERATORS
CONTROL FLOW OPERATOR INTERNAL VARIABLE DECLARATIONS
History:
07 Nov 04 v2.0 Incorporation of new 32-bit / 40-bit / control
operators for the ITU-T Standard Tool Library as
described in Geneva, 20-30 January 2004 WP 3/16 Q10/16
TD 11 document and subsequent discussions on the
wp3audio@yahoogroups.com email reflector.
March 06 v2.1 Changed to improve portability.
============================================================================
*/
#include "stl.h"
#ifdef WMOPS
int funcId_where_last_call_to_else_occurred;
long funcid_total_wmops_at_last_call_to_else;
int call_occurred = 1;
#endif
#ifdef CONTROL_CODE_OPS
Flag LT_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 < var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_16++;
#endif
return F_ret;
}
Flag GT_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 > var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_16++;
#endif
return F_ret;
}
Flag LE_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 <= var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_16++;
#endif
return F_ret;
}
Flag GE_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 >= var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_16++;
#endif
return F_ret;
}
Flag EQ_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 == var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_16++;
#endif
return F_ret;
}
Flag NE_16( Word16 var1, Word16 var2 )
{
Flag F_ret = 0;
if ( var1 != var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].NE_16++;
#endif
return F_ret;
}
Flag LT_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 < L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_32++;
#endif
return F_ret;
}
Flag GT_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 > L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_32++;
#endif
return F_ret;
}
Flag LE_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 <= L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_32++;
#endif
return F_ret;
}
Flag GE_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 >= L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_32++;
#endif
return F_ret;
}
Flag EQ_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 == L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_32++;
#endif
return F_ret;
}
Flag NE_32( Word32 L_var1, Word32 L_var2 )
{
Flag F_ret = 0;
if ( L_var1 != L_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].NE_32++;
#endif
return F_ret;
}
Flag LT_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 < L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LT_64++;
#endif
return F_ret;
}
Flag GT_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 > L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GT_64++;
#endif
return F_ret;
}
Flag LE_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 <= L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].LE_64++;
#endif
return F_ret;
}
Flag GE_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 >= L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].GE_64++;
#endif
return F_ret;
}
Flag EQ_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 == L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].EQ_64++;
#endif
return F_ret;
}
Flag NE_64( Word64 L64_var1, Word64 L64_var2 )
{
Flag F_ret = 0;
if ( L64_var1 != L64_var2 )
{
F_ret = 1;
}
#ifdef WMOPS
multiCounter[currCounter].NE_64++;
#endif
return F_ret;
}
#endif /* #ifdef CONTROL_CODE_OPS */
/* end of file */
/******************************************************************************************************
(C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository. All Rights Reserved.
This software is protected by copyright law and by international treaties.
The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository retain full ownership rights in their respective contributions in
the software. This notice grants no license of any kind, including but not limited to patent
license, nor is any license granted by implication, estoppel or otherwise.
Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
contributions.
This software is provided "AS IS", without any express or implied warranties. The software is in the
development stage. It is intended exclusively for experts who have experience with such software and
solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
and fitness for a particular purpose are hereby disclaimed and excluded.
Any dispute, controversy or claim arising under or in relation to providing this software shall be
submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
#ifndef _CONTROL_H
#define _CONTROL_H
#include "stl.h"
/*****************************************************************************
*
* Constants and Globals
*
*****************************************************************************/
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
/* Technical note :
* The following 3 variables are only used for correct complexity
* evaluation of the following structure :
* IF{
* ...
* } ELSE IF {
* ...
* } ELSE IF {
* ...
* }
* ...
* } ELSE {
* ...
* }
*/
extern int funcId_where_last_call_to_else_occurred;
extern long funcid_total_wmops_at_last_call_to_else;
extern int call_occurred;
#endif /* ifdef WMOPS */
/*****************************************************************************
*
* Function Macros
*
*****************************************************************************/
/*****************************************************************************
*
* Function Name : FOR
*
* Purpose :
*
* The macro FOR should be used instead of the 'for' C statement.
* The complexity is independent of the number of loop iterations that are
* performed.
*
* Complexity weight : 3 (regardless of number of iterations).
*
*****************************************************************************/
#ifndef WMOPS
#define FOR( a ) for ( a )
#else /* ifndef WMOPS */
#define FOR( a ) \
if ( incrFor(), 0 ) \
; \
else \
for ( a )
static __inline void incrFor( void )
{
multiCounter[currCounter].For++;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : WHILE
*
* Purpose :
*
* The macro WHILE should be used instead of the 'while' C statement.
* The complexity is proportional to the number of loop iterations that
* are performed.
*
* Complexity weight : 4 x 'number of loop iterations'.
*
*****************************************************************************/
#ifndef WMOPS
#define WHILE( a ) while ( a )
#else /* ifndef WMOPS */
#define WHILE( a ) while ( incrWhile(), a )
static __inline void incrWhile( void )
{
multiCounter[currCounter].While++;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : DO
*
* Purpose :
*
* The macro DO should be used instead of the 'do' C statement.
*
* Complexity weight : 0 (complexity counted by WHILE macro).
*
*****************************************************************************/
#ifndef WMOPS
#define DO do
#else /* ifndef WMOPS */
#define DO do
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : IF
*
* Purpose :
*
* The macro IF should :
*
* - not be used when :
* - the 'if' structure does not have any 'else if' nor 'else' statement
* - and it conditions only one DSP basic operations.
*
* - be used instead of the 'if' C statement in every other case :
* - when there is an 'else' or 'else if' statement,
* - or when the 'if' conditions several DSP basic operations,
* - or when the 'if' conditions a function call.
*
* Complexity weight : 4
*
*****************************************************************************/
#ifndef WMOPS
#define IF( a ) if ( a )
#else /* ifndef WMOPS */
#define IF( a ) if ( incrIf(), a )
static __inline void incrIf( void )
{
/* Technical note :
* If the "IF" operator comes just after an "ELSE", its counter
* must not be incremented.
*/
if ( ( currCounter != funcId_where_last_call_to_else_occurred ) || ( TotalWeightedOperation() != funcid_total_wmops_at_last_call_to_else ) || ( call_occurred == 1 ) )
multiCounter[currCounter].If++;
call_occurred = 0;
funcId_where_last_call_to_else_occurred = MAXCOUNTERS;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : ELSE
*
* Purpose :
*
* The macro ELSE should be used instead of the 'else' C statement.
*
* Complexity weight : 4
*
*****************************************************************************/
#ifndef WMOPS
#define ELSE else
#else /* ifndef WMOPS */
#define ELSE \
else if ( incrElse(), 0 ); \
else
static __inline void incrElse( void )
{
multiCounter[currCounter].If++;
/* We keep track of the funcId of the last function which used ELSE {...} structure. */
funcId_where_last_call_to_else_occurred = currCounter;
/* We keep track of the number of WMOPS of this funcId when the ELSE macro was called. */
funcid_total_wmops_at_last_call_to_else = TotalWeightedOperation();
/* call_occurred is set to 0, in order to count the next IF (if necessary) */
call_occurred = 0;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : SWITCH
*
* Purpose :
*
* The macro SWITCH should be used instead of the 'switch' C statement.
*
* Complexity weight : 8
*
*****************************************************************************/
#ifndef WMOPS
#define SWITCH( a ) switch ( a )
#else /* ifndef WMOPS */
#define SWITCH( a ) switch ( incrSwitch(), a )
static __inline void incrSwitch( void )
{
multiCounter[currCounter].Switch++;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : CONTINUE
*
* Purpose :
*
* The macro CONTINUE should be used instead of the 'continue' C statement.
*
* Complexity weight : 4
*
*****************************************************************************/
#ifndef WMOPS
#define CONTINUE continue
#else /* ifndef WMOPS */
#define CONTINUE \
if ( incrContinue(), 0 ) \
; \
else \
continue
static __inline void incrContinue( void )
{
multiCounter[currCounter].Continue++;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : BREAK
*
* Purpose :
*
* The macro BREAK should be used instead of the 'break' C statement.
*
* Complexity weight : 4
*
*****************************************************************************/
#ifndef WMOPS
#define BREAK break
#else /* ifndef WMOPS */
#define BREAK \
if ( incrBreak(), 0 ) \
; \
else \
break
static __inline void incrBreak( void )
{
multiCounter[currCounter].Break++;
}
#endif /* ifndef WMOPS */
/*****************************************************************************
*
* Function Name : GOTO
*
* Purpose :
*
* The macro GOTO should be used instead of the 'goto' C statement.
*
* Complexity weight : 4
*
*****************************************************************************/
#ifndef WMOPS
#define GOTO goto
#else /* ifndef WMOPS */
#define GOTO \
if ( incrGoto(), 0 ) \
; \
else \
goto
static __inline void incrGoto( void )
{
multiCounter[currCounter].Goto++;
}
#endif /* ifndef WMOPS */
/*
* New control code basops
*/
#ifdef CONTROL_CODE_OPS
Flag LT_16( Word16 var1, Word16 var2 );
Flag GT_16( Word16 var1, Word16 var2 );
Flag LE_16( Word16 var1, Word16 var2 );
Flag GE_16( Word16 var1, Word16 var2 );
Flag EQ_16( Word16 var1, Word16 var2 );
Flag NE_16( Word16 var1, Word16 var2 );
Flag LT_32( Word32 L_var1, Word32 L_var2 );
Flag GT_32( Word32 L_var1, Word32 L_var2 );
Flag LE_32( Word32 L_var1, Word32 L_var2 );
Flag GE_32( Word32 L_var1, Word32 L_var2 );
Flag EQ_32( Word32 L_var1, Word32 L_var2 );
Flag NE_32( Word32 L_var1, Word32 L_var2 );
Flag LT_64( Word64 L64_var1, Word64 L64_var2 );
Flag GT_64( Word64 L64_var1, Word64 L64_var2 );
Flag LE_64( Word64 L64_var1, Word64 L64_var2 );
Flag GE_64( Word64 L64_var1, Word64 L64_var2 );
Flag EQ_64( Word64 L64_var1, Word64 L64_var2 );
Flag NE_64( Word64 L64_var1, Word64 L64_var2 );
#endif /* #ifdef CONTROL_CODE_OPS */
#endif /* _CONTROL_H */
/* end of file */
This diff is collapsed.
This diff is collapsed.
......@@ -58,12 +58,6 @@
#define WMC_TOOL_SKIP
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* ifdef WMOPS */
/*****************************************************************************
*
* Constants and Globals
......
......@@ -35,14 +35,6 @@
#include "stl.h"
#ifdef WMOPS
#include "count.h"
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* ifdef WMOPS */
/*****************************************************************************
*
* Prototypes for enhanced 16/32 bit arithmetic operators
......
......@@ -21,15 +21,10 @@
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "enh32.h"
#include "stl.h"
#define WMC_TOOL_SKIP
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* if WMOPS */
#ifdef ENH_32_BIT_OPERATOR
/*****************************************************************************
*
......
......@@ -16,16 +16,10 @@
*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "enh64.h"
#include "stl.h"
#define WMC_TOOL_SKIP
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* if WMOPS */
/*****************************************************************************
*
* Local Functions
......
......@@ -25,16 +25,10 @@
#include <stdio.h>
#include <stdlib.h>
#include "stl.h"
#include "enhUL32.h"
#include "stl.h"
#define WMC_TOOL_SKIP
#ifdef WMOPS
extern BASIC_OP multiCounter[MAXCOUNTERS];
extern int currCounter;
#endif /* if WMOPS */
/*****************************************************************************
*
* Constants and Globals
......
......@@ -24,12 +24,6 @@
#define UWord64 unsigned long long /* for local use inside UL_Mpy_32_* */
#endif
#ifdef WMOPS
#include "count.h"
extern BASIC_OP multiCounter[MAXCOUNTERS]; /* existing signed counters are reused for unsigedn operators */
extern int currCounter;
#endif /* if WMOPS */
/*****************************************************************************
*
* Prototypes for enhanced unsigned 32 bit arithmetic operators
......
/******************************************************************************************************
(C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository. All Rights Reserved.
This software is protected by copyright law and by international treaties.
The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository retain full ownership rights in their respective contributions in
the software. This notice grants no license of any kind, including but not limited to patent
license, nor is any license granted by implication, estoppel or otherwise.
Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
contributions.
This software is provided "AS IS", without any express or implied warranties. The software is in the
development stage. It is intended exclusively for experts who have experience with such software and
solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
and fitness for a particular purpose are hereby disclaimed and excluded.
Any dispute, controversy or claim arising under or in relation to providing this software shall be
submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
/*====================================================================================
EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
====================================================================================*/
#include <stdint.h>
#include "options.h"
#include "cnst.h"
#include "prot.h"
#include "wmc_auto.h"
/*-------------------------------------------------------------------*
* est_tilt()
*
* Estimate spectral tilt based on the relative E of adaptive
* and innovative excitations
*-------------------------------------------------------------------*/
/*! r: tilt of the code */
float est_tilt(
const float *adpt_exc, /* i : adaptive excitation vector */
const float gain_pit, /* i : adaptive gain */
const float *fixe_exc, /* i : algebraic exctitation vector */
const float gain_code, /* i : algebraic code gain */
float *voice_fac, /* o : voicing factor */
const int16_t L_subfr, /* i : subframe size */
const int16_t flag_tilt /* i : flag for special tilt */
)
{
float ener, tmp, tilt_code;
ener = dotp( adpt_exc, adpt_exc, L_subfr );
ener *= gain_pit * gain_pit; /* energy of pitch excitation */
tmp = dotp( fixe_exc, fixe_exc, L_subfr );
tmp *= gain_code * gain_code; /* energy of innovative code excitation */
/* find voice factor (1=voiced, -1=unvoiced) */
*voice_fac = (float) ( ( ener - tmp ) / ( ener + tmp + 0.01f ) );
/* find tilt of code for next subframe */
if ( flag_tilt == 0 )
{
/*Between 0 (=unvoiced) and 0.5 (=voiced)*/
tilt_code = (float) ( 0.25f * ( 1.0f + *voice_fac ) );
}
else if ( flag_tilt == 1 )
{
/*Between 0.25 (=unvoiced) and 0.5 (=voiced)*/
tilt_code = (float) ( 0.25f + ( *voice_fac + 1.0f ) * 0.125f );
}
else
{
/*Between 0.28 (=unvoiced) and 0.56 (=voiced)*/
tilt_code = (float) ( 0.28f + ( *voice_fac + 1.0f ) * 0.14f );
}
return tilt_code;
}
......@@ -7262,15 +7262,29 @@ Word16 L_norm_arr( Word32 *arr, Word16 size )
Word16 q = 31;
move16();
FOR( Word16 i = 0; i < size; i++ )
#ifndef FIX_1103_OPT_L_NORM_ARR
IF( arr[i] != 0 )
{
q = s_min( q, norm_l( arr[i] ) );
}
#else
{
Word16 q_tst;
q_tst = norm_l( arr[i] );
if ( arr[i] != 0 )
{
q = s_min( q, q_tst );
}
}
#endif
return q;
}
Word16 get_min_scalefactor( Word32 x, Word32 y )
{
#ifndef FIX_1104_OPT_GETMINSCALEFAC
Word16 scf = Q31;
move16();
test();
......@@ -7287,8 +7301,34 @@ Word16 get_min_scalefactor( Word32 x, Word32 y )
scf = s_min( scf, norm_l( y ) );
}
return scf;
#else
Word16 scf_y;
Word16 scf = Q31;
move16();
test();
if ( x == 0 && y == 0 )
{
scf = 0;
move16();
}
if ( x != 0 )
{
scf = norm_l( x );
}
scf_y = norm_l( y );
if ( y != 0 )
{
scf = s_min( scf_y, scf );
}
return scf;
#endif
}
Flag is_zero_arr( Word32 *arr, Word16 size )
{
FOR( Word16 i = 0; i < size; i++ )
......@@ -7299,3 +7339,14 @@ Flag is_zero_arr( Word32 *arr, Word16 size )
return 1;
}
Flag is_zero_arr16( Word16 *arr, Word16 size )
{
FOR( Word16 i = 0; i < size; i++ )
IF( arr[i] != 0 )
{
return 0;
}
return 1;
}
/******************************************************************************************************
(C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository. All Rights Reserved.
This software is protected by copyright law and by international treaties.
The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
contributors to this repository retain full ownership rights in their respective contributions in
the software. This notice grants no license of any kind, including but not limited to patent
license, nor is any license granted by implication, estoppel or otherwise.
Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
contributions.
This software is provided "AS IS", without any express or implied warranties. The software is in the
development stage. It is intended exclusively for experts who have experience with such software and
solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
and fitness for a particular purpose are hereby disclaimed and excluded.
Any dispute, controversy or claim arising under or in relation to providing this software shall be
submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
/*====================================================================================
EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
====================================================================================*/
#include <stdint.h>
#include "options.h"
#include "rom_com.h"
#include "prot.h"
#include <assert.h>
#include "wmc_auto.h"
#ifndef IVAS_FLOAT_FIXED
/*--------------------------------------------------------------------------
* subband_gain_bits()
*
* HQ core encoder
*--------------------------------------------------------------------------*/
static void subband_gain_bits(
const int16_t *Rk, /* i : bit allocation per band (Q3)*/
const int16_t N, /* i : number of bands */
int16_t *bits, /* o : gain bits per band */
const int16_t *sfmsize /* i : Size of bands */
)
{
int16_t i, b, tot;
int16_t bps;
tot = 0;
for ( i = 0; i < N; i++ )
{
bps = ( Rk[i] * fg_inv_tbl_fx[sfmsize[i] >> 3] ) >> 18;
if ( ( ( sfmsize[i] * ( bps + 1 ) ) << 3 ) - Rk[i] == 0 )
{ /* correct approx. division result, to obtain exact integer division output */
bps++;
}
bps = min( 7, bps );
b = fine_gain_bits[bps];
bits[i] = b;
tot += b;
}
if ( tot == 0 )
{
/* If no gain bits were assigned, use one bit anyway for potential PVQ overage */
bits[0] = 1;
}
return;
}
/*--------------------------------------------------------------------------*
* assign_gain_bits()
*
* Assign gain adjustment bits and update bit budget
*--------------------------------------------------------------------------*/
/*! r: Number of assigned gain bits */
int16_t assign_gain_bits(
const int16_t core, /* i : HQ core */
const int16_t BANDS, /* i : Number of bands */
const int16_t *band_width, /* i : Sub band bandwidth */
int16_t *Rk, /* i/o: Bit allocation/Adjusted bit alloc. (Q3) */
int16_t *gain_bits_array, /* o : Assigned gain bits */
int16_t *Rcalc /* o : Bit budget for shape quantizer (Q3) */
)
{
int16_t gain_bits_tot;
int16_t i;
/* Allocate gain bits for every subband used, based on bitrate and bandwidth */
if ( core == HQ_CORE )
{
subband_gain_bits( Rk, BANDS, gain_bits_array, band_width );
}
else
{
set_s( gain_bits_array, 0, BANDS );
}
/* Re-adjust bit budget for gain quantization */
gain_bits_tot = 0;
*Rcalc = 0;
for ( i = 0; i < BANDS; i++ )
{
if ( Rk[i] > 0 )
{
Rk[i] -= gain_bits_array[i] * 8;
gain_bits_tot += gain_bits_array[i];
*Rcalc += Rk[i];
}
}
return gain_bits_tot;
}
#endif