Commit 12f110d5 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Port float MR 1542 to BASOP

parent 86dffae6
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@
#define NONBE_FIX_1063_DIV_BY_ZERO_SUMNRG               /* VoiceAge: issue 1063: division by zero for angle_rot feature in the UNCLR classifier */
#define FIX_1060_USAN_ARRAY_BOUNDS                      /* FhG: issue 1060: USAN array-bounds errors */
#define NONBE_FIX_SBA_SIGNALING_BITS_B                  /* FhG: issue 1061: option B: signal sba order additionally in OSBA */
#define NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR            /* Nok: issue 1074 fixing number of objects signaling in OMASA low rate */

/* #################### End BASOP porting switches ############################ */

+20 −0
Original line number Diff line number Diff line
@@ -390,6 +390,25 @@ ivas_error ivas_dec_setup(
            /* this should be non-zero if original input format was MASA_ISM_FORMAT */
            st_ivas->nchan_ism = add( st_ivas->bit_stream[L_sub( res_dec, 3 )], shl( st_ivas->bit_stream[L_sub( res_dec, 2 )], 1 ) );

#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
            /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */
            /* info about the number of objects:
                      '00' - MASA format at the encoder
                      '01' - MASA_ISM_FORMAT at the encoder, with 4 objects
                      '10' - MASA_ISM_FORMAT at the encoder, with 3 objects
                      '11' - MASA_ISM_FORMAT at the encoder, with 1 or 2 objects
                      reading if 1 or 2 objects is performed later
            */
            st_ivas->nchan_ism = sub( 5, st_ivas->nchan_ism );

            test();
            IF( EQ_16( st_ivas->nchan_transport, 1 ) && EQ_16( st_ivas->nchan_ism, 2 ) )
            {
                st_ivas->nchan_ism = 1;
                move16();
            }
            /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 and the corresponding bit is not used here*/
#else
            IF( GT_16( st_ivas->nchan_ism, 0 ) )
            {
                /* the input_ivas_format should be MASA_ISM_FORMAT, but we cannot initialize it now */
@@ -400,6 +419,7 @@ ivas_error ivas_dec_setup(
                    move16();
                }
                /* for MASA_ISM_FORMAT at input the number of MASA transport channels is always 2 */
#endif
                st_ivas->nchan_transport = 2;
                element_mode_flag = 1;
                move16();
+171 −102
Original line number Diff line number Diff line
@@ -184,6 +184,70 @@ ivas_error ivas_masa_decode_fx(
        test();
        IF( NE_32( ivas_format, MC_FORMAT ) || NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
        {
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
            Word16 bits_per_frame = extract_l( Mpy_32_32( ivas_total_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
            if ( EQ_32( ivas_format, MASA_FORMAT ) )
            {
                /* re-read the number of objects, needed in case of bad frame  */
                st_ivas->nchan_ism = sub( 5, add( st_ivas->bit_stream[bits_per_frame - 3], i_mult( 2, st_ivas->bit_stream[bits_per_frame - 2] ) ) );
            }
            test();
            IF( EQ_32( ivas_format, MASA_FORMAT ) && NE_16( st_ivas->nchan_ism, 5 ) )
            {
                /* there was OMASA in the input */
                hMasa->config.input_ivas_format = MASA_ISM_FORMAT;
                move32();
                IF( LT_16( st_ivas->nchan_ism, 3 ) )
                {
                    /* was read in ivas_init_dec() to distinguish between 1 and 2 objects */
                    if ( EQ_16( st_ivas->bit_stream[bits_per_frame - 1], 0 ) )
                    {
                        st_ivas->nchan_ism = 1;
                        move16();
                    }
                    st->next_bit_pos = sub( st->next_bit_pos, MASA_TRANSP_BITS );
                    *nb_bits_read = add( *nb_bits_read, MASA_TRANSP_BITS );
                    move16();
                    move16();

                    /* the two reserved bits were already read in ivas_init_dec()*/
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    move16();
                    move16();
                    *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS );
                    move16();
                    /* read number of directions */
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    move16();
                    *nb_bits_read = add( *nb_bits_read, 1 );
                    move16();
                    hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
                    move16();
                }
                ELSE
                {
                    /* if there are 3 or 4 objects the number of transport channels bit is given to MASA format
                    and used to read number of directions*/
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    move16();
                    *nb_bits_read = add( *nb_bits_read, 1 );
                    move16();
                    hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
                    move16();

                    /* the two reserved bits were already read in ivas_init_dec()*/
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    byteBuffer = st->bit_stream[( st->next_bit_pos )--];
                    move16();
                    move16();
                    *nb_bits_read = add( *nb_bits_read, MASA_HEADER_BITS );
                    move16();
                }
            }
            ELSE
            {
#endif
                IF( NE_32( ivas_format, MASA_ISM_FORMAT ) )
                {
                    /* number of transport channels is always 2 for MASA_ISM format */
@@ -322,6 +386,7 @@ ivas_error ivas_masa_decode_fx(
                }
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT

#ifndef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
                /* read 2 bits:
                              '00' - MASA format at the encoder
                              '01' - MASA_ISM_FORMAT at the encoder, with 1 object
@@ -329,6 +394,7 @@ ivas_error ivas_masa_decode_fx(
                              '11' - MASA_ISM_FORMAT at the encoder, with 3 or 4 objects
                              reading if 3 or 4 object is performed later
                 */
#endif
                byteBuffer = st->bit_stream[st->next_bit_pos];
                move16();
                st->next_bit_pos = sub( st->next_bit_pos, 1 );
@@ -373,6 +439,9 @@ ivas_error ivas_masa_decode_fx(
                move16();
                hMasa->config.numberOfDirections = (UWord8) L_add( byteBuffer, 1 );
                move16();
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
            }
#endif
        }
        ELSE
        {
+39 −4
Original line number Diff line number Diff line
@@ -537,6 +537,19 @@ ivas_error ivas_masa_encode_fx(
            test();
            IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) )
            {
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
                /* use the MASA number of transport channels bit to signal if there are 1 or 2 objects */
                test();
                IF( EQ_16( nchan_ism, 1 ) || EQ_16( nchan_ism, 2 ) )
                {
                    push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_TRANSP_BITS );
                }
                ELSE
                {
                    /* for 3 or 4 objects write already the number of MASA directions */
                    push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), MASA_TRANSP_BITS );
                }
#else
                /* use the MASA number of transport channels bit to signal if there are 3 or 4 objects */
                IF( EQ_16( nchan_ism, 4 ) )
                {
@@ -546,6 +559,7 @@ ivas_error ivas_masa_encode_fx(
                {
                    push_next_indice( hMetaData, 0, MASA_TRANSP_BITS );
                }
#endif
            }
            ELSE
            {
@@ -563,6 +577,16 @@ ivas_error ivas_masa_encode_fx(
        IF( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) )
        {
#ifdef NONBE_FIX_984_OMASA_EXT_OUTPUT
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
            IF( GE_16( nchan_ism, 3 ) ) /* if 3 or 4 objects */
            {
                push_next_indice( hMetaData, sub( 5, nchan_ism ), MASA_HEADER_BITS );
            }
            ELSE
            {
                push_next_indice( hMetaData, 3, MASA_HEADER_BITS );
            }
#else
            IF( LE_16( nchan_ism, 3 ) )
            {
                push_next_indice( hMetaData, nchan_ism, MASA_HEADER_BITS );
@@ -571,6 +595,7 @@ ivas_error ivas_masa_encode_fx(
            {
                push_next_indice( hMetaData, sub( nchan_ism, 1 ), MASA_HEADER_BITS );
            }
#endif
            hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS );
            move16();
#else
@@ -590,10 +615,20 @@ ivas_error ivas_masa_encode_fx(
            hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, MASA_HEADER_BITS );
            move16();
        }
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
        test();
        test();
        test();
        IF( !( EQ_32( ivas_format, MASA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_MODE_NONE ) && GT_16( nchan_ism, 2 ) ) )
        {
#endif
            /* write number of directions */
            push_next_indice( hMetaData, sub( hQMetaData->no_directions, 1 ), 1 );
            hQMetaData->metadata_max_bits = sub( hQMetaData->metadata_max_bits, 1 );
            move16();
#ifdef NONBE_FIX_1074_NOBJ_SIGNAL_OMASA_LBR
        }
#endif

        /* write subframe mode */
        IF( EQ_16( hQMetaData->q_direction[0].cfg.nblocks, 1 ) )