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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
From f80c1410b31d758adc2b3ec3ada3e27133eb41a4 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Date: Thu, 5 Nov 2015 10:53:44 +0100
Subject: [PATCH] Replace deprecated FFmpeg API for compatibility with ffmpeg
2.9
---
client/CVideoHandler.cpp | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/client/CVideoHandler.cpp b/client/CVideoHandler.cpp
index c334725..1218fc0 100644
--- a/client/CVideoHandler.cpp
+++ b/client/CVideoHandler.cpp
@@ -151,7 +151,11 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
}
// Allocate video frame
+#if LIBAVUTIL_VERSION_MAJOR > 52
+ frame = av_alloc_frame();
+#else
frame = avcodec_alloc_frame();
+#endif
//setup scaling
@@ -185,21 +189,36 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
if (texture)
{ // Convert the image into YUV format that SDL uses
sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt,
- pos.w, pos.h, PIX_FMT_YUV420P,
+ pos.w, pos.h,
+#if LIBAVUTIL_VERSION_MAJOR > 51
+ AV_PIX_FMT_YUV420P,
+#else
+ PIX_FMT_YUV420P,
+#endif
SWS_BICUBIC, nullptr, nullptr, nullptr);
}
else
{
+#if LIBAVUTIL_VERSION_MAJOR > 51
+ AVPixelFormat screenFormat = AV_PIX_FMT_NONE;
+#else
PixelFormat screenFormat = PIX_FMT_NONE;
+#endif
if (screen->format->Bshift > screen->format->Rshift)
{
// this a BGR surface
switch (screen->format->BytesPerPixel)
{
+#if LIBAVUTIL_VERSION_MAJOR > 51
+ case 2: screenFormat = AV_PIX_FMT_BGR565; break;
+ case 3: screenFormat = AV_PIX_FMT_BGR24; break;
+ case 4: screenFormat = AV_PIX_FMT_BGR32; break;
+#else
case 2: screenFormat = PIX_FMT_BGR565; break;
case 3: screenFormat = PIX_FMT_BGR24; break;
case 4: screenFormat = PIX_FMT_BGR32; break;
+#endif
default: return false;
}
}
@@ -208,9 +227,15 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay, bool scal
// this a RGB surface
switch (screen->format->BytesPerPixel)
{
+#if LIBAVUTIL_VERSION_MAJOR > 51
+ case 2: screenFormat = AV_PIX_FMT_RGB565; break;
+ case 3: screenFormat = AV_PIX_FMT_RGB24; break;
+ case 4: screenFormat = AV_PIX_FMT_RGB32; break;
+#else
case 2: screenFormat = PIX_FMT_RGB565; break;
case 3: screenFormat = PIX_FMT_RGB24; break;
case 4: screenFormat = PIX_FMT_RGB32; break;
+#endif
default: return false;
}
}
@@ -367,7 +392,11 @@ void CVideoPlayer::close()
if (frame)
{
+#if LIBAVUTIL_VERSION_MAJOR > 52
+ av_frame_free(frame);
+#else
av_free(frame);
+#endif
frame = nullptr;
}
--
2.9.3
|