Do one memset for left and right padding.
This commit is contained in:
parent
fdbe6efc35
commit
b4032a3eee
1
TODO.md
1
TODO.md
|
@ -7,6 +7,7 @@
|
|||
[X] Fixed point computation
|
||||
[-] -funroll-loops -> no gain
|
||||
[-] restrict qualifier -> unavailable in C++
|
||||
[ ] All positions as simple integer
|
||||
|
||||
# Cache
|
||||
[-] Rotate per channel -> no gain
|
||||
|
|
52
rotation.cpp
52
rotation.cpp
|
@ -444,25 +444,23 @@ Image* rotate(Image const& src, double angle)
|
|||
qdx, qdy,
|
||||
src_qwidth, src_qheight,
|
||||
q_pos));
|
||||
// uint16_t* front_border = generate_border_table(padding_table, back_padding_table, *rotated);
|
||||
// uint16_t* back_border = generate_border_table_back(padding_table, front_border, back_padding_table, *rotated);
|
||||
|
||||
int previous_right_padding = 0;
|
||||
|
||||
for (int y = 0; y < height; ++y)
|
||||
{
|
||||
|
||||
int const left_padding = padding_table[2 * y];
|
||||
int const left_border = 0;
|
||||
int const right_border = 0;
|
||||
// int const left_border = 0;
|
||||
// int const right_border = 0;
|
||||
int const right_padding = padding_table[2 * y + 1];
|
||||
int const core_pixels = width - left_padding - left_border - right_border - right_padding;
|
||||
int const core_pixels = width - left_padding - right_padding;
|
||||
|
||||
if (core_pixels < 0)
|
||||
{
|
||||
ERRLOG << "Too much border at line " << y << endl;
|
||||
ERRLOG << " width = " << width << endl;
|
||||
ERRLOG << " left padding = " << left_padding << endl;
|
||||
ERRLOG << " left border = " << left_border << endl;
|
||||
ERRLOG << " right border = " << right_border << endl;
|
||||
ERRLOG << " right padding = " << right_padding << endl;
|
||||
ERRLOG << " core pixels = " << core_pixels << endl;
|
||||
abort();
|
||||
|
@ -475,18 +473,20 @@ Image* rotate(Image const& src, double angle)
|
|||
LOG << "core pixels = " << core_pixels << endl;
|
||||
}
|
||||
|
||||
// Left padding
|
||||
memset(buffer + buffer_index, 0, left_padding * sizeof (pvalue_t));
|
||||
buffer_index += left_padding;
|
||||
// Padding
|
||||
int const padding = left_padding + previous_right_padding;
|
||||
memset(buffer + buffer_index, 0, padding * sizeof (pvalue_t));
|
||||
buffer_index += padding;
|
||||
previous_right_padding = right_padding;
|
||||
|
||||
// Border
|
||||
for (int x = 0; x < left_border; ++x, ++buffer_index)
|
||||
{
|
||||
buffer[buffer_index] = 0; // TODO: handle border
|
||||
}
|
||||
// // Border
|
||||
// for (int x = 0; x < left_border; ++x, ++buffer_index)
|
||||
// {
|
||||
// buffer[buffer_index] = 0; // TODO: handle border
|
||||
// }
|
||||
|
||||
Point src_rotated_point(src_rotated_origin.x + (left_padding + left_border) * qdx.x,
|
||||
src_rotated_origin.y + (left_padding + left_border) * qdx.y);
|
||||
Point src_rotated_point(src_rotated_origin.x + left_padding * qdx.x,
|
||||
src_rotated_origin.y + left_padding * qdx.y);
|
||||
|
||||
// Body
|
||||
for (int x = 0; x < core_pixels; ++x, ++buffer_index)
|
||||
|
@ -495,20 +495,20 @@ Image* rotate(Image const& src, double angle)
|
|||
src_rotated_point += qdx;
|
||||
}
|
||||
|
||||
// Border
|
||||
for (int x = 0; x < right_border; ++x, ++buffer_index)
|
||||
{
|
||||
buffer[buffer_index] = 0; // TODO: handle border
|
||||
src_rotated_point += qdx;
|
||||
}
|
||||
// // Border
|
||||
// for (int x = 0; x < right_border; ++x, ++buffer_index)
|
||||
// {
|
||||
// buffer[buffer_index] = 0; // TODO: handle border
|
||||
// src_rotated_index += pdx;
|
||||
// }
|
||||
|
||||
// Right padding
|
||||
memset(buffer + buffer_index, 0, right_padding * sizeof (pvalue_t));
|
||||
buffer_index += right_padding;
|
||||
|
||||
src_rotated_origin += qdy;
|
||||
}
|
||||
|
||||
// Final right padding
|
||||
memset(buffer + buffer_index, 0, padding_table[2 * (height - 1) + 1] * sizeof (pvalue_t));
|
||||
|
||||
return rotated;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue