libavcodec/x86/vp3dsp_sse2.c

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 the ffmpeg project
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00026 #include "libavcodec/dsputil.h"
00027 #include "dsputil_mmx.h"
00028 
00029 DECLARE_ALIGNED_16(const uint16_t, ff_vp3_idct_data[7 * 8]) =
00030 {
00031 64277,64277,64277,64277,64277,64277,64277,64277,
00032 60547,60547,60547,60547,60547,60547,60547,60547,
00033 54491,54491,54491,54491,54491,54491,54491,54491,
00034 46341,46341,46341,46341,46341,46341,46341,46341,
00035 36410,36410,36410,36410,36410,36410,36410,36410,
00036 25080,25080,25080,25080,25080,25080,25080,25080,
00037 12785,12785,12785,12785,12785,12785,12785,12785
00038 };
00039 
00040 
00041 #define VP3_1D_IDCT_SSE2(ADD, SHIFT) \
00042  "movdqa "I(3)", %%xmm2 \n\t" /* xmm2 = i3 */ \
00043 "movdqa "C(3)", %%xmm6 \n\t" /* xmm6 = c3 */ \
00044 "movdqa %%xmm2, %%xmm4 \n\t" /* xmm4 = i3 */ \
00045 "movdqa "I(5)", %%xmm7 \n\t" /* xmm7 = i5 */ \
00046 "pmulhw %%xmm6, %%xmm4 \n\t" /* xmm4 = c3 * i3 - i3 */ \
00047 "movdqa "C(5)", %%xmm1 \n\t" /* xmm1 = c5 */ \
00048 "pmulhw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 - i5 */ \
00049 "movdqa %%xmm1, %%xmm5 \n\t" /* xmm5 = c5 */ \
00050 "pmulhw %%xmm2, %%xmm1 \n\t" /* xmm1 = c5 * i3 - i3 */ \
00051 "movdqa "I(1)", %%xmm3 \n\t" /* xmm3 = i1 */ \
00052 "pmulhw %%xmm7, %%xmm5 \n\t" /* xmm5 = c5 * i5 - i5 */ \
00053 "movdqa "C(1)", %%xmm0 \n\t" /* xmm0 = c1 */ \
00054 "paddw %%xmm2, %%xmm4 \n\t" /* xmm4 = c3 * i3 */ \
00055 "paddw %%xmm7, %%xmm6 \n\t" /* xmm6 = c3 * i5 */ \
00056 "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = c5 * i3 */ \
00057 "movdqa "I(7)", %%xmm1 \n\t" /* xmm1 = i7 */ \
00058 "paddw %%xmm5, %%xmm7 \n\t" /* xmm7 = c5 * i5 */ \
00059 "movdqa %%xmm0, %%xmm5 \n\t" /* xmm5 = c1 */ \
00060 "pmulhw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 - i1 */ \
00061 "paddsw %%xmm7, %%xmm4 \n\t" /* xmm4 = c3 * i3 + c5 * i5 = C */ \
00062 "pmulhw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 - i7 */ \
00063 "movdqa "C(7)", %%xmm7 \n\t" /* xmm7 = c7 */ \
00064 "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = c3 * i5 - c5 * i3 = D */ \
00065 "paddw %%xmm3, %%xmm0 \n\t" /* xmm0 = c1 * i1 */ \
00066 "pmulhw %%xmm7, %%xmm3 \n\t" /* xmm3 = c7 * i1 */ \
00067 "movdqa "I(2)", %%xmm2 \n\t" /* xmm2 = i2 */ \
00068 "pmulhw %%xmm1, %%xmm7 \n\t" /* xmm7 = c7 * i7 */ \
00069 "paddw %%xmm1, %%xmm5 \n\t" /* xmm5 = c1 * i7 */ \
00070 "movdqa %%xmm2, %%xmm1 \n\t" /* xmm1 = i2 */ \
00071 "pmulhw "C(2)", %%xmm2 \n\t" /* xmm2 = i2 * c2 -i2 */ \
00072 "psubsw %%xmm5, %%xmm3 \n\t" /* xmm3 = c7 * i1 - c1 * i7 = B */ \
00073 "movdqa "I(6)", %%xmm5 \n\t" /* xmm5 = i6 */ \
00074 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = c1 * i1 + c7 * i7 = A */ \
00075 "movdqa %%xmm5, %%xmm7 \n\t" /* xmm7 = i6 */ \
00076 "psubsw %%xmm4, %%xmm0 \n\t" /* xmm0 = A - C */ \
00077 "pmulhw "C(2)", %%xmm5 \n\t" /* xmm5 = c2 * i6 - i6 */ \
00078 "paddw %%xmm1, %%xmm2 \n\t" /* xmm2 = i2 * c2 */ \
00079 "pmulhw "C(6)", %%xmm1 \n\t" /* xmm1 = c6 * i2 */ \
00080 "paddsw %%xmm4, %%xmm4 \n\t" /* xmm4 = C + C */ \
00081 "paddsw %%xmm0, %%xmm4 \n\t" /* xmm4 = A + C = C. */ \
00082 "psubsw %%xmm6, %%xmm3 \n\t" /* xmm3 = B - D */ \
00083 "paddw %%xmm7, %%xmm5 \n\t" /* xmm5 = c2 * i6 */ \
00084 "paddsw %%xmm6, %%xmm6 \n\t" /* xmm6 = D + D */ \
00085 "pmulhw "C(6)", %%xmm7 \n\t" /* xmm7 = c6 * i6 */ \
00086 "paddsw %%xmm3, %%xmm6 \n\t" /* xmm6 = B + D = D. */ \
00087 "movdqa %%xmm4, "I(1)" \n\t" /* Save C. at I(1) */ \
00088 "psubsw %%xmm5, %%xmm1 \n\t" /* xmm1 = c6 * i2 - c2 * i6 = H */ \
00089 "movdqa "C(4)", %%xmm4 \n\t" /* xmm4 = c4 */ \
00090 "movdqa %%xmm3, %%xmm5 \n\t" /* xmm5 = B - D */ \
00091 "pmulhw %%xmm4, %%xmm3 \n\t" /* xmm3 = ( c4 -1 ) * ( B - D ) */ \
00092 "paddsw %%xmm2, %%xmm7 \n\t" /* xmm7 = c2 * i2 + c6 * i6 = G */ \
00093 "movdqa %%xmm6, "I(2)" \n\t" /* Save D. at I(2) */ \
00094 "movdqa %%xmm0, %%xmm2 \n\t" /* xmm2 = A - C */ \
00095 "movdqa "I(0)", %%xmm6 \n\t" /* xmm6 = i0 */ \
00096 "pmulhw %%xmm4, %%xmm0 \n\t" /* xmm0 = ( c4 - 1 ) * ( A - C ) = A. */ \
00097 "paddw %%xmm3, %%xmm5 \n\t" /* xmm5 = c4 * ( B - D ) = B. */ \
00098 "movdqa "I(4)", %%xmm3 \n\t" /* xmm3 = i4 */ \
00099 "psubsw %%xmm1, %%xmm5 \n\t" /* xmm5 = B. - H = B.. */ \
00100 "paddw %%xmm0, %%xmm2 \n\t" /* xmm2 = c4 * ( A - C) = A. */ \
00101 "psubsw %%xmm3, %%xmm6 \n\t" /* xmm6 = i0 - i4 */ \
00102 "movdqa %%xmm6, %%xmm0 \n\t" /* xmm0 = i0 - i4 */ \
00103 "pmulhw %%xmm4, %%xmm6 \n\t" /* xmm6 = (c4 - 1) * (i0 - i4) = F */ \
00104 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = i4 + i4 */ \
00105 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H + H */ \
00106 "paddsw %%xmm0, %%xmm3 \n\t" /* xmm3 = i0 + i4 */ \
00107 "paddsw %%xmm5, %%xmm1 \n\t" /* xmm1 = B. + H = H. */ \
00108 "pmulhw %%xmm3, %%xmm4 \n\t" /* xmm4 = ( c4 - 1 ) * ( i0 + i4 ) */ \
00109 "paddw %%xmm0, %%xmm6 \n\t" /* xmm6 = c4 * ( i0 - i4 ) */ \
00110 "psubsw %%xmm2, %%xmm6 \n\t" /* xmm6 = F - A. = F. */ \
00111 "paddsw %%xmm2, %%xmm2 \n\t" /* xmm2 = A. + A. */ \
00112 "movdqa "I(1)", %%xmm0 \n\t" /* Load C. from I(1) */ \
00113 "paddsw %%xmm6, %%xmm2 \n\t" /* xmm2 = F + A. = A.. */ \
00114 "paddw %%xmm3, %%xmm4 \n\t" /* xmm4 = c4 * ( i0 + i4 ) = 3 */ \
00115 "psubsw %%xmm1, %%xmm2 \n\t" /* xmm2 = A.. - H. = R2 */ \
00116 ADD(%%xmm2) /* Adjust R2 and R1 before shifting */ \
00117 "paddsw %%xmm1, %%xmm1 \n\t" /* xmm1 = H. + H. */ \
00118 "paddsw %%xmm2, %%xmm1 \n\t" /* xmm1 = A.. + H. = R1 */ \
00119 SHIFT(%%xmm2) /* xmm2 = op2 */ \
00120 "psubsw %%xmm7, %%xmm4 \n\t" /* xmm4 = E - G = E. */ \
00121 SHIFT(%%xmm1) /* xmm1 = op1 */ \
00122 "movdqa "I(2)", %%xmm3 \n\t" /* Load D. from I(2) */ \
00123 "paddsw %%xmm7, %%xmm7 \n\t" /* xmm7 = G + G */ \
00124 "paddsw %%xmm4, %%xmm7 \n\t" /* xmm7 = E + G = G. */ \
00125 "psubsw %%xmm3, %%xmm4 \n\t" /* xmm4 = E. - D. = R4 */ \
00126 ADD(%%xmm4) /* Adjust R4 and R3 before shifting */ \
00127 "paddsw %%xmm3, %%xmm3 \n\t" /* xmm3 = D. + D. */ \
00128 "paddsw %%xmm4, %%xmm3 \n\t" /* xmm3 = E. + D. = R3 */ \
00129 SHIFT(%%xmm4) /* xmm4 = op4 */ \
00130 "psubsw %%xmm5, %%xmm6 \n\t" /* xmm6 = F. - B..= R6 */ \
00131 SHIFT(%%xmm3) /* xmm3 = op3 */ \
00132 ADD(%%xmm6) /* Adjust R6 and R5 before shifting */ \
00133 "paddsw %%xmm5, %%xmm5 \n\t" /* xmm5 = B.. + B.. */ \
00134 "paddsw %%xmm6, %%xmm5 \n\t" /* xmm5 = F. + B.. = R5 */ \
00135 SHIFT(%%xmm6) /* xmm6 = op6 */ \
00136 SHIFT(%%xmm5) /* xmm5 = op5 */ \
00137 "psubsw %%xmm0, %%xmm7 \n\t" /* xmm7 = G. - C. = R7 */ \
00138 ADD(%%xmm7) /* Adjust R7 and R0 before shifting */ \
00139 "paddsw %%xmm0, %%xmm0 \n\t" /* xmm0 = C. + C. */ \
00140 "paddsw %%xmm7, %%xmm0 \n\t" /* xmm0 = G. + C. */ \
00141 SHIFT(%%xmm7) /* xmm7 = op7 */ \
00142 SHIFT(%%xmm0) /* xmm0 = op0 */
00143 
00144 #define PUT_BLOCK(r0, r1, r2, r3, r4, r5, r6, r7) \
00145  "movdqa " #r0 ", " O(0) "\n\t" \
00146  "movdqa " #r1 ", " O(1) "\n\t" \
00147  "movdqa " #r2 ", " O(2) "\n\t" \
00148  "movdqa " #r3 ", " O(3) "\n\t" \
00149  "movdqa " #r4 ", " O(4) "\n\t" \
00150  "movdqa " #r5 ", " O(5) "\n\t" \
00151  "movdqa " #r6 ", " O(6) "\n\t" \
00152  "movdqa " #r7 ", " O(7) "\n\t"
00153 
00154 #define NOP(xmm)
00155 #define SHIFT4(xmm) "psraw 4,ドル "#xmm"\n\t"
00156 #define ADD8(xmm) "paddsw %2, "#xmm"\n\t"
00157 
00158 void ff_vp3_idct_sse2(int16_t *input_data)
00159 {
00160 #define I(x) AV_STRINGIFY(16*x)"(%0)"
00161 #define O(x) I(x)
00162 #define C(x) AV_STRINGIFY(16*(x-1))"(%1)"
00163 
00164 __asm__ volatile (
00165 VP3_1D_IDCT_SSE2(NOP, NOP)
00166 
00167 TRANSPOSE8(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7, (%0))
00168 PUT_BLOCK(%%xmm0, %%xmm5, %%xmm7, %%xmm3, %%xmm6, %%xmm4, %%xmm2, %%xmm1)
00169 
00170 VP3_1D_IDCT_SSE2(ADD8, SHIFT4)
00171 PUT_BLOCK(%%xmm0, %%xmm1, %%xmm2, %%xmm3, %%xmm4, %%xmm5, %%xmm6, %%xmm7)
00172 :: "r"(input_data), "r"(ff_vp3_idct_data), "m"(ff_pw_8)
00173 );
00174 }
00175 
00176 void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, DCTELEM *block)
00177 {
00178 ff_vp3_idct_sse2(block);
00179 put_signed_pixels_clamped_mmx(block, dest, line_size);
00180 }
00181 
00182 void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, DCTELEM *block)
00183 {
00184 ff_vp3_idct_sse2(block);
00185 add_pixels_clamped_mmx(block, dest, line_size);
00186 }

Generated on Fri Oct 26 02:35:40 2012 for FFmpeg by doxygen 1.5.8

AltStyle によって変換されたページ (->オリジナル) /