Commit 7310e1c5 authored by vaclav's avatar vaclav
Browse files

Merge branch 'main' into 133-bitrate-switching-in-core-coder

parents 951ab347 bf3291e9
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ scripts/ref/
scripts/test/
scripts/out/
scripts/self_test_summary.txt
tests/dut
tests/ref

# Python files that pop up when running scripts
__pycache__/
+57 −72
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@ variables:
  OUT_FORMATS_CHANNEL_BASED: "stereo mono 5_1 5_1_2 5_1_4 7_1 7_1_4"
  OUT_FORMATS_SCENE_BASED: "FOA HOA2 HOA3"
  OUT_FORMATS_BINAURAL: "BINAURAL BINAURAL_ROOM"
  EXIT_CODE_NON_BE: 123
  EXIT_CODE_FAIL: 1


# This sets when pipelines are created. Jobs have more specific rules to restrict them.
@@ -253,7 +255,7 @@ asan-on-merge-request-linux:


# compare bit exactness between target and source branch
self-test-on-merge-request:
pytest-on-merge-request:
  extends: 
    - .test-job-linux
    - .rules-merge-request
@@ -295,54 +297,51 @@ self-test-on-merge-request:
    - mv IVAS_dec ../IVAS_dec_ref
    - cd ..

    ### re-checkout the commit from the source branch to have up-to-date self_test.py and scripts/testv (and actually everything)
    ### 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

    ### run selftest
    - ls -altr scripts/testv
    - python3 ./scripts/self_test.py --encref IVAS_cod_ref --decref IVAS_dec_ref --enctest IVAS_cod_test --dectest IVAS_dec_test | tee test_output.txt
    - python3 ./scripts/self_test.py --encref IVAS_cod_ref --decref IVAS_dec_ref --enctest IVAS_cod_test --dectest IVAS_dec_test scripts/config/self_test_evs.prm | tee test_output_evs.txt
    ### analyse test output

    # 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
    - run_errors=$(cat test_output.txt test_output_evs.txt | grep -c "test conditions had run errors") || true
    - bitexact=$(cat test_output.txt | grep -c "All [0-9]* tests are bitexact") || true
    - bitexact_evs=$(cat test_output_evs.txt | grep -c "All [0-9]* tests are bitexact") || true
    - EXIT_CODE_NON_BE=123
    - EXIT_CODE_FAIL=1
    - expected_nonbe_1=0
    - expected_nonbe_2=0
    - expected_nonbe_3=0
    - fail_1=0
    - fail_2=0
    - fail_3=0

    # check for crashes during the test, if any happened, fail the test
    - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py"; fail_1=1; 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 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

    # check for non bitexact output and store exit code to also always run the SBA pytest
    - if [ $bitexact == 0 ] && [ $non_be_flag == 0 ] ; then echo "Non-bitexact cases without non-BE tag encountered"; fail_1=1; fi
    - if [ $bitexact == 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; expected_nonbe_1=1; fi
    - if [ $zero_errors != 1 ]; then echo "Run errors in pytest"; fail_1=1; fi

    # check for non bitexact EVS output
    - if [ $bitexact_evs == 0 ] && [ $evs_non_be_flag == 0 ] ; then echo "Non-bitexact EVS cases without EVS-non-BE tag encountered"; fail_2=1; fi
    - if [ $bitexact_evs == 0 ] && [ $evs_non_be_flag != 0 ] ; then echo "Non-bitexact EVS cases with EVS-non-BE tag encountered"; expected_nonbe_2=1; fi
    - 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

    ### run SBA pytest
    ### run pytest for EVS cases
    - exit_code=0
    - python3 ./scripts/ivas_pytests/self_test_b.py --encref IVAS_cod_ref --decref IVAS_dec_ref --encdut IVAS_cod_test --decdut IVAS_dec_test || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
    - 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 SBA pytest"; fail_3=1; fi
    - if [ $zero_errors != 1 ]; then echo "Run errors in pytest for EVS"; fail_2=1; fi

    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures without non-BE tag encountered"; fail_3=1; fi
    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 1 ]; then echo "pytest run had failures with non-BE tag encountered"; expected_nonbe_3=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 all three tests
    - if [ $fail_1 -eq 1 ] || [ $fail_2 -eq 1 ] || [ $fail_3 -eq 1 ]; then exit $EXIT_CODE_FAIL; fi
    - if [ $expected_nonbe_1 -eq 1 ] || [ $expected_nonbe_2 -eq 1 ] || [ $expected_nonbe_3 -eq 1 ]; then exit $EXIT_CODE_NON_BE; 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

  allow_failure:
@@ -352,14 +351,13 @@ self-test-on-merge-request:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    when: always
    paths:
      - test_output.txt
      - test_output_evs.txt
      - scripts/test/logs/
      - scripts/ref/logs/
      - report-junit.xml
    expose_as: 'Self test results'
      - report-junit-evs.xml
    expose_as: 'pytest results'
    reports:
      junit: report-junit.xml
      junit:
        - report-junit.xml
        - report-junit-evs.xml


# ---------------------------------------------------------------
@@ -436,37 +434,26 @@ codec-comparison-on-main-push:
    ### re-checkout the latest commit in the main branch
    - git checkout $latest_commit

    ### run selftest
    - ls -altr scripts/testv
    - python3 ./scripts/self_test.py --encref IVAS_cod_ref --decref IVAS_dec_ref --enctest IVAS_cod_test --dectest IVAS_dec_test | tee test_output.txt

    ### analyse test output

    # some helper variables - "|| true" to prevent failures from grep not finding anything
    # helper variable - "|| true" to prevent failures from grep not finding anything
    - non_be_flag=$(echo $CI_MERGE_REQUEST_TITLE | grep -c --ignore-case "\[non[ -]*be\]") || true
    - run_errors=$(cat test_output.txt | grep -c "test conditions had run errors") || true
    - bitexact=$(cat test_output.txt | grep -c "All [0-9]* tests are bitexact") || true
    - EXIT_CODE_NON_BE=123
    - EXIT_CODE_FAIL=1

    - selftest_exit_code=0

    # check for crashes during the test, if any happened, fail the test
    - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py"; exit $EXIT_CODE_FAIL; fi

    # check for non bitexact output and store exit code to also always run the SBA pytest
    - if [ $bitexact == 0 ] && [ $non_be_flag == 0 ] ; then echo "Non-bitexact cases without non-BE tag encountered"; selftest_exit_code=$EXIT_CODE_FAIL; fi
    - if [ $bitexact == 0 ] && [ $non_be_flag != 0 ]; then echo "Non-bitexact cases with non-BE tag encountered"; selftest_exit_code=$EXIT_CODE_NON_BE; fi

    ### run SBA pytest
    ### 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

    ### run pytest
    - exit_code=0
    - python3 ./scripts/ivas_pytests/self_test_b.py --encref IVAS_cod_ref --decref IVAS_dec_ref --encdut IVAS_cod_test --decdut IVAS_dec_test || exit_code=$?
    - python3 -m pytest tests -v --junit-xml=report-junit.xml || exit_code=$?
    - if [ $exit_code -eq 1 ] && [ $non_be_flag == 0 ]; then echo "pytest run had failures and non-BE flag not present"; exit $EXIT_CODE_FAIL; fi
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true
    - if [ $exit_code -eq 1 ] && [ $zero_errors == 1 ]; then echo "pytest run had failures, but no errors and non-BE flag present"; exit $EXIT_CODE_NON_BE; fi
    - if [ $exit_code -ne 0 ]; then echo "pytest run had errors"; exit $EXIT_CODE_FAIL; fi;
    # return exit code from selftest if everything went well with the pytest run
    - exit $selftest_exit_code
  allow_failure:
    exit_codes:
      - 123
@@ -474,9 +461,6 @@ codec-comparison-on-main-push:
    name: "main-push--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    when: always
    paths:
      - test_output.txt
      - scripts/test/logs/
      - scripts/ref/logs/
      - report-junit.xml
    expose_as: 'Results of comparison to previous merge commit'
    reports:
@@ -645,9 +629,10 @@ coverage-test-on-main-scheduled:
  script:
    - *print-common-info
    - make GCOV=1 -j
    - ./scripts/self_test.py --create -t 1
    - ./scripts/self_test.py --create -t 1 scripts/config/self_test_evs.prm
    - ./scripts/ivas_pytests/self_test_b.py --create_only --numprocesses 1 --encref IVAS_cod --decref IVAS_dec --encdut IVAS_cod --decdut IVAS_dec
    - python3 tests/create_short_testvectors.py
    - python3 -m pytest tests -v -n 0 --update_ref 1 -m create_ref --ref_encoder_path IVAS_cod --ref_decoder_path IVAS_dec
    - python3 -m pytest tests -v -n 0 --update_ref 1 -m create_ref_part2 --ref_encoder_path IVAS_cod --ref_decoder_path IVAS_dec
    - python3 -m pytest tests/test_param_file.py -v -n 0 --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm --ref_encoder_path IVAS_cod --ref_decoder_path IVAS_dec
    - lcov -c -d obj -o coverage.info
    - genhtml coverage.info -o coverage
  artifacts:
+4 −1
Original line number Diff line number Diff line
@@ -1981,7 +1981,6 @@ ivas_error preview_indices(
        }
        else if ( st_ivas->ivas_format == SBA_FORMAT )
        {

            /* Read SBA planar flag and SBA order */
            st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA] == 1 );
            st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 );
@@ -1989,7 +1988,11 @@ ivas_error preview_indices(

            st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order );

#ifdef HARMONIZE_SBA_NCHAN_TRANSPORT
            ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
#else
            ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ), st_ivas->sba_mode );
#endif
        }
    }

+20 −2
Original line number Diff line number Diff line
@@ -165,7 +165,9 @@ typedef enum
#define HEAD_ROTATION_HOA_ORDER                 3                           /* HOA 3rd order */
#define MAX_CICP_CHANNELS                       16                          /* max channels for loudspeaker layouts (16 for custom layouts)*/
#define MAX_OUTPUT_CHANNELS                     16                          /* Maximum number of output channels (HOA 3rd order) */
#ifndef FIX_CREND_CHANNELS
#define IVAS_MAX_NUM_CH                         16                          /* == MAX_OUTPUT_CHANNELS */
#endif

#define FOA_CHANNELS                            4                           /* number of FOA channels */

@@ -805,16 +807,25 @@ enum fea_names
#define MAX_MDCT_ITD_BRATE                      IVAS_64k

#define SNS_LOW_BR_MODE                         -1
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
#ifdef MDCT_STEREO_PLC_FADE_2_BG_NOISE
#define SNS_NPTS                                16 /* Number of downsampled SNS parameters */

#define MDCT_ST_PLC_FADEOUT_START_FRAME         3
#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG       0.001f
#ifdef FADE_TO_ZERO_FOR_TOO_LONG_FRAMELOSS
#define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME      2 * FRAMES_PER_SEC
#define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN         20
#endif

typedef enum {
    EQUAL_CORES,
    TCX10_IN_0_TCX20_IN_1,
    TCX20_IN_0_TCX10_IN_1,
} TONALMDCTCONC_NOISE_GEN_MODE;

typedef enum {
    ON_FIRST_LOST_FRAME,
    ON_FIRST_GOOD_FRAME,
} TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE;
#endif


@@ -858,8 +869,15 @@ typedef enum
 * DirAC Constants 
 *----------------------------------------------------------------------------------*/

#ifdef FIX_DIRAC_CHANNELS
#define DIRAC_MAX_ANA_CHANS                     FOA_CHANNELS                /* Maximum number of channels for DirAC analysis */
#else
#define DIRAC_MAX_ANA_CHANS                     4                           /* Maximum number of channels for DirAC analysis */
#endif

