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 @@
#include <stdlib.h>
#include "av1/common/av1_fwd_txfm1d.h"
#if CONFIG_COEFFICIENT_RANGE_CHECKING
#define range_check(stage, input, buf, size, bit) \
{ \
int i, j; \
for (i = 0; i < size; ++i) { \
int buf_bit = get_max_bit(abs(buf[i])) + 1; \
if (buf_bit > 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); \
} \
} \
}
void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
int32_t size, int8_t bit);
#define range_check(stage, input, buf, size, bit) \
range_check_func(stage, input, buf, size, bit)
#else
#define range_check(stage, input, buf, size, bit) \
{ \
......
......@@ -12,24 +12,30 @@
#include <stdlib.h>
#include "av1/common/av1_inv_txfm1d.h"
#if CONFIG_COEFFICIENT_RANGE_CHECKING
#define range_check(stage, input, buf, size, bit) \
{ \
int i, j; \
for (i = 0; i < size; ++i) { \
int buf_bit = get_max_bit(abs(buf[i])) + 1; \
if (buf_bit > 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); \
} \
} \
void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
int32_t size, int8_t bit) {
const int32_t maxValue = (1 << (bit - 1)) - 1;
const int32_t minValue = -(1 << (bit - 1));
for (int i = 0; i < size; ++i) {
if (buf[i] < minValue || buf[i] > maxValue) {
int buf_bit = get_max_bit(abs(buf[i])) + 1;
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 (int j = 0; j < size; j++) {
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
#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