Do one memset for left and right padding.

This commit is contained in:
Fabien Freling 2014-08-08 19:29:46 +02:00
parent fdbe6efc35
commit b4032a3eee
2 changed files with 27 additions and 26 deletions

View file

@ -7,6 +7,7 @@
[X] Fixed point computation [X] Fixed point computation
[-] -funroll-loops -> no gain [-] -funroll-loops -> no gain
[-] restrict qualifier -> unavailable in C++ [-] restrict qualifier -> unavailable in C++
[ ] All positions as simple integer
# Cache # Cache
[-] Rotate per channel -> no gain [-] Rotate per channel -> no gain

View file

@ -444,25 +444,23 @@ Image* rotate(Image const& src, double angle)
qdx, qdy, qdx, qdy,
src_qwidth, src_qheight, src_qwidth, src_qheight,
q_pos)); 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) for (int y = 0; y < height; ++y)
{ {
int const left_padding = padding_table[2 * y]; int const left_padding = padding_table[2 * y];
int const left_border = 0; // int const left_border = 0;
int const right_border = 0; // int const right_border = 0;
int const right_padding = padding_table[2 * y + 1]; 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) if (core_pixels < 0)
{ {
ERRLOG << "Too much border at line " << y << endl; ERRLOG << "Too much border at line " << y << endl;
ERRLOG << " width = " << width << endl; ERRLOG << " width = " << width << endl;
ERRLOG << " left padding = " << left_padding << 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 << " right padding = " << right_padding << endl;
ERRLOG << " core pixels = " << core_pixels << endl; ERRLOG << " core pixels = " << core_pixels << endl;
abort(); abort();
@ -475,18 +473,20 @@ Image* rotate(Image const& src, double angle)
LOG << "core pixels = " << core_pixels << endl; LOG << "core pixels = " << core_pixels << endl;
} }
// Left padding // Padding
memset(buffer + buffer_index, 0, left_padding * sizeof (pvalue_t)); int const padding = left_padding + previous_right_padding;
buffer_index += left_padding; memset(buffer + buffer_index, 0, padding * sizeof (pvalue_t));
buffer_index += padding;
previous_right_padding = right_padding;
// Border // // Border
for (int x = 0; x < left_border; ++x, ++buffer_index) // for (int x = 0; x < left_border; ++x, ++buffer_index)
{ // {
buffer[buffer_index] = 0; // TODO: handle border // buffer[buffer_index] = 0; // TODO: handle border
} // }
Point src_rotated_point(src_rotated_origin.x + (left_padding + left_border) * qdx.x, Point src_rotated_point(src_rotated_origin.x + left_padding * qdx.x,
src_rotated_origin.y + (left_padding + left_border) * qdx.y); src_rotated_origin.y + left_padding * qdx.y);
// Body // Body
for (int x = 0; x < core_pixels; ++x, ++buffer_index) 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; src_rotated_point += qdx;
} }
// Border // // Border
for (int x = 0; x < right_border; ++x, ++buffer_index) // for (int x = 0; x < right_border; ++x, ++buffer_index)
{ // {
buffer[buffer_index] = 0; // TODO: handle border // buffer[buffer_index] = 0; // TODO: handle border
src_rotated_point += qdx; // src_rotated_index += pdx;
} // }
// Right padding
memset(buffer + buffer_index, 0, right_padding * sizeof (pvalue_t));
buffer_index += right_padding;
src_rotated_origin += qdy; src_rotated_origin += qdy;
} }
// Final right padding
memset(buffer + buffer_index, 0, padding_table[2 * (height - 1) + 1] * sizeof (pvalue_t));
return rotated; return rotated;
} }