Libav 0.7.1
|
00001 /* 00002 * copyright (c) 2004 AGAWA Koji 00003 * 00004 * This file is part of Libav. 00005 * 00006 * Libav 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 * Libav 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 Libav; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include "libavutil/cpu.h" 00022 #include "libavcodec/avcodec.h" 00023 #include "libavcodec/dsputil.h" 00024 #include "libavcodec/mpegvideo.h" 00025 #include "mpegvideo_arm.h" 00026 00027 static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s, 00028 DCTELEM *block, int n, int qscale) 00029 { 00030 int level, qmul, qadd; 00031 int nCoeffs; 00032 DCTELEM *block_orig = block; 00033 00034 assert(s->block_last_index[n]>=0); 00035 00036 qmul = qscale << 1; 00037 00038 if (!s->h263_aic) { 00039 if (n < 4) 00040 level = block[0] * s->y_dc_scale; 00041 else 00042 level = block[0] * s->c_dc_scale; 00043 qadd = (qscale - 1) | 1; 00044 }else{ 00045 qadd = 0; 00046 level = block[0]; 00047 } 00048 if(s->ac_pred) 00049 nCoeffs=63; 00050 else 00051 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; 00052 00053 __asm__ volatile ( 00054 /* "movd %1, %%mm6 \n\t" //qmul */ 00055 /* "packssdw %%mm6, %%mm6 \n\t" */ 00056 /* "packssdw %%mm6, %%mm6 \n\t" */ 00057 "tbcsth wr6, %[qmul] \n\t" 00058 /* "movd %2, %%mm5 \n\t" //qadd */ 00059 /* "packssdw %%mm5, %%mm5 \n\t" */ 00060 /* "packssdw %%mm5, %%mm5 \n\t" */ 00061 "tbcsth wr5, %[qadd] \n\t" 00062 "wzero wr7 \n\t" /* "pxor %%mm7, %%mm7 \n\t" */ 00063 "wzero wr4 \n\t" /* "pxor %%mm4, %%mm4 \n\t" */ 00064 "wsubh wr7, wr5, wr7 \n\t" /* "psubw %%mm5, %%mm7 \n\t" */ 00065 "1: \n\t" 00066 "wldrd wr2, [%[block]] \n\t" /* "movq (%0, %3), %%mm0 \n\t" */ 00067 "wldrd wr3, [%[block], #8] \n\t" /* "movq 8(%0, %3), %%mm1 \n\t" */ 00068 "wmulsl wr0, wr6, wr2 \n\t" /* "pmullw %%mm6, %%mm0 \n\t" */ 00069 "wmulsl wr1, wr6, wr3 \n\t" /* "pmullw %%mm6, %%mm1 \n\t" */ 00070 /* "movq (%0, %3), %%mm2 \n\t" */ 00071 /* "movq 8(%0, %3), %%mm3 \n\t" */ 00072 "wcmpgtsh wr2, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 */ 00073 "wcmpgtsh wr3, wr4, wr2 \n\t" /* "pcmpgtw %%mm4, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 */ 00074 "wxor wr0, wr2, wr0 \n\t" /* "pxor %%mm2, %%mm0 \n\t" */ 00075 "wxor wr1, wr3, wr1 \n\t" /* "pxor %%mm3, %%mm1 \n\t" */ 00076 "waddh wr0, wr7, wr0 \n\t" /* "paddw %%mm7, %%mm0 \n\t" */ 00077 "waddh wr1, wr7, wr1 \n\t" /* "paddw %%mm7, %%mm1 \n\t" */ 00078 "wxor wr2, wr0, wr2 \n\t" /* "pxor %%mm0, %%mm2 \n\t" */ 00079 "wxor wr3, wr1, wr3 \n\t" /* "pxor %%mm1, %%mm3 \n\t" */ 00080 "wcmpeqh wr0, wr7, wr0 \n\t" /* "pcmpeqw %%mm7, %%mm0 \n\t" // block[i] == 0 ? -1 : 0 */ 00081 "wcmpeqh wr1, wr7, wr1 \n\t" /* "pcmpeqw %%mm7, %%mm1 \n\t" // block[i] == 0 ? -1 : 0 */ 00082 "wandn wr0, wr2, wr0 \n\t" /* "pandn %%mm2, %%mm0 \n\t" */ 00083 "wandn wr1, wr3, wr1 \n\t" /* "pandn %%mm3, %%mm1 \n\t" */ 00084 "wstrd wr0, [%[block]] \n\t" /* "movq %%mm0, (%0, %3) \n\t" */ 00085 "wstrd wr1, [%[block], #8] \n\t" /* "movq %%mm1, 8(%0, %3) \n\t" */ 00086 "add %[block], %[block], #16 \n\t" /* "addl $16, %3 \n\t" */ 00087 "subs %[i], %[i], #1 \n\t" 00088 "bne 1b \n\t" /* "jng 1b \n\t" */ 00089 :[block]"+r"(block) 00090 :[i]"r"((nCoeffs + 8) / 8), [qmul]"r"(qmul), [qadd]"r"(qadd) 00091 :"memory"); 00092 00093 block_orig[0] = level; 00094 } 00095 00096 #if 0 00097 static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s, 00098 DCTELEM *block, int n, int qscale) 00099 { 00100 int nCoeffs; 00101 00102 assert(s->block_last_index[n]>=0); 00103 00104 if(s->ac_pred) 00105 nCoeffs=63; 00106 else 00107 nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; 00108 00109 ippiQuantInvInter_Compact_H263_16s_I(block, nCoeffs+1, qscale); 00110 } 00111 #endif 00112 00113 void MPV_common_init_iwmmxt(MpegEncContext *s) 00114 { 00115 if (!(mm_flags & AV_CPU_FLAG_IWMMXT)) return; 00116 00117 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt; 00118 #if 0 00119 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_iwmmxt; 00120 #endif 00121 }