mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-14 21:09:55 +02:00
Merge changes If628bb93,Ic79f6309,I45f0db23 into main
* changes: Update lossless spec for two simple codes. Fix non-C90 code. Fix static analyzer warnings.
This commit is contained in:
@ -75,7 +75,7 @@ static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
|
||||
const WebPRGBABuffer* const buf = &buffer->u.RGBA;
|
||||
const int stride = abs(buf->stride);
|
||||
const uint64_t size =
|
||||
MIN_BUFFER_SIZE(width * kModeBpp[mode], height, stride);
|
||||
MIN_BUFFER_SIZE((uint64_t)width * kModeBpp[mode], height, stride);
|
||||
ok &= (size <= buf->size);
|
||||
ok &= (stride >= width * kModeBpp[mode]);
|
||||
ok &= (buf->rgba != NULL);
|
||||
|
@ -36,8 +36,9 @@ static WEBP_INLINE int IsFlat(const int16_t* levels, int num_blocks,
|
||||
int thresh) {
|
||||
const int16x8_t tst_ones = vdupq_n_s16(-1);
|
||||
uint32x4_t sum = vdupq_n_u32(0);
|
||||
int i;
|
||||
|
||||
for (int i = 0; i < num_blocks; ++i) {
|
||||
for (i = 0; i < num_blocks; ++i) {
|
||||
// Set DC to zero.
|
||||
const int16x8_t a_0 = vsetq_lane_s16(0, vld1q_s16(levels), 0);
|
||||
const int16x8_t a_1 = vld1q_s16(levels + 8);
|
||||
|
@ -55,7 +55,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
|
||||
WebPConfig config;
|
||||
WebPPicture picture;
|
||||
|
||||
WebPPictureInit(&picture);
|
||||
if (!WebPPictureInit(&picture)) return 0;
|
||||
picture.width = width;
|
||||
picture.height = height;
|
||||
picture.use_argb = 1;
|
||||
|
@ -578,7 +578,7 @@ static uint64_t OneStatPass(VP8Encoder* const enc, VP8RDLevel rd_opt,
|
||||
uint64_t size = 0;
|
||||
uint64_t size_p0 = 0;
|
||||
uint64_t distortion = 0;
|
||||
const uint64_t pixel_count = nb_mbs * 384;
|
||||
const uint64_t pixel_count = (uint64_t)nb_mbs * 384;
|
||||
|
||||
VP8IteratorInit(enc, &it);
|
||||
SetLoopParams(enc, s->q);
|
||||
@ -789,7 +789,7 @@ int VP8EncTokenLoop(VP8Encoder* const enc) {
|
||||
VP8EncIterator it;
|
||||
VP8EncProba* const proba = &enc->proba_;
|
||||
const VP8RDLevel rd_opt = enc->rd_opt_level_;
|
||||
const uint64_t pixel_count = enc->mb_w_ * enc->mb_h_ * 384;
|
||||
const uint64_t pixel_count = (uint64_t)enc->mb_w_ * enc->mb_h_ * 384;
|
||||
PassStats stats;
|
||||
int ok;
|
||||
|
||||
|
@ -1181,7 +1181,7 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
||||
const int entropy_combine_num_bins = low_effort ? NUM_PARTITIONS : BIN_SIZE;
|
||||
int entropy_combine;
|
||||
uint16_t* const map_tmp =
|
||||
WebPSafeMalloc(2 * image_histo_raw_size, sizeof(map_tmp));
|
||||
WebPSafeMalloc(2 * image_histo_raw_size, sizeof(*map_tmp));
|
||||
uint16_t* const cluster_mappings = map_tmp + image_histo_raw_size;
|
||||
int num_used = image_histo_raw_size;
|
||||
if (orig_histo == NULL || map_tmp == NULL) {
|
||||
|
@ -1192,7 +1192,7 @@ static void ClearTransformBuffer(VP8LEncoder* const enc) {
|
||||
// enc->use_predict_, enc->use_cross_color_
|
||||
static int AllocateTransformBuffer(VP8LEncoder* const enc, int width,
|
||||
int height) {
|
||||
const uint64_t image_size = width * height;
|
||||
const uint64_t image_size = (uint64_t)width * height;
|
||||
// VP8LResidualImage needs room for 2 scanlines of uint32 pixels with an extra
|
||||
// pixel in each, plus 2 regular scanlines of bytes.
|
||||
// TODO(skal): Clean up by using arithmetic in bytes instead of words.
|
||||
@ -1202,7 +1202,7 @@ static int AllocateTransformBuffer(VP8LEncoder* const enc, int width,
|
||||
: 0;
|
||||
const uint64_t transform_data_size =
|
||||
(enc->use_predict_ || enc->use_cross_color_)
|
||||
? VP8LSubSampleSize(width, enc->transform_bits_) *
|
||||
? (uint64_t)VP8LSubSampleSize(width, enc->transform_bits_) *
|
||||
VP8LSubSampleSize(height, enc->transform_bits_)
|
||||
: 0;
|
||||
const uint64_t max_alignment_in_words =
|
||||
|
@ -593,16 +593,17 @@ int WebPAnimEncoderRefineRect(
|
||||
int is_lossless, float quality, int* const x_offset, int* const y_offset,
|
||||
int* const width, int* const height) {
|
||||
FrameRectangle rect;
|
||||
const int right = clip(*x_offset + *width, 0, curr_canvas->width);
|
||||
const int left = clip(*x_offset, 0, curr_canvas->width - 1);
|
||||
const int bottom = clip(*y_offset + *height, 0, curr_canvas->height);
|
||||
const int top = clip(*y_offset, 0, curr_canvas->height - 1);
|
||||
int right, left, bottom, top;
|
||||
if (prev_canvas == NULL || curr_canvas == NULL ||
|
||||
prev_canvas->width != curr_canvas->width ||
|
||||
prev_canvas->height != curr_canvas->height ||
|
||||
!prev_canvas->use_argb || !curr_canvas->use_argb) {
|
||||
return 0;
|
||||
}
|
||||
right = clip(*x_offset + *width, 0, curr_canvas->width);
|
||||
left = clip(*x_offset, 0, curr_canvas->width - 1);
|
||||
bottom = clip(*y_offset + *height, 0, curr_canvas->height);
|
||||
top = clip(*y_offset, 0, curr_canvas->height - 1);
|
||||
rect.x_offset_ = left;
|
||||
rect.y_offset_ = top;
|
||||
rect.width_ = clip(right - left, 0, curr_canvas->width - rect.x_offset_);
|
||||
|
@ -555,7 +555,8 @@ static WebPMuxError MuxCleanup(WebPMux* const mux) {
|
||||
if (num_frames == 1) {
|
||||
WebPMuxImage* frame = NULL;
|
||||
err = MuxImageGetNth((const WebPMuxImage**)&mux->images_, 1, &frame);
|
||||
assert(err == WEBP_MUX_OK); // We know that one frame does exist.
|
||||
if (err != WEBP_MUX_OK) return err;
|
||||
// We know that one frame does exist.
|
||||
assert(frame != NULL);
|
||||
if (frame->header_ != NULL &&
|
||||
((mux->canvas_width_ == 0 && mux->canvas_height_ == 0) ||
|
||||
|
@ -97,7 +97,7 @@ int GetColorPalette(const WebPPicture* const pic, uint32_t* const palette) {
|
||||
int x, y;
|
||||
int num_colors = 0;
|
||||
uint8_t in_use[COLOR_HASH_SIZE] = {0};
|
||||
uint32_t colors[COLOR_HASH_SIZE];
|
||||
uint32_t colors[COLOR_HASH_SIZE] = {0};
|
||||
const uint32_t* argb = pic->argb;
|
||||
const int width = pic->width;
|
||||
const int height = pic->height;
|
||||
|
Reference in New Issue
Block a user