| 1 | See [6], [7], and [8].
|
| 2 | [6] https://github.com/Tatsh/tatsh-overlay/blob/master/games-arcade/stepmania/files/stepmania-ffmpeg-6.patch
|
| 3 | [7] https://github.com/Tatsh/tatsh-overlay/blob/master/games-arcade/stepmania/files/stepmania-ffmpeg-7.patch
|
| 4 | [8] https://github.com/Tatsh/tatsh-overlay/blob/master/games-arcade/stepmania/files/stepmania-ffmpeg-8.patch
|
| 5 |
|
| 6 | Hunk #2 is not present in any of these patches, but prevents a segmentation
|
| 7 | fault due to freeing unallocated memory.
|
| 8 | Hunk #4 was likewise altered to prevent nullptr dereferences.
|
| 9 |
|
| 10 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp
|
| 11 | index 935ddf324b0..d4eed01d599 100644
|
| 12 | |
| 13 | |
| 14 | @@ -9,6 +9,10 @@
|
| 15 |
|
| 16 | #include <cerrno>
|
| 17 |
|
| 18 | +#if LIBAVCODEC_VERSION_MAJOR > 59
|
| 19 | +#define frame_number frame_num
|
| 20 | +#endif
|
| 21 | +
|
| 22 | static void FixLilEndian()
|
| 23 | {
|
| 24 | #if defined(ENDIAN_LITTLE)
|
| 25 | @@ -118,5 +118,6 @@
|
| 26 | m_buffer = NULL;
|
| 27 | m_fctx = nullptr;
|
| 28 | m_pStream = nullptr;
|
| 29 | + m_pStreamCodec = nullptr;
|
| 30 | m_iCurrentPacketOffset = -1;
|
| 31 | m_Frame = avcodec::av_frame_alloc();
|
| 32 | @@ -405,7 +405,7 @@ void MovieTexture_FFMpeg::RegisterProtocols()
|
| 33 | return;
|
| 34 | Done = true;
|
| 35 |
|
| 36 | -#if !FF_API_NEXT
|
| 37 | +#if LIBAVCODEC_VERSION_MAJOR < 58
|
| 38 | avcodec::avcodec_register_all();
|
| 39 | avcodec::av_register_all();
|
| 40 | #endif
|
| 41 | @@ -508,6 +508,16 @@ RString MovieDecoder_FFMpeg::OpenCodec()
|
| 42 | +#if LIBAVCODEC_VERSION_MAJOR < 58
|
| 43 | if( m_pStreamCodec->codec )
|
| 44 | avcodec::avcodec_close( m_pStreamCodec );
|
| 45 | +#else
|
| 46 | + if ( m_pStreamCodec )
|
| 47 | + {
|
| 48 | + avcodec::avcodec_free_context ( &m_pStreamCodec );
|
| 49 | + m_pStreamCodec = avcodec::avcodec_alloc_context3(nullptr);
|
| 50 | + if (avcodec::avcodec_parameters_to_context(m_pStreamCodec, m_pStream->codecpar) < 0)
|
| 51 | + return ssprintf("Could not get context from parameters");
|
| 52 | + }
|
| 53 | +#endif
|
| 54 |
|
| 55 | - avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
|
| 56 | + const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id );
|
| 57 | if( pCodec == nullptr )
|
| 58 | return ssprintf( "Couldn't find decoder %i", m_pStreamCodec->codec_id );
|
| 59 | @@ -535,7 +535,7 @@ void MovieDecoder_FFMpeg::Close()
|
| 60 | {
|
| 61 | if( m_pStream && m_pStreamCodec->codec )
|
| 62 | {
|
| 63 | - avcodec::avcodec_close( m_pStreamCodec );
|
| 64 | + avcodec::avcodec_free_context( &m_pStreamCodec );
|
| 65 | m_pStream = nullptr;
|
| 66 | }
|
| 67 |
|
| 68 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.h b/src/arch/MovieTexture/MovieTexture_FFMpeg.h
|
| 69 | index c092b765fc2..99f5ffcb1be 100644
|
| 70 | |
| 71 | |
| 72 | @@ -13,6 +13,7 @@ namespace avcodec
|
| 73 | #include <libavformat/avformat.h>
|
| 74 | #include <libswscale/swscale.h>
|
| 75 | #include <libavutil/pixdesc.h>
|
| 76 | + #include <libavcodec/avcodec.h>
|
| 77 |
|
| 78 | #if LIBAVCODEC_VERSION_MAJOR >= 58
|
| 79 | #define av_free_packet av_packet_unref
|
| 80 | @@ -32,7 +32,7 @@ namespace avcodec
|
| 81 | };
|
| 82 |
|
| 83 | #define STEPMANIA_FFMPEG_BUFFER_SIZE 4096
|
| 84 | -static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default?
|
| 85 | +static const int sws_flags = avcodec::SWS_BICUBIC; // XXX: Reasonable default?
|
| 86 |
|
| 87 | class MovieTexture_FFMpeg: public MovieTexture_Generic
|
| 88 | {
|