libavcodec/ac3enc.c:723: error: Buffer Overrun L2
  Offset: [1, 6] Size: 6.

libavcodec/ac3enc.c:698:9: <Offset trace>
696.        coordinates in successive blocks */
697.     for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
698.         blk = 0;
             ^
699.         while (blk < AC3_MAX_BLOCKS) {
700.             int blk1;

libavcodec/ac3enc.c:698:9: Assignment
696.        coordinates in successive blocks */
697.     for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
698.         blk = 0;
             ^
699.         while (blk < AC3_MAX_BLOCKS) {
700.             int blk1;

libavcodec/ac3enc.c:722:17: Assignment
720.                     continue;
721.                 energy_ch = energy[blk][ch][bnd];
722.                 blk1 = blk+1;
                     ^
723.                 while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {
724.                     if (s->blocks[blk1].cpl_in_use)

libavcodec/ac3enc.c:583:1: <Length trace>
581.  *       at that time to use coupling for the fixed-point encoder as well.
582.  */
583. static void apply_channel_coupling(AC3EncodeContext *s)
     ^
584. {
585. #if CONFIG_AC3ENC_FLOAT

libavcodec/ac3enc.c:583:1: Parameter `s->blocks[*]`
581.  *       at that time to use coupling for the fixed-point encoder as well.
582.  */
583. static void apply_channel_coupling(AC3EncodeContext *s)
     ^
584. {
585. #if CONFIG_AC3ENC_FLOAT

libavcodec/ac3enc.c:723:25: Array access: Offset: [1, 6] Size: 6
721.                 energy_ch = energy[blk][ch][bnd];
722.                 blk1 = blk+1;
723.                 while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {
                             ^
724.                     if (s->blocks[blk1].cpl_in_use)
725.                         energy_ch += energy[blk1][ch][bnd];

static void apply_channel_coupling(AC3EncodeContext *s)
{
#if CONFIG_AC3ENC_FLOAT
    DECLARE_ALIGNED(16, float,   cpl_coords)      [AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16];
    DECLARE_ALIGNED(16, int32_t, fixed_cpl_coords)[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16];
    int blk, ch, bnd, i, j;
    CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};
    int num_cpl_coefs = s->num_cpl_subbands * 12;
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
        AC3Block *block = &s->blocks[blk];
        CoefType *cpl_coef = &block->mdct_coef[CPL_CH][s->start_freq[CPL_CH]];
        if (!block->cpl_in_use)
            continue;
        memset(cpl_coef-1, 0, (num_cpl_coefs+4) * sizeof(*cpl_coef));
        for (ch = 1; ch <= s->fbw_channels; ch++) {
            CoefType *ch_coef = &block->mdct_coef[ch][s->start_freq[CPL_CH]];
            if (!block->channel_in_cpl[ch])
                continue;
            for (i = 0; i < num_cpl_coefs; i++)
                cpl_coef[i] += ch_coef[i];
        }
        s->dsp.vector_clipf(cpl_coef-1, cpl_coef-1, -1.0f, 1.0f, num_cpl_coefs+4);
        s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][s->start_freq[CPL_CH]-1],
                                   cpl_coef-1, num_cpl_coefs+4);
    }
    bnd = 0;
    i = s->start_freq[CPL_CH];
    while (i < s->cpl_end_freq) {
        int band_size = s->cpl_band_sizes[bnd];
        for (ch = CPL_CH; ch <= s->fbw_channels; ch++) {
            for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
                AC3Block *block = &s->blocks[blk];
                if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch]))
                    continue;
                for (j = 0; j < band_size; j++) {
                    CoefType v = block->mdct_coef[ch][i+j];
                    MAC_COEF(energy[blk][ch][bnd], v, v);
                }
            }
        }
        i += band_size;
        bnd++;
    }
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
        AC3Block *block  = &s->blocks[blk];
        AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL;
        int new_coords = 0;
        CoefSumType coord_diff[AC3_MAX_CHANNELS] = {0,};
        if (block->cpl_in_use) {
            for (ch = 1; ch <= s->fbw_channels; ch++) {
                if (!block->channel_in_cpl[ch])
                    continue;
                for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
                    cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy[blk][ch][bnd],
                                                              energy[blk][CPL_CH][bnd]);
                    if (blk > 0 && block0->cpl_in_use &&
                        block0->channel_in_cpl[ch]) {
                        coord_diff[ch] += fabs(cpl_coords[blk-1][ch][bnd] -
                                               cpl_coords[blk  ][ch][bnd]);
                    }
                }
                coord_diff[ch] /= s->num_cpl_bands;
            }
            if (blk == 0) {
                new_coords = 1;
            } else if (!block0->cpl_in_use) {
                new_coords = 1;
            } else {
                for (ch = 1; ch <= s->fbw_channels; ch++) {
                    if (block->channel_in_cpl[ch] && !block0->channel_in_cpl[ch]) {
                        new_coords = 1;
                        break;
                    }
                }
                if (!new_coords) {
                    for (ch = 1; ch <= s->fbw_channels; ch++) {
                        if (block->channel_in_cpl[ch] && coord_diff[ch] > 0.04) {
                            new_coords = 1;
                            break;
                        }
                    }
                }
            }
        }
        block->new_cpl_coords = new_coords;
    }
    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
        blk = 0;
        while (blk < AC3_MAX_BLOCKS) {
            int blk1;
            CoefSumType energy_cpl;
            AC3Block *block  = &s->blocks[blk];
            if (!block->cpl_in_use) {
                blk++;
                continue;
            }
            energy_cpl = energy[blk][CPL_CH][bnd];
            blk1 = blk+1;
            while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {
                if (s->blocks[blk1].cpl_in_use)
                    energy_cpl += energy[blk1][CPL_CH][bnd];
                blk1++;
            }
            for (ch = 1; ch <= s->fbw_channels; ch++) {
                CoefType energy_ch;
                if (!block->channel_in_cpl[ch])
                    continue;
                energy_ch = energy[blk][ch][bnd];
                blk1 = blk+1;
                while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {
                    if (s->blocks[blk1].cpl_in_use)
                        energy_ch += energy[blk1][ch][bnd];
                    blk1++;
                }
                cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy_ch, energy_cpl);
            }
            blk = blk1;
        }
    }
    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
        AC3Block *block = &s->blocks[blk];
        if (!block->cpl_in_use || !block->new_cpl_coords)
            continue;
        s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],
                                   cpl_coords[blk][1],
                                   s->fbw_channels * 16);
        s->ac3dsp.extract_exponents(block->cpl_coord_exp[1],
                                    fixed_cpl_coords[blk][1],
                                    s->fbw_channels * 16);
        for (ch = 1; ch <= s->fbw_channels; ch++) {
            int bnd, min_exp, max_exp, master_exp;
            min_exp = max_exp = block->cpl_coord_exp[ch][0];
            for (bnd = 1; bnd < s->num_cpl_bands; bnd++) {
                int exp = block->cpl_coord_exp[ch][bnd];
                min_exp = FFMIN(exp, min_exp);
                max_exp = FFMAX(exp, max_exp);
            }
            master_exp = ((max_exp - 15) + 2) / 3;
            master_exp = FFMAX(master_exp, 0);
            while (min_exp < master_exp * 3)
                master_exp--;
            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
                block->cpl_coord_exp[ch][bnd] = av_clip(block->cpl_coord_exp[ch][bnd] -
                                                        master_exp * 3, 0, 15);
            }
            block->cpl_master_exp[ch] = master_exp;
            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {
                int cpl_exp  = block->cpl_coord_exp[ch][bnd];
                int cpl_mant = (fixed_cpl_coords[blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;
                if (cpl_exp == 15)
                    cpl_mant >>= 1;
                else
                    cpl_mant -= 16;
                block->cpl_coord_mant[ch][bnd] = cpl_mant;
            }
        }
    }
