Originally committed as revision 18898 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.6
| @@ -696,13 +696,13 @@ static int svq1_decode_frame(AVCodecContext *avctx, | |||||
| for (i=0; i < 3; i++) { | for (i=0; i < 3; i++) { | ||||
| int linesize; | int linesize; | ||||
| if (i == 0) { | if (i == 0) { | ||||
| width = (s->width+15)&~15; | |||||
| height = (s->height+15)&~15; | |||||
| width = FFALIGN(s->width, 16); | |||||
| height = FFALIGN(s->height, 16); | |||||
| linesize= s->linesize; | linesize= s->linesize; | ||||
| } else { | } else { | ||||
| if(s->flags&CODEC_FLAG_GRAY) break; | if(s->flags&CODEC_FLAG_GRAY) break; | ||||
| width = (s->width/4+15)&~15; | |||||
| height = (s->height/4+15)&~15; | |||||
| width = FFALIGN(s->width/4, 16); | |||||
| height = FFALIGN(s->height/4, 16); | |||||
| linesize= s->uvlinesize; | linesize= s->uvlinesize; | ||||
| } | } | ||||
| @@ -134,8 +134,6 @@ typedef struct InternalBuffer{ | |||||
| #define INTERNAL_BUFFER_SIZE 32 | #define INTERNAL_BUFFER_SIZE 32 | ||||
| #define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) | |||||
| void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ | void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ | ||||
| int w_align= 1; | int w_align= 1; | ||||
| int h_align= 1; | int h_align= 1; | ||||
| @@ -193,8 +191,8 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ | |||||
| break; | break; | ||||
| } | } | ||||
| *width = ALIGN(*width , w_align); | |||||
| *height= ALIGN(*height, h_align); | |||||
| *width = FFALIGN(*width , w_align); | |||||
| *height= FFALIGN(*height, h_align); | |||||
| if(s->codec_id == CODEC_ID_H264) | if(s->codec_id == CODEC_ID_H264) | ||||
| *height+=2; // some of the optimized chroma MC reads one line too much | *height+=2; // some of the optimized chroma MC reads one line too much | ||||
| } | } | ||||
| @@ -317,7 +315,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ | |||||
| if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) | if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) | ||||
| buf->data[i] = buf->base[i]; | buf->data[i] = buf->base[i]; | ||||
| else | else | ||||
| buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); | |||||
| buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); | |||||
| } | } | ||||
| if(size[1] && !size[2]) | if(size[1] && !size[2]) | ||||
| ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt); | ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt); | ||||
| @@ -1636,8 +1636,8 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx) | |||||
| s->version = 1; | s->version = 1; | ||||
| s->avctx = avctx; | s->avctx = avctx; | ||||
| s->width = (avctx->width + 15) & 0xFFFFFFF0; | |||||
| s->height = (avctx->height + 15) & 0xFFFFFFF0; | |||||
| s->width = FFALIGN(avctx->width, 16); | |||||
| s->height = FFALIGN(avctx->height, 16); | |||||
| avctx->pix_fmt = PIX_FMT_YUV420P; | avctx->pix_fmt = PIX_FMT_YUV420P; | ||||
| avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; | avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; | ||||
| if(avctx->idct_algo==FF_IDCT_AUTO) | if(avctx->idct_algo==FF_IDCT_AUTO) | ||||
| @@ -284,7 +284,7 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||
| av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); | av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| c->pstride = (avctx->width + 15) & ~15; | |||||
| c->pstride = FFALIGN(avctx->width, 16); | |||||
| if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) { | if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) { | ||||
| av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n"); | av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n"); | ||||
| return -1; | return -1; | ||||
| @@ -29,10 +29,6 @@ void avfilter_default_free_video_buffer(AVFilterPic *pic) | |||||
| av_free(pic); | av_free(pic); | ||||
| } | } | ||||
| #define ALIGN(a) do{ \ | |||||
| (a) = ((a) + 15) & (~15); \ | |||||
| } while(0); | |||||
| /* TODO: set the buffer's priv member to a context structure for the whole | /* TODO: set the buffer's priv member to a context structure for the whole | ||||
| * filter chain. This will allow for a buffer pool instead of the constant | * filter chain. This will allow for a buffer pool instead of the constant | ||||
| * alloc & free cycle currently implemented. */ | * alloc & free cycle currently implemented. */ | ||||
| @@ -56,7 +52,7 @@ AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms) | |||||
| ff_fill_linesize((AVPicture *)pic, pic->format, ref->w); | ff_fill_linesize((AVPicture *)pic, pic->format, ref->w); | ||||
| for (i=0; i<4;i++) | for (i=0; i<4;i++) | ||||
| ALIGN(pic->linesize[i]); | |||||
| pic->linesize[i] = FFALIGN(pic->linesize[i], 16); | |||||
| tempsize = ff_fill_pointer((AVPicture *)pic, NULL, pic->format, ref->h); | tempsize = ff_fill_pointer((AVPicture *)pic, NULL, pic->format, ref->h); | ||||
| buf = av_malloc(tempsize); | buf = av_malloc(tempsize); | ||||
| @@ -127,6 +127,7 @@ | |||||
| #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||||
| #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) | #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) | ||||
| #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) | |||||
| /* misc math functions */ | /* misc math functions */ | ||||
| extern const uint8_t ff_log2_tab[256]; | extern const uint8_t ff_log2_tab[256]; | ||||
| @@ -951,7 +951,7 @@ static const AVClass av_codec_context_class = { "Postproc", context_to_name, NUL | |||||
| pp_context *pp_get_context(int width, int height, int cpuCaps){ | pp_context *pp_get_context(int width, int height, int cpuCaps){ | ||||
| PPContext *c= av_malloc(sizeof(PPContext)); | PPContext *c= av_malloc(sizeof(PPContext)); | ||||
| int stride= (width+15)&(~15); //assumed / will realloc if needed | |||||
| int stride= FFALIGN(width, 16); //assumed / will realloc if needed | |||||
| int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed | int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed | ||||
| memset(c, 0, sizeof(PPContext)); | memset(c, 0, sizeof(PPContext)); | ||||