Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 11247803b37c18f5c2f1699a15ca336c > files > 10

stepmania-3.9-12mdv2010.1.src.rpm

diff -Nau StepMania-3.9-src-orig/configure.ac StepMania-3.9-src/configure.ac
--- StepMania-3.9-src-orig/configure.ac	2005-11-03 16:27:02.000000000 +0100
+++ StepMania-3.9-src/configure.ac	2008-01-24 00:10:35.000000000 +0100
@@ -159,39 +159,19 @@
 SM_AUDIO
 SM_TLS
 
-AC_SEARCH_LIBS(avcodec_init, [avcodec], have_libavcodec=yes,  have_libavcodec=no)
-AC_SEARCH_LIBS(guess_format, [avformat], have_libavformat=yes,  have_libavformat=no)
-
-if test "$have_libavcodec" = "yes"; then
-  AC_MSG_CHECKING([for libavcodec >= 0.4.9])
-  AC_TRY_RUN([
-      #include <ffmpeg/avcodec.h>
-      int main()
-      {
-	      return ( LIBAVCODEC_VERSION_INT < 0x000409 )? 1:0;
-      }
-      ],,have_libavcodec=no,)
-  AC_MSG_RESULT($have_libavcodec)
-fi
-
-if test "$have_libavformat" = "yes"; then
-  AC_MSG_CHECKING([for libavformat >= 0.4.9])
-  AC_TRY_RUN([
-      #include <ffmpeg/avformat.h>
-      int main()
-      {
-	      return ( LIBAVFORMAT_VERSION_INT < 0x000409 )? 1:0;
-      }
-      ],,have_libavformat=no,)
-  AC_MSG_RESULT($have_libavformat)
+PKG_PROG_PKG_CONFIG
+PKG_CHECK_MODULES(FFMPEG, [libavformat libavcodec libswscale], have_ffmpeg=yes)
+AM_CONDITIONAL(HAVE_FFMPEG, test "$have_ffmpeg" = "yes")
+if test "$have_ffmpeg" = "yes"; then
+	AC_DEFINE(HAVE_FFMPEG, 1, [FMPEG support available])
+	AC_CHECK_LIB(avcodec, avcodec_init, have_libavcodec=yes,  have_libavcodec=no, [$FFMPEG_LIBS])
+	AC_CHECK_LIB(avformat, guess_format, have_libavformat=yes,  have_libavformat=no, [$FFMPEG_LIBS])
+	AC_CHECK_LIB(swscale, sws_scale, have_libswscale=yes,  have_libswscale=no, [$FFMPEG_LIBS])
 fi
 
-have_ffmpeg=no
-if test "$have_libavformat" = "yes" -a "$have_libavcodec" = "yes"; then
-	have_ffmpeg=yes
-	AC_DEFINE(HAVE_FFMPEG, 1, [FMPEG support available])
+if test "$have_libswscale" = "no"; then
+	AC_CHECK_LIB(avcodec, img_convert, [AC_DEFINE([HAVE_IMG_CONVERT], [], [Deprecated img_convert function is available])])
 fi
-AM_CONDITIONAL(HAVE_FFMPEG, test "$have_ffmpeg" = "yes")
 
 SM_CHECK_CRASH_HANDLER
 
diff -ur StepMania-3.9-src.orig/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp StepMania-3.9-src/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp
--- StepMania-3.9-src.orig/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp	2005-10-17 05:25:55.000000000 +0300
+++ StepMania-3.9-src/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp	2007-08-07 16:57:06.000000000 +0300
@@ -1,3 +1,6 @@
+#define __STDC_CONSTANT_MACROS
+#include <stdint.h>
+
 #include "global.h"
 #include "MovieTexture_FFMpeg.h"
 
@@ -20,9 +23,31 @@
 #if defined(_WIN32)
 #include "ffmpeg/include/ffmpeg/avformat.h"
 #else
+extern "C"
+{
 #include <ffmpeg/avformat.h>
+}
 #endif
