Skip to content

Commit b850ea9

Browse files
committed
gpujpeg_decoder: warn if using CPU Huffman decoder
1 parent b88b2d0 commit b850ea9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/gpujpeg_decoder.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i
234234
// Get coder
235235
struct gpujpeg_coder* coder = &decoder->coder;
236236
int rc;
237-
int unsupp_gpu_huffman_params = 0;
237+
bool use_cpu_huffman_decoder = false;
238238

239239
coder->start_time = coder->param.perf_stats ? gpujpeg_get_time() : 0;
240240

@@ -253,17 +253,23 @@ gpujpeg_decoder_decode(struct gpujpeg_decoder* decoder, uint8_t* image, size_t i
253253
// packed_block_info_ptr holds only component type
254254
if ( decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_DC] != decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_AC] ) {
255255
fprintf(stderr, "[GPUJPEG] [Warning] Using different table DC/AC indices (%d and %d) for component %d (ID %d)! Using Huffman CPU decoder. Please report to GPUJPEG developers.\n", decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_AC], decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_DC], i, decoder->comp_id[i]);
256-
unsupp_gpu_huffman_params = 1;
256+
use_cpu_huffman_decoder = true;
257257
}
258258
// only DC/AC tables 0 and 1 are processed gpujpeg_huffman_decoder_table_kernel()
259259
if ( decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_DC] > 1 || decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_AC] > 1 ) {
260260
fprintf(stderr, "[GPUJPEG] [Warning] Using Huffman tables (%d, %d) implies extended process! Using Huffman CPU decoder. Please report to GPUJPEG developers.\n", decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_AC], decoder->comp_table_huffman_map[i][GPUJPEG_HUFFMAN_DC]);
261-
unsupp_gpu_huffman_params = 1;
261+
use_cpu_huffman_decoder = true;
262262
}
263263
}
264264

265+
if ( coder->segment_count < 32 ) { // the CPU Huffman implementation will be likely faster
266+
VERBOSE_MSG(decoder->coder.param.verbose, "Huffman has only %d segments. Using CPU decoder, which is slower!\n",
267+
coder->segment_count);
268+
use_cpu_huffman_decoder = true;
269+
}
270+
265271
// Perform huffman decoding on CPU (when there are not enough segments to saturate GPU)
266-
if (coder->segment_count < 32 || unsupp_gpu_huffman_params) {
272+
if ( use_cpu_huffman_decoder ) {
267273
GPUJPEG_CUSTOM_TIMER_START(coder->duration_huffman_coder, coder->param.perf_stats, decoder->stream, return -1);
268274
if (coder->data_quantized == NULL) {
269275
if (gpujpeg_coder_allocate_cpu_huffman_buf(coder) != 0) {

0 commit comments

Comments
 (0)