Fix build against FFmpeg 8 (libavcodec 62 / libswscale). - The SWS_* scaler flags became an enum (previously macros), so SWS_BICUBIC now lives inside StepMania's "avcodec" namespace wrapper and must be qualified. - avcodec_close() was removed; use avcodec_free_context() (closes and frees) for teardown, and free+realloc the context to reset it before reopening. All changes are guarded by LIBAVCODEC_VERSION_MAJOR so older FFmpeg still builds. --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.h +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.h @@ -33,7 +33,13 @@ }; #define STEPMANIA_FFMPEG_BUFFER_SIZE 4096 +#ifdef SWS_BICUBIC static const int sws_flags = SWS_BICUBIC; // XXX: Reasonable default? +#else +// FFmpeg 8 turned the SWS_* flags from macros into an enum, so they now live +// inside this file's "avcodec" namespace wrapper and must be qualified. +static const int sws_flags = avcodec::SWS_BICUBIC; +#endif class MovieTexture_FFMpeg: public MovieTexture_Generic { --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -514,8 +514,19 @@ m_fLastFrame = 0; ASSERT( m_pStream != nullptr ); +#if LIBAVCODEC_VERSION_MAJOR >= 58 + // avcodec_close() was removed in FFmpeg 8. Reset the context by freeing + // and reallocating it from the stream parameters before (re)opening. + if( m_pStreamCodec->codec ) + { + avcodec::avcodec_free_context( &m_pStreamCodec ); + m_pStreamCodec = avcodec::avcodec_alloc_context3( nullptr ); + avcodec::avcodec_parameters_to_context( m_pStreamCodec, m_pStream->codecpar ); + } +#else if( m_pStreamCodec->codec ) avcodec::avcodec_close( m_pStreamCodec ); +#endif const avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStreamCodec->codec_id ); if( pCodec == nullptr ) @@ -542,11 +553,21 @@ void MovieDecoder_FFMpeg::Close() { +#if LIBAVCODEC_VERSION_MAJOR >= 58 + // avcodec_close() was removed in FFmpeg 8; avcodec_free_context() both + // closes and frees the context (and NULLs it, so the later cleanup skips). + if( m_pStream && m_pStreamCodec && m_pStreamCodec->codec ) + { + avcodec::avcodec_free_context( &m_pStreamCodec ); + m_pStream = nullptr; + } +#else if( m_pStream && m_pStreamCodec->codec ) { avcodec::avcodec_close( m_pStreamCodec ); m_pStream = nullptr; } +#endif if( m_fctx ) {