summaryrefslogtreecommitdiff
path: root/community-testing/performous/ffmpeg-0.11.patch
blob: 2962123edae41c23c99e37e5b5a4b5e746d6db53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
diff -ru Performous-0.6.1-Source/game/ffmpeg.cc Performous-0.6.1a-Source/game/ffmpeg.cc
--- Performous-0.6.1-Source/game/ffmpeg.cc	2010-10-31 16:05:43.000000000 +0000
+++ Performous-0.6.1a-Source/game/ffmpeg.cc	2012-06-08 21:40:10.876636789 +0000
@@ -47,11 +47,17 @@
 	return d >= 0.0 ? d : getInf();
 }
 
+// FFMPEG has fluctuating API
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(64<<8)+0)
+#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
+#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
+#endif
+
 void FFmpeg::open() {
 	boost::mutex::scoped_lock l(s_avcodec_mutex);
 	av_register_all();
 	av_log_set_level(AV_LOG_ERROR);
-	if (av_open_input_file(&pFormatCtx, m_filename.c_str(), NULL, 0, NULL)) throw std::runtime_error("Cannot open input file");
+	if (avformat_open_input(&pFormatCtx, m_filename.c_str(), NULL, NULL)) throw std::runtime_error("Cannot open input file");
 	if (av_find_stream_info(pFormatCtx) < 0) throw std::runtime_error("Cannot find stream information");
 	pFormatCtx->flags |= AVFMT_FLAG_GENPTS;
 	videoStream = -1;
@@ -60,8 +66,8 @@
 	for (unsigned int i=0; i<pFormatCtx->nb_streams; i++) {
 		AVCodecContext* cc = pFormatCtx->streams[i]->codec;
 		cc->workaround_bugs = FF_BUG_AUTODETECT;
-		if (videoStream == -1 && cc->codec_type==CODEC_TYPE_VIDEO) videoStream = i;
-		if (audioStream == -1 && cc->codec_type==CODEC_TYPE_AUDIO) audioStream = i;
+		if (videoStream == -1 && cc->codec_type==AVMEDIA_TYPE_VIDEO) videoStream = i;
+		if (audioStream == -1 && cc->codec_type==AVMEDIA_TYPE_AUDIO) audioStream = i;
 	}
 	if (videoStream == -1 && decodeVideo) throw std::runtime_error("No video stream found");
 	if (audioStream == -1 && decodeAudio) throw std::runtime_error("No audio stream found");
@@ -92,7 +98,7 @@
 		pAudioCodecCtx = cc;
 #if LIBAVCODEC_VERSION_INT > ((52<<16)+(12<<8)+0)
 		pResampleCtx = av_audio_resample_init(AUDIO_CHANNELS, cc->channels, m_rate, cc->sample_rate,
-			SAMPLE_FMT_S16, SAMPLE_FMT_S16, 16, 10, 0, 0.8);
+			AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16, 16, 10, 0, 0.8);
 #else
 		pResampleCtx = audio_resample_init(AUDIO_CHANNELS, cc->channels, m_rate, cc->sample_rate);
 #endif