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