mirror of
https://chromium.googlesource.com/libyuv/libyuv
synced 2026-06-15 00:16:08 +08:00
Refactored RGB/RAW to YUV color conversion functions to use generic Matrix-based functions parameterized by ArgbConstants.
This consolidation standardizes conversion logic, improves code
maintainability, and provides flexible support for various color spaces
(e.g., BT.601, JPEG full
range).
Key Modifications:
- Function Consolidation: Refactored several high-level conversion functions into lightweight wrappers around generic Matrix variants:
- ARGBToI420 → ARGBToI420Matrix
- ARGBToI444 → ARGBToI444Matrix
- ARGBToI422 → ARGBToI422Matrix
- ARGBToNV12 → ARGBToNV12Matrix
- RAWToJ400, RGB24ToJ400 → RGBToI400Matrix
- RAWToI444, RAWToJ444 → RGBToI444Matrix
- 2-Pass Conversions: Updated RGB565ToI420, ARGB1555ToI420, and ARGB4444ToI420 to utilize 2-pass conversions via RGBToI420Matrix.
- Standardization: Refactored ARGBToNV21, ARGBToYUY2, and ARGBToUYVY to use parameterized matrix row functions (ARGBToYMatrixRow,
ARGBToUVMatrixRow).
- Legacy Cleanup: Replaced legacy calls to ARGBToYJRow with the parameterized ARGBToYMatrixRow in the ARGBSobelize helper.
- Internal Integration: Included libyuv/convert_from_argb.h in planar_functions.cc and ensured all new matrix symbols are properly
declared/exported (LIBYUV_API).
Bug: libyuv:42280902
Change-Id: Ied5fd9899767427e3a03cdcfbeaff3e9d502374a
Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/7822033
Reviewed-by: richard winterton <rrwinterton@gmail.com>
Commit-Queue: Frank Barchard <fbarchard@google.com>
This commit is contained in:
parent
8773064a72
commit
4aacbbdfb4
@ -1,6 +1,6 @@
|
||||
Name: libyuv
|
||||
URL: https://chromium.googlesource.com/libyuv/libyuv/
|
||||
Version: 1935
|
||||
Version: 1936
|
||||
Revision: DEPS
|
||||
License: BSD-3-Clause
|
||||
License File: LICENSE
|
||||
|
||||
@ -458,7 +458,7 @@ int ARGBToUYVY(const uint8_t* src_argb,
|
||||
|
||||
// RAW to NV21 with Matrix
|
||||
LIBYUV_API
|
||||
int RAWToNV21Matrix(const uint8_t* src_raw,
|
||||
int RGBToNV21Matrix(const uint8_t* src_raw,
|
||||
int src_stride_raw,
|
||||
uint8_t* dst_y,
|
||||
int dst_stride_y,
|
||||
|
||||
@ -11,6 +11,6 @@
|
||||
#ifndef INCLUDE_LIBYUV_VERSION_H_
|
||||
#define INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
#define LIBYUV_VERSION 1935
|
||||
#define LIBYUV_VERSION 1936
|
||||
|
||||
#endif // INCLUDE_LIBYUV_VERSION_H_
|
||||
|
||||
2532
source/convert.cc
2532
source/convert.cc
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -15,10 +15,12 @@
|
||||
|
||||
#include "libyuv/cpu_id.h"
|
||||
#include "libyuv/row.h"
|
||||
#include "libyuv/convert_from_argb.h"
|
||||
#include "libyuv/scale_row.h" // for ScaleRowDown2
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace libyuv {
|
||||
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
@ -4743,8 +4745,8 @@ static int ARGBSobelize(const uint8_t* src_argb,
|
||||
uint8_t* dst,
|
||||
int width)) {
|
||||
int y;
|
||||
void (*ARGBToYJRow)(const uint8_t* src_argb, uint8_t* dst_g, int width) =
|
||||
ARGBToYJRow_C;
|
||||
void (*ARGBToYMatrixRow)(const uint8_t* src_argb, uint8_t* dst_y, int width,
|
||||
const struct ArgbConstants* c) = ARGBToYMatrixRow_C;
|
||||
void (*SobelYRow)(const uint8_t* src_y0, const uint8_t* src_y1,
|
||||
uint8_t* dst_sobely, int width) = SobelYRow_C;
|
||||
void (*SobelXRow)(const uint8_t* src_y0, const uint8_t* src_y1,
|
||||
@ -4761,57 +4763,65 @@ static int ARGBSobelize(const uint8_t* src_argb,
|
||||
src_stride_argb = -src_stride_argb;
|
||||
}
|
||||
|
||||
#if defined(HAS_ARGBTOYJROW_SSSE3)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_SSSE3)
|
||||
if (TestCpuFlag(kCpuHasSSSE3)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_SSSE3;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_SSSE3;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBToYJRow = ARGBToYJRow_SSSE3;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_SSSE3;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYJROW_AVX2)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_AVX2)
|
||||
if (TestCpuFlag(kCpuHasAVX2)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_AVX2;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_AVX2;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
ARGBToYJRow = ARGBToYJRow_AVX2;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_AVX2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYROW_AVX512BW)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_AVX512BW)
|
||||
if (TestCpuFlag(kCpuHasAVX512BW)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_AVX512BW;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_AVX512BW;
|
||||
if (IS_ALIGNED(width, 64)) {
|
||||
ARGBToYJRow = ARGBToYJRow_AVX512BW;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_AVX512BW;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYJROW_NEON)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_NEON)
|
||||
if (TestCpuFlag(kCpuHasNEON)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_NEON;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_NEON;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBToYJRow = ARGBToYJRow_NEON;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_NEON;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYJROW_LSX)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_NEON_DOTPROD)
|
||||
if (TestCpuFlag(kCpuHasNeonDotProd)) {
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_NEON_DotProd;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_NEON_DotProd;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_LSX)
|
||||
if (TestCpuFlag(kCpuHasLSX)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_LSX;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_LSX;
|
||||
if (IS_ALIGNED(width, 16)) {
|
||||
ARGBToYJRow = ARGBToYJRow_LSX;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_LSX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYJROW_LASX)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_LASX)
|
||||
if (TestCpuFlag(kCpuHasLASX)) {
|
||||
ARGBToYJRow = ARGBToYJRow_Any_LASX;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_Any_LASX;
|
||||
if (IS_ALIGNED(width, 32)) {
|
||||
ARGBToYJRow = ARGBToYJRow_LASX;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_LASX;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAS_ARGBTOYJROW_RVV)
|
||||
#if defined(HAS_ARGBTOYMATRIXROW_RVV)
|
||||
if (TestCpuFlag(kCpuHasRVV)) {
|
||||
ARGBToYJRow = ARGBToYJRow_RVV;
|
||||
ARGBToYMatrixRow = ARGBToYMatrixRow_RVV;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4849,10 +4859,10 @@ static int ARGBSobelize(const uint8_t* src_argb,
|
||||
uint8_t* row_y2 = row_y1 + row_size;
|
||||
if (!rows)
|
||||
return 1;
|
||||
ARGBToYJRow(src_argb, row_y0, width);
|
||||
ARGBToYMatrixRow(src_argb, row_y0, width, &kArgbJPEGConstants);
|
||||
row_y0[-1] = row_y0[0];
|
||||
memset(row_y0 + width, row_y0[width - 1], 16); // Extrude 16 for valgrind.
|
||||
ARGBToYJRow(src_argb, row_y1, width);
|
||||
ARGBToYMatrixRow(src_argb, row_y1, width, &kArgbJPEGConstants);
|
||||
row_y1[-1] = row_y1[0];
|
||||
memset(row_y1 + width, row_y1[width - 1], 16);
|
||||
memset(row_y2 + width, 0, 16);
|
||||
@ -4862,7 +4872,7 @@ static int ARGBSobelize(const uint8_t* src_argb,
|
||||
if (y < (height - 1)) {
|
||||
src_argb += src_stride_argb;
|
||||
}
|
||||
ARGBToYJRow(src_argb, row_y2, width);
|
||||
ARGBToYMatrixRow(src_argb, row_y2, width, &kArgbJPEGConstants);
|
||||
row_y2[-1] = row_y2[0];
|
||||
row_y2[width] = row_y2[width - 1];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user