replace deprecated functions to fix build on ffmpeg 0.11.1

tested on static 0.10.2 as well and it works just fine.
This commit is contained in:
Devin J. Pohly
2012-08-02 17:38:08 -04:00
parent e0ed921357
commit 92c7a7389c
+16 -12
View File
@@ -15,6 +15,7 @@ namespace avcodec
{ {
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
#include <libavutil/pixdesc.h>
} }
}; };
@@ -615,20 +616,23 @@ RString MovieDecoder_FFMpeg::Open( RString sFile )
MovieTexture_FFMpeg::RegisterProtocols(); MovieTexture_FFMpeg::RegisterProtocols();
m_fctx = avcodec::avformat_alloc_context(); m_fctx = avcodec::avformat_alloc_context();
if( !m_fctx )
return "AVCodec: Couldn't allocate context";
RageFile *f = new RageFile; RageFile *f = new RageFile;
if( !f->Open(sFile, RageFile::READ) ) if( !f->Open(sFile, RageFile::READ) )
{ {
RString errorMessage = f->GetError(); RString errorMessage = f->GetError();
RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str() ); RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str() );
delete f; delete f;
return error; return error;
} }
m_buffer = (unsigned char *)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE); 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_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 ); m_fctx->pb = m_avioContext;
int ret = avcodec::avformat_open_input( &m_fctx, sFile.c_str(), NULL, NULL );
if( ret < 0 ) if( ret < 0 )
return RString( averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str()) ); 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() ); return ssprintf( "AVCodec (%s): %s", sFile.c_str(), sError.c_str() );
LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate ); 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(); return RString();
} }