changeset 9686:bc32976d6d9d libavcodec

Move ALIGN macro to libavutil/common.h and use it in various places
author conrad
date Fri, 22 May 2009 21:32:13 +0000
parents ab8b3b2e4d49
children d9f8496b3b91
files svq1dec.c utils.c vp3.c zmbvenc.c
diffstat 4 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/svq1dec.c	Fri May 22 18:39:00 2009 +0000
+++ b/svq1dec.c	Fri May 22 21:32:13 2009 +0000
@@ -696,13 +696,13 @@
   for (i=0; i < 3; i++) {
     int linesize;
     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;
     } else {
       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;
     }
 
--- a/utils.c	Fri May 22 18:39:00 2009 +0000
+++ b/utils.c	Fri May 22 21:32:13 2009 +0000
@@ -134,8 +134,6 @@
 
 #define INTERNAL_BUFFER_SIZE 32
 
-#define ALIGN(x, a) (((x)+(a)-1)&~((a)-1))
-
 void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
     int w_align= 1;
     int h_align= 1;
@@ -193,8 +191,8 @@
         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)
         *height+=2; // some of the optimized chroma MC reads one line too much
 }
@@ -317,7 +315,7 @@
             if((s->flags&CODEC_FLAG_EMU_EDGE) || !size[2])
                 buf->data[i] = buf->base[i];
             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])
             ff_set_systematic_pal((uint32_t*)buf->data[1], s->pix_fmt);
--- a/vp3.c	Fri May 22 18:39:00 2009 +0000
+++ b/vp3.c	Fri May 22 21:32:13 2009 +0000
@@ -1636,8 +1636,8 @@
         s->version = 1;
 
     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->chroma_sample_location = AVCHROMA_LOC_CENTER;
     if(avctx->idct_algo==FF_IDCT_AUTO)
--- a/zmbvenc.c	Fri May 22 18:39:00 2009 +0000
+++ b/zmbvenc.c	Fri May 22 21:32:13 2009 +0000
@@ -284,7 +284,7 @@
         av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n");
         return -1;
     }
-    c->pstride = (avctx->width + 15) & ~15;
+    c->pstride = FFALIGN(avctx->width, 16);
     if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) {
         av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n");
         return -1;