]> git.sesse.net Git - ffmpeg/blobdiff - libswscale/swscale.c
Move array specifiers outside DECLARE_ALIGNED() invocations
[ffmpeg] / libswscale / swscale.c
index 0b12b5e20bc5da249040d880386563978e99e159..67a9364c9742ed3f402d9036f2c1dd5c441cf916 100644 (file)
@@ -251,11 +251,11 @@ DECLARE_ASM_CONST(8, uint64_t, bm00000111)=0x0000000000FFFFFFLL;
 DECLARE_ASM_CONST(8, uint64_t, bm11111000)=0xFFFFFFFFFF000000LL;
 DECLARE_ASM_CONST(8, uint64_t, bm01010101)=0x00FF00FF00FF00FFLL;
 
-const DECLARE_ALIGNED(8, uint64_t, ff_dither4[2]) = {
+const DECLARE_ALIGNED(8, uint64_t, ff_dither4)[2] = {
         0x0103010301030103LL,
         0x0200020002000200LL,};
 
-const DECLARE_ALIGNED(8, uint64_t, ff_dither8[2]) = {
+const DECLARE_ALIGNED(8, uint64_t, ff_dither8)[2] = {
         0x0602060206020602LL,
         0x0004000400040004LL,};
 
@@ -289,7 +289,7 @@ DECLARE_ASM_CONST(8, uint64_t, ff_rgb24toY1Coeff) = 0x20DE0000408720DEULL;
 DECLARE_ASM_CONST(8, uint64_t, ff_rgb24toY2Coeff) = 0x0C88408700000C88ULL;
 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toYOffset) = 0x0008400000084000ULL;
 
-DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUV[2][4]) = {
+DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUV)[2][4] = {
     {0x38380000DAC83838ULL, 0xECFFDAC80000ECFFULL, 0xF6E40000D0E3F6E4ULL, 0x3838D0E300003838ULL},
     {0xECFF0000DAC8ECFFULL, 0x3838DAC800003838ULL, 0x38380000D0E33838ULL, 0xF6E4D0E30000F6E4ULL},
 };
@@ -298,19 +298,17 @@ DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUVOffset)= 0x0040400000404000ULL;
 
 #endif /* ARCH_X86 && CONFIG_GPL */
 
-static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b);
-
-DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_4[2][8])={
+DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_4)[2][8]={
 {  1,   3,   1,   3,   1,   3,   1,   3, },
 {  2,   0,   2,   0,   2,   0,   2,   0, },
 };
 
-DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_8[2][8])={
+DECLARE_ALIGNED(8, static const uint8_t, dither_2x2_8)[2][8]={
 {  6,   2,   6,   2,   6,   2,   6,   2, },
 {  0,   4,   0,   4,   0,   4,   0,   4, },
 };
 
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32)[8][8]={
 { 17,   9,  23,  15,  16,   8,  22,  14, },
 {  5,  29,   3,  27,   4,  28,   2,  26, },
 { 21,  13,  19,  11,  20,  12,  18,  10, },
@@ -321,7 +319,7 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_32[8][8])={
 {  1,  25,   7,  31,   0,  24,   6,  30, },
 };
 
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73)[8][8]={
 {  0,  55,  14,  68,   3,  58,  17,  72, },
 { 37,  18,  50,  32,  40,  22,  54,  35, },
 {  9,  64,   5,  59,  13,  67,   8,  63, },
@@ -333,7 +331,7 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_73[8][8])={
 };
 
 #if 1
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 {117,  62, 158, 103, 113,  58, 155, 100, },
 { 34, 199,  21, 186,  31, 196,  17, 182, },
 {144,  89, 131,  76, 141,  86, 127,  72, },
@@ -345,7 +343,7 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
 };
 #elif 1
 // tries to correct a gamma of 1.5
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 {  0, 143,  18, 200,   2, 156,  25, 215, },
 { 78,  28, 125,  64,  89,  36, 138,  74, },
 { 10, 180,   3, 161,  16, 195,   8, 175, },
@@ -357,7 +355,7 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
 };
 #elif 1
 // tries to correct a gamma of 2.0
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 {  0, 124,   8, 193,   0, 140,  12, 213, },
 { 55,  14, 104,  42,  66,  19, 119,  52, },
 {  3, 168,   1, 145,   6, 187,   3, 162, },
@@ -369,7 +367,7 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
 };
 #else
 // tries to correct a gamma of 2.5
-DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220[8][8])={
+DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={
 {  0, 107,   3, 187,   0, 125,   6, 212, },
 { 39,   7,  86,  28,  49,  11, 102,  36, },
 {  1, 158,   0, 131,   3, 180,   1, 151, },
@@ -588,7 +586,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
             }\
             A1>>=19;\
             A2>>=19;\
-        }\
+        }
 
 #define YSCALE_YUV_2_PACKEDX_C(type,alpha) \
         YSCALE_YUV_2_PACKEDX_NOCLIP_C(type,alpha)\
@@ -633,7 +631,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
             A >>=19;\
             if (A&256)\
                 A = av_clip_uint8(A);\
-        }\
+        }
 
 #define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \
     YSCALE_YUV_2_PACKEDX_FULL_C(rnd>>3,alpha)\
@@ -650,8 +648,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
             else if (G<0)G=0;   \
             if (B>=(256<<22))   B=(256<<22)-1; \
             else if (B<0)B=0;   \
-        }\
-
+        }
 
 #define YSCALE_YUV_2_GRAY16_C \
     for (i=0; i<(dstW>>1); i++) {\
@@ -680,7 +677,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
     YSCALE_YUV_2_PACKEDX_C(type,alpha)  /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
     r = (type *)c->table_rV[V];   \
     g = (type *)(c->table_gU[U] + c->table_gV[V]); \
-    b = (type *)c->table_bU[U];   \
+    b = (type *)c->table_bU[U];
 
 #define YSCALE_YUV_2_PACKED2_C(type,alpha)   \
     for (i=0; i<(dstW>>1); i++) { \
@@ -694,19 +691,19 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
         if (alpha) {\
             A1= (abuf0[i2  ]*yalpha1+abuf1[i2  ]*yalpha)>>19;         \
             A2= (abuf0[i2+1]*yalpha1+abuf1[i2+1]*yalpha)>>19;         \
-        }\
+        }
 
 #define YSCALE_YUV_2_GRAY16_2_C   \
     for (i=0; i<(dstW>>1); i++) { \
         const int i2= 2*i;       \
         int Y1= (buf0[i2  ]*yalpha1+buf1[i2  ]*yalpha)>>11;           \
-        int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>11;           \
+        int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>11;
 
 #define YSCALE_YUV_2_RGB2_C(type,alpha) \
     YSCALE_YUV_2_PACKED2_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
-    b = (type *)c->table_bU[U];\
+    b = (type *)c->table_bU[U];
 
 #define YSCALE_YUV_2_PACKED1_C(type,alpha) \
     for (i=0; i<(dstW>>1); i++) {\
@@ -720,19 +717,19 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
         if (alpha) {\
             A1= abuf0[i2  ]>>7;\
             A2= abuf0[i2+1]>>7;\
-        }\
+        }
 
 #define YSCALE_YUV_2_GRAY16_1_C \
     for (i=0; i<(dstW>>1); i++) {\
         const int i2= 2*i;\
         int Y1= buf0[i2  ]<<1;\
-        int Y2= buf0[i2+1]<<1;\
+        int Y2= buf0[i2+1]<<1;
 
 #define YSCALE_YUV_2_RGB1_C(type,alpha) \
     YSCALE_YUV_2_PACKED1_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
-    b = (type *)c->table_bU[U];\
+    b = (type *)c->table_bU[U];
 
 #define YSCALE_YUV_2_PACKED1B_C(type,alpha) \
     for (i=0; i<(dstW>>1); i++) {\
@@ -746,13 +743,13 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
         if (alpha) {\
             A1= abuf0[i2  ]>>7;\
             A2= abuf0[i2+1]>>7;\
-        }\
+        }
 
 #define YSCALE_YUV_2_RGB1B_C(type,alpha) \
     YSCALE_YUV_2_PACKED1B_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
-    b = (type *)c->table_bU[U];\
+    b = (type *)c->table_bU[U];
 
 #define YSCALE_YUV_2_MONO2_C \
     const uint8_t * const d128=dither_8x8_220[y&7];\
@@ -769,8 +766,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
         acc+= acc + g[((buf0[i+7]*yalpha1+buf1[i+7]*yalpha)>>19) + d128[7]];\
         ((uint8_t*)dest)[0]= c->dstFormat == PIX_FMT_MONOBLACK ? acc : ~acc;\
         dest++;\
-    }\
-
+    }
 
 #define YSCALE_YUV_2_MONOX_C \
     const uint8_t * const d128=dither_8x8_220[y&7];\
@@ -801,7 +797,6 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
         }\
     }
 
