diff options
| author | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2025-12-30 22:50:05 +0100 |
|---|---|---|
| committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2026-01-03 15:18:56 +0100 |
| commit | 65f57fc74f039b02bd58a89c0fc5a8d870363bba (patch) | |
| tree | e6683160b79e874b019a2dbcd053942af86021b3 /gnu | |
| parent | 9c70ddf23e91763416cd8d5c4a22c3701a1dc094 (diff) | |
gnu: stepmania: Fix compatibility with ffmpeg 8.
This is a follow-up to 31919486254117d95c43711595a9de5e0bae134d, which fixed
compile-time compatibility with newer ffmpeg, but introduced runtime crashes.
* gnu/packages/games.scm (stepmania): Replace ffmpeg-6 with ffmpeg.
* gnu/packages/patches/stepmania-ffmpeg-compat.patch: Add hunks for FFMPEG 8
compatibility.
Initialize m_pStreamCodec to nullptr and reinitialize it in
MovieDecoder_FFMpeg::OpenCodec.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/packages/games.scm | 2 | ||||
| -rw-r--r-- | gnu/packages/patches/stepmania-ffmpeg-compat.patch | 47 |
2 files changed, 44 insertions, 5 deletions
diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm index cf0b3a419c5..2ef3948a2e5 100644 --- a/gnu/packages/games.scm +++ b/gnu/packages/games.scm | |||
| @@ -10191,7 +10191,7 @@ via the in-game download manager.") | |||
| 10191 | (inputs | 10191 | (inputs |
| 10192 | (list alsa-lib | 10192 | (list alsa-lib |
| 10193 | eudev | 10193 | eudev |
| 10194 | ffmpeg-6 | 10194 | ffmpeg |
| 10195 | glib | 10195 | glib |
| 10196 | glew | 10196 | glew |
| 10197 | gtk+-2 | 10197 | gtk+-2 |
diff --git a/gnu/packages/patches/stepmania-ffmpeg-compat.patch b/gnu/packages/patches/stepmania-ffmpeg-compat.patch index b5b9bcd8f24..2475754489d 100644 --- a/gnu/packages/patches/stepmania-ffmpeg-compat.patch +++ b/gnu/packages/patches/stepmania-ffmpeg-compat.patch | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | See [6] and [7]. | 1 | See [6], [7], and [8]. |
| 2 | [6] https://github.com/Tatsh/tatsh-overlay/blob/master/games-arcade/stepmania/files/stepmania-ffmpeg-6.patch | 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 | 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. | ||
| 4 | 9 | ||
| 5 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp | 10 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp |
| 6 | index 935ddf324b0..d4eed01d599 100644 | 11 | index 935ddf324b0..d4eed01d599 100644 |
| @@ -17,6 +22,13 @@ index 935ddf324b0..d4eed01d599 100644 | |||
| 17 | static void FixLilEndian() | 22 | static void FixLilEndian() |
| 18 | { | 23 | { |
| 19 | #if defined(ENDIAN_LITTLE) | 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(); | ||
| 20 | @@ -405,7 +405,7 @@ void MovieTexture_FFMpeg::RegisterProtocols() | 32 | @@ -405,7 +405,7 @@ void MovieTexture_FFMpeg::RegisterProtocols() |
| 21 | return; | 33 | return; |
| 22 | Done = true; | 34 | Done = true; |
| @@ -26,15 +38,33 @@ index 935ddf324b0..d4eed01d599 100644 | |||
| 26 | avcodec::avcodec_register_all(); | 38 | avcodec::avcodec_register_all(); |
| 27 | avcodec::av_register_all(); | 39 | avcodec::av_register_all(); |
| 28 | #endif | 40 | #endif |
| 29 | @@ -508,7 +508,7 @@ RString MovieDecoder_FFMpeg::OpenCodec() | 41 | @@ -508,6 +508,16 @@ RString MovieDecoder_FFMpeg::OpenCodec() |
| 42 | +#if LIBAVCODEC_VERSION_MAJOR < 58 | ||
| 30 | if( m_pStreamCodec->codec ) | 43 | if( m_pStreamCodec->codec ) |
| 31 | avcodec::avcodec_close( m_pStreamCodec ); | 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 | ||
| 32 | 54 | ||
| 33 | - avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id ); | 55 | - avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id ); |
| 34 | + const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id ); | 56 | + const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id ); |
| 35 | if( pCodec == nullptr ) | 57 | if( pCodec == nullptr ) |
| 36 | return ssprintf( "Couldn't find decoder %i", m_pStreamCodec->codec_id ); | 58 | return ssprintf( "Couldn't find decoder %i", m_pStreamCodec->codec_id ); |
| 37 | 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 | |||
| 38 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.h b/src/arch/MovieTexture/MovieTexture_FFMpeg.h | 68 | diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.h b/src/arch/MovieTexture/MovieTexture_FFMpeg.h |
| 39 | index c092b765fc2..99f5ffcb1be 100644 | 69 | index c092b765fc2..99f5ffcb1be 100644 |
| 40 | --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.h | 70 | --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.h |
| @@ -46,4 +76,13 @@ index c092b765fc2..99f5ffcb1be 100644 | |||
| 46 | + #include <libavcodec/avcodec.h> | 76 | + #include <libavcodec/avcodec.h> |
| 47 | 77 | ||
| 48 | #if LIBAVCODEC_VERSION_MAJOR >= 58 | 78 | #if LIBAVCODEC_VERSION_MAJOR >= 58 |
| 49 | #define av_free_packet av_packet_unref \ No newline at end of file | 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 | { | ||
