Remove boundary check in rotate_pixel().
This check makes the last line invalid.
This commit is contained in:
parent
210dff5c62
commit
e2a17282aa
2
TODO.md
2
TODO.md
|
@ -1,7 +1,7 @@
|
||||||
[-] Draw rotated pixels in src order -> cache write miss
|
[-] Draw rotated pixels in src order -> cache write miss
|
||||||
[X] Use atan2 at beginning and end of line.
|
[X] Use atan2 at beginning and end of line.
|
||||||
Interpolation in-between values
|
Interpolation in-between values
|
||||||
[ ] Test pixel perfect 0, 90
|
[X] Test pixel perfect 0, 90
|
||||||
|
|
||||||
[X] Optimization for square images
|
[X] Optimization for square images
|
||||||
[X] Fixed point computation
|
[X] Fixed point computation
|
||||||
|
|
12
rotation.cpp
12
rotation.cpp
|
@ -438,7 +438,6 @@ uint16_t* generate_border_table(uint16_t const* padding_table, Image const& imag
|
||||||
inline
|
inline
|
||||||
void rotate_pixel(Image const& src,
|
void rotate_pixel(Image const& src,
|
||||||
Point const& src_rotated_point,
|
Point const& src_rotated_point,
|
||||||
unsigned int const src_limit,
|
|
||||||
pvalue_t* rotate_buffer, unsigned int rot_index,
|
pvalue_t* rotate_buffer, unsigned int rot_index,
|
||||||
int q_pow)
|
int q_pow)
|
||||||
{
|
{
|
||||||
|
@ -456,12 +455,6 @@ void rotate_pixel(Image const& src,
|
||||||
unsigned int const src_index_3 = src_index_1 + src.pixel_size * src.width;
|
unsigned int const src_index_3 = src_index_1 + src.pixel_size * src.width;
|
||||||
unsigned int const src_index_4 = src_index_3 + src.pixel_size;
|
unsigned int const src_index_4 = src_index_3 + src.pixel_size;
|
||||||
|
|
||||||
// Out-of-bounds check
|
|
||||||
if (src_index_4 >= src_limit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pvalue_t const src_tl = src.buffer[src_index_1];
|
pvalue_t const src_tl = src.buffer[src_index_1];
|
||||||
pvalue_t const src_tr = src.buffer[src_index_2];
|
pvalue_t const src_tr = src.buffer[src_index_2];
|
||||||
pvalue_t const src_bl = src.buffer[src_index_3];
|
pvalue_t const src_bl = src.buffer[src_index_3];
|
||||||
|
@ -536,7 +529,6 @@ Image* rotate(Image const& src, double angle)
|
||||||
unsigned int buffer_index = 0;
|
unsigned int buffer_index = 0;
|
||||||
pvalue_t* buffer = rotated->buffer;
|
pvalue_t* buffer = rotated->buffer;
|
||||||
|
|
||||||
unsigned int const src_limit = src.width * src.height * src.pixel_size;
|
|
||||||
int const width = rotated->width;
|
int const width = rotated->width;
|
||||||
int const height = rotated->height;
|
int const height = rotated->height;
|
||||||
int const& src_qwidth = src.width * q_pos;
|
int const& src_qwidth = src.width * q_pos;
|
||||||
|
@ -588,7 +580,7 @@ Image* rotate(Image const& src, double angle)
|
||||||
if (src_rotated_point.x < 0 || src_rotated_point.y < 0
|
if (src_rotated_point.x < 0 || src_rotated_point.y < 0
|
||||||
|| src_rotated_point.x >= src_qwidth || src_rotated_point.y >= src_qheight)
|
|| src_rotated_point.x >= src_qwidth || src_rotated_point.y >= src_qheight)
|
||||||
{
|
{
|
||||||
// cout << "Point too low!" << endl;
|
LOG << "Out-of-bounds point!" << endl;
|
||||||
// cout << " x: " << x << endl;
|
// cout << " x: " << x << endl;
|
||||||
// cout << " src_rotated_point: " << src_rotated_point << endl;
|
// cout << " src_rotated_point: " << src_rotated_point << endl;
|
||||||
// cout << " qdx: " << qdx << endl;
|
// cout << " qdx: " << qdx << endl;
|
||||||
|
@ -606,7 +598,7 @@ Image* rotate(Image const& src, double angle)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rotate_pixel(src, src_rotated_point, src_limit, buffer, buffer_index, q_pos_pow);
|
rotate_pixel(src, src_rotated_point, buffer, buffer_index, q_pos_pow);
|
||||||
}
|
}
|
||||||
|
|
||||||
src_rotated_point += qdx;
|
src_rotated_point += qdx;
|
||||||
|
|
Loading…
Reference in a new issue