@@ -38,29 +38,12 @@ static constexpr uint32_t ASTCENC_BYTES_PER_BLOCK = 16;
3838
3939template <typename T> T sqr (T v) { return v * v; }
4040
41+ extern " C" void progress_emitter (float value);
42+
4143extern " C" void rdo_progress_emitter (
4244 float value
4345) {
4446 static float previous_value = 100 .0f ;
45- const uint32_t bar_size = 25 ;
46- auto parts = static_cast <uint32_t >(value / 4 .0f );
47-
48- char buffer[bar_size + 3 ];
49- buffer[0 ] = ' [' ;
50-
51- for (uint32_t i = 0 ; i < parts; i++)
52- {
53- buffer[i + 1 ] = ' =' ;
54- }
55-
56- for (uint32_t i = parts; i < bar_size; i++)
57- {
58- buffer[i + 1 ] = ' ' ;
59- }
60-
61- buffer[bar_size + 1 ] = ' ]' ;
62- buffer[bar_size + 2 ] = ' \0 ' ;
63-
6447 if (previous_value == 100 .0f )
6548 {
6649 printf (" \n\n " );
@@ -69,8 +52,7 @@ extern "C" void rdo_progress_emitter(
6952 }
7053 previous_value = value;
7154
72- printf (" Progress: %s %03.1f%%\r " , buffer, static_cast <double >(value));
73- fflush (stdout);
55+ progress_emitter (value);
7456}
7557
7658static uint32_t init_rdo_context (
@@ -419,15 +401,11 @@ void rate_distortion_optimize(
419401 uint32_t zblocks = (image.dim_z + ctx.bsd ->zdim - 1u ) / ctx.bsd ->zdim ;
420402 uint32_t total_blocks = xblocks * yblocks * zblocks;
421403
422- uint32_t blocks_per_task = total_blocks;
423- if (!ctx.config .rdo_no_multithreading )
424- {
425- blocks_per_task = astc::min (ctx.config .rdo_lookback , total_blocks);
426- // There is no way to losslessly partition the job (sequentially dependent on previous output)
427- // So we reserve only one task for each thread to minimize the quality impact.
428- uint32_t partitions = ctx.config .rdo_partitions ? ctx.config .rdo_partitions : ctx.thread_count ;
429- blocks_per_task = astc::max (blocks_per_task, (total_blocks - 1 ) / partitions + 1 );
430- }
404+ uint32_t blocks_per_task = astc::min (ctx.config .rdo_lookback , total_blocks);
405+ // There is no way to losslessly partition the job (sequentially dependent on previous output)
406+ // So we reserve up to one task for each thread to minimize the quality impact.
407+ uint32_t partitions = ctx.config .rdo_partitions ? ctx.config .rdo_partitions : ctx.thread_count ;
408+ blocks_per_task = astc::max (blocks_per_task, (total_blocks - 1 ) / partitions + 1 );
431409
432410 uint32_t total_modified = 0 ;
433411 while (true )
0 commit comments