Libav 0.7.1
|
00001 /* 00002 * Copyright (c) 2000,2001 Fabrice Bellard 00003 * 00004 * MMI optimization by Leon van Stuivenberg 00005 * 00006 * This file is part of Libav. 00007 * 00008 * Libav is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * Libav is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with Libav; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #include "libavcodec/avcodec.h" 00024 #include "libavcodec/dsputil.h" 00025 #include "libavcodec/mpegvideo.h" 00026 00027 static void dct_unquantize_h263_mmi(MpegEncContext *s, 00028 DCTELEM *block, int n, int qscale) 00029 { 00030 int level=0, qmul, qadd; 00031 int nCoeffs; 00032 00033 assert(s->block_last_index[n]>=0); 00034 00035 qadd = (qscale - 1) | 1; 00036 qmul = qscale << 1; 00037 00038 if (s->mb_intra) { 00039 if (!s->h263_aic) { 00040 if (n < 4) 00041 level = block[0] * s->y_dc_scale; 00042 else 00043 level = block[0] * s->c_dc_scale; 00044 }else { 00045 qadd = 0; 00046 level = block[0]; 00047 } 00048 nCoeffs= 63; //does not always use zigzag table 00049 } else { 00050 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; 00051 } 00052 00053 __asm__ volatile( 00054 "add $14, $0, %3 \n\t" 00055 "pcpyld $8, %0, %0 \n\t" 00056 "pcpyh $8, $8 \n\t" //r8 = qmul 00057 "pcpyld $9, %1, %1 \n\t" 00058 "pcpyh $9, $9 \n\t" //r9 = qadd 00059 ".p2align 2 \n\t" 00060 "1: \n\t" 00061 "lq $10, 0($14) \n\t" //r10 = level 00062 "addi $14, $14, 16 \n\t" //block+=8 00063 "addi %2, %2, -8 \n\t" 00064 "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0 00065 "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0 00066 "por $12, $11, $12 \n\t" 00067 "pmulth $10, $10, $8 \n\t" 00068 "paddh $13, $9, $11 \n\t" 00069 "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd 00070 "pmfhl.uw $11 \n\t" 00071 "pinteh $10, $11, $10 \n\t" //r10 = level * qmul 00072 "paddh $10, $10, $13 \n\t" 00073 "pand $10, $10, $12 \n\t" 00074 "sq $10, -16($14) \n\t" 00075 "bgez %2, 1b \n\t" 00076 :: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" ); 00077 00078 if(s->mb_intra) 00079 block[0]= level; 00080 } 00081 00082 00083 void MPV_common_init_mmi(MpegEncContext *s) 00084 { 00085 s->dct_unquantize_h263_intra = 00086 s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi; 00087 } 00088 00089