ffmpeg.c:1013: error: Buffer Overrun L2
  Offset: [0, 255] Size: 8 by call to `sws_scale`.

ffmpeg.c:879:1: Parameter `in_picture->data[*]`
877. static uint8_t *bit_buffer= NULL;
878. 
879. static void do_video_out(AVFormatContext *s,
     ^
880.                          AVOutputStream *ost,
881.                          AVInputStream *ist,

ffmpeg.c:1013:9: Call
1011.             }
1012.         }
1013.         sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
              ^
1014.               0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
1015.     }

libswscale/swscale.c:2965:14: <Offset trace>
2963. 
2964.     if (usePal(c->srcFormat)) {
2965.         for (i=0; i<256; i++) {
                   ^
2966.             int p, r, g, b,y,u,v;
2967.             if(c->srcFormat == PIX_FMT_PAL8) {

libswscale/swscale.c:2965:14: Assignment
  2963. 
  2964.     if (usePal(c->srcFormat)) {
  2965.         for (i=0; i<256; i++) {
                     ^
  2966.             int p, r, g, b,y,u,v;
  2967.             if(c->srcFormat == PIX_FMT_PAL8) {

libswscale/swscale.c:2945:1: <Length trace>
2943.  * Assumes planar YUV to be in YUV order instead of YVU.
2944.  */
2945. int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
      ^
2946.               int srcSliceH, uint8_t* dst[], int dstStride[])
2947. {

libswscale/swscale.c:2945:1: Parameter `**src`
  2943.  * Assumes planar YUV to be in YUV order instead of YVU.
  2944.  */
  2945. int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
        ^
  2946.               int srcSliceH, uint8_t* dst[], int dstStride[])
  2947. {

libswscale/swscale.c:2968:19: Array access: Offset: [0, 255] Size: 8 by call to `sws_scale` 
  2966.             int p, r, g, b,y,u,v;
  2967.             if(c->srcFormat == PIX_FMT_PAL8) {
  2968.                 p=((const uint32_t*)(src[1]))[i];
                          ^
  2969.                 r= (p>>16)&0xFF;
  2970.                 g= (p>> 8)&0xFF;

int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[])
{
    int i;
    const uint8_t* src2[4]= {src[0], src[1], src[2], src[3]};
    uint8_t* dst2[4]= {dst[0], dst[1], dst[2], dst[3]};
    if (srcSliceH == 0)
        return 0;
    if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
        av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
        return 0;
    }
    if (c->sliceDir == 0) {
        if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;
    }
    if (usePal(c->srcFormat)) {
        for (i=0; i<256; i++) {
            int p, r, g, b,y,u,v;
            if(c->srcFormat == PIX_FMT_PAL8) {
                p=((const uint32_t*)(src[1]))[i];
                r= (p>>16)&0xFF;
                g= (p>> 8)&0xFF;
                b=  p     &0xFF;
            } else if(c->srcFormat == PIX_FMT_RGB8) {
                r= (i>>5    )*36;
                g= ((i>>2)&7)*36;
                b= (i&3     )*85;
            } else if(c->srcFormat == PIX_FMT_BGR8) {
                b= (i>>6    )*85;
                g= ((i>>3)&7)*36;
                r= (i&7     )*36;
            } else if(c->srcFormat == PIX_FMT_RGB4_BYTE) {
                r= (i>>3    )*255;
                g= ((i>>1)&3)*85;
                b= (i&1     )*255;
            } else {
                assert(c->srcFormat == PIX_FMT_BGR4_BYTE);
                b= (i>>3    )*255;
                g= ((i>>1)&3)*85;
                r= (i&1     )*255;
            }
            y= av_clip_uint8((RY*r + GY*g + BY*b + ( 33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
            u= av_clip_uint8((RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
            v= av_clip_uint8((RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
            c->pal_yuv[i]= y + (u<<8) + (v<<16);
            switch(c->dstFormat) {
            case PIX_FMT_BGR32:
#if !HAVE_BIGENDIAN
            case PIX_FMT_RGB24:
#endif
                c->pal_rgb[i]=  r + (g<<8) + (b<<16);
                break;
            case PIX_FMT_BGR32_1:
#if HAVE_BIGENDIAN
            case PIX_FMT_BGR24:
#endif
                c->pal_rgb[i]= (r + (g<<8) + (b<<16)) << 8;
                break;
            case PIX_FMT_RGB32_1:
#if HAVE_BIGENDIAN
            case PIX_FMT_RGB24:
#endif
                c->pal_rgb[i]= (b + (g<<8) + (r<<16)) << 8;
                break;
            case PIX_FMT_RGB32:
#if !HAVE_BIGENDIAN
            case PIX_FMT_BGR24:
#endif
            default:
                c->pal_rgb[i]=  b + (g<<8) + (r<<16);
            }
        }
    }
    if (c->sliceDir == 1) {
        int srcStride2[4]= {srcStride[0], srcStride[1], srcStride[2], srcStride[3]};
        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2], dstStride[3]};
        reset_ptr(src2, c->srcFormat);
        reset_ptr((const uint8_t**)dst2, c->dstFormat);
        if (srcSliceY + srcSliceH == c->srcH)
            c->sliceDir = 0;
        return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2, dstStride2);
    } else {
        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2], -srcStride[3]};
        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2], -dstStride[3]};
        src2[0] += (srcSliceH-1)*srcStride[0];
        if (!usePal(c->srcFormat))
            src2[1] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1];
        src2[2] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2];
        src2[3] += (srcSliceH-1)*srcStride[3];
        dst2[0] += ( c->dstH                      -1)*dstStride[0];
        dst2[1] += ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1];
        dst2[2] += ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2];
        dst2[3] += ( c->dstH                      -1)*dstStride[3];
        reset_ptr(src2, c->srcFormat);
        reset_ptr((const uint8_t**)dst2, c->dstFormat);
        if (!srcSliceY)
            c->sliceDir = 0;
        return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);
    }
}
['static void do_video_out(AVFormatContext *s,\n                         AVOutputStream *ost,\n                         AVInputStream *ist,\n                         AVFrame *in_picture,\n                         int *frame_size)\n{\n    int nb_frames, i, ret;\n    int64_t topBand, bottomBand, leftBand, rightBand;\n    AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;\n    AVFrame picture_crop_temp, picture_pad_temp;\n    AVCodecContext *enc, *dec;\n    avcodec_get_frame_defaults(&picture_crop_temp);\n    avcodec_get_frame_defaults(&picture_pad_temp);\n    enc = ost->st->codec;\n    dec = ist->st->codec;\n    nb_frames = 1;\n    *frame_size = 0;\n    if(video_sync_method){\n        double vdelta;\n        vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts;\n        if (vdelta < -1.1)\n            nb_frames = 0;\n        else if (video_sync_method == 2 || (video_sync_method<0 && (s->oformat->flags & AVFMT_VARIABLE_FPS))){\n            if(vdelta<=-0.6){\n                nb_frames=0;\n            }else if(vdelta>0.6)\n            ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));\n        }else if (vdelta > 1.1)\n            nb_frames = lrintf(vdelta);\n        if (nb_frames == 0){\n            ++nb_frames_drop;\n            if (verbose>2)\n                fprintf(stderr, "*** drop!\\n");\n        }else if (nb_frames > 1) {\n            nb_frames_dup += nb_frames - 1;\n            if (verbose>2)\n                fprintf(stderr, "*** %d dup!\\n", nb_frames-1);\n        }\n    }else\n        ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));\n    nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);\n    if (nb_frames <= 0)\n        return;\n    if (ost->video_crop) {\n        if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {\n            fprintf(stderr, "error cropping picture\\n");\n            if (exit_on_error)\n                av_exit(1);\n            return;\n        }\n        formatted_picture = &picture_crop_temp;\n    } else {\n        formatted_picture = in_picture;\n    }\n    final_picture = formatted_picture;\n    padding_src = formatted_picture;\n    resampling_dst = &ost->pict_tmp;\n    if (ost->video_pad) {\n        final_picture = &ost->pict_tmp;\n        if (ost->video_resample) {\n            if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {\n                fprintf(stderr, "error padding picture\\n");\n                if (exit_on_error)\n                    av_exit(1);\n                return;\n            }\n            resampling_dst = &picture_pad_temp;\n        }\n    }\n    if(    (ost->resample_height != (ist->st->codec->height - (ost->topBand  + ost->bottomBand)))\n        || (ost->resample_width  != (ist->st->codec->width  - (ost->leftBand + ost->rightBand)))\n        || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {\n        fprintf(stderr,"Input Stream #%d.%d frame size changed to %dx%d, %s\\n", ist->file_index, ist->index, ist->st->codec->width,     ist->st->codec->height,avcodec_get_pix_fmt_name(ist->st->codec->pix_fmt));\n        if(!ost->video_resample)\n            av_exit(1);\n    }\n    if (ost->video_resample) {\n        padding_src = NULL;\n        final_picture = &ost->pict_tmp;\n        if(  (ost->resample_height != (ist->st->codec->height - (ost->topBand  + ost->bottomBand)))\n          || (ost->resample_width  != (ist->st->codec->width  - (ost->leftBand + ost->rightBand)))\n          || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {\n            topBand    = ((int64_t)ist->st->codec->height * ost->original_topBand    / ost->original_height) & ~1;\n            bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;\n            leftBand   = ((int64_t)ist->st->codec->width  * ost->original_leftBand   / ost->original_width)  & ~1;\n            rightBand  = ((int64_t)ist->st->codec->width  * ost->original_rightBand  / ost->original_width)  & ~1;\n            assert(topBand    <= INT_MAX && topBand    >= 0);\n            assert(bottomBand <= INT_MAX && bottomBand >= 0);\n            assert(leftBand   <= INT_MAX && leftBand   >= 0);\n            assert(rightBand  <= INT_MAX && rightBand  >= 0);\n            ost->topBand    = topBand;\n            ost->bottomBand = bottomBand;\n            ost->leftBand   = leftBand;\n            ost->rightBand  = rightBand;\n            ost->resample_height = ist->st->codec->height - (ost->topBand  + ost->bottomBand);\n            ost->resample_width  = ist->st->codec->width  - (ost->leftBand + ost->rightBand);\n            ost->resample_pix_fmt= ist->st->codec->pix_fmt;\n            sws_freeContext(ost->img_resample_ctx);\n            sws_flags = av_get_int(sws_opts, "sws_flags", NULL);\n            ost->img_resample_ctx = sws_getContext(\n                ist->st->codec->width  - (ost->leftBand + ost->rightBand),\n                ist->st->codec->height - (ost->topBand  + ost->bottomBand),\n                ist->st->codec->pix_fmt,\n                ost->st->codec->width  - (ost->padleft  + ost->padright),\n                ost->st->codec->height - (ost->padtop   + ost->padbottom),\n                ost->st->codec->pix_fmt,\n                sws_flags, NULL, NULL, NULL);\n            if (ost->img_resample_ctx == NULL) {\n                fprintf(stderr, "Cannot get resampling context\\n");\n                av_exit(1);\n            }\n        }\n        sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,\n              0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);\n    }\n    if (ost->video_pad) {\n        av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,\n                enc->height, enc->width, enc->pix_fmt,\n                ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);\n    }\n    for(i=0;i<nb_frames;i++) {\n        AVPacket pkt;\n        av_init_packet(&pkt);\n        pkt.stream_index= ost->index;\n        if (s->oformat->flags & AVFMT_RAWPICTURE) {\n            AVFrame* old_frame = enc->coded_frame;\n            enc->coded_frame = dec->coded_frame;\n            pkt.data= (uint8_t *)final_picture;\n            pkt.size=  sizeof(AVPicture);\n            pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);\n            pkt.flags |= PKT_FLAG_KEY;\n            write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);\n            enc->coded_frame = old_frame;\n        } else {\n            AVFrame big_picture;\n            big_picture= *final_picture;\n            big_picture.interlaced_frame = in_picture->interlaced_frame;\n            if(avcodec_opts[CODEC_TYPE_VIDEO]->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)){\n                if(top_field_first == -1)\n                    big_picture.top_field_first = in_picture->top_field_first;\n                else\n                    big_picture.top_field_first = top_field_first;\n            }\n            if (same_quality) {\n                big_picture.quality = ist->st->quality;\n            }else\n                big_picture.quality = ost->st->quality;\n            if(!me_threshold)\n                big_picture.pict_type = 0;\n            big_picture.pts= ost->sync_opts;\n            ret = avcodec_encode_video(enc,\n                                       bit_buffer, bit_buffer_size,\n                                       &big_picture);\n            if (ret < 0) {\n                fprintf(stderr, "Video encoding failed\\n");\n                av_exit(1);\n            }\n            if(ret>0){\n                pkt.data= bit_buffer;\n                pkt.size= ret;\n                if(enc->coded_frame->pts != AV_NOPTS_VALUE)\n                    pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);\n                if(enc->coded_frame->key_frame)\n                    pkt.flags |= PKT_FLAG_KEY;\n                write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);\n                *frame_size = ret;\n                video_size += ret;\n                if (ost->logfile && enc->stats_out) {\n                    fprintf(ost->logfile, "%s", enc->stats_out);\n                }\n            }\n        }\n        ost->sync_opts++;\n        ost->frame_number++;\n    }\n}', 'int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,\n              int srcSliceH, uint8_t* dst[], int dstStride[])\n{\n    int i;\n    const uint8_t* src2[4]= {src[0], src[1], src[2], src[3]};\n    uint8_t* dst2[4]= {dst[0], dst[1], dst[2], dst[3]};\n    if (srcSliceH == 0)\n        return 0;\n    if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {\n        av_log(c, AV_LOG_ERROR, "Slices start in the middle!\\n");\n        return 0;\n    }\n    if (c->sliceDir == 0) {\n        if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1;\n    }\n    if (usePal(c->srcFormat)) {\n        for (i=0; i<256; i++) {\n            int p, r, g, b,y,u,v;\n            if(c->srcFormat == PIX_FMT_PAL8) {\n                p=((const uint32_t*)(src[1]))[i];\n                r= (p>>16)&0xFF;\n                g= (p>> 8)&0xFF;\n                b=  p     &0xFF;\n            } else if(c->srcFormat == PIX_FMT_RGB8) {\n                r= (i>>5    )*36;\n                g= ((i>>2)&7)*36;\n                b= (i&3     )*85;\n            } else if(c->srcFormat == PIX_FMT_BGR8) {\n                b= (i>>6    )*85;\n                g= ((i>>3)&7)*36;\n                r= (i&7     )*36;\n            } else if(c->srcFormat == PIX_FMT_RGB4_BYTE) {\n                r= (i>>3    )*255;\n                g= ((i>>1)&3)*85;\n                b= (i&1     )*255;\n            } else {\n                assert(c->srcFormat == PIX_FMT_BGR4_BYTE);\n                b= (i>>3    )*255;\n                g= ((i>>1)&3)*85;\n                r= (i&1     )*255;\n            }\n            y= av_clip_uint8((RY*r + GY*g + BY*b + ( 33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);\n            u= av_clip_uint8((RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);\n            v= av_clip_uint8((RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);\n            c->pal_yuv[i]= y + (u<<8) + (v<<16);\n            switch(c->dstFormat) {\n            case PIX_FMT_BGR32:\n#if !HAVE_BIGENDIAN\n            case PIX_FMT_RGB24:\n#endif\n                c->pal_rgb[i]=  r + (g<<8) + (b<<16);\n                break;\n            case PIX_FMT_BGR32_1:\n#if HAVE_BIGENDIAN\n            case PIX_FMT_BGR24:\n#endif\n                c->pal_rgb[i]= (r + (g<<8) + (b<<16)) << 8;\n                break;\n            case PIX_FMT_RGB32_1:\n#if HAVE_BIGENDIAN\n            case PIX_FMT_RGB24:\n#endif\n                c->pal_rgb[i]= (b + (g<<8) + (r<<16)) << 8;\n                break;\n            case PIX_FMT_RGB32:\n#if !HAVE_BIGENDIAN\n            case PIX_FMT_BGR24:\n#endif\n            default:\n                c->pal_rgb[i]=  b + (g<<8) + (r<<16);\n            }\n        }\n    }\n    if (c->sliceDir == 1) {\n        int srcStride2[4]= {srcStride[0], srcStride[1], srcStride[2], srcStride[3]};\n        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2], dstStride[3]};\n        reset_ptr(src2, c->srcFormat);\n        reset_ptr((const uint8_t**)dst2, c->dstFormat);\n        if (srcSliceY + srcSliceH == c->srcH)\n            c->sliceDir = 0;\n        return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst2, dstStride2);\n    } else {\n        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2], -srcStride[3]};\n        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2], -dstStride[3]};\n        src2[0] += (srcSliceH-1)*srcStride[0];\n        if (!usePal(c->srcFormat))\n            src2[1] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1];\n        src2[2] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2];\n        src2[3] += (srcSliceH-1)*srcStride[3];\n        dst2[0] += ( c->dstH                      -1)*dstStride[0];\n        dst2[1] += ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1];\n        dst2[2] += ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2];\n        dst2[3] += ( c->dstH                      -1)*dstStride[3];\n        reset_ptr(src2, c->srcFormat);\n        reset_ptr((const uint8_t**)dst2, c->dstFormat);\n        if (!srcSliceY)\n            c->sliceDir = 0;\n        return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);\n    }\n}']