void decode_and_reconstruct_block_inter (uint8_t *rec, int stride, int size, int qp, uint8_t *pblock, int16_t *coeffq,int tb_split){ int16_t *rcoeff = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock2 = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); if (tb_split){ int size2 = size/2; int i,j,k,index; for (i=0;i<size;i+=size2){ for (j=0;j<size;j+=size2){ index = 2*(i/size2) + (j/size2); dequantize (coeffq+index*size2*size2,rcoeff,qp,size2); inverse_transform (rcoeff, rblock2, size2); /* Copy from compact block of quarter size to full size */ for (k=0;k<size2;k++){ memcpy(rblock+(i+k)*size+j,rblock2+k*size2,size2*sizeof(int16_t)); } } } } else{ dequantize (coeffq,rcoeff,qp,size); inverse_transform (rcoeff, rblock, size); } reconstruct_block(rblock,pblock,rec,size,stride); thor_free(rcoeff); thor_free(rblock); thor_free(rblock2); }
test_loop_speed_inversetransform(void) { struct weston_matrix m; struct inverse_matrix inv; struct weston_vector v = { { 0.5, 0.5, 0.5, 1.0 } }; unsigned long count = 0; double t; printf("\nRunning 3 s test on inverse_transform()...\n"); weston_matrix_init(&m); matrix_invert(inv.LU, inv.perm, &m); running = 1; alarm(3); reset_timer(); while (running) { inverse_transform(inv.LU, inv.perm, v.f); count++; } t = read_timer(); printf("%lu iterations in %f seconds, avg. %.1f ns/iter.\n", count, t, 1e9 * t / count); }
/* Take a matrix, compute inverse, multiply together * and subtract the identity matrix to get the error matrix. * Return the largest absolute value from the error matrix. */ static double test_inverse(struct weston_matrix *m) { unsigned i; struct inverse_matrix q; double errsup = 0.0; if (matrix_invert(q.LU, q.perm, m) != 0) return INFINITY; for (i = 0; i < 4; ++i) inverse_transform(q.LU, q.perm, &m->d[i * 4]); m->d[0] -= 1.0f; m->d[5] -= 1.0f; m->d[10] -= 1.0f; m->d[15] -= 1.0f; for (i = 0; i < 16; ++i) { double err = fabs(m->d[i]); if (err > errsup) errsup = err; } return errsup; }
/* this is the "main" of colorspace.c for the decompress. it takes the a, b, c, d, pr, pb and outputs a UArray of the RGB */ UArray_T get_pix_block(CVC_trans abcd) { CVC *YPbPr = inverse_transform(abcd); UArray_T return_block = CVC_to_rgb_pixels(YPbPr); free(YPbPr->Y); free(YPbPr); return return_block; }
void decode_and_reconstruct_block_intra (uint8_t *rec, int stride, int size, int qp, uint8_t *pblock, int16_t *coeffq, int tb_split, int upright_available,int downleft_available, intra_mode_t intra_mode,int ypos,int xpos,int width,int comp, qmtx_t ** iwmatrix){ int16_t *rcoeff = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); int16_t *rblock2 = thor_alloc(2*MAX_TR_SIZE*MAX_TR_SIZE, 16); uint8_t* left_data = (uint8_t*)thor_alloc(2*MAX_TR_SIZE+2,16)+1; uint8_t* top_data = (uint8_t*)thor_alloc(2*MAX_TR_SIZE+2,16)+1; uint8_t top_left; if (tb_split){ int size2 = size/2; int i,j,index; for (i=0;i<size;i+=size2){ for (j=0;j<size;j+=size2){ make_top_and_left(left_data,top_data,&top_left,rec,stride,&rec[i*stride+j],stride,i,j,ypos,xpos,size2,upright_available,downleft_available,1); get_intra_prediction(left_data,top_data,top_left,ypos+i,xpos+j,size2,pblock,intra_mode); index = 2*(i/size2) + (j/size2); dequantize (coeffq+index*size2*size2, rcoeff, qp, size2, iwmatrix ? iwmatrix[log2i(size2/4)] : NULL, MAX_QUANT_SIZE); inverse_transform (rcoeff, rblock2, size2); reconstruct_block(rblock2,pblock,&rec[i*stride+j],size2,stride); } } } else{ make_top_and_left(left_data,top_data,&top_left,rec,stride,NULL,0,0,0,ypos,xpos,size,upright_available,downleft_available,0); get_intra_prediction(left_data,top_data,top_left,ypos,xpos,size,pblock,intra_mode); dequantize (coeffq, rcoeff, qp, size, iwmatrix ? iwmatrix[log2i(size/4)] : NULL, MAX_QUANT_SIZE); inverse_transform (rcoeff, rblock, size); reconstruct_block(rblock,pblock,rec,size,stride); } thor_free(top_data - 1); thor_free(left_data - 1); thor_free(rcoeff); thor_free(rblock); thor_free(rblock2); }
/* take right edge, ceil (round up) */ static int dx_right(struct screenparam sp, int xmax, int dy, gboolean left_side) { if (left_side) { if (!dy) return xmax>sp.pos.x+sp.screendist.x /* ?1:0 */ ; if (xmax<(sp.pos.x+sp.screendist.x*eye_pos_x)) return dx_right(sp,xmax,dy-1,FALSE); else return dx_right(sp,xmax,dy,FALSE); } return (int)(ceilf(inverse_transform(sp.pos.x, sp.screendist.x, xmax, dy, eye_pos_x, eye_pos_z))) - 1; }
/* take left edge, floor (round down) */ static int dx_left(struct screenparam sp, int xmin, int dy, gboolean left_side) { if (left_side) { if (!dy) return xmin>sp.pos.x-sp.screendist.x /* ?1:0 */ ; if (xmin<(sp.pos.x+sp.screendist.x*eye_pos_x)) return dx_left(sp,xmin,dy,FALSE)+1; else return dx_left(sp,xmin,dy-1,FALSE)+1; } return (int)(floorf(inverse_transform(sp.pos.x, sp.screendist.x, xmin, dy, eye_pos_x, eye_pos_z))); }
int convolve_complex(const float xreal[], const float ximag[], const float yreal[], const float yimag[], float outreal[], float outimag[], size_t n, int procNumber) { int status = 0; size_t size; size_t i; float *xr, *xi, *yr, *yi; if (SIZE_MAX / sizeof(float) < n) return 0; size = n * sizeof(float); xr = memdup(xreal, size); xi = memdup(ximag, size); yr = memdup(yreal, size); yi = memdup(yimag, size); if (xr == NULL || xi == NULL || yr == NULL || yi == NULL) goto cleanup; if (!transform(xr, xi, n, procNumber)) goto cleanup; if (!transform(yr, yi, n, procNumber)) goto cleanup; int start, end; getVectorParcel(&start,&end, n, procNumber); for (i = start; i < end; i++) { float temp = xr[i] * yr[i] - xi[i] * yi[i]; xi[i] = xi[i] * yr[i] + xr[i] * yi[i]; xr[i] = temp; } incrementSemaphore(&secondSemaphore); acquireSemaphore(&secondSemaphore); if (!inverse_transform(xr, xi, n, procNumber)); goto cleanup; getVectorParcel(&start,&end, n, procNumber); for (i = start; i < end; i++) { // Scaling (because this FFT implementation omits it) outreal[i] = xr[i] / n; outimag[i] = xi[i] / n; } incrementSemaphore(&fourthSemaphore); acquireSemaphore(&fourthSemaphore); status = 1; cleanup: free(yi); free(yr); free(xi); free(xr); return status; }
int convolve_complex(double xreal[], double ximag[], double yreal[], double yimag[], double outreal[], double outimag[], size_t n) { int status = 0; size_t size; size_t i; if (SIZE_MAX / sizeof(double) < n) return 0; size = n * sizeof(double); xreal = memdup(xreal, size); if (xreal == NULL) goto cleanup0; ximag = memdup(ximag, size); if (ximag == NULL) goto cleanup1; yreal = memdup(yreal, size); if (yreal == NULL) goto cleanup2; yimag = memdup(yimag, size); if (yimag == NULL) goto cleanup3; if (!transform(xreal, ximag, n)) goto cleanup4; if (!transform(yreal, yimag, n)) goto cleanup4; for (i = 0; i < n; i++) { double temp = xreal[i] * yreal[i] - ximag[i] * yimag[i]; ximag[i] = ximag[i] * yreal[i] + xreal[i] * yimag[i]; xreal[i] = temp; } if (!inverse_transform(xreal, ximag, n)) goto cleanup4; for (i = 0; i < n; i++) { // Scaling (because this FFT implementation omits it) outreal[i] = xreal[i] / n; outimag[i] = ximag[i] / n; } status = 1; cleanup4: free(yimag); cleanup3: free(yreal); cleanup2: free(ximag); cleanup1: free(xreal); cleanup0: return status; }
int convolve_complex(const float xreal[], const float ximag[], const float yreal[], const float yimag[], float outreal[], float outimag[], size_t n) { int status = 0; size_t size; size_t i; float *xr, *xi, *yr, *yi; if (N_MAX / sizeof(float) < n) return 0; size = n * sizeof(float); xr = memdup(xreal, size); xi = memdup(ximag, size); yr = memdup(yreal, size); yi = memdup(yimag, size); if (xr == NULL || xi == NULL || yr == NULL || yi == NULL) goto cleanup; if (!transform(xr, xi, n)) goto cleanup; if (!transform(yr, yi, n)) goto cleanup; for (i = 0; i < n; i++) { float temp = sub_acc(mul_acc(xr[i], yr[i]), mul_acc(xi[i], yi[i])); xi[i] = sum_acc(mul_acc(xi[i], yr[i]), mul_acc(xr[i], yi[i])); xr[i] = temp; } if (!inverse_transform(xr, xi, n)) goto cleanup; for (i = 0; i < n; i++) { // Scaling (because this FFT implementation omits it) outreal[i] = div_acc(xr[i], n); outimag[i] = div_acc(xi[i], n); } status = 1; cleanup: free(yi); free(yr); free(xi); free(xr); return status; }
int convolve_complex(const double xreal[], const double ximag[], const double yreal[], const double yimag[], double outreal[], double outimag[], size_t n) { int status = 0; size_t size; size_t i; double *xr, *xi, *yr, *yi; if (SIZE_MAX / sizeof(double) < n) return 0; size = n * sizeof(double); xr = memdup(xreal, size); xi = memdup(ximag, size); yr = memdup(yreal, size); yi = memdup(yimag, size); if (xr == NULL || xi == NULL || yr == NULL || yi == NULL) goto cleanup; if (!transform(xr, xi, n)) goto cleanup; if (!transform(yr, yi, n)) goto cleanup; for (i = 0; i < n; i++) { double temp = xr[i] * yr[i] - xi[i] * yi[i]; xi[i] = xi[i] * yr[i] + xr[i] * yi[i]; xr[i] = temp; } if (!inverse_transform(xr, xi, n)) goto cleanup; for (i = 0; i < n; i++) { // Scaling (because this FFT implementation omits it) outreal[i] = xr[i] / n; outimag[i] = xi[i] / n; } status = 1; cleanup: free(yi); free(yr); free(xi); free(xr); return status; }
/*--------------------------------------------------------------------------*/ void decode_frame(short bitstream[], short bfi, short out16[], DecoderState *d) { short is_transient; float t_audio_q[FRAME_LENGTH]; float wtda_audio[2*FRAME_LENGTH]; short bitalloc[NB_SFM]; short ynrm[NB_SFM]; short i; float audio_q_norm[FREQ_LENGTH]; short nf_idx; short **pbitstream; short *tbitstream; if (bfi) { for (i=0; i < FRAME_LENGTH; i++) { t_audio_q[i] = d->old_coeffs[i]; d->old_coeffs[i] = d->old_coeffs[i]/2; } is_transient = d->old_is_transient; } else { if (*bitstream == G192_BIT1) { is_transient = 1; } else { is_transient = 0; } bitstream++; tbitstream = bitstream; pbitstream = &bitstream; if (is_transient) { flvqdec(pbitstream, t_audio_q, audio_q_norm, bitalloc, (short)d->num_bits_spectrum_transient, ynrm, is_transient); nf_idx = 0; } else { flvqdec(pbitstream, t_audio_q, audio_q_norm, bitalloc, (short)d->num_bits_spectrum_stationary, ynrm, is_transient); bits2idxn(bitstream, 2, &nf_idx); bitstream += 2; } for (i = FREQ_LENGTH; i < FRAME_LENGTH; i++) { t_audio_q[i] = 0.0f; } fill_spectrum(audio_q_norm, t_audio_q, bitalloc, is_transient, ynrm, nf_idx); if (is_transient) { de_interleave_spectrum(t_audio_q); } for (i=0; i < FRAME_LENGTH; i++) { d->old_coeffs[i] = t_audio_q[i]; } d->old_is_transient = is_transient; } inverse_transform(t_audio_q, wtda_audio, is_transient); window_ola(wtda_audio, out16, d->old_out); }
ray ray::inverse_transform(const surface *surface_ptr) const { return inverse_transform(surface_ptr->tranmatrix, surface_ptr->trancenter); }