Revision 99ca4f73

View differences:

libavcodec/ac3enc.c
1252 1252

  
1253 1253
static av_cold int validate_options(AVCodecContext *avctx, AC3EncodeContext *s)
1254 1254
{
1255
    int i, j;
1255
    int i;
1256 1256

  
1257 1257
    if (!avctx->channel_layout) {
1258 1258
        av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The "
......
1265 1265
    }
1266 1266

  
1267 1267
    /* frequency */
1268
    for (i = 0; i < 3; i++) {
1269
        for (j = 0; j < 3; j++)
1270
            if ((ff_ac3_sample_rate_tab[j] >> i) == avctx->sample_rate)
1271
                goto found;
1268
    for (i = 0; i < 9; i++) {
1269
        if ((ff_ac3_sample_rate_tab[i / 3] >> (i % 3)) == avctx->sample_rate)
1270
            break;
1272 1271
    }
1272
    if (i == 9) {
1273 1273
    return -1;
1274
 found:
1274
    }
1275 1275
    s->sample_rate        = avctx->sample_rate;
1276
    s->bit_alloc.sr_shift = i;
1277
    s->bit_alloc.sr_code  = j;
1276
    s->bit_alloc.sr_shift = i % 3;
1277
    s->bit_alloc.sr_code  = i / 3;
1278 1278
    s->bitstream_id       = 8 + s->bit_alloc.sr_shift;
1279 1279
    s->bitstream_mode     = 0; /* complete main audio service */
1280 1280

  

Also available in: Unified diff