Commit 12d3c0fff1 for aom
commit 12d3c0fff1759ac2a85bed6cd322a2bca011785c
Author: Ranjit Kumar Tulabandu <ranjit.tulabandu@ittiam.com>
Date: Mon Apr 13 16:29:44 2026 +0530
Fix the calculation of palette_pixels
In parent version, palette_pixels tracked the pixels for
which palette mode was chosen. However this tracking was
incorrect as the same was done before mode was finalized.
In this CL, the tracking is done only for final encode in
encode_superblock(). As palette_pixels is used only for
screen content decision, the performance impact is seen
to be marginal and is seen to affect few contents only.
STATS_CHANGED
Change-Id: I21df10c4a6a6a159322b3db9db419bf44052fc84
diff --git a/av1/encoder/palette.c b/av1/encoder/palette.c
index 14c8970933..cab15e86a4 100644
--- a/av1/encoder/palette.c
+++ b/av1/encoder/palette.c
@@ -756,9 +756,6 @@ void av1_rd_pick_palette_intra_sby(
if (best_mbmi->palette_mode_info.palette_size[0] > 0) {
memcpy(color_map, best_palette_color_map,
block_width * block_height * sizeof(best_palette_color_map[0]));
- // Gather the stats to determine whether to use screen content tools in
- // function av1_determine_sc_tools_with_encoding().
- x->palette_pixels += (block_width * block_height);
}
*mbmi = *best_mbmi;
}
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index c3b667dbdf..19d42b9e1c 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -431,6 +431,11 @@ static void encode_superblock(const AV1_COMP *const cpi, TileDataEnc *tile_data,
xd->cfl.store_y = 0;
if (av1_allow_palette(cm->features.allow_screen_content_tools, bsize)) {
+ // Gather the stats to determine whether to use screen content tools in
+ // function av1_determine_sc_tools_with_encoding().
+ if (mbmi->palette_mode_info.palette_size[0] > 0 &&
+ dry_run == OUTPUT_ENABLED)
+ x->palette_pixels += (block_size_wide[bsize] * block_size_high[bsize]);
for (int plane = 0; plane < AOMMIN(2, num_planes); ++plane) {
if (mbmi->palette_mode_info.palette_size[plane] > 0) {
if (!dry_run) {