 {
     const unsigned int image_position_x = threadIdx.x + blockIdx.x * blockDim.x;
     const unsigned int image_position_y = blockIdx.y;
-    int x  = threadIdx.x;
+    const unsigned int x = threadIdx.x;
     const unsigned int pix_offset = image_position_y * image_width + blockIdx.x * blockDim.x;
             
     // Load to shared

{
    const unsigned int image_position_x = threadIdx.x + blockIdx.x * blockDim.x;
    const unsigned int image_position_y = blockIdx.y;
    int x = threadIdx.x;
    const unsigned int pix_offset = image_position_y * image_width + blockIdx.x * blockDim.x;
        
    // Load to shared

struct gpujpeg_preprocessor_raw_to_comp_store
{
    static __device__ void
    perform(uint8_t value, unsigned int position_x, unsigned int position_y, struct gpujpeg_preprocessor_data_component & comp)
    {
        uint8_t samp_factor_h = s_samp_factor_h;
        if ( samp_factor_h == GPUJPEG_DYNAMIC ) {
