libavcodec/dvdec.c:323: error: Buffer Overrun L3
  Offset: [-54, +oo] Size: 64 by call to `ff_dv_init_dynamic_tables`.

libavcodec/dvdec.c:322:14: Call
320.     int apt, is16_9;
321. 
322.     s->sys = avpriv_dv_frame_profile(s->sys, buf, buf_size);
                  ^
323.     if (!s->sys || buf_size < s->sys->frame_size || ff_dv_init_dynamic_tables(s->sys)) {
324.         av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");

libavcodec/dvdata.c:380:1: Parameter `buf_size`
  378. };
  379. 
  380. const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,
       ^
  381.                                   const uint8_t* frame, unsigned buf_size)
  382. {

libavcodec/dvdec.c:323:53: Call
321. 
322.     s->sys = avpriv_dv_frame_profile(s->sys, buf, buf_size);
323.     if (!s->sys || buf_size < s->sys->frame_size || ff_dv_init_dynamic_tables(s->sys)) {
                                                         ^
324.         av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n");
325.         return -1; /* NOTE: we only accept several full frames */

libavcodec/dv.c:178:1: Parameter `d->n_difchan`
  176. static const uint8_t dv_quant_areas[4]  = { 6, 21, 43, 64 };
  177. 
  178. int ff_dv_init_dynamic_tables(const DVprofile *d)
       ^
  179. {
  180.     int j,i,c,s,p;

libavcodec/dv.c:193:27: Call
  191.                     if (!(DV_PROFILE_IS_1080i50(d) && c != 0 && s == 11) &&
  192.                         !(DV_PROFILE_IS_720p50(d) && s > 9)) {
  193.                           dv_calc_mb_coordinates(d, c, s, j, &d->work_chunks[i].mb_coordinates[0]);
                                 ^
  194.                           d->work_chunks[i++].buf_offset = p;
  195.                     }

libavcodec/dv.c:54:1: <Offset trace>
52. RL_VLC_ELEM ff_dv_rl_vlc[1184];
53. 
54. static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,
    ^
55.                                           uint16_t *tbl)
56. {

libavcodec/dv.c:54:1: Parameter `chan`
    52. RL_VLC_ELEM ff_dv_rl_vlc[1184];
    53. 
    54. static inline void dv_calc_mb_coordinates(const DVprofile *d, int chan, int seq, int slot,
        ^
    55.                                           uint16_t *tbl)
    56. {

libavcodec/dv.c:120:15: Assignment
    118. 
    119.               x = shuf1[m]+(chan&1)*9 + k%9;
    120.               y = (i*3+k/9)*2 + (chan>>1) + 4;
                       ^
    121. 
    122.               if (x >= 80) {

libavcodec/dv.c:74:5: <Length trace>
72.                                        0, 1, 2, 3, 4, 5};
73. 
74.     static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, /* dummy */
        ^
75.                                        { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},
76.                                        {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},

libavcodec/dv.c:74:5: Array declaration
    72.                                        0, 1, 2, 3, 4, 5};
    73. 
    74.     static const uint8_t remap[][2] = {{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}, /* dummy */
            ^
    75.                                        { 0, 0}, { 0, 1}, { 0, 2}, { 0, 3}, {10, 0},
    76.                                        {10, 1}, {10, 2}, {10, 3}, {20, 0}, {20, 1},

libavcodec/dv.c:123:23: Array access: Offset: [-54, +oo] Size: 64 by call to `ff_dv_init_dynamic_tables` 
    121. 
    122.               if (x >= 80) {
    123.                   x = remap[y][0]+((x-80)<<(y>59));
                               ^
    124.                   y = remap[y][1];
    125.               }

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_decode_frame(AVCodecContext *avctx,\n                                 void *data, int *data_size,\n                                 AVPacket *avpkt)\n{\n    const uint8_t *buf = avpkt->data;\n    int buf_size = avpkt->size;\n    DVVideoContext *s = avctx->priv_data;\n    const uint8_t* vsc_pack;\n    int apt, is16_9;\n    s->sys = avpriv_dv_frame_profile(s->sys, buf, buf_size);\n    if (!s->sys || buf_size < s->sys->frame_size || ff_dv_init_dynamic_tables(s->sys)) {\n        av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\\n");\n        return -1;\n    }\n    if (s->picture.data[0])\n        avctx->release_buffer(avctx, &s->picture);\n    s->picture.reference = 0;\n    s->picture.key_frame = 1;\n    s->picture.pict_type = AV_PICTURE_TYPE_I;\n    avctx->pix_fmt   = s->sys->pix_fmt;\n    avctx->time_base = s->sys->time_base;\n    avcodec_set_dimensions(avctx, s->sys->width, s->sys->height);\n    if (avctx->get_buffer(avctx, &s->picture) < 0) {\n        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\\n");\n        return -1;\n    }\n    s->picture.interlaced_frame = 1;\n    s->picture.top_field_first  = 0;\n    s->buf = buf;\n    avctx->execute(avctx, dv_decode_video_segment, s->sys->work_chunks, NULL,\n                   dv_work_pool_size(s->sys), sizeof(DVwork_chunk));\n    emms_c();\n    *data_size = sizeof(AVFrame);\n    *(AVFrame*)data = s->picture;\n    vsc_pack = buf + 80*5 + 48 + 5;\n    if ( *vsc_pack == dv_video_control ) {\n        apt = buf[4] & 0x07;\n        is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));\n        avctx->sample_aspect_ratio = s->sys->sar[is16_9];\n    }\n    return s->sys->frame_size;\n}', 'const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys,\n                                  const uint8_t* frame, unsigned buf_size)\n{\n    int i, dsf, stype;\n    if (buf_size < 80 * 5 + 48 + 4)\n        return NULL;\n    dsf = (frame[3] & 0x80) >> 7;\n    stype = frame[80 * 5 + 48 + 3] & 0x1f;\n    if (dsf == 1 && stype == 0 && frame[4] & 0x07  ) {\n        return &dv_profiles[2];\n    }\n    for (i = 0; i < FF_ARRAY_ELEMS(dv_profiles); i++)\n        if (dsf == dv_profiles[i].dsf && stype == dv_profiles[i].video_stype)\n            return &dv_profiles[i];\n    if (sys && buf_size == sys->frame_size)\n        return sys;\n    return NULL;\n}', 'int ff_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 = &ff_dv_iweight_720_y[0];\n            iweight2 = &ff_dv_iweight_720_c[0];\n        } else {\n            iweight1 = &ff_dv_iweight_1080_y[0];\n            iweight2 = &ff_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 = &ff_dv_iweight_88[0];\n            for (j = 0; j < 2; j++, iweight1 = &ff_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] << (ff_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}']