Commit d527fa6e authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Implement most of signal processing parts of float MR 1505

parent 5748d3c2
Loading
Loading
Loading
Loading
Loading
+115 −0
Original line number Diff line number Diff line
@@ -51,6 +51,11 @@
#include "wmc_auto.h"
#include "options.h"
#include "stl.h"
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_EXAMPLE
#include <math.h>
#endif
#endif


#define WMC_TOOL_SKIP
@@ -135,6 +140,9 @@ typedef struct
    AcousticEnvironmentSequence aeSequence;
    bool dpidEnabled;
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
#ifdef OBJ_EDITING_EXAMPLE
    bool objEditEnabled;
#endif

} DecArguments;

@@ -1008,6 +1016,9 @@ static bool parseCmdlIVAS_dec(
    {
        arg->directivityPatternId[i] = 65535;
    }
#ifdef OBJ_EDITING_EXAMPLE
    arg->objEditEnabled = false;
#endif

    /*-----------------------------------------------------------------*
     * Initialization
@@ -1459,6 +1470,13 @@ static bool parseCmdlIVAS_dec(

            i += tmp;
        }
#ifdef OBJ_EDITING_EXAMPLE
        else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 )
        {
            arg->objEditEnabled = true;
            i++;
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
@@ -1997,6 +2015,11 @@ static ivas_error decodeG192(
    int16_t isSplitRend, isSplitCoded;
    IVAS_RENDER_CONFIG_DATA renderConfig;
    RenderConfigReader *renderConfigReader = NULL;
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_EXAMPLE
    IVAS_EDITABLE_PARAMETERS editableParameters;
#endif
#endif

    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
@@ -2275,6 +2298,98 @@ static ivas_error decodeG192(

#endif
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_EXAMPLE
                if ( arg.objEditEnabled )
                {

                    /* Do object info editing here */
                    /* get object parameters */
                    if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }

                    /* edit object parameters...*/

                    /* put the objects equally spaced at the horizontal plane */
                    /* and play a little bit with the gains... */
                    // int16_t obj_idx, non_diegetic_obj_idx;
                    // int16_t num_nondiegetic_objects;
                    //
                    // num_nondiegetic_objects = 0;
                    // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                    // {
                    //     if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag )
                    //     {
                    //         num_nondiegetic_objects++;
                    //     }
                    // }
                    // if ( num_nondiegetic_objects )
                    // {
                    //     float start_angle, angle_inc;
                    //     angle_inc = 360.0f / (float) num_nondiegetic_objects;
                    //     start_angle = angle_inc / 2.0f;
                    //     for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                    //     {
                    //         if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag )
                    //         {
                    //             editableParameters.ism_metadata[obj_idx].elevation = 0.0f;
                    //             editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc;
                    //             non_diegetic_obj_idx++;
                    //         }
                    //     }
                    // }
                    //
                    // /* breakover object gains */
                    // for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                    // {
                    //     editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f;
                    // }
                    //
                    // editableParameters.gain_bed = 0.5f;

                    // TODO: Cleanup with proper example
                    int Q_dir = 22;
                    float azi1 = 90.2f;
                    float azi2 = -104.6f;
                    float azi3 = 44.6f;
                    float azi4 = -150.1f;

                    editableParameters.ism_metadata[0].azimuth_fx = (Word32) azi1 * pow( 2, Q_dir );
                    editableParameters.ism_metadata[0].elevation_fx = 0;

                    editableParameters.ism_metadata[1].azimuth_fx = (Word32) azi2 * pow( 2, Q_dir );
                    editableParameters.ism_metadata[1].elevation_fx = 0;

                    editableParameters.ism_metadata[2].azimuth_fx = (Word32) azi3 * pow( 2, Q_dir );
                    editableParameters.ism_metadata[2].elevation_fx = 0;

                    editableParameters.ism_metadata[3].azimuth_fx = (Word32) azi4 * pow( 2, Q_dir );
                    editableParameters.ism_metadata[3].elevation_fx = 0;


                    int Q_gain = 12;
                    float g1 = 1.3f;
                    float g2 = 0.78f;
                    float g3 = 2.1f;
                    float g4 = 0.57f;
                    float gMasa = 2.0f;

                    editableParameters.ism_metadata[0].gain_fx = (Word32) (g1 * pow(2,Q_gain));
                    editableParameters.ism_metadata[1].gain_fx = (Word32) (g2 * pow(2,Q_gain));
                    editableParameters.ism_metadata[2].gain_fx = (Word32) (g3 * pow(2,Q_gain));
                    editableParameters.ism_metadata[3].gain_fx = (Word32) (g4 * pow(2,Q_gain));
                    editableParameters.gain_bed_fx = (Word32) (gMasa * pow(2,Q_gain));

                    /* set new object parameters*/
                    if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
                }
