00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include "libavutil/cpu.h"
00027 #include "libavcodec/dsputil.h"
00028 #include "libavcodec/mpegvideo.h"
00029
00030 #include "util_altivec.h"
00031 #include "types_altivec.h"
00032 #include "dsputil_altivec.h"
00033
00034
00035
00036 static void dct_unquantize_h263_altivec(MpegEncContext *s,
00037 DCTELEM *block, int n, int qscale)
00038 {
00039 int i, level, qmul, qadd;
00040 int nCoeffs;
00041
00042 assert(s->block_last_index[n]>=0);
00043
00044 qadd = (qscale - 1) | 1;
00045 qmul = qscale << 1;
00046
00047 if (s->mb_intra) {
00048 if (!s->h263_aic) {
00049 if (n < 4)
00050 block[0] = block[0] * s->y_dc_scale;
00051 else
00052 block[0] = block[0] * s->c_dc_scale;
00053 }else
00054 qadd = 0;
00055 i = 1;
00056 nCoeffs= 63;
00057 } else {
00058 i = 0;
00059 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
00060 }
00061
00062 {
00063 register const vector signed short vczero = (const vector signed short)vec_splat_s16(0);
00064 DECLARE_ALIGNED(16, short, qmul8) = qmul;
00065 DECLARE_ALIGNED(16, short, qadd8) = qadd;
00066 register vector signed short blockv, qmulv, qaddv, nqaddv, temp1;
00067 register vector bool short blockv_null, blockv_neg;
00068 register short backup_0 = block[0];
00069 register int j = 0;
00070
00071 qmulv = vec_splat((vec_s16)vec_lde(0, &qmul8), 0);
00072 qaddv = vec_splat((vec_s16)vec_lde(0, &qadd8), 0);
00073 nqaddv = vec_sub(vczero, qaddv);
00074
00075
00076
00077 for(; (j + 7) <= nCoeffs ; j+=8) {
00078 blockv = vec_ld(j << 1, block);
00079 blockv_neg = vec_cmplt(blockv, vczero);
00080 blockv_null = vec_cmpeq(blockv, vczero);
00081
00082 temp1 = vec_sel(qaddv, nqaddv, blockv_neg);
00083
00084 temp1 = vec_mladd(blockv, qmulv, temp1);
00085
00086 blockv = vec_sel(temp1, blockv, blockv_null);
00087 vec_st(blockv, j << 1, block);
00088 }
00089
00090
00091
00092
00093
00094 for(; j <= nCoeffs ; j++) {
00095 level = block[j];
00096 if (level) {
00097 if (level < 0) {
00098 level = level * qmul - qadd;
00099 } else {
00100 level = level * qmul + qadd;
00101 }
00102 block[j] = level;
00103 }
00104 }
00105
00106 if (i == 1) {
00107
00108 block[0] = backup_0;
00109 }
00110 }
00111 }
00112
00113
00114 void ff_MPV_common_init_altivec(MpegEncContext *s)
00115 {
00116 if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return;
00117
00118 if ((s->avctx->dct_algo == FF_DCT_AUTO) ||
00119 (s->avctx->dct_algo == FF_DCT_ALTIVEC)) {
00120 s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec;
00121 s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec;
00122 }
00123 }