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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
From: Simon McVittie <smcv@debian.org>
Date: Thu, 2 Apr 2015 10:01:39 +0100
Subject: Add support for DP_LINK_THEORA=shared (default is dlopen)
Like the existing DP_LINK_TO_JPEG, this can be configured to
link libtheora etc. in the normal way instead of dlopening them.
Origin: vendor, Debian
Forwarded: no
---
cap_ogg.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
makefile | 15 +++++++++++++++
makefile.inc | 6 +++---
3 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/cap_ogg.c b/cap_ogg.c
index e9abc7a..7c1b2d2 100644
--- a/cap_ogg.c
+++ b/cap_ogg.c
@@ -19,6 +19,55 @@ static cvar_t cl_capturevideo_ogg_theora_noise_sensitivity = {CVAR_SAVE, "cl_cap
static cvar_t cl_capturevideo_ogg_theora_sharpness = {CVAR_SAVE, "cl_capturevideo_ogg_theora_sharpness", "0", "sharpness (0 to 2); lower is sharper"};
static cvar_t cl_capturevideo_ogg_vorbis_quality = {CVAR_SAVE, "cl_capturevideo_ogg_vorbis_quality", "3", "audio quality (-1 to 10); higher is better"};
+#ifdef LINK_TO_THEORA
+
+#include <ogg/ogg.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisenc.h>
+#include <theora/theora.h>
+
+#define qogg_stream_packetin ogg_stream_packetin
+#define qogg_stream_pageout ogg_stream_pageout
+#define qogg_stream_flush ogg_stream_flush
+#define qogg_stream_init ogg_stream_init
+#define qogg_stream_clear ogg_stream_clear
+#define qogg_page_granulepos ogg_page_granulepos
+
+#define qvorbis_info_init vorbis_info_init
+#define qvorbis_info_clear vorbis_info_clear
+#define qvorbis_comment_init vorbis_comment_init
+#define qvorbis_comment_clear vorbis_comment_clear
+#define qvorbis_block_init vorbis_block_init
+#define qvorbis_block_clear vorbis_block_clear
+#define qvorbis_dsp_clear vorbis_dsp_clear
+#define qvorbis_granule_time vorbis_granule_time
+#define qvorbis_analysis_init vorbis_analysis_init
+#define qvorbis_commentheader_out vorbis_commentheader_out
+#define qvorbis_analysis_headerout vorbis_analysis_headerout
+#define qvorbis_analysis_buffer vorbis_analysis_buffer
+#define qvorbis_analysis_wrote vorbis_analysis_wrote
+#define qvorbis_analysis_blockout vorbis_analysis_blockout
+#define qvorbis_analysis vorbis_analysis
+#define qvorbis_bitrate_addblock vorbis_bitrate_addblock
+#define qvorbis_bitrate_flushpacket vorbis_bitrate_flushpacket
+#define qvorbis_encode_init_vbr vorbis_encode_init_vbr
+
+#define qtheora_encode_init theora_encode_init
+#define qtheora_encode_YUVin theora_encode_YUVin
+#define qtheora_encode_packetout theora_encode_packetout
+#define qtheora_encode_header theora_encode_header
+#define qtheora_encode_comment theora_encode_comment
+#define qtheora_encode_tables theora_encode_tables
+#define qtheora_info_init theora_info_init
+#define qtheora_info_clear theora_info_clear
+#define qtheora_clear theora_clear
+#define qtheora_comment_init theora_comment_init
+#define qtheora_comment_clear theora_comment_clear
+#define qtheora_granule_time theora_granule_time
+#define qtheora_control theora_control
+
+#else
+
// ogg.h stuff
#ifdef _MSC_VER
typedef __int16 ogg_int16_t;
@@ -591,10 +640,13 @@ static qboolean SCR_CaptureVideo_Ogg_OpenLibrary(void)
&&
Sys_LoadLibrary (dllnames_ve, &ve_dll, vorbisencfuncs);
}
+#endif
void SCR_CaptureVideo_Ogg_Init(void)
{
+#ifndef LINK_TO_THEORA
SCR_CaptureVideo_Ogg_OpenLibrary();
+#endif
Cvar_RegisterVariable(&cl_capturevideo_ogg_theora_vp3compat);
Cvar_RegisterVariable(&cl_capturevideo_ogg_theora_quality);
@@ -609,15 +661,21 @@ void SCR_CaptureVideo_Ogg_Init(void)
qboolean SCR_CaptureVideo_Ogg_Available(void)
{
+#ifdef LINK_TO_THEORA
+ return TRUE;
+#else
return og_dll && th_dll && vo_dll && ve_dll;
+#endif
}
void SCR_CaptureVideo_Ogg_CloseDLL(void)
{
+#ifndef LINK_TO_THEORA
Sys_UnloadLibrary (&ve_dll);
Sys_UnloadLibrary (&vo_dll);
Sys_UnloadLibrary (&th_dll);
Sys_UnloadLibrary (&og_dll);
+#endif
}
// this struct should not be needed
diff --git a/makefile b/makefile
index 2450c35..6a00037 100644
--- a/makefile
+++ b/makefile
@@ -113,6 +113,7 @@ ifeq ($(DP_MAKE_TARGET), linux)
DP_LINK_CRYPTO?=dlopen
DP_LINK_CRYPTO_RIJNDAEL?=dlopen
DP_LINK_VORBIS?=dlopen
+ DP_LINK_THEORA?=dlopen
endif
# Mac OS X configuration
@@ -149,6 +150,7 @@ ifeq ($(DP_MAKE_TARGET), macosx)
DP_LINK_CRYPTO?=dlopen
DP_LINK_CRYPTO_RIJNDAEL?=dlopen
DP_LINK_VORBIS?=dlopen
+ DP_LINK_THEORA?=dlopen
# on OS X, we don't build the CL by default because it uses deprecated
# and not-implemented-in-64bit Carbon
@@ -191,6 +193,7 @@ ifeq ($(DP_MAKE_TARGET), sunos)
DP_LINK_CRYPTO?=dlopen
DP_LINK_CRYPTO_RIJNDAEL?=dlopen
DP_LINK_VORBIS?=dlopen
+ DP_LINK_THEORA?=dlopen
endif
# BSD configuration
@@ -227,6 +230,7 @@ endif
DP_LINK_CRYPTO?=dlopen
DP_LINK_CRYPTO_RIJNDAEL?=dlopen
DP_LINK_VORBIS?=dlopen
+ DP_LINK_THEORA?=dlopen
endif
# Win32 configuration
@@ -287,6 +291,7 @@ ifeq ($(DP_MAKE_TARGET), mingw)
DP_LINK_CRYPTO?=dlopen
DP_LINK_CRYPTO_RIJNDAEL?=dlopen
DP_LINK_VORBIS?=dlopen
+ DP_LINK_THEORA?=dlopen
endif
# set these to "" if you want to use dynamic loading instead
@@ -349,6 +354,16 @@ ifeq ($(DP_LINK_VORBIS), dlopen)
LIB_VORBIS=
endif
+# theora
+ifeq ($(DP_LINK_THEORA), shared)
+ CFLAGS_LIBTHEORA=-DLINK_TO_THEORA `pkg-config --cflags theora vorbis vorbisenc ogg`
+ LIB_THEORA=`pkg-config --libs theora vorbis vorbisenc ogg`
+endif
+ifeq ($(DP_LINK_THEORA), dlopen)
+ CFLAGS_LIBTHEORA=
+ LIB_THEORA=
+endif
+
##### Sound configuration #####
ifndef DP_SOUND_API
diff --git a/makefile.inc b/makefile.inc
index ba2ccc5..9d29592 100644
--- a/makefile.inc
+++ b/makefile.inc
@@ -172,7 +172,7 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMM
# Compilation
-CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_LIBVORBIS) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../
+CFLAGS_COMMON=$(CFLAGS_MAKEDEP) $(CFLAGS_PRELOAD) $(CFLAGS_FS) $(CFLAGS_WARNINGS) $(CFLAGS_LIBZ) $(CFLAGS_LIBJPEG) $(CFLAGS_LIBVORBIS) $(CFLAGS_LIBTHEORA) $(CFLAGS_D3D) -D_FILE_OFFSET_BITS=64 -D__KERNEL_STRICT_NAMES -I../../../
CFLAGS_CLIENT=-DCONFIG_MENU -DCONFIG_CD $(CFLAGS_VIDEO_CAPTURE)
CFLAGS_SERVER=
CFLAGS_DEBUG=-ggdb
@@ -206,13 +206,13 @@ LDFLAGS_RELEASE=$(OPTIM_RELEASE) -DSVNREVISION=`{ test -d .svn && svnversion; }
OBJ_GLX= builddate.c sys_linux.o vid_glx.o thread_pthread.o keysym2ucs.o $(OBJ_MENU) $(OBJ_SOUND) $(OBJ_CD) $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
LDFLAGS_UNIXCOMMON=-lm $(LIB_ODE) $(LIB_Z) $(LIB_JPEG) $(LIB_CRYPTO) $(LIB_CRYPTO_RIJNDAEL)
-LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm -pthread $(LIB_SOUND) $(LIB_VORBIS)
+LDFLAGS_UNIXCL=-L$(UNIX_X11LIBPATH) -lX11 -lXpm -lXext -lXxf86vm -pthread $(LIB_SOUND) $(LIB_VORBIS) $(LIB_THEORA)
LDFLAGS_UNIXCL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
LDFLAGS_UNIXSV_PRELOAD=-lz -ljpeg -lpng -lcurl
LDFLAGS_UNIXSDL_PRELOAD=-lz -ljpeg -lpng -logg -ltheora -lvorbis -lvorbisenc -lvorbisfile -lcurl
CFLAGS_UNIX_PRELOAD=-DPREFER_PRELOAD
-LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_VORBIS)
+LDFLAGS_UNIXSDL=$(SDLCONFIG_LIBS) $(LIB_VORBIS) $(LIB_THEORA)
EXE_UNIXCL=darkplaces-glx
EXE_UNIXSV=darkplaces-dedicated
EXE_UNIXSDL=darkplaces-sdl
|