RGB -> YUV

My current device code looks like

__global__ void kernel(unsigned int *dst, int imageW, int imageH)

{

    

    const int ix = blockDim.x * blockIdx.x + threadIdx.x;

    const int iy = blockDim.y * blockIdx.y + threadIdx.y;

    //Add half of a texel to always address exact texel centers

    const float x = (float)ix + 0.5f;

    const float y = (float)iy + 0.5f;

    

    float4 clr;

   if(ix < imageW && iy < imageH)

    {

  for(float i = -WINDOW_RADIUS; i <= WINDOW_RADIUS; i++)

  {

  	for(float j = -WINDOW_RADIUS; j <= WINDOW_RADIUS; j++)

  	{

    clr = tex2D(texImage, x+i, y+i); 

  	}

  	} 

                dst[imageW * iy + ix] = make_YUV(clr.x, clr.y, clr.z, 1.0);

    };

}

__device__ unsigned int make_YUV(float r, float g, float b, float a)

{

    float y = 0.299*r + 0.587*g + 0.114*b; 

    float u = 0.492*(b-y);

    float v = 0.877*(r-y);

	

    y = min(y, 1.0);

    u = min(u, 1.0);

    v = min(v, 1.0);

   y = max(y, 0.0);

    u = max(u, 0.0);

    v = max(v, 0.0);

    

    return

	((int)(1.0 * 255.0f) << 24) |

        ((int)(v * 255.0f) << 16) |

        ((int)(u * 255.0f) <<  8) |

        ((int)(y * 255.0f) <<  0);

}

But now I get following error which I can’t really debug…

Performing Custom Build Step

ImageTransformation.cu

"c:\program files\nvidia corporation\nvidia cuda sdk\testprojects\imagetransformation\imageTransformation_kernel.cu", line 32: error: 

          identifier "make_YUV" is undefined

      dst[imageW * iy + ix] = make_YUV(clr.x, clr.y, clr.z, 1.0); 

                              ^

1 error detected in the compilation of "C:\DOCUME~1\LOCALS~1\Temp/tmpxft_00000ef4_00000000-5.ii".

Anyone who can help me out?

just a quick thought : did you try to put the code of make_YUV before the code of kernel() in your file ? (cuda 1.1 didn’t cause any problem with that, but CUDA 2.0 did, when I last tried)

Hmm lol you are correct!

Allthough another weird thing came up:

1>------ Rebuild All started: Project: ImageTransformation, Configuration: Debug Win32 ------

1>Deleting intermediate and output files for project 'ImageTransformation', configuration 'Debug|Win32'

1>Performing Custom Build Step

1>ImageTransformation.cu

1>tmpxft_00000cd0_00000000-3.gpu

1>tmpxft_00000cd0_00000000-7.gpu

1>"c:\program files\nvidia corporation\nvidia cuda sdk\testprojects\imagetransformation\imageTransformation_kernel.cu", line 37: Error: External calls are not supported (found non-inlined call to _ZN7textureI6uchar4Li2EL19cudaTextureReadMode1EEC1Ei21cudaTextureFilterMode22cudaTextureAddressMode)

1>Compiling manifest to resources...

1>Linking...

<b>1>LINK : fatal error LNK1104: cannot open file '.\Debug\ImageTransformation.obj'</b>

1>Build log was saved at "file://c:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\TestProjects\ImageTransformation\Debug\BuildLog.htm"

1>ImageTransformation - 1 error(s), 0 warning(s)

========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Any ideas about that?