Fix #126394: ffmpeg on win64 is built without SIMD optimizations

Since ee1b2f53cc the ffmpeg libraries for Windows x64 are built effectively
without CPU specific SIMD optimizations. `--arch=x64` is not an architecture
that ffmpeg configure understands, so it falls back to "nothing is known,
turn any architecture specific bits off" code path.

Pull Request: https://projects.blender.org/blender/blender/pulls/126396
This commit is contained in:
Aras Pranckevicius
2024-08-22 10:36:18 +02:00
committed by Aras Pranckevicius
parent 9b903d4c6f
commit 246a0ec46a
4 changed files with 33 additions and 4 deletions

View File

@@ -118,7 +118,7 @@ if(WIN32)
else()
set(FFMPEG_EXTRA_FLAGS
${FFMPEG_EXTRA_FLAGS}
--arch=x64
--arch=x86_64
--target-os=win32
)
endif()

View File

@@ -1,10 +1,11 @@
# SPDX-FileCopyrightText: 2020 Blender Authors
# SPDX-FileCopyrightText: 2020-2024 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
if(WITH_GTESTS)
set(TEST_SRC
tests/ffmpeg_codecs.cc
tests/ffmpeg_cpu_flags.cc
)
set(TEST_INC
.
@@ -22,5 +23,5 @@ if(WITH_GTESTS)
if(WITH_IMAGE_OPENJPEG)
set(TEST_LIB ${TEST_LIB} ${OPENJPEG_LIBRARIES})
endif()
blender_add_test_suite_lib(ffmpeg_codecs "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}")
blender_add_test_suite_lib(ffmpeg_libs "${TEST_SRC}" "${TEST_INC}" "${TEST_INC_SYS}" "${TEST_LIB}")
endif()

View File

@@ -0,0 +1,28 @@
/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "testing/testing.h"
extern "C" {
#include <libavutil/cpu.h>
}
namespace ffmpeg::tests {
TEST(ffmpeg, correct_av_cpu_flags)
{
int flags = av_get_cpu_flags();
#if defined(_M_X64) || defined(__x86_64__)
/* x64 expected to have at least up to SSE4.2. */
EXPECT_TRUE((flags & AV_CPU_FLAG_SSE2) != 0);
EXPECT_TRUE((flags & AV_CPU_FLAG_SSE4) != 0);
EXPECT_TRUE((flags & AV_CPU_FLAG_SSE42) != 0);
#elif defined(__aarch64__) || defined(_M_ARM64)
/* arm64 expected to have at least NEON. */
EXPECT_TRUE((flags & AV_CPU_FLAG_ARMV8) != 0);
EXPECT_TRUE((flags & AV_CPU_FLAG_NEON) != 0);
#endif
}
} // namespace ffmpeg::tests

View File

@@ -48,7 +48,7 @@ elseif(APPLE)
foreach(_lib ${_test_libs})
# We need -force_load for every test library and target_link_libraries will
# deduplicate it. So explicitly set as linker option for every test lib.
target_link_libraries(blender_test PRIVATE ${_lib} "-Wl,-force_load,$<TARGET_PROPERTY:${_lib},IMPORTED_LOCATION>")
target_link_libraries(blender_test PRIVATE "-Wl,-force_load" ${_lib})
endforeach()
endif()