Commit 90333f35 authored by vaclav's avatar vaclav
Browse files

fixes for sanity checks

parent 9bb06dc9
Loading
Loading
Loading
Loading
Loading
+18 −5
Original line number Diff line number Diff line
@@ -244,10 +244,6 @@ ivas_error ivas_dec_get_format(
                st_ivas->nchan_transport = 2;
                element_mode_flag = 1;
            }
            else
            {
                nchan_ism = 5;
            }

            if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism )
            {
@@ -265,7 +261,7 @@ ivas_error ivas_dec_get_format(

            /* the number of objects are written at the end of the bitstream */
            nchan_ism = 2 * st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 1] + st_ivas->bit_stream[ivas_total_brate / FRAMES_PER_SEC - 2] + 1;
            st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, st_ivas->nchan_ism );
            st_ivas->ism_mode = ivas_omasa_ism_mode_select( ivas_total_brate, nchan_ism );

            if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism )
            {
@@ -430,6 +426,14 @@ ivas_error ivas_dec_get_format(
            }
            k--;

            if ( st_ivas->ini_frame > 0 && nchan_ism != st_ivas->nchan_ism )
            {
#ifdef DEBUGGING
                fprintf( stderr, "\nError: Changing the number of ISMs is not supported!\n" );
#endif
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Wrong number of objects signalled!" );
            }

            st_ivas->nchan_ism = nchan_ism;

            /* read ism_mode */
@@ -1004,6 +1008,15 @@ static ivas_error ivas_read_format(
                    if ( st_ivas->sba_order == 0 )
                    {
                        st_ivas->ivas_format = SBA_ISM_FORMAT;

#ifdef FIX_HRTF_LOAD
                        /* read the real Ambisonic order when the above bits are used to signal OSBA format */
                        if ( ivas_total_brate < IVAS_24k4 )
                        {
                            st_ivas->sba_order = st_ivas->bit_stream[*num_bits_read + 2 + SBA_PLANAR_BITS + SBA_ORDER_BITS];
                            st_ivas->sba_order += 2 * st_ivas->bit_stream[*num_bits_read + 1 + SBA_PLANAR_BITS + SBA_ORDER_BITS];
                        }
#endif
                    }
                }
                ( *num_bits_read )++;
+16 −0
Original line number Diff line number Diff line
@@ -151,12 +151,28 @@ ivas_error ivas_masa_decode(
    {
        if ( !( ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) )
        {
#ifdef FIX_HRTF_LOAD
            if ( ivas_format == MASA_FORMAT )
            {
                /* re-read the number of objects, needed in case of bad frame  */
                ch = 5 - ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3] + 2 * st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2] );

                if ( ch == 5 )
                {
                    ch = 0;
                }
                st_ivas->nchan_ism = ch;
            }

            if ( ivas_format == MASA_FORMAT && st_ivas->nchan_ism > 0 )
#else
            if ( ivas_format == MASA_FORMAT )
            {
                /* re-read the number of objects, needed in case of bad frame  */
                st_ivas->nchan_ism = 5 - ( st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 3] + 2 * st_ivas->bit_stream[( ivas_total_brate / FRAMES_PER_SEC ) - 2] );
            }
            if ( ivas_format == MASA_FORMAT && st_ivas->nchan_ism != 5 )
#endif
            {
                /* there was OMASA in the input */
                hMasa->config.input_ivas_format = MASA_ISM_FORMAT;