本文整理汇总了C++中RIDX函数的典型用法代码示例。如果您正苦于以下问题:C++ RIDX函数的具体用法?C++ RIDX怎么用?C++ RIDX使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RIDX函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attempt_ten
void attempt_ten(int dim, pixel *src, pixel *dst)
{
int a,b,i,j;
int sav=0; //LICM
int sav1=0; //LICM
int sav2=0; //LICM
int adj_dim = dim-1;
for (j=0; j<dim; j+=32)
{
sav = adj_dim-j;
for (i=0; i<dim; i+=8)
{
//Using for loop unrolling
for (b=0; b<32; b++)
{
sav1 = sav - b;
sav2 = j+b;
//Use for loop unrolling
for (a=0; a<8; a++)
dst[RIDX(sav1, i+a, dim)] = src[RIDX(i+a, sav2, dim)];
}
}
}
}
示例2: check_average
static pixel check_average(int dim, int i, int j, pixel *src) {
pixel result;
int num = 0;
int ii, jj;
int sum0, sum1, sum2;
int top_left_i, top_left_j;
int bottom_right_i, bottom_right_j;
top_left_i = max(i-1, 0);
top_left_j = max(j-1, 0);
bottom_right_i = min(i+1, dim-1);
bottom_right_j = min(j+1, dim-1);
sum0 = sum1 = sum2 = 0;
for(ii=top_left_i; ii <= bottom_right_i; ii++) {
for(jj=top_left_j; jj <= bottom_right_j; jj++) {
num++;
sum0 += (int) src[RIDX(ii,jj,dim)].red;
sum1 += (int) src[RIDX(ii,jj,dim)].green;
sum2 += (int) src[RIDX(ii,jj,dim)].blue;
}
}
result.red = (unsigned short) (sum0/num);
result.green = (unsigned short) (sum1/num);
result.blue = (unsigned short) (sum2/num);
return result;
}
示例3: naive_rotate
void naive_rotate(int dim, pixel *src, pixel *dst)
{
int i, j;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
dst[RIDX(dim-1-j, i, dim)] = src[RIDX(i, j, dim)];
}
示例4: rotate3
void rotate3(int dim, pixel *src, pixel *dst)
{
int i,j, ii;
for (i = 0; i < dim; i = i + 16)
{
for (j = 0; j < dim; j++)
{
for(ii = 0; ii < 16; ii++)
{
dst[RIDX(dim-1-j, i+ii, dim)] = src[RIDX(i+ii, j, dim)];
}
}
}
/*
blocking
*/
}
示例5: check_rotate
/*
* check_rotate - Make sure the rotate actually works.
* The orig array should not have been tampered with!
*/
static int check_rotate(int dim)
{
int err = 0;
int i, j;
int badi = 0;
int badj = 0;
pixel orig_bad = {0}, res_bad = {0};
/* return 1 if the original image has been changed */
if (check_orig(dim))
return 1;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j++)
if (compare_pixels(orig[RIDX(i,j,dim)],
result[RIDX(dim-1-j,i,dim)])) {
err++;
badi = i;
badj = j;
orig_bad = orig[RIDX(i,j,dim)];
res_bad = result[RIDX(dim-1-j,i,dim)];
}
if (err) {
printf("\n");
printf("ERROR: Dimension=%d, %d errors\n", dim, err);
printf("E.g., The following two pixels should have equal value:\n");
printf("src[%d][%d].{red,green,blue} = {%d,%d,%d}\n",
badi, badj, orig_bad.red, orig_bad.green, orig_bad.blue);
printf("dst[%d][%d].{red,green,blue} = {%d,%d,%d}\n",
(dim-1-badj), badi, res_bad.red, res_bad.green, res_bad.blue);
}
return err;
}
示例6: rotate
void rotate(int dim, pixel *src, pixel *dst)
{
int i,j;
pixel *dptr,*sptr;
for(i=0;i<dim;i+=16)
for(j=dim-1;j>=0;j--){
dptr=dst+RIDX(dim-1-j,i,dim);
sptr=src+RIDX(i,j,dim);
*(dptr)=*(sptr);sptr+=dim;
*(dptr+1)=*(sptr);sptr+=dim;
*(dptr+2)=*(sptr);sptr+=dim;
*(dptr+3)=*(sptr);sptr+=dim;
*(dptr+4)=*(sptr);sptr+=dim;
*(dptr+5)=*(sptr);sptr+=dim;
*(dptr+6)=*(sptr);sptr+=dim;
*(dptr+7)=*(sptr);sptr+=dim;
*(dptr+8)=*(sptr);sptr+=dim;
*(dptr+9)=*(sptr);sptr+=dim;
*(dptr+10)=*(sptr);sptr+=dim;
*(dptr+11)=*(sptr);sptr+=dim;
*(dptr+12)=*(sptr);sptr+=dim;
*(dptr+13)=*(sptr);sptr+=dim;
*(dptr+14)=*(sptr);sptr+=dim;
*(dptr+15)=*(sptr);
}
}
示例7: naive_rotate_unrolled
void naive_rotate_unrolled(int dim, pixel *src, pixel *dst)
{
int i, j;
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j+=4)
{
dst[RIDX(dim-1-j, i, dim)] = src[0];
dst[RIDX(dim-1-(j + 1), i, dim)] = src[1];
dst[RIDX(dim-1-(j + 2), i, dim)] = src[2];
dst[RIDX(dim-1-(j + 3), i, dim)] = src[3];
// dst[RIDX(dim-1-(j + 4), i, dim)] = *(src + 4);
// dst[RIDX(dim-1-(j + 5), i, dim)] = *(src + 5);
// dst[RIDX(dim-1-(j + 6), i, dim)] = *(src + 6);
// dst[RIDX(dim-1-(j + 7), i, dim)] = *(src + 7);
// dst[RIDX(dim-1-(j + 8), i, dim)] = *(src + 8);
// dst[RIDX(dim-1-(j + 9), i, dim)] = *(src + 9);
// dst[RIDX(dim-1-(j + 10), i, dim)] = *(src + 10);
// dst[RIDX(dim-1-(j + 11), i, dim)] = *(src + 11);
// dst[RIDX(dim-1-(j + 12), i, dim)] = *(src + 12);
// dst[RIDX(dim-1-(j + 13), i, dim)] = *(src + 13);
// dst[RIDX(dim-1-(j + 14), i, dim)] = *(src + 14);
// dst[RIDX(dim-1-(j + 15), i, dim)] = *(src + 15);
src += 4;
}
}
示例8: rotate2
void rotate2(int dim, pixel *src, pixel *dst)
{
int i,j, ii;
for (i = 0; i < dim; i = i + 16)
{
for (j = 0; j < dim; j++)
{
for(ii = 0; ii < 16; ii++)
{
dst[RIDX(dim-1-j, i+ii, dim)] = src[RIDX(i+ii, j, dim)];
}
}
}
/*
unrolling the first loop offers ~ 245% increase in speedup by completing 16
rotations per iteration of i instead of 1.
*/
}
示例9: attempt_two
void attempt_two(int dim, pixel *src, pixel *dst)
{
int i, j;
for (j = 0; j < dim; j++)
for (i = 0; i < dim; i++)
dst[RIDX(dim-1-j, i, dim)] = src[RIDX(i, j, dim)];
}
示例10: rotate2
void rotate2(int dim, pixel *src, pixel *dst) {
int i, j, ridx11, ridx12, ridx21, ridx22, dim2 = dim<<1;
/*if(src == dst) { printf("Aliasing!\n"); return; }*/
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j+=32) {
ridx11 = RIDX(dim-1-j, i, dim);
ridx12 = RIDX(dim-2-j, i, dim);
ridx21 = RIDX(i, j, dim);
ridx22 = RIDX(i, j, dim) + 1;
dst[ridx11] = src[ridx21];
dst[ridx12] = src[ridx22];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
dst[(ridx11-=dim2)] = src[ridx21+=2];
dst[(ridx12-=dim2)] = src[ridx22+=2];
}
}
示例11: attempt_three
void attempt_three(int dim, pixel *src, pixel *dst)
{
int i, j, i1, j1;
int x = dim-1;
int T = dim/4;
for (j = 0; j < dim; j+=8)
for (i = 0; i < dim; i+=T)
for (j1 = j; j1 < MIN(dim, j + 8); j1++)
for (i1 = i; i1 < MIN(dim, i + T); i1++)
dst[RIDX(x - j1, i1, dim)] = src[RIDX(i1, j1, dim)];
}
示例12: smooth4
void smooth4(int dim, pixel *src, pixel *dst)
{
int i,j,x;
for (i = 0; i < dim; i+=16)
{
for (j = 0; j < dim; j++)
{
for(x = 0; x<16;x++)
{
int ii, jj;
pixel_sum sum;
pixel_sum *sum1;
sum1 = ∑
pixel current_pixel;
pixel *curr;
curr = ¤t_pixel;
//initialize_pixel_sum(&sum);
//pixel_sum *sum;
sum1->red = sum1->green = sum1->blue = 0;
sum1->num = 0;
for(ii = max(i+x-1, 0); ii <= min(i+x+1, dim-1); ii++)
{
for(jj = max(j-1, 0); jj <= min(j+1, dim-1); jj++)
{
/*accumulate_sum(&sum, src[RIDX(ii, jj, dim)]);*/
pixel p = src[RIDX(ii, jj, dim)];
/*pixel pp = &p;*/
sum1->red += (int) p.red;
sum1->green += (int) p.green;
sum1->blue += (int) p.blue;
sum1->num++;
}
}
curr->red = (unsigned short) (sum.red/sum.num);
curr->green = (unsigned short) (sum.green/sum.num);
curr->blue = (unsigned short) (sum.blue/sum.num);
dst[RIDX(i, j, dim)] = current_pixel;
}
}
}
}
示例13: rotate
void rotate(int dim, pixel *src, pixel *dst)
{
int i, j, i1, j1;
int x = dim-1;
int W = 8;
int L = 128;
for (j = 0; j < dim; j+=L)
for (i = 0; i < dim; i+=W)
for (j1 = j; j1 < MIN(dim, j + L); j1++)
for (i1 = i; i1 < MIN(dim, i + W); i1++)
dst[RIDX(x - j1, i1, dim)] = src[RIDX(i1, j1, dim)];
}
示例14: rotate1
void rotate1(int dim, pixel *src, pixel *dst) {
int i, j, ridx1, ridx2;
/*if(src == dst) { printf("Aliasing!\n"); return; }*/
for (i = 0; i < dim; i++)
for (j = 0; j < dim; j+=32) {
ridx1 = RIDX(dim-1-j, i, dim);
ridx2 = RIDX(i, j, dim);
dst[ridx1] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
dst[(ridx1-=dim)] = src[ridx2++];
}
}
示例15: line_7
void line_7(int dim, pixel *src, pixel *dst) {
int x0 = 0;
int y0 = floor (dim / 3); /* left endpoint */
int x1 = dim - 1;
int y1 = ceil (dim - 1 - dim / 3); /* right endpoint */
double dy = y1 - y0;
double dx = x1 - x0;
double slope = dy / dx;
double slope2 = slope*2;
double slope3 = slope*3;
double slope4 = slope*4;
double slope5 = slope*5;
double slope6 = slope*6;
double slope7 = slope*7;
double slope8 = slope*8;
double y = y0;
int x = x0;
pixel max = *maximum_7(dim, src);
for (; x <= x1; x+=8) {
dst[RIDX(x, (int)rint(y), dim)] = max;
dst[RIDX(x+1, (int)rint(y+slope), dim)] = max;
dst[RIDX(x+2, (int)rint(y+slope2), dim)] = max;
dst[RIDX(x+3, (int)rint(y+slope3), dim)] = max;
dst[RIDX(x+4, (int)rint(y+slope4), dim)] = max;
dst[RIDX(x+5, (int)rint(y+slope5), dim)] = max;
dst[RIDX(x+6, (int)rint(y+slope6), dim)] = max;
dst[RIDX(x+7, (int)rint(y+slope7), dim)] = max;
y += slope8;
}
}