Bug 1951376 - apply patches 01-05 manually;r=chunmin

Differential Revision: https://phabricator.services.mozilla.com/D242261
This commit is contained in:
Nico Grunbaum
2025-04-10 03:10:59 +00:00
parent 35b53fa890
commit adea196294
3 changed files with 144 additions and 18 deletions

View File

@@ -29,6 +29,7 @@
'mips_msa%': 0, # Default to msa off. 'mips_msa%': 0, # Default to msa off.
'build_neon': 0, 'build_neon': 0,
'build_msa': 0, 'build_msa': 0,
'build_lsx': 0,
'conditions': [ 'conditions': [
['(target_arch == "armv7" or target_arch == "armv7s" or \ ['(target_arch == "armv7" or target_arch == "armv7s" or \
(target_arch == "arm" and arm_version >= 7) or target_arch == "arm64")\ (target_arch == "arm" and arm_version >= 7) or target_arch == "arm64")\
@@ -52,7 +53,7 @@
'optimize': 'max', # enable O2 and ltcg. 'optimize': 'max', # enable O2 and ltcg.
}, },
# Allows libyuv.a redistributable library without external dependencies. # Allows libyuv.a redistributable library without external dependencies.
'standalone_static_library': 1, # 'standalone_static_library': 1,
'conditions': [ 'conditions': [
# Disable -Wunused-parameter # Disable -Wunused-parameter
['clang == 1', { ['clang == 1', {
@@ -70,6 +71,9 @@
'-mfpu=vfpv3-d16', '-mfpu=vfpv3-d16',
# '-mthumb', # arm32 not thumb # '-mthumb', # arm32 not thumb
], ],
'cflags_mozilla!': [
'<@(moz_neon_cflags_block_list)',
],
'conditions': [ 'conditions': [
# Disable LTO in libyuv_neon target due to gcc 4.9 compiler bug. # Disable LTO in libyuv_neon target due to gcc 4.9 compiler bug.
['clang == 0 and use_lto == 1', { ['clang == 0 and use_lto == 1', {
@@ -78,13 +82,6 @@
'-ffat-lto-objects', '-ffat-lto-objects',
], ],
}], }],
# arm64 does not need -mfpu=neon option as neon is not optional
['target_arch != "arm64"', {
'cflags': [
'-mfpu=neon',
# '-marm', # arm32 not thumb
],
}],
], ],
}], }],
['build_msa != 0', { ['build_msa != 0', {
@@ -92,7 +89,24 @@
'LIBYUV_MSA', 'LIBYUV_MSA',
], ],
}], }],
['OS != "ios" and libyuv_disable_jpeg != 1', { ['build_lsx == 0', {
'conditions': [
['target_arch == "loongarch64"', {
'cflags_mozilla': [
'-mno-lsx',
],
}],
],
}],
['build_with_mozilla == 1', {
'defines': [
'HAVE_JPEG'
],
'cflags_mozilla': [
'$(MOZ_JPEG_CFLAGS)',
],
}],
['OS != "ios" and libyuv_disable_jpeg != 1 and build_with_mozilla != 1', {
'defines': [ 'defines': [
'HAVE_JPEG' 'HAVE_JPEG'
], ],
@@ -118,6 +132,7 @@
}], }],
], #conditions ], #conditions
'defines': [ 'defines': [
'LIBYUV_DISABLE_SME',
# Enable the following 3 macros to turn off assembly for specified CPU. # Enable the following 3 macros to turn off assembly for specified CPU.
# 'LIBYUV_DISABLE_X86', # 'LIBYUV_DISABLE_X86',
# 'LIBYUV_DISABLE_NEON', # 'LIBYUV_DISABLE_NEON',
@@ -146,12 +161,105 @@
'-Wl,--dynamic-linker,/system/bin/linker', '-Wl,--dynamic-linker,/system/bin/linker',
], ],
}], }],
['target_arch == "armv7" or target_arch == "arm64" and moz_have_arm_i8mm_and_dot_prod == 1 and build_with_mozilla == 1', {
'dependencies': [
':libyuv_neon',
],
}],
['target_arch == "arm64" and moz_have_arm_sve2 == 1 and build_with_mozilla == 1', {
'dependencies': [
':libyuv_sve',
],
'defines' :[
'LIBYUV_SVE',
]
}],
['target_arch == "arm64" and moz_have_arm_sve2 == 1 and build_with_mozilla == 1', {
'dependencies': [
':libyuv_sve',
],
'defines' :[
'LIBYUV_SVE',
]
}],
], #conditions ], #conditions
}, },
'sources': [ 'sources': [
'<@(libyuv_sources)', '<@(libyuv_sources)',
], ],
}, },
{
'target_name': 'libyuv_neon',
'type': 'static_library',
'variables': {
'optimize': 'max', # enable O2 and ltcg.
},
'conditions': [
['target_arch == "arm64" and moz_have_arm_i8mm_and_dot_prod == 1 and build_with_mozilla == 1', {
'cflags_mozilla': [
'-march=armv8.2-a+dotprod+i8mm',
],
}],
# arm64 does not need -mfpu=neon option as neon is not optional
['target_arch != "arm64"', {
'cflags': [
'-mfpu=neon',
# '-marm', # arm32 not thumb
],
'cflags_mozilla': [
'-mfpu=neon',
],
}],
['build_neon != 0', {
'cflags_mozilla!': [
'<@(moz_neon_cflags_block_list)',
],
'sources': [
'<@(libyuv_neon_sources)',
],
}],
], #conditions
'include_dirs': [
'include',
'.',
],
'direct_dependent_settings': {
'include_dirs': [
'include',
'.',
], #conditions
},
},
{
'target_name': 'libyuv_sve',
'type': 'static_library',
'variables': {
'optimize': 'max', # enable O2 and ltcg.
},
'conditions': [
['target_arch == "arm64" and moz_have_arm_sve2 == 1 and build_with_mozilla == 1', {
'cflags_mozilla!': [
'<@(moz_neon_cflags_block_list)',
],
'cflags_mozilla': [
'-march=armv9-a+dotprod+sve2+i8mm',
],
'sources': [
'<@(libyuv_sve_sources)',
],
}],
], #conditions
'include_dirs': [
'include',
'.',
],
'direct_dependent_settings': {
'include_dirs': [
'include',
'.',
], #conditions
},
},
], # targets. ], # targets.
} }

