 
 __device__ static unsigned int
 gpujpeg_huffman_gpu_encode_value(const int preceding_zero_count, const int value,
-                                 const struct gpujpeg_table_huffman_encoder * const d_table,
-                                 const bool encode)
+                                 const struct gpujpeg_table_huffman_encoder * const d_table)
 {
     // value bits are in MSBs (left aligned) and bit size of the value is in LSBs (right aligned)
     const unsigned int packed_value = gpujpeg_huffman_value_decomposition[4096 + value];

        *last_dc = original_in_even;
    }
    
    // each thread gets codeword for its two pixels
    const bool encode = nonzero_follows || !tid;
    unsigned int even_code = gpujpeg_huffman_gpu_encode_value(zeros_before_even & 0xf, in_even, d_table_even, encode);
    unsigned int odd_code = gpujpeg_huffman_gpu_encode_value(zeros_before_odd & 0xf, in_odd, d_table_ac, encode);
    
    // special case for last zero coefficient
    if(tid == 31 && in_odd == 0) {

    const unsigned int nonzero_mask = (1 << tid) - 1;
    const int even_nonzero_count = __clz(even_nonzero_bitmap & nonzero_mask);
    const int odd_nonzero_count = __clz(odd_nonzero_bitmap & nonzero_mask);
    int zeros_before_even = (min(odd_nonzero_count, even_nonzero_count) + tid - 32) * 2
                                + (odd_nonzero_count > even_nonzero_count ? 1 : 0);
    
    // count of consecutive zeros before odd value (either one more than 
    // even if even is zero or none if even value itself is nonzero)
    int zeros_before_odd = in_even || !tid ? 0 : zeros_before_even + 1;
                                
    // true if any nonzero pixel follows thread's even pixel
    const unsigned int follow_mask = ~(nonzero_mask >> 1);
    const bool nonzero_follows = follow_mask & (even_nonzero_bitmap | odd_nonzero_bitmap);
    
    // clear zero counts if no nonzero pixel follows (so that no 16-zero symbols will be emited)
    // otherwise only trim extra bits from the counts of following zeros
    const int zero_count_mask = nonzero_follows ? 0xF : 0;
    zeros_before_even &= zero_count_mask;
    zeros_before_odd &= zero_count_mask;
    
    // pointer to LUT for encoding thread's even value 
    // (only thread #0 uses DC table, others use AC table)
