mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
consistency cosmetics
Change-Id: Ie8e372ddcdd6e48527478f70bf716953ed18292a
This commit is contained in:
parent
2ebe8394f8
commit
81720c9139
@ -51,10 +51,12 @@ static int AnalyzeAndCreatePalette(const WebPPicture* const pic,
|
|||||||
uint32_t colors[MAX_PALETTE_SIZE * 4];
|
uint32_t colors[MAX_PALETTE_SIZE * 4];
|
||||||
static const uint32_t kHashMul = 0x1e35a7bd;
|
static const uint32_t kHashMul = 0x1e35a7bd;
|
||||||
const uint32_t* argb = pic->argb;
|
const uint32_t* argb = pic->argb;
|
||||||
|
const int width = pic->width;
|
||||||
|
const int height = pic->height;
|
||||||
uint32_t last_pix = ~argb[0]; // so we're sure that last_pix != argb[0]
|
uint32_t last_pix = ~argb[0]; // so we're sure that last_pix != argb[0]
|
||||||
|
|
||||||
for (y = 0; y < pic->height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
for (x = 0; x < pic->width; ++x) {
|
for (x = 0; x < width; ++x) {
|
||||||
if (argb[x] == last_pix) {
|
if (argb[x] == last_pix) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -83,6 +85,7 @@ static int AnalyzeAndCreatePalette(const WebPPicture* const pic,
|
|||||||
argb += pic->argb_stride;
|
argb += pic->argb_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(skal): could we reuse in_use[] to speed up ApplyPalette()?
|
||||||
num_colors = 0;
|
num_colors = 0;
|
||||||
for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) {
|
for (i = 0; i < (int)(sizeof(in_use) / sizeof(in_use[0])); ++i) {
|
||||||
if (in_use[i]) {
|
if (in_use[i]) {
|
||||||
@ -708,7 +711,7 @@ static WebPEncodingError WriteRiffHeader(const WebPPicture* const pic,
|
|||||||
static int WriteImageSize(const WebPPicture* const pic,
|
static int WriteImageSize(const WebPPicture* const pic,
|
||||||
VP8LBitWriter* const bw) {
|
VP8LBitWriter* const bw) {
|
||||||
const int width = pic->width - 1;
|
const int width = pic->width - 1;
|
||||||
const int height = pic->height -1;
|
const int height = pic->height - 1;
|
||||||
assert(width < WEBP_MAX_DIMENSION && height < WEBP_MAX_DIMENSION);
|
assert(width < WEBP_MAX_DIMENSION && height < WEBP_MAX_DIMENSION);
|
||||||
|
|
||||||
VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, width);
|
VP8LWriteBits(bw, VP8L_IMAGE_SIZE_BITS, width);
|
||||||
@ -816,11 +819,11 @@ static void BundleColorMap(const WebPPicture* const pic,
|
|||||||
// Also, "enc->palette_" will be modified after this call and should not be used
|
// Also, "enc->palette_" will be modified after this call and should not be used
|
||||||
// later.
|
// later.
|
||||||
static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
||||||
VP8LEncoder* const enc,
|
VP8LEncoder* const enc, int quality) {
|
||||||
int quality) {
|
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
WebPEncodingError err = VP8_ENC_OK;
|
||||||
int i, x, y;
|
int i, x, y;
|
||||||
const WebPPicture* const pic = enc->pic_;
|
const WebPPicture* const pic = enc->pic_;
|
||||||
|
uint32_t* argb = pic->argb;
|
||||||
const int width = pic->width;
|
const int width = pic->width;
|
||||||
const int height = pic->height;
|
const int height = pic->height;
|
||||||
uint32_t* const palette = enc->palette_;
|
uint32_t* const palette = enc->palette_;
|
||||||
@ -828,7 +831,6 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
|||||||
|
|
||||||
// Replace each input pixel by corresponding palette index.
|
// Replace each input pixel by corresponding palette index.
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
uint32_t* const argb = pic->argb + y * pic->argb_stride;
|
|
||||||
for (x = 0; x < width; ++x) {
|
for (x = 0; x < width; ++x) {
|
||||||
const uint32_t pix = argb[x];
|
const uint32_t pix = argb[x];
|
||||||
for (i = 0; i < palette_size; ++i) {
|
for (i = 0; i < palette_size; ++i) {
|
||||||
@ -838,6 +840,7 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
argb += pic->argb_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save palette to bitstream.
|
// Save palette to bitstream.
|
||||||
|
Loading…
Reference in New Issue
Block a user