comparison cavsdsp.c @ 3395:adccbf4a1040 libavcodec

CAVS decoder by (Stefan Gehrer stefan.gehrer gmx.de)
author michael
date Mon, 03 Jul 2006 00:16:45 +0000
parents 1f47e26323bc
children 26dc0057a8f8
comparison
equal deleted inserted replaced
3394:2b5283c15310 3395:adccbf4a1040
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */ 21 */
22 22
23 #include <stdio.h> 23 #include <stdio.h>
24 #include "dsputil.h" 24 #include "dsputil.h"
25 #include "cavsdsp.h"
26 25
27 /***************************************************************************** 26 /*****************************************************************************
28 * 27 *
29 * in-loop deblocking filter 28 * in-loop deblocking filter
30 * 29 *
108 #undef P2 107 #undef P2
109 #undef Q0 108 #undef Q0
110 #undef Q1 109 #undef Q1
111 #undef Q2 110 #undef Q2
112 111
113 void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc, 112 static void cavs_filter_lv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
114 int bs1, int bs2) { 113 int bs1, int bs2) {
115 int i; 114 int i;
116 if(bs1==2) 115 if(bs1==2)
117 for(i=0;i<16;i++) 116 for(i=0;i<16;i++)
118 loop_filter_l2(d + i*stride,1,alpha,beta); 117 loop_filter_l2(d + i*stride,1,alpha,beta);
124 for(i=8;i<16;i++) 123 for(i=8;i<16;i++)
125 loop_filter_l1(d + i*stride,1,alpha,beta,tc); 124 loop_filter_l1(d + i*stride,1,alpha,beta,tc);
126 } 125 }
127 } 126 }
128 127
129 void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc, 128 static void cavs_filter_lh_c(uint8_t *d, int stride, int alpha, int beta, int tc,
130 int bs1, int bs2) { 129 int bs1, int bs2) {
131 int i; 130 int i;
132 if(bs1==2) 131 if(bs1==2)
133 for(i=0;i<16;i++) 132 for(i=0;i<16;i++)
134 loop_filter_l2(d + i,stride,alpha,beta); 133 loop_filter_l2(d + i,stride,alpha,beta);
140 for(i=8;i<16;i++) 139 for(i=8;i<16;i++)
141 loop_filter_l1(d + i,stride,alpha,beta,tc); 140 loop_filter_l1(d + i,stride,alpha,beta,tc);
142 } 141 }
143 } 142 }
144 143
145 void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc, 144 static void cavs_filter_cv_c(uint8_t *d, int stride, int alpha, int beta, int tc,
146 int bs1, int bs2) { 145 int bs1, int bs2) {
147 int i; 146 int i;
148 if(bs1==2) 147 if(bs1==2)
149 for(i=0;i<8;i++) 148 for(i=0;i<8;i++)
150 loop_filter_c2(d + i*stride,1,alpha,beta); 149 loop_filter_c2(d + i*stride,1,alpha,beta);
156 for(i=4;i<8;i++) 155 for(i=4;i<8;i++)
157 loop_filter_c1(d + i*stride,1,alpha,beta,tc); 156 loop_filter_c1(d + i*stride,1,alpha,beta,tc);
158 } 157 }
159 } 158 }
160 159
161 void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc, 160 static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc,
162 int bs1, int bs2) { 161 int bs1, int bs2) {
163 int i; 162 int i;
164 if(bs1==2) 163 if(bs1==2)
165 for(i=0;i<8;i++) 164 for(i=0;i<8;i++)
166 loop_filter_c2(d + i,stride,alpha,beta); 165 loop_filter_c2(d + i,stride,alpha,beta);
178 * 177 *
179 * inverse transform 178 * inverse transform
180 * 179 *
181 ****************************************************************************/ 180 ****************************************************************************/
182 181
183 void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) { 182 static void cavs_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride) {
184 int i; 183 int i;
185 DCTELEM (*src)[8] = (DCTELEM(*)[8])block; 184 DCTELEM (*src)[8] = (DCTELEM(*)[8])block;
186 uint8_t *cm = cropTbl + MAX_NEG_CROP; 185 uint8_t *cm = cropTbl + MAX_NEG_CROP;
187 186
188 for( i = 0; i < 8; i++ ) { 187 for( i = 0; i < 8; i++ ) {
414 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \ 413 OPNAME ## cavs_filt8_hv_ ## NAME(dst , src1, src2 , dstStride, srcStride); \
415 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \ 414 OPNAME ## cavs_filt8_hv_ ## NAME(dst+8, src1+8, src2+8, dstStride, srcStride); \
416 }\ 415 }\
417 416
418 #define CAVS_MC(OPNAME, SIZE) \ 417 #define CAVS_MC(OPNAME, SIZE) \
419 void OPNAME ## cavs_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\ 418 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
420 OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\
421 }\
422 void OPNAME ## cavs_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\
423 OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\ 419 OPNAME ## cavs_filt ## SIZE ## _h_qpel_l(dst, src, stride, stride);\
424 }\ 420 }\
425 \ 421 \
426 void OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\ 422 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\
427 OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\ 423 OPNAME ## cavs_filt ## SIZE ## _h_hpel(dst, src, stride, stride);\
428 }\ 424 }\
429 \ 425 \
430 void OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\ 426 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\
431 OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\ 427 OPNAME ## cavs_filt ## SIZE ## _h_qpel_r(dst, src, stride, stride);\
432 }\ 428 }\
433 \ 429 \
434 void OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\ 430 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\
435 OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\ 431 OPNAME ## cavs_filt ## SIZE ## _v_qpel_l(dst, src, stride, stride);\
436 }\ 432 }\
437 \ 433 \
438 void OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\ 434 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\
439 OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\ 435 OPNAME ## cavs_filt ## SIZE ## _v_hpel(dst, src, stride, stride);\
440 }\ 436 }\
441 \ 437 \
442 void OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\ 438 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\
443 OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\ 439 OPNAME ## cavs_filt ## SIZE ## _v_qpel_r(dst, src, stride, stride);\
444 }\ 440 }\
445 \ 441 \
446 void OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\ 442 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\
447 OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \ 443 OPNAME ## cavs_filt ## SIZE ## _hv_jj(dst, src, NULL, stride, stride); \
448 }\ 444 }\
449 \ 445 \
450 void OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\ 446 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\
451 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \ 447 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src, stride, stride); \
452 }\ 448 }\
453 \ 449 \
454 void OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\ 450 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\
455 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \ 451 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride, stride, stride); \
456 }\ 452 }\
457 \ 453 \
458 void OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\ 454 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\
459 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \ 455 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+1, stride, stride); \
460 }\ 456 }\
461 \ 457 \
462 void OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\ 458 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\
463 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \ 459 OPNAME ## cavs_filt ## SIZE ## _hv_egpr(dst, src, src+stride+1,stride, stride); \
464 }\ 460 }\
465 \ 461 \
466 void OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\ 462 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\
467 OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \ 463 OPNAME ## cavs_filt ## SIZE ## _hv_ff(dst, src, src+stride+1,stride, stride); \
468 }\ 464 }\
469 \ 465 \
470 void OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\ 466 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\
471 OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \ 467 OPNAME ## cavs_filt ## SIZE ## _hv_ii(dst, src, src+stride+1,stride, stride); \
472 }\ 468 }\
473 \ 469 \
474 void OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\ 470 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\
475 OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \ 471 OPNAME ## cavs_filt ## SIZE ## _hv_kk(dst, src, src+stride+1,stride, stride); \
476 }\ 472 }\
477 \ 473 \
478 void OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\ 474 static void ff_ ## OPNAME ## cavs_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\
479 OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \ 475 OPNAME ## cavs_filt ## SIZE ## _hv_qq(dst, src, src+stride+1,stride, stride); \
480 }\ 476 }\
481 477
482 #define op_put1(a, b) a = cm[((b)+4)>>3] 478 #define op_put1(a, b) a = cm[((b)+4)>>3]
483 #define op_put2(a, b) a = cm[((b)+64)>>7] 479 #define op_put2(a, b) a = cm[((b)+64)>>7]
507 CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1) 503 CAVS_SUBPIX_HV(avg_, op_avg2, egpr, 0, -1, 5, 5, -1, 0, 0, -1, 5, 5, -1, 0, 1)
508 CAVS_MC(put_, 8) 504 CAVS_MC(put_, 8)
509 CAVS_MC(put_, 16) 505 CAVS_MC(put_, 16)
510 CAVS_MC(avg_, 8) 506 CAVS_MC(avg_, 8)
511 CAVS_MC(avg_, 16) 507 CAVS_MC(avg_, 16)
508
509 void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
510 void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride);
511 void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
512 void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride);
513
514 void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx) {
515 #define dspfunc(PFX, IDX, NUM) \
516 c->PFX ## _pixels_tab[IDX][ 0] = ff_ ## PFX ## NUM ## _mc00_c; \
517 c->PFX ## _pixels_tab[IDX][ 1] = ff_ ## PFX ## NUM ## _mc10_c; \
518 c->PFX ## _pixels_tab[IDX][ 2] = ff_ ## PFX ## NUM ## _mc20_c; \
519 c->PFX ## _pixels_tab[IDX][ 3] = ff_ ## PFX ## NUM ## _mc30_c; \
520 c->PFX ## _pixels_tab[IDX][ 4] = ff_ ## PFX ## NUM ## _mc01_c; \
521 c->PFX ## _pixels_tab[IDX][ 5] = ff_ ## PFX ## NUM ## _mc11_c; \
522 c->PFX ## _pixels_tab[IDX][ 6] = ff_ ## PFX ## NUM ## _mc21_c; \
523 c->PFX ## _pixels_tab[IDX][ 7] = ff_ ## PFX ## NUM ## _mc31_c; \
524 c->PFX ## _pixels_tab[IDX][ 8] = ff_ ## PFX ## NUM ## _mc02_c; \
525 c->PFX ## _pixels_tab[IDX][ 9] = ff_ ## PFX ## NUM ## _mc12_c; \
526 c->PFX ## _pixels_tab[IDX][10] = ff_ ## PFX ## NUM ## _mc22_c; \
527 c->PFX ## _pixels_tab[IDX][11] = ff_ ## PFX ## NUM ## _mc32_c; \
528 c->PFX ## _pixels_tab[IDX][12] = ff_ ## PFX ## NUM ## _mc03_c; \
529 c->PFX ## _pixels_tab[IDX][13] = ff_ ## PFX ## NUM ## _mc13_c; \
530 c->PFX ## _pixels_tab[IDX][14] = ff_ ## PFX ## NUM ## _mc23_c; \
531 c->PFX ## _pixels_tab[IDX][15] = ff_ ## PFX ## NUM ## _mc33_c
532 dspfunc(put_cavs_qpel, 0, 16);
533 dspfunc(put_cavs_qpel, 1, 8);
534 dspfunc(avg_cavs_qpel, 0, 16);
535 dspfunc(avg_cavs_qpel, 1, 8);
536 c->cavs_filter_lv = cavs_filter_lv_c;
537 c->cavs_filter_lh = cavs_filter_lh_c;
538 c->cavs_filter_cv = cavs_filter_cv_c;
539 c->cavs_filter_ch = cavs_filter_ch_c;
540 c->cavs_idct8_add = cavs_idct8_add_c;
541 }