* simpleidct in C.
*/
-/*
- based upon some outcommented c code from mpeg2dec (idct_mmx.c
- written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>)
- */
+/* Based upon some commented-out C code from mpeg2dec (idct_mmx.c
+ * written by Aaron Holtzman <aholtzma@ess.engr.uvic.ca>). */
+
+#include "simple_idct.h"
#include "bit_depth_template.c"
#endif
-static inline void FUNC(idctRowCondDC)(DCTELEM *row, int extra_shift)
+static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
#if HAVE_FAST_64BIT
#define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN)
- if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) {
+ if (((AV_RN64A(row) & ~ROW0_MASK) | AV_RN64A(row+4)) == 0) {
uint64_t temp;
if (DC_SHIFT - extra_shift > 0) {
- temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
+ temp = (row[0] * (1 << (DC_SHIFT - extra_shift))) & 0xffff;
} else {
temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
}
- temp += temp << 16;
- temp += temp << 32;
- ((uint64_t *)row)[0] = temp;
- ((uint64_t *)row)[1] = temp;
+ temp += temp * (1 << 16);
+ temp += temp * ((uint64_t) 1 << 32);
+ AV_WN64A(row, temp);
+ AV_WN64A(row + 4, temp);
return;
}
#else
- if (!(((uint32_t*)row)[1] |
- ((uint32_t*)row)[2] |
- ((uint32_t*)row)[3] |
+ if (!(AV_RN32A(row+2) |
+ AV_RN32A(row+4) |
+ AV_RN32A(row+6) |
row[1])) {
uint32_t temp;
if (DC_SHIFT - extra_shift > 0) {
- temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff;
+ temp = (row[0] * (1 << (DC_SHIFT - extra_shift))) & 0xffff;
} else {
temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff;
}
- temp += temp << 16;
- ((uint32_t*)row)[0]=((uint32_t*)row)[1] =
- ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp;
+ temp += temp * (1 << 16);
+ AV_WN32A(row, temp);
+ AV_WN32A(row+2, temp);
+ AV_WN32A(row+4, temp);
+ AV_WN32A(row+6, temp);
return;
}
#endif
} \
} while (0)
-static inline void FUNC(idctSparseColPut)(pixel *dest, int line_size,
- DCTELEM *col)
+static inline void FUNC(idctSparseColPut)(pixel *dest, ptrdiff_t line_size,
+ int16_t *col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
dest[0] = av_clip_pixel((a0 - b0) >> COL_SHIFT);
}
-static inline void FUNC(idctSparseColAdd)(pixel *dest, int line_size,
- DCTELEM *col)
+static inline void FUNC(idctSparseColAdd)(pixel *dest, ptrdiff_t line_size,
+ int16_t *col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
dest[0] = av_clip_pixel(dest[0] + ((a0 - b0) >> COL_SHIFT));
}
-static inline void FUNC(idctSparseCol)(DCTELEM *col)
+static inline void FUNC(idctSparseCol)(int16_t *col)
{
int a0, a1, a2, a3, b0, b1, b2, b3;
col[56] = ((a0 - b0) >> COL_SHIFT);
}
-void FUNC(ff_simple_idct_put)(uint8_t *dest_, int line_size, DCTELEM *block)
+void FUNC(ff_simple_idct_put)(uint8_t *dest_, ptrdiff_t line_size, int16_t *block)
{
pixel *dest = (pixel *)dest_;
int i;
FUNC(idctSparseColPut)(dest + i, line_size, block + i);
}
-void FUNC(ff_simple_idct_add)(uint8_t *dest_, int line_size, DCTELEM *block)
+void FUNC(ff_simple_idct_add)(uint8_t *dest_, ptrdiff_t line_size, int16_t *block)
{
pixel *dest = (pixel *)dest_;
int i;
FUNC(idctSparseColAdd)(dest + i, line_size, block + i);
}
-void FUNC(ff_simple_idct)(DCTELEM *block)
+void FUNC(ff_simple_idct)(int16_t *block)
{
int i;