mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
ffmpeg: Improved fix for checking if const AVCodec* is necessary
This commit is contained in:
parent
f65c84f4cb
commit
930b7f644d
@ -116,6 +116,7 @@ if(NOT IOS)
|
|||||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/sdl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")
|
add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/")
|
||||||
@ -953,6 +954,23 @@ if(USE_FFMPEG)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale)
|
find_package(FFmpeg REQUIRED avcodec avformat avutil swresample swscale)
|
||||||
|
# Check if we need to use avcodec_(alloc|free)_frame instead of av_frame_(alloc|free)
|
||||||
|
# Check if we need to use const AVCodec
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES avcodec;avformat)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "-pedantic -Wall -Werror -Wno-unused-variable")
|
||||||
|
check_cxx_source_compiles("extern \"C\" {
|
||||||
|
#include <libavcodec/avcodec.h>
|
||||||
|
#include <libavformat/avformat.h>
|
||||||
|
}
|
||||||
|
static AVCodecContext *s_codec_context = NULL;
|
||||||
|
int main() {
|
||||||
|
const AVCodec *codec = avcodec_find_encoder(s_codec_context->codec_id);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
" HAVE_LIBAVCODEC_CONST_AVCODEC FAIL_REGEX "invalid conversion")
|
||||||
|
|
||||||
|
# Check if we need to use avcodec_alloc_context3 instead of stream->codec
|
||||||
|
# Check if we need to use av_frame_get_buffer instead of avcodec_default_get_buffer
|
||||||
endif(USE_FFMPEG)
|
endif(USE_FFMPEG)
|
||||||
|
|
||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
@ -2024,6 +2042,7 @@ add_library(${CoreLibName} ${CoreLinkType}
|
|||||||
Core/ELF/PrxDecrypter.h
|
Core/ELF/PrxDecrypter.h
|
||||||
Core/ELF/ParamSFO.cpp
|
Core/ELF/ParamSFO.cpp
|
||||||
Core/ELF/ParamSFO.h
|
Core/ELF/ParamSFO.h
|
||||||
|
Core/FFMPEGCompat.h
|
||||||
Core/FileSystems/tlzrc.cpp
|
Core/FileSystems/tlzrc.cpp
|
||||||
Core/FileSystems/BlobFileSystem.cpp
|
Core/FileSystems/BlobFileSystem.cpp
|
||||||
Core/FileSystems/BlobFileSystem.h
|
Core/FileSystems/BlobFileSystem.h
|
||||||
@ -2358,6 +2377,9 @@ target_compile_features(${CoreLibName} PUBLIC cxx_std_17)
|
|||||||
|
|
||||||
if(FFmpeg_FOUND)
|
if(FFmpeg_FOUND)
|
||||||
target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1)
|
target_compile_definitions(${CoreLibName} PRIVATE USE_FFMPEG=1)
|
||||||
|
if (HAVE_LIBAVCODEC_CONST_AVCODEC)
|
||||||
|
target_compile_definitions(${CoreLibName} PRIVATE HAVE_LIBAVCODEC_CONST_AVCODEC=1)
|
||||||
|
endif()
|
||||||
set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
|
set_target_properties(${CoreLibName} PROPERTIES NO_SYSTEM_FROM_IMPORTED true)
|
||||||
target_include_directories(${CoreLibName} BEFORE PUBLIC ${FFmpeg_INCLUDE_avcodec})
|
target_include_directories(${CoreLibName} BEFORE PUBLIC ${FFmpeg_INCLUDE_avcodec})
|
||||||
target_link_libraries(${CoreLibName}
|
target_link_libraries(${CoreLibName}
|
||||||
|
@ -45,9 +45,7 @@ extern "C" {
|
|||||||
#define av_frame_free avcodec_free_frame
|
#define av_frame_free avcodec_free_frame
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
|
#include "FFMPEGCompat.h"
|
||||||
#define AVCodec const AVCodec
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static AVFormatContext *s_format_context = nullptr;
|
static AVFormatContext *s_format_context = nullptr;
|
||||||
static AVCodecContext *s_codec_context = nullptr;
|
static AVCodecContext *s_codec_context = nullptr;
|
||||||
|
8
Core/FFMPEGCompat.h
Normal file
8
Core/FFMPEGCompat.h
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#ifndef FFMPEG_COMPAT_H
|
||||||
|
#define FFMPEG_COMPAT_H
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBAVCODEC_CONST_AVCODEC
|
||||||
|
#define AVCodec const AVCodec
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // FFMPEG_COMPAT_H
|
@ -129,10 +129,7 @@ extern "C" {
|
|||||||
#include "libavcodec/avcodec.h"
|
#include "libavcodec/avcodec.h"
|
||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
}
|
}
|
||||||
|
#include "Core/FFMPEGCompat.h"
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
|
|
||||||
#define AVCodec const AVCodec
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // USE_FFMPEG
|
#endif // USE_FFMPEG
|
||||||
|
|
||||||
|
@ -113,9 +113,7 @@ extern "C" {
|
|||||||
#include "libswscale/swscale.h"
|
#include "libswscale/swscale.h"
|
||||||
#include "libavcodec/avcodec.h"
|
#include "libavcodec/avcodec.h"
|
||||||
}
|
}
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
|
#include "Core/FFMPEGCompat.h"
|
||||||
#define AVCodec const AVCodec
|
|
||||||
#endif
|
|
||||||
static AVPixelFormat pmp_want_pix_fmt;
|
static AVPixelFormat pmp_want_pix_fmt;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,9 +56,7 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef USE_FFMPEG
|
#ifdef USE_FFMPEG
|
||||||
|
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
|
#include "Core/FFMPEGCompat.h"
|
||||||
#define AVCodec const AVCodec
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static AVPixelFormat getSwsFormat(int pspFormat)
|
static AVPixelFormat getSwsFormat(int pspFormat)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ extern "C" {
|
|||||||
#include "libavutil/samplefmt.h"
|
#include "libavutil/samplefmt.h"
|
||||||
#include "libavcodec/avcodec.h"
|
#include "libavcodec/avcodec.h"
|
||||||
}
|
}
|
||||||
|
#include "Core/FFMPEGCompat.h"
|
||||||
|
|
||||||
#endif // USE_FFMPEG
|
#endif // USE_FFMPEG
|
||||||
|
|
||||||
|
@ -33,10 +33,6 @@ extern "C" {
|
|||||||
#include "libavutil/version.h"
|
#include "libavutil/version.h"
|
||||||
};
|
};
|
||||||
|
|
||||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
|
|
||||||
#define AVCodec const AVCodec
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Wraps FFMPEG for audio decoding in a nice interface.
|
// Wraps FFMPEG for audio decoding in a nice interface.
|
||||||
@ -90,6 +86,9 @@ private:
|
|||||||
int wanted_resample_freq; // wanted resampling rate/frequency
|
int wanted_resample_freq; // wanted resampling rate/frequency
|
||||||
|
|
||||||
AVFrame *frame_;
|
AVFrame *frame_;
|
||||||
|
#if HAVE_LIBAVCODEC_CONST_AVCODEC // USE_FFMPEG is implied
|
||||||
|
const
|
||||||
|
#endif
|
||||||
AVCodec *codec_;
|
AVCodec *codec_;
|
||||||
AVCodecContext *codecCtx_;
|
AVCodecContext *codecCtx_;
|
||||||
SwrContext *swrCtx_;
|
SwrContext *swrCtx_;
|
||||||
|
Loading…
Reference in New Issue
Block a user