Commit 19a49d6d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch...

Merge branch '1066-ivas-float-update-enhance-the-mode-enforcement-functionality-force-to-include-support-for-read-write-operations' into 'ivas-float-update'

Resolve "Enhance the mode enforcement functionality (-force) to include support for read/write operations."

See merge request !868
parents 7af0b15d 1bb1d49f
Loading
Loading
Loading
Loading

.gitignore

0 → 100644
+5 −0
Original line number Diff line number Diff line
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/enf
+117 −1
Original line number Diff line number Diff line
@@ -43,6 +43,19 @@
#endif
#include "wmc_auto.h"

#ifdef DEBUG_FORCE_DIR
/* Windows does not define the S_ISREG and S_ISDIR macros in stat.h, so we do.
   We have to define _CRT_INTERNAL_NONSTDC_NAMES 1 before #including sys/stat.h
   in order for Microsoft's stat.h to define names like S_IFMT, S_IFREG, and S_IFDIR,
   rather than just defining  _S_IFMT, _S_IFREG, and _S_IFDIR as it normally does. */
#include <sys/stat.h>
#if !defined( S_ISREG ) && defined( S_IFMT ) && defined( S_IFREG )
#define S_ISREG( m ) ( ( (m) &S_IFMT ) == S_IFREG )
#endif
#if !defined( S_ISDIR ) && defined( S_IFMT ) && defined( S_IFDIR )
#define S_ISDIR( m ) ( ( (m) &S_IFMT ) == S_IFDIR )
#endif
#endif

#define WMC_TOOL_SKIP

@@ -134,6 +147,9 @@ typedef struct
#ifdef DEBUGGING
    IVAS_ENC_FORCED_MODE forcedMode;
    const char *forcedModeFile;
#ifdef DEBUG_FORCE_DIR
    const char *forcedModeDir;
#endif
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    IVAS_ENC_AGC agc;
#endif
@@ -719,7 +735,12 @@ int main(
        /* Force mode not set when configuring, set in first frame even if not reading from file */
        if ( f_forcedModeProfile || frame == 0 )
        {
            if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_ENC_SetForcedMode( hIvasEnc, forcedMode
#ifdef DEBUG_FORCE_DIR
                                                   ,
                                                   arg.forcedModeDir
#endif
                                                   ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_ENC_SetForcedMode failed: %s\n\n", IVAS_ENC_GetErrorMessage( error ) );
                goto cleanup;
@@ -908,6 +929,9 @@ static void initArgStruct( EncArguments *arg )
#ifdef DEBUGGING
    arg->forcedMode = IVAS_ENC_FORCE_UNFORCED;
    arg->forcedModeFile = NULL;
#ifdef DEBUG_FORCE_DIR
    arg->forcedModeDir = NULL;
#endif
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
    arg->agc = IVAS_ENC_AGC_UNDEFINED;
#endif
@@ -1058,6 +1082,28 @@ static bool parseCmdlIVAS_enc(

            arg->forcedMode = parseForcedMode( stmp );

#ifdef DEBUG_FORCE_DIR
            if ( arg->forcedMode < IVAS_ENC_FORCE_FILE )
            {
                fprintf( stdout, "Forcing codec to:       %s\n", argv[i + 1] );
            }
            else if ( arg->forcedMode == IVAS_ENC_FORCE_FILE )
            {
                arg->forcedModeFile = argv[i + 1];
                fprintf( stdout, "Force switching file:   %s\n", argv[i + 1] );
            }
            else if ( arg->forcedMode == IVAS_ENC_FORCE_DIR )
            {
                arg->forcedModeDir = argv[i + 1];
                fprintf( stdout, "Forcing switching directory:       %s\n", argv[i + 1] );
            }
            else
            {
                fprintf( stderr, "\nError: The force switching profile file/dir %s does not exist or could not be opened!\n\n", argv[i + 1] );
                usage_enc();
                return false;
            }
#else
            if ( arg->forcedMode == IVAS_ENC_FORCE_UNDEFINED )
            {
                arg->forcedModeFile = argv[i + 1];
@@ -1084,6 +1130,7 @@ static bool parseCmdlIVAS_enc(
                fprintf( stdout, "Forcing codec to:       %s\n", argv[i + 1] );
#endif
            }
#endif

            i += 2;
        }
@@ -1923,6 +1970,9 @@ static void usage_enc( void )
#ifdef DEBUGGING
    fprintf( stdout, "-force T            : Force specific mode, T = (speech, music, ACELP, GSC, TCX, HQ),\n" );
    fprintf( stdout, "                      alternatively, T can be a text file where each line contains \"nb_frames T\"\n" );
#ifdef DEBUG_FORCE_DIR
    fprintf( stdout, "                      or T can be a directory containing external binary files for modes/parameters enforcement\n" );
#endif
#ifdef DEBUG_SBA
    fprintf( stdout, "-tag                : Tag name for intermediate debug files\n" );
#endif
@@ -2040,8 +2090,73 @@ static bool readBitrate(
static IVAS_ENC_FORCED_MODE parseForcedMode(
    char *forcedModeChar )
{
#ifdef DEBUG_FORCE_DIR
    struct stat path_stat;
#endif

    to_upper( forcedModeChar );

#ifdef DEBUG_FORCE_DIR
    if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) ||
         ( strcmp( forcedModeChar, "0" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_SPEECH;
    }
    else if ( ( strcmp( forcedModeChar, "MUSIC" ) == 0 ) || ( strcmp( forcedModeChar, "'MUSIC'" ) == 0 ) || ( strcmp( forcedModeChar, "AUDIO" ) == 0 ) || ( strcmp( forcedModeChar, "'AUDIO'" ) == 0 ) || ( strcmp( forcedModeChar, "1" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_MUSIC;
    }
    else if ( ( strcmp( forcedModeChar, "ACELP" ) == 0 ) || ( strcmp( forcedModeChar, "'ACELP'" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_ACELP;
    }
    else if ( ( strcmp( forcedModeChar, "GSC" ) == 0 ) || ( strcmp( forcedModeChar, "'GSC'" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_GSC;
    }
    if ( ( strcmp( forcedModeChar, "TCX" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX'" ) == 0 )
#ifdef SUPPORT_FORCE_TCX10_TCX20
         || ( strcmp( forcedModeChar, "TCX20" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX20'" ) == 0 )
#endif
    )
    {
#ifdef SUPPORT_FORCE_TCX10_TCX20
        return IVAS_ENC_FORCE_TCX20;
#else
        return IVAS_ENC_FORCE_TCX;
#endif
    }
#ifdef SUPPORT_FORCE_TCX10_TCX20
    if ( ( strcmp( forcedModeChar, "TCX10" ) == 0 ) || ( strcmp( forcedModeChar, "'TCX10'" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_TCX10;
    }
#endif
    else if ( ( strcmp( forcedModeChar, "HQ" ) == 0 ) || ( strcmp( forcedModeChar, "'HQ'" ) == 0 ) )
    {
        return IVAS_ENC_FORCE_HQ;
    }
    else
    {
        if ( stat( forcedModeChar, &path_stat ) != 0 )
        {
            return IVAS_ENC_FORCE_UNDEFINED;
        }

        /* check if the argument represents an existing file or directory */
        if ( S_ISDIR( path_stat.st_mode ) )
        {
            /* it's a directory */
            return IVAS_ENC_FORCE_DIR;
        }
        else
        {
            /* it's a file */
            return IVAS_ENC_FORCE_FILE;
        }
    }

#else
    if ( ( strcmp( forcedModeChar, "SPEECH" ) == 0 ) || ( strcmp( forcedModeChar, "'SPEECH'" ) == 0 ) ||
         ( strcmp( forcedModeChar, "0" ) == 0 ) )
    {
@@ -2083,6 +2198,7 @@ static IVAS_ENC_FORCED_MODE parseForcedMode(
    }

    return IVAS_ENC_FORCE_UNDEFINED;
#endif
}


bit

0 → 100644
+400 KiB

File added.

No diff preview for this file type.

bit.enf.basop

0 → 100644
+400 KiB

File added.

No diff preview for this file type.

bit.flt

0 → 100644
+400 KiB

File added.

No diff preview for this file type.

Loading