Commit fdf4eb79 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '945673f7'

* commit '945673f7':
  dsputil_template: K&R formatting cosmetics

Conflicts:
	libavcodec/dsputil_template.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 3a27f968 945673f7
...@@ -31,18 +31,19 @@ ...@@ -31,18 +31,19 @@
#if BIT_DEPTH == 8 #if BIT_DEPTH == 8
/* draw the edges of width 'w' of an image of size width, height */ /* draw the edges of width 'w' of an image of size width, height */
//FIXME check that this is ok for mpeg4 interlaced // FIXME: Check that this is OK for MPEG-4 interlaced.
static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, int w, int h, int sides) static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height,
int w, int h, int sides)
{ {
pixel *buf = (pixel*)_buf; pixel *buf = (pixel *) _buf;
int wrap = _wrap / sizeof(pixel); int wrap = _wrap / sizeof(pixel);
pixel *ptr = buf, *last_line; pixel *ptr = buf, *last_line;
int i; int i;
/* left and right */ /* left and right */
for(i=0;i<height;i++) { for (i = 0; i < height; i++) {
memset(ptr - w, ptr[0], w); memset(ptr - w, ptr[0], w);
memset(ptr + width, ptr[width-1], w); memset(ptr + width, ptr[width - 1], w);
ptr += wrap; ptr += wrap;
} }
...@@ -50,23 +51,25 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, i ...@@ -50,23 +51,25 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, i
buf -= w; buf -= w;
last_line = buf + (height - 1) * wrap; last_line = buf + (height - 1) * wrap;
if (sides & EDGE_TOP) if (sides & EDGE_TOP)
for(i = 0; i < h; i++) for (i = 0; i < h; i++)
memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel)); // top // top
memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel));
if (sides & EDGE_BOTTOM) if (sides & EDGE_BOTTOM)
for (i = 0; i < h; i++) for (i = 0; i < h; i++)
memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom // bottom
memcpy(last_line + (i + 1) * wrap, last_line,
(width + w + w) * sizeof(pixel));
} }
#endif #endif
static void FUNCC(get_pixels)(int16_t *av_restrict block, static void FUNCC(get_pixels)(int16_t *av_restrict block, const uint8_t *_pixels,
const uint8_t *_pixels,
int line_size) int line_size)
{ {
const pixel *pixels = (const pixel *) _pixels; const pixel *pixels = (const pixel *) _pixels;
int i; int i;
/* read the pixels */ /* read the pixels */
for(i=0;i<8;i++) { for (i = 0; i < 8; i++) {
block[0] = pixels[0]; block[0] = pixels[0];
block[1] = pixels[1]; block[1] = pixels[1];
block[2] = pixels[2]; block[2] = pixels[2];
...@@ -75,20 +78,20 @@ static void FUNCC(get_pixels)(int16_t *av_restrict block, ...@@ -75,20 +78,20 @@ static void FUNCC(get_pixels)(int16_t *av_restrict block,
block[5] = pixels[5]; block[5] = pixels[5];
block[6] = pixels[6]; block[6] = pixels[6];
block[7] = pixels[7]; block[7] = pixels[7];
pixels += line_size / sizeof(pixel); pixels += line_size / sizeof(pixel);
block += 8; block += 8;
} }
} }
#if BIT_DEPTH == 8 #if BIT_DEPTH == 8
static void FUNCC(clear_block)(int16_t *block) static void FUNCC(clear_block)(int16_t *block)
{ {
memset(block, 0, sizeof(int16_t)*64); memset(block, 0, sizeof(int16_t) * 64);
} }
static void FUNCC(clear_blocks)(int16_t *blocks) static void FUNCC(clear_blocks)(int16_t *blocks)
{ {
memset(blocks, 0, sizeof(int16_t)*6*64); memset(blocks, 0, sizeof(int16_t) * 6 * 64);
} }
#endif #endif
...@@ -96,154 +99,244 @@ static void FUNCC(clear_blocks)(int16_t *blocks) ...@@ -96,154 +99,244 @@ static void FUNCC(clear_blocks)(int16_t *blocks)
#include "hpel_template.c" #include "hpel_template.c"
#endif #endif
#define PIXOP2(OPNAME, OP) \ #define PIXOP2(OPNAME, OP) \
static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, \
int src_stride1, int src_stride2, int h){\ const uint8_t *src1, \
int i;\ const uint8_t *src2, \
for(i=0; i<h; i++){\ int dst_stride, \
pixel4 a,b;\ int src_stride1, \
a= AV_RN4P(&src1[i*src_stride1 ]);\ int src_stride2, \
b= AV_RN4P(&src2[i*src_stride2 ]);\ int h) \
OP(*((pixel4*)&dst[i*dst_stride ]), no_rnd_avg_pixel4(a, b));\ { \
a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\ int i; \
b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\ \
OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\ for (i = 0; i < h; i++) { \
}\ pixel4 a, b; \
}\ a = AV_RN4P(&src1[i * src_stride1]); \
\ b = AV_RN4P(&src2[i * src_stride2]); \
static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ OP(*((pixel4 *) &dst[i * dst_stride]), \
int src_stride1, int src_stride2, int h){\ no_rnd_avg_pixel4(a, b)); \
FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\ a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]); \
FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\ b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]); \
}\ OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]), \
\ no_rnd_avg_pixel4(a, b)); \
static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ } \
int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ } \
/* FIXME HIGH BIT DEPTH */\ \
int i;\ static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, \
for(i=0; i<h; i++){\ const uint8_t *src1, \
uint32_t a, b, c, d, l0, l1, h0, h1;\ const uint8_t *src2, \
a= AV_RN32(&src1[i*src_stride1]);\ int dst_stride, \
b= AV_RN32(&src2[i*src_stride2]);\ int src_stride1, \
c= AV_RN32(&src3[i*src_stride3]);\ int src_stride2, \
d= AV_RN32(&src4[i*src_stride4]);\ int h) \
l0= (a&0x03030303UL)\ { \
+ (b&0x03030303UL)\ FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst, src1, src2, dst_stride, \
+ 0x02020202UL;\ src_stride1, src_stride2, h); \
h0= ((a&0xFCFCFCFCUL)>>2)\ FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst + 8 * sizeof(pixel), \
+ ((b&0xFCFCFCFCUL)>>2);\ src1 + 8 * sizeof(pixel), \
l1= (c&0x03030303UL)\ src2 + 8 * sizeof(pixel), \
+ (d&0x03030303UL);\ dst_stride, src_stride1, \
h1= ((c&0xFCFCFCFCUL)>>2)\ src_stride2, h); \
+ ((d&0xFCFCFCFCUL)>>2);\ } \
OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ \
a= AV_RN32(&src1[i*src_stride1+4]);\ static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, \
b= AV_RN32(&src2[i*src_stride2+4]);\ const uint8_t *src1, \
c= AV_RN32(&src3[i*src_stride3+4]);\ const uint8_t *src2, \
d= AV_RN32(&src4[i*src_stride4+4]);\ const uint8_t *src3, \
l0= (a&0x03030303UL)\ const uint8_t *src4, \
+ (b&0x03030303UL)\ int dst_stride, \
+ 0x02020202UL;\ int src_stride1, \
h0= ((a&0xFCFCFCFCUL)>>2)\ int src_stride2, \
+ ((b&0xFCFCFCFCUL)>>2);\ int src_stride3, \
l1= (c&0x03030303UL)\ int src_stride4, \
+ (d&0x03030303UL);\ int h) \
h1= ((c&0xFCFCFCFCUL)>>2)\ { \
+ ((d&0xFCFCFCFCUL)>>2);\ /* FIXME HIGH BIT DEPTH */ \
OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ int i; \
}\ \
}\ for (i = 0; i < h; i++) { \
\ uint32_t a, b, c, d, l0, l1, h0, h1; \
static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ a = AV_RN32(&src1[i * src_stride1]); \
int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ b = AV_RN32(&src2[i * src_stride2]); \
/* FIXME HIGH BIT DEPTH*/\ c = AV_RN32(&src3[i * src_stride3]); \
int i;\ d = AV_RN32(&src4[i * src_stride4]); \
for(i=0; i<h; i++){\ l0 = (a & 0x03030303UL) + \
uint32_t a, b, c, d, l0, l1, h0, h1;\ (b & 0x03030303UL) + \
a= AV_RN32(&src1[i*src_stride1]);\ 0x02020202UL; \
b= AV_RN32(&src2[i*src_stride2]);\ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
c= AV_RN32(&src3[i*src_stride3]);\ ((b & 0xFCFCFCFCUL) >> 2); \
d= AV_RN32(&src4[i*src_stride4]);\ l1 = (c & 0x03030303UL) + \
l0= (a&0x03030303UL)\ (d & 0x03030303UL); \
+ (b&0x03030303UL)\ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ 0x01010101UL;\ ((d & 0xFCFCFCFCUL) >> 2); \
h0= ((a&0xFCFCFCFCUL)>>2)\ OP(*((uint32_t *) &dst[i * dst_stride]), \
+ ((b&0xFCFCFCFCUL)>>2);\ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
l1= (c&0x03030303UL)\ a = AV_RN32(&src1[i * src_stride1 + 4]); \
+ (d&0x03030303UL);\ b = AV_RN32(&src2[i * src_stride2 + 4]); \
h1= ((c&0xFCFCFCFCUL)>>2)\ c = AV_RN32(&src3[i * src_stride3 + 4]); \
+ ((d&0xFCFCFCFCUL)>>2);\ d = AV_RN32(&src4[i * src_stride4 + 4]); \
OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ l0 = (a & 0x03030303UL) + \
a= AV_RN32(&src1[i*src_stride1+4]);\ (b & 0x03030303UL) + \
b= AV_RN32(&src2[i*src_stride2+4]);\ 0x02020202UL; \
c= AV_RN32(&src3[i*src_stride3+4]);\ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
d= AV_RN32(&src4[i*src_stride4+4]);\ ((b & 0xFCFCFCFCUL) >> 2); \
l0= (a&0x03030303UL)\ l1 = (c & 0x03030303UL) + \
+ (b&0x03030303UL)\ (d & 0x03030303UL); \
+ 0x01010101UL;\ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
h0= ((a&0xFCFCFCFCUL)>>2)\ ((d & 0xFCFCFCFCUL) >> 2); \
+ ((b&0xFCFCFCFCUL)>>2);\ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
l1= (c&0x03030303UL)\ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
+ (d&0x03030303UL);\ } \
h1= ((c&0xFCFCFCFCUL)>>2)\ } \
+ ((d&0xFCFCFCFCUL)>>2);\ \
OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, \
}\ const uint8_t *src1, \
}\ const uint8_t *src2, \
static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ const uint8_t *src3, \
int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ const uint8_t *src4, \
FUNC(OPNAME ## _pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ int dst_stride, \
FUNC(OPNAME ## _pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ int src_stride1, \
}\ int src_stride2, \
static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\ int src_stride3, \
int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ int src_stride4, \
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ int h) \
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ { \
}\ /* FIXME HIGH BIT DEPTH */ \
\ int i; \
static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\ \
{\ for (i = 0; i < h; i++) { \
/* FIXME HIGH BIT DEPTH */\ uint32_t a, b, c, d, l0, l1, h0, h1; \
int j;\ a = AV_RN32(&src1[i * src_stride1]); \
for(j=0; j<2; j++){\ b = AV_RN32(&src2[i * src_stride2]); \
int i;\ c = AV_RN32(&src3[i * src_stride3]); \
const uint32_t a= AV_RN32(pixels );\ d = AV_RN32(&src4[i * src_stride4]); \
const uint32_t b= AV_RN32(pixels+1);\ l0 = (a & 0x03030303UL) + \
uint32_t l0= (a&0x03030303UL)\ (b & 0x03030303UL) + \
+ (b&0x03030303UL)\ 0x01010101UL; \
+ 0x02020202UL;\ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ ((b & 0xFCFCFCFCUL) >> 2); \
+ ((b&0xFCFCFCFCUL)>>2);\ l1 = (c & 0x03030303UL) + \
uint32_t l1,h1;\ (d & 0x03030303UL); \
\ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
pixels+=line_size;\ ((d & 0xFCFCFCFCUL) >> 2); \
for(i=0; i<h; i+=2){\ OP(*((uint32_t *) &dst[i * dst_stride]), \
uint32_t a= AV_RN32(pixels );\ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
uint32_t b= AV_RN32(pixels+1);\ a = AV_RN32(&src1[i * src_stride1 + 4]); \
l1= (a&0x03030303UL)\ b = AV_RN32(&src2[i * src_stride2 + 4]); \
+ (b&0x03030303UL);\ c = AV_RN32(&src3[i * src_stride3 + 4]); \
h1= ((a&0xFCFCFCFCUL)>>2)\ d = AV_RN32(&src4[i * src_stride4 + 4]); \
+ ((b&0xFCFCFCFCUL)>>2);\ l0 = (a & 0x03030303UL) + \
OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ (b & 0x03030303UL) + \
pixels+=line_size;\ 0x01010101UL; \
block +=line_size;\ h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
a= AV_RN32(pixels );\ ((b & 0xFCFCFCFCUL) >> 2); \
b= AV_RN32(pixels+1);\ l1 = (c & 0x03030303UL) + \
l0= (a&0x03030303UL)\ (d & 0x03030303UL); \
+ (b&0x03030303UL)\ h1 = ((c & 0xFCFCFCFCUL) >> 2) + \
+ 0x02020202UL;\ ((d & 0xFCFCFCFCUL) >> 2); \
h0= ((a&0xFCFCFCFCUL)>>2)\ OP(*((uint32_t *) &dst[i * dst_stride + 4]), \
+ ((b&0xFCFCFCFCUL)>>2);\ h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ } \
pixels+=line_size;\ } \
block +=line_size;\ static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, \
}\ const uint8_t *src1, \
pixels+=4-line_size*(h+1);\ const uint8_t *src2, \
block +=4-line_size*h;\ const uint8_t *src3, \
}\ const uint8_t *src4, \
}\ int dst_stride, \
\ int src_stride1, \
CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\ int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
{ \
FUNC(OPNAME ## _pixels8_l4)(dst, src1, src2, src3, src4, dst_stride, \
src_stride1, src_stride2, src_stride3, \
src_stride4, h); \
FUNC(OPNAME ## _pixels8_l4)(dst + 8 * sizeof(pixel), \
src1 + 8 * sizeof(pixel), \
src2 + 8 * sizeof(pixel), \
src3 + 8 * sizeof(pixel), \
src4 + 8 * sizeof(pixel), \
dst_stride, src_stride1, src_stride2, \
src_stride3, src_stride4, h); \
} \
static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, \
const uint8_t *src1, \
const uint8_t *src2, \
const uint8_t *src3, \
const uint8_t *src4, \
int dst_stride, \
int src_stride1, \
int src_stride2, \
int src_stride3, \
int src_stride4, \
int h) \
{ \
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst, src1, src2, src3, src4, \
dst_stride, src_stride1, src_stride2, \
src_stride3, src_stride4, h); \
FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst + 8 * sizeof(pixel), \
src1 + 8 * sizeof(pixel), \
src2 + 8 * sizeof(pixel), \
src3 + 8 * sizeof(pixel), \
src4 + 8 * sizeof(pixel), \
dst_stride, src_stride1, src_stride2, \
src_stride3, src_stride4, h); \
} \
\
static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, \
const uint8_t *pixels, \
ptrdiff_t line_size, \
int h) \
{ \
/* FIXME HIGH BIT DEPTH */ \
int j; \
\
for (j = 0; j < 2; j++) { \
int i; \
const uint32_t a = AV_RN32(pixels); \
const uint32_t b = AV_RN32(pixels + 1); \
uint32_t l0 = (a & 0x03030303UL) + \
(b & 0x03030303UL) + \
0x02020202UL; \
uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
((b & 0xFCFCFCFCUL) >> 2); \
uint32_t l1, h1; \
\
pixels += line_size; \
for (i = 0; i < h; i += 2) { \
uint32_t a = AV_RN32(pixels); \
uint32_t b = AV_RN32(pixels + 1); \
l1 = (a & 0x03030303UL) + \
(b & 0x03030303UL); \
h1 = ((a & 0xFCFCFCFCUL) >> 2) + \
((b & 0xFCFCFCFCUL) >> 2); \
OP(*((uint32_t *) block), \
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
pixels += line_size; \
block += line_size; \
a = AV_RN32(pixels); \
b = AV_RN32(pixels + 1); \
l0 = (a & 0x03030303UL) + \
(b & 0x03030303UL) + \
0x02020202UL; \
h0 = ((a & 0xFCFCFCFCUL) >> 2) + \
((b & 0xFCFCFCFCUL) >> 2); \
OP(*((uint32_t *) block), \
h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL)); \
pixels += line_size; \
block += line_size; \
} \
pixels += 4 - line_size * (h + 1); \
block += 4 - line_size * h; \
} \
} \
\
CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), \
FUNCC(OPNAME ## _pixels8_xy2), \
8 * sizeof(pixel)) \
#define op_avg(a, b) a = rnd_avg_pixel4(a, b) #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
#define op_put(a, b) a = b #define op_put(a, b) a = b
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment