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

ffmpeg.c:830:1: Parameter `in_picture->data[*]`
828. static uint8_t *bit_buffer= NULL;
829. 
830. static void do_video_out(AVFormatContext *s,
     ^
831.                          AVOutputStream *ost,
832.                          AVInputStream *ist,

ffmpeg.c:913:9: Call
911.         padding_src = NULL;
912.         final_picture = &ost->pict_tmp;
913.         sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
             ^
914.               0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
915.     }

libswscale/swscale.c:2740:14: <Offset trace>
2738. 
2739.     if (usePal(c->srcFormat)){
2740.         for (i=0; i<256; i++){
                   ^
2741.             int p, r, g, b,y,u,v;
2742.             if(c->srcFormat == PIX_FMT_PAL8){

libswscale/swscale.c:2740:14: Assignment
  2738. 
  2739.     if (usePal(c->srcFormat)){
  2740.         for (i=0; i<256; i++){
                     ^
  2741.             int p, r, g, b,y,u,v;
  2742.             if(c->srcFormat == PIX_FMT_PAL8){

libswscale/swscale.c:2726:1: <Length trace>
2724.  * Assumes planar YUV to be in YUV order instead of YVU.
2725.  */
2726. int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
      ^
2727.               int srcSliceH, uint8_t* dst[], int dstStride[]){
2728.     int i;

libswscale/swscale.c:2726:1: Parameter `**src`
  2724.  * Assumes planar YUV to be in YUV order instead of YVU.
  2725.  */
  2726. int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
        ^
  2727.               int srcSliceH, uint8_t* dst[], int dstStride[]){
  2728.     int i;

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

int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]){
    int i;
    uint8_t* src2[4]= {src[0], src[1], src[2]};
    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=((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:
#ifndef WORDS_BIGENDIAN
            case PIX_FMT_RGB24:
#endif
                c->pal_rgb[i]=  r + (g<<8) + (b<<16);
                break;
            case PIX_FMT_BGR32_1:
#ifdef  WORDS_BIGENDIAN
            case PIX_FMT_BGR24:
#endif
                c->pal_rgb[i]= (r + (g<<8) + (b<<16)) << 8;
                break;
            case PIX_FMT_RGB32_1:
#ifdef  WORDS_BIGENDIAN
            case PIX_FMT_RGB24:
#endif
                c->pal_rgb[i]= (b + (g<<8) + (r<<16)) << 8;
                break;
            case PIX_FMT_RGB32:
#ifndef WORDS_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]};
        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2]};
        return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
    } else {
        uint8_t* dst2[4]= {dst[0] + (c->dstH-1)*dstStride[0],
                           dst[1] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1],
                           dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2]};
        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2]};
        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]};
        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];
        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    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>0 || (video_sync_method && av_q2d(enc->time_base) > 0.001)){\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;\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->video_resample) {\n        padding_src = NULL;\n        final_picture = &ost->pict_tmp;\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, uint8_t* src[], int srcStride[], int srcSliceY,\n              int srcSliceH, uint8_t* dst[], int dstStride[]){\n    int i;\n    uint8_t* src2[4]= {src[0], src[1], src[2]};\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=((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#ifndef WORDS_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#ifdef  WORDS_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#ifdef  WORDS_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#ifndef WORDS_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]};\n        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2]};\n        return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);\n    } else {\n        uint8_t* dst2[4]= {dst[0] + (c->dstH-1)*dstStride[0],\n                           dst[1] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1],\n                           dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2]};\n        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2]};\n        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]};\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        return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);\n    }\n}']