DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
cl_video_libavw.h File Reference
#include "quakedef.h"
#include "cl_video.h"
+ Include dependency graph for cl_video_libavw.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void libavw_close (void *stream)
 
void LibAvW_CloseLibrary (void)
 
qbool LibAvW_OpenLibrary (void)
 
voidLibAvW_OpenVideo (clvideo_t *video, char *filename, const char **errorstring)
 

Function Documentation

◆ libavw_close()

void libavw_close ( void * stream)

Definition at line 222 of file cl_video_libavw.c.

223{
224 libavwstream_t *s = (libavwstream_t *)stream;
225
226 if (s->stream)
228 s->stream = NULL;
229 if (s->file)
230 FS_Close(s->file);
231 s->file = NULL;
232 if (s->sndchan >= 0)
233 S_StopChannel(s->sndchan, true, true);
234 s->sndchan = -1;
235}
void(* qLibAvW_RemoveStream)(void *stream)
int FS_Close(qfile_t *file)
Definition fs.c:2970
#define NULL
Definition qtypes.h:12
void S_StopChannel(unsigned int channel_ind, qbool lockmutex, qbool freesfx)
Definition snd_main.c:1648

References libavwstream_t::file, FS_Close(), NULL, qLibAvW_RemoveStream, S_StopChannel(), libavwstream_t::sndchan, and libavwstream_t::stream.

Referenced by LibAvW_OpenVideo().

◆ LibAvW_CloseLibrary()

void LibAvW_CloseLibrary ( void )

Definition at line 385 of file cl_video_libavw.c.

386{
388}
static dllhandle_t libavw_dll
void Sys_FreeLibrary(dllhandle_t *handle)
Definition sys_shared.c:245

References libavw_dll, and Sys_FreeLibrary().

Referenced by CL_Video_Shutdown().

◆ LibAvW_OpenLibrary()

qbool LibAvW_OpenLibrary ( void )

Definition at line 358 of file cl_video_libavw.c.

359{
360 int errorcode;
361
362 // COMMANDLINEOPTION: Video: -nolibavw disables libavcodec wrapper support
363 if (Sys_CheckParm("-nolibavw"))
364 return false;
365
366 // load DLL's
368 if (!libavw_dll)
369 return false;
370
371 // initialize libav wrapper
372 if ((errorcode = qLibAvW_Init(&libavw_message)))
373 {
374 Con_Printf(CON_ERROR "LibAvW failed to initialize: %s\n", qLibAvW_ErrorString(errorcode));
376 }
377
381
382 return true;
383}
static void libavw_message(int level, const char *message)
cvar_t cl_video_libavw_minwidth
static dllfunction_t libavwfuncs[]
cvar_t cl_video_libavw_scaler
cvar_t cl_video_libavw_minheight
const char *(* qLibAvW_ErrorString)(int errorcode)
int(* qLibAvW_Init)(avwCallbackPrint *printfunction)
const char * dllnames_libavw[]
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_ERROR
Definition console.h:102
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
qbool Sys_LoadDependency(const char **dllnames, dllhandle_t *handle, const dllfunction_t *fcts)
Definition sys_shared.c:131
int Sys_CheckParm(const char *parm)
Definition sys_shared.c:327

References cl_video_libavw_minheight, cl_video_libavw_minwidth, cl_video_libavw_scaler, CON_ERROR, Con_Printf(), Cvar_RegisterVariable(), dllnames_libavw, libavw_dll, libavw_message(), libavwfuncs, qLibAvW_ErrorString, qLibAvW_Init, Sys_CheckParm(), Sys_FreeLibrary(), and Sys_LoadDependency().

Referenced by CL_Video_Init().

◆ LibAvW_OpenVideo()

void * LibAvW_OpenVideo ( clvideo_t * video,
char * filename,
const char ** errorstring )

Definition at line 252 of file cl_video_libavw.c.

