Commit 1a02439f authored by Sebastien Alaiwan's avatar Sebastien Alaiwan Committed by sebastien alaiwan
Browse files

Huge speedup for range checking.

De-duplicate implementations of 'range_check', and use precomputed pixel value
boundaries instead of computing the log2 of each pixel value.
Overall speedup: encoding with enabled-range checks goes 3.3 times
faster.

Change-Id: I2f7c97cac4ad479b07898fb69c0131e3c7e0bf98
parent 18c53c81
...@@ -12,24 +12,12 @@ ...@@ -12,24 +12,12 @@
#include <stdlib.h> #include <stdlib.h>
#include "av1/common/av1_fwd_txfm1d.h" #include "av1/common/av1_fwd_txfm1d.h"
#if CONFIG_COEFFICIENT_RANGE_CHECKING #if CONFIG_COEFFICIENT_RANGE_CHECKING
#define range_check(stage, input, buf, size, bit) \
{ \ void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
int i, j; \ int32_t size, int8_t bit);
for (i = 0; i < size; ++i) { \
int buf_bit = get_max_bit(abs(buf[i])) + 1; \ #define range_check(stage, input, buf, size, bit) \
if (buf_bit > bit) { \ range_check_func(stage, input, buf, size, bit)
printf("======== %s %d overflow ========\n", __FILE__, __LINE__); \
printf("stage: %d node: %d\n", stage, i); \
printf("bit: %d buf_bit: %d buf[i]: %d\n", bit, buf_bit, buf[i]); \
printf("input:\n"); \
for (j = 0; j < size; j++) { \
printf("%d,", input[j]); \
} \
printf("\n"); \
assert(0); \
} \
} \
}
#else #else
#define range_check(stage, input, buf, size, bit) \ #define range_check(stage, input, buf, size, bit) \
{ \ { \
......
...@@ -12,24 +12,30 @@ ...@@ -12,24 +12,30 @@
#include <stdlib.h> #include <stdlib.h>
#include "av1/common/av1_inv_txfm1d.h" #include "av1/common/av1_inv_txfm1d.h"
#if CONFIG_COEFFICIENT_RANGE_CHECKING #if CONFIG_COEFFICIENT_RANGE_CHECKING
#define range_check(stage, input, buf, size, bit) \
{ \ void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
int i, j; \ int32_t size, int8_t bit) {
for (i = 0; i < size; ++i) { \ const int32_t maxValue = (1 << (bit - 1)) - 1;
int buf_bit = get_max_bit(abs(buf[i])) + 1; \ const int32_t minValue = -(1 << (bit - 1));
if (buf_bit > bit) { \
printf("======== %s %d overflow ========\n", __FILE__, __LINE__); \ for (int i = 0; i < size; ++i) {
printf("stage: %d node: %d\n", stage, i); \ if (buf[i] < minValue || buf[i] > maxValue) {
printf("bit: %d buf_bit: %d buf[i]: %d\n", bit, buf_bit, buf[i]); \ int buf_bit = get_max_bit(abs(buf[i])) + 1;
printf("input:\n"); \ printf("======== %s %d overflow ========\n", __FILE__, __LINE__);
for (j = 0; j < size; j++) { \ printf("stage: %d node: %d\n", stage, i);
printf("%d,", input[j]); \ printf("bit: %d buf_bit: %d buf[i]: %d\n", bit, buf_bit, buf[i]);
} \ printf("input:\n");
printf("\n"); \ for (int j = 0; j < size; j++) {
assert(0); \ printf("%d,", input[j]);
} \ }
} \ printf("\n");
assert(0);
}
} }
}
#define range_check(stage, input, buf, size, bit) \
range_check_func(stage, input, buf, size, bit)
#else #else
#define range_check(stage, input, buf, size, bit) \ #define range_check(stage, input, buf, size, bit) \
{ \ { \
......
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