-
 #define YSCALE_YUV_2_ANYRGB_C(func, func2, func_g16, func_monoblack)\
     switch(c->dstFormat) {\
     case PIX_FMT_RGB48BE:\
@@ -989,8 +984,7 @@ static inline void yuv2nv12XinC(const int16_t *lumFilter, const int16_t **lumSrc
             ((uint8_t*)dest)[2*i2+3]= Y2>>8;\
         }                \
         break;\
-    }\
-
+    }
 
 static inline void yuv2packedXinC(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
                                   const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
@@ -1249,7 +1243,6 @@ static inline void monoblack2Y(uint8_t *dst, const uint8_t *src, long width, uin
     }
 }
 
-
 //Note: we have C, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
 //Plain C versions
 #if ((!HAVE_MMX || !CONFIG_GPL) && !HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
@@ -1349,9 +1342,9 @@ static double getSplineCoeff(double a, double b, double c, double d, double dist
                                          dist-1.0);
 }
 
-static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc,
-                             int srcW, int dstW, int filterAlign, int one, int flags,
-                             SwsVector *srcFilter, SwsVector *dstFilter, double param[2])
+static int initFilter(int16_t **outFilter, int16_t **filterPos, int *outFilterSize, int xInc,
+                      int srcW, int dstW, int filterAlign, int one, int flags,
+                      SwsVector *srcFilter, SwsVector *dstFilter, double param[2])
 {
     int i;
     int filterSize;
@@ -1624,7 +1617,6 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         }
     }
 
-
     //FIXME try to align filterPos if possible
 
     //fix borders
@@ -2032,26 +2024,26 @@ static int pal2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[],
     uint8_t *dstPtr= dst[0] + dstStride[0]*srcSliceY;
     const uint8_t *srcPtr= src[0];
 
-    if (!usePal(srcFormat))
-        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
-               sws_format_name(srcFormat), sws_format_name(dstFormat));
-
-    switch(dstFormat) {
-    case PIX_FMT_RGB32  : conv = palette8topacked32; break;
-    case PIX_FMT_BGR32  : conv = palette8topacked32; break;
-    case PIX_FMT_BGR32_1: conv = palette8topacked32; break;
-    case PIX_FMT_RGB32_1: conv = palette8topacked32; break;
-    case PIX_FMT_RGB24  : conv = palette8topacked24; break;
-    case PIX_FMT_BGR24  : conv = palette8topacked24; break;
-    default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
-                    sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
+    if (usePal(srcFormat)) {
+        switch (dstFormat) {
+        case PIX_FMT_RGB32  : conv = palette8topacked32; break;
+        case PIX_FMT_BGR32  : conv = palette8topacked32; break;
+        case PIX_FMT_BGR32_1: conv = palette8topacked32; break;
+        case PIX_FMT_RGB32_1: conv = palette8topacked32; break;
+        case PIX_FMT_RGB24  : conv = palette8topacked24; break;
+        case PIX_FMT_BGR24  : conv = palette8topacked24; break;
+        }
     }
 
-
-    for (i=0; i<srcSliceH; i++) {
-        conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
-        srcPtr+= srcStride[0];
-        dstPtr+= dstStride[0];
+    if (!conv)
+        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
+               sws_format_name(srcFormat), sws_format_name(dstFormat));
+    else {
+        for (i=0; i<srcSliceH; i++) {
+            conv(srcPtr, dstPtr, c->srcW, (uint8_t *) c->pal_rgb);
+            srcPtr+= srcStride[0];
+            dstPtr+= dstStride[0];
+        }
     }
 
     return srcSliceH;
@@ -2085,8 +2077,6 @@ static int rgb2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[],
         case 0x83: conv= rgb15to32; break;
         case 0x84: conv= rgb16to32; break;
         case 0x86: conv= rgb24to32; break;
-        default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
-                        sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
         }
     } else if (  (isBGR(srcFormat) && isRGB(dstFormat))
              || (isRGB(srcFormat) && isBGR(dstFormat))) {
@@ -2107,15 +2097,13 @@ static int rgb2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[],
         case 0x84: conv= rgb16tobgr32; break;
         case 0x86: conv= rgb24tobgr32; break;
         case 0x88: conv= rgb32tobgr32; break;
-        default: av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
-                        sws_format_name(srcFormat), sws_format_name(dstFormat)); break;
         }
