 #endif
 
     // Emit left bits
-    //TODO co jsou nase zbyvajici bity
-    //if ( put_bits > 0 )
-    //    gpujpeg_huffman_gpu_encoder_emit_left_bits(put_value, put_bits, data_compressed);
+    gpujpeg_huffman_gpu_encoder_emit_left_bits(data_compressed, s_out, out_size, tid);
 
     // Output restart marker
     if (tid == 0 ) {

    cudaFuncSetCacheConfig(gpujpeg_huffman_encoder_encode_kernel, cudaFuncCachePreferShared);
            
    // Run kernel
    dim3 thread(THREAD_BLOCK_SIZE);
    dim3 grid(gpujpeg_div_and_round_up(coder->segment_count, thread.x));
    gpujpeg_huffman_encoder_encode_kernel<<<grid, thread>>>(
        coder->d_component, 
        coder->d_segment, 

        dc[comp] = 0;
    
    // Prepare data pointers
    uint8_t * data_compressed = &d_data_compressed[segment->data_compressed_index]; //TODO zmeni datovy typ
    uint8_t * data_compressed_start = data_compressed;
    
    // Non-interleaving mode
    if ( comp_count == 1 ) {
