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 if(n<4){
00065 bias = s->q_intra_matrix16[qscale][1];
00066 qmat = s->q_intra_matrix16[qscale][0];
00067 }else{
00068 bias = s->q_chroma_intra_matrix16[qscale][1];
00069 qmat = s->q_chroma_intra_matrix16[qscale][0];
00070 }
00071
00072 } else {
00073 start_i = 0;
00074 last_non_zero = -1;
00075 bias = s->q_inter_matrix16[qscale][1];
00076 qmat = s->q_inter_matrix16[qscale][0];
00077
00078 }
00079 EPROF();
00080
00081 PROF("quantize",4);
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 __asm__ volatile
00093 ("i2=%1;\n\t"
00094 "r1=[%1++]; \n\t"
00095 "r0=r1>>>15 (v); \n\t"
00096 "lsetup (0f,1f) lc0=%3; \n\t"
00097 "0: r0=r0|%4; \n\t"
00098 " r1=abs r1 (v) || r2=[%2++];\n\t"
00099 " r1=r1+|+%5; \n\t"
00100 " r1=max(r1,%6) (v); \n\t"
00101 " r1.h=(a1 =r1.h*r2.h), r1.l=(a0 =r1.l*r2.l) (tfu); \n\t"
00102 " %0=%0|r1; \n\t"
00103 " r0.h=(a1 =r1.h*r0.h), r0.l=(a0 =r1.l*r0.l) (is) || r1=[%1++];\n\t"
00104 "1: r0=r1>>>15 (v) || [i2++]=r0;\n\t"
00105 "r1=%0>>16; \n\t"
00106 "%0=%0|r1; \n\t"
00107 "%0.h=0; \n\t"
00108 : "=&d" (max)
00109 : "b" (block), "b" (qmat), "a" (32), "d" (0x00010001), "d" (bias[0]*0x10001), "d" (0)
00110 : "R0","R1","R2", "I2");
00111 if (start_i == 1) block[0] = dc;
00112
00113 EPROF();
00114
00115
00116 PROF("zzscan",5);
00117
00118 __asm__ volatile
00119 ("r0=b[%1--] (x); \n\t"
00120 "lsetup (0f,1f) lc0=%3; \n\t"
00121 "0: p0=r0; \n\t"
00122 " p0=%2+(p0<<1); \n\t"
00123 " r0=w[p0]; \n\t"
00124 " cc=r0==0; \n\t"
00125 " if !cc jump 2f; \n\t"
00126 "1: r0=b[%1--] (x); \n\t"
00127 " %0=%4; \n\t"
00128 " jump 3f; \n\t"
00129 "2: %0=lc0; \n\t"
00130 "3:\n\t"
00131
00132 : "=d" (last_non_zero)
00133 : "a" (scantable+63), "a" (block), "a" (63), "d" (last_non_zero)
00134 : "P0","R0");
00135
00136 EPROF();
00137
00138 *overflow= s->max_qcoeff < max;
00139
00140 bfprof();
00141
00142
00143 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
00144 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
00145
00146 return last_non_zero;
00147 }
00148
00149 void MPV_common_init_bfin (MpegEncContext *s)
00150 {
00151
00152 }
00153