#endif
}
['static void apply_channel_coupling(AC3EncodeContext *s)\n{\n#if CONFIG_AC3ENC_FLOAT\n    DECLARE_ALIGNED(16, float,   cpl_coords)      [AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16];\n    DECLARE_ALIGNED(16, int32_t, fixed_cpl_coords)[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16];\n    int blk, ch, bnd, i, j;\n    CoefSumType energy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][16] = {{{0}}};\n    int num_cpl_coefs = s->num_cpl_subbands * 12;\n    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n        AC3Block *block = &s->blocks[blk];\n        CoefType *cpl_coef = &block->mdct_coef[CPL_CH][s->start_freq[CPL_CH]];\n        if (!block->cpl_in_use)\n            continue;\n        memset(cpl_coef-1, 0, (num_cpl_coefs+4) * sizeof(*cpl_coef));\n        for (ch = 1; ch <= s->fbw_channels; ch++) {\n            CoefType *ch_coef = &block->mdct_coef[ch][s->start_freq[CPL_CH]];\n            if (!block->channel_in_cpl[ch])\n                continue;\n            for (i = 0; i < num_cpl_coefs; i++)\n                cpl_coef[i] += ch_coef[i];\n        }\n        s->dsp.vector_clipf(cpl_coef-1, cpl_coef-1, -1.0f, 1.0f, num_cpl_coefs+4);\n        s->ac3dsp.float_to_fixed24(&block->fixed_coef[CPL_CH][s->start_freq[CPL_CH]-1],\n                                   cpl_coef-1, num_cpl_coefs+4);\n    }\n    bnd = 0;\n    i = s->start_freq[CPL_CH];\n    while (i < s->cpl_end_freq) {\n        int band_size = s->cpl_band_sizes[bnd];\n        for (ch = CPL_CH; ch <= s->fbw_channels; ch++) {\n            for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n                AC3Block *block = &s->blocks[blk];\n                if (!block->cpl_in_use || (ch > CPL_CH && !block->channel_in_cpl[ch]))\n                    continue;\n                for (j = 0; j < band_size; j++) {\n                    CoefType v = block->mdct_coef[ch][i+j];\n                    MAC_COEF(energy[blk][ch][bnd], v, v);\n                }\n            }\n        }\n        i += band_size;\n        bnd++;\n    }\n    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n        AC3Block *block  = &s->blocks[blk];\n        AC3Block *block0 = blk ? &s->blocks[blk-1] : NULL;\n        int new_coords = 0;\n        CoefSumType coord_diff[AC3_MAX_CHANNELS] = {0,};\n        if (block->cpl_in_use) {\n            for (ch = 1; ch <= s->fbw_channels; ch++) {\n                if (!block->channel_in_cpl[ch])\n                    continue;\n                for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n                    cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy[blk][ch][bnd],\n                                                              energy[blk][CPL_CH][bnd]);\n                    if (blk > 0 && block0->cpl_in_use &&\n                        block0->channel_in_cpl[ch]) {\n                        coord_diff[ch] += fabs(cpl_coords[blk-1][ch][bnd] -\n                                               cpl_coords[blk  ][ch][bnd]);\n                    }\n                }\n                coord_diff[ch] /= s->num_cpl_bands;\n            }\n            if (blk == 0) {\n                new_coords = 1;\n            } else if (!block0->cpl_in_use) {\n                new_coords = 1;\n            } else {\n                for (ch = 1; ch <= s->fbw_channels; ch++) {\n                    if (block->channel_in_cpl[ch] && !block0->channel_in_cpl[ch]) {\n                        new_coords = 1;\n                        break;\n                    }\n                }\n                if (!new_coords) {\n                    for (ch = 1; ch <= s->fbw_channels; ch++) {\n                        if (block->channel_in_cpl[ch] && coord_diff[ch] > 0.04) {\n                            new_coords = 1;\n                            break;\n                        }\n                    }\n                }\n            }\n        }\n        block->new_cpl_coords = new_coords;\n    }\n    for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n        blk = 0;\n        while (blk < AC3_MAX_BLOCKS) {\n            int blk1;\n            CoefSumType energy_cpl;\n            AC3Block *block  = &s->blocks[blk];\n            if (!block->cpl_in_use) {\n                blk++;\n                continue;\n            }\n            energy_cpl = energy[blk][CPL_CH][bnd];\n            blk1 = blk+1;\n            while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {\n                if (s->blocks[blk1].cpl_in_use)\n                    energy_cpl += energy[blk1][CPL_CH][bnd];\n                blk1++;\n            }\n            for (ch = 1; ch <= s->fbw_channels; ch++) {\n                CoefType energy_ch;\n                if (!block->channel_in_cpl[ch])\n                    continue;\n                energy_ch = energy[blk][ch][bnd];\n                blk1 = blk+1;\n                while (!s->blocks[blk1].new_cpl_coords && blk1 < AC3_MAX_BLOCKS) {\n                    if (s->blocks[blk1].cpl_in_use)\n                        energy_ch += energy[blk1][ch][bnd];\n                    blk1++;\n                }\n                cpl_coords[blk][ch][bnd] = calc_cpl_coord(energy_ch, energy_cpl);\n            }\n            blk = blk1;\n        }\n    }\n    for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {\n        AC3Block *block = &s->blocks[blk];\n        if (!block->cpl_in_use || !block->new_cpl_coords)\n            continue;\n        s->ac3dsp.float_to_fixed24(fixed_cpl_coords[blk][1],\n                                   cpl_coords[blk][1],\n                                   s->fbw_channels * 16);\n        s->ac3dsp.extract_exponents(block->cpl_coord_exp[1],\n                                    fixed_cpl_coords[blk][1],\n                                    s->fbw_channels * 16);\n        for (ch = 1; ch <= s->fbw_channels; ch++) {\n            int bnd, min_exp, max_exp, master_exp;\n            min_exp = max_exp = block->cpl_coord_exp[ch][0];\n            for (bnd = 1; bnd < s->num_cpl_bands; bnd++) {\n                int exp = block->cpl_coord_exp[ch][bnd];\n                min_exp = FFMIN(exp, min_exp);\n                max_exp = FFMAX(exp, max_exp);\n            }\n            master_exp = ((max_exp - 15) + 2) / 3;\n            master_exp = FFMAX(master_exp, 0);\n            while (min_exp < master_exp * 3)\n                master_exp--;\n            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n                block->cpl_coord_exp[ch][bnd] = av_clip(block->cpl_coord_exp[ch][bnd] -\n                                                        master_exp * 3, 0, 15);\n            }\n            block->cpl_master_exp[ch] = master_exp;\n            for (bnd = 0; bnd < s->num_cpl_bands; bnd++) {\n                int cpl_exp  = block->cpl_coord_exp[ch][bnd];\n                int cpl_mant = (fixed_cpl_coords[blk][ch][bnd] << (5 + cpl_exp + master_exp * 3)) >> 24;\n                if (cpl_exp == 15)\n                    cpl_mant >>= 1;\n                else\n                    cpl_mant -= 16;\n                block->cpl_coord_mant[ch][bnd] = cpl_mant;\n            }\n        }\n    }\n#endif\n}']