dct.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:2k
- #include "Includesysdefs.h"
- #include "PlaycoreCaptureLogompeg_encdct.h"
- #ifdef SUPPORT_CAPTURE_LOGO
- void dct(short block[8][8])
- {
- long tmp_blk[8][8];
- int i, j, k;
- #if 0
- long s;
- for (i=0; i<8; i++)
- {
- for (j=0; j<8; j++)
- {
- s = 0;
- for (k=0; k<8; k++)
- {
- s += (long)(DCT_arr[j][k]) * (long)(block[i][k]);
- }
- tmp_blk[i][j] = s;
- }
- }
- #endif
- long s;
- asm{
- /*
- first loop:
- bx = j*8+k (DCT_arr index)
- si = block+i*8+k (block index)
- di = i*8+j (tmp_blk index)
- */
- push ds
- lds si,[block]
- xor di,di
- loop_i1:
- xor bx,bx
- add si,16
- loop_j1:
- sub si,16
- mov ax,seg DCT_arr
- mov es,ax
- xor ax,ax
- mov word ptr [s],ax
- mov word ptr [s+2],ax
- loop_k1:
- mov ax,word ptr es:DCT_arr[bx]
- mov dx,[si]
- imul dx
- add word ptr [s],ax
- adc word ptr [s+2],dx
- add bx,2
- add si,2
- test bx,15
- jne loop_k1
- /*
- mov ax,seg tmp_blk
- mov es,ax
- */
- mov ax,word ptr [s]
- mov word ptr tmp_blk[di],ax
- mov ax,word ptr [s+2]
- mov word ptr tmp_blk[di+2],ax
- add di,4
- test di,31
- jne loop_j1
- cmp di,256
- jne loop_i1
- }
- #if 1
- asm{ pop ds }
- for (j=0; j<8; j++)
- {
- for (i=0; i<8; i++)
- {
- s = 0;
- for (k=0; k<8; k++)
- {
- s += DCT_arr[i][k] * tmp_blk[k][j];
- }
- block[i][j] = (short)((s+32768)>>16); /* round to nearest short */
- }
- }
- #else
- asm{
- /*
- first loop:
- bx = i*8+k (DCT_arr index)
- si = block+i*8+j (block index)
- di = k*8+j (tmp_blk index)
- */
- mov si,word ptr [block]
- xor di,di
- loop_j2:
- xor bx,bx
- mov ax,seg DCT_arr
- mov ds,ax
- loop_i2:
- xor ax,ax
- mov word ptr [s],ax
- mov word ptr [s+2],ax
- mov ax,seg tmp_blk
- mov es,ax
- loop_k2:
- mov ax,word ptr es:tmp_blk[di]
- mov cx,DCT_arr[bx]
- mul cx
- add word ptr [s],ax
- adc word ptr [s+2],dx
- mov ax,word ptr es:tmp_blk[di+2]
- mul cx
- add word ptr [s+2],ax
- add di,32
- add bx,2
- test bx,15
- jne loop_k2
- add word ptr [s],32768
- adc word ptr [s+2],0
- les ax,[block]
- mov ax,word ptr [s+2]
- mov es:[si],ax
- sub di,256
- add si,16
- cmp bx,128
- jne loop_i2
- sub si,126
- add di,4
- cmp di,32
- jne loop_j2
- pop ds
- }
- #endif
- }
- #endif