Allow use of external ffmpeg SDK

This commit is contained in:
Lukas Cone 2021-07-17 18:37:49 +02:00
parent 4681aecada
commit aa196055c2
5 changed files with 31 additions and 22 deletions

View File

@ -42,6 +42,24 @@ else()
option(BUILD_AUDACIOUS "Build Audacious plugin" ON)
endif()
if(USE_FFMPEG)
find_package(FFmpeg)
if(NOT FFMPEG_LIBRARIES)
set(USE_FFMPEG OFF)
else()
if(${AVCODEC_VERSION} VERSION_LESS 57)
set(USE_FFMPEG OFF)
message("libavcodec version mismatch ${AVCODEC_VERSION} expected >=57")
elseif(${AVUTIL_VERSION} VERSION_LESS 55)
set(USE_FFMPEG OFF)
message("libavutil version mismatch ${AVUTIL_VERSION} expected >=55")
elseif(${SWRESAMPLE_VERSION} VERSION_LESS 2)
set(USE_FFMPEG OFF)
message("libswresample version mismatch ${SWRESAMPLE_VERSION} expected >=2")
endif()
endif()
endif()
if(WIN32)
# Enable support for the resource compiler when using MinGW
if(MINGW)
@ -91,23 +109,6 @@ else()
set(USE_VORBIS OFF)
endif()
endif()
if(USE_FFMPEG)
find_package(FFmpeg)
if(NOT FFMPEG_LIBRARIES)
set(USE_FFMPEG OFF)
else()
if(${AVCODEC_VERSION} VERSION_LESS 57)
set(USE_FFMPEG OFF)
message("libavcodec version mismatch ${AVCODEC_VERSION} expected >=57")
elseif(${AVUTIL_VERSION} VERSION_LESS 55)
set(USE_FFMPEG OFF)
message("libavutil version mismatch ${AVUTIL_VERSION} expected >=55")
elseif(${SWRESAMPLE_VERSION} VERSION_LESS 2)
set(USE_FFMPEG OFF)
message("libswresample version mismatch ${SWRESAMPLE_VERSION} expected >=2")
endif()
endif()
endif()
# If building the CLI, we need to include AO as well
if(BUILD_CLI)

View File

@ -72,16 +72,24 @@ macro(find_component _component _pkgconfig _library _header)
HINTS
${PC_LIB${_component}_INCLUDEDIR}
${PC_LIB${_component}_INCLUDE_DIRS}
${FFMPEG_PATH}/include
PATH_SUFFIXES ffmpeg)
find_library(${_component}_LIBRARIES NAMES ${_library}
HINTS
${PC_LIB${_component}_LIBDIR}
${PC_LIB${_component}_LIBRARY_DIRS})
${PC_LIB${_component}_LIBRARY_DIRS}
${FFMPEG_PATH}/lib)
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
if(WIN32 AND NOT ${_component}_VERSION)
file(GLOB FOUND_DLL_ ${FFMPEG_PATH}/bin/${_library}*.dll)
string(REGEX MATCH ".*${_library}-(.+).dll" FOUND_DLL_ ${FOUND_DLL_})
set(${_component}_VERSION ${CMAKE_MATCH_1} CACHE STRING "The ${_component} version number." FORCE)
endif()
set_component_found(${_component})
mark_as_advanced(

View File

@ -56,7 +56,7 @@ macro(setup_target TARGET)
if(USE_FFMPEG)
target_compile_definitions(${TARGET} PRIVATE VGM_USE_FFMPEG)
if(WIN32)
if(WIN32 AND NOT FFMPEG_LIBRARIES)
target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/ext_includes/ffmpeg)
if(LINK)
add_dependencies(${TARGET} ffmpeg)

View File

@ -95,7 +95,7 @@ All of these options are of type BOOL and can be set to either `ON` or `OFF`. Mo
- **USE_FDKAAC**: Chooses if you wish to use FDK-AAC/QAAC for support of MP4 AAC. Note that this requires `QAAC_PATH` and `FDK_AAC_PATH` to also be given if the option is `ON`. The default for is `ON`. See the foobar2000 plugin section of [BUILD.md](BUILD.md) for more information on this.
- **USE_MPEG**: Chooses if you wish to use libmpg123 for support of MP1/MP2/MP3. The default is `ON`.
- **USE_VORBIS**: Chooses if you wish to use libvorbis for support of Vorbis. The default is `ON`.
- **USE_FFMPEG**: Chooses if you wish to use FFmpeg for support of many codecs. The default is `ON`.
- **USE_FFMPEG**: Chooses if you wish to use FFmpeg for support of many codecs. The default is `ON`. `FFMPEG_PATH` can also be given, so it can use official/external SDK instead of the one used in vgmstream project.
- **USE_MAIATRAC3PLUS**: Chooses if you wish to use MAIATRAC3+ for support of ATRAC3+. The default is `OFF`. It is not recommended to enable.
- **USE_G7221**: Chooses if you wish to use G7221 for support of ITU-T G.722.1 annex C. The default is `ON`.

View File

@ -37,7 +37,7 @@ if(MSVC)
SOURCES ${VGM_SOURCE_DIR}/ext_includes/g719.h)
endif()
if(USE_FFMPEG)
if(USE_FFMPEG AND NOT FFMPEG_LIBRARIES)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib ${CMAKE_CURRENT_BINARY_DIR}/avcodec.exp
COMMAND lib
ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/avcodec-vgmstream-58.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib
@ -144,7 +144,7 @@ elseif(MINGW)
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libg719_decode.lib)
endif()
if(USE_FFMPEG)
if(USE_FFMPEG AND NOT FFMPEG_LIBRARIES)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib
COMMAND ${DLLTOOL}
ARGS -d ${CMAKE_CURRENT_SOURCE_DIR}/avcodec-vgmstream-58.def -l ${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib -D avcodec-vgmstream-58.dll