Skip to content

Commit d8ce270

Browse files
authored
Merge pull request #189 from ferdnyc/rename-rshift
Rename RSHIFT macro
2 parents 4837655 + 2c82533 commit d8ce270

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

include/FFmpegUtilities.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@
117117
#define PIX_FMT_YUV420P AV_PIX_FMT_YUV420P
118118
#endif
119119

120+
// FFmpeg's libavutil/common.h defines an RSHIFT incompatible with Ruby's
121+
// definition in ruby/config.h, so we move it to FF_RSHIFT
122+
#ifdef RSHIFT
123+
#define FF_RSHIFT(a, b) RSHIFT(a, b)
124+
#undef RSHIFT
125+
#endif
126+
120127
#ifdef USE_SW
121128
#define SWR_CONVERT(ctx, out, linesize, out_count, in, linesize2, in_count) \
122129
swr_convert(ctx, out, out_count, (const uint8_t **)in, in_count)

src/bindings/ruby/openshot.i

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ namespace std {
5757

5858

5959
%{
60+
/* Ruby and FFmpeg define competing RSHIFT macros,
61+
* so we move Ruby's out of the way for now. We'll
62+
* restore it after dealing with FFmpeg's
63+
*/
64+
#ifdef RSHIFT
65+
#define RB_RSHIFT(a, b) RSHIFT(a, b)
66+
#undef RSHIFT
67+
#endif
6068
#include "../../../include/Version.h"
6169
#include "../../../include/ReaderBase.h"
6270
#include "../../../include/WriterBase.h"
@@ -93,6 +101,15 @@ namespace std {
93101
#include "../../../include/ZmqLogger.h"
94102
#include "../../../include/AudioDeviceInfo.h"
95103

104+
/* Move FFmpeg's RSHIFT to FF_RSHIFT, if present */
105+
#ifdef RSHIFT
106+
#define FF_RSHIFT(a, b) RSHIFT(a, b)
107+
#undef RSHIFT
108+
#endif
109+
/* And restore Ruby's RSHIFT, if we captured it */
110+
#ifdef RB_RSHIFT
111+
#define RSHIFT(a, b) RB_RSHIFT(a, b)
112+
#endif
96113
%}
97114

98115
#ifdef USE_BLACKMAGIC
@@ -133,8 +150,29 @@ namespace std {
133150
%include "../../../include/EffectInfo.h"
134151
%include "../../../include/Enums.h"
135152
%include "../../../include/Exceptions.h"
153+
154+
/* Ruby and FFmpeg define competing RSHIFT macros,
155+
* so we move Ruby's out of the way for now. We'll
156+
* restore it after dealing with FFmpeg's
157+
*/
158+
#ifdef RSHIFT
159+
#define RB_RSHIFT(a, b) RSHIFT(a, b)
160+
#undef RSHIFT
161+
#endif
162+
136163
%include "../../../include/FFmpegReader.h"
137164
%include "../../../include/FFmpegWriter.h"
165+
166+
/* Move FFmpeg's RSHIFT to FF_RSHIFT, if present */
167+
#ifdef RSHIFT
168+
#define FF_RSHIFT(a, b) RSHIFT(a, b)
169+
#undef RSHIFT
170+
#endif
171+
/* And restore Ruby's RSHIFT, if we captured it */
172+
#ifdef RB_RSHIFT
173+
#define RSHIFT(a, b) RB_RSHIFT(a, b)
174+
#endif
175+
138176
%include "../../../include/Fraction.h"
139177
%include "../../../include/Frame.h"
140178
%include "../../../include/FrameMapper.h"

0 commit comments

Comments
 (0)