Skip to content

Commit 458c520

Browse files
committed
Use returned partition match count from search
1 parent 54eddab commit 458c520

3 files changed

Lines changed: 15 additions & 29 deletions

File tree

Source/astcenc_block_sizes.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,6 @@ static void construct_block_size_descriptor_3d(
11581158
}
11591159
}
11601160

1161-
// TODO: Probably need to do the 1/2 split for 3d modes too ...
11621161
bsd.block_mode_count_1plane_always = 0; // Skipped for 3D modes
11631162
bsd.block_mode_count_1plane_selected = bm_counts[0];
11641163
bsd.block_mode_count_1plane_2plane_selected = bm_counts[0] + bm_counts[1];

Source/astcenc_compress_symbolic.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,6 @@ static float compress_symbolic_block_for_partition_2planes(
756756
uint8_t *dec_weights_quant_pvalue = tmpbuf.dec_weights_quant_pvalue;
757757

758758
// For each decimation mode, compute an ideal set of weights with no quantization
759-
// TODO: Try to split this list into separate 1 and 2 plane lists?
760759
for (unsigned int i = 0; i < bsd.decimation_mode_count_selected; i++)
761760
{
762761
const auto& dm = bsd.get_decimation_mode(i);

Source/astcenc_find_best_partitioning.cpp

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,10 @@ static void count_partition_mismatch_bits(
394394
* @param partitioning_count The number of packed partitionings.
395395
* @param mismatch_count Partitioning mismatch counts, in index order.
396396
* @param[out] partition_ordering Partition index values, in mismatch order.
397+
*
398+
* @return The number of active partitions in this selection.
397399
*/
398-
static void get_partition_ordering_by_mismatch_bits(
400+
static unsigned int get_partition_ordering_by_mismatch_bits(
399401
unsigned int partitioning_count,
400402
const unsigned int mismatch_count[BLOCK_MAX_PARTITIONINGS],
401403
unsigned int partition_ordering[BLOCK_MAX_PARTITIONINGS]
@@ -408,6 +410,8 @@ static void get_partition_ordering_by_mismatch_bits(
408410
mscount[mismatch_count[i]]++;
409411
}
410412

413+
unsigned int active_count = partitioning_count - mscount[255];
414+
411415
// Create a running sum from the histogram array
412416
// Cells store previous values only; i.e. exclude self after sum
413417
unsigned int summa = 0;
@@ -425,6 +429,8 @@ static void get_partition_ordering_by_mismatch_bits(
425429
unsigned int idx = mscount[mismatch_count[i]]++;
426430
partition_ordering[idx] = i;
427431
}
432+
433+
return active_count;
428434
}
429435

430436
/**
@@ -434,8 +440,10 @@ static void get_partition_ordering_by_mismatch_bits(
434440
* @param blk The image block color data to compress.
435441
* @param partition_count The desired number of partitions in the block.
436442
* @param[out] partition_ordering The list of recommended partition indices, in priority order.
443+
*
444+
* @return The number of active partitionings in this selection.
437445
*/
438-
static void compute_kmeans_partition_ordering(
446+
static unsigned int compute_kmeans_partition_ordering(
439447
const block_size_descriptor& bsd,
440448
const image_block& blk,
441449
unsigned int partition_count,
@@ -474,8 +482,9 @@ static void compute_kmeans_partition_ordering(
474482
count_partition_mismatch_bits(bsd, partition_count, bitmaps, mismatch_counts);
475483

476484
// Sort the partitions based on the number of mismatched bits
477-
get_partition_ordering_by_mismatch_bits(bsd.partitioning_count_selected[partition_count - 1],
478-
mismatch_counts, partition_ordering);
485+
return get_partition_ordering_by_mismatch_bits(
486+
bsd.partitioning_count_selected[partition_count - 1],
487+
mismatch_counts, partition_ordering);
479488
}
480489

481490
/* See header for documentation. */
@@ -509,9 +518,8 @@ void find_best_partition_candidates(
509518
weight_imprecision_estim = weight_imprecision_estim * weight_imprecision_estim;
510519

511520
unsigned int partition_sequence[BLOCK_MAX_PARTITIONINGS];
512-
compute_kmeans_partition_ordering(bsd, blk, partition_count, partition_sequence);
513-
partition_search_limit = astc::min(partition_search_limit,
514-
bsd.partitioning_count_selected[partition_count - 1]);
521+
unsigned int sequence_len = compute_kmeans_partition_ordering(bsd, blk, partition_count, partition_sequence);
522+
partition_search_limit = astc::min(partition_search_limit, sequence_len);
515523

516524
bool uses_alpha = !blk.is_constant_channel(3);
517525

@@ -531,16 +539,6 @@ void find_best_partition_candidates(
531539
unsigned int partition = partition_sequence[i];
532540
const auto& pi = bsd.get_raw_partition_info(partition_count, partition);
533541

534-
// TODO: This escape shouldn't really be needed. We should return
535-
// the number of blocks which have usable (!= 255) mismatch count
536-
// from compute_kmeans_partition_ordering and use that as the upper
537-
// loop limit.
538-
unsigned int bk_partition_count = pi.partition_count;
539-
if (bk_partition_count < partition_count)
540-
{
541-
break;
542-
}
543-
544542
// Compute weighting to give to each component in each partition
545543
partition_metrics pms[BLOCK_MAX_PARTITIONS];
546544

@@ -634,16 +632,6 @@ void find_best_partition_candidates(
634632
unsigned int partition = partition_sequence[i];
635633
const auto& pi = bsd.get_raw_partition_info(partition_count, partition);
636634

637-
// TODO: This escape shouldn't really be needed. We should return
638-
// the number of blocks which have usable (!= 255) mismatch count
639-
// from compute_kmeans_partition_ordering and use that as the upper
640-
// loop limit.
641-
unsigned int bk_partition_count = pi.partition_count;
642-
if (bk_partition_count < partition_count)
643-
{
644-
break;
645-
}
646-
647635
// Compute weighting to give to each component in each partition
648636
partition_metrics pms[BLOCK_MAX_PARTITIONS];
649637
compute_avgs_and_dirs_3_comp_rgb(pi, blk, pms);

0 commit comments

Comments
 (0)