Commit bd63091d authored by vaclav's avatar vaclav
Browse files

fix to ivas_rend_crendProcessSubframe()

parent 11eac443
Loading
Loading
Loading
Loading
Loading
+85 −16
Original line number Diff line number Diff line
@@ -2353,6 +2353,11 @@ ivas_error ivas_rend_crendProcessSubframe(
    {
        p_pcm_tmp_fx[ch] = pcm_tmp_fx[ch];
    }

#ifdef FIX_911_REMOVE_CREND_DUPLICATION
    IF( hTcBuffer != NULL )
    {
#endif
        slot_size = hTcBuffer->n_samples_granularity;
        move16();

@@ -2368,9 +2373,54 @@ ivas_error ivas_rend_crendProcessSubframe(
            slots_to_render = sub( slots_to_render, hTcBuffer->subframe_nbslots[last_sf] );
            last_sf = add( last_sf, 1 );
        }

#ifdef FIX_911_REMOVE_CREND_DUPLICATION
        subframe_len = -1; /* will be set later */
        move16();
    }
    ELSE
    {
        Word16 n_den, den, last_sf_tmp;

        SWITCH( output_Fs )
        {
            case 48000:
                subframe_len = L_SUBFRAME_48k;
                move16();
                BREAK;
            case 32000:
                subframe_len = L_SUBFRAME_32k;
                move16();
                BREAK;
            case 16000:
            default:
                subframe_len = L_SUBFRAME_16k;
                move16();
                BREAK;
        }

        first_sf = 0;
        move16();
        last_sf = idiv1616( n_samples_to_render, subframe_len );

        n_den = norm_s( subframe_len );
        den = shl( subframe_len, n_den );
        last_sf_tmp = div_s( n_samples_to_render, den );
        last_sf = shr( last_sf_tmp, sub( 15, n_den ) );
    }
#endif

    FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    {
#ifdef FIX_911_REMOVE_CREND_DUPLICATION
        if ( hTcBuffer != NULL )
        {
#endif
            subframe_len = imult1616( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->n_samples_granularity );
#ifdef FIX_911_REMOVE_CREND_DUPLICATION
        }
#endif

        /* Early Reflections */
        IF( hCrend->reflections != NULL )
        {
@@ -2434,6 +2484,7 @@ ivas_error ivas_rend_crendProcessSubframe(
                }
            }
#endif

            FOR( ch = 0; ch < nchan_in; ch++ )
            {
                tc_local_fx[ch] += subframe_len;
@@ -2442,13 +2493,22 @@ ivas_error ivas_rend_crendProcessSubframe(
            {
                p_pcm_tmp_fx[ch] += subframe_len;
            }

#ifdef FIX_911_REMOVE_CREND_DUPLICATION
            if ( hTcBuffer != NULL )
            {
#endif
                hTcBuffer->slots_rendered = add( hTcBuffer->subframe_nbslots[subframe_idx], hTcBuffer->slots_rendered );
                move16();
#ifdef FIX_911_REMOVE_CREND_DUPLICATION
            }
#endif
        }
        ELSE
        {
            return IVAS_ERR_INVALID_INPUT_FORMAT;
        }

        /* update combined orientation access index */
        ivas_combined_orientation_update_index( hCombinedOrientationData, subframe_len );
    }
@@ -2470,14 +2530,23 @@ ivas_error ivas_rend_crendProcessSubframe(
            }
        }
    }

    /* move to output */
    FOR( ch = 0; ch < nchan_out; ch++ )
    {
        MVR2R_WORD32( pcm_tmp_fx[ch], output[ch], n_samples_to_render ); // Qx
    }

#ifdef FIX_911_REMOVE_CREND_DUPLICATION
    if ( hTcBuffer != NULL )
    {
#endif
        hTcBuffer->subframes_rendered = last_sf;
        move16();
#ifdef FIX_911_REMOVE_CREND_DUPLICATION
    }
#endif

    pop_wmops();

    return IVAS_ERR_OK;