Originally committed as revision 18898 to svn://svn.ffmpeg.org/ffmpeg/trunk
David Conrad authored on 2009/05/23 06:32:13... | ... |
@@ -696,13 +696,13 @@ static int svq1_decode_frame(AVCodecContext *avctx, |
696 | 696 |
for (i=0; i < 3; i++) { |
697 | 697 |
int linesize; |
698 | 698 |
if (i == 0) { |
699 |
- width = (s->width+15)&~15; |
|
700 |
- height = (s->height+15)&~15; |
|
699 |
+ width = FFALIGN(s->width, 16); |
|
700 |
+ height = FFALIGN(s->height, 16); |
|
701 | 701 |
linesize= s->linesize; |
702 | 702 |
} else { |
703 | 703 |
if(s->flags&CODEC_FLAG_GRAY) break; |
704 |
- width = (s->width/4+15)&~15; |
|
705 |
- height = (s->height/4+15)&~15; |
|
704 |
+ width = FFALIGN(s->width/4, 16); |
|
705 |
+ height = FFALIGN(s->height/4, 16); |
|
706 | 706 |
linesize= s->uvlinesize; |
707 | 707 |
} |
708 | 708 |
|
... | ... |
@@ -134,8 +134,6 @@ typedef struct InternalBuffer{ |
134 | 134 |
|
135 | 135 |
#define INTERNAL_BUFFER_SIZE 32 |
136 | 136 |
|
137 |
-#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1)) |
|
138 |
- |
|
139 | 137 |
void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ |
140 | 138 |
int w_align= 1; |
141 | 139 |
int h_align= 1; |
... | ... |
@@ -193,8 +191,8 @@ void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){ |
193 | 193 |
break; |
194 | 194 |
} |
195 | 195 |
|
196 |
- *width = ALIGN(*width , w_align); |
|
197 |
- *height= ALIGN(*height, h_align); |
|
196 |
+ *width = FFALIGN(*width , w_align); |
|
197 |
+ *height= FFALIGN(*height, h_align); |
|
198 | 198 |
if(s->codec_id == CODEC_ID_H264) |
199 | 199 |
*height+=2; // some of the optimized chroma MC reads one line too much |
200 | 200 |
} |
... | ... |
@@ -317,7 +315,7 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){ |
317 | 317 |
if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2]) |
318 | 318 |
buf->data[i] = buf->base[i]; |
319 | 319 |
else |
320 |
- buf->data[i] = buf->base[i] + ALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); |
|
320 |
+ buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*EDGE_WIDTH>>v_shift) + (EDGE_WIDTH>>h_shift), stride_align[i]); |
|
321 | 321 |
} |
322 | 322 |
if(size[1] && !size[2]) |
323 | 323 |
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) |
1636 | 1636 |
s->version = 1; |
1637 | 1637 |
|
1638 | 1638 |
s->avctx = avctx; |
1639 |
- s->width = (avctx->width + 15) & 0xFFFFFFF0; |
|
1640 |
- s->height = (avctx->height + 15) & 0xFFFFFFF0; |
|
1639 |
+ s->width = FFALIGN(avctx->width, 16); |
|
1640 |
+ s->height = FFALIGN(avctx->height, 16); |
|
1641 | 1641 |
avctx->pix_fmt = PIX_FMT_YUV420P; |
1642 | 1642 |
avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; |
1643 | 1643 |
if(avctx->idct_algo==FF_IDCT_AUTO) |
... | ... |
@@ -284,7 +284,7 @@ static av_cold int encode_init(AVCodecContext *avctx) |
284 | 284 |
av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); |
285 | 285 |
return -1; |
286 | 286 |
} |
287 |
- c->pstride = (avctx->width + 15) & ~15; |
|
287 |
+ c->pstride = FFALIGN(avctx->width, 16); |
|
288 | 288 |
if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) { |
289 | 289 |
av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n"); |
290 | 290 |
return -1; |
... | ... |
@@ -29,10 +29,6 @@ void avfilter_default_free_video_buffer(AVFilterPic *pic) |
29 | 29 |
av_free(pic); |
30 | 30 |
} |
31 | 31 |
|
32 |
-#define ALIGN(a) do{ \ |
|
33 |
- (a) = ((a) + 15) & (~15); \ |
|
34 |
- } while(0); |
|
35 |
- |
|
36 | 32 |
/* TODO: set the buffer's priv member to a context structure for the whole |
37 | 33 |
* filter chain. This will allow for a buffer pool instead of the constant |
38 | 34 |
* alloc & free cycle currently implemented. */ |
... | ... |
@@ -56,7 +52,7 @@ AVFilterPicRef *avfilter_default_get_video_buffer(AVFilterLink *link, int perms) |
56 | 56 |
ff_fill_linesize((AVPicture *)pic, pic->format, ref->w); |
57 | 57 |
|
58 | 58 |
for (i=0; i<4;i++) |
59 |
- ALIGN(pic->linesize[i]); |
|
59 |
+ pic->linesize[i] = FFALIGN(pic->linesize[i], 16); |
|
60 | 60 |
|
61 | 61 |
tempsize = ff_fill_pointer((AVPicture *)pic, NULL, pic->format, ref->h); |
62 | 62 |
buf = av_malloc(tempsize); |
... | ... |
@@ -127,6 +127,7 @@ |
127 | 127 |
|
128 | 128 |
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) |
129 | 129 |
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) |
130 |
+#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) |
|
130 | 131 |
|
131 | 132 |
/* misc math functions */ |
132 | 133 |
extern const uint8_t ff_log2_tab[256]; |
... | ... |
@@ -951,7 +951,7 @@ static const AVClass av_codec_context_class = { "Postproc", context_to_name, NUL |
951 | 951 |
|
952 | 952 |
pp_context *pp_get_context(int width, int height, int cpuCaps){ |
953 | 953 |
PPContext *c= av_malloc(sizeof(PPContext)); |
954 |
- int stride= (width+15)&(~15); //assumed / will realloc if needed |
|
954 |
+ int stride= FFALIGN(width, 16); //assumed / will realloc if needed |
|
955 | 955 |
int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed |
956 | 956 |
|
957 | 957 |
memset(c, 0, sizeof(PPContext)); |