Files
oak-editor/ffmpeg_bridge/CMakeLists.txt
T
Mike-Solar 3a3ead6fc0 app: route all FFmpeg access through the ffmpeg_bridge C API
Replace every direct FFmpeg call in the editor and the render worker
with the pure C ffmpeg_bridge API, wrapped in thin C++ adapters that
preserve the original interfaces:

- avframeptr.h: olive::AVFrame adapter around FBFrame handles
- ffmpegutils: format conversion helpers on FB_* constants; the int
  overload is renamed GetCompatibleBridgePixelFormat to avoid a silent
  overload-resolution trap with the PixelFormat enum
- ffmpegdecoder/ffmpegencoder: rewritten as handle-based adapters over
  FBDecoder/FBProbe/FBEncoder/FBScaler/FBResampler
- audioprocessor: FBAudioGraph push/pull adapter
- pluginrenderer/OliveClip: sws/pixdesc usage converted to FBScaler and
  fb_pix_fmt_* queries
- AudioParams/channel layouts are plain uint64_t masks everywhere

Build integration: the root project no longer links FFMPEG directly;
only ffmpeg_bridge does. Binaries resolve the bridge library at runtime
via @loader_path inside the macOS app bundle (copied there post-build)
and via $ORIGIN/../ffmpeg_bridge/bin on Linux; on Windows the DLL is
installed next to the executables, so packages on all three platforms
ship the bridge library.

ffmpeg_bridge gains the extra API the adapters need:
fb_frame_make_writable, fb_decoder_get_format_duration,
fb_resampler_convert_frame, FB_PIX_FMT_YUV440P, SRT validation in
fb_probe_read_subtitle_stream, packed/planar fixes in
fb_encoder_write_audio, and a component-size fix in
fb_pix_fmt_component_size.
2026-07-15 23:00:06 +08:00

109 lines
3.0 KiB
CMake

# Olive - Non-Linear Video Editor
# Copyright (C) 2022 Olive Team
# Modifications Copyright (C) 2025 mikesolar
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ffmpeg_bridge: a self-contained shared library that isolates all FFmpeg
# access behind a pure C API (see include/ffmpeg_bridge/ffmpeg_bridge.h).
# The editor and the render worker link only against this library.
find_package(FFMPEG 6.0 REQUIRED
COMPONENTS
avutil
avcodec
avformat
avfilter
swscale
swresample
)
add_library(ffmpeg_bridge SHARED
src/audiograph.cpp
src/decoder.cpp
src/encoder.cpp
src/frame.cpp
src/packet.cpp
src/probe.cpp
src/sws.cpp
src/swr.cpp
src/utils.cpp
src/internal.h
include/ffmpeg_bridge/ffmpeg_bridge.h
)
target_compile_features(ffmpeg_bridge PRIVATE cxx_std_17)
target_include_directories(ffmpeg_bridge
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE
${FFMPEG_INCLUDE_DIRS}
)
target_link_libraries(ffmpeg_bridge
PRIVATE
FFMPEG::avutil
FFMPEG::avcodec
FFMPEG::avformat
FFMPEG::avfilter
FFMPEG::swscale
FFMPEG::swresample
)
# Static FFmpeg (e.g. the Linux CI build) needs system libs for
# libavcodec/libavformat.
find_package(ZLIB REQUIRED)
target_link_libraries(ffmpeg_bridge PRIVATE ZLIB::ZLIB)
find_package(BZip2 REQUIRED)
target_link_libraries(ffmpeg_bridge PRIVATE BZip2::BZip2)
find_package(LibLZMA)
if (LIBLZMA_FOUND)
target_link_libraries(ffmpeg_bridge PRIVATE ${LIBLZMA_LIBRARIES})
endif()
target_compile_definitions(ffmpeg_bridge PRIVATE FFMPEG_BRIDGE_BUILD)
# Only export the FB_API functions
set_target_properties(ffmpeg_bridge PROPERTIES
C_VISIBILITY_PRESET hidden
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
# The shared library lives in its own directory outside of app/
set_target_properties(ffmpeg_bridge PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/ffmpeg_bridge/bin"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/ffmpeg_bridge/bin"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/ffmpeg_bridge/lib"
)
if (WIN32)
set_target_properties(ffmpeg_bridge PROPERTIES PREFIX "")
# Windows has no RPATH: the DLL must sit next to the executables
install(TARGETS ffmpeg_bridge
RUNTIME DESTINATION bin
LIBRARY DESTINATION bin
ARCHIVE DESTINATION ffmpeg_bridge/lib
)
else()
install(TARGETS ffmpeg_bridge
RUNTIME DESTINATION ffmpeg_bridge/bin
LIBRARY DESTINATION ffmpeg_bridge/bin
ARCHIVE DESTINATION ffmpeg_bridge/lib
)
endif ()