00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "asm.h"
00023 #include "dsputil.h"
00024 #include "mpegvideo.h"
00025
00026 static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
00027 int n, int qscale)
00028 {
00029 int i, n_coeffs;
00030 uint64_t qmul, qadd;
00031 uint64_t correction;
00032 DCTELEM *orig_block = block;
00033 DCTELEM block0;
00034
00035 qadd = WORD_VEC((qscale - 1) | 1);
00036 qmul = qscale << 1;
00037
00038 correction = WORD_VEC((qmul - 1) + 1);
00039
00040 if (!s->h263_aic) {
00041 if (n < 4)
00042 block0 = block[0] * s->y_dc_scale;
00043 else
00044 block0 = block[0] * s->c_dc_scale;
00045 } else {
00046 qadd = 0;
00047 }
00048 n_coeffs = 63;
00049
00050 for(i = 0; i <= n_coeffs; block += 4, i += 4) {
00051 uint64_t levels, negmask, zeros, add;
00052
00053 levels = ldq(block);
00054 if (levels == 0)
00055 continue;
00056
00057 #ifdef __alpha_max__
00058
00059
00060 negmask = maxsw4(levels, -1);
00061 negmask = minsw4(negmask, 0);
00062 #else
00063 negmask = cmpbge(WORD_VEC(0x7fff), levels);
00064 negmask &= (negmask >> 1) | (1 << 7);
00065 negmask = zap(-1, negmask);
00066 #endif
00067
00068 zeros = cmpbge(0, levels);
00069 zeros &= zeros >> 1;
00070
00071
00072
00073 levels *= qmul;
00074 levels -= correction & (negmask << 16);
00075
00076
00077 add = qadd ^ negmask;
00078 add += WORD_VEC(0x0001) & negmask;
00079
00080 add = zap(add, zeros);
00081
00082 levels += add;
00083
00084 stq(levels, block);
00085 }
00086
00087 if (s->mb_intra && !s->h263_aic)
00088 orig_block[0] = block0;
00089 }
00090
00091 static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
00092 int n, int qscale)
00093 {
00094 int i, n_coeffs;
00095 uint64_t qmul, qadd;
00096 uint64_t correction;
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 }