253{
255 char filebase[MAX_OSPATH], check[MAX_OSPATH];
256 unsigned int i;
257 int errorcode;
258 char *wavename;
259 size_t len;
260
261 if (!libavw_dll)
262 return NULL;
263
264 // allocate stream
265 s = (libavwstream_t *)Z_Malloc(sizeof(libavwstream_t));
266 if (s == NULL)
267 {
268 *errorstring = "unable to allocate memory for stream info structure";
269 return NULL;
270 }
271 memset(s, 0, sizeof(libavwstream_t));
272 s->sndchan = -1;
273
274 // open file
275 s->file = FS_OpenVirtualFile(filename, true);
276 if (!s->file)
277 {
278 FS_StripExtension(filename, filebase, sizeof(filebase));
279 // we tried .dpv, try another extensions
280 for (i = 0; libavw_extensions[i] != NULL; i++)
281 {
282 dpsnprintf(check, sizeof(check), "%s.%s", filebase, libavw_extensions[i]);
283 s->file = FS_OpenVirtualFile(check, true);
284 if (s->file)
285 break;
286 }
287 if (!s->file)
288 {
289 *errorstring = "unable to open videofile";
290 libavw_close(s);
291 Z_Free(s);
292 return NULL;
293 }
294 }
295
296 // allocate libavw stream
297 if ((errorcode = qLibAvW_CreateStream(&s->stream)))
298 {
299 *errorstring = qLibAvW_ErrorString(errorcode);
300 libavw_close(s);
301 Z_Free(s);
302 return NULL;
303 }
304
305 // open video for playing
307 {
309 libavw_close(s);
310 Z_Free(s);
311 return NULL;
312 }
313
314 // all right, start codec
318 s->info_aspectratio = (double)s->info_imagewidth / (double)s->info_imageheight;
319 video->close = libavw_close;
320 video->getwidth = libavw_getwidth;
325
326 // apply min-width, min-height, keep aspect rate
331
332 // provide sound in separate .wav
333 len = strlen(filename) + 10;
334 wavename = (char *)Z_Malloc(len);
335 if (wavename)
336 {
337 FS_StripExtension(filename, wavename, len-1);
338 dp_strlcat(wavename, ".wav", len);
339 s->sfx = S_PrecacheSound(wavename, false, false);
340 s->sndchan = -1;
341 Z_Free(wavename);
342 }
343 return s;
344}
int(* qLibAvW_PlayVideo)(void *stream, void *file, avwCallbackIoRead *IoRead, avwCallbackIoSeek *IoSeek, avwCallbackIoSeekSize *IoSeekSize)
double(* qLibAvW_StreamGetFramerate)(void *stream)
int(* qLibAvW_CreateStream)(void **stream)
unsigned int libavw_getheight(void *stream)
unsigned int libavw_getwidth(void *stream)
int(* qLibAvW_StreamGetVideoWidth)(void *stream)
int(* qLibAvW_StreamGetVideoHeight)(void *stream)
static int LibAvW_FS_Read(void *opaque, uint8_t *buf, int buf_size)
int(* qLibAvW_StreamGetError)(void *stream)
double libavw_getaspectratio(void *stream)
void libavw_close(void *stream)
double libavw_getframerate(void *stream)
static int libavw_decodeframe(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow)
static uint64_t LibAvW_FS_SeekSize(void *opaque)
static uint64_t LibAvW_FS_Seek(void *opaque, uint64_t pos, int whence)
const char * libavw_extensions[]
int dpsnprintf(char *buffer, size_t buffersize, const char *format,...)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:997
#define dp_strlcat(dst, src, dsize)
Definition common.h:304
qfile_t * FS_OpenVirtualFile(const char *filepath, qbool quiet)
Definition fs.c:2928
void FS_StripExtension(const char *in, char *out, size_t size_out)
Definition fs.c:3611
#define max(A, B)
Definition mathlib.h:38
float strlen(string s)
int i
#define MAX_OSPATH
max length of a filesystem pathname
Definition qdefs.h:175
sfx_t * S_PrecacheSound(const char *name, qbool complain, qbool levelsound)
Definition snd_main.c:1048
void(* close)(void *stream)
Definition cl_video.h:62
double(* getframerate)(void *stream)
Definition cl_video.h:65
unsigned int(* getheight)(void *stream)
Definition cl_video.h:64
int(* decodeframe)(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow)
Definition cl_video.h:67
double(* getaspectratio)(void *stream)
Definition cl_video.h:66
unsigned int(* getwidth)(void *stream)
Definition cl_video.h:63
int integer
Definition cvar.h:73
unsigned int info_imagewidth
unsigned int info_imageheight
#define Z_Malloc(size)
Definition zone.h:161
#define Z_Free(data)
Definition zone.h:164

References cl_video_libavw_minheight, cl_video_libavw_minwidth, clvideo_t::close, clvideo_t::decodeframe, dp_strlcat, dpsnprintf(), libavwstream_t::file, FS_OpenVirtualFile(), FS_StripExtension(), clvideo_t::getaspectratio, clvideo_t::getframerate, clvideo_t::getheight, clvideo_t::getwidth, i, libavwstream_t::info_aspectratio, libavwstream_t::info_framerate, libavwstream_t::info_imageheight, libavwstream_t::info_imagewidth, cvar_t::integer, libavw_close(), libavw_decodeframe(), libavw_dll, libavw_extensions, LibAvW_FS_Read(), LibAvW_FS_Seek(), LibAvW_FS_SeekSize(), libavw_getaspectratio(), libavw_getframerate(), libavw_getheight(), libavw_getwidth(), max, MAX_OSPATH, NULL, qLibAvW_CreateStream, qLibAvW_ErrorString, qLibAvW_PlayVideo, qLibAvW_StreamGetError, qLibAvW_StreamGetFramerate, qLibAvW_StreamGetVideoHeight, qLibAvW_StreamGetVideoWidth, S_PrecacheSound(), libavwstream_t::sfx, libavwstream_t::sndchan, libavwstream_t::stream, strlen(), Z_Free, and Z_Malloc.

Referenced by OpenStream().