Commit 231cba45 authored by Angie Chiang's avatar Angie Chiang

Allow one-sided scan count down sampling

Change-Id: I164add43e9d75af82312b464a176cdf0045ef9e1
parent 1a4bae1f
......@@ -6620,18 +6620,47 @@ void av1_down_sample_scan_count(uint32_t *non_zero_count_ds,
TX_SIZE tx_size) {
const int tx_w = tx_size_wide[tx_size];
const int tx_h = tx_size_high[tx_size];
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
non_zero_count_ds[ci_ds] = non_zero_count[ci] + non_zero_count[ci + 1] +
non_zero_count[ci + tx_w] +
non_zero_count[ci + 1 + tx_w];
if (tx_w > 8 && tx_h > 8) {
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
non_zero_count_ds[ci_ds] = non_zero_count[ci] + non_zero_count[ci + 1] +
non_zero_count[ci + tx_w] +
non_zero_count[ci + 1 + tx_w];
}
}
} else if (tx_w > 8 && tx_h <= 8) {
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
non_zero_count_ds[ci_ds] = non_zero_count[ci] + non_zero_count[ci + 1];
}
}
} else if (tx_w <= 8 && tx_h > 8) {
const int tx_w_ds = tx_w;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds;
const int ci = r * tx_w + c;
non_zero_count_ds[ci_ds] =
non_zero_count[ci] + non_zero_count[ci + tx_w];
}
}
} else {
assert(0);
}
}
......@@ -6640,21 +6669,55 @@ void av1_up_sample_scan_count(uint32_t *non_zero_count,
TX_SIZE tx_size, unsigned int block_num) {
const int tx_w = tx_size_wide[tx_size];
const int tx_h = tx_size_high[tx_size];
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
uint32_t count = ROUND_POWER_OF_TWO(non_zero_count_ds[ci_ds], 2);
clamp64(count, 0, block_num);
non_zero_count[ci] = count;
non_zero_count[ci + 1] = count;
non_zero_count[ci + tx_w] = count;
non_zero_count[ci + tx_w + 1] = count;
if (tx_w > 8 && tx_h > 8) {
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
uint32_t count = ROUND_POWER_OF_TWO(non_zero_count_ds[ci_ds], 2);
count = clamp64(count, 0, block_num);
non_zero_count[ci] = count;
non_zero_count[ci + 1] = count;
non_zero_count[ci + tx_w] = count;
non_zero_count[ci + tx_w + 1] = count;
}
}
} else if (tx_w > 8 && tx_h <= 8) {
const int tx_w_ds = tx_w >> 1;
const int tx_h_ds = tx_h;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds;
const int c = c_ds << 1;
const int ci = r * tx_w + c;
uint32_t count = ROUND_POWER_OF_TWO(non_zero_count_ds[ci_ds], 1);
count = clamp64(count, 0, block_num);
non_zero_count[ci] = count;
non_zero_count[ci + 1] = count;
}
}
} else if (tx_w <= 8 && tx_h > 8) {
const int tx_w_ds = tx_w;
const int tx_h_ds = tx_h >> 1;
for (int r_ds = 0; r_ds < tx_h_ds; ++r_ds) {
for (int c_ds = 0; c_ds < tx_w_ds; ++c_ds) {
const int ci_ds = r_ds * tx_w_ds + c_ds;
const int r = r_ds << 1;
const int c = c_ds;
const int ci = r * tx_w + c;
uint32_t count = ROUND_POWER_OF_TWO(non_zero_count_ds[ci_ds], 1);
count = clamp64(count, 0, block_num);
non_zero_count[ci] = count;
non_zero_count[ci + tx_w] = count;
}
}
} else {
assert(0);
}
}
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment