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 "libavcodec/avcodec.h"
00025 #include "libavcodec/dsputil.h"
00026 #include "dsputil_bfin.h"
00027
00028 int off;
00029
00030 static void bfin_idct_add (uint8_t *dest, int line_size, DCTELEM *block)
00031 {
00032 ff_bfin_idct (block);
00033 ff_bfin_add_pixels_clamped (block, dest, line_size);
00034 }
00035
00036 static void bfin_idct_put (uint8_t *dest, int line_size, DCTELEM *block)
00037 {
00038 ff_bfin_idct (block);
00039 ff_bfin_put_pixels_clamped (block, dest, line_size);
00040 }
00041
00042
00043 static void bfin_clear_blocks (DCTELEM *blocks)
00044 {
00045
00046
00047 __asm__("P0=192; "
00048 "I0=%0; "
00049 "R0=0; "
00050 "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
00051 "clear_blocks_blkfn_lab:"
00052 "[I0++]=R0;"
00053 ::"a" (blocks):"P0","I0","R0");
00054 }
00055
00056
00057
00058 static void bfin_put_pixels8 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00059 {
00060 ff_bfin_put_pixels8uc (block, pixels, pixels, line_size, line_size, h);
00061 }
00062
00063 static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, int line_size, int h)
00064 {
00065 ff_bfin_put_pixels8uc (block, pixels, pixels+1, line_size, line_size, h);
00066 }
00067
00068 static void bfin_put_pixels8_y2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00069 {
00070 ff_bfin_put_pixels8uc (block, pixels, pixels+line_size, line_size, line_size, h);
00071 }
00072
00073 static void bfin_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, int line_size, int h)
00074 {
00075 ff_bfin_z_put_pixels8_xy2 (block,s0,line_size, line_size, h);
00076 }
00077
00078 static void bfin_put_pixels16 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00079 {
00080 ff_bfin_put_pixels16uc (block, pixels, pixels, line_size, line_size, h);
00081 }
00082
00083 static void bfin_put_pixels16_x2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00084 {
00085 ff_bfin_put_pixels16uc (block, pixels, pixels+1, line_size, line_size, h);
00086 }
00087
00088 static void bfin_put_pixels16_y2 (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00089 {
00090 ff_bfin_put_pixels16uc (block, pixels, pixels+line_size, line_size, line_size, h);
00091 }
00092
00093 static void bfin_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, int line_size, int h)
00094 {
00095 ff_bfin_z_put_pixels16_xy2 (block,s0,line_size, line_size, h);
00096 }
00097
00098 static void bfin_put_pixels8_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00099 {
00100 ff_bfin_put_pixels8uc_nornd (block, pixels, pixels, line_size, h);
00101 }
00102
00103 static void bfin_put_pixels8_x2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00104 {
00105 ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+1, line_size, h);
00106 }
00107
00108 static void bfin_put_pixels8_y2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00109 {
00110 ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+line_size, line_size, h);
00111 }
00112
00113
00114 static void bfin_put_pixels16_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00115 {
00116 ff_bfin_put_pixels16uc_nornd (block, pixels, pixels, line_size, h);
00117 }
00118
00119 static void bfin_put_pixels16_x2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00120 {
00121 ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+1, line_size, h);
00122 }
00123
00124 static void bfin_put_pixels16_y2_nornd (uint8_t *block, const uint8_t *pixels, int line_size, int h)
00125 {
00126 ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+line_size, line_size, h);
00127 }
00128
00129 static int bfin_pix_abs16 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00130 {
00131 return ff_bfin_z_sad16x16 (blk1,blk2,line_size,line_size,h);
00132 }
00133
00134 static int bfin_vsad_intra16 (void *c, uint8_t *blk1, uint8_t *dummy, int stride, int h) {
00135 return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h);
00136 }
00137
00138 static int bfin_vsad (void *c, uint8_t *blk1, uint8_t *blk2, int stride, int h) {
00139 return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h)
00140 + ff_bfin_z_sad16x16 (blk2,blk2+stride,stride<<1,stride<<1,h);
00141 }
00142
00143 static uint8_t vtmp_blk[256] attribute_l1_data_b;
00144
00145 static int bfin_pix_abs16_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00146 {
00147 ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+1, 16, line_size, h);
00148 return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
00149 }
00150
00151 static int bfin_pix_abs16_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00152 {
00153 ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+line_size, 16, line_size, h);
00154 return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
00155 }
00156
00157 static int bfin_pix_abs16_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00158 {
00159 ff_bfin_z_put_pixels16_xy2 (vtmp_blk, blk2, 16, line_size, h);
00160 return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
00161 }
00162
00163 static int bfin_pix_abs8 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00164 {
00165 return ff_bfin_z_sad8x8 (blk1,blk2,line_size,line_size, h);
00166 }
00167
00168 static int bfin_pix_abs8_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00169 {
00170 ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+1, 8, line_size, h);
00171 return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
00172 }
00173
00174 static int bfin_pix_abs8_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00175 {
00176 ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+line_size, 8, line_size, h);
00177 return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
00178 }
00179
00180 static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
00181 {
00182 ff_bfin_z_put_pixels8_xy2 (vtmp_blk, blk2, 8, line_size, h);
00183 return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 void dsputil_init_bfin( DSPContext* c, AVCodecContext *avctx )
00199 {
00200 const int high_bit_depth = avctx->bits_per_raw_sample > 8;
00201
00202 c->diff_pixels = ff_bfin_diff_pixels;
00203 c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
00204 c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
00205
00206 if (!high_bit_depth)
00207 c->get_pixels = ff_bfin_get_pixels;
00208 c->clear_blocks = bfin_clear_blocks;
00209 c->pix_sum = ff_bfin_pix_sum;
00210 c->pix_norm1 = ff_bfin_pix_norm1;
00211
00212 c->sad[0] = bfin_pix_abs16;
00213 c->sad[1] = bfin_pix_abs8;
00214
00215
00216
00217
00218
00219 c->pix_abs[0][0] = bfin_pix_abs16;
00220 c->pix_abs[0][1] = bfin_pix_abs16_x2;
00221 c->pix_abs[0][2] = bfin_pix_abs16_y2;
00222 c->pix_abs[0][3] = bfin_pix_abs16_xy2;
00223
00224 c->pix_abs[1][0] = bfin_pix_abs8;
00225 c->pix_abs[1][1] = bfin_pix_abs8_x2;
00226 c->pix_abs[1][2] = bfin_pix_abs8_y2;
00227 c->pix_abs[1][3] = bfin_pix_abs8_xy2;
00228
00229
00230 c->sse[0] = ff_bfin_sse16;
00231 c->sse[1] = ff_bfin_sse8;
00232 c->sse[2] = ff_bfin_sse4;
00233
00234 if (!high_bit_depth) {
00235 c->put_pixels_tab[0][0] = bfin_put_pixels16;
00236 c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
00237 c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
00238 c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
00239
00240 c->put_pixels_tab[1][0] = bfin_put_pixels8;
00241 c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
00242 c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
00243 c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
00244
00245 c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_nornd;
00246 c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_nornd;
00247 c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_nornd;
00248
00249
00250 c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_nornd;
00251 c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_nornd;
00252 c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_nornd;
00253
00254 }
00255
00256 if (avctx->bits_per_raw_sample <= 8) {
00257 if (avctx->dct_algo == FF_DCT_AUTO)
00258 c->fdct = ff_bfin_fdct;
00259
00260 if (avctx->idct_algo == FF_IDCT_VP3) {
00261 c->idct_permutation_type = FF_NO_IDCT_PERM;
00262 c->idct = ff_bfin_vp3_idct;
00263 c->idct_add = ff_bfin_vp3_idct_add;
00264 c->idct_put = ff_bfin_vp3_idct_put;
00265 } else if (avctx->idct_algo == FF_IDCT_AUTO) {
00266 c->idct_permutation_type = FF_NO_IDCT_PERM;
00267 c->idct = ff_bfin_idct;
00268 c->idct_add = bfin_idct_add;
00269 c->idct_put = bfin_idct_put;
00270 }
00271 }
00272 }
00273
00274
00275