[Ffmpeg-devel] [PATCH] use libavutil macros in libpostproc

Diego Biurrun diego
Tue Oct 10 01:23:23 CEST 2006


$subject, plus put the SIGN macro in libavutil/common.h as well, it
might be useful in other places.

I'll commit this tomorrow, it's very trivial, in three separate commits
even, but i'm too lazy to split the patch right now.

Diego
-------------- next part --------------
Index: libavutil/common.h
===================================================================
--- libavutil/common.h	(revision 6612)
+++ libavutil/common.h	(working copy)
@@ -193,6 +193,7 @@
 /* assume b>0 */
 #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
 #define ABS(a) ((a) >= 0 ? (a) : (-(a)))
+#define SIGN(a) ((a) > 0 ? 1 : -1)
 
 #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
 #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
Index: libpostproc/postprocess_template.c
===================================================================
--- libpostproc/postprocess_template.c	(revision 6612)
+++ libpostproc/postprocess_template.c	(working copy)
@@ -590,7 +590,7 @@
                 int c= src[l5] - src[l6];
 
                 int d= ABS(b) - ((ABS(a) + ABS(c))>>1);
-                d= MAX(d, 0);
+                d= FFMAX(d, 0);
 
                 if(d < co->QP*2)
                 {
@@ -851,8 +851,8 @@
                         const int leftEnergy=  5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
                         const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
 
-                        int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
-                        d= MAX(d, 0);
+                        int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) );
+                        d= FFMAX(d, 0);
 
                         d= (5*d + 32) >> 6;
                         d*= SIGN(-middleEnergy);
@@ -1155,8 +1155,8 @@
                         const int leftEnergy=  5*(src[l3] - src[l2]) + 2*(src[l1] - src[l4]);
                         const int rightEnergy= 5*(src[l7] - src[l6]) + 2*(src[l5] - src[l8]);
 
-                        int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
-                        d= MAX(d, 0);
+                        int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) );
+                        d= FFMAX(d, 0);
 
                         d= (5*d + 32) >> 6;
                         d*= SIGN(-middleEnergy);
@@ -1532,7 +1532,7 @@
                         for(x=1; x<9; x++)
                         {
                                 p++;
-                                *p = MIN(*p + 20, 255);
+                                *p = FFMIN(*p + 20, 255);
                         }
                 }
 //                src[0] = src[7]=src[stride*7]=src[stride*7 + 7]=255;
@@ -3566,14 +3566,14 @@
                         /* copy from line (copyAhead) to (copyAhead+7) of src, these will be copied with
                            blockcopy to dst later */
                         linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead,
-                                MAX(height-y-copyAhead, 0), srcStride);
+                                FFMAX(height-y-copyAhead, 0), srcStride);
 
                         /* duplicate last line of src to fill the void upto line (copyAhead+7) */
-                        for(i=MAX(height-y, 8); i<copyAhead+8; i++)
+                        for(i=FFMAX(height-y, 8); i<copyAhead+8; i++)
                                 memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), ABS(srcStride));
 
                         /* copy up to (copyAhead+1) lines of dst (line -1 to (copyAhead-1))*/
-                        linecpy(tempDst, dstBlock - dstStride, MIN(height-y+1, copyAhead+1), dstStride);
+                        linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride);
 
                         /* duplicate last line of dst to fill the void upto line (copyAhead) */
                         for(i=height-y+1; i<=copyAhead; i++)
Index: libpostproc/postprocess.c
===================================================================
--- libpostproc/postprocess.c	(revision 6614)
+++ libpostproc/postprocess.c	(working copy)
@@ -99,11 +99,6 @@
 #include <altivec.h>
 #endif
 
-#define MIN(a,b) ((a) > (b) ? (b) : (a))
-#define MAX(a,b) ((a) < (b) ? (b) : (a))
-#define ABS(a) ((a) > 0 ? (a) : (-(a)))
-#define SIGN(a) ((a) > 0 ? 1 : -1)
-
 #define GET_MODE_BUFFER_SIZE 500
 #define OPTIONS_ARRAY_SIZE 10
 #define BLOCK_SIZE 8
@@ -343,8 +338,8 @@
                         const int leftEnergy=  5*(dst[2] - dst[1]) + 2*(dst[0] - dst[3]);
                         const int rightEnergy= 5*(dst[6] - dst[5]) + 2*(dst[4] - dst[7]);
 
-                        int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
-                        d= MAX(d, 0);
+                        int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) );
+                        d= FFMAX(d, 0);
 
                         d= (5*d + 32) >> 6;
                         d*= SIGN(-middleEnergy);
@@ -452,7 +447,7 @@
                 int b= src[3] - src[4];
                 int c= src[5] - src[6];
 
-                int d= MAX(ABS(b) - (ABS(a) + ABS(c))/2, 0);
+                int d= FFMAX(ABS(b) - (ABS(a) + ABS(c))/2, 0);
 
                 if(d < QP)
                 {
@@ -545,8 +540,8 @@
                                 const int leftEnergy=  5*(src[2*step] - src[1*step]) + 2*(src[0*step] - src[3*step]);
                                 const int rightEnergy= 5*(src[6*step] - src[5*step]) + 2*(src[4*step] - src[7*step]);
 
-                                int d= ABS(middleEnergy) - MIN( ABS(leftEnergy), ABS(rightEnergy) );
-                                d= MAX(d, 0);
+                                int d= ABS(middleEnergy) - FFMIN( ABS(leftEnergy), ABS(rightEnergy) );
+                                d= FFMAX(d, 0);
 
                                 d= (5*d + 32) >> 6;
                                 d*= SIGN(-middleEnergy);
@@ -1046,14 +1041,14 @@
         int mbHeight= (height+15)>>4;
         PPMode *mode = (PPMode*)vm;
         PPContext *c = (PPContext*)vc;
-        int minStride= MAX(ABS(srcStride[0]), ABS(dstStride[0]));
+        int minStride= FFMAX(ABS(srcStride[0]), ABS(dstStride[0]));
         int absQPStride = ABS(QPStride);
 
         // c->stride and c->QPStride are always positive
         if(c->stride < minStride || c->qpStride < absQPStride)
                 reallocBuffers(c, width, height,
-                                MAX(minStride, c->stride),
-                                MAX(c->qpStride, absQPStride));
+                                FFMAX(minStride, c->stride),
+                                FFMAX(c->qpStride, absQPStride));
 
         if(QP_store==NULL || (mode->lumMode & FORCE_QUANT))
         {



More information about the ffmpeg-devel mailing list