Merge changes Ie43dc5ef,I94cd8bab into main

* changes:
  Do*Filter_*: remove row & num_rows parameters
  Do*Filter_C: remove dead 'inverse' code paths
This commit is contained in:
James Zern 2024-08-19 18:51:06 +00:00 committed by Gerrit Code Review
commit 233e86b91f
4 changed files with 122 additions and 254 deletions

View File

@ -26,19 +26,13 @@
assert(width > 0); \ assert(width > 0); \
assert(height > 0); \ assert(height > 0); \
assert(stride >= width); \ assert(stride >= width); \
assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
(void)height; /* Silence unused warning. */ \
} while (0) } while (0)
#if !WEBP_NEON_OMIT_C_CODE #if !WEBP_NEON_OMIT_C_CODE
static WEBP_INLINE void PredictLine_C(const uint8_t* src, const uint8_t* pred, static WEBP_INLINE void PredictLine_C(const uint8_t* src, const uint8_t* pred,
uint8_t* dst, int length, int inverse) { uint8_t* dst, int length) {
int i; int i;
if (inverse) { for (i = 0; i < length; ++i) dst[i] = (uint8_t)(src[i] - pred[i]);
for (i = 0; i < length; ++i) dst[i] = (uint8_t)(src[i] + pred[i]);
} else {
for (i = 0; i < length; ++i) dst[i] = (uint8_t)(src[i] - pred[i]);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -46,32 +40,23 @@ static WEBP_INLINE void PredictLine_C(const uint8_t* src, const uint8_t* pred,
static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in, static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows, uint8_t* out) {
int inverse, uint8_t* out) { const uint8_t* preds = in;
const uint8_t* preds; int row;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = inverse ? out : in;
if (row == 0) { // Leftmost pixel is the same as input for topmost scanline.
// Leftmost pixel is the same as input for topmost scanline. out[0] = in[0];
out[0] = in[0]; PredictLine_C(in + 1, preds, out + 1, width - 1);
PredictLine_C(in + 1, preds, out + 1, width - 1, inverse); preds += stride;
row = 1; in += stride;
preds += stride; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
// Leftmost pixel is predicted from above. // Leftmost pixel is predicted from above.
PredictLine_C(in, preds - stride, out, 1, inverse); PredictLine_C(in, preds - stride, out, 1);
PredictLine_C(in + 1, preds, out + 1, width - 1, inverse); PredictLine_C(in + 1, preds, out + 1, width - 1);
++row;
preds += stride; preds += stride;
in += stride; in += stride;
out += stride; out += stride;
@ -83,33 +68,21 @@ static WEBP_INLINE void DoHorizontalFilter_C(const uint8_t* in,
static WEBP_INLINE void DoVerticalFilter_C(const uint8_t* in, static WEBP_INLINE void DoVerticalFilter_C(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows, uint8_t* out) {
int inverse, uint8_t* out) { const uint8_t* preds = in;
const uint8_t* preds; int row;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = inverse ? out : in;
if (row == 0) { // Very first top-left pixel is copied.
// Very first top-left pixel is copied. out[0] = in[0];
out[0] = in[0]; // Rest of top scan-line is left-predicted.
// Rest of top scan-line is left-predicted. PredictLine_C(in + 1, preds, out + 1, width - 1);
PredictLine_C(in + 1, preds, out + 1, width - 1, inverse); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
} else {
// We are starting from in-between. Make sure 'preds' points to prev row.
preds -= stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
PredictLine_C(in, preds, out, width, inverse); PredictLine_C(in, preds, out, width);
++row;
preds += stride; preds += stride;
in += stride; in += stride;
out += stride; out += stride;
@ -128,38 +101,29 @@ static WEBP_INLINE int GradientPredictor_C(uint8_t a, uint8_t b, uint8_t c) {
#if !WEBP_NEON_OMIT_C_CODE #if !WEBP_NEON_OMIT_C_CODE
static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in, static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows, uint8_t* out) {
int inverse, uint8_t* out) { const uint8_t* preds = in;
const uint8_t* preds; int row;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = inverse ? out : in;
// left prediction for top scan-line // left prediction for top scan-line
if (row == 0) { out[0] = in[0];
out[0] = in[0]; PredictLine_C(in + 1, preds, out + 1, width - 1);
PredictLine_C(in + 1, preds, out + 1, width - 1, inverse); preds += stride;
row = 1; in += stride;
preds += stride; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
int w; int w;
// leftmost pixel: predict from above. // leftmost pixel: predict from above.
PredictLine_C(in, preds - stride, out, 1, inverse); PredictLine_C(in, preds - stride, out, 1);
for (w = 1; w < width; ++w) { for (w = 1; w < width; ++w) {
const int pred = GradientPredictor_C(preds[w - 1], const int pred = GradientPredictor_C(preds[w - 1],
preds[w - stride], preds[w - stride],
preds[w - stride - 1]); preds[w - stride - 1]);
out[w] = (uint8_t)(in[w] + (inverse ? pred : -pred)); out[w] = (uint8_t)(in[w] - pred);
} }
++row;
preds += stride; preds += stride;
in += stride; in += stride;
out += stride; out += stride;
@ -174,18 +138,17 @@ static WEBP_INLINE void DoGradientFilter_C(const uint8_t* in,
#if !WEBP_NEON_OMIT_C_CODE #if !WEBP_NEON_OMIT_C_CODE
static void HorizontalFilter_C(const uint8_t* data, int width, int height, static void HorizontalFilter_C(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoHorizontalFilter_C(data, width, height, stride, 0, height, 0, DoHorizontalFilter_C(data, width, height, stride, filtered_data);
filtered_data);
} }
static void VerticalFilter_C(const uint8_t* data, int width, int height, static void VerticalFilter_C(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoVerticalFilter_C(data, width, height, stride, 0, height, 0, filtered_data); DoVerticalFilter_C(data, width, height, stride, filtered_data);
} }
static void GradientFilter_C(const uint8_t* data, int width, int height, static void GradientFilter_C(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoGradientFilter_C(data, width, height, stride, 0, height, 0, filtered_data); DoGradientFilter_C(data, width, height, stride, filtered_data);
} }
#endif // !WEBP_NEON_OMIT_C_CODE #endif // !WEBP_NEON_OMIT_C_CODE

View File

@ -31,8 +31,6 @@
assert(width > 0); \ assert(width > 0); \
assert(height > 0); \ assert(height > 0); \
assert(stride >= width); \ assert(stride >= width); \
assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
(void)height; /* Silence unused warning. */ \
} while (0) } while (0)
#define DO_PREDICT_LINE(SRC, DST, LENGTH, INVERSE) do { \ #define DO_PREDICT_LINE(SRC, DST, LENGTH, INVERSE) do { \
@ -184,10 +182,9 @@ static WEBP_INLINE void PredictLine_MIPSdspR2(const uint8_t* src, uint8_t* dst,
// Horizontal filter. // Horizontal filter.
#define FILTER_LINE_BY_LINE do { \ #define FILTER_LINE_BY_LINE do { \
while (row < last_row) { \ for (row = 1; row < height; ++row) { \
PREDICT_LINE_ONE_PASS(in, preds - stride, out); \ PREDICT_LINE_ONE_PASS(in, preds - stride, out); \
DO_PREDICT_LINE(in + 1, out + 1, width - 1, 0); \ DO_PREDICT_LINE(in + 1, out + 1, width - 1, 0); \
++row; \
preds += stride; \ preds += stride; \
in += stride; \ in += stride; \
out += stride; \ out += stride; \
@ -196,26 +193,17 @@ static WEBP_INLINE void PredictLine_MIPSdspR2(const uint8_t* src, uint8_t* dst,
static WEBP_INLINE void DoHorizontalFilter_MIPSdspR2(const uint8_t* in, static WEBP_INLINE void DoHorizontalFilter_MIPSdspR2(const uint8_t* in,
int width, int height, int width, int height,
int stride, int stride, uint8_t* out) {
int row, int num_rows, const uint8_t* preds = in;
uint8_t* out) { int row;
const uint8_t* preds;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = in;
if (row == 0) { // Leftmost pixel is the same as input for topmost scanline.
// Leftmost pixel is the same as input for topmost scanline. out[0] = in[0];
out[0] = in[0]; PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
PredictLine_MIPSdspR2(in + 1, out + 1, width - 1); preds += stride;
row = 1; in += stride;
preds += stride; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
FILTER_LINE_BY_LINE; FILTER_LINE_BY_LINE;
@ -225,17 +213,15 @@ static WEBP_INLINE void DoHorizontalFilter_MIPSdspR2(const uint8_t* in,
static void HorizontalFilter_MIPSdspR2(const uint8_t* data, static void HorizontalFilter_MIPSdspR2(const uint8_t* data,
int width, int height, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoHorizontalFilter_MIPSdspR2(data, width, height, stride, 0, height, DoHorizontalFilter_MIPSdspR2(data, width, height, stride, filtered_data);
filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Vertical filter. // Vertical filter.
#define FILTER_LINE_BY_LINE do { \ #define FILTER_LINE_BY_LINE do { \
while (row < last_row) { \ for (row = 1; row < height; ++row) { \
DO_PREDICT_LINE_VERTICAL(in, preds, out, width, 0); \ DO_PREDICT_LINE_VERTICAL(in, preds, out, width, 0); \
++row; \
preds += stride; \ preds += stride; \
in += stride; \ in += stride; \
out += stride; \ out += stride; \
@ -244,29 +230,17 @@ static void HorizontalFilter_MIPSdspR2(const uint8_t* data,
static WEBP_INLINE void DoVerticalFilter_MIPSdspR2(const uint8_t* in, static WEBP_INLINE void DoVerticalFilter_MIPSdspR2(const uint8_t* in,
int width, int height, int width, int height,
int stride, int stride, uint8_t* out) {
int row, int num_rows, const uint8_t* preds = in;
uint8_t* out) { int row;
const uint8_t* preds;
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = in;
if (row == 0) { // Very first top-left pixel is copied.
// Very first top-left pixel is copied. out[0] = in[0];
out[0] = in[0]; // Rest of top scan-line is left-predicted.
// Rest of top scan-line is left-predicted. PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
PredictLine_MIPSdspR2(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
} else {
// We are starting from in-between. Make sure 'preds' points to prev row.
preds -= stride;
}
// Filter line-by-line. // Filter line-by-line.
FILTER_LINE_BY_LINE; FILTER_LINE_BY_LINE;
@ -275,8 +249,7 @@ static WEBP_INLINE void DoVerticalFilter_MIPSdspR2(const uint8_t* in,
static void VerticalFilter_MIPSdspR2(const uint8_t* data, int width, int height, static void VerticalFilter_MIPSdspR2(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoVerticalFilter_MIPSdspR2(data, width, height, stride, 0, height, DoVerticalFilter_MIPSdspR2(data, width, height, stride, filtered_data);
filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -297,7 +270,7 @@ static int GradientPredictor_MIPSdspR2(uint8_t a, uint8_t b, uint8_t c) {
} }
#define FILTER_LINE_BY_LINE(PREDS, OPERATION) do { \ #define FILTER_LINE_BY_LINE(PREDS, OPERATION) do { \
while (row < last_row) { \ for (row = 1; row < height; ++row) { \
int w; \ int w; \
PREDICT_LINE_ONE_PASS(in, PREDS - stride, out); \ PREDICT_LINE_ONE_PASS(in, PREDS - stride, out); \
for (w = 1; w < width; ++w) { \ for (w = 1; w < width; ++w) { \
@ -306,7 +279,6 @@ static int GradientPredictor_MIPSdspR2(uint8_t a, uint8_t b, uint8_t c) {
PREDS[w - stride - 1]); \ PREDS[w - stride - 1]); \
out[w] = in[w] OPERATION pred; \ out[w] = in[w] OPERATION pred; \
} \ } \
++row; \
in += stride; \ in += stride; \
out += stride; \ out += stride; \
} \ } \
@ -314,24 +286,17 @@ static int GradientPredictor_MIPSdspR2(uint8_t a, uint8_t b, uint8_t c) {
static void DoGradientFilter_MIPSdspR2(const uint8_t* in, static void DoGradientFilter_MIPSdspR2(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows, uint8_t* out) { uint8_t* out) {
const uint8_t* preds; const uint8_t* preds = in;
const size_t start_offset = row * stride; int row;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
preds = in;
// left prediction for top scan-line // left prediction for top scan-line
if (row == 0) { out[0] = in[0];
out[0] = in[0]; PredictLine_MIPSdspR2(in + 1, out + 1, width - 1);
PredictLine_MIPSdspR2(in + 1, out + 1, width - 1); preds += stride;
row = 1; in += stride;
preds += stride; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
FILTER_LINE_BY_LINE(in, -); FILTER_LINE_BY_LINE(in, -);
@ -340,8 +305,7 @@ static void DoGradientFilter_MIPSdspR2(const uint8_t* in,
static void GradientFilter_MIPSdspR2(const uint8_t* data, int width, int height, static void GradientFilter_MIPSdspR2(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoGradientFilter_MIPSdspR2(data, width, height, stride, 0, height, DoGradientFilter_MIPSdspR2(data, width, height, stride, filtered_data);
filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -28,8 +28,6 @@
assert(width > 0); \ assert(width > 0); \
assert(height > 0); \ assert(height > 0); \
assert(stride >= width); \ assert(stride >= width); \
assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
(void)height; /* Silence unused warning. */ \
} while (0) } while (0)
// load eight u8 and widen to s16 // load eight u8 and widen to s16
@ -68,30 +66,21 @@ static void PredictLineLeft_NEON(const uint8_t* src, uint8_t* dst, int length) {
static WEBP_INLINE void DoHorizontalFilter_NEON(const uint8_t* in, static WEBP_INLINE void DoHorizontalFilter_NEON(const uint8_t* in,
int width, int height, int width, int height,
int stride, int stride, uint8_t* out) {
int row, int num_rows, int row;
uint8_t* out) {
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
if (row == 0) { // Leftmost pixel is the same as input for topmost scanline.
// Leftmost pixel is the same as input for topmost scanline. out[0] = in[0];
out[0] = in[0]; PredictLineLeft_NEON(in + 1, out + 1, width - 1);
PredictLineLeft_NEON(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
// Leftmost pixel is predicted from above. // Leftmost pixel is predicted from above.
out[0] = in[0] - in[-stride]; out[0] = in[0] - in[-stride];
PredictLineLeft_NEON(in + 1, out + 1, width - 1); PredictLineLeft_NEON(in + 1, out + 1, width - 1);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -99,8 +88,7 @@ static WEBP_INLINE void DoHorizontalFilter_NEON(const uint8_t* in,
static void HorizontalFilter_NEON(const uint8_t* data, int width, int height, static void HorizontalFilter_NEON(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoHorizontalFilter_NEON(data, width, height, stride, 0, height, DoHorizontalFilter_NEON(data, width, height, stride, filtered_data);
filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -108,28 +96,20 @@ static void HorizontalFilter_NEON(const uint8_t* data, int width, int height,
static WEBP_INLINE void DoVerticalFilter_NEON(const uint8_t* in, static WEBP_INLINE void DoVerticalFilter_NEON(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows,
uint8_t* out) { uint8_t* out) {
const size_t start_offset = row * stride; int row;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
if (row == 0) { // Very first top-left pixel is copied.
// Very first top-left pixel is copied. out[0] = in[0];
out[0] = in[0]; // Rest of top scan-line is left-predicted.
// Rest of top scan-line is left-predicted. PredictLineLeft_NEON(in + 1, out + 1, width - 1);
PredictLineLeft_NEON(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
PredictLine_NEON(in, in - stride, out, width); PredictLine_NEON(in, in - stride, out, width);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -137,8 +117,7 @@ static WEBP_INLINE void DoVerticalFilter_NEON(const uint8_t* in,
static void VerticalFilter_NEON(const uint8_t* data, int width, int height, static void VerticalFilter_NEON(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoVerticalFilter_NEON(data, width, height, stride, 0, height, DoVerticalFilter_NEON(data, width, height, stride, filtered_data);
filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -168,30 +147,21 @@ static void GradientPredictDirect_NEON(const uint8_t* const row,
} }
static WEBP_INLINE void DoGradientFilter_NEON(const uint8_t* in, static WEBP_INLINE void DoGradientFilter_NEON(const uint8_t* in,
int width, int height, int width, int height, int stride,
int stride,
int row, int num_rows,
uint8_t* out) { uint8_t* out) {
const size_t start_offset = row * stride; int row;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
// left prediction for top scan-line // left prediction for top scan-line
if (row == 0) { out[0] = in[0];
out[0] = in[0]; PredictLineLeft_NEON(in + 1, out + 1, width - 1);
PredictLineLeft_NEON(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
out[0] = in[0] - in[-stride]; out[0] = in[0] - in[-stride];
GradientPredictDirect_NEON(in + 1, in + 1 - stride, out + 1, width - 1); GradientPredictDirect_NEON(in + 1, in + 1 - stride, out + 1, width - 1);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -199,8 +169,7 @@ static WEBP_INLINE void DoGradientFilter_NEON(const uint8_t* in,
static void GradientFilter_NEON(const uint8_t* data, int width, int height, static void GradientFilter_NEON(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoGradientFilter_NEON(data, width, height, stride, 0, height, DoGradientFilter_NEON(data, width, height, stride, filtered_data);
filtered_data);
} }
#undef DCHECK #undef DCHECK

View File

@ -30,8 +30,6 @@
assert(width > 0); \ assert(width > 0); \
assert(height > 0); \ assert(height > 0); \
assert(stride >= width); \ assert(stride >= width); \
assert(row >= 0 && num_rows > 0 && row + num_rows <= height); \
(void)height; /* Silence unused warning. */ \
} while (0) } while (0)
static void PredictLineTop_SSE2(const uint8_t* src, const uint8_t* pred, static void PredictLineTop_SSE2(const uint8_t* src, const uint8_t* pred,
@ -75,30 +73,21 @@ static void PredictLineLeft_SSE2(const uint8_t* src, uint8_t* dst, int length) {
static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in, static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in,
int width, int height, int width, int height,
int stride, int stride, uint8_t* out) {
int row, int num_rows, int row;
uint8_t* out) {
const size_t start_offset = row * stride;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
if (row == 0) { // Leftmost pixel is the same as input for topmost scanline.
// Leftmost pixel is the same as input for topmost scanline. out[0] = in[0];
out[0] = in[0]; PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
PredictLineLeft_SSE2(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
// Leftmost pixel is predicted from above. // Leftmost pixel is predicted from above.
out[0] = in[0] - in[-stride]; out[0] = in[0] - in[-stride];
PredictLineLeft_SSE2(in + 1, out + 1, width - 1); PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -109,28 +98,20 @@ static WEBP_INLINE void DoHorizontalFilter_SSE2(const uint8_t* in,
static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in, static WEBP_INLINE void DoVerticalFilter_SSE2(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows,
uint8_t* out) { uint8_t* out) {
const size_t start_offset = row * stride; int row;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
if (row == 0) { // Very first top-left pixel is copied.
// Very first top-left pixel is copied. out[0] = in[0];
out[0] = in[0]; // Rest of top scan-line is left-predicted.
// Rest of top scan-line is left-predicted. PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
PredictLineLeft_SSE2(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
PredictLineTop_SSE2(in, in - stride, out, width); PredictLineTop_SSE2(in, in - stride, out, width);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -172,28 +153,20 @@ static void GradientPredictDirect_SSE2(const uint8_t* const row,
static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in, static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in,
int width, int height, int stride, int width, int height, int stride,
int row, int num_rows,
uint8_t* out) { uint8_t* out) {
const size_t start_offset = row * stride; int row;
const int last_row = row + num_rows;
DCHECK(in, out); DCHECK(in, out);
in += start_offset;
out += start_offset;
// left prediction for top scan-line // left prediction for top scan-line
if (row == 0) { out[0] = in[0];
out[0] = in[0]; PredictLineLeft_SSE2(in + 1, out + 1, width - 1);
PredictLineLeft_SSE2(in + 1, out + 1, width - 1); in += stride;
row = 1; out += stride;
in += stride;
out += stride;
}
// Filter line-by-line. // Filter line-by-line.
while (row < last_row) { for (row = 1; row < height; ++row) {
out[0] = (uint8_t)(in[0] - in[-stride]); out[0] = (uint8_t)(in[0] - in[-stride]);
GradientPredictDirect_SSE2(in + 1, in + 1 - stride, out + 1, width - 1); GradientPredictDirect_SSE2(in + 1, in + 1 - stride, out + 1, width - 1);
++row;
in += stride; in += stride;
out += stride; out += stride;
} }
@ -205,18 +178,17 @@ static WEBP_INLINE void DoGradientFilter_SSE2(const uint8_t* in,
static void HorizontalFilter_SSE2(const uint8_t* data, int width, int height, static void HorizontalFilter_SSE2(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoHorizontalFilter_SSE2(data, width, height, stride, 0, height, DoHorizontalFilter_SSE2(data, width, height, stride, filtered_data);
filtered_data);
} }
static void VerticalFilter_SSE2(const uint8_t* data, int width, int height, static void VerticalFilter_SSE2(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoVerticalFilter_SSE2(data, width, height, stride, 0, height, filtered_data); DoVerticalFilter_SSE2(data, width, height, stride, filtered_data);
} }
static void GradientFilter_SSE2(const uint8_t* data, int width, int height, static void GradientFilter_SSE2(const uint8_t* data, int width, int height,
int stride, uint8_t* filtered_data) { int stride, uint8_t* filtered_data) {
DoGradientFilter_SSE2(data, width, height, stride, 0, height, filtered_data); DoGradientFilter_SSE2(data, width, height, stride, filtered_data);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------