@@ -171,23 +171,23 @@ gpujpeg_print_devices_info(void)
171171{
172172 struct gpujpeg_devices_info devices_info = gpujpeg_get_devices_info ();
173173 if ( devices_info .device_count == 0 ) {
174- printf ("There is no device supporting CUDA.\n" );
174+ PRINTF ("There is no device supporting CUDA.\n" );
175175 return -1 ;
176176 } else if ( devices_info .device_count == 1 ) {
177- printf ("There is 1 device supporting CUDA:\n" );
177+ PRINTF ("There is 1 device supporting CUDA:\n" );
178178 } else {
179- printf ("There are %d devices supporting CUDA:\n" , devices_info .device_count );
179+ PRINTF ("There are %d devices supporting CUDA:\n" , devices_info .device_count );
180180 }
181181
182182 for ( int device_id = 0 ; device_id < devices_info .device_count ; device_id ++ ) {
183183 struct gpujpeg_device_info * device_info = & devices_info .device [device_id ];
184- printf ("\nDevice #%d: \"%s\"\n" , device_info -> id , device_info -> name );
185- printf (" Compute capability: %d.%d\n" , device_info -> cc_major , device_info -> cc_minor );
186- printf (" Total amount of global memory: %zu KiB\n" , device_info -> global_memory / 1024 );
187- printf (" Total amount of constant memory: %zu KiB\n" , device_info -> constant_memory / 1024 );
188- printf (" Total amount of shared memory per block: %zu KiB\n" , device_info -> shared_memory / 1024 );
189- printf (" Total number of registers available per block: %d\n" , device_info -> register_count );
190- printf (" Multiprocessors: %d\n" , device_info -> multiprocessor_count );
184+ PRINTF ("\nDevice #%d: \"%s\"\n" , device_info -> id , device_info -> name );
185+ PRINTF (" Compute capability: %d.%d\n" , device_info -> cc_major , device_info -> cc_minor );
186+ PRINTF (" Total amount of global memory: %zu KiB\n" , device_info -> global_memory / 1024 );
187+ PRINTF (" Total amount of constant memory: %zu KiB\n" , device_info -> constant_memory / 1024 );
188+ PRINTF (" Total amount of shared memory per block: %zu KiB\n" , device_info -> shared_memory / 1024 );
189+ PRINTF (" Total number of registers available per block: %d\n" , device_info -> register_count );
190+ PRINTF (" Multiprocessors: %d\n" , device_info -> multiprocessor_count );
191191 }
192192 return 0 ;
193193}
@@ -234,13 +234,13 @@ gpujpeg_init_device(int device_id, int flags)
234234 if ( flags & GPUJPEG_INIT_DEV_VERBOSE ) {
235235 int cuda_driver_version = 0 ;
236236 cudaDriverGetVersion (& cuda_driver_version );
237- printf ("CUDA driver version: %d.%d\n" , cuda_driver_version / 1000 , (cuda_driver_version % 100 ) / 10 );
237+ PRINTF ("CUDA driver version: %d.%d\n" , cuda_driver_version / 1000 , (cuda_driver_version % 100 ) / 10 );
238238
239239 int cuda_runtime_version = 0 ;
240240 cudaRuntimeGetVersion (& cuda_runtime_version );
241- printf ("CUDA runtime version: %d.%d\n" , cuda_runtime_version / 1000 , (cuda_runtime_version % 100 ) / 10 );
241+ PRINTF ("CUDA runtime version: %d.%d\n" , cuda_runtime_version / 1000 , (cuda_runtime_version % 100 ) / 10 );
242242
243- printf ("Using Device #%d: %s (c.c. %d.%d)\n" , device_id , devProp .name , devProp .major , devProp .minor );
243+ PRINTF ("Using Device #%d: %s (c.c. %d.%d)\n" , device_id , devProp .name , devProp .major , devProp .minor );
244244 }
245245
246246 cudaSetDevice (device_id );
@@ -407,17 +407,17 @@ gpujpeg_image_get_file_format(const char* filename)
407407 return GPUJPEG_IMAGE_FILE_UNKNOWN ;
408408 ext ++ ;
409409 if ( strcmp (ext , "help" ) == 0 ) {
410- printf ("Recognized extensions:\n" );
410+ PRINTF ("Recognized extensions:\n" );
411411 }
412412 for ( unsigned i = 0 ; i < sizeof extensions / sizeof extensions [0 ]; i ++ ) {
413413 if ( strcmp (ext , "help" ) == 0 ) {
414- printf ("\t- %s\n" , extensions [i ].ext );
414+ PRINTF ("\t- %s\n" , extensions [i ].ext );
415415 }
416416 if ( strcasecmp (ext , extensions [i ].ext ) == 0 ) {
417417 return extensions [i ].format ;
418418 }
419419 }
420- printf ("\nUse \"help.tst\" (eg. `gpujpegtool help.tst null.jpg`) for test image usage).\n" );
420+ PRINTF ("\nUse \"help.tst\" (eg. `gpujpegtool help.tst null.jpg`) for test image usage).\n" );
421421 return GPUJPEG_IMAGE_FILE_UNKNOWN ;
422422}
423423
@@ -460,12 +460,12 @@ gpujpeg_component_print8(struct gpujpeg_component* component, uint8_t* d_data)
460460 cudaMallocHost ((void * * )& data , data_size * sizeof (uint8_t ));
461461 cudaMemcpy (data , d_data , data_size * sizeof (uint8_t ), cudaMemcpyDeviceToHost );
462462
463- printf ("Print Data\n" );
463+ PRINTF ("Print Data\n" );
464464 for ( int y = 0 ; y < component -> data_height ; y ++ ) {
465465 for ( int x = 0 ; x < component -> data_width ; x ++ ) {
466- printf ("%3u " , data [y * component -> data_width + x ]);
466+ PRINTF ("%3u " , data [y * component -> data_width + x ]);
467467 }
468- printf ("\n" );
468+ PRINTF ("\n" );
469469 }
470470 cudaFreeHost (data );
471471}
@@ -479,12 +479,12 @@ gpujpeg_component_print16(struct gpujpeg_component* component, int16_t* d_data)
479479 cudaMallocHost ((void * * )& data , data_size * sizeof (int16_t ));
480480 cudaMemcpy (data , d_data , data_size * sizeof (int16_t ), cudaMemcpyDeviceToHost );
481481
482- printf ("Print Data\n" );
482+ PRINTF ("Print Data\n" );
483483 for ( int y = 0 ; y < component -> data_height ; y ++ ) {
484484 for ( int x = 0 ; x < component -> data_width ; x ++ ) {
485- printf ("%3d " , data [y * component -> data_width + x ]);
485+ PRINTF ("%3d " , data [y * component -> data_width + x ]);
486486 }
487- printf ("\n" );
487+ PRINTF ("\n" );
488488 }
489489 cudaFreeHost (data );
490490}
@@ -836,17 +836,17 @@ gpujpeg_coder_init_image(struct gpujpeg_coder * coder, const struct gpujpeg_para
836836 total_size += coder -> data_compressed_size ; // for Huffman coding output
837837 total_size += coder -> data_compressed_size ; // for Hiffman coding temp buffer
838838
839- printf ("\nAllocation Info:\n" );
840- printf (" Segment Count: %d\n" , coder -> segment_count );
841- printf (" Allocated Data Size: %dx%d\n" , coder -> data_width , coder -> data_height );
842- printf (" Raw Buffer Size: %0.1f MiB\n" , (double )coder -> data_raw_size / (1024.0 * 1024.0 ));
843- printf (" Preprocessor Buffer Size: %0.1f MiB\n" , (double )coder -> data_size / (1024.0 * 1024.0 ));
844- printf (" DCT Buffer Size: %0.1f MiB\n" , (double )2 * coder -> data_size / (1024.0 * 1024.0 ));
845- printf (" Compressed Buffer Size: %0.1f MiB\n" , (double )coder -> data_compressed_size / (1024.0 * 1024.0 ));
846- printf (" Huffman Temp buffer Size: %0.1f MiB\n" , (double )coder -> data_compressed_size / (1024.0 * 1024.0 ));
847- printf (" Structures Size: %0.1f KiB\n" , (double )structures_size / (1024.0 ));
848- printf (" Total GPU Memory Size: %0.1f MiB\n" , (double )total_size / (1024.0 * 1024.0 ));
849- printf ("\n" );
839+ PRINTF ("\nAllocation Info:\n" );
840+ PRINTF (" Segment Count: %d\n" , coder -> segment_count );
841+ PRINTF (" Allocated Data Size: %dx%d\n" , coder -> data_width , coder -> data_height );
842+ PRINTF (" Raw Buffer Size: %0.1f MiB\n" , (double )coder -> data_raw_size / (1024.0 * 1024.0 ));
843+ PRINTF (" Preprocessor Buffer Size: %0.1f MiB\n" , (double )coder -> data_size / (1024.0 * 1024.0 ));
844+ PRINTF (" DCT Buffer Size: %0.1f MiB\n" , (double )2 * coder -> data_size / (1024.0 * 1024.0 ));
845+ PRINTF (" Compressed Buffer Size: %0.1f MiB\n" , (double )coder -> data_compressed_size / (1024.0 * 1024.0 ));
846+ PRINTF (" Huffman Temp buffer Size: %0.1f MiB\n" , (double )coder -> data_compressed_size / (1024.0 * 1024.0 ));
847+ PRINTF (" Structures Size: %0.1f KiB\n" , (double )structures_size / (1024.0 ));
848+ PRINTF (" Total GPU Memory Size: %0.1f MiB\n" , (double )total_size / (1024.0 * 1024.0 ));
849+ PRINTF ("\n" );
850850 }
851851
852852 // Allocate data buffers for all color components
@@ -1360,9 +1360,9 @@ gpujpeg_image_range_info(const char* filename, int width, int height, enum gpujp
13601360 return ;
13611361 }
13621362
1363- printf ("Image Samples Range:\n" );
1363+ PRINTF ("Image Samples Range:\n" );
13641364 for ( int c = 0 ; c < 3 ; c ++ ) {
1365- printf ("Component %d: %d - %d\n" , c + 1 , c_min [c ], c_max [c ]);
1365+ PRINTF ("Component %d: %d - %d\n" , c + 1 , c_min [c ], c_max [c ]);
13661366 }
13671367
13681368 // Destroy image
@@ -1881,8 +1881,8 @@ GPUJPEG_API gpujpeg_sampling_factor_t
18811881gpujpeg_subsampling_from_name (const char * subsampling ) {
18821882 enum { UNKNOWN = 0 };
18831883 if ( strcmp (subsampling , "help" ) == 0 ) {
1884- printf ("Set subsampling in usual J:a:b[:alpha] format, eg. 4:2:2. Colons are optional.\n" );
1885- printf ("Non-standard subsamplings 4:4:2 and 4:2:1 are allowed.\n" );
1884+ PRINTF ("Set subsampling in usual J:a:b[:alpha] format, eg. 4:2:2. Colons are optional.\n" );
1885+ PRINTF ("Non-standard subsamplings 4:4:2 and 4:2:1 are allowed.\n" );
18861886 return UNKNOWN ;
18871887 }
18881888 int J = 0 ;
@@ -1972,7 +1972,7 @@ gpujpeg_pixel_format_by_name(const char *name)
19721972void
19731973gpujpeg_print_pixel_formats (void )
19741974{
1975- printf (" u8 (grayscale) 420-u8-p0p1p2 (planar 4:2:0)\n"
1975+ PRINTF (" u8 (grayscale) 420-u8-p0p1p2 (planar 4:2:0)\n"
19761976 " 422-u8-p1020 (eg. UYVY) 422-u8-p0p1p2 (planar 4:2:2)\n"
19771977 " 444-u8-p012 (eg. RGB) 444-u8-p0p1p2 (planar 4:4:4)\n"
19781978 " 4444-u8-p0123 (RGBA)\n" );
@@ -2000,7 +2000,7 @@ gpujpeg_color_space_by_name(const char* name)
20002000 return GPUJPEG_YCBCR_BT709 ;
20012001 }
20022002 if ( strcmp (name , "help" ) == 0 ) {
2003- printf ("Available color spaces:\n"
2003+ PRINTF ("Available color spaces:\n"
20042004 "- rgb\n"
20052005 "- yuv (deprecated)\n"
20062006 "- ycbcr - same as ycbcr-bt709\n"
@@ -2119,41 +2119,41 @@ coder_process_stats(struct gpujpeg_coder* coder)
21192119
21202120 if ( coder -> encoder ) {
21212121 if ( coder -> param .verbose >= GPUJPEG_LL_VERBOSE ) {
2122- printf (" -(Re)initialization:%10.4f ms\n" , duration_init_ms );
2123- printf (" -Copy To Device: %10.4f ms\n" , stats .duration_memory_to );
2122+ PRINTF (" -(Re)initialization:%10.4f ms\n" , duration_init_ms );
2123+ PRINTF (" -Copy To Device: %10.4f ms\n" , stats .duration_memory_to );
21242124 if ( stats .duration_memory_map != 0.0 && stats .duration_memory_unmap != 0.0 ) {
2125- printf (" -OpenGL Memory Map: %10.4f ms\n" , stats .duration_memory_map );
2126- printf (" -OpenGL Memory Unmap:%9.4f ms\n" , stats .duration_memory_unmap );
2125+ PRINTF (" -OpenGL Memory Map: %10.4f ms\n" , stats .duration_memory_map );
2126+ PRINTF (" -OpenGL Memory Unmap:%9.4f ms\n" , stats .duration_memory_unmap );
21272127 }
2128- printf (" -Preprocessing: %10.4f ms\n" , stats .duration_preprocessor );
2129- printf (" -DCT & Quantization:%10.4f ms\n" , stats .duration_dct_quantization );
2130- printf (" -Huffman Encoder: %10.4f ms\n" , stats .duration_huffman_coder );
2131- printf (" -Copy From Device: %10.4f ms\n" , stats .duration_memory_from );
2132- printf (" -Stream Formatter: %10.4f ms\n" , stats .duration_stream );
2128+ PRINTF (" -Preprocessing: %10.4f ms\n" , stats .duration_preprocessor );
2129+ PRINTF (" -DCT & Quantization:%10.4f ms\n" , stats .duration_dct_quantization );
2130+ PRINTF (" -Huffman Encoder: %10.4f ms\n" , stats .duration_huffman_coder );
2131+ PRINTF (" -Copy From Device: %10.4f ms\n" , stats .duration_memory_from );
2132+ PRINTF (" -Stream Formatter: %10.4f ms\n" , stats .duration_stream );
21332133 }
2134- printf ("Encode Image GPU: %10.4f ms (only in-GPU processing)\n" , stats .duration_in_gpu );
2135- printf ("Encode Image Bare: %10.4f ms (without copy to/from GPU memory)\n" ,
2134+ PRINTF ("Encode Image GPU: %10.4f ms (only in-GPU processing)\n" , stats .duration_in_gpu );
2135+ PRINTF ("Encode Image Bare: %10.4f ms (without copy to/from GPU memory)\n" ,
21362136 duration_ms - stats .duration_memory_to - stats .duration_memory_from );
2137- printf ("Encode Image: %10.4f ms\n" , duration_ms );
2137+ PRINTF ("Encode Image: %10.4f ms\n" , duration_ms );
21382138 }
21392139 else {
21402140 if ( coder -> param .verbose >= GPUJPEG_LL_VERBOSE ) {
2141- printf (" -(Re)initialization:%10.4f ms\n" , duration_init_ms );
2142- printf (" -Stream Reader: %10.4f ms\n" , stats .duration_stream );
2143- printf (" -Copy To Device: %10.4f ms\n" , stats .duration_memory_to );
2144- printf (" -Huffman Decoder: %10.4f ms\n" , stats .duration_huffman_coder );
2145- printf (" -DCT & Quantization:%10.4f ms\n" , stats .duration_dct_quantization );
2146- printf (" -Postprocessing: %10.4f ms\n" , stats .duration_preprocessor );
2147- printf (" -Copy From Device: %10.4f ms\n" , stats .duration_memory_from );
2141+ PRINTF (" -(Re)initialization:%10.4f ms\n" , duration_init_ms );
2142+ PRINTF (" -Stream Reader: %10.4f ms\n" , stats .duration_stream );
2143+ PRINTF (" -Copy To Device: %10.4f ms\n" , stats .duration_memory_to );
2144+ PRINTF (" -Huffman Decoder: %10.4f ms\n" , stats .duration_huffman_coder );
2145+ PRINTF (" -DCT & Quantization:%10.4f ms\n" , stats .duration_dct_quantization );
2146+ PRINTF (" -Postprocessing: %10.4f ms\n" , stats .duration_preprocessor );
2147+ PRINTF (" -Copy From Device: %10.4f ms\n" , stats .duration_memory_from );
21482148 if ( stats .duration_memory_map != 0.0 && stats .duration_memory_unmap != 0.0 ) {
2149- printf (" -OpenGL Memory Map: %10.4f ms\n" , stats .duration_memory_map );
2150- printf (" -OpenGL Memory Unmap:%9.4f ms\n" , stats .duration_memory_unmap );
2149+ PRINTF (" -OpenGL Memory Map: %10.4f ms\n" , stats .duration_memory_map );
2150+ PRINTF (" -OpenGL Memory Unmap:%9.4f ms\n" , stats .duration_memory_unmap );
21512151 }
21522152 }
2153- printf ("Decode Image GPU: %10.4f ms (only in-GPU processing)\n" , stats .duration_in_gpu );
2154- printf ("Decode Image Bare: %10.4f ms (without copy to/from GPU memory)\n" ,
2153+ PRINTF ("Decode Image GPU: %10.4f ms (only in-GPU processing)\n" , stats .duration_in_gpu );
2154+ PRINTF ("Decode Image Bare: %10.4f ms (without copy to/from GPU memory)\n" ,
21552155 duration_ms - stats .duration_memory_to - stats .duration_memory_from );
2156- printf ("Decode Image: %10.4f ms\n" , duration_ms );
2156+ PRINTF ("Decode Image: %10.4f ms\n" , duration_ms );
21572157 }
21582158}
21592159
@@ -2171,14 +2171,14 @@ coder_process_stats_overall(struct gpujpeg_coder* coder) {
21712171 if ( coder -> param .verbose <= GPUJPEG_LL_QUIET ) {
21722172 return ;
21732173 }
2174- printf ("\n" );
2175- printf ("Avg %s Duration: %10.4f ms\n" , coder -> encoder ? "Encode" : "Decode" ,
2174+ PRINTF ("\n" );
2175+ PRINTF ("Avg %s Duration: %10.4f ms\n" , coder -> encoder ? "Encode" : "Decode" ,
21762176 coder -> aggregate_duration / (double )coder -> frames );
21772177 if ( coder -> param .verbose >= GPUJPEG_LL_VERBOSE ) {
2178- printf ("Avg w/o 1st Iter: %10.4f ms\n" ,
2178+ PRINTF ("Avg w/o 1st Iter: %10.4f ms\n" ,
21792179 (coder -> aggregate_duration - coder -> first_frame_duration ) / ((double )coder -> frames - 1 ));
21802180 }
2181- printf ("\n" );
2181+ PRINTF ("\n" );
21822182}
21832183
21842184char *
0 commit comments