libavcodec/ffv1.c:661: error: Buffer Overrun L2
  Offset: [2, 4] (⇐ [0, 2] + 2) Size: 3 by call to `encode_line`.

libavcodec/ffv1.c:627:1: Array declaration
625. }
626. 
627. static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){
     ^
628.     int x, y, p, i;
629.     const int ring_size= s->avctx->context_model ? 3 : 2;

libavcodec/ffv1.c:661:13: Call
659.             sample[p][0][-1]= sample[p][1][0  ];
660.             sample[p][1][ w]= sample[p][1][w-1];
661.             encode_line(s, w, sample[p], FFMIN(p, 1), 9);
                 ^
662.         }
663.     }

libavcodec/ffv1.c:512:1: <Length trace>
510. 
511. #if CONFIG_FFV1_ENCODER
512. static av_always_inline int encode_line(FFV1Context *s, int w,
     ^
513.                                         int16_t *sample[2],
514.                                         int plane_index, int bits)

libavcodec/ffv1.c:512:1: Parameter `*sample`
  510. 
  511. #if CONFIG_FFV1_ENCODER
  512. static av_always_inline int encode_line(FFV1Context *s, int w,
       ^
  513.                                         int16_t *sample[2],
  514.                                         int plane_index, int bits)

libavcodec/ffv1.c:538:59: Array access: Offset: [2, 4] (⇐ [0, 2] + 2) Size: 3 by call to `encode_line` 
  536.         int diff, context;
  537. 
  538.         context= get_context(p, sample[0]+x, sample[1]+x, sample[2]+x);
                                                                 ^
  539.         diff= sample[0][x] - predict(sample[0]+x, sample[1]+x);
  540. 

static av_always_inline int encode_line(FFV1Context *s, int w,
                                        int16_t *sample[2],
                                        int plane_index, int bits)
{
    PlaneContext * const p= &s->plane[plane_index];
    RangeCoder * const c= &s->c;
    int x;
    int run_index= s->run_index;
    int run_count=0;
    int run_mode=0;
    if(s->ac){
        if(c->bytestream_end - c->bytestream < w*20){
            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
            return -1;
        }
    }else{
        if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < w*4){
            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n");
            return -1;
        }
    }
    for(x=0; x<w; x++){
        int diff, context;
        context= get_context(p, sample[0]+x, sample[1]+x, sample[2]+x);
        diff= sample[0][x] - predict(sample[0]+x, sample[1]+x);
        if(context < 0){
            context = -context;
            diff= -diff;
        }
        diff= fold(diff, bits);
        if(s->ac){
            if(s->flags & CODEC_FLAG_PASS1){
                put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, s->rc_stat2[p->quant_table_index][context]);
            }else{
                put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL);
            }
        }else{
            if(context == 0) run_mode=1;
            if(run_mode){
                if(diff){
                    while(run_count >= 1<<ff_log2_run[run_index]){
                        run_count -= 1<<ff_log2_run[run_index];
                        run_index++;
                        put_bits(&s->pb, 1, 1);
                    }
                    put_bits(&s->pb, 1 + ff_log2_run[run_index], run_count);
                    if(run_index) run_index--;
                    run_count=0;
                    run_mode=0;
                    if(diff>0) diff--;
                }else{
                    run_count++;
                }
            }
            if(run_mode == 0)
                put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits);
        }
    }
    if(run_mode){
        while(run_count >= 1<<ff_log2_run[run_index]){
            run_count -= 1<<ff_log2_run[run_index];
            run_index++;
            put_bits(&s->pb, 1, 1);
        }
        if(run_count)
            put_bits(&s->pb, 1, 1);
    }
    s->run_index= run_index;
    return 0;
}
['static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){\n    int x, y, p, i;\n    const int ring_size= s->avctx->context_model ? 3 : 2;\n    int16_t *sample[3][3];\n    s->run_index=0;\n    memset(s->sample_buffer, 0, ring_size*3*(w+6)*sizeof(*s->sample_buffer));\n    for(y=0; y<h; y++){\n        for(i=0; i<ring_size; i++)\n            for(p=0; p<3; p++)\n                sample[p][i]= s->sample_buffer + p*ring_size*(w+6) + ((h+i-y)%ring_size)*(w+6) + 3;\n        for(x=0; x<w; x++){\n            int v= src[x + stride*y];\n            int b= v&0xFF;\n            int g= (v>>8)&0xFF;\n            int r= (v>>16)&0xFF;\n            b -= g;\n            r -= g;\n            g += (b + r)>>2;\n            b += 0x100;\n            r += 0x100;\n            sample[0][0][x]= g;\n            sample[1][0][x]= b;\n            sample[2][0][x]= r;\n        }\n        for(p=0; p<3; p++){\n            sample[p][0][-1]= sample[p][1][0  ];\n            sample[p][1][ w]= sample[p][1][w-1];\n            encode_line(s, w, sample[p], FFMIN(p, 1), 9);\n        }\n    }\n}', 'static av_always_inline int encode_line(FFV1Context *s, int w,\n                                        int16_t *sample[2],\n                                        int plane_index, int bits)\n{\n    PlaneContext * const p= &s->plane[plane_index];\n    RangeCoder * const c= &s->c;\n    int x;\n    int run_index= s->run_index;\n    int run_count=0;\n    int run_mode=0;\n    if(s->ac){\n        if(c->bytestream_end - c->bytestream < w*20){\n            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\\n");\n            return -1;\n        }\n    }else{\n        if(s->pb.buf_end - s->pb.buf - (put_bits_count(&s->pb)>>3) < w*4){\n            av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\\n");\n            return -1;\n        }\n    }\n    for(x=0; x<w; x++){\n        int diff, context;\n        context= get_context(p, sample[0]+x, sample[1]+x, sample[2]+x);\n        diff= sample[0][x] - predict(sample[0]+x, sample[1]+x);\n        if(context < 0){\n            context = -context;\n            diff= -diff;\n        }\n        diff= fold(diff, bits);\n        if(s->ac){\n            if(s->flags & CODEC_FLAG_PASS1){\n                put_symbol_inline(c, p->state[context], diff, 1, s->rc_stat, s->rc_stat2[p->quant_table_index][context]);\n            }else{\n                put_symbol_inline(c, p->state[context], diff, 1, NULL, NULL);\n            }\n        }else{\n            if(context == 0) run_mode=1;\n            if(run_mode){\n                if(diff){\n                    while(run_count >= 1<<ff_log2_run[run_index]){\n                        run_count -= 1<<ff_log2_run[run_index];\n                        run_index++;\n                        put_bits(&s->pb, 1, 1);\n                    }\n                    put_bits(&s->pb, 1 + ff_log2_run[run_index], run_count);\n                    if(run_index) run_index--;\n                    run_count=0;\n                    run_mode=0;\n                    if(diff>0) diff--;\n                }else{\n                    run_count++;\n                }\n            }\n            if(run_mode == 0)\n                put_vlc_symbol(&s->pb, &p->vlc_state[context], diff, bits);\n        }\n    }\n    if(run_mode){\n        while(run_count >= 1<<ff_log2_run[run_index]){\n            run_count -= 1<<ff_log2_run[run_index];\n            run_index++;\n            put_bits(&s->pb, 1, 1);\n        }\n        if(run_count)\n            put_bits(&s->pb, 1, 1);\n    }\n    s->run_index= run_index;\n    return 0;\n}']