aboutsummaryrefslogtreecommitdiff
path: root/source/scale_argb.cc
diff options
context:
space:
mode:
authorFrank Barchard <fbarchard@google.com>2023-12-04 01:16:59 -0800
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-12-04 22:55:20 +0000
commitdef473f501acbd652cd4593fd2a90a067e8c9f1a (patch)
treec4aec58c96864262fd184f4fa448e0374ec681a8 /source/scale_argb.cc
parente6d5adb3629a4aedb385f948fc5a8eb379a5ca3b (diff)
downloadlibyuv-def473f501acbd652cd4593fd2a90a067e8c9f1a.tar.gz
malloc return 1 for failures and assert for internal functions
Bug: libyuv:968 Change-Id: Iea2f907061532d2e00347996124bc80d079a7bdc Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5010874 Reviewed-by: Wan-Teh Chang <wtc@google.com> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source/scale_argb.cc')
-rw-r--r--source/scale_argb.cc26
1 files changed, 12 insertions, 14 deletions
diff --git a/source/scale_argb.cc b/source/scale_argb.cc
index 65d0c892..c8e0db9e 100644
--- a/source/scale_argb.cc
+++ b/source/scale_argb.cc
@@ -170,7 +170,8 @@ static int ScaleARGBDown4Box(int src_width,
// but implemented via a 2 pass wrapper that uses a very small array on the
// stack with a horizontal loop.
align_buffer_64(row, row_size * 2);
- if (!row) return 1;
+ if (!row)
+ return 1;
int row_stride = src_stride * (dy >> 16);
void (*ScaleARGBRowDown2)(const uint8_t* src_argb, ptrdiff_t src_stride,
uint8_t* dst_argb, int dst_width) =
@@ -412,7 +413,8 @@ static int ScaleARGBBilinearDown(int src_width,
// Allocate a row of ARGB.
{
align_buffer_64(row, clip_src_width * 4);
- if (!row) return 1;
+ if (!row)
+ return 1;
const int max_y = (src_height - 1) << 16;
if (y > max_y) {
@@ -588,7 +590,8 @@ static int ScaleARGBBilinearUp(int src_width,
// Allocate 2 rows of ARGB.
const int row_size = (dst_width * 4 + 31) & ~31;
align_buffer_64(row, row_size * 2);
- if (!row) return 1;
+ if (!row)
+ return 1;
uint8_t* rowptr = row;
int rowstride = row_size;
@@ -855,21 +858,17 @@ static int ScaleYUVToARGBBilinearUp(int src_width,
const uint8_t* src_row_u = src_u + uv_yi * (intptr_t)src_stride_u;
const uint8_t* src_row_v = src_v + uv_yi * (intptr_t)src_stride_v;
- // Allocate 2 rows of ARGB.
+ // Allocate 1 row of ARGB for source conversion and 2 rows of ARGB
+ // scaled horizontally to the destination width.
const int row_size = (dst_width * 4 + 31) & ~31;
- align_buffer_64(row, row_size * 2);
- if (!row) return 1;
-
- // Allocate 1 row of ARGB for source conversion.
- align_buffer_64(argb_row, src_width * 4);
- if (!argb_row) {
- free_aligned_buffer_64(row);
- return 1;
- }
+ align_buffer_64(row, row_size * 2 + src_width * 4);
+ uint8_t* argb_row = row + row_size * 2;
uint8_t* rowptr = row;
int rowstride = row_size;
int lasty = yi;
+ if (!row)
+ return 1;
// TODO(fbarchard): Convert first 2 rows of YUV to ARGB.
ScaleARGBFilterCols(rowptr, src_row_y, dst_width, x, dx);
@@ -924,7 +923,6 @@ static int ScaleYUVToARGBBilinearUp(int src_width,
y += dy;
}
free_aligned_buffer_64(row);
- free_aligned_buffer_64(row_argb);
return 0;
}
#endif