void performdct() { float fourier1[N*N],fourier2[N*N],inverse[N*N]; //init_dct(); fdct(fourier1,mat1); fdct(fourier2,mat2); int i=0; for(i=0;i<64;i++) { fourier1[i]=(fourier1[i]+fourier2[i])/2.0; } idct(inverse,fourier1); printf("\n<"); for(i=0;i<64;i++) { if((i%8==0)) printf("\n"); printf("%d ",(int)inverse[i]); } printf(">\n"); }
dct_io_buffer_t* dct_result( void ) { uint32_t i; dct_io_buffer_t* io_buffer; io_buffer = NULL; if( current_io_buffer != NULL) { if( current_io_buffer->dct_mode == DCT_MODE_FDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { fdct(current_io_buffer->input[i], current_io_buffer->output[i]); } } else if( current_io_buffer->dct_mode == DCT_MODE_IDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { idct(current_io_buffer->input[i], current_io_buffer->output[i]); } } io_buffer = current_io_buffer; current_io_buffer = NULL; } return io_buffer; }
main() { int i; fdct(block/* , 8 */); return block[0]; }
int main(void) { /* int i; */ fdct (block, 8); /* 8x8 Blocks, DC precision value = 0, Quantization coefficient (mquant) = 64 */ #ifdef IO for(i=0;i<64;i+=2) printf("block[%2d] -> %8d . block[%2d] -> %8d\n",i,block[i],i+1,block[i+1]); #endif return block[0]; }
/* Performs Forward DCT on all blocks */ static __inline void MBfDCT(const MBParam * const pParam, const FRAMEINFO * const frame, MACROBLOCK * const pMB, uint32_t x_pos, uint32_t y_pos, int16_t data[6 * 64]) { /* Handles interlacing */ start_timer(); pMB->field_dct = 0; if ((frame->vol_flags & XVID_VOL_INTERLACING) && (x_pos>0) && (x_pos<pParam->mb_width-1) && (y_pos>0) && (y_pos<pParam->mb_height-1)) { pMB->field_dct = MBDecideFieldDCT(data); } stop_interlacing_timer(); /* Perform DCT */ start_timer(); fdct((short * const)&data[0 * 64]); fdct((short * const)&data[1 * 64]); fdct((short * const)&data[2 * 64]); fdct((short * const)&data[3 * 64]); fdct((short * const)&data[4 * 64]); fdct((short * const)&data[5 * 64]); stop_dct_timer(); }
int main() { int i; long int n; /* We can only do a check with 1 or 4096 transformations. */ short int check_block_1 [64] = { 699, 164, -51,- 16, 31, -15, -19, 8, 71, 14, -61, -2, 11, -12, 7, 12, -58, -55, 13, 28, -20, -7, 14, -18, 29, 22, 3, 3, -11, 7, 11, -22, -1, -28, -27, 10, 0, -7, 11, 6, 7, 6, 21, 21, -10, -8, 2, -14, 1, -7, -15, -15, -10, 15, 16, -10, 0, -1, 0, 15, 4, -13, -5, 4 }; short int check_block_4096 [64] = { -2480, -665, -689, 44, -350, 26, -272, -535, -628, -2044, -544, 141, 300, -147, -1, 89, -676, -551, -1820, 224, 267, -154, -281, -290, 52, 149, 262, -1508, -228, -102, 58, 100, -425, 342, 148, -185, -2485, 802, 227, -750, 34, -62, -225, -84, 829, -1495, -172, 319, -171, -14, -367, 67, 323, -127, -1400, 28, -546, 38, -355, 159, -750, 316, -4, -1849 }; short int *check_block; int to_return; initialise_board (); start_trigger(); for(n = 0; n < SCALE_FACTOR; ++n) fdct (block, 8); /* 8x8 Blocks, DC precision value = 0, Quantization coefficient (mquant) = 64 */ stop_trigger(); /* Verify if we can */ to_return = 0; check_block = (1 == SCALE_FACTOR) ? check_block_1 : (4096 == SCALE_FACTOR) ? check_block_4096 : NULL; if (NULL != check_block) for (i = 0; i < 64; i++) if (block[i] != check_block[i]) { to_return = -1; break; } return to_return; }
int main() { #ifdef PRINT_RESULTS int i; #endif fdct(block, 8); /* 8x8 Blocks, DC precision value = 0, * Quantization coefficient (mquant) = 64 */ #ifdef PRINT_RESULTS for (i = 0; i < 64; i += 2) printf("fdct: block[%2d] -> %8d . block[%2d] -> %8d\n", i, block[i], i + 1, block[i + 1]); #endif if(block[0] + block[63] != 703) return (1); return (0); }
PROTO_THREAD_ROUTINE(dct, params) { uint32_t i; PRINT("DCT thread start\n"); while(1) { if( current_io_buffer == NULL ) { vp_os_mutex_lock(&dct_start_mutex); vp_os_cond_wait(&dct_start_cond); vp_os_mutex_unlock(&dct_start_mutex); } if( current_io_buffer->dct_mode == DCT_MODE_FDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { fdct(current_io_buffer->input[i], current_io_buffer->output[i]); } } else if( current_io_buffer->dct_mode == DCT_MODE_IDCT ) { for( i = 0; i < current_io_buffer->num_total_blocks; i++ ) { idct(current_io_buffer->input[i], current_io_buffer->output[i]); } } vp_os_mutex_lock(&critical_section); result_io_buffer = current_io_buffer; current_io_buffer = NULL; vp_os_mutex_unlock(&critical_section); } return 0; }
int main() { int i; float src[N*N]; float ref_fdct[N*N], ref_idct[N*N]; float out_fdct[N*N], out_idct[N*N]; for (i = 0; i < N*N; i++) src[i] = random() % 256; init_dct(); fdct_ref(ref_fdct, src); fdct(out_fdct, src); if (check_output("FDCT", ref_fdct, out_fdct) < 0) return 1; idct_ref(ref_idct, ref_fdct); idct(out_idct, out_fdct); if (check_output("IDCT", ref_idct, out_idct) < 0) return 1; return 0; }
void flot2(float *x, float *y, int logm) { static int n, m, m2, m4; static float tmp, fac, *xp1, *xp2, *yp1, *yp2; /* Check range of logm */ if ((logm < 2) || (logm >MAXLOGM)) { printf("Error : FLOT : logm = %d is out of bounds [%d, %d]\n", logm, 2, MAXLOGM); error_exit(); } /* Define m */ m = 1 << logm; m2 = m / 2; m4 = m2 / 2; /* Compute DCT */ fdct(x, logm); /* Copy even-indexed x's on y[0] and odd-indexed x's on y[m/2] */ xp1 = x; yp1 = y; yp2 = y + m2; for (n = 0; n < m2; n++) { *(yp1++) = *(xp1++); *(yp2++) = *(xp1++); } /* First butterflies with +1/-1 factors, with 1/2 factor, output in x */ xp1 = x; xp2 = x + m2; yp1 = y; yp2 = y + m2; for (n = 0; n < m2; n++ ) { *(xp1++) = 0.5 * ( *yp1 + *yp2 ); *(xp2++) = 0.5 * ( *(yp1++) - *(yp2++) ); } /* This piece of code correspond to the z^-1 delays in Section 4.4. The stored values are in the last m/2 samples of y */ memcpy(y, y + m, m2 * sizeof(float)); memcpy(y + m, x + m2, m2 * sizeof(float)); /* Copy first m/2 coefficients of y in x[m/2] */ memcpy(x + m2, y, m2 * sizeof(float)); /* Second stage of +1/-1 butterflies, output in y */ xp1 = x; xp2 = x + m2; yp1 = y; yp2 = y + m2; for (n = 0; n < m2; n++) { *(yp1++) = *xp1 + *xp2; *(yp2++) = *xp1 - *xp2; xp1++; xp2++; } /* Length-(n/2) IDCT */ fidct(y + m2, logm-1); /* Length-(n/2) DST-IV via DCT-IV */ yp1 = y + m2 + 1; for (n = 0; n < m4; n++) { *yp1 = - *yp1; yp1++; yp1++; } fdctiv(y + m2, logm-1); yp1 = y + m2; yp2 = y + m - 1; fac = sqrt(m2); for (n = 0; n < m4; n++) { tmp = *yp2; *yp2 = fac * *yp1; *yp1 = fac * tmp; yp1++; yp2--; } /* Even/odd re-indexing, output in x */ xp1 = x; yp1 = y; yp2 = y + m2; for (n = 0; n < m2; n++) { *(xp1++) = *(yp1++); *(xp1++) = *(yp2++); } }
int benchmark() { fdct(block, 8); return 0; }