-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Am 2015-12-27 um 10:23 schrieb Aaryaman Vasishta:
if (info_header.biWidth % 4 != 0)
expected = (info_header.biWidth & ~0x03) + 4;
else
expected = info_header.biWidth;
This is more complicated than it needs to be:
expected = (info_header.biWidth + 3) & ~3
should work as well.
k++;
/* Take into account padded bytes after every row for odd widths */
if ((w % 2 == 1) && (j == w - 1))
k = (k & ~0x03) + 4;
Wouldn't this also apply for e.g. a width of 10 that is a multiple of 2, but not a multiple of 4?
The canonical way is to advance bytes_per_line bytes every line, e.g. buffer1[i * bytes_per_line + j]
Or do k += bytes_per_line in the outer loop and then just do buffer1[k + j] to avoid re-doing the multiplication every time. I'd expect the compiler to optimize it anyway though.
Other than that the patch looks good :-)
On Fri, Jan 1, 2016 at 6:39 PM, Stefan Dösinger stefandoesinger@gmail.com wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256
Am 2015-12-27 um 10:23 schrieb Aaryaman Vasishta:
if (info_header.biWidth % 4 != 0)
expected = (info_header.biWidth & ~0x03) + 4;
else
expected = info_header.biWidth;
This is more complicated than it needs to be:
expected = (info_header.biWidth + 3) & ~3
should work as well.
Much better solution :)
I've sent try 6 with the changes.
Cheers, Aaryaman