#ifndef HARMONIZE_SBA_NCHAN_TRANSPORT
#define DIRAC_MAX_TRANS_CHANS                   8                           /* Maximum number of transport channels for DirAC */
#endif

#define DIRAC_MIN_BITRATE_8_TRANS_CHAN          IVAS_384k
#define DIRAC_MIN_BITRATE_6_TRANS_CHAN          IVAS_256k
+23 −5
Original line number Diff line number Diff line
@@ -60,7 +60,11 @@ ivas_error ivas_dirac_config(
)
{
    IVAS_FORMAT ivas_format;
#ifdef HARMONIZE_SBA_NCHAN_TRANSPORT
    int16_t sba_order;
#else
    int16_t sba_order, sba_planar;
#endif
    int16_t *nSCE, *nCPE, *element_mode, *nchan_transport;
    int32_t ivas_total_brate;
    DIRAC_CONFIG_DATA_HANDLE hConfig;
@@ -83,7 +87,9 @@ ivas_error ivas_dirac_config(
        element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init;
        nchan_transport = &( (Encoder_Struct *) st_ivas )->nchan_transport;
        sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order;
#ifndef HARMONIZE_SBA_NCHAN_TRANSPORT
        sba_planar = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->sba_planar;
#endif
        ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate;
        Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs;
        band_grouping = ( (Encoder_Struct *) st_ivas )->hDirAC->band_grouping;
@@ -108,7 +114,9 @@ ivas_error ivas_dirac_config(
        element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init;
        nchan_transport = &( (Decoder_Struct *) st_ivas )->nchan_transport;
        sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order;
#ifndef HARMONIZE_SBA_NCHAN_TRANSPORT
        sba_planar = ( (Decoder_Struct *) st_ivas )->sba_planar;
#endif
        ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate;
        Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs;
        band_grouping = ( (Decoder_Struct *) st_ivas )->hDirAC->band_grouping;
@@ -142,8 +150,12 @@ ivas_error ivas_dirac_config(

    if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */
    {
#ifdef HARMONIZE_SBA_NCHAN_TRANSPORT
        if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
#else
        if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_planar,
                                              sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
#endif
        {
            return error;
        }
@@ -307,7 +319,9 @@ ivas_error ivas_dirac_sba_config(
    int16_t *element_mode,            /* i/o: element mode of the core coder                       */
    int32_t sba_total_brate,          /* i  : SBA total bitrate                                    */
    const int16_t sba_order,          /* i  : Ambisonic (SBA) order                                */
#ifndef HARMONIZE_SBA_NCHAN_TRANSPORT
    const int16_t sba_planar, /* i  : SBA planar flag                                      */
#endif
    const SBA_MODE sba_mode, /* i  : SBA mode                                             */
    const int16_t nbands     /* i  : number of frequency bands                            */
)
@@ -430,7 +444,11 @@ ivas_error ivas_dirac_sba_config(
    if ( sba_total_brate > IVAS_SID_4k4 )
#endif
    {
#ifdef HARMONIZE_SBA_NCHAN_TRANSPORT
        *nchan_transport = ivas_get_sba_num_TCs( sba_total_brate, sba_order );
#else
        *nchan_transport = ivas_dirac_getNumTransportChannels( sba_total_brate, sba_order, sba_planar );
#endif
    }
#ifdef ALIGN_SID_SIZE
    else if ( sba_total_brate == IVAS_SID_5k2 )
@@ -575,7 +593,7 @@ ivas_error ivas_dirac_sba_config(
    return error;
}


#ifndef HARMONIZE_SBA_NCHAN_TRANSPORT
/*-------------------------------------------------------------------------
 * ivas_dirac_getNumTransportChannels()
 *
@@ -647,7 +665,7 @@ int16_t ivas_dirac_getNumTransportChannels(

    return num_channels;
}

#endif

/*-------------------------------------------------------------------------
 * computeDirectionVectors()
Loading