diff --git a/autoconf/m4/video.m4 b/autoconf/m4/video.m4 index 0d3a91a4cd..4ec88801b4 100644 --- a/autoconf/m4/video.m4 +++ b/autoconf/m4/video.m4 @@ -17,7 +17,7 @@ have_ffmpeg=no if test "$with_ffmpeg" = "yes"; then if test "$with_static_ffmpeg" = "yes" -o "$with_static_ffmpeg" = "no"; then AC_CHECK_LIB(avutil, av_free, have_libavutil=yes, have_libavutil=no) - AC_CHECK_LIB(avcodec, avcodec_init, have_libavcodec=yes, have_libavcodec=no) + AC_CHECK_LIB(avcodec, avcodec_register_all, have_libavcodec=yes, have_libavcodec=no) AC_CHECK_LIB(avformat, av_guess_format, have_libavformat=yes, have_libavformat=no) AC_CHECK_LIB(swscale, sws_scale, have_libswscale=yes, have_libswscale=no) if test "$have_libavutil" = "yes" -a "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes" -a "$have_libswscale" = "yes"; then @@ -46,7 +46,7 @@ if test "$with_ffmpeg" = "yes"; then LIBS="$FFMPEG_LIBS -lpthread $LIBS" AC_CHECK_FUNC([av_free], have_libavutil=yes, have_libavutil=no) - AC_CHECK_FUNC([avcodec_init], have_libavcodec=yes, have_libavcodec=no) + AC_CHECK_FUNC([avcodec_register_all], have_libavcodec=yes, have_libavcodec=no) AC_CHECK_FUNC([av_guess_format], have_libavformat=yes, have_libavformat=no) AC_CHECK_FUNC([sws_scale], have_libswscale=yes, have_libswscale=no) diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 5e2f60fa7d..0dd9dad3aa 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -15,6 +15,7 @@ namespace avcodec { #include #include + #include } }; @@ -615,20 +616,23 @@ RString MovieDecoder_FFMpeg::Open( RString sFile ) MovieTexture_FFMpeg::RegisterProtocols(); m_fctx = avcodec::avformat_alloc_context(); + if( !m_fctx ) + return "AVCodec: Couldn't allocate context"; - RageFile *f = new RageFile; - - if( !f->Open(sFile, RageFile::READ) ) - { - RString errorMessage = f->GetError(); - RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str() ); - delete f; - return error; - } - - m_buffer = (unsigned char *)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE); - m_avioContext = avcodec::avio_alloc_context(m_buffer, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, NULL, AVIORageFile_Seek); - int ret = avcodec::av_open_input_stream( &m_fctx, m_avioContext, sFile.c_str(), NULL, NULL ); + RageFile *f = new RageFile; + + if( !f->Open(sFile, RageFile::READ) ) + { + RString errorMessage = f->GetError(); + RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str() ); + delete f; + return error; + } + + m_buffer = (unsigned char *)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE); + m_avioContext = avcodec::avio_alloc_context(m_buffer, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, NULL, AVIORageFile_Seek); + m_fctx->pb = m_avioContext; + int ret = avcodec::avformat_open_input( &m_fctx, sFile.c_str(), NULL, NULL ); if( ret < 0 ) return RString( averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str()) ); @@ -651,7 +655,7 @@ RString MovieDecoder_FFMpeg::Open( RString sFile ) return ssprintf( "AVCodec (%s): %s", sFile.c_str(), sError.c_str() ); LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate ); - LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec->pix_fmt) ); + LOG->Trace( "Codec pixel format: %s", avcodec::av_get_pix_fmt_name(m_pStream->codec->pix_fmt) ); return RString(); }