mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-07-30 16:26:19 +08:00
Fix potential int overflows in ScaleFilterReduce()
Change-Id: I2eb69772f0d65760a87360e46215a6c6d69f250f
This commit is contained in:
parent
b56492e2df
commit
669d7c7d6c
@ -11,6 +11,8 @@
|
||||
#include "libyuv/scale.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "libyuv/cpu_id.h"
|
||||
@ -1830,14 +1832,17 @@ enum FilterMode ScaleFilterReduce(int src_width,
|
||||
int dst_height,
|
||||
enum FilterMode filtering) {
|
||||
if (src_width < 0) {
|
||||
assert(src_width != INT_MIN);
|
||||
src_width = -src_width;
|
||||
}
|
||||
if (src_height < 0) {
|
||||
assert(src_height != INT_MIN);
|
||||
src_height = -src_height;
|
||||
}
|
||||
if (filtering == kFilterBox) {
|
||||
// If scaling either axis to 0.5 or larger, switch from Box to Bilinear.
|
||||
if (dst_width * 2 >= src_width || dst_height * 2 >= src_height) {
|
||||
if ((int64_t)dst_width * 2 >= src_width ||
|
||||
(int64_t)dst_height * 2 >= src_height) {
|
||||
filtering = kFilterBilinear;
|
||||
}
|
||||
}
|
||||
@ -1846,7 +1851,7 @@ enum FilterMode ScaleFilterReduce(int src_width,
|
||||
filtering = kFilterLinear;
|
||||
}
|
||||
// TODO(fbarchard): Detect any odd scale factor and reduce to Linear.
|
||||
if (dst_height == src_height || dst_height * 3 == src_height) {
|
||||
if (dst_height == src_height || (int64_t)dst_height * 3 == src_height) {
|
||||
filtering = kFilterLinear;
|
||||
}
|
||||
// TODO(fbarchard): Remove 1 pixel wide filter restriction, which is to
|
||||
@ -1860,7 +1865,7 @@ enum FilterMode ScaleFilterReduce(int src_width,
|
||||
filtering = kFilterNone;
|
||||
}
|
||||
// TODO(fbarchard): Detect any odd scale factor and reduce to None.
|
||||
if (dst_width == src_width || dst_width * 3 == src_width) {
|
||||
if (dst_width == src_width || (int64_t)dst_width * 3 == src_width) {
|
||||
filtering = kFilterNone;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user