00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "../dsputil.h"
00021 #include "../mpegvideo.h"
00022
00023 #include <mlib_types.h>
00024 #include <mlib_status.h>
00025 #include <mlib_sys.h>
00026 #include <mlib_algebra.h>
00027 #include <mlib_video.h>
00028
00029
00030
00031 static void get_pixels_mlib(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
00032 {
00033 int i;
00034
00035 for (i=0;i<8;i++) {
00036 mlib_VectorConvert_S16_U8_Mod((mlib_s16 *)block, (mlib_u8 *)pixels, 8);
00037
00038 pixels += line_size;
00039 block += 8;
00040 }
00041 }
00042
00043 static void diff_pixels_mlib(DCTELEM *restrict block, const uint8_t *s1, const uint8_t *s2, int line_size)
00044 {
00045 int i;
00046
00047 for (i=0;i<8;i++) {
00048 mlib_VectorSub_S16_U8_Mod((mlib_s16 *)block, (mlib_u8 *)s1, (mlib_u8 *)s2, 8);
00049
00050 s1 += line_size;
00051 s2 += line_size;
00052 block += 8;
00053 }
00054 }
00055
00056 static void add_pixels_clamped_mlib(const DCTELEM *block, uint8_t *pixels, int line_size)
00057 {
00058 mlib_VideoAddBlock_U8_S16(pixels, (mlib_s16 *)block, line_size);
00059 }
00060
00061
00062
00063 static void put_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
00064 int stride, int height)
00065 {
00066 switch (height) {
00067 case 8:
00068 mlib_VideoCopyRef_U8_U8_16x8(dest, (uint8_t *)ref, stride);
00069 break;
00070
00071 case 16:
00072 mlib_VideoCopyRef_U8_U8_16x16(dest, (uint8_t *)ref, stride);
00073 break;
00074
00075 default:
00076 assert(0);
00077 }
00078 }
00079
00080 static void put_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
00081 int stride, int height)
00082 {
00083 switch (height) {
00084 case 8:
00085 mlib_VideoInterpX_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00086 break;
00087
00088 case 16:
00089 mlib_VideoInterpX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00090 break;
00091
00092 default:
00093 assert(0);
00094 }
00095 }
00096
00097 static void put_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
00098 int stride, int height)
00099 {
00100 switch (height) {
00101 case 8:
00102 mlib_VideoInterpY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00103 break;
00104
00105 case 16:
00106 mlib_VideoInterpY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00107 break;
00108
00109 default:
00110 assert(0);
00111 }
00112 }
00113
00114 static void put_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
00115 int stride, int height)
00116 {
00117 switch (height) {
00118 case 8:
00119 mlib_VideoInterpXY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00120 break;
00121
00122 case 16:
00123 mlib_VideoInterpXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00124 break;
00125
00126 default:
00127 assert(0);
00128 }
00129 }
00130
00131
00132
00133 static void put_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
00134 int stride, int height)
00135 {
00136 switch (height) {
00137 case 4:
00138 mlib_VideoCopyRef_U8_U8_8x4(dest, (uint8_t *)ref, stride);
00139 break;
00140
00141 case 8:
00142 mlib_VideoCopyRef_U8_U8_8x8(dest, (uint8_t *)ref, stride);
00143 break;
00144
00145 case 16:
00146 mlib_VideoCopyRef_U8_U8_8x16(dest, (uint8_t *)ref, stride);
00147 break;
00148
00149 default:
00150 assert(0);
00151 }
00152 }
00153
00154 static void put_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
00155 int stride, int height)
00156 {
00157 switch (height) {
00158 case 4:
00159 mlib_VideoInterpX_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00160 break;
00161
00162 case 8:
00163 mlib_VideoInterpX_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00164 break;
00165
00166 case 16:
00167 mlib_VideoInterpX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00168 break;
00169
00170 default:
00171 assert(0);
00172 }
00173 }
00174
00175 static void put_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
00176 int stride, int height)
00177 {
00178 switch (height) {
00179 case 4:
00180 mlib_VideoInterpY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00181 break;
00182
00183 case 8:
00184 mlib_VideoInterpY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00185 break;
00186
00187 case 16:
00188 mlib_VideoInterpY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00189 break;
00190
00191 default:
00192 assert(0);
00193 }
00194 }
00195
00196 static void put_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
00197 int stride, int height)
00198 {
00199 switch (height) {
00200 case 4:
00201 mlib_VideoInterpXY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00202 break;
00203
00204 case 8:
00205 mlib_VideoInterpXY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00206 break;
00207
00208 case 16:
00209 mlib_VideoInterpXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00210 break;
00211
00212 default:
00213 assert(0);
00214 }
00215 }
00216
00217
00218
00219 static void avg_pixels16_mlib (uint8_t * dest, const uint8_t * ref,
00220 int stride, int height)
00221 {
00222 switch (height) {
00223 case 8:
00224 mlib_VideoCopyRefAve_U8_U8_16x8(dest, (uint8_t *)ref, stride);
00225 break;
00226
00227 case 16:
00228 mlib_VideoCopyRefAve_U8_U8_16x16(dest, (uint8_t *)ref, stride);
00229 break;
00230
00231 default:
00232 assert(0);
00233 }
00234 }
00235
00236 static void avg_pixels16_x2_mlib (uint8_t * dest, const uint8_t * ref,
00237 int stride, int height)
00238 {
00239 switch (height) {
00240 case 8:
00241 mlib_VideoInterpAveX_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00242 break;
00243
00244 case 16:
00245 mlib_VideoInterpAveX_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00246 break;
00247
00248 default:
00249 assert(0);
00250 }
00251 }
00252
00253 static void avg_pixels16_y2_mlib (uint8_t * dest, const uint8_t * ref,
00254 int stride, int height)
00255 {
00256 switch (height) {
00257 case 8:
00258 mlib_VideoInterpAveY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00259 break;
00260
00261 case 16:
00262 mlib_VideoInterpAveY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00263 break;
00264
00265 default:
00266 assert(0);
00267 }
00268 }
00269
00270 static void avg_pixels16_xy2_mlib(uint8_t * dest, const uint8_t * ref,
00271 int stride, int height)
00272 {
00273 switch (height) {
00274 case 8:
00275 mlib_VideoInterpAveXY_U8_U8_16x8(dest, (uint8_t *)ref, stride, stride);
00276 break;
00277
00278 case 16:
00279 mlib_VideoInterpAveXY_U8_U8_16x16(dest, (uint8_t *)ref, stride, stride);
00280 break;
00281
00282 default:
00283 assert(0);
00284 }
00285 }
00286
00287
00288
00289 static void avg_pixels8_mlib (uint8_t * dest, const uint8_t * ref,
00290 int stride, int height)
00291 {
00292 switch (height) {
00293 case 4:
00294 mlib_VideoCopyRefAve_U8_U8_8x4(dest, (uint8_t *)ref, stride);
00295 break;
00296
00297 case 8:
00298 mlib_VideoCopyRefAve_U8_U8_8x8(dest, (uint8_t *)ref, stride);
00299 break;
00300
00301 case 16:
00302 mlib_VideoCopyRefAve_U8_U8_8x16(dest, (uint8_t *)ref, stride);
00303 break;
00304
00305 default:
00306 assert(0);
00307 }
00308 }
00309
00310 static void avg_pixels8_x2_mlib (uint8_t * dest, const uint8_t * ref,
00311 int stride, int height)
00312 {
00313 switch (height) {
00314 case 4:
00315 mlib_VideoInterpAveX_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00316 break;
00317
00318 case 8:
00319 mlib_VideoInterpAveX_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00320 break;
00321
00322 case 16:
00323 mlib_VideoInterpAveX_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00324 break;
00325
00326 default:
00327 assert(0);
00328 }
00329 }
00330
00331 static void avg_pixels8_y2_mlib (uint8_t * dest, const uint8_t * ref,
00332 int stride, int height)
00333 {
00334 switch (height) {
00335 case 4:
00336 mlib_VideoInterpAveY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00337 break;
00338
00339 case 8:
00340 mlib_VideoInterpAveY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00341 break;
00342
00343 case 16:
00344 mlib_VideoInterpAveY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00345 break;
00346
00347 default:
00348 assert(0);
00349 }
00350 }
00351
00352 static void avg_pixels8_xy2_mlib(uint8_t * dest, const uint8_t * ref,
00353 int stride, int height)
00354 {
00355 switch (height) {
00356 case 4:
00357 mlib_VideoInterpAveXY_U8_U8_8x4(dest, (uint8_t *)ref, stride, stride);
00358 break;
00359
00360 case 8:
00361 mlib_VideoInterpAveXY_U8_U8_8x8(dest, (uint8_t *)ref, stride, stride);
00362 break;
00363
00364 case 16:
00365 mlib_VideoInterpAveXY_U8_U8_8x16(dest, (uint8_t *)ref, stride, stride);
00366 break;
00367
00368 default:
00369 assert(0);
00370 }
00371 }
00372
00373
00374
00375 static void bswap_buf_mlib(uint32_t *dst, uint32_t *src, int w)
00376 {
00377 mlib_VectorReverseByteOrder_U32_U32(dst, src, w);
00378 }
00379
00380
00381
00382 static void ff_idct_put_mlib(uint8_t *dest, int line_size, DCTELEM *data)
00383 {
00384 int i;
00385 uint8_t *cm = cropTbl + MAX_NEG_CROP;
00386
00387 mlib_VideoIDCT8x8_S16_S16 (data, data);
00388
00389 for(i=0;i<8;i++) {
00390 dest[0] = cm[data[0]];
00391 dest[1] = cm[data[1]];
00392 dest[2] = cm[data[2]];
00393 dest[3] = cm[data[3]];
00394 dest[4] = cm[data[4]];
00395 dest[5] = cm[data[5]];
00396 dest[6] = cm[data[6]];
00397 dest[7] = cm[data[7]];
00398
00399 dest += line_size;
00400 data += 8;
00401 }
00402 }
00403
00404 static void ff_idct_add_mlib(uint8_t *dest, int line_size, DCTELEM *data)
00405 {
00406 mlib_VideoIDCT8x8_S16_S16 (data, data);
00407 mlib_VideoAddBlock_U8_S16(dest, (mlib_s16 *)data, line_size);
00408 }
00409
00410 static void ff_idct_mlib(DCTELEM *data)
00411 {
00412 mlib_VideoIDCT8x8_S16_S16 (data, data);
00413 }
00414
00415 static void ff_fdct_mlib(DCTELEM *data)
00416 {
00417 mlib_VideoDCT8x8_S16_S16 (data, data);
00418 }
00419
00420 void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx)
00421 {
00422 c->get_pixels = get_pixels_mlib;
00423 c->diff_pixels = diff_pixels_mlib;
00424 c->add_pixels_clamped = add_pixels_clamped_mlib;
00425
00426 c->put_pixels_tab[0][0] = put_pixels16_mlib;
00427 c->put_pixels_tab[0][1] = put_pixels16_x2_mlib;
00428 c->put_pixels_tab[0][2] = put_pixels16_y2_mlib;
00429 c->put_pixels_tab[0][3] = put_pixels16_xy2_mlib;
00430 c->put_pixels_tab[1][0] = put_pixels8_mlib;
00431 c->put_pixels_tab[1][1] = put_pixels8_x2_mlib;
00432 c->put_pixels_tab[1][2] = put_pixels8_y2_mlib;
00433 c->put_pixels_tab[1][3] = put_pixels8_xy2_mlib;
00434
00435 c->avg_pixels_tab[0][0] = avg_pixels16_mlib;
00436 c->avg_pixels_tab[0][1] = avg_pixels16_x2_mlib;
00437 c->avg_pixels_tab[0][2] = avg_pixels16_y2_mlib;
00438 c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mlib;
00439 c->avg_pixels_tab[1][0] = avg_pixels8_mlib;
00440 c->avg_pixels_tab[1][1] = avg_pixels8_x2_mlib;
00441 c->avg_pixels_tab[1][2] = avg_pixels8_y2_mlib;
00442 c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mlib;
00443
00444 c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mlib;
00445 c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mlib;
00446
00447 c->bswap_buf = bswap_buf_mlib;
00448 }
00449
00450 void MPV_common_init_mlib(MpegEncContext *s)
00451 {
00452 if(s->avctx->dct_algo==FF_DCT_AUTO || s->avctx->dct_algo==FF_DCT_MLIB){
00453 s->dsp.fdct = ff_fdct_mlib;
00454 }
00455
00456 if(s->avctx->idct_algo==FF_IDCT_AUTO || s->avctx->idct_algo==FF_IDCT_MLIB){
00457 s->dsp.idct_put= ff_idct_put_mlib;
00458 s->dsp.idct_add= ff_idct_add_mlib;
00459 s->dsp.idct = ff_idct_mlib;
00460 s->dsp.idct_permutation_type= FF_NO_IDCT_PERM;
00461 }
00462 }