-    } else {
-        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
-               sws_format_name(srcFormat), sws_format_name(dstFormat));
     }
 
-    if(conv) {
+    if (!conv) {
+        av_log(c, AV_LOG_ERROR, "internal error %s -> %s converter\n",
+               sws_format_name(srcFormat), sws_format_name(dstFormat));
+    } else {
         const uint8_t *srcPtr= src[0];
         if(srcFormat == PIX_FMT_RGB32_1 || srcFormat == PIX_FMT_BGR32_1)
             srcPtr += ALT32_CORR;
@@ -2139,7 +2127,6 @@ static int rgb2rgbWrapper(SwsContext *c, const uint8_t* src[], int srcStride[],
 static int bgr24toyv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
                               int srcSliceH, uint8_t* dst[], int dstStride[])
 {
-
     rgb24toyv12(
         src[0],
         dst[0]+ srcSliceY    *dstStride[0],
@@ -2152,7 +2139,7 @@ static int bgr24toyv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride
     return srcSliceH;
 }
 
-static int yvu9toyv12Wrapper(SwsContext *c, const const uint8_t* src[], int srcStride[], int srcSliceY,
+static int yvu9toyv12Wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
                              int srcSliceH, uint8_t* dst[], int dstStride[])
 {
     int i;
@@ -2273,7 +2260,6 @@ static int planarCopy(SwsContext *c, const uint8_t* src[], int srcStride[], int
     return srcSliceH;
 }
 
-
 static void getSubSampleFactors(int *h, int *v, enum PixelFormat format)
 {
     *h = av_pix_fmt_descriptors[format].log2_chroma_w;
@@ -2387,7 +2373,8 @@ static int handle_jpeg(enum PixelFormat *format)
     }
 }
 
-SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int dstW, int dstH, enum PixelFormat dstFormat, int flags,
+SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
+                           int dstW, int dstH, enum PixelFormat dstFormat, int flags,
                            SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
 {
 
@@ -2723,8 +2710,6 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         }
     } // initialize horizontal stuff
 
-
-
     /* precalculate vertical scaler filter coefficients */
     {
         const int filterAlign=
@@ -2942,8 +2927,8 @@ static void reset_ptr(const uint8_t* src[], int format)
  * swscale wrapper, so we don't need to export the SwsContext.
  * Assumes planar YUV to be in YUV order instead of YVU.
  */
-int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
-              int srcSliceH, uint8_t* dst[], int dstStride[])
+int sws_scale(SwsContext *c, const uint8_t* const src[], const int srcStride[], int srcSliceY,
+              int srcSliceH, uint8_t* const dst[], const int dstStride[])
 {
     int i;
     const uint8_t* src2[4]= {src[0], src[1], src[2], src[3]};
@@ -2965,7 +2950,7 @@ int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSlice
         for (i=0; i<256; i++) {
             int p, r, g, b,y,u,v;
             if(c->srcFormat == PIX_FMT_PAL8) {
-                p=((uint32_t*)(src[1]))[i];
+                p=((const uint32_t*)(src[1]))[i];
                 r= (p>>16)&0xFF;
                 g= (p>> 8)&0xFF;
                 b=  p     &0xFF;
@@ -2992,7 +2977,6 @@ int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSlice
             v= av_clip_uint8((RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT);
             c->pal_yuv[i]= y + (u<<8) + (v<<16);
 
-
             switch(c->dstFormat) {
             case PIX_FMT_BGR32:
 #if !HAVE_BIGENDIAN
@@ -3063,7 +3047,7 @@ int sws_scale(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSlice
 }
 
 #if LIBSWSCALE_VERSION_MAJOR < 1
-int sws_scale_ordered(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY,
+int sws_scale_ordered(SwsContext *c, const uint8_t* const src[], int srcStride[], int srcSliceY,
                       int srcSliceH, uint8_t* dst[], int dstStride[])
 {
     return sws_scale(c, src, srcStride, srcSliceY, srcSliceH, dst, dstStride);
@@ -3176,7 +3160,6 @@ SwsVector *sws_getConstVec(double c, int length)
     return vec;
 }
 
-
 SwsVector *sws_getIdentityVec(void)
 {
     return sws_getConstVec(1.0, 1);
@@ -3369,7 +3352,6 @@ void sws_freeFilter(SwsFilter *filter)
     av_free(filter);
 }
 
-
 void sws_freeContext(SwsContext *c)
 {
     int i;