mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-10-28 18:07:12 +08:00
ARGBToRGB565Dither fix for unaligned dither matrix
Copy dither4x4 (16 bytes) into an aligned local uint32_t dither4[4] array using memcpy and index using dither4[y & 3] to avoid unaligned 32-bit pointer dereference traps in fastbuild / UB sanitizers. Bug: None Test: LibYUVConvertTest.TestNoDither, LibYUVConvertTest.TestDither Change-Id: I4447cd2924b16739a9bce2792d57a550dedeb345 Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/8262354 Reviewed-by: richard winterton <rrwinterton@gmail.com> Commit-Queue: Frank Barchard <fbarchard@google.com> Reviewed-by: Wan-Teh Chang <wtc@google.com>
This commit is contained in:
parent
1dac06e8c0
commit
6fa5264292
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: https://chromium.googlesource.com/libyuv/libyuv/
|
||||
Version: 1958
|
||||
Version: 1959
|
||||
Revision: DEPS
|
||||
License: BSD-3-Clause
|
||||
License File: LICENSE
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1958
|
||||
#define LIBYUV_VERSION 1959
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <string.h> // For memcpy.
|
||||
|
||||
#include "libyuv/convert_from_argb.h"
|
||||
#include "libyuv/cpu_id.h"
|
||||
@ -6314,6 +6315,7 @@ int I420ToRGB565Dither(const uint8_t* src_y,
|
||||
int width,
|
||||
int height) {
|
||||
int y;
|
||||
uint32_t dither4[4];
|
||||
void (*I422ToARGBRow)(const uint8_t* y_buf, const uint8_t* u_buf,
|
||||
const uint8_t* v_buf, uint8_t* rgb_buf,
|
||||
const struct YuvConstants* yuvconstants, int width) =
|
||||
@ -6334,6 +6336,7 @@ int I420ToRGB565Dither(const uint8_t* src_y,
|
||||
if (!dither4x4) {
|
||||
dither4x4 = kDither565_4x4;
|
||||
}
|
||||
memcpy(dither4, dither4x4, 16);
|
||||
#if defined(HAS_I422TOARGBROW_SSSE3)
|
||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||
I422ToARGBRow = I422ToARGBRow_Any_SSSE3;
|
||||
@ -6450,9 +6453,7 @@ int I420ToRGB565Dither(const uint8_t* src_y,
|
||||
return 1;
|
||||
for (y = 0; y < height; ++y) {
|
||||
I422ToARGBRow(src_y, src_u, src_v, row_argb, &kYuvI601Constants, width);
|
||||
ARGBToRGB565DitherRow(row_argb, dst_rgb565,
|
||||
*(const uint32_t*)(dither4x4 + ((y & 3) << 2)),
|
||||
width);
|
||||
ARGBToRGB565DitherRow(row_argb, dst_rgb565, dither4[y & 3], width);
|
||||
dst_rgb565 += dst_stride_rgb565;
|
||||
src_y += src_stride_y;
|
||||
if (y & 1) {
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "libyuv/convert_from_argb.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h> // For memcpy.
|
||||
|
||||
#include "libyuv/basic_types.h"
|
||||
#include "libyuv/cpu_id.h"
|
||||
@ -1582,6 +1583,7 @@ int ARGBToRGB565Dither(const uint8_t* src_argb,
|
||||
int width,
|
||||
int height) {
|
||||
int y;
|
||||
uint32_t dither4[4];
|
||||
void (*ARGBToRGB565DitherRow)(const uint8_t* src_argb, uint8_t* dst_rgb,
|
||||
uint32_t dither4, int width) =
|
||||
ARGBToRGB565DitherRow_C;
|
||||
@ -1597,6 +1599,7 @@ int ARGBToRGB565Dither(const uint8_t* src_argb,
|
||||
if (!dither4x4) {
|
||||
dither4x4 = kDither565_4x4;
|
||||
}
|
||||
memcpy(dither4, dither4x4, 16);
|
||||
|
||||
#if defined(HAS_ARGBTORGB565DITHERROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
@ -1637,9 +1640,7 @@ int ARGBToRGB565Dither(const uint8_t* src_argb,
|
||||
#endif
|
||||
|
||||
for (y = 0; y < height; ++y) {
|
||||
ARGBToRGB565DitherRow(src_argb, dst_rgb565,
|
||||
*(const uint32_t*)(dither4x4 + ((y & 3) << 2)),
|
||||
width);
|
||||
ARGBToRGB565DitherRow(src_argb, dst_rgb565, dither4[y & 3], width);
|
||||
src_argb += src_stride_argb;
|
||||
dst_rgb565 += dst_stride_rgb565;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user