Commit d447f0c5 authored by vaclav's avatar vaclav
Browse files

Merge branch 'main' into 351-hrtf-command-option

parents e9c84dba f0f272f1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ workflow:
    # see https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"
      when: never
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' # Runs for merge requests
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Pushes to main
    - if: $CI_PIPELINE_SOURCE == 'schedule' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Scheduled in main
    - if: $CI_PIPELINE_SOURCE == 'web' # for testing
@@ -130,7 +130,7 @@ stages:
.rules-merge-request:
  extends: .rules-basis
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - 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 == 'push'
      when: never

+0 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "options.h"
#include "lib_dec.h"
#include "cmdl_tools.h"
#include "audio_file_writer.h"
+63 −1
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "options.h"
#include "lib_enc.h"
#include "cmdl_tools.h"
#include "audio_file_reader.h"
@@ -214,6 +213,7 @@ int main(
        goto cleanup;
    }

#ifndef FIX_94_VERIFY_WAV_NUM_CHANNELS
    /*------------------------------------------------------------------------------------------*
     * Open input audio file
     *------------------------------------------------------------------------------------------*/
@@ -229,6 +229,7 @@ int main(
        fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename );
        goto cleanup;
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Open output bitstream file
@@ -451,6 +452,67 @@ int main(
        goto cleanup;
    }

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    /*------------------------------------------------------------------------------------------*
     * Open input audio file
     *------------------------------------------------------------------------------------------*/

    if ( AudioFileReader_open( &audioReader, arg.inputWavFilename ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nCan't open %s\n\n", arg.inputWavFilename );
        goto cleanup;
    }

    /* Validate input sampling rate */
    int32_t inFileSampleRate = 0;
    error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate );
    switch ( error )
    {
        case IVAS_ERR_OK:
            if ( inFileSampleRate != arg.inputFs )
            {
                fprintf( stderr, "\nSampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n\n", arg.inputFs, inFileSampleRate, arg.inputWavFilename );
                goto cleanup;
            }
            break;
        case IVAS_ERR_SAMPLING_RATE_UNKNOWN:
            /* IVAS_ERR_SAMPLING_RATE_UNKNOWN will be returned for raw PCM files.
             * Nothing to check here */
            break;
        default:
            fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) );
            goto cleanup;
    }


    /* Validate number of channels */
    int16_t encInNumChannels = 0;
    if ( ( error = IVAS_ENC_GetNumInChannels( hIvasEnc, &encInNumChannels ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
    }
    int16_t inFileNumChannels = 0;
    error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels );
    switch ( error )
    {
        case IVAS_ERR_OK:
            if ( inFileNumChannels != encInNumChannels )
            {
                fprintf( stderr, "\nNumber of input audio channels mismatch: %d accepted by encoder, but %d found in file %s\n\n", encInNumChannels, inFileNumChannels, arg.inputWavFilename );
                goto cleanup;
            }
            break;
        case IVAS_ERR_NUM_CHANNELS_UNKNOWN:
            /* IVAS_ERR_NUM_CHANNELS_UNKNOWN will be returned for raw PCM files.
             * Nothing to check here */
            break;
        default:
            fprintf( stderr, "\nError: %s\n", ivas_error_to_string( error ) );
            goto cleanup;
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Open input metadata files
     *------------------------------------------------------------------------------------------*/
+45 −4
Original line number Diff line number Diff line
@@ -30,23 +30,20 @@

*******************************************************************************************************/

#include "lib_rend.h"
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "options.h"
#include "audio_file_reader.h"
#include "audio_file_writer.h"
#include "cmdl_tools.h"
#include "cmdln_parser.h"
#include "common_api_types.h"
#include "head_rotation_file_reader.h"
#include "hrtf_file_reader.h"
#include "ism_file_reader.h"
#include "lib_rend.h"
#include "ls_custom_file_reader.h"
#include "masa_file_reader.h"
#include "prot.h"
@@ -568,6 +565,45 @@ int main(
        setupWithSingleFormatInput( args, audioFilePath, positionProvider, masaReaders );
    }

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    if ( AudioFileReader_open( &audioReader, audioFilePath ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "Error opening file: %s\n", audioFilePath );
        exit( -1 );
    }

    int32_t inFileSampleRate = 0;
    error = AudioFileReader_getSamplingRate( audioReader, &inFileSampleRate );
    switch ( error )
    {
        case IVAS_ERR_OK:
            if ( inFileSampleRate != args.sampleRate )
            {
                fprintf( stderr, "Sampling rate mismatch: %d Hz requested, but %d Hz found in file %s\n", args.sampleRate, inFileSampleRate, args.inputFilePath );
                exit( -1 );
            }
            break;
        case IVAS_ERR_SAMPLING_RATE_UNKNOWN: /* Returned when input is raw PCM */
            if ( args.sampleRate == 0 )
            {
                fprintf( stderr, "Sampling rate must be specified on command line when using raw PCM input\n" );
                exit( -1 );
            }
            args.sampleRate = inFileSampleRate;
            break;
        default:
            fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
            exit( -1 );
    }

    int16_t inFileNumChannels = 0;
    error = AudioFileReader_getNumChannels( audioReader, &inFileNumChannels );
    if ( error != IVAS_ERR_OK && error != IVAS_ERR_NUM_CHANNELS_UNKNOWN )
    {
        fprintf( stderr, "Error: %s\n", ivas_error_to_string( error ) );
        exit( -1 );
    }
#else
    int32_t inFileSampleRate = 0;
    if ( AudioFileReader_open( &audioReader, audioFilePath, &inFileSampleRate ) != IVAS_ERR_OK )
    {
@@ -588,6 +624,7 @@ int main(
    {
        args.sampleRate = inFileSampleRate;
    }
#endif
    const int16_t frameSize_smpls = (int16_t) ( 20 * args.sampleRate / 1000 );

    IVAS_REND_InputId mcIds[RENDERER_MAX_MC_INPUTS] = { 0 };
@@ -755,8 +792,12 @@ int main(

    const int16_t totalNumInChannels = getTotalNumInChannels( hIvasRend, mcIds, ismIds, sbaIds, masaIds );

#ifdef FIX_94_VERIFY_WAV_NUM_CHANNELS
    if ( inFileNumChannels != 0 /* inFileNumChannels is 0 with raw PCM input */ && totalNumInChannels != inFileNumChannels )
#else
    if ( AudioFileReader_getNumChannels( audioReader ) != 0 /* If input file is raw PCM, audio reader has no info about number of channels */
         && totalNumInChannels != AudioFileReader_getNumChannels( audioReader ) )
#endif
    {
        fprintf( stderr, "Number of channels in input file does not match selected configuration\n" );
        exit( -1 );
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include "options.h"
#include <stdint.h>
#include <stdio.h>
#include "ivas_error.h"

/*----------------------------------------------------------------------------------*
 * Common API constants
Loading