diff --git a/src/gpujpeg_common.c b/src/gpujpeg_common.c index 20e96794..0a883adb 100644 --- a/src/gpujpeg_common.c +++ b/src/gpujpeg_common.c @@ -160,7 +160,8 @@ gpujpeg_get_devices_info(void) #endif } #else -// TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_get_devices_info(): NOT YET IMPLEMENTED\n"); #endif return devices_info; } @@ -261,7 +262,8 @@ gpujpeg_init_device(int device_id, int flags) return -1; } #else -// TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_init_device(): NOT YET IMPLEMENTED\n"); #endif return 0; } @@ -440,6 +442,7 @@ void gpujpeg_set_device(int index) cudaSetDevice(index); #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_set_device(): NOT YET IMPLEMENTED\n"); #endif } @@ -463,7 +466,8 @@ gpujpeg_component_print8(struct gpujpeg_component* component, uint8_t* d_data) cudaFreeHost(data); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_component_print8(): NOT YET IMPLEMENTED\n"); +#endif } /* Documented at declaration */ @@ -486,7 +490,8 @@ gpujpeg_component_print16(struct gpujpeg_component* component, int16_t* d_data) cudaFreeHost(data); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_component_print16(): NOT YET IMPLEMENTED\n"); +#endif } /* Documented at declaration */ @@ -508,6 +513,7 @@ gpujpeg_coder_init(struct gpujpeg_coder * coder) } #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_coder_init(): NOT YET IMPLEMENTED\n"); #endif // Initialize coder for no image coder->param.quality = -1; @@ -594,6 +600,18 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("Coder color component device allocation", return 0); #else // TODO: NEED IMPLEMENTATION + // (Re)allocate color components in host memory + if (coder->component != NULL) { + free(coder->component); + coder->component = NULL; + } + coder->component = (struct gpujpeg_component*)malloc(param_image->comp_count * sizeof(struct gpujpeg_component)); + // (Re)allocate color components in device memory + if (coder->d_component != NULL) { + free(coder->d_component); + coder->d_component = NULL; + } + coder->d_component = (struct gpujpeg_component*)malloc(param_image->comp_count * sizeof(struct gpujpeg_component)); #endif coder->component_allocated_size = param_image->comp_count; } @@ -738,6 +756,19 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("Coder segment device allocation", return 0); #else // TODO: NEED IMPLEMENTATION + // (Re)allocate segments in host memory + if (coder->segment != NULL) { + free(coder->segment); + coder->segment = NULL; + } + coder->segment = (struct gpujpeg_segment*) malloc(coder->segment_count * sizeof(struct gpujpeg_segment)); + + // (Re)allocate segments in device memory + if (coder->d_segment != NULL) { + free(coder->d_segment); + coder->d_segment = NULL; + } + coder->d_segment = (struct gpujpeg_segment*) malloc(coder->segment_count * sizeof(struct gpujpeg_segment)); #endif coder->segment_allocated_size = coder->segment_count; } @@ -870,6 +901,27 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("Coder quantized data device allocation", return 0); #else // TODO: NEED IMPLEMENTATION + // (Re)allocate preprocessor data in device memory + if (coder->d_data != NULL) { + free(coder->d_data); + coder->d_data = NULL; + } + coder->d_data = (uint8_t*) malloc((coder->data_size + idct_overhead) * sizeof(uint8_t)); + + // (Re)allocated DCT and quantizer data in host memory + if (coder->data_quantized != NULL) { + free(coder->data_quantized); + coder->data_quantized = NULL; + } + coder->data_quantized = (int16_t*) malloc(coder->data_size * sizeof(int16_t)); + + // (Re)allocated DCT and quantizer data in device memory + if (coder->d_data_quantized != NULL) { + free(coder->d_data_quantized); + coder->d_data_quantized = NULL; + } + + coder->d_data_quantized = (int16_t*) malloc((coder->data_size + idct_overhead) * sizeof(int16_t)); #endif coder->data_allocated_size = coder->data_size + idct_overhead; } @@ -882,7 +934,8 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("d_data memset failed", return 0); #else // TODO: NEED IMPLEMENTATION -#endif + memset(coder->d_data, 0, coder->data_size * sizeof(uint8_t)); +#endif } // Set data buffer to color components @@ -934,6 +987,26 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("Huffman temp buffer device allocation", return 0); #else // TODO: NEED IMPLEMENTATION + // (Re)allocate huffman coder data in host memory + if (coder->data_compressed != NULL) { + free(coder->data_compressed); + coder->data_compressed = NULL; + } + coder->data_compressed = (uint8_t*)malloc(max_compressed_data_size * sizeof(uint8_t)); + + // (Re)allocate huffman coder data in device memory + if (coder->d_data_compressed != NULL) { + free(coder->d_data_compressed); + coder->d_data_compressed = NULL; + } + coder->d_data_compressed = (uint8_t*)malloc(max_compressed_data_size * sizeof(uint8_t)); + + // (Re)allocate Huffman coder temporary buffer + if (coder->d_temp_huffman != NULL) { + free(coder->d_temp_huffman); + coder->d_temp_huffman = NULL; + } + coder->d_temp_huffman = (uint8_t*)malloc(max_compressed_data_size * sizeof(uint8_t)); #endif coder->data_compressed_allocated_size = max_compressed_data_size; } @@ -965,6 +1038,19 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para gpujpeg_cuda_check_error("Coder block list device allocation", return 0); #else // TODO: NEED IMPLEMENTATION + // (Re)allocate list of block indices in host memory + if (coder->block_list != NULL) { + free(coder->block_list); + coder->block_list = NULL; + } + coder->block_list = (uint64_t*)malloc(coder->block_count * sizeof(*coder->block_list)); + + // (Re)allocate list of block indices in device memory + if (coder->d_block_list != NULL) { + free(coder->d_block_list); + coder->d_block_list = NULL; + } + coder->d_block_list = (uint64_t*)malloc(coder->block_count * sizeof(*coder->d_block_list)); #endif coder->block_allocated_size = coder->block_count; } @@ -1041,7 +1127,15 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para cudaMemcpyAsync(coder->d_segment, coder->segment, coder->segment_count * sizeof(struct gpujpeg_segment), cudaMemcpyHostToDevice, stream); gpujpeg_cuda_check_error("Coder segment copy", return 0); #else - // TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + // Copy components to device memory + memcpy(coder->d_component, coder->component, coder->param_image.comp_count * sizeof(struct gpujpeg_component)); + + // Copy block lists to device memory + memcpy(coder->d_block_list, coder->block_list, coder->block_count * sizeof(*coder->d_block_list)); + + // Copy segments to device memory + memcpy(coder->d_segment, coder->segment, coder->segment_count * sizeof(struct gpujpeg_segment)); #endif coder->allocated_gpu_memory_size = allocated_gpu_memory_size; @@ -1098,7 +1192,8 @@ gpujpeg_coder_deinit(struct gpujpeg_coder* coder) if ( coder->d_block_list != NULL ) cudaFree(coder->d_block_list); #else - // TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_coder_deinit(): NOT YET IMPLEMENTED\n"); #endif GPUJPEG_CUSTOM_TIMER_DESTROY(coder->duration_memory_to, return -1); GPUJPEG_CUSTOM_TIMER_DESTROY(coder->duration_memory_from, return -1); @@ -1143,7 +1238,8 @@ static void *gpujpeg_cuda_malloc_host(size_t size) { GPUJPEG_CHECK_EX(cudaMallocHost(&ptr, size), "Could not alloc host pointer", return NULL); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_cuda_malloc_host(): NOT YET IMPLEMENTED\n"); +#endif return ptr; } @@ -1180,7 +1276,12 @@ gpujpeg_image_load_from_file(const char* filename, uint8_t** image, size_t* imag } #else // TODO: NEED IMPLEMENTATION -#endif + data = (uint8_t*)malloc(*image_size * sizeof(uint8_t)); + if ( *image_size != fread(data, sizeof(uint8_t), *image_size, file) ) { + fprintf(stderr, "[GPUJPEG] [Error] Failed to load image data [%zd bytes] from file %s!\n", *image_size, filename); + return -1; + } +#endif fclose(file); *image = data; @@ -1266,7 +1367,8 @@ gpujpeg_image_destroy(uint8_t* image) cudaFreeHost(image); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_image_destroy(): NOT YET IMPLEMENTED\n"); +#endif return 0; } @@ -1684,7 +1786,8 @@ gpujpeg_opengl_texture_register(int texture_id, enum gpujpeg_opengl_texture_type #endif #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_opengl_texture_register(): NOT YET IMPLEMENTED\n"); +#endif } /* Documented at declaration */ @@ -1704,6 +1807,7 @@ gpujpeg_opengl_texture_unregister(struct gpujpeg_opengl_texture* texture) cudaFreeHost(texture); #else // TODO: NEED TO BE IMPLEMENTED + printf("[WARNING] gpujpeg_opengl_texture_unregister(): NOT YET IMPLEMENTED\n"); #endif #else (void) texture; @@ -1751,6 +1855,7 @@ gpujpeg_opengl_texture_map(struct gpujpeg_opengl_texture* texture, size_t* data_ *data_size = d_data_size; #else // TODO: NEED TO BE IMPLEMENTED + printf("[WARNING] gpujpeg_opengl_texture_map(): NOT YET IMPLEMENTED\n"); (void) data_size; GPUJPEG_MISSING_OPENGL(return NULL); #endif @@ -1792,6 +1897,7 @@ gpujpeg_opengl_texture_unmap(struct gpujpeg_opengl_texture* texture) #endif #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_opengl_texture_unmap(): NOT YET IMPLEMENTED\n"); #endif } @@ -1990,7 +2096,10 @@ float gpujpeg_custom_timer_get_duration(cudaEvent_t start, cudaEvent_t stop) { return elapsedTime; } #else -// TODO: NEED IMPLEMENTATION +float gpujpeg_custom_timer_get_duration(float start, float stop) { + float elapsedTime = NAN; + return elapsedTime; +} #endif /* vi: set expandtab sw=4 : */ diff --git a/src/gpujpeg_common_internal.h b/src/gpujpeg_common_internal.h index c67ebdf2..6a3d7993 100644 --- a/src/gpujpeg_common_internal.h +++ b/src/gpujpeg_common_internal.h @@ -75,7 +75,10 @@ struct gpujpeg_timer { #ifdef GPUJPEG_USE_CUDA cudaEvent_t start; cudaEvent_t stop; -#endif +#else + float start; + float stop; +#endif }; #ifdef GPUJPEG_USE_CUDA @@ -147,7 +150,8 @@ struct gpujpeg_timer { * * @param name */ -#define GPUJPEG_CUSTOM_TIMER_DURATION(name) 0 +#define GPUJPEG_CUSTOM_TIMER_DURATION(name) \ + (name).started == 1 ? gpujpeg_custom_timer_get_duration((name).start, (name).stop) : (name).started == 0 ? 0 : ( fprintf(stderr, "Debug timer disabled!\n"), 0) #endif #ifdef __cplusplus @@ -463,6 +467,9 @@ gpujpeg_image_parameters_equals(const struct gpujpeg_image_parameters *p1 , cons #ifdef GPUJPEG_USE_CUDA float gpujpeg_custom_timer_get_duration(cudaEvent_t start, cudaEvent_t stop); +#else +float +gpujpeg_custom_timer_get_duration(float start, float stop); #endif #ifdef __cplusplus diff --git a/src/gpujpeg_dct_cpu.c b/src/gpujpeg_dct_cpu.c index 8e7bfb7a..43de6023 100644 --- a/src/gpujpeg_dct_cpu.c +++ b/src/gpujpeg_dct_cpu.c @@ -217,7 +217,8 @@ gpujpeg_idct_cpu(struct gpujpeg_decoder* decoder) cudaMemcpy(component->data_quantized, component->d_data_quantized, component->data_size * sizeof(uint16_t), cudaMemcpyDeviceToHost); #else // TODO: NEED IMPLEMENTATION -#endif + memcpy(component->data_quantized, component->d_data_quantized, component->data_size * sizeof(uint16_t)); +#endif @@ -257,6 +258,24 @@ gpujpeg_idct_cpu(struct gpujpeg_decoder* decoder) cudaFreeHost(data); #else // TODO: NEED IMPLEMENTATION -#endif + data = (uint8_t*)malloc(component->data_size * sizeof(uint8_t)); + for ( int y = 0; y < height; y++ ) { + for ( int x = 0; x < width; x++ ) { + for ( int c = 0; c < (GPUJPEG_BLOCK_SIZE * GPUJPEG_BLOCK_SIZE); c++ ) { + int coefficient_index = (y * width + x) * (GPUJPEG_BLOCK_SIZE * GPUJPEG_BLOCK_SIZE) + c; + int16_t coefficient = component->data_quantized[coefficient_index]; + coefficient += 128; + if ( coefficient > 255 ) + coefficient = 255; + if ( coefficient < 0 ) + coefficient = 0; + int index = ((y * GPUJPEG_BLOCK_SIZE) + (c / GPUJPEG_BLOCK_SIZE)) * component->data_width + ((x * GPUJPEG_BLOCK_SIZE) + (c % GPUJPEG_BLOCK_SIZE)); + data[index] = coefficient; + } + } + } + memcpy(component->d_data, data, component->data_size * sizeof(uint8_t)); + free(data); +#endif } } diff --git a/src/gpujpeg_decoder.c b/src/gpujpeg_decoder.c index fa41a15b..f8aea27a 100644 --- a/src/gpujpeg_decoder.c +++ b/src/gpujpeg_decoder.c @@ -142,14 +142,27 @@ gpujpeg_decoder_create(cudaStream_t stream) } gpujpeg_cuda_check_error("Decoder table allocation", return NULL); - // Init huffman encoder + // Init huffman decoder if ((decoder->huffman_gpu_decoder = gpujpeg_huffman_gpu_decoder_init()) == NULL) { result = 0; } #else - // TODO: NEED IMPLEMENTATION - result = 0; -#endif + // Allocate quantization tables in device memory + for ( int comp_type = 0; comp_type < GPUJPEG_MAX_COMPONENT_COUNT; comp_type++ ) { + decoder->table_quantization[comp_type].d_table = (uint16_t*)malloc(64 * sizeof(uint16_t)); + } + // Allocate huffman tables in device memory + for ( int comp_type = 0; comp_type < GPUJPEG_MAX_COMPONENT_COUNT; comp_type++ ) { + for ( int huff_type = 0; huff_type < GPUJPEG_HUFFMAN_TYPE_COUNT; huff_type++ ) { + + decoder->d_table_huffman[comp_type][huff_type] = malloc(sizeof(struct gpujpeg_table_huffman_decoder)); + memset(decoder->d_table_huffman[comp_type][huff_type], 0, sizeof(struct gpujpeg_table_huffman_decoder)); + } + } + + // Init huffman decoder + // TODO: Need to init the hufman encoder +#endif // Stream decoder->stream = stream; @@ -207,7 +220,7 @@ gpujpeg_decoder_init(struct gpujpeg_decoder* decoder, const struct gpujpeg_param return -1; } #else - // TODO: NOT YET IMPLEMENTED + // TODO: NOT YET IMPLEMENTED\n #endif return 0; @@ -286,16 +299,38 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i } GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_huffman_coder, coder->param.perf_stats, decoder->stream, return -1); } +#else + // TODO: NEED IMPLEMENTATION + GPUJPEG_CUSTOM_TIMER_START(coder->duration_huffman_coder, coder->param.perf_stats, decoder->stream, return -1); + if (0 != gpujpeg_huffman_cpu_decoder_decode(decoder)) { + fprintf(stderr, "[GPUJPEG] [Error] Huffman decoder failed!\n"); + return -1; + } + GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_huffman_coder, coder->param.perf_stats, decoder->stream, return -1); + // Copy quantized data to device memory from cpu memory + GPUJPEG_CUSTOM_TIMER_START(coder->duration_memory_to, coder->param.perf_stats, decoder->stream, return -1); + memcpy(coder->d_data_quantized, coder->data_quantized, coder->data_size * sizeof(int16_t)); + GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_to, coder->param.perf_stats, decoder->stream, return -1); + + GPUJPEG_CUSTOM_TIMER_START(coder->duration_in_gpu, coder->param.perf_stats, decoder->stream, return -1); +#endif + GPUJPEG_CUSTOM_TIMER_START(coder->duration_dct_quantization, coder->param.perf_stats, decoder->stream, return -1); // Perform IDCT and dequantization (own CUDA implementation) +#ifdef GPUJPEG_USE_CUDA if (0 != gpujpeg_idct_gpu(decoder)) { return -1; } - +#else + // TODO: NEED IMPLEMENTATION + gpujpeg_idct_cpu(decoder); +#endif + GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_dct_quantization, coder->param.perf_stats, decoder->stream, return -1); +#ifdef GPUJPEG_USE_CUDA if (coder->data_raw == NULL) { if (cudaSuccess != cudaMallocHost((void**)&coder->data_raw, coder->data_raw_size * sizeof(uint8_t))) { return -1; @@ -308,7 +343,13 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i } #else // TODO: NEED IMPLEMENTATION -#endif + if (coder->data_raw == NULL) { + coder->data_raw = (uint8_t*)malloc(coder->data_raw_size * sizeof(uint8_t)); + } + if (coder->d_data_raw_allocated == NULL) { + coder->d_data_raw_allocated = (uint8_t*)malloc(coder->data_raw_size * sizeof(uint8_t)); + } +#endif // Select CUDA output buffer if (output->type == GPUJPEG_DECODER_OUTPUT_CUSTOM_CUDA_BUFFER) { @@ -344,7 +385,8 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i cudaStreamSynchronize(decoder->stream); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_decoder_decode(): NOT YET IMPLEMENTED\n"); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_in_gpu, coder->param.perf_stats, decoder->stream, return -1); @@ -363,7 +405,8 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i cudaMemcpy(coder->data_raw, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t), cudaMemcpyDeviceToHost); #else // TODO: NEED IMPLEMENTATION -#endif + memcpy(coder->data_raw, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t)); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_from, coder->param.perf_stats, decoder->stream, return -1); // Set output to internal buffer @@ -379,7 +422,8 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i cudaMemcpy(output->data, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t), cudaMemcpyDeviceToHost); #else // TODO: NEED IMPLEMENTATION -#endif + memcpy(output->data, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t)); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_from, coder->param.perf_stats, decoder->stream, return -1); } else if (output->type == GPUJPEG_DECODER_OUTPUT_OPENGL_TEXTURE) { @@ -400,7 +444,8 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i cudaMemcpy(d_data, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t), cudaMemcpyDeviceToDevice); #else // TODO: NEED IMPLEMENTATION -#endif + memcpy(d_data, coder->d_data_raw, coder->data_raw_size * sizeof(uint8_t)); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_from, coder->param.perf_stats, decoder->stream, return -1); } @@ -473,6 +518,7 @@ gpujpeg_decoder_destroy(struct gpujpeg_decoder* decoder) } #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_decoder_destroy(): NOT YET IMPLEMENTED\n"); #endif free(decoder); diff --git a/src/gpujpeg_encoder.c b/src/gpujpeg_encoder.c index bd9758db..2822ff6a 100644 --- a/src/gpujpeg_encoder.c +++ b/src/gpujpeg_encoder.c @@ -109,6 +109,7 @@ gpujpeg_encoder_create(cudaStream_t stream) gpujpeg_cuda_check_error("Encoder table allocation", return NULL); #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_create(): NOT YET IMPLEMENTED\n"); #endif // Init huffman tables for encoder @@ -122,6 +123,7 @@ gpujpeg_encoder_create(cudaStream_t stream) gpujpeg_cuda_check_error("Encoder table init", return NULL); #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_create(): NOT YET IMPLEMENTED\n"); #endif // Init huffman encoder @@ -132,7 +134,8 @@ gpujpeg_encoder_create(cudaStream_t stream) } #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_encoder_create(): NOT YET IMPLEMENTED\n"); +#endif if ( result == 0 ) { gpujpeg_encoder_destroy(encoder); @@ -167,7 +170,8 @@ size_t gpujpeg_encoder_max_pixels(struct gpujpeg_parameters * param, struct gpuj #else // TODO: NEED IMPLEMENTATION size_t image_memory_size = 0; -#endif + printf("[WARNING] gpujpeg_encoder_max_pixels(): NOT YET IMPLEMENTED\n"); +#endif if (image_memory_size == 0) { break; } @@ -227,7 +231,8 @@ size_t gpujpeg_encoder_max_memory(struct gpujpeg_parameters * param, struct gpuj #else // TODO: NEED IMPLEMENTATION size_t image_memory_size = 0; -#endif + printf("[WARNING] gpujpeg_encoder_max_memory(): NOT YET IMPLEMENTED\n"); +#endif if (image_memory_size == 0) { return 0; @@ -275,6 +280,7 @@ int gpujpeg_encoder_allocate(struct gpujpeg_encoder * encoder, const struct gpuj gpujpeg_cuda_check_error("Encoder raw data allocation", return -1); #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_allocate(): NOT YET IMPLEMENTED\n"); #endif coder->data_raw_allocated_size = coder->data_raw_size; } @@ -338,7 +344,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter gpujpeg_cuda_check_error("Quantization init", return -1); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif } if (0 == gpujpeg_coder_init_image(coder, param, param_image, encoder->stream)) { @@ -359,7 +366,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter return -1; } #else - // TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); #endif // Load input image @@ -389,6 +397,7 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter gpujpeg_cuda_check_error("Encoder raw data copy", return -1); #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); #endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_to, coder->param.perf_stats, encoder->stream, return -1); } @@ -417,7 +426,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter } #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif coder->d_data_raw = coder->d_data_raw_allocated; // Map texture to CUDA @@ -433,7 +443,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter cudaMemcpyAsync(coder->d_data_raw, d_data, coder->data_raw_size * sizeof(uint8_t), cudaMemcpyDeviceToDevice, encoder->stream); #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_to, coder->param.perf_stats, encoder->stream, return -1); GPUJPEG_CUSTOM_TIMER_START(coder->duration_memory_unmap, coder->param.perf_stats, encoder->stream, return -1); @@ -469,7 +480,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter } #else // TODO: NEED IMPLEMENTATION -#endif + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif // If restart interval is 0 then the GPU processing is in the end (even huffman coder will be performed on CPU) if (coder->param.restart_interval == 0) { @@ -494,7 +506,8 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter // Wait for async operations before the coding cudaStreamSynchronize(encoder->stream); #else - // TODO: NEED IMPLEMENTATION + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); #endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_from, coder->param.perf_stats, encoder->stream, return -1); @@ -518,6 +531,7 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter } #else // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); return -1; #endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_huffman_coder, coder->param.perf_stats, encoder->stream, return -1); @@ -537,8 +551,9 @@ gpujpeg_encoder_encode(struct gpujpeg_encoder* encoder, struct gpujpeg_parameter // Wait for async operations before formatting cudaStreamSynchronize(encoder->stream); #else - // TODO: NEED IMPLEMENTATION -#endif + // TODO: NEED IMPLEMENTATION + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif GPUJPEG_CUSTOM_TIMER_STOP(coder->duration_memory_from, coder->param.perf_stats, encoder->stream, return -1); GPUJPEG_CUSTOM_TIMER_START(coder->duration_stream, coder->param.perf_stats, encoder->stream, return -1); @@ -632,7 +647,8 @@ gpujpeg_encoder_destroy(struct gpujpeg_encoder* encoder) gpujpeg_huffman_gpu_encoder_destroy(encoder->huffman_gpu_encoder); #else // TODO: NEED TO BE IMPLEMENTED -#endif + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); +#endif } if (gpujpeg_coder_deinit(&encoder->coder) != 0) { return -1; @@ -647,6 +663,7 @@ gpujpeg_encoder_destroy(struct gpujpeg_encoder* encoder) } #else // TODO: NEED TO BE IMPLEMENTED + printf("[WARNING] gpujpeg_encoder_encode(): NOT YET IMPLEMENTED\n"); #endif } if (encoder->writer != NULL) {