#endif
                /* Do the final preparations needed for rendering */
                if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK )
                {
+1 −1
Original line number Diff line number Diff line
@@ -126,7 +126,7 @@ typedef struct _IVAS_ISM_METADATA
    Word32 elevation_fx;  /* Q22 */
    Word16 radius_fx;     /* Q9 */
    Word32 spread_fx;     /* Q22 */
    Word32 gainFactor_fx; /* Q31 */
    Word32 gainFactor_fx; /* Q31 */     // TODO: Gain factor can't be Q31, due to the gain editing
    Word32 yaw_fx;        /* Q22 */
    Word32 pitch_fx;      /* Q22 */
    float azimuth;
+3 −4
Original line number Diff line number Diff line
@@ -1328,14 +1328,13 @@ enum
#define OMASA_TDREND_MATCHING_GAIN_FX 26026
//TODO: insert proper Q representations
#ifdef OMASA_OBJECT_EDITING
#define OMASA_GAIN_EDIT_THR_FX                     0                        /* OMASA gain change threshold */
#define OMASA_AZI_EDIT_THR_FX                      1                        /* OMASA-DISC azimuth change threshold */
#define OMASA_ELE_EDIT_THR_FX                      2                        /* OMASA-DISC elevation change threshold */
#define OMASA_GAIN_EDIT_THR_FX                  246                         /* OMASA gain change threshold, 0.06f in Q12 */
#define OMASA_AZI_EDIT_THR_FX                   ONE_IN_Q22                  /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */
#define OMASA_ELE_EDIT_THR_FX                   ONE_IN_Q23                  /* OMASA-DISC elevation change threshold, 2.0f in Q22 */
#endif

#define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30       (1453366656l)


#define MASA_JBM_RINGBUFFER_FRAMES              3
#define TOLERANCE_360_Q22                       1510033326  /* 360 in Q22 + 0.02 in Q22*/
#define MINUS_TOLERANCE_360_Q22                 -1510033326 /* - (360 in Q22 + 0.02 in Q22) */
+3 −0
Original line number Diff line number Diff line
@@ -294,6 +294,9 @@ extern const Word32 diffuseness_thresholds_hr_fx[HR_MASA_ER_LEVELS + 1];
extern const Word32 no_phi_masa_inv_fx[NO_SPHERICAL_GRIDS][MAX_NO_THETA];
extern const Word32 azimuth_cb_fx[8];
extern const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2];
#ifdef OBJ_EDIT_BASOP
extern const Word32 delta_theta_masa_inv_fx[NO_SPHERICAL_GRIDS - 2];
#endif
extern const Word16 coherence_cb0_masa_Q14[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH];
extern const Word32 coherence_cb0_masa_fx[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH];
extern const Word16 coherence_cb1_masa_Q15[MASA_NO_CV_COH1 * MASA_MAXIMUM_CODING_SUBBANDS]; /* 25 */
+7 −0
Original line number Diff line number Diff line
@@ -4406,6 +4406,13 @@ const Word32 delta_theta_masa_fx[NO_SPHERICAL_GRIDS - 2] = {
    188743680, 188743680, 150994944, 106954752, 83886080, 62914560, 45214596, 28101836, 20971520
};

#ifdef OBJ_EDIT_BASOP
// Q31
const Word32 delta_theta_masa_inv_fx[NO_SPHERICAL_GRIDS - 2] = {
    47721859, 47721859, 59652324, 84215045, 107374182, 143165577, 199209986, 320519947, 429496730
};
#endif

// q = 14
const Word16 coherence_cb0_masa_Q14[DIRAC_DIFFUSE_LEVELS * 2 * MASA_NO_CV_COH] = {
    783, 4173, 9036, 16163, 22238, 27587, 32234, 0,
Loading