00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "libavcodec/avcodec.h"
00024 #include "libavcodec/dsputil.h"
00025 #include "libavcodec/mpegvideo.h"
00026 #include "dsputil_bfin.h"
00027
00028 static int dct_quantize_bfin (MpegEncContext *s,
00029 DCTELEM *block, int n,
00030 int qscale, int *overflow)
00031 {
00032 int last_non_zero, q, start_i;
00033 const short *qmat;
00034 short *bias;
00035 const uint8_t *scantable= s->intra_scantable.scantable;
00036 short dc;
00037 int max=0;
00038
00039 PROF("fdct",0);
00040 s->dsp.fdct(block);
00041 EPROF();
00042
00043 PROF("denoise",1);
00044 if(s->dct_error_sum)
00045 s->denoise_dct(s, block);
00046 EPROF();
00047
00048 PROF("quant-init",2);
00049 if (s->mb_intra) {
00050 if (!s->h263_aic) {
00051 if (n < 4)
00052 q = s->y_dc_scale;
00053 else
00054 q = s->c_dc_scale;
00055 q = q << 3;
00056 } else
00057
00058 q = 1 << 3;
00059
00060
00061 dc = block[0] = (block[0] + (q >> 1)) / q;
00062 start_i = 1;
00063 last_non_zero = 0;
00064 bias = s->q_intra_matrix16[qscale][1];
00065 qmat = s->q_intra_matrix16[qscale][0];
00066
00067 } else {
00068 start_i = 0;
00069 last_non_zero = -1;
00070 bias = s->q_inter_matrix16[qscale][1];
00071 qmat = s->q_inter_matrix16[qscale][0];
00072
00073 }
00074 EPROF();
00075
00076 PROF("quantize",4);
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 __asm__ volatile
00088 ("i2=%1;\n\t"
00089 "r1=[%1++]; \n\t"
00090 "r0=r1>>>15 (v); \n\t"
00091 "lsetup (0f,1f) lc0=%3; \n\t"
00092 "0: r0=r0|%4; \n\t"
00093 " r1=abs r1 (v) || r2=[%2++];\n\t"
00094 " r1=r1+|+%5; \n\t"
00095 " r1=max(r1,%6) (v); \n\t"
00096 " r1.h=(a1 =r1.h*r2.h), r1.l=(a0 =r1.l*r2.l) (tfu); \n\t"
00097 " %0=%0|r1; \n\t"
00098 " r0.h=(a1 =r1.h*r0.h), r0.l=(a0 =r1.l*r0.l) (is) || r1=[%1++];\n\t"
00099 "1: r0=r1>>>15 (v) || [i2++]=r0;\n\t"
00100 "r1=%0>>16; \n\t"
00101 "%0=%0|r1; \n\t"
00102 "%0.h=0; \n\t"
00103 : "=&d" (max)
00104 : "b" (block), "b" (qmat), "a" (32), "d" (0x00010001), "d" (bias[0]*0x10001), "d" (0)
00105 : "R0","R1","R2", "I2");
00106 if (start_i == 1) block[0] = dc;
00107
00108 EPROF();
00109
00110
00111 PROF("zzscan",5);
00112
00113 __asm__ volatile
00114 ("r0=b[%1--] (x); \n\t"
00115 "lsetup (0f,1f) lc0=%3; \n\t"
00116 "0: p0=r0; \n\t"
00117 " p0=%2+(p0<<1); \n\t"
00118 " r0=w[p0]; \n\t"
00119 " cc=r0==0; \n\t"
00120 " if !cc jump 2f; \n\t"
00121 "1: r0=b[%1--] (x); \n\t"
00122 " %0=%4; \n\t"
00123 " jump 3f; \n\t"
00124 "2: %0=lc0; \n\t"
00125 "3:\n\t"
00126
00127 : "=d" (last_non_zero)
00128 : "a" (scantable+63), "a" (block), "a" (63), "d" (last_non_zero)
00129 : "P0","R0");
00130
00131 EPROF();
00132
00133 *overflow= s->max_qcoeff < max;
00134
00135 bfprof();
00136
00137
00138 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
00139 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
00140
00141 return last_non_zero;
00142 }
00143
00144 void MPV_common_init_bfin (MpegEncContext *s)
00145 {
00146
00147 }
00148