Update ffmpeg 2.1.3 -> 5.0.1
Old ffmpeg has a lot of vulnerabilities that have been fixed in newer versions, see https://www.cvedetails.com/vulnerability-list/vendor_id-3611/Ffmpeg.html.
This commit is contained in:
+12
-18
@@ -152,13 +152,6 @@ set_target_properties("${SM_EXE_NAME}"
|
||||
OUTPUT_NAME_MINSIZEREL "${SM_NAME_MINSIZEREL}"
|
||||
OUTPUT_NAME_RELWITHDEBINFO "${SM_NAME_RELWITHDEBINFO}")
|
||||
|
||||
list(APPEND SM_WINDOWS_PROGRAM_DLLS
|
||||
"${SM_PROGRAM_DIR}/avcodec-55.dll"
|
||||
"${SM_PROGRAM_DIR}/avformat-55.dll"
|
||||
"${SM_PROGRAM_DIR}/avutil-52.dll"
|
||||
"${SM_PROGRAM_DIR}/parallel_lights_io.dll"
|
||||
"${SM_PROGRAM_DIR}/swscale-2.dll")
|
||||
|
||||
if(WIN32)
|
||||
target_compile_definitions("${SM_EXE_NAME}" PRIVATE WINDOWS)
|
||||
target_compile_definitions("${SM_EXE_NAME}" PRIVATE _WINDOWS) # TODO: Remove this potential duplicate.
|
||||
@@ -478,7 +471,7 @@ if(WIN32)
|
||||
"setupapi.lib"
|
||||
"hid.lib")
|
||||
|
||||
sm_add_link_flag("${SM_EXE_NAME}" "/LIBPATH:\"${SM_EXTERN_DIR}/ffmpeg/${SM_WIN32_ARCH}/lib\"")
|
||||
sm_add_link_flag("${SM_EXE_NAME}" "/LIBPATH:\"${SM_EXTERN_DIR}/ffmpeg-w32/${SM_WIN32_ARCH}\"")
|
||||
sm_add_link_flag("${SM_EXE_NAME}"
|
||||
"/LIBPATH:\"${SM_SRC_DIR}/archutils/Win32/ddk/${SM_WIN32_ARCH}\"")
|
||||
sm_add_link_flag("${SM_EXE_NAME}" "/ERRORREPORT:SEND")
|
||||
@@ -522,7 +515,10 @@ elseif(APPLE)
|
||||
"${SM_FFMPEG_LIB}/libavformat.a"
|
||||
"${SM_FFMPEG_LIB}/libavcodec.a"
|
||||
"${SM_FFMPEG_LIB}/libswscale.a"
|
||||
"${SM_FFMPEG_LIB}/libavutil.a")
|
||||
"${SM_FFMPEG_LIB}/libavutil.a"
|
||||
"${MAC_FRAME_COREMEDIA}"
|
||||
"${MAC_FRAME_COREVIDEO}"
|
||||
"${MAC_FRAME_VIDEOTOOLBOX}")
|
||||
endif()
|
||||
else() # Unix / Linux TODO: Remember to find and locate the zip archive files.
|
||||
if(HAS_FFMPEG)
|
||||
@@ -545,8 +541,9 @@ else() # Unix / Linux TODO: Remember to find and locate the zip archive files.
|
||||
list(APPEND SMDATA_LINK_LIB "zlib")
|
||||
endif()
|
||||
|
||||
if(VA_FOUND)
|
||||
if(NOT WITH_SYSTEM_FFMPEG)
|
||||
list(APPEND SMDATA_LINK_LIB ${VA_LIBRARY})
|
||||
list(APPEND SMDATA_LINK_LIB ${VA_DRM_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -635,7 +632,7 @@ if(NOT APPLE)
|
||||
"${SM_EXTERN_DIR}/newvorbis/lib"
|
||||
"${SM_EXTERN_DIR}/newvorbis/include")
|
||||
endif()
|
||||
list(APPEND SM_INCLUDE_DIRS "${SM_EXTERN_DIR}/ffmpeg/include")
|
||||
list(APPEND SM_INCLUDE_DIRS "${SM_EXTERN_DIR}/ffmpeg-w32/include")
|
||||
else()
|
||||
if(WITH_OGG AND NOT WITH_SYSTEM_OGG)
|
||||
list(APPEND SM_INCLUDE_DIRS "${SM_EXTERN_DIR}/vorbis")
|
||||
@@ -705,21 +702,18 @@ if(NOT APPLE)
|
||||
install(FILES "${SM_PROGRAM_DIR}/Texture Font Generator.exe"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
endif()
|
||||
install(FILES "${SM_PROGRAM_DIR}/avcodec-55.dll"
|
||||
install(FILES "${SM_PROGRAM_DIR}/avcodec-59.dll"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
install(FILES "${SM_PROGRAM_DIR}/avformat-55.dll"
|
||||
install(FILES "${SM_PROGRAM_DIR}/avformat-59.dll"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
install(FILES "${SM_PROGRAM_DIR}/avutil-52.dll"
|
||||
install(FILES "${SM_PROGRAM_DIR}/avutil-57.dll"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
install(FILES "${SM_PROGRAM_DIR}/parallel_lights_io.dll"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
install(FILES "${SM_PROGRAM_DIR}/swscale-2.dll"
|
||||
install(FILES "${SM_PROGRAM_DIR}/swscale-6.dll"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
install(FILES "${SM_PROGRAM_DIR}/ITGmania.vdi"
|
||||
DESTINATION "${SM_FULL_INSTALLATION_PATH}")
|
||||
|
||||
# foreach(SM_WINDOW_DLL "${SM_WINDOWS_PROGRAM_DLLS}") install(FILES
|
||||
# "${SM_WINDOW_DLL}" DESTINATION "${SM_INSTALL_DESTINATION}") endforeach()
|
||||
else()
|
||||
install(TARGETS "${SM_EXE_NAME}" DESTINATION "${SM_INSTALL_DESTINATION}")
|
||||
endif()
|
||||
|
||||
@@ -121,7 +121,7 @@ MovieDecoder_FFMpeg::~MovieDecoder_FFMpeg()
|
||||
{
|
||||
if( m_iCurrentPacketOffset != -1 )
|
||||
{
|
||||
avcodec::av_free_packet( &m_Packet );
|
||||
avcodec::av_packet_unref( &m_Packet );
|
||||
m_iCurrentPacketOffset = -1;
|
||||
}
|
||||
if (m_swsctx)
|
||||
@@ -129,23 +129,21 @@ MovieDecoder_FFMpeg::~MovieDecoder_FFMpeg()
|
||||
avcodec::sws_freeContext(m_swsctx);
|
||||
m_swsctx = nullptr;
|
||||
}
|
||||
if (m_avioContext != nullptr )
|
||||
{
|
||||
RageFile *file = (RageFile *)m_avioContext->opaque;
|
||||
file->Close();
|
||||
delete file;
|
||||
avcodec::av_free(m_avioContext);
|
||||
}
|
||||
if ( m_buffer != nullptr )
|
||||
{
|
||||
avcodec::av_free(m_buffer);
|
||||
}
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||
if (m_avioContext != nullptr )
|
||||
{
|
||||
RageFile *file = (RageFile *)m_avioContext->opaque;
|
||||
file->Close();
|
||||
delete file;
|
||||
avcodec::av_free(m_avioContext);
|
||||
}
|
||||
if ( m_buffer != nullptr )
|
||||
{
|
||||
avcodec::av_free(m_buffer);
|
||||
}
|
||||
if ( m_pStreamCodec != nullptr)
|
||||
{
|
||||
avcodec::avcodec_free_context(&m_pStreamCodec);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MovieDecoder_FFMpeg::Init()
|
||||
@@ -162,7 +160,7 @@ void MovieDecoder_FFMpeg::Init()
|
||||
|
||||
if( m_iCurrentPacketOffset != -1 )
|
||||
{
|
||||
avcodec::av_free_packet( &m_Packet );
|
||||
avcodec::av_packet_unref( &m_Packet );
|
||||
m_iCurrentPacketOffset = -1;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +225,7 @@ int MovieDecoder_FFMpeg::ReadPacket()
|
||||
if( m_iCurrentPacketOffset != -1 )
|
||||
{
|
||||
m_iCurrentPacketOffset = -1;
|
||||
avcodec::av_free_packet( &m_Packet );
|
||||
avcodec::av_packet_unref( &m_Packet );
|
||||
}
|
||||
|
||||
int ret = avcodec::av_read_frame( m_fctx, &m_Packet );
|
||||
@@ -248,7 +246,7 @@ int MovieDecoder_FFMpeg::ReadPacket()
|
||||
}
|
||||
|
||||
/* It's not for the video stream; ignore it. */
|
||||
avcodec::av_free_packet( &m_Packet );
|
||||
avcodec::av_packet_unref( &m_Packet );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,16 +276,9 @@ int MovieDecoder_FFMpeg::DecodePacket( float fTargetTime )
|
||||
/* Hack: we need to send size = 0 to flush frames at the end, but we have
|
||||
* to give it a buffer to read from since it tries to read anyway. */
|
||||
m_Packet.data = m_Packet.size ? m_Packet.data : nullptr;
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
len = avcodec::avcodec_decode_video2(
|
||||
m_pStreamCodec,
|
||||
m_Frame, &iGotFrame,
|
||||
&m_Packet );
|
||||
#else
|
||||
len = m_Packet.size;
|
||||
avcodec::avcodec_send_packet(m_pStreamCodec, &m_Packet);
|
||||
iGotFrame = !avcodec::avcodec_receive_frame(m_pStreamCodec, m_Frame);
|
||||
#endif
|
||||
|
||||
if( len < 0 )
|
||||
{
|
||||
@@ -346,15 +337,9 @@ int MovieDecoder_FFMpeg::DecodePacket( float fTargetTime )
|
||||
|
||||
void MovieDecoder_FFMpeg::GetFrame( RageSurface *pSurface )
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
avcodec::AVPicture pict;
|
||||
pict.data[0] = (unsigned char *) pSurface->pixels;
|
||||
pict.linesize[0] = pSurface->pitch;
|
||||
#else
|
||||
avcodec::AVFrame pict;
|
||||
pict.data[0] = (unsigned char *) pSurface->pixels;
|
||||
pict.linesize[0] = pSurface->pitch;
|
||||
#endif
|
||||
|
||||
/* XXX 1: Do this in one of the Open() methods instead?
|
||||
* XXX 2: The problem of doing this in Open() is that m_AVTexfmt is not
|
||||
@@ -396,19 +381,6 @@ static RString averr_ssprintf( int err, const char *fmt, ... )
|
||||
return s + " (" + Error + ")";
|
||||
}
|
||||
|
||||
void MovieTexture_FFMpeg::RegisterProtocols()
|
||||
{
|
||||
static bool Done = false;
|
||||
if( Done )
|
||||
return;
|
||||
Done = true;
|
||||
|
||||
#if !FF_API_NEXT
|
||||
avcodec::avcodec_register_all();
|
||||
avcodec::av_register_all();
|
||||
#endif
|
||||
}
|
||||
|
||||
static int AVIORageFile_ReadPacket( void *opaque, uint8_t *buf, int buf_size )
|
||||
{
|
||||
RageFile *f = (RageFile *)opaque;
|
||||
@@ -432,8 +404,6 @@ static int64_t AVIORageFile_Seek( void *opaque, int64_t offset, int whence )
|
||||
|
||||
RString MovieDecoder_FFMpeg::Open( RString sFile )
|
||||
{
|
||||
MovieTexture_FFMpeg::RegisterProtocols();
|
||||
|
||||
m_fctx = avcodec::avformat_alloc_context();
|
||||
if( !m_fctx )
|
||||
return "AVCodec: Couldn't allocate context";
|
||||
@@ -465,15 +435,11 @@ RString MovieDecoder_FFMpeg::Open( RString sFile )
|
||||
m_fctx->streams[stream_idx] == nullptr )
|
||||
return "Couldn't find any video streams";
|
||||
m_pStream = m_fctx->streams[stream_idx];
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||
m_pStreamCodec = avcodec::avcodec_alloc_context3(nullptr);
|
||||
if (avcodec::avcodec_parameters_to_context(m_pStreamCodec, m_pStream->codecpar) < 0)
|
||||
return ssprintf("Could not get context from parameters");
|
||||
#else
|
||||
m_pStreamCodec = m_pStream->codec;
|
||||
#endif
|
||||
|
||||
if( m_pStreamCodec->codec_id == avcodec::CODEC_ID_NONE )
|
||||
if( m_pStreamCodec->codec_id == avcodec::AV_CODEC_ID_NONE )
|
||||
return ssprintf( "Unsupported codec %08x", m_pStreamCodec->codec_tag );
|
||||
|
||||
RString sError = OpenCodec();
|
||||
@@ -494,7 +460,7 @@ RString MovieDecoder_FFMpeg::OpenCodec()
|
||||
if( m_pStreamCodec->codec )
|
||||
avcodec::avcodec_close( m_pStreamCodec );
|
||||
|
||||
avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
|
||||
const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
|
||||
if( pCodec == nullptr )
|
||||
return ssprintf( "Couldn't find decoder %i", m_pStreamCodec->codec_id );
|
||||
|
||||
@@ -502,11 +468,6 @@ RString MovieDecoder_FFMpeg::OpenCodec()
|
||||
m_pStreamCodec->idct_algo = FF_IDCT_AUTO;
|
||||
m_pStreamCodec->error_concealment = 3;
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 58
|
||||
if( pCodec->capabilities & CODEC_CAP_DR1 )
|
||||
m_pStreamCodec->flags |= CODEC_FLAG_EMU_EDGE;
|
||||
#endif
|
||||
|
||||
LOG->Trace("Opening codec %s", pCodec->name );
|
||||
|
||||
int ret = avcodec::avcodec_open2( m_pStreamCodec, pCodec, nullptr );
|
||||
|
||||
@@ -10,24 +10,10 @@ namespace avcodec
|
||||
{
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libswscale/swscale.h>
|
||||
#include <libavutil/pixdesc.h>
|
||||
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 58
|
||||
#define av_free_packet av_packet_unref
|
||||
#define PixelFormat AVPixelFormat
|
||||
#define PIX_FMT_YUYV422 AV_PIX_FMT_YUYV422
|
||||
#define PIX_FMT_BGRA AV_PIX_FMT_BGRA
|
||||
#define PIX_FMT_ARGB AV_PIX_FMT_ARGB
|
||||
#define PIX_FMT_ABGR AV_PIX_FMT_ABGR
|
||||
#define PIX_FMT_RGBA AV_PIX_FMT_RGBA
|
||||
#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24
|
||||
#define PIX_FMT_BGR24 AV_PIX_FMT_BGR24
|
||||
#define PIX_FMT_RGB555 AV_PIX_FMT_RGB555
|
||||
#define PIX_FMT_NB AV_PIX_FMT_NB
|
||||
#define CODEC_ID_NONE AV_CODEC_ID_NONE
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +25,6 @@ class MovieTexture_FFMpeg: public MovieTexture_Generic
|
||||
public:
|
||||
MovieTexture_FFMpeg( RageTextureID ID );
|
||||
|
||||
static void RegisterProtocols();
|
||||
static RageSurface *AVCodecCreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor, int &iAVTexfmt, MovieDecoderPixelFormatYCbCr &fmtout );
|
||||
};
|
||||
|
||||
@@ -79,7 +64,7 @@ private:
|
||||
|
||||
avcodec::AVStream *m_pStream;
|
||||
avcodec::AVFrame *m_Frame;
|
||||
avcodec::PixelFormat m_AVTexfmt; /* PixelFormat of output surface */
|
||||
avcodec::AVPixelFormat m_AVTexfmt; /* pixel format of output surface */
|
||||
avcodec::SwsContext *m_swsctx;
|
||||
avcodec::AVCodecContext *m_pStreamCodec;
|
||||
|
||||
@@ -106,7 +91,7 @@ static struct AVPixelFormat_t
|
||||
{
|
||||
int bpp;
|
||||
uint32_t masks[4];
|
||||
avcodec::PixelFormat pf;
|
||||
avcodec::AVPixelFormat pf;
|
||||
bool bHighColor;
|
||||
bool bByteSwapOnLittleEndian;
|
||||
MovieDecoderPixelFormatYCbCr YUV;
|
||||
@@ -117,7 +102,7 @@ static struct AVPixelFormat_t
|
||||
0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF },
|
||||
avcodec::PIX_FMT_YUYV422,
|
||||
avcodec::AV_PIX_FMT_YUYV422,
|
||||
false, /* N/A */
|
||||
true,
|
||||
PixelFormatYCbCr_YUYV422,
|
||||
@@ -128,7 +113,7 @@ static struct AVPixelFormat_t
|
||||
0x00FF0000,
|
||||
0xFF000000,
|
||||
0x000000FF },
|
||||
avcodec::PIX_FMT_BGRA,
|
||||
avcodec::AV_PIX_FMT_BGRA,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -139,7 +124,7 @@ static struct AVPixelFormat_t
|
||||
0x0000FF00,
|
||||
0x000000FF,
|
||||
0xFF000000 },
|
||||
avcodec::PIX_FMT_ARGB,
|
||||
avcodec::AV_PIX_FMT_ARGB,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -151,7 +136,7 @@ static struct AVPixelFormat_t
|
||||
0x0000FF00,
|
||||
0x00FF0000,
|
||||
0xFF000000 },
|
||||
avcodec::PIX_FMT_ABGR,
|
||||
avcodec::AV_PIX_FMT_ABGR,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -162,7 +147,7 @@ static struct AVPixelFormat_t
|
||||
0x00FF0000,
|
||||
0x0000FF00,
|
||||
0x000000FF },
|
||||
avcodec::PIX_FMT_RGBA,
|
||||
avcodec::AV_PIX_FMT_RGBA,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -173,7 +158,7 @@ static struct AVPixelFormat_t
|
||||
0x00FF00,
|
||||
0x0000FF,
|
||||
0x000000 },
|
||||
avcodec::PIX_FMT_RGB24,
|
||||
avcodec::AV_PIX_FMT_RGB24,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -184,7 +169,7 @@ static struct AVPixelFormat_t
|
||||
0x00FF00,
|
||||
0xFF0000,
|
||||
0x000000 },
|
||||
avcodec::PIX_FMT_BGR24,
|
||||
avcodec::AV_PIX_FMT_BGR24,
|
||||
true,
|
||||
true,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
@@ -195,12 +180,12 @@ static struct AVPixelFormat_t
|
||||
0x03E0,
|
||||
0x001F,
|
||||
0x0000 },
|
||||
avcodec::PIX_FMT_RGB555,
|
||||
avcodec::AV_PIX_FMT_RGB555,
|
||||
false,
|
||||
false,
|
||||
PixelFormatYCbCr_Invalid,
|
||||
},
|
||||
{ 0, { 0,0,0,0 }, avcodec::PIX_FMT_NB, true, false, PixelFormatYCbCr_Invalid }
|
||||
{ 0, { 0,0,0,0 }, avcodec::AV_PIX_FMT_NB, true, false, PixelFormatYCbCr_Invalid }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user