--- src/arch/MovieTexture/MovieTexture_FFMpeg.cpp 2006-09-01 05:27:27.000000000 +0200 +++ src/arch/MovieTexture/MovieTexture_FFMpeg.cpp 2006-09-23 18:20:10.000000000 +0200 @@ -166,8 +166,13 @@ int GetFrame( RageSurface *pOut, float fTargetTime ); +#if (LIBAVCODEC_BUILD >= 4754) + int GetWidth() const { return m_pStream->codec->width; } + int GetHeight() const { return m_pStream->codec->height; } +#else int GetWidth() const { return m_pStream->codec.width; } int GetHeight() const { return m_pStream->codec.height; } +#endif RageSurface *CreateCompatibleSurface( int iTextureWidth, int iTextureHeight, bool bPreferHighColor ); @@ -317,7 +322,11 @@ if( m_bGetNextTimestamp ) { if (m_Packet.dts != int64_t(AV_NOPTS_VALUE)) +#if (LIBAVCODEC_BUILD >= 4754) + m_fPTS = (float)m_Packet.dts * m_pStream->time_base.num / m_pStream->time_base.den; +#else m_fPTS = (float)m_Packet.dts / AV_TIME_BASE; +#endif else m_fPTS = -1; m_bGetNextTimestamp = false; @@ -333,7 +342,11 @@ bool bSkipThisFrame = fTargetTime != -1 && GetTimestamp() + GetFrameDuration() <= fTargetTime && +#if (LIBAVCODEC_BUILD >= 4754) + (m_pStream->codec->frame_number % 2) == 0; +#else (m_pStream->codec.frame_number % 2) == 0; +#endif int iGotFrame; CHECKPOINT; @@ -341,7 +354,11 @@ * to give it a buffer to read from since it tries to read anyway. */ static uint8_t dummy[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 }; int len = avcodec::avcodec_decode_video( +#if (LIBAVCODEC_BUILD >= 4754) + m_pStream->codec, +#else &m_pStream->codec, +#endif &m_Frame, &iGotFrame, m_Packet.size? m_Packet.data:dummy, m_Packet.size ); CHECKPOINT; @@ -375,7 +392,11 @@ } /* Length of this frame: */ +#if (LIBAVCODEC_BUILD >= 4754) + m_fLastFrameDelay = (float)m_pStream->codec->time_base.num / m_pStream->codec->time_base.den; +#else m_fLastFrameDelay = (float)m_pStream->codec.frame_rate_base / m_pStream->codec.frame_rate; +#endif m_fLastFrameDelay += m_Frame.repeat_pict * (m_fLastFrameDelay * 0.5f); ++m_iFrameNumber; @@ -415,9 +436,15 @@ pict.data[0] = (unsigned char *) pSurface->pixels; pict.linesize[0] = pSurface->pitch; +#if (LIBAVCODEC_BUILD >= 4754) + avcodec::img_convert( &pict, m_AVTexfmt, + (avcodec::AVPicture *) &m_Frame, m_pStream->codec->pix_fmt, + m_pStream->codec->width, m_pStream->codec->height ); +#else avcodec::img_convert( &pict, m_AVTexfmt, (avcodec::AVPicture *) &m_Frame, m_pStream->codec.pix_fmt, m_pStream->codec.width, m_pStream->codec.height ); +#endif } static avcodec::AVStream *FindVideoStream( avcodec::AVFormatContext *m_fctx ) @@ -426,8 +453,13 @@ for( int stream = 0; stream < m_fctx->nb_streams; ++stream ) { avcodec::AVStream *enc = m_fctx->streams[stream]; +#if (LIBAVCODEC_BUILD >= 4754) + if( enc->codec->codec_type == avcodec::CODEC_TYPE_VIDEO ) + return enc; +#else if( enc->codec.codec_type == avcodec::CODEC_TYPE_VIDEO ) return enc; +#endif } return NULL; } @@ -550,6 +582,17 @@ if ( stream == NULL ) return ssprintf( "AVCodec (%s): Couldn't find any video streams", sFile.c_str() ); +#if (LIBAVCODEC_BUILD >= 4754) + if( stream->codec->codec_id == avcodec::CODEC_ID_NONE ) + return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec->codec_tag ); + + avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec->codec_id ); + if( codec == NULL ) + return ssprintf( "AVCodec (%s): Couldn't find decoder %i", sFile.c_str(), stream->codec->codec_id ); + + LOG->Trace("Opening codec %s", codec->name ); + ret = avcodec::avcodec_open( stream->codec, codec ); +#else if( stream->codec.codec_id == avcodec::CODEC_ID_NONE ) return ssprintf( "AVCodec (%s): Unsupported codec %08x", sFile.c_str(), stream->codec.codec_tag ); @@ -559,12 +602,18 @@ LOG->Trace("Opening codec %s", codec->name ); ret = avcodec::avcodec_open( &stream->codec, codec ); +#endif if ( ret < 0 ) return ssprintf( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", sFile.c_str(), codec->name) ); m_pStream = stream; +#if (LIBAVCODEC_BUILD >= 4754) + 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) ); +#else 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) ); +#endif return RString(); } @@ -573,7 +622,11 @@ { if( m_pStream ) { +#if (LIBAVCODEC_BUILD >= 4754) + avcodec::avcodec_close( m_pStream->codec ); +#else avcodec::avcodec_close( &m_pStream->codec ); +#endif m_pStream = NULL; } --- autoconf/m4/video.m4 2006-09-01 05:27:23.000000000 +0200 +++ autoconf/m4/video.m4 2006-09-23 18:23:05.000000000 +0200 @@ -19,44 +19,6 @@ AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes, have_libavcodec=no) AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes, have_libavformat=no) fi - -if test "$have_libavcodec" = "yes"; then - AC_MSG_CHECKING([for matching libavcodec headers and libs]) - AC_TRY_RUN([ - #include - int main() - { - return ( LIBAVCODEC_VERSION_INT == avcodec_version() && - LIBAVCODEC_BUILD == avcodec_build() ) ? 0:1; - } - ],,have_libavcodec=no,) - AC_MSG_RESULT($have_libavcodec) - if test "$have_libavcodec" = "yes"; then - AC_MSG_CHECKING([for libavcodec = 0.4.9-pre1]) - AC_TRY_RUN([ - #include - int main() - { - return ( LIBAVCODEC_VERSION_INT == 0x000409 && - LIBAVCODEC_BUILD == 4718 ) ? 0:1; - } - ],,have_libavcodec=no,) - AC_MSG_RESULT($have_libavcodec) - fi -fi - -if test "$have_libavformat" = "yes"; then - AC_MSG_CHECKING([for libavformat = 0.4.9-pre1]) - AC_TRY_RUN([ - #include - int main() - { - return ( LIBAVFORMAT_VERSION_INT == 0x000409 && - LIBAVFORMAT_BUILD == 4616 )? 0:1; - } - ],,have_libavformat=no,) - AC_MSG_RESULT($have_libavformat) -fi fi have_ffmpeg=no