00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00028 #include "dsputil.h"
00029 #include "eaidct.h"
00030 #include "libavutil/common.h"
00031
00032 #define ASQRT 181
00033 #define A4 669
00034 #define A2 277
00035 #define A5 196
00036
00037 #define IDCT_TRANSFORM(dest,s0,s1,s2,s3,s4,s5,s6,s7,d0,d1,d2,d3,d4,d5,d6,d7,munge,src) {\
00038 const int a1 = (src)[s1] + (src)[s7]; \
00039 const int a7 = (src)[s1] - (src)[s7]; \
00040 const int a5 = (src)[s5] + (src)[s3]; \
00041 const int a3 = (src)[s5] - (src)[s3]; \
00042 const int a2 = (src)[s2] + (src)[s6]; \
00043 const int a6 = (ASQRT*((src)[s2] - (src)[s6]))>>8; \
00044 const int a0 = (src)[s0] + (src)[s4]; \
00045 const int a4 = (src)[s0] - (src)[s4]; \
00046 const int b0 = (((A4-A5)*a7 - A5*a3)>>9) + a1+a5; \
00047 const int b1 = (((A4-A5)*a7 - A5*a3)>>9) + ((ASQRT*(a1-a5))>>8); \
00048 const int b2 = (((A2+A5)*a3 + A5*a7)>>9) + ((ASQRT*(a1-a5))>>8); \
00049 const int b3 = ((A2+A5)*a3 + A5*a7)>>9; \
00050 (dest)[d0] = munge(a0+a2+a6+b0); \
00051 (dest)[d1] = munge(a4+a6 +b1); \
00052 (dest)[d2] = munge(a4-a6 +b2); \
00053 (dest)[d3] = munge(a0-a2-a6+b3); \
00054 (dest)[d4] = munge(a0-a2-a6-b3); \
00055 (dest)[d5] = munge(a4-a6 -b2); \
00056 (dest)[d6] = munge(a4+a6 -b1); \
00057 (dest)[d7] = munge(a0+a2+a6-b0); \
00058 }
00059
00060
00061 #define MUNGE_NONE(x) (x)
00062 #define IDCT_COL(dest,src) IDCT_TRANSFORM(dest,0,8,16,24,32,40,48,56,0,8,16,24,32,40,48,56,MUNGE_NONE,src)
00063
00064 #define MUNGE_8BIT(x) av_clip_uint8((x)>>4)
00065 #define IDCT_ROW(dest,src) IDCT_TRANSFORM(dest,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,MUNGE_8BIT,src)
00066
00067 static inline void ea_idct_col(DCTELEM *dest, const DCTELEM *src) {
00068 if ((src[8]|src[16]|src[24]|src[32]|src[40]|src[48]|src[56])==0) {
00069 dest[0] =
00070 dest[8] =
00071 dest[16] =
00072 dest[24] =
00073 dest[32] =
00074 dest[40] =
00075 dest[48] =
00076 dest[56] = src[0];
00077 }else
00078 IDCT_COL(dest, src);
00079 }
00080
00081 void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block) {
00082 int i;
00083 DCTELEM temp[64];
00084 block[0] += 4;
00085 for (i=0; i<8; i++)
00086 ea_idct_col(&temp[i], &block[i]);
00087 for (i=0; i<8; i++)
00088 IDCT_ROW( (&dest[i*linesize]), (&temp[8*i]) );
00089 }