00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00027 #include "dsputil.h"
00028 #include "rv34dsp.h"
00029 #include "libavutil/common.h"
00030
00036 static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block)
00037 {
00038 int i;
00039
00040 for(i = 0; i < 4; i++){
00041 const int z0 = 13*(block[i+4*0] + block[i+4*2]);
00042 const int z1 = 13*(block[i+4*0] - block[i+4*2]);
00043 const int z2 = 7* block[i+4*1] - 17*block[i+4*3];
00044 const int z3 = 17* block[i+4*1] + 7*block[i+4*3];
00045
00046 temp[4*i+0] = z0 + z3;
00047 temp[4*i+1] = z1 + z2;
00048 temp[4*i+2] = z1 - z2;
00049 temp[4*i+3] = z0 - z3;
00050 }
00051 }
00052
00057 static void rv34_idct_add_c(uint8_t *dst, ptrdiff_t stride, DCTELEM *block){
00058 int temp[16];
00059 int i;
00060
00061 rv34_row_transform(temp, block);
00062 memset(block, 0, 16*sizeof(DCTELEM));
00063
00064 for(i = 0; i < 4; i++){
00065 const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200;
00066 const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200;
00067 const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i];
00068 const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i];
00069
00070 dst[0] = av_clip_uint8( dst[0] + ( (z0 + z3) >> 10 ) );
00071 dst[1] = av_clip_uint8( dst[1] + ( (z1 + z2) >> 10 ) );
00072 dst[2] = av_clip_uint8( dst[2] + ( (z1 - z2) >> 10 ) );
00073 dst[3] = av_clip_uint8( dst[3] + ( (z0 - z3) >> 10 ) );
00074
00075 dst += stride;
00076 }
00077 }
00078
00085 static void rv34_inv_transform_noround_c(DCTELEM *block){
00086 int temp[16];
00087 int i;
00088
00089 rv34_row_transform(temp, block);
00090
00091 for(i = 0; i < 4; i++){
00092 const int z0 = 39*(temp[4*0+i] + temp[4*2+i]);
00093 const int z1 = 39*(temp[4*0+i] - temp[4*2+i]);
00094 const int z2 = 21* temp[4*1+i] - 51*temp[4*3+i];
00095 const int z3 = 51* temp[4*1+i] + 21*temp[4*3+i];
00096
00097 block[i*4+0] = (z0 + z3) >> 11;
00098 block[i*4+1] = (z1 + z2) >> 11;
00099 block[i*4+2] = (z1 - z2) >> 11;
00100 block[i*4+3] = (z0 - z3) >> 11;
00101 }
00102 }
00103
00104 static void rv34_idct_dc_add_c(uint8_t *dst, ptrdiff_t stride, int dc)
00105 {
00106 int i, j;
00107
00108 dc = (13*13*dc + 0x200) >> 10;
00109 for (i = 0; i < 4; i++)
00110 {
00111 for (j = 0; j < 4; j++)
00112 dst[j] = av_clip_uint8( dst[j] + dc );
00113
00114 dst += stride;
00115 }
00116 }
00117
00118 static void rv34_inv_transform_dc_noround_c(DCTELEM *block)
00119 {
00120 DCTELEM dc = (13 * 13 * 3 * block[0]) >> 11;
00121 int i, j;
00122
00123 for (i = 0; i < 4; i++, block += 4)
00124 for (j = 0; j < 4; j++)
00125 block[j] = dc;
00126 }
00127
00129
00130
00131 av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) {
00132 c->rv34_inv_transform = rv34_inv_transform_noround_c;
00133 c->rv34_inv_transform_dc = rv34_inv_transform_dc_noround_c;
00134
00135 c->rv34_idct_add = rv34_idct_add_c;
00136 c->rv34_idct_dc_add = rv34_idct_dc_add_c;
00137
00138 if (HAVE_NEON)
00139 ff_rv34dsp_init_neon(c, dsp);
00140 if (HAVE_MMX)
00141 ff_rv34dsp_init_x86(c, dsp);
00142 }