static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)

{

    int i, j;



    if (!avctx->channel_layout) {

        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "

                                      "encoder will guess the layout, but it "

                                      "might be incorrect.\n");

    }

    if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) {

        av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");

        return -1;

    }



    /* frequency */

    for (i = 0; i < 3; i++) {

        for (j = 0; j < 3; j++)

            if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate)

                goto found;

    }

    return -1;

 found:

    s->sample_rate        = avctx->sample_rate;

    s->bit_alloc.sr_shift = i;

    s->bit_alloc.sr_code  = j;

    s->bitstream_id       = 8 + s->bit_alloc.sr_shift;

    s->bitstream_mode     = 0; /* complete main audio service */



    /* bitrate & frame size */

    for (i = 0; i < 19; i++) {

        if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)

            break;

    }

    if (i == 19)

        return -1;

    s->bit_rate        = avctx->bit_rate;

    s->frame_size_code = i << 1;



    return 0;

}

static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)

{

    int i, j;



    if (!avctx->channel_layout) {

        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "

                                      "encoder will guess the layout, but it "

                                      "might be incorrect.\n");

    }

    if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) {

        av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");

        return -1;

    }



    

    for (i = 0; i < 3; i++) {

        for (j = 0; j < 3; j++)

            if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate)

                goto found;

    }

    return -1;

 found:

    s->sample_rate        = avctx->sample_rate;

    s->bit_alloc.sr_shift = i;

    s->bit_alloc.sr_code  = j;

    s->bitstream_id       = 8 + s->bit_alloc.sr_shift;

    s->bitstream_mode     = 0; 



    

    for (i = 0; i < 19; i++) {

        if ((ff_ac3_bitrate_tab[i] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)

            break;

    }

    if (i == 19)

        return -1;

    s->bit_rate        = avctx->bit_rate;

    s->frame_size_code = i << 1;



    return 0;

}

static av_cold int FUNC_0(AVCodecContext *avctx, AC3EncodeContext *s)

{

    int VAR_0, VAR_1;



    if (!avctx->channel_layout) {

        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "

                                      "encoder will guess the layout, but it "

                                      "might be incorrect.\n");

    }

    if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) {

        av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n");

        return -1;

    }



    

    for (VAR_0 = 0; VAR_0 < 3; VAR_0++) {

        for (VAR_1 = 0; VAR_1 < 3; VAR_1++)

            if ((ff_ac3_sample_rate_tab[VAR_1] >> VAR_0) == avctx->sample_rate)

                goto found;

    }

    return -1;

 found:

    s->sample_rate        = avctx->sample_rate;

    s->bit_alloc.sr_shift = VAR_0;

    s->bit_alloc.sr_code  = VAR_1;

    s->bitstream_id       = 8 + s->bit_alloc.sr_shift;

    s->bitstream_mode     = 0; 



    

    for (VAR_0 = 0; VAR_0 < 19; VAR_0++) {

        if ((ff_ac3_bitrate_tab[VAR_0] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)

            break;

    }

    if (VAR_0 == 19)

        return -1;

    s->bit_rate        = avctx->bit_rate;

    s->frame_size_code = VAR_0 << 1;



    return 0;

}

static av_cold int FUNC_0(AVCodecContext *avctx, AC3EncodeContext *s)
{ int VAR_0, VAR_1; if (!avctx->channel_layout) { av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
"encoder will guess the layout, but it "
"might be incorrect.\n"); } if (set_channel_info(s, avctx->channels, &avctx->channel_layout)) { av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); return -1; } for (VAR_0 = 0; VAR_0 < 3; VAR_0++) { for (VAR_1 = 0; VAR_1 < 3; VAR_1++) if ((ff_ac3_sample_rate_tab[VAR_1] >> VAR_0) == avctx->sample_rate)
goto found; } return -1; found:
s->sample_rate        = avctx->sample_rate; s->bit_alloc.sr_shift = VAR_0; s->bit_alloc.sr_code  = VAR_1; s->bitstream_id       = 8 + s->bit_alloc.sr_shift; s->bitstream_mode     = 0; for (VAR_0 = 0; VAR_0 < 19; VAR_0++) { if ((ff_ac3_bitrate_tab[VAR_0] >> s->bit_alloc.sr_shift)*1000 == avctx->bit_rate)
break; } if (VAR_0 == 19)
return -1; s->bit_rate        = avctx->bit_rate; s->frame_size_code = VAR_0 << 1; return 0; }