pic->pict_type= pic_arg->pict_type; pic->quality= pic_arg->quality;  if(   pic->data[0] == pic_arg->data[0] && pic->data[1] == pic_arg->data[1] && pic->data[2] == pic_arg->data[2]){  }else{ int h_chroma_shift, v_chroma_shift;  avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);  for(i=0; i<3; i++){ int src_stride= pic_arg->linesize[i]; int dst_stride= i ? s->uvlinesize : s->linesize; int h_shift= i ? h_chroma_shift : 0; int v_shift= i ? v_chroma_shift : 0; int w= s->width >>h_shift; int h= s->height>>v_shift; uint8_t *src= pic_arg->data[i]; uint8_t *dst= pic->data[i] + 16;  if(src_stride==dst_stride) memcpy(dst, src, src_stride*h); else{ while(h--){ memcpy(dst, src, w); dst += dst_stride; src += src_stride; } } } }
static int load_input_picture(MpegEncContext *s, AVVideoFrame *pic_arg){    AVVideoFrame *pic;    int i,r;    const int encoding_delay= s->max_b_frames;    /* find unused Picture */    for(i=0; i<MAX_PICTURE_COUNT; i++){        if(s->picture[i].data[0]==NULL) break;    }    assert(i<MAX_PICTURE_COUNT);            pic= (AVVideoFrame*)&s->picture[i];    pic->reference= 1;    //    assert(avctx->get_buffer == default_get_buffer || avctx->get_buffer==NULL);    r= s->avctx->get_buffer(s->avctx, pic);    if(r<0 || (s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1]))){        fprintf(stderr, "get_buffer() failed (stride changed), bye bye\n");        return -1;    }        assert(s->linesize==0   || s->linesize  ==pic->linesize[0]);    assert(s->uvlinesize==0 || s->uvlinesize==pic->linesize[1]);    assert(pic->linesize[1] == pic->linesize[2]);    s->linesize  = pic->linesize[0];    s->uvlinesize= pic->linesize[1];        if(pic->qscale_table==NULL)        alloc_picture(s, (Picture*)pic);//    assert(s->input_picture[0]==NULL || s->input_picture[0]->data[0]==NULL);        if(s->input_picture[encoding_delay])        pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1;//printf("dpn2:%d\n", pic->display_picture_number);    /* shift buffer entries */    for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++)        s->input_picture[i-1]= s->input_picture[i];            s->input_picture[encoding_delay]= (Picture*)pic;    pic->pict_type= pic_arg->pict_type;    pic->quality= pic_arg->quality;        if(   pic->data[0] == pic_arg->data[0]        && pic->data[1] == pic_arg->data[1]       && pic->data[2] == pic_arg->data[2]){       // empty    }else{        int h_chroma_shift, v_chroma_shift;                avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);                for(i=0; i<3; i++){            int src_stride= pic_arg->linesize[i];            int dst_stride= i ? s->uvlinesize : s->linesize;            int h_shift= i ? h_chroma_shift : 0;            int v_shift= i ? v_chroma_shift : 0;            int w= s->width >>h_shift;            int h= s->height>>v_shift;            uint8_t *src= pic_arg->data[i];            uint8_t *dst= pic->data[i] + 16;                        if(src_stride==dst_stride)                memcpy(dst, src, src_stride*h);            else{                while(h--){                    memcpy(dst, src, w);                    dst += dst_stride;                    src += src_stride;                }            }        }    }    return 0;}