if(s->codec_id==CODEC_ID_SVQ1) align=63; else                           align=15;  w= (width +align)&~align; h= (height+align)&~align;
avcodec_align_dimensions(s, &w, &h); #if defined(ARCH_POWERPC) || defined(HAVE_MMI) s_align= 16; #else s_align= 8; #endif
int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){    int i;    const int width = s->width;    const int height= s->height;    InternalBuffer *buf;        assert(pic->data[0]==NULL);    assert(INTERNAL_BUFFER_SIZE > s->internal_buffer_count);    if(s->internal_buffer==NULL){        s->internal_buffer= av_mallocz(INTERNAL_BUFFER_SIZE*sizeof(InternalBuffer));    }#if 0    s->internal_buffer= av_fast_realloc(        s->internal_buffer,         &s->internal_buffer_size,         sizeof(InternalBuffer)*FFMAX(99,  s->internal_buffer_count+1)/*FIXME*/        );#endif         buf= &((InternalBuffer*)s->internal_buffer)[s->internal_buffer_count];    if(buf->base[0]){        pic->age= pic->coded_picture_number - buf->last_pic_num;        buf->last_pic_num= pic->coded_picture_number;    }else{        int align, h_chroma_shift, v_chroma_shift;        int w, h, pixel_size;                avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);        switch(s->pix_fmt){        case PIX_FMT_RGB555:        case PIX_FMT_RGB565:        case PIX_FMT_YUV422:            pixel_size=2;            break;        case PIX_FMT_RGB24:        case PIX_FMT_BGR24:            pixel_size=3;            break;        case PIX_FMT_RGBA32:            pixel_size=4;            break;        default:            pixel_size=1;        }                if(s->codec_id==CODEC_ID_SVQ1) align=63;        else                           align=15;            w= (width +align)&~align;        h= (height+align)&~align;            if(!(s->flags&CODEC_FLAG_EMU_EDGE)){            w+= EDGE_WIDTH*2;            h+= EDGE_WIDTH*2;        }                buf->last_pic_num= -256*256*256*64;        for(i=0; i<3; i++){            const int h_shift= i==0 ? 0 : h_chroma_shift;            const int v_shift= i==0 ? 0 : v_chroma_shift;            pic->linesize[i]= pixel_size*w>>h_shift;            buf->base[i]= av_mallocz((pic->linesize[i]*h>>v_shift)+16); //FIXME 16            if(buf->base[i]==NULL) return -1;            memset(buf->base[i], 128, pic->linesize[i]*h>>v_shift);                    if(s->flags&CODEC_FLAG_EMU_EDGE)                buf->data[i] = buf->base[i];            else                buf->data[i] = buf->base[i] + (pic->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift);        }        pic->age= 256*256*256*64;        pic->type= FF_BUFFER_TYPE_INTERNAL;    }    for(i=0; i<4; i++){        pic->base[i]= buf->base[i];        pic->data[i]= buf->data[i];    }    s->internal_buffer_count++;    return 0;}