libavcodec/dv.c:1286: error: Buffer Overrun L3
  Offset: [-54, +oo] Size: 64 by call to `dv_init_dynamic_tables`.

libavcodec/dv.c:1286:20: Call
1284. 
1285.     s->sys = avpriv_dv_codec_profile(c);
1286.     if (!s->sys || dv_init_dynamic_tables(s->sys))
                         ^
1287.         return -1;
1288.     if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {

libavcodec/dv.c:199:1: Parameter `d->n_difchan`
  197. }
  198. 
  199. static int dv_init_dynamic_tables(const DVprofile *d)
       ^
  200. {
  201.     int j,i,c,s,p;

libavcodec/dv.c:214:27: Call
  212.                     if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
  213.                         !(DV_PROFILE_IS_720p50(d) && s > 9)) {
  214.                           dv_calc_mb_coordinates(d, c, s, j, &d->work_chunks[i].mb_coordinates[0]);
                                 ^
  215.                           d->work_chunks[i++].buf_offset = p;
  216.                     }

libavcodec/dv.c:84:1: <Offset trace>
82. }
83. 
84. static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,
    ^
85.                                           uint16_t *tbl)
86. {

libavcodec/dv.c:84:1: Parameter `chan`
    82. }
    83. 
    84. static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,
        ^
    85.                                           uint16_t *tbl)
    86. {

libavcodec/dv.c:150:15: Assignment
    148. 
    149.               x = shuf1[m]+(chan&1)*9 + k%9;
    150.               y = (i*3+k/9)*2 + (chan>>1) + 4;
                       ^
    151. 
    152.               if (x >= 80) {

libavcodec/dv.c:104:5: <Length trace>
102.                                        0, 1, 2, 3, 4, 5};
103. 
104.     static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, /* dummy */
         ^
105.                                        { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},
106.                                        {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},

libavcodec/dv.c:104:5: Array declaration
    102.                                        0, 1, 2, 3, 4, 5};
    103. 
    104.     static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, /* dummy */
             ^
    105.                                        { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},
    106.                                        {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},

libavcodec/dv.c:153:23: Array access: Offset: [-54, +oo] Size: 64 by call to `dv_init_dynamic_tables` 
    151. 
    152.               if (x >= 80) {
    153.                   x = remap[y][0]+((x-80)<<(y>59));
                               ^
    154.                   y = remap[y][1];
    155.               }

static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,
                                          uint16_t *tbl)
{
    static const uint8_t off[] = { 2, 6, 8, 0, 4 };
    static const uint8_t shuf1[] = { 36, 18, 54, 0, 72 };
    static const uint8_t shuf2[] = { 24, 12, 36, 0, 48 };
    static const uint8_t shuf3[] = { 18, 9, 27, 0, 36 };
    static const uint8_t l_start[] = {0, 4, 9, 13, 18, 22, 27, 31, 36, 40};
    static const uint8_t l_start_shuffled[] = { 9, 4, 13, 0, 18 };
    static const uint8_t serpent1[] = {0, 1, 2, 2, 1, 0,
                                       0, 1, 2, 2, 1, 0,
                                       0, 1, 2, 2, 1, 0,
                                       0, 1, 2, 2, 1, 0,
                                       0, 1, 2};
    static const uint8_t serpent2[] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0,
                                       0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0,
                                       0, 1, 2, 3, 4, 5};
    static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},
                                       { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},
                                       {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},
                                       {20, 2}, {20, 3}, {30, 0}, {30, 1}, {30, 2},
                                       {30, 3}, {40, 0}, {40, 1}, {40, 2}, {40, 3},
                                       {50, 0}, {50, 1}, {50, 2}, {50, 3}, {60, 0},
                                       {60, 1}, {60, 2}, {60, 3}, {70, 0}, {70, 1},
                                       {70, 2}, {70, 3}, { 0,64}, { 0,65}, { 0,66},
                                       {10,64}, {10,65}, {10,66}, {20,64}, {20,65},
                                       {20,66}, {30,64}, {30,65}, {30,66}, {40,64},
                                       {40,65}, {40,66}, {50,64}, {50,65}, {50,66},
                                       {60,64}, {60,65}, {60,66}, {70,64}, {70,65},
                                       {70,66}, { 0,67}, {20,67}, {40,67}, {60,67}};
    int i, k, m;
    int x, y, blk;
    for (m=0; m<5; m++) {
         switch (d->width) {
         case 1440:
              blk = (chan*11+seq)*27+slot;
              if (chan == 0 && seq == 11) {
                  x = m*27+slot;
                  if (x<90) {
                      y = 0;
                  } else {
                      x = (x - 90)*2;
                      y = 67;
                  }
              } else {
                  i = (4*chan + blk + off[m])%11;
                  k = (blk/11)%27;
                  x = shuf1[m] + (chan&1)*9 + k%9;
                  y = (i*3+k/9)*2 + (chan>>1) + 1;
              }
              tbl[m] = (x<<1)|(y<<9);
              break;
         case 1280:
              blk = (chan*10+seq)*27+slot;
              i = (4*chan + (seq/5) + 2*blk + off[m])%10;
              k = (blk/5)%27;
              x = shuf1[m]+(chan&1)*9 + k%9;
              y = (i*3+k/9)*2 + (chan>>1) + 4;
              if (x >= 80) {
                  x = remap[y][0]+((x-80)<<(y>59));
                  y = remap[y][1];
              }
              tbl[m] = (x<<1)|(y<<9);
              break;
       case 960:
              blk = (chan*10+seq)*27+slot;
              i = (4*chan + (seq/5) + 2*blk + off[m])%10;
              k = (blk/5)%27 + (i&1)*3;
              x = shuf2[m] + k%6 + 6*(chan&1);
              y = l_start[i] + k/6 + 45*(chan>>1);
              tbl[m] = (x<<1)|(y<<9);
              break;
        case 720:
              switch (d->pix_fmt) {
              case PIX_FMT_YUV422P:
                   x = shuf3[m] + slot/3;
                   y = serpent1[slot] +
                       ((((seq + off[m]) % d->difseg_size)<<1) + chan)*3;
                   tbl[m] = (x<<1)|(y<<8);
                   break;
              case PIX_FMT_YUV420P:
                   x = shuf3[m] + slot/3;
                   y = serpent1[slot] +
                       ((seq + off[m]) % d->difseg_size)*3;
                   tbl[m] = (x<<1)|(y<<9);
                   break;
              case PIX_FMT_YUV411P:
                   i = (seq + off[m]) % d->difseg_size;
                   k = slot + ((m==1||m==2)?3:0);
                   x = l_start_shuffled[m] + k/6;
                   y = serpent2[k] + i*6;
                   if (x>21)
                       y = y*2 - i*6;
                   tbl[m] = (x<<2)|(y<<8);
                   break;
              }
        default:
              break;
        }
    }
}
['static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt,\n                                const AVFrame *frame, int *got_packet)\n{\n    DVVideoContext *s = c->priv_data;\n    int ret;\n    s->sys = avpriv_dv_codec_profile(c);\n    if (!s->sys || dv_init_dynamic_tables(s->sys))\n        return -1;\n    if ((ret = ff_alloc_packet(pkt, s->sys->frame_size)) < 0) {\n        av_log(c, AV_LOG_ERROR, "Error getting output packet.\\n");\n        return ret;\n    }\n    c->pix_fmt           = s->sys->pix_fmt;\n    s->picture           = *frame;\n    s->picture.key_frame = 1;\n    s->picture.pict_type = AV_PICTURE_TYPE_I;\n    s->buf = pkt->data;\n    c->execute(c, dv_encode_video_segment, s->sys->work_chunks, NULL,\n               dv_work_pool_size(s->sys), sizeof(DVwork_chunk));\n    emms_c();\n    dv_format_frame(s, pkt->data);\n    pkt->flags |= AV_PKT_FLAG_KEY;\n    *got_packet = 1;\n    return 0;\n}', 'static int dv_init_dynamic_tables(const DVprofile *d)\n{\n    int j,i,c,s,p;\n    uint32_t *factor1, *factor2;\n    const int *iweight1, *iweight2;\n    if (!d->work_chunks[dv_work_pool_size(d)-1].buf_offset) {\n        p = i = 0;\n        for (c=0; c<d->n_difchan; c++) {\n            for (s=0; s<d->difseg_size; s++) {\n                p += 6;\n                for (j=0; j<27; j++) {\n                    p += !(j%3);\n                    if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&\n                        !(DV_PROFILE_IS_720p50(d) && s > 9)) {\n                          dv_calc_mb_coordinates(d, c, s, j, &d->work_chunks[i].mb_coordinates[0]);\n                          d->work_chunks[i++].buf_offset = p;\n                    }\n                    p += 5;\n                }\n            }\n        }\n    }\n    if (!d->idct_factor[DV_PROFILE_IS_HD(d)?8191:5631]) {\n        factor1 = &d->idct_factor[0];\n        factor2 = &d->idct_factor[DV_PROFILE_IS_HD(d)?4096:2816];\n        if (d->height == 720) {\n            iweight1 = &dv_iweight_720_y[0];\n            iweight2 = &dv_iweight_720_c[0];\n        } else {\n            iweight1 = &dv_iweight_1080_y[0];\n            iweight2 = &dv_iweight_1080_c[0];\n        }\n        if (DV_PROFILE_IS_HD(d)) {\n            for (c = 0; c < 4; c++) {\n                for (s = 0; s < 16; s++) {\n                    for (i = 0; i < 64; i++) {\n                        *factor1++ = (dv100_qstep[s] << (c + 9)) * iweight1[i];\n                        *factor2++ = (dv100_qstep[s] << (c + 9)) * iweight2[i];\n                    }\n                }\n            }\n        } else {\n            iweight1 = &dv_iweight_88[0];\n            for (j = 0; j < 2; j++, iweight1 = &dv_iweight_248[0]) {\n                for (s = 0; s < 22; s++) {\n                    for (i = c = 0; c < 4; c++) {\n                        for (; i < dv_quant_areas[c]; i++) {\n                            *factor1   = iweight1[i] << (dv_quant_shifts[s][c] + 1);\n                            *factor2++ = (*factor1++) << 1;\n                        }\n                    }\n                }\n            }\n        }\n    }\n    return 0;\n}', 'static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,\n                                          uint16_t *tbl)\n{\n    static const uint8_t off[] = { 2, 6, 8, 0, 4 };\n    static const uint8_t shuf1[] = { 36, 18, 54, 0, 72 };\n    static const uint8_t shuf2[] = { 24, 12, 36, 0, 48 };\n    static const uint8_t shuf3[] = { 18, 9, 27, 0, 36 };\n    static const uint8_t l_start[] = {0, 4, 9, 13, 18, 22, 27, 31, 36, 40};\n    static const uint8_t l_start_shuffled[] = { 9, 4, 13, 0, 18 };\n    static const uint8_t serpent1[] = {0, 1, 2, 2, 1, 0,\n                                       0, 1, 2, 2, 1, 0,\n                                       0, 1, 2, 2, 1, 0,\n                                       0, 1, 2, 2, 1, 0,\n                                       0, 1, 2};\n    static const uint8_t serpent2[] = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0,\n                                       0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0,\n                                       0, 1, 2, 3, 4, 5};\n    static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0},\n                                       { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},\n                                       {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},\n                                       {20, 2}, {20, 3}, {30, 0}, {30, 1}, {30, 2},\n                                       {30, 3}, {40, 0}, {40, 1}, {40, 2}, {40, 3},\n                                       {50, 0}, {50, 1}, {50, 2}, {50, 3}, {60, 0},\n                                       {60, 1}, {60, 2}, {60, 3}, {70, 0}, {70, 1},\n                                       {70, 2}, {70, 3}, { 0,64}, { 0,65}, { 0,66},\n                                       {10,64}, {10,65}, {10,66}, {20,64}, {20,65},\n                                       {20,66}, {30,64}, {30,65}, {30,66}, {40,64},\n                                       {40,65}, {40,66}, {50,64}, {50,65}, {50,66},\n                                       {60,64}, {60,65}, {60,66}, {70,64}, {70,65},\n                                       {70,66}, { 0,67}, {20,67}, {40,67}, {60,67}};\n    int i, k, m;\n    int x, y, blk;\n    for (m=0; m<5; m++) {\n         switch (d->width) {\n         case 1440:\n              blk = (chan*11+seq)*27+slot;\n              if (chan == 0 && seq == 11) {\n                  x = m*27+slot;\n                  if (x<90) {\n                      y = 0;\n                  } else {\n                      x = (x - 90)*2;\n                      y = 67;\n                  }\n              } else {\n                  i = (4*chan + blk + off[m])%11;\n                  k = (blk/11)%27;\n                  x = shuf1[m] + (chan&1)*9 + k%9;\n                  y = (i*3+k/9)*2 + (chan>>1) + 1;\n              }\n              tbl[m] = (x<<1)|(y<<9);\n              break;\n         case 1280:\n              blk = (chan*10+seq)*27+slot;\n              i = (4*chan + (seq/5) + 2*blk + off[m])%10;\n              k = (blk/5)%27;\n              x = shuf1[m]+(chan&1)*9 + k%9;\n              y = (i*3+k/9)*2 + (chan>>1) + 4;\n              if (x >= 80) {\n                  x = remap[y][0]+((x-80)<<(y>59));\n                  y = remap[y][1];\n              }\n              tbl[m] = (x<<1)|(y<<9);\n              break;\n       case 960:\n              blk = (chan*10+seq)*27+slot;\n              i = (4*chan + (seq/5) + 2*blk + off[m])%10;\n              k = (blk/5)%27 + (i&1)*3;\n              x = shuf2[m] + k%6 + 6*(chan&1);\n              y = l_start[i] + k/6 + 45*(chan>>1);\n              tbl[m] = (x<<1)|(y<<9);\n              break;\n        case 720:\n              switch (d->pix_fmt) {\n              case PIX_FMT_YUV422P:\n                   x = shuf3[m] + slot/3;\n                   y = serpent1[slot] +\n                       ((((seq + off[m]) % d->difseg_size)<<1) + chan)*3;\n                   tbl[m] = (x<<1)|(y<<8);\n                   break;\n              case PIX_FMT_YUV420P:\n                   x = shuf3[m] + slot/3;\n                   y = serpent1[slot] +\n                       ((seq + off[m]) % d->difseg_size)*3;\n                   tbl[m] = (x<<1)|(y<<9);\n                   break;\n              case PIX_FMT_YUV411P:\n                   i = (seq + off[m]) % d->difseg_size;\n                   k = slot + ((m==1||m==2)?3:0);\n                   x = l_start_shuffled[m] + k/6;\n                   y = serpent2[k] + i*6;\n                   if (x>21)\n                       y = y*2 - i*6;\n                   tbl[m] = (x<<2)|(y<<8);\n                   break;\n              }\n        default:\n              break;\n        }\n    }\n}']