00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "asm.h"
00021 #include "../dsputil.h"
00022 #include "../mpegvideo.h"
00023
00024 static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
00025 int n, int qscale)
00026 {
00027 int i, n_coeffs;
00028 uint64_t qmul, qadd;
00029 uint64_t correction;
00030 DCTELEM *orig_block = block;
00031 DCTELEM block0;
00032
00033 qadd = WORD_VEC((qscale - 1) | 1);
00034 qmul = qscale << 1;
00035
00036 correction = WORD_VEC((qmul - 1) + 1);
00037
00038 if (!s->h263_aic) {
00039 if (n < 4)
00040 block0 = block[0] * s->y_dc_scale;
00041 else
00042 block0 = block[0] * s->c_dc_scale;
00043 } else {
00044 qadd = 0;
00045 }
00046 n_coeffs = 63;
00047
00048 for(i = 0; i <= n_coeffs; block += 4, i += 4) {
00049 uint64_t levels, negmask, zeros, add;
00050
00051 levels = ldq(block);
00052 if (levels == 0)
00053 continue;
00054
00055 #ifdef __alpha_max__
00056
00057
00058 negmask = maxsw4(levels, -1);
00059 negmask = minsw4(negmask, 0);
00060 #else
00061 negmask = cmpbge(WORD_VEC(0x7fff), levels);
00062 negmask &= (negmask >> 1) | (1 << 7);
00063 negmask = zap(-1, negmask);
00064 #endif
00065
00066 zeros = cmpbge(0, levels);
00067 zeros &= zeros >> 1;
00068
00069
00070
00071 levels *= qmul;
00072 levels -= correction & (negmask << 16);
00073
00074
00075 add = qadd ^ negmask;
00076 add += WORD_VEC(0x0001) & negmask;
00077
00078 add = zap(add, zeros);
00079
00080 levels += add;
00081
00082 stq(levels, block);
00083 }
00084
00085 if (s->mb_intra && !s->h263_aic)
00086 orig_block[0] = block0;
00087 }
00088
00089 static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
00090 int n, int qscale)
00091 {
00092 int i, n_coeffs;
00093 uint64_t qmul, qadd;
00094 uint64_t correction;
00095 DCTELEM *orig_block = block;
00096 DCTELEM block0;
00097
00098 qadd = WORD_VEC((qscale - 1) | 1);
00099 qmul = qscale << 1;
00100
00101 correction = WORD_VEC((qmul - 1) + 1);
00102
00103 n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
00104
00105 for(i = 0; i <= n_coeffs; block += 4, i += 4) {
00106 uint64_t levels, negmask, zeros, add;
00107
00108 levels = ldq(block);
00109 if (levels == 0)
00110 continue;
00111
00112 #ifdef __alpha_max__
00113
00114
00115 negmask = maxsw4(levels, -1);
00116 negmask = minsw4(negmask, 0);
00117 #else
00118 negmask = cmpbge(WORD_VEC(0x7fff), levels);
00119 negmask &= (negmask >> 1) | (1 << 7);
00120 negmask = zap(-1, negmask);
00121 #endif
00122
00123 zeros = cmpbge(0, levels);
00124 zeros &= zeros >> 1;
00125
00126
00127
00128 levels *= qmul;
00129 levels -= correction & (negmask << 16);
00130
00131
00132 add = qadd ^ negmask;
00133 add += WORD_VEC(0x0001) & negmask;
00134
00135 add = zap(add, zeros);
00136
00137 levels += add;
00138
00139 stq(levels, block);
00140 }
00141 }
00142
00143 void MPV_common_init_axp(MpegEncContext *s)
00144 {
00145 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp;
00146 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp;
00147 }