mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 06:08:21 +01:00
Import: use relative pointer offsets
avoids int rollover when working with large input
BUG=webp:312
Change-Id: I6ad9f93b6c4b665c559bff87716a7b847f66a20d
(cherry picked from commit 342e15f0ce
)
This commit is contained in:
parent
a1ade40ed8
commit
83cbfa09a1
@ -1105,10 +1105,10 @@ static int Import(WebPPicture* const picture,
|
|||||||
const uint8_t* const rgb, int rgb_stride,
|
const uint8_t* const rgb, int rgb_stride,
|
||||||
int step, int swap_rb, int import_alpha) {
|
int step, int swap_rb, int import_alpha) {
|
||||||
int y;
|
int y;
|
||||||
const uint8_t* const r_ptr = rgb + (swap_rb ? 2 : 0);
|
const uint8_t* r_ptr = rgb + (swap_rb ? 2 : 0);
|
||||||
const uint8_t* const g_ptr = rgb + 1;
|
const uint8_t* g_ptr = rgb + 1;
|
||||||
const uint8_t* const b_ptr = rgb + (swap_rb ? 0 : 2);
|
const uint8_t* b_ptr = rgb + (swap_rb ? 0 : 2);
|
||||||
const uint8_t* const a_ptr = import_alpha ? rgb + 3 : NULL;
|
const uint8_t* a_ptr = import_alpha ? rgb + 3 : NULL;
|
||||||
const int width = picture->width;
|
const int width = picture->width;
|
||||||
const int height = picture->height;
|
const int height = picture->height;
|
||||||
|
|
||||||
@ -1121,20 +1121,25 @@ static int Import(WebPPicture* const picture,
|
|||||||
VP8EncDspARGBInit();
|
VP8EncDspARGBInit();
|
||||||
|
|
||||||
if (import_alpha) {
|
if (import_alpha) {
|
||||||
|
uint32_t* dst = picture->argb;
|
||||||
assert(step == 4);
|
assert(step == 4);
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
uint32_t* const dst = &picture->argb[y * picture->argb_stride];
|
VP8PackARGB(a_ptr, r_ptr, g_ptr, b_ptr, width, dst);
|
||||||
const int offset = y * rgb_stride;
|
a_ptr += rgb_stride;
|
||||||
VP8PackARGB(a_ptr + offset, r_ptr + offset, g_ptr + offset,
|
r_ptr += rgb_stride;
|
||||||
b_ptr + offset, width, dst);
|
g_ptr += rgb_stride;
|
||||||
|
b_ptr += rgb_stride;
|
||||||
|
dst += picture->argb_stride;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
uint32_t* dst = picture->argb;
|
||||||
assert(step >= 3);
|
assert(step >= 3);
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
uint32_t* const dst = &picture->argb[y * picture->argb_stride];
|
VP8PackRGB(r_ptr, g_ptr, b_ptr, width, step, dst);
|
||||||
const int offset = y * rgb_stride;
|
r_ptr += rgb_stride;
|
||||||
VP8PackRGB(r_ptr + offset, g_ptr + offset, b_ptr + offset,
|
g_ptr += rgb_stride;
|
||||||
width, step, dst);
|
b_ptr += rgb_stride;
|
||||||
|
dst += picture->argb_stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user