libavcodec/g722enc.c:202: error: Buffer Overrun L2
  Offset: [1+min(22, `c->prev_samples_pos`), 1+max(1023, `c->prev_samples_pos`)] Size: 1024 by call to `filter_samples`.

libavcodec/g722enc.c:171:1: Parameter `c->prev_samples_pos`
169. }
170. 
171. static void g722_encode_trellis(G722Context *c, int trellis,
     ^
172.                                 uint8_t *dst, int nb_samples,
173.                                 const int16_t *samples)

libavcodec/g722enc.c:202:9: Call
200.         }
201. 
202.         filter_samples(c, &samples[2*i], &xlow, &xhigh);
             ^
203. 
204.         for (j = 0; j < frontier && nodes[0][j]; j++) {

libavcodec/g722enc.c:132:1: <Offset trace>
130. };
131. 
132. static inline void filter_samples(G722Context *c, const int16_t *samples,
     ^
133.                                   int *xlow, int *xhigh)
134. {

libavcodec/g722enc.c:132:1: Parameter `c->prev_samples_pos`
  130. };
  131. 
  132. static inline void filter_samples(G722Context *c, const int16_t *samples,
       ^
  133.                                   int *xlow, int *xhigh)
  134. {

libavcodec/g722enc.c:136:21: Assignment
  134. {
  135.     int xout1, xout2;
  136.     c->prev_samples[c->prev_samples_pos++] = samples[0];
                           ^
  137.     c->prev_samples[c->prev_samples_pos++] = samples[1];
  138.     ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);

libavcodec/g722enc.c:132:1: <Length trace>
130. };
131. 
132. static inline void filter_samples(G722Context *c, const int16_t *samples,
     ^
133.                                   int *xlow, int *xhigh)
134. {

libavcodec/g722enc.c:132:1: Parameter `c->prev_samples[*]`
  130. };
  131. 
  132. static inline void filter_samples(G722Context *c, const int16_t *samples,
       ^
  133.                                   int *xlow, int *xhigh)
  134. {

libavcodec/g722enc.c:137:5: Array access: Offset: [1+min(22, c->prev_samples_pos), 1+max(1023, c->prev_samples_pos)] Size: 1024 by call to `filter_samples` 
  135.     int xout1, xout2;
  136.     c->prev_samples[c->prev_samples_pos++] = samples[0];
  137.     c->prev_samples[c->prev_samples_pos++] = samples[1];
           ^
  138.     ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
  139.     *xlow  = xout1 + xout2 >> 14;

static inline void filter_samples(G722Context *c, const int16_t *samples,
                                  int *xlow, int *xhigh)
{
    int xout1, xout2;
    c->prev_samples[c->prev_samples_pos++] = samples[0];
    c->prev_samples[c->prev_samples_pos++] = samples[1];
    ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
    *xlow  = xout1 + xout2 >> 14;
    *xhigh = xout1 - xout2 >> 14;
    if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
        memmove(c->prev_samples,
                c->prev_samples + c->prev_samples_pos - 22,
                22 * sizeof(c->prev_samples[0]));
        c->prev_samples_pos = 22;
    }
}
['static void g722_encode_trellis(G722Context *c, int trellis,\n                                uint8_t *dst, int nb_samples,\n                                const int16_t *samples)\n{\n    int i, j, k;\n    int frontier = 1 << trellis;\n    struct TrellisNode **nodes[2];\n    struct TrellisNode **nodes_next[2];\n    int pathn[2] = {0, 0}, froze = -1;\n    struct TrellisPath *p[2];\n    for (i = 0; i < 2; i++) {\n        nodes[i] = c->nodep_buf[i];\n        nodes_next[i] = c->nodep_buf[i] + frontier;\n        memset(c->nodep_buf[i], 0, 2 * frontier * sizeof(*c->nodep_buf));\n        nodes[i][0] = c->node_buf[i] + frontier;\n        nodes[i][0]->ssd = 0;\n        nodes[i][0]->path = 0;\n        nodes[i][0]->state = c->band[i];\n    }\n    for (i = 0; i < nb_samples >> 1; i++) {\n        int xlow, xhigh;\n        struct TrellisNode *next[2];\n        int heap_pos[2] = {0, 0};\n        for (j = 0; j < 2; j++) {\n            next[j] = c->node_buf[j] + frontier*(i & 1);\n            memset(nodes_next[j], 0, frontier * sizeof(**nodes_next));\n        }\n        filter_samples(c, &samples[2*i], &xlow, &xhigh);\n        for (j = 0; j < frontier && nodes[0][j]; j++) {\n            int range = j < frontier/2 ? 4 : 0;\n            struct TrellisNode *cur_node = nodes[0][j];\n            int ilow = encode_low(&cur_node->state, xlow);\n            for (k = ilow - range; k <= ilow + range && k <= 63; k += 4) {\n                int decoded, dec_diff, pos;\n                uint32_t ssd;\n                struct TrellisNode* node;\n                if (k < 0)\n                    continue;\n                decoded = av_clip((cur_node->state.scale_factor *\n                                  ff_g722_low_inv_quant6[k] >> 10)\n                                + cur_node->state.s_predictor, -16384, 16383);\n                dec_diff = xlow - decoded;\n#define STORE_NODE(index, UPDATE, VALUE)\\\n                ssd = cur_node->ssd + dec_diff*dec_diff;\\\n                 \\\n                if (ssd < cur_node->ssd)\\\n                    continue;\\\n                if (heap_pos[index] < frontier) {\\\n                    pos = heap_pos[index]++;\\\n                    assert(pathn[index] < FREEZE_INTERVAL * frontier);\\\n                    node = nodes_next[index][pos] = next[index]++;\\\n                    node->path = pathn[index]++;\\\n                } else {\\\n                     \\\n                    pos = (frontier>>1) + (heap_pos[index] & ((frontier>>1) - 1));\\\n                    if (ssd >= nodes_next[index][pos]->ssd)\\\n                        continue;\\\n                    heap_pos[index]++;\\\n                    node = nodes_next[index][pos];\\\n                }\\\n                node->ssd = ssd;\\\n                node->state = cur_node->state;\\\n                UPDATE;\\\n                c->paths[index][node->path].value = VALUE;\\\n                c->paths[index][node->path].prev = cur_node->path;\\\n                 \\\n                while (pos > 0) {\\\n                    int parent = (pos - 1) >> 1;\\\n                    if (nodes_next[index][parent]->ssd <= ssd)\\\n                        break;\\\n                    FFSWAP(struct TrellisNode*, nodes_next[index][parent],\\\n                                                nodes_next[index][pos]);\\\n                    pos = parent;\\\n                }\n                STORE_NODE(0, ff_g722_update_low_predictor(&node->state, k >> 2), k);\n            }\n        }\n        for (j = 0; j < frontier && nodes[1][j]; j++) {\n            int ihigh;\n            struct TrellisNode *cur_node = nodes[1][j];\n            for (ihigh = 0; ihigh < 4; ihigh++) {\n                int dhigh, decoded, dec_diff, pos;\n                uint32_t ssd;\n                struct TrellisNode* node;\n                dhigh = cur_node->state.scale_factor *\n                        ff_g722_high_inv_quant[ihigh] >> 10;\n                decoded = av_clip(dhigh + cur_node->state.s_predictor,\n                                  -16384, 16383);\n                dec_diff = xhigh - decoded;\n                STORE_NODE(1, ff_g722_update_high_predictor(&node->state, dhigh, ihigh), ihigh);\n            }\n        }\n        for (j = 0; j < 2; j++) {\n            FFSWAP(struct TrellisNode**, nodes[j], nodes_next[j]);\n            if (nodes[j][0]->ssd > (1 << 16)) {\n                for (k = 1; k < frontier && nodes[j][k]; k++)\n                    nodes[j][k]->ssd -= nodes[j][0]->ssd;\n                nodes[j][0]->ssd = 0;\n            }\n        }\n        if (i == froze + FREEZE_INTERVAL) {\n            p[0] = &c->paths[0][nodes[0][0]->path];\n            p[1] = &c->paths[1][nodes[1][0]->path];\n            for (j = i; j > froze; j--) {\n                dst[j] = p[1]->value << 6 | p[0]->value;\n                p[0] = &c->paths[0][p[0]->prev];\n                p[1] = &c->paths[1][p[1]->prev];\n            }\n            froze = i;\n            pathn[0] = pathn[1] = 0;\n            memset(nodes[0] + 1, 0, (frontier - 1)*sizeof(**nodes));\n            memset(nodes[1] + 1, 0, (frontier - 1)*sizeof(**nodes));\n        }\n    }\n    p[0] = &c->paths[0][nodes[0][0]->path];\n    p[1] = &c->paths[1][nodes[1][0]->path];\n    for (j = i; j > froze; j--) {\n        dst[j] = p[1]->value << 6 | p[0]->value;\n        p[0] = &c->paths[0][p[0]->prev];\n        p[1] = &c->paths[1][p[1]->prev];\n    }\n    c->band[0] = nodes[0][0]->state;\n    c->band[1] = nodes[1][0]->state;\n}', 'static inline void filter_samples(G722Context *c, const int16_t *samples,\n                                  int *xlow, int *xhigh)\n{\n    int xout1, xout2;\n    c->prev_samples[c->prev_samples_pos++] = samples[0];\n    c->prev_samples[c->prev_samples_pos++] = samples[1];\n    ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);\n    *xlow  = xout1 + xout2 >> 14;\n    *xhigh = xout1 - xout2 >> 14;\n    if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {\n        memmove(c->prev_samples,\n                c->prev_samples + c->prev_samples_pos - 22,\n                22 * sizeof(c->prev_samples[0]));\n        c->prev_samples_pos = 22;\n    }\n}']