-};
+
+#if !defined(HAVE_IMG_CONVERT)
+extern "C"
+{
+#include <ffmpeg/swscale.h>
+}
+#endif // HAVE_IMG_CONVERT
+    void img_convert__(AVPicture *dst, avcodec::PixelFormat dst_pix_fmt,
+                       const AVPicture *src, avcodec::PixelFormat pix_fmt,
+                       int width, int height)
+    {
+#ifdef HAVE_IMG_CONVERT
+        img_convert(dst, dst_pix_fmt, src, pix_fmt, width, height);
+#else
+        static SwsContext* context = 0;
+        context = sws_getCachedContext(context, width, height, pix_fmt, width, height, dst_pix_fmt, 0, NULL, NULL, NULL);
+        sws_scale(context, const_cast<uint8_t**>(src->data), const_cast<int*>(src->linesize), 0, height, dst->data, dst->linesize);
+#endif // HAVE_IMG_CONVERT
+    }
+}
 
 #if defined(_WIN32)
 	#pragma comment(lib, "ffmpeg/lib/avcodec.lib")
@@ -307,7 +332,11 @@
 		if ( GetNextTimestamp )
 		{
 			if (pkt.dts != int64_t(AV_NOPTS_VALUE))
+#if (LIBAVCODEC_BUILD >= 4754)
+				pts = (float)pkt.dts * m_stream->time_base.num / m_stream->time_base.den;
+#else
 				pts = (float)pkt.dts / AV_TIME_BASE;
+#endif
 			else
 				pts = -1;
 			GetNextTimestamp = false;
@@ -326,7 +355,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_stream->codec, 
+#else
 				&m_stream->codec, 
+#endif
 				&frame, &got_frame,
 				pkt.size? pkt.data:dummy, pkt.size );
 		CHECKPOINT;
@@ -360,7 +393,11 @@
 		}
 
 		/* Length of this frame: */
+#if (LIBAVCODEC_BUILD >= 4754)
+		LastFrameDelay = (float)m_stream->codec->time_base.num / m_stream->codec->time_base.den;
+#else
 		LastFrameDelay = (float)m_stream->codec.frame_rate_base / m_stream->codec.frame_rate;
+#endif
 		LastFrameDelay += frame.repeat_pict * (LastFrameDelay * 0.5f);
 
 		return 1;
@@ -377,9 +414,15 @@
 	pict.data[0] = (unsigned char *)m_img->pixels;
 	pict.linesize[0] = m_img->pitch;
 
-	avcodec::img_convert(&pict, AVPixelFormats[m_AVTexfmt].pf,
+#if (LIBAVCODEC_BUILD >= 4754)
+	avcodec::img_convert__(&pict, AVPixelFormats[m_AVTexfmt].pf,
+			(avcodec::AVPicture *) &decoder->frame, decoder->m_stream->codec->pix_fmt, 
+			decoder->m_stream->codec->width, decoder->m_stream->codec->height);
+#else
+	avcodec::img_convert__(&pict, AVPixelFormats[m_AVTexfmt].pf,
 			(avcodec::AVPicture *) &decoder->frame, decoder->m_stream->codec.pix_fmt, 
 			decoder->m_stream->codec.width, decoder->m_stream->codec.height);
+#endif
 
 	m_ImageWaiting = FRAME_WAITING;
 }
@@ -389,8 +432,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;
 }
@@ -418,8 +466,13 @@
 	m_bThreaded = PREFSMAN->m_bThreadedMovieDecode;
 
 	CreateDecoder();
+#if (LIBAVCODEC_BUILD >= 4754)
+	LOG->Trace("Bitrate: %i", decoder->m_stream->codec->bit_rate );
+	LOG->Trace("Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(decoder->m_stream->codec->pix_fmt) );
+#else
 	LOG->Trace("Bitrate: %i", decoder->m_stream->codec.bit_rate );
 	LOG->Trace("Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(decoder->m_stream->codec.pix_fmt) );
+#endif
 
 	/* Decode one frame, to guarantee that the texture is drawn when this function returns. */
 	int ret = decoder->GetFrame();
@@ -487,7 +540,6 @@
 	case AVERROR_INVALIDDATA:	Error = "invalid data found"; break;
 	case AVERROR_NOMEM:			Error = "not enough memory"; break;
 	case AVERROR_NOFMT:			Error = "unknown format"; break;
-	case AVERROR_UNKNOWN:		Error = "unknown error"; break;
 	default: Error = ssprintf( "unknown error %i", err ); break;
 	}
 
@@ -573,6 +625,17 @@
 	if ( stream == NULL )
 		RageException::Throw( "AVCodec (%s): Couldn't find any video streams", GetID().filename.c_str() );
 
+#if (LIBAVCODEC_BUILD >= 4754)
+	if( stream->codec->codec_id == avcodec::CODEC_ID_NONE )
+		RageException::ThrowNonfatal( "AVCodec (%s): Unsupported codec %08x", GetID().filename.c_str(), stream->codec->codec_tag );
+
+	avcodec::AVCodec *codec = avcodec::avcodec_find_decoder( stream->codec->codec_id );
+	if( codec == NULL )
+		RageException::Throw( "AVCodec (%s): Couldn't find decoder %i", GetID().filename.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 )
 		RageException::ThrowNonfatal( "AVCodec (%s): Unsupported codec %08x", GetID().filename.c_str(), stream->codec.codec_tag );
 
@@ -582,6 +645,7 @@
 
 	LOG->Trace("Opening codec %s", codec->name );
 	ret = avcodec::avcodec_open( &stream->codec, codec );
+#endif
 	if ( ret < 0 )
 		RageException::Throw( averr_ssprintf(ret, "AVCodec (%s): Couldn't open codec \"%s\"", GetID().filename.c_str(), codec->name) );
 
@@ -596,7 +660,11 @@
 {
 	if( decoder->m_stream )
 	{
+#if (LIBAVCODEC_BUILD >= 4754)
+		avcodec::avcodec_close( decoder->m_stream->codec );
+#else
 		avcodec::avcodec_close( &decoder->m_stream->codec );
+#endif
 		decoder->m_stream = NULL;
 	}
 
@@ -637,8 +705,13 @@
 	/* Cap the max texture size to the hardware max. */
 	actualID.iMaxSize = min( actualID.iMaxSize, DISPLAY->GetMaxTextureSize() );
 
+#if (LIBAVCODEC_BUILD >= 4754)
+	m_iSourceWidth  = decoder->m_stream->codec->width;
+	m_iSourceHeight = decoder->m_stream->codec->height;
+#else
 	m_iSourceWidth  = decoder->m_stream->codec.width;
 	m_iSourceHeight = decoder->m_stream->codec.height;
+#endif
 
 	/* image size cannot exceed max size */
 	m_iImageWidth = min( m_iSourceWidth, actualID.iMaxSize );
@@ -818,7 +891,11 @@
 		m_FrameSkipMode = true;
 	}
 
+#if (LIBAVCODEC_BUILD >= 4754)
+	if( m_FrameSkipMode && decoder->m_stream->codec->frame_number % 2 )
+#else
 	if( m_FrameSkipMode && decoder->m_stream->codec.frame_number % 2 )
+#endif
 		return -1; /* skip */
 	
 	return 0;
diff -ur StepMania-3.9-src.orig/src/Makefile.am StepMania-3.9-src/src/Makefile.am
--- StepMania-3.9-src.orig/src/Makefile.am	2004-09-08 09:48:45.000000000 +0300
+++ StepMania-3.9-src/src/Makefile.am	2007-08-07 16:57:06.000000000 +0300
@@ -303,6 +303,10 @@
 		  $(XLIBS) \
 		  $(srcdir)/libresample/libresample.a
 
+if HAVE_FFMPEG
+main_LDADD += $(FFMPEG_LIBS)
+endif
+
 stepmania_SOURCES = $(main_SOURCES)
 stepmania_LDADD = $(main_LDADD)
 
--- StepMania-3.9-src-orig/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp	2009-01-28 19:14:55.000000000 +0100
+++ StepMania-3.9-src/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp	2009-01-28 19:10:15.000000000 +0100
@@ -574,7 +574,7 @@
 	return f->Read( buf, size );
 }
 
-avcodec::offset_t URLRageFile_seek( avcodec::URLContext *h, avcodec::offset_t pos, int whence )
+int64_t URLRageFile_seek( avcodec::URLContext *h, int64_t pos, int whence )
 {
 	RageFile *f = (RageFile *) h->priv_data;
 	return f->Seek( (int) pos, whence );