static int init_resampler(AVCodecContext *input_codec_context,

                          AVCodecContext *output_codec_context,

                          SwrContext **resample_context)

{

    /**

     * Only initialize the resampler if it is necessary, i.e.,

     * if and only if the sample formats differ.

     */

    if (input_codec_context->sample_fmt != output_codec_context->sample_fmt ||

        input_codec_context->channels != output_codec_context->channels) {

        int error;



        /**

         * Create a resampler context for the conversion.

         * Set the conversion parameters.

         * Default channel layouts based on the number of channels

         * are assumed for simplicity (they are sometimes not detected

         * properly by the demuxer and/or decoder).

         */

        *resample_context = swr_alloc_set_opts(NULL,

                                              av_get_default_channel_layout(output_codec_context->channels),

                                              output_codec_context->sample_fmt,

                                              output_codec_context->sample_rate,

                                              av_get_default_channel_layout(input_codec_context->channels),

                                              input_codec_context->sample_fmt,

                                              input_codec_context->sample_rate,

                                              0, NULL);

        if (!*resample_context) {

            fprintf(stderr, "Could not allocate resample context\n");

            return AVERROR(ENOMEM);

        }

        /**

        * Perform a sanity check so that the number of converted samples is

        * not greater than the number of samples to be converted.

        * If the sample rates differ, this case has to be handled differently

        */

        av_assert0(output_codec_context->sample_rate == input_codec_context->sample_rate);



        /** Open the resampler with the specified parameters. */

        if ((error = swr_init(*resample_context)) < 0) {

            fprintf(stderr, "Could not open resample context\n");

            swr_free(resample_context);

            return error;

        }

    }

    return 0;

}

static int init_resampler(AVCodecContext *input_codec_context,

                          AVCodecContext *output_codec_context,

                          SwrContext **resample_context)

{

    







    if (input_codec_context->sample_fmt != output_codec_context->sample_fmt ||

        input_codec_context->channels != output_codec_context->channels) {

        int error;



        













        *resample_context = swr_alloc_set_opts(NULL,

                                              av_get_default_channel_layout(output_codec_context->channels),

                                              output_codec_context->sample_fmt,

                                              output_codec_context->sample_rate,

                                              av_get_default_channel_layout(input_codec_context->channels),

                                              input_codec_context->sample_fmt,

                                              input_codec_context->sample_rate,

                                              0, NULL);

        if (!*resample_context) {

            fprintf(stderr, "Could not allocate resample context\n");

            return AVERROR(ENOMEM);

        }

        









        av_assert0(output_codec_context->sample_rate == input_codec_context->sample_rate);



        

        if ((error = swr_init(*resample_context)) < 0) {

            fprintf(stderr, "Could not open resample context\n");

            swr_free(resample_context);

            return error;

        }

    }

    return 0;

}

    if (input_codec_context->sample_fmt != output_codec_context->sample_fmt ||         input_codec_context->channels != output_codec_context->channels) {
static int FUNC_0(AVCodecContext *VAR_0,

                          AVCodecContext *VAR_1,

                          SwrContext **VAR_2)

{

    







    if (VAR_0->sample_fmt != VAR_1->sample_fmt ||

        VAR_0->channels != VAR_1->channels) {

        int VAR_3;



        













        *VAR_2 = swr_alloc_set_opts(NULL,

                                              av_get_default_channel_layout(VAR_1->channels),

                                              VAR_1->sample_fmt,

                                              VAR_1->sample_rate,

                                              av_get_default_channel_layout(VAR_0->channels),

                                              VAR_0->sample_fmt,

                                              VAR_0->sample_rate,

                                              0, NULL);

        if (!*VAR_2) {

            fprintf(stderr, "Could not allocate resample context\n");

            return AVERROR(ENOMEM);

        }

        









        av_assert0(VAR_1->sample_rate == VAR_0->sample_rate);



        

        if ((VAR_3 = swr_init(*VAR_2)) < 0) {

            fprintf(stderr, "Could not open resample context\n");

            swr_free(VAR_2);

            return VAR_3;

        }

    }

    return 0;

}

static int FUNC_0(AVCodecContext *VAR_0,
AVCodecContext *VAR_1,
SwrContext **VAR_2)
{ if (VAR_0->sample_fmt != VAR_1->sample_fmt ||
VAR_0->channels != VAR_1->channels) { int VAR_3; *VAR_2 = swr_alloc_set_opts(NULL,
av_get_default_channel_layout(VAR_1->channels),
VAR_1->sample_fmt,
VAR_1->sample_rate,
av_get_default_channel_layout(VAR_0->channels),
VAR_0->sample_fmt,
VAR_0->sample_rate,
0, NULL); if (!*VAR_2) { fprintf(stderr, "Could not allocate resample context\n"); return AVERROR(ENOMEM); } av_assert0(VAR_1->sample_rate == VAR_0->sample_rate); if ((VAR_3 = swr_init(*VAR_2)) < 0) { fprintf(stderr, "Could not open resample context\n"); swr_free(VAR_2); return VAR_3; } } return 0; }