Commit 665c07a0 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'main' into 101-fd-cng-encoder-handle-initialization

parents f233f1a2 9063e751
Loading
Loading
Loading
Loading
Loading
+99 −63
Original line number Diff line number Diff line
@@ -44,6 +44,49 @@ stages:
.get-previous-merge-commit-sha: &get-previous-merge-commit-sha
  - previous_merge_commit=$(git --no-pager log --merges HEAD~1 -n 1 --pretty=format:%H)

.merge_request_comparison_setup: &merge_request_comparison_setup
  ### build test binaries, initial clean for paranoia reasons
  - make clean
  - mkdir build
  - cd build
  - cmake ..
  - make -j
  - mv IVAS_cod ../IVAS_cod_test
  - mv IVAS_dec ../IVAS_dec_test
  - cd ..
  - rm -rf build/*

  ### store the current commit hash
  - source_branch_commit_sha=$(git rev-parse HEAD)

  ### checkout version to compare against
  # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
  # depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later
  - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME || true
  # needed when depth is lower than the number of commits in the branch
  - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:$CI_MERGE_REQUEST_TARGET_BRANCH_NAME

  ### compare to last target branch commit before pipeline was created
  - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H)
  - git checkout $target_commit

  ### build reference binaries
  - cd build
  - cmake ..
  - make -j
  - mv IVAS_cod ../IVAS_cod_ref
  - mv IVAS_dec ../IVAS_dec_ref
  - cd ..

  # rename test binaries back
  - mv IVAS_cod_test IVAS_cod
  - mv IVAS_dec_test IVAS_dec

.merge-request-comparison-check: &merge-request-comparison-check
    - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi
    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "Non-bitexact cases without non-BE tag encountered!"; exit $EXIT_CODE_FAIL; fi
    - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact  cases with non-BE tag encountered"; exit $EXIT_CODE_NON_BE; fi
    - exit 0

# ---------------------------------------------------------------
# Job templates
@@ -275,7 +318,7 @@ asan-on-merge-request-linux:


# compare bit exactness between target and source branch
pytest-on-merge-request:
ivas-pytest-on-merge-request:
  extends: 
    - .test-job-linux
    - .rules-merge-request
@@ -284,85 +327,76 @@ pytest-on-merge-request:
  timeout: "10 minutes"
  script:
    - *print-common-info
    ### build test binaries, initial clean for paranoia reasons
    - make clean
    - mkdir build
    - cd build
    - cmake ..
    - make -j
    - mv IVAS_cod ../IVAS_cod_test
    - mv IVAS_dec ../IVAS_dec_test
    - cd ..
    - rm -rf build/*

    ### store the current commit hash
    - source_branch_commit_sha=$(git rev-parse HEAD)

    ### checkout version to compare against
    # first delete local target branch to avoid conflicts when branch is cached and there are merge conflicts during fetching
    # depending on chaching, the branch may not be there, so prevent failure of this command -> should maybe be done smarter later
    - git branch -D $CI_MERGE_REQUEST_TARGET_BRANCH_NAME || true
    # needed when depth is lower than the number of commits in the branch
    - git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME:$CI_MERGE_REQUEST_TARGET_BRANCH_NAME

    ### compare to last target branch commit before pipeline was created
    - target_commit=$(git log $CI_MERGE_REQUEST_TARGET_BRANCH_NAME -1 --oneline --before=${CI_PIPELINE_CREATED_AT} --format=%H)
    - git checkout $target_commit

    ### build reference binaries
    - cd build
    - cmake ..
    - make -j
    - mv IVAS_cod ../IVAS_cod_ref
    - mv IVAS_dec ../IVAS_dec_ref
    - cd ..

    ### re-checkout the commit from the source branch to have up-to-date test scripts and test vectors (and actually everything)
    - git checkout $source_branch_commit_sha
    - *merge_request_comparison_setup

    # some helper variables - "|| true" to prevent failures from grep not finding anything
    - evs_non_be_flag=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[evs[ -]*non[ -]*be\]") || true
    - non_be_flag=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[non[ -]*be\]") || true
    - expected_nonbe_1=0
    - expected_nonbe_2=0
    - fail_1=0
    - fail_2=0
    - ref_using_main=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[ref[ -]*using[ -]*main\]") || true

    ### If ref_using_main is not set, checkoug the source branch to use scripts and input from there
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi

    ### prepare pytest
    # create short test vectors
    - python3 tests/create_short_testvectors.py
    # rename test binaries back
    - mv IVAS_cod_test IVAS_cod
    - mv IVAS_dec_test IVAS_dec
    # create references
    - python3 -m pytest tests -v --update_ref 1 -m create_ref
    - python3 -m pytest tests -v --update_ref 1 -m create_ref_part2
    - python3 -m pytest tests/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm

    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    ### run pytest
    - exit_code=0
    - python3 -m pytest tests -v --junit-xml=report-junit.xml || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - if [ $zero_errors != 1 ]; then echo "Run errors in pytest"; fail_1=1; fi
    - *merge-request-comparison-check

  allow_failure:
    exit_codes:
      - 123
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    when: always
    paths:
      - report-junit.xml
    expose_as: 'pytest ivas results'
    reports:
      junit:
        - report-junit.xml

evs-pytest-on-merge-request:
  extends: 
    - .test-job-linux
    - .rules-merge-request
  stage: compare
  needs: [ "build-codec-linux-cmake", "codec-smoke-test" ]
  timeout: "10 minutes"
  script:
    - *print-common-info
    - *merge_request_comparison_setup
    
    # some helper variables - "|| true" to prevent failures from grep not finding anything
    - non_be_flag=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[evs[ -]*non[ -]*be\]") || true
    - ref_using_main=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[ref[ -]*using[ -]*main\]") || true

    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures without non-BE tag encountered"; fail_1=1; fi
    - if [ $exit_code -eq 1 ] && [ $non_be_flag != 0 ]; then echo "pytest run had failures with non-BE tag encountered"; expected_nonbe_1=1; fi
    ### If ref_using_main is not set, checkoug the source branch to use scripts and input from there
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi

    ### prepare pytest
    # create references
    - python3 -m pytest tests/test_param_file.py -v --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm

    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    ### run pytest for EVS cases
    - exit_code=0
    - python3 -m pytest tests/test_param_file.py -v --param_file scripts/config/self_test_evs.prm --junit-xml=report-junit-evs.xml || exit_code=$?
    - zero_errors=$(cat report-junit-evs.xml | grep -c 'errors="0"') || true

    - if [ $zero_errors != 1 ]; then echo "Run errors in pytest for EVS"; fail_2=1; fi

    - if [ $exit_code -eq 1 ] && [ $evs_non_be_flag == 0 ]; then echo "Non-bitexact EVS cases without EVS-non-BE tag encountered"; fail_2=1; fi
    - if [ $exit_code -eq 1 ] && [ $evs_non_be_flag != 0 ]; then echo "Non-bitexact EVS cases with EVS-non-BE tag encountered"; expected_nonbe_2=1; fi

    # Check results from both tests
    - if [ $fail_1 -eq 1 ] || [ $fail_2 -eq 1 ]; then exit $EXIT_CODE_FAIL; fi
    - if [ $expected_nonbe_1 -eq 1 ] || [ $expected_nonbe_2 -eq 1 ]; then exit $EXIT_CODE_NON_BE; fi
    - exit 0
    - *merge-request-comparison-check

  allow_failure:
    exit_codes:
@@ -371,12 +405,10 @@ pytest-on-merge-request:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    when: always
    paths:
      - report-junit.xml
      - report-junit-evs.xml
    expose_as: 'pytest results'
    expose_as: 'pytest evs results'
    reports:
      junit:
        - report-junit.xml
        - report-junit-evs.xml


@@ -451,11 +483,12 @@ codec-comparison-on-main-push:
    - mv IVAS_dec ../IVAS_dec_ref
    - cd ..

    ### re-checkout the latest commit in the main branch
    - git checkout $latest_commit

    # helper variable - "|| true" to prevent failures from grep not finding anything
    - non_be_flag=$(echo $CI_COMMIT_MESSAGE | grep -c --ignore-case "\[non[ -]*be\]") || true
    - ref_using_main=$(echo $CI_COMMIT_MESSAGE | grep -c --ignore-case "\[ref[ -]*using[ -]*main\]") || true

    ### re-checkout the latest commit in the main branch, if ref_using_main is not set
    - if [ $ref_using_main == 0 ]; then git checkout $latest_commit;fi

    ### prepare pytest
    # create short test vectors
@@ -467,6 +500,9 @@ codec-comparison-on-main-push:
    - python3 -m pytest tests -v --update_ref 1 -m create_ref
    - python3 -m pytest tests -v --update_ref 1 -m create_ref_part2

    ### re-checkout the latest commit here, if ref_using_main is set
    - if [ $ref_using_main -eq 1 ]; then git checkout $latest_commit;fi

    ### run pytest
    - exit_code=0
    - python3 -m pytest tests -v --junit-xml=report-junit.xml || exit_code=$?
+44 −3
Original line number Diff line number Diff line
@@ -120,7 +120,13 @@ typedef struct
    const char *ca_config_file;
    bool mimeOutput;

#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    IVAS_ENC_AGC agc;
#else
    bool agc;
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */
    bool pca;
#ifdef DEBUG_FOA_AGC
    FILE *agcBitstream; /* temporary */
@@ -440,11 +446,25 @@ int main(
            }
            break;
        case IVAS_ENC_INPUT_SBA:
            if ( ( error =
                       IVAS_ENC_ConfigureForAmbisonics(
                           hIvasEnc,
                           arg.inputFs,
                           totalBitrate,
                           arg.max_bwidth_user,
                           bandwidth,
                           arg.dtxConfig,
                           arg.inputFormatConfig.sba.order,
                           arg.inputFormatConfig.sba.isPlanar,
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
                           arg.agc,
#endif
                           arg.pca
#ifdef DEBUG_SBA_AUDIO_DUMP
            if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, arg.agc, arg.pca, &numTransportChannels ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_ENC_ConfigureForAmbisonics( hIvasEnc, arg.inputFs, totalBitrate, arg.max_bwidth_user, bandwidth, arg.dtxConfig, arg.inputFormatConfig.sba.order, arg.inputFormatConfig.sba.isPlanar, arg.agc, arg.pca ) ) != IVAS_ERR_OK )
                           ,
                           &numTransportChannels
#endif
                           ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_ConfigureForAmbisonics failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
@@ -870,7 +890,13 @@ static void initArgStruct( EncArguments *arg )
    arg->ca_config_file = NULL;
    arg->mimeOutput = false;

#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    arg->agc = IVAS_ENC_AGC_UNDEFINED;
#else
    arg->agc = IVAS_DEFAULT_AGC;
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */
    arg->pca = false;
#ifdef DEBUG_FOA_AGC
    arg->agcBitstream = NULL;
@@ -1376,12 +1402,17 @@ static bool parseCmdlIVAS_enc(
            arg->inputFormatConfig.stereoToMonoDownmix = true;
            i++;
        }
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
        else if ( strcmp( argv_to_upper, "-AGC" ) == 0 )
        {
            i++;
            if ( i < argc - 4 )
            {
#ifdef AGC_ENABLE_FOR_LBR
                arg->agc = ( atoi( argv[i] ) ) ? IVAS_ENC_AGC_ENABLED : IVAS_ENC_AGC_DISABLED;
#else
                arg->agc = (int16_t) atoi( argv[i] );
#endif
                if ( argv[i] == NULL || atoi( argv[i] ) < 0 || atoi( argv[i] ) > 1 )
                {
                    fprintf( stderr, "Error: wrong adaptive gain control option specified (%d), expected 0 or 1\n\n", (int32_t) atoi( argv[i] ) );
@@ -1397,6 +1428,7 @@ static bool parseCmdlIVAS_enc(
                return false;
            }
        }
#endif
        else if ( strcmp( argv_to_upper, "-BYPASS" ) == 0 ) // VE: should be renamed to "-pca"
        {
            i++;
@@ -1636,7 +1668,16 @@ static void usage_enc( void )
#ifdef DEBUG_SBA
    fprintf( stdout, "-tag                : Tag name for intermediate debug files\n" );
#endif
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
#ifdef AGC_ENABLE_FOR_LBR
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1).  \n" );
    fprintf( stdout, "                      By default op is 1 (activated) for bitrates between 24400 and 32000,\n" );
    fprintf( stdout, "                      otherwise it is 0 (deactivated) for all other bitrates\n" );
#else
    fprintf( stdout, "-agc op             : SBA Adaptive gain control, op = (0, 1), by default op is 0 or deactivated\n" );
#endif /* AGC_ENABLE_FOR_LBR */
#endif /* DEBUG_AGC_ENCODER_CMD_OPTION */

    fprintf( stdout, "-bypass mode        : SBA PCA by-pass, mode = (1, 2), 1 = PCA off, 2 = signal adaptive, default is 1\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-force T            : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
+5 −2
Original line number Diff line number Diff line
@@ -132,6 +132,9 @@ enum{

#define MAX_V_MULT_MAT                  100             /* maximum array length for the function v_mult_mat() */

#define SBA_AGC_FORCE_ENABLE            1
#define SBA_AGC_FORCE_DISABLE           0
#define SBA_AGC_DEFAULT                 -1

/*----------------------------------------------------------------------------------*
 * Layers
+6 −6
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ int16_t get_codec_mode(
int16_t getTcxonly(
    const int16_t element_mode, /* i  : IVAS element mode                   */
    const int32_t total_brate,  /* i  : total bitrate                       */
    const int16_t is_mct        /* i  : MCT mode flag               */
    const int16_t MCT_flag      /* i  : hMCT handle allocated (1) or not (0)*/
)
{
    int16_t tcxonly = 0;
@@ -187,7 +187,7 @@ int16_t getTcxonly(
            }
            break;
        case IVAS_CPE_MDCT:
            if ( total_brate >= ( is_mct ? IVAS_32k : IVAS_48k ) )
            if ( total_brate >= ( MCT_flag ? IVAS_32k : IVAS_48k ) )
            {
                tcxonly = 1;
            }
@@ -808,7 +808,7 @@ void init_tcx_cfg(
    const int16_t infoIGFStopFreq,
    const int16_t element_mode,
    const int16_t ini_frame,
    const int16_t is_mct,
    const int16_t MCT_flag,
    const MCT_CHAN_MODE mct_chan_mode /* i  : MDCT channel mode     */
)
{
@@ -850,7 +850,7 @@ void init_tcx_cfg(

    if ( hTcxCfg->fIsTNSAllowed )
    {
        InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, is_mct );
        InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );

        SetAllowTnsOnWhite( hTcxCfg->tnsConfig, element_mode == IVAS_CPE_MDCT );
    }
+2 −2
Original line number Diff line number Diff line
@@ -90,10 +90,10 @@ void fill_spectrum(
    const int16_t element_mode         /* i  : element mode                                          */
)
{
    float CodeBook[FREQ_LENGTH];
    float CodeBook[L_SPEC48k_EXT];
    int16_t cb_size = 0;
    int16_t last_sfm;
    float CodeBook_mod[FREQ_LENGTH];
    float CodeBook_mod[L_SPEC48k_EXT];
    float norm_adj[NB_SFM];
    int16_t high_sfm = 23;
    int16_t flag_32K_env_hangover;
Loading