             return -1;
     }
 
+#endif
     return 0;
 }
 

            }
            
            // Encode 8x8 block
            if ( gpujpeg_huffman_gpu_encoder_encode_block(put_value, put_bits, component_dc, block, data_compressed, d_table_dc, d_table_ac) != 0 )
                break;
        } 
    }
    // Interleaving mode
    else {
        int segment_index = segment->scan_segment_index;

    struct gpujpeg_table_huffman_encoder* d_table_cbcr_ac = &gpujpeg_huffman_gpu_encoder_table_huffman[GPUJPEG_COMPONENT_CHROMINANCE][GPUJPEG_HUFFMAN_AC];
#endif
    
    int warpidx  = threadIdx.x >> 5;
    int warpsnum = 8; // TODO kandidat na nahrazeni konstantou
    int tid    = threadIdx.x & 31;
    int out_size = 0;

    __shared__ int s_in_all[64 * 8];
    __shared__ int s_out_all[192 * 8];

    int * s_in  =  s_in_all + warpidx * 64;
    int * s_out = s_out_all + warpidx * 192;
    
    // Select Segment
    int segment_index = blockIdx.x * warpsnum + warpidx;
    if ( segment_index >= segment_count )
        return;
    
    struct gpujpeg_segment* segment = &d_segment[segment_index];
    
    // Initialize huffman coder
    int dc[GPUJPEG_MAX_COMPONENT_COUNT]; //TODO pouze prvni vlakno
    for ( int comp = 0; comp < GPUJPEG_MAX_COMPONENT_COUNT; comp++ )
        dc[comp] = 0;
    
    // Prepare data pointers
    int * data_compressed = (int *)&d_data_compressed[segment->data_compressed_index]; //TODO zmeni datovy typ
    int * data_compressed_start = data_compressed;
    
    // Non-interleaving mode
    if ( comp_count == 1 ) {
        int segment_index = segment->scan_segment_index; //TODO tento index muze byt jiny nez byl segment_index vyse?

        // Get component for current scan
        struct gpujpeg_component* component = &d_component[segment->scan_index];

        // Get component data for MCU (first block)
        int16_t* block = &component->d_data_quantized[(segment_index * component->segment_mcu_count) * component->mcu_size];
        //int16_t* block = &component->d_data_quantized[(segment_index * component->segment_mcu_count + mcu_index) * component->mcu_size];
     
        // Encode MCUs in segment
        for ( int mcu_index = 0; mcu_index < segment->mcu_count; mcu_index++ ) {

            // Get coder parameters
            int & last_dc = dc[segment->scan_index]; //TODO tohle by nemel byt problem vytahnout pred for cyklus, kdyz delame pouze jednu komponentu
            
            // Get huffman tables //TODO rovnez vytahnout pred for cyklus
            struct gpujpeg_table_huffman_encoder* d_table_dc = NULL;
            struct gpujpeg_table_huffman_encoder* d_table_ac = NULL;
            if ( component->type == GPUJPEG_COMPONENT_LUMINANCE ) {