View File

@@ -8,6 +8,29 @@
{ {
'variables': { 'variables': {
'moz_have_arm_sve2%': '<(moz_have_arm_sve2)',
'moz_have_arm_i8mm_and_dot_prod%': '<(moz_have_arm_i8mm_and_dot_prod)',
'moz_neon_cflags_block_list': [
'-mfpu=vfp',
'-mfpu=vfpv3',
'-mfpu=vfpv3-d16',
],
# Needs to be reflected in upstream gyp file.
'libyuv_sve_sources': [
# sources.
'source/row_sve.cc',
],
'libyuv_neon_sources': [
# ARM Source Files
"source/compare_neon.cc",
"source/compare_neon64.cc",
"source/rotate_neon.cc",
"source/rotate_neon64.cc",
"source/row_neon.cc",
"source/row_neon64.cc",
"source/scale_neon.cc",
"source/scale_neon64.cc",
],
'libyuv_sources': [ 'libyuv_sources': [
# includes. # includes.
'include/libyuv.h', 'include/libyuv.h',
@@ -40,8 +63,6 @@
'source/compare_common.cc', 'source/compare_common.cc',
'source/compare_gcc.cc', 'source/compare_gcc.cc',
'source/compare_msa.cc', 'source/compare_msa.cc',
'source/compare_neon.cc',
'source/compare_neon64.cc',
'source/compare_win.cc', 'source/compare_win.cc',
'source/convert.cc', 'source/convert.cc',
'source/convert_argb.cc', 'source/convert_argb.cc',
@@ -60,15 +81,11 @@
'source/rotate_common.cc', 'source/rotate_common.cc',
'source/rotate_gcc.cc', 'source/rotate_gcc.cc',
'source/rotate_msa.cc', 'source/rotate_msa.cc',
'source/rotate_neon.cc',
'source/rotate_neon64.cc',
'source/rotate_win.cc', 'source/rotate_win.cc',
'source/row_any.cc', 'source/row_any.cc',
'source/row_common.cc', 'source/row_common.cc',
'source/row_gcc.cc', 'source/row_gcc.cc',
'source/row_msa.cc', 'source/row_msa.cc',
'source/row_neon.cc',
'source/row_neon64.cc',
'source/row_win.cc', 'source/row_win.cc',
'source/scale.cc', 'source/scale.cc',
'source/scale_any.cc', 'source/scale_any.cc',
@@ -76,8 +93,6 @@
'source/scale_common.cc', 'source/scale_common.cc',
'source/scale_gcc.cc', 'source/scale_gcc.cc',
'source/scale_msa.cc', 'source/scale_msa.cc',
'source/scale_neon.cc',
'source/scale_neon64.cc',
'source/scale_rgb.cc', 'source/scale_rgb.cc',
'source/scale_uv.cc', 'source/scale_uv.cc',
'source/scale_win.cc', 'source/scale_win.cc',

View File

@@ -78,7 +78,9 @@ MJpegDecoder::MJpegDecoder()
decompress_struct_->err = jpeg_std_error(&error_mgr_->base); decompress_struct_->err = jpeg_std_error(&error_mgr_->base);
// Override standard exit()-based error handler. // Override standard exit()-based error handler.
error_mgr_->base.error_exit = &ErrorHandler; error_mgr_->base.error_exit = &ErrorHandler;
#ifndef DEBUG_MJPEG
error_mgr_->base.output_message = &OutputHandler; error_mgr_->base.output_message = &OutputHandler;
#endif
#endif #endif
decompress_struct_->client_data = NULL; decompress_struct_->client_data = NULL;
source_mgr_->init_source = &init_source; source_mgr_->init_source = &init_source;
@@ -462,11 +464,12 @@ void ErrorHandler(j_common_ptr cinfo) {
longjmp(mgr->setjmp_buffer, 1); longjmp(mgr->setjmp_buffer, 1);
} }
#ifndef DEBUG_MJPEG
// Suppress fprintf warnings. // Suppress fprintf warnings.
void OutputHandler(j_common_ptr cinfo) { void OutputHandler(j_common_ptr cinfo) {
(void)cinfo; (void)cinfo;
} }
#endif
#endif // HAVE_SETJMP #endif // HAVE_SETJMP
void MJpegDecoder::AllocOutputBuffers(int num_outbufs) { void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {