libavformat/dv.c:439: error: Buffer Overrun L2
  Offset: [0, 7] Size: 3 by call to `dv_produce_packet`.

libavformat/dv.c:436:13: Call
434.             return AVERROR(EIO);
435.         size = c->dv_demux->sys->frame_size;
436.         if (get_buffer(s->pb, c->buf, size) <= 0)
                 ^
437.             return AVERROR(EIO);
438. 

libavformat/aviobuf.c:377:1: Parameter `*buf`
  375. }
  376. 
  377. int get_buffer(ByteIOContext *s, unsigned char *buf, int size)
       ^
  378. {
  379.     int len, size1;

libavformat/dv.c:439:16: Call
437.             return AVERROR(EIO);
438. 
439.         size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);
                    ^
440.     }
441. 

libavformat/dv.c:317:1: Parameter `*buf`
  315. }
  316. 
  317. int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
       ^
  318.                       uint8_t* buf, int buf_size)
  319. {

libavformat/dv.c:324:20: Call
  322. 
  323.     if (buf_size < DV_PROFILE_BYTES ||
  324.         !(c->sys = dv_frame_profile(buf)) ||
                          ^
  325.         buf_size < c->sys->frame_size) {
  326.           return -1;   /* Broken frame, or not enough data */

libavcodec/dvdata.h:701:1: Parameter `*frame`
    699. #define DV_MAX_BPM 8
    700. 
    701. static inline const DVprofile* dv_frame_profile(const uint8_t* frame)
         ^
    702. {
    703.    int i;

libavformat/dv.c:337:5: Call
  335.        ppcm[i] = c->audio_buf[i];
  336.     }
  337.     dv_extract_audio(buf, ppcm, c->sys);
           ^
  338.     c->abytes += size;
  339. 

libavformat/dv.c:102:1: <Offset trace>
100.  *    are converted into 16bit linear ones.
101.  */
102. static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
     ^
103.                             const DVprofile *sys)
104. {

libavformat/dv.c:102:1: Parameter `*frame`
    100.  *    are converted into 16bit linear ones.
    101.  */
    102. static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
         ^
    103.                             const DVprofile *sys)
    104. {

libavformat/dv.c:110:15: Call
    108.     uint8_t *pcm, ipcm;
    109. 
    110.     as_pack = dv_extract_pack(frame, dv_audio_source);
                       ^
    111.     if (!as_pack)    /* No audio ? */
    112.         return 0;

libavformat/dv.c:73:1: Parameter `t`
      71.  * to have a fallback mechanism for complete search of missing packs.
      72.  */
      73. static const uint8_t* dv_extract_pack(uint8_t* frame, enum dv_pack_type t)
          ^
      74. {
      75.     int offs;

libavformat/dv.c:115:5: Assignment
    113. 
    114.     smpls =  as_pack[1] & 0x3f;       /* samples in this frame - min. samples */
    115.     freq  = (as_pack[4] >> 3) & 0x07; /* 0 - 48kHz, 1 - 44,1kHz, 2 - 32kHz */
             ^
    116.     quant =  as_pack[4] & 0x07;       /* 0 - 16bit linear, 1 - 12bit nonlinear */
    117. 

libavformat/dv.c:102:1: <Length trace>
100.  *    are converted into 16bit linear ones.
101.  */
102. static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
     ^
103.                             const DVprofile *sys)
104. {

libavformat/dv.c:102:1: Parameter `sys->audio_min_samples[*]`
    100.  *    are converted into 16bit linear ones.
    101.  */
    102. static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
         ^
    103.                             const DVprofile *sys)
    104. {

libavformat/dv.c:121:13: Array access: Offset: [0, 7] Size: 3 by call to `dv_produce_packet` 
    119.         return -1; /* unsupported quantization */
    120. 
    121.     size = (sys->audio_min_samples[freq] + smpls) * 4; /* 2ch, 2bytes */
                     ^
    122.     half_ch = sys->difseg_size / 2;
    123. 

static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],
                            const DVprofile *sys)
{
    int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
    uint16_t lc, rc;
    const uint8_t* as_pack;
    uint8_t *pcm, ipcm;
    as_pack = dv_extract_pack(frame, dv_audio_source);
    if (!as_pack)
        return 0;
    smpls =  as_pack[1] & 0x3f;
    freq  = (as_pack[4] >> 3) & 0x07;
    quant =  as_pack[4] & 0x07;
    if (quant > 1)
        return -1;
    size = (sys->audio_min_samples[freq] + smpls) * 4;
    half_ch = sys->difseg_size / 2;
    ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;
    pcm  = ppcm[ipcm++];
    for (chan = 0; chan < sys->n_difchan; chan++) {
        for (i = 0; i < sys->difseg_size; i++) {
            frame += 6 * 80;
            if (quant == 1 && i == half_ch) {
                pcm = ppcm[ipcm++];
                if (!pcm)
                    break;
            }
            for (j = 0; j < 9; j++) {
                for (d = 8; d < 80; d += 2) {
                    if (quant == 0) {
                        of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride;
                        if (of*2 >= size)
                            continue;
                        pcm[of*2]   = frame[d+1];
                        pcm[of*2+1] = frame[d];
                        if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)
                            pcm[of*2+1] = 0;
                    } else {
                        lc = ((uint16_t)frame[d]   << 4) |
                             ((uint16_t)frame[d+2] >> 4);
                        rc = ((uint16_t)frame[d+1] << 4) |
                             ((uint16_t)frame[d+2] & 0x0f);
                        lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));
                        rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));
                        of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride;
                        if (of*2 >= size)
                            continue;
                        pcm[of*2]   = lc & 0xff;
                        pcm[of*2+1] = lc >> 8;
                        of = sys->audio_shuffle[i%half_ch+half_ch][j] +
                            (d - 8) / 3 * sys->audio_stride;
                        pcm[of*2]   = rc & 0xff;
                        pcm[of*2+1] = rc >> 8;
                        ++d;
                    }
                }
                frame += 16 * 80;
            }
        }
        pcm = ppcm[ipcm++];
        if (!pcm)
            break;
    }
    return size;
}
['static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)\n{\n    int size;\n    RawDVContext *c = s->priv_data;\n    size = dv_get_packet(c->dv_demux, pkt);\n    if (size < 0) {\n        if (!c->dv_demux->sys)\n            return AVERROR(EIO);\n        size = c->dv_demux->sys->frame_size;\n        if (get_buffer(s->pb, c->buf, size) <= 0)\n            return AVERROR(EIO);\n        size = dv_produce_packet(c->dv_demux, pkt, c->buf, size);\n    }\n    return size;\n}', 'int get_buffer(ByteIOContext *s, unsigned char *buf, int size)\n{\n    int len, size1;\n    size1 = size;\n    while (size > 0) {\n        len = s->buf_end - s->buf_ptr;\n        if (len > size)\n            len = size;\n        if (len == 0) {\n            if(size > s->buffer_size && !s->update_checksum){\n                if(s->read_packet)\n                    len = s->read_packet(s->opaque, buf, size);\n                if (len <= 0) {\n                    s->eof_reached = 1;\n                    if(len<0)\n                        s->error= len;\n                    break;\n                } else {\n                    s->pos += len;\n                    size -= len;\n                    buf += len;\n                    s->buf_ptr = s->buffer;\n                    s->buf_end = s->buffer ;\n                }\n            }else{\n                fill_buffer(s);\n                len = s->buf_end - s->buf_ptr;\n                if (len == 0)\n                    break;\n            }\n        } else {\n            memcpy(buf, s->buf_ptr, len);\n            buf += len;\n            s->buf_ptr += len;\n            size -= len;\n        }\n    }\n    return size1 - size;\n}', 'int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,\n                      uint8_t* buf, int buf_size)\n{\n    int size, i;\n    uint8_t *ppcm[4] = {0};\n    if (buf_size < DV_PROFILE_BYTES ||\n        !(c->sys = dv_frame_profile(buf)) ||\n        buf_size < c->sys->frame_size) {\n          return -1;\n    }\n    size = dv_extract_audio_info(c, buf);\n    for (i = 0; i < c->ach; i++) {\n       c->audio_pkt[i].size = size;\n       c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;\n       ppcm[i] = c->audio_buf[i];\n    }\n    dv_extract_audio(buf, ppcm, c->sys);\n    c->abytes += size;\n    if (c->sys->height == 720) {\n        if (buf[1] & 0x0C)\n            c->audio_pkt[2].size = c->audio_pkt[3].size = 0;\n        else\n            c->audio_pkt[0].size = c->audio_pkt[1].size = 0;\n    }\n    size = dv_extract_video_info(c, buf);\n    av_init_packet(pkt);\n    pkt->data         = buf;\n    pkt->size         = size;\n    pkt->flags       |= PKT_FLAG_KEY;\n    pkt->stream_index = c->vst->id;\n    pkt->pts          = c->frames;\n    c->frames++;\n    return size;\n}', 'static inline const DVprofile* dv_frame_profile(const uint8_t* frame)\n{\n   int i;\n   int dsf = (frame[3] & 0x80) >> 7;\n   int stype = frame[80*5 + 48 + 3] & 0x1f;\n   if (dsf == 1 && stype == 0 && frame[5] & 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   return NULL;\n}', 'static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4],\n                            const DVprofile *sys)\n{\n    int size, chan, i, j, d, of, smpls, freq, quant, half_ch;\n    uint16_t lc, rc;\n    const uint8_t* as_pack;\n    uint8_t *pcm, ipcm;\n    as_pack = dv_extract_pack(frame, dv_audio_source);\n    if (!as_pack)\n        return 0;\n    smpls =  as_pack[1] & 0x3f;\n    freq  = (as_pack[4] >> 3) & 0x07;\n    quant =  as_pack[4] & 0x07;\n    if (quant > 1)\n        return -1;\n    size = (sys->audio_min_samples[freq] + smpls) * 4;\n    half_ch = sys->difseg_size / 2;\n    ipcm = (sys->height == 720 && !(frame[1] & 0x0C)) ? 2 : 0;\n    pcm  = ppcm[ipcm++];\n    for (chan = 0; chan < sys->n_difchan; chan++) {\n        for (i = 0; i < sys->difseg_size; i++) {\n            frame += 6 * 80;\n            if (quant == 1 && i == half_ch) {\n                pcm = ppcm[ipcm++];\n                if (!pcm)\n                    break;\n            }\n            for (j = 0; j < 9; j++) {\n                for (d = 8; d < 80; d += 2) {\n                    if (quant == 0) {\n                        of = sys->audio_shuffle[i][j] + (d - 8) / 2 * sys->audio_stride;\n                        if (of*2 >= size)\n                            continue;\n                        pcm[of*2]   = frame[d+1];\n                        pcm[of*2+1] = frame[d];\n                        if (pcm[of*2+1] == 0x80 && pcm[of*2] == 0x00)\n                            pcm[of*2+1] = 0;\n                    } else {\n                        lc = ((uint16_t)frame[d]   << 4) |\n                             ((uint16_t)frame[d+2] >> 4);\n                        rc = ((uint16_t)frame[d+1] << 4) |\n                             ((uint16_t)frame[d+2] & 0x0f);\n                        lc = (lc == 0x800 ? 0 : dv_audio_12to16(lc));\n                        rc = (rc == 0x800 ? 0 : dv_audio_12to16(rc));\n                        of = sys->audio_shuffle[i%half_ch][j] + (d - 8) / 3 * sys->audio_stride;\n                        if (of*2 >= size)\n                            continue;\n                        pcm[of*2]   = lc & 0xff;\n                        pcm[of*2+1] = lc >> 8;\n                        of = sys->audio_shuffle[i%half_ch+half_ch][j] +\n                            (d - 8) / 3 * sys->audio_stride;\n                        pcm[of*2]   = rc & 0xff;\n                        pcm[of*2+1] = rc >> 8;\n                        ++d;\n                    }\n                }\n                frame += 16 * 80;\n            }\n        }\n        pcm = ppcm[ipcm++];\n        if (!pcm)\n            break;\n    }\n    return size;\n}', 'static const uint8_t* dv_extract_pack(uint8_t* frame, enum dv_pack_type t)\n{\n    int offs;\n    switch (t) {\n    case dv_audio_source:\n        offs = (80*6 + 80*16*3 + 3);\n        break;\n    case dv_audio_control:\n        offs = (80*6 + 80*16*4 + 3);\n        break;\n    case dv_video_control:\n        offs = (80*5 + 48 + 5);\n        break;\n    default:\n        return NULL;\n    }\n    return frame[offs] == t ? &frame[offs] : NULL;\n}']