int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,

                          int stride)

{

    int in_channels, out_channels, i, o;



    in_channels  = av_get_channel_layout_nb_channels(avr->in_channel_layout);

    out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);



    if ( in_channels < 0 ||  in_channels > AVRESAMPLE_MAX_CHANNELS ||

        out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {

        av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");

        return AVERROR(EINVAL);

    }



    switch (avr->mix_coeff_type) {

    case AV_MIX_COEFF_TYPE_Q8:

        if (!avr->am->matrix_q8[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0;

        break;

    case AV_MIX_COEFF_TYPE_Q15:

        if (!avr->am->matrix_q15[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0;

        break;

    case AV_MIX_COEFF_TYPE_FLT:

        if (!avr->am->matrix_flt[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_flt[o][i];

        break;

    default:

        av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n");

        return AVERROR(EINVAL);

    }

    return 0;

}

int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix,

                          int stride)

{

    int in_channels, out_channels, i, o;



    in_channels  = av_get_channel_layout_nb_channels(avr->in_channel_layout);

    out_channels = av_get_channel_layout_nb_channels(avr->out_channel_layout);



    if ( in_channels < 0 ||  in_channels > AVRESAMPLE_MAX_CHANNELS ||

        out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {

        av_log(avr, AV_LOG_ERROR, "Invalid channel layouts\n");

        return AVERROR(EINVAL);

    }



    switch (avr->mix_coeff_type) {

    case AV_MIX_COEFF_TYPE_Q8:

        if (!avr->am->matrix_q8[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_q8[o][i] / 256.0;

        break;

    case AV_MIX_COEFF_TYPE_Q15:

        if (!avr->am->matrix_q15[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_q15[o][i] / 32768.0;

        break;

    case AV_MIX_COEFF_TYPE_FLT:

        if (!avr->am->matrix_flt[0]) {

            av_log(avr, AV_LOG_ERROR, "matrix is not set\n");

            return AVERROR(EINVAL);

        }

        for (o = 0; o < out_channels; o++)

            for (i = 0; i < in_channels; i++)

                matrix[o * stride + i] = avr->am->matrix_flt[o][i];

        break;

    default:

        av_log(avr, AV_LOG_ERROR, "Invalid mix coeff type\n");

        return AVERROR(EINVAL);

    }

    return 0;

}

    if ( in_channels < 0 ||  in_channels > AVRESAMPLE_MAX_CHANNELS ||         out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {     if ( in_channels < 0 ||  in_channels > AVRESAMPLE_MAX_CHANNELS ||         out_channels < 0 || out_channels > AVRESAMPLE_MAX_CHANNELS) {
int FUNC_0(AVAudioResampleContext *VAR_0, double *VAR_1,

                          int VAR_2)

{

    int VAR_3, VAR_4, VAR_5, VAR_6;



    VAR_3  = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout);

    VAR_4 = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout);



    if ( VAR_3 < 0 ||  VAR_3 > AVRESAMPLE_MAX_CHANNELS ||

        VAR_4 < 0 || VAR_4 > AVRESAMPLE_MAX_CHANNELS) {

        av_log(VAR_0, AV_LOG_ERROR, "Invalid channel layouts\n");

        return AVERROR(EINVAL);

    }



    switch (VAR_0->mix_coeff_type) {

    case AV_MIX_COEFF_TYPE_Q8:

        if (!VAR_0->am->matrix_q8[0]) {

            av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");

            return AVERROR(EINVAL);

        }

        for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)

            for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)

                VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q8[VAR_6][VAR_5] / 256.0;

        break;

    case AV_MIX_COEFF_TYPE_Q15:

        if (!VAR_0->am->matrix_q15[0]) {

            av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");

            return AVERROR(EINVAL);

        }

        for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)

            for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)

                VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q15[VAR_6][VAR_5] / 32768.0;

        break;

    case AV_MIX_COEFF_TYPE_FLT:

        if (!VAR_0->am->matrix_flt[0]) {

            av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n");

            return AVERROR(EINVAL);

        }

        for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++)

            for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++)

                VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_flt[VAR_6][VAR_5];

        break;

    default:

        av_log(VAR_0, AV_LOG_ERROR, "Invalid mix coeff type\n");

        return AVERROR(EINVAL);

    }

    return 0;

}

int FUNC_0(AVAudioResampleContext *VAR_0, double *VAR_1,
int VAR_2)
{ int VAR_3, VAR_4, VAR_5, VAR_6; VAR_3  = av_get_channel_layout_nb_channels(VAR_0->in_channel_layout); VAR_4 = av_get_channel_layout_nb_channels(VAR_0->out_channel_layout); if ( VAR_3 < 0 ||  VAR_3 > AVRESAMPLE_MAX_CHANNELS ||
VAR_4 < 0 || VAR_4 > AVRESAMPLE_MAX_CHANNELS) { av_log(VAR_0, AV_LOG_ERROR, "Invalid channel layouts\n"); return AVERROR(EINVAL); } switch (VAR_0->mix_coeff_type) { case AV_MIX_COEFF_TYPE_Q8:
if (!VAR_0->am->matrix_q8[0]) { av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n"); return AVERROR(EINVAL); } for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q8[VAR_6][VAR_5] / 256.0; break; case AV_MIX_COEFF_TYPE_Q15:
if (!VAR_0->am->matrix_q15[0]) { av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n"); return AVERROR(EINVAL); } for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_q15[VAR_6][VAR_5] / 32768.0; break; case AV_MIX_COEFF_TYPE_FLT:
if (!VAR_0->am->matrix_flt[0]) { av_log(VAR_0, AV_LOG_ERROR, "VAR_1 is not set\n"); return AVERROR(EINVAL); } for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) VAR_1[VAR_6 * VAR_2 + VAR_5] = VAR_0->am->matrix_flt[VAR_6][VAR_5]; break; default:
av_log(VAR_0, AV_LOG_ERROR, "Invalid mix coeff type\n"); return AVERROR(EINVAL); } return 0; }