X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=cl_video_libavw.c;h=83f4921c35677005afeb608254a0697add198831;hp=a5381e8145fa1ce6b51427992b265cf0070600c1;hb=d7c6a4d737c8f59bab92b37e0039882aa88a6dc8;hpb=48669036b4be979d997c27227942ed9c430277d5 diff --git a/cl_video_libavw.c b/cl_video_libavw.c index a5381e81..83f4921c 100644 --- a/cl_video_libavw.c +++ b/cl_video_libavw.c @@ -22,7 +22,11 @@ */ // LadyHavoc: for some reason this is being #include'd rather than treated as its own file... -// LadyHavoc: adapted to not require stdint.h as this is not available on MSVC++, using unsigned char instead of uint8_t and fs_offset_t instead of int64_t. + +#include "quakedef.h" +#include "client.h" +#include "cl_video.h" +#include "cl_video_libavw.h" // scaler type #define LIBAVW_SCALER_BILINEAR 0 @@ -45,9 +49,9 @@ #define LIBAVW_PRINT_PANIC 4 // exported callback functions: typedef void avwCallbackPrint(int, const char *); -typedef int avwCallbackIoRead(void *, unsigned char *, int); -typedef fs_offset_t avwCallbackIoSeek(void *, fs_offset_t, int); -typedef fs_offset_t avwCallbackIoSeekSize(void *); +typedef int avwCallbackIoRead(void *, uint8_t *, int); +typedef uint64_t avwCallbackIoSeek(void *, uint64_t, int); +typedef uint64_t avwCallbackIoSeekSize(void *); // exported functions: int (*qLibAvW_Init)(avwCallbackPrint *printfunction); // init library, returns error code const char *(*qLibAvW_ErrorString)(int errorcode); // get string for error code @@ -85,12 +89,11 @@ static dllfunction_t libavwfuncs[] = const char* dllnames_libavw[] = { #if defined(WIN32) - "libavw.dll", + "libavcodec.dll", #elif defined(MACOSX) - "libavw.dylib", + "libavcodec.dylib", #else - "libavw.so.1", - "libavw.so", + "libavcodec.so", #endif NULL }; @@ -114,9 +117,9 @@ typedef struct libavwstream_s } libavwstream_t; -cvar_t cl_video_libavw_minwidth = {CVAR_SAVE, "cl_video_libavw_minwidth", "0", "if videos width is lesser than minimal, thay will be upscaled"}; -cvar_t cl_video_libavw_minheight = {CVAR_SAVE, "cl_video_libavw_minheight", "0", "if videos height is lesser than minimal, thay will be upscaled"}; -cvar_t cl_video_libavw_scaler = {CVAR_SAVE, "cl_video_libavw_scaler", "1", "selects a scaler for libavcode played videos. Scalers are: 0 - bilinear, 1 - bicubic, 2 - x, 3 - point, 4 - area, 5 - bicublin, 6 - gauss, 7 - sinc, 8 - lanczos, 9 - spline."}; +cvar_t cl_video_libavw_minwidth = {CF_ARCHIVE, "cl_video_libavw_minwidth", "0", "if videos width is lesser than minimal, thay will be upscaled"}; +cvar_t cl_video_libavw_minheight = {CF_ARCHIVE, "cl_video_libavw_minheight", "0", "if videos height is lesser than minimal, thay will be upscaled"}; +cvar_t cl_video_libavw_scaler = {CF_ARCHIVE, "cl_video_libavw_scaler", "1", "selects a scaler for libavcode played videos. Scalers are: 0 - bilinear, 1 - bicubic, 2 - x, 3 - point, 4 - area, 5 - bicublin, 6 - gauss, 7 - sinc, 8 - lanczos, 9 - spline."}; // video extensions const char* libavw_extensions[] = @@ -175,7 +178,7 @@ static int libavw_decodeframe(void *stream, void *imagedata, unsigned int Rmask, // got error or file end errorcode = qLibAvW_StreamGetError(s->stream); if (errorcode) - Con_Printf("LibAvW: %s\n", qLibAvW_ErrorString(errorcode)); + Con_Printf(CON_ERROR "LibAvW: %s\n", qLibAvW_ErrorString(errorcode)); return 1; } @@ -186,11 +189,11 @@ static int libavw_decodeframe(void *stream, void *imagedata, unsigned int Rmask, pixel_format = LIBAVW_PIXEL_FORMAT_BGR; else { - Con_Printf("LibAvW: cannot determine pixel format for bpp %i\n", bytesperpixel); + Con_Printf(CON_ERROR "LibAvW: cannot determine pixel format for bpp %i\n", bytesperpixel); return 1; } if (!qLibAvW_PlayGetFrameImage(s->stream, pixel_format, imagedata, s->info_imagewidth, s->info_imageheight, min(9, max(0, cl_video_libavw_scaler.integer)))) - Con_Printf("LibAvW: %s\n", qLibAvW_ErrorString(qLibAvW_StreamGetError(s->stream))); + Con_Printf(CON_ERROR "LibAvW: %s\n", qLibAvW_ErrorString(qLibAvW_StreamGetError(s->stream))); return 0; } @@ -232,21 +235,21 @@ void libavw_close(void *stream) } // IO wrapper -static int LibAvW_FS_Read(void *opaque, unsigned char *buf, int buf_size) +static int LibAvW_FS_Read(void *opaque, uint8_t *buf, int buf_size) { return FS_Read((qfile_t *)opaque, buf, buf_size); } -static fs_offset_t LibAvW_FS_Seek(void *opaque, fs_offset_t pos, int whence) +static uint64_t LibAvW_FS_Seek(void *opaque, uint64_t pos, int whence) { - return (fs_offset_t)FS_Seek((qfile_t *)opaque, pos, whence); + return (uint64_t)FS_Seek((qfile_t *)opaque, pos, whence); } -static fs_offset_t LibAvW_FS_SeekSize(void *opaque) +static uint64_t LibAvW_FS_SeekSize(void *opaque) { - return (fs_offset_t)FS_FileSize((qfile_t *)opaque); + return (uint64_t)FS_FileSize((qfile_t *)opaque); } // open as DP video stream -static void *LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **errorstring) +void *LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **errorstring) { libavwstream_t *s; char filebase[MAX_OSPATH], check[MAX_OSPATH]; @@ -343,33 +346,33 @@ static void *LibAvW_OpenVideo(clvideo_t *video, char *filename, const char **err static void libavw_message(int level, const char *message) { if (level == LIBAVW_PRINT_WARNING) - Con_Printf("LibAvcodec warning: %s\n", message); + Con_Printf(CON_WARN "LibAvcodec warning: %s\n", message); else if (level == LIBAVW_PRINT_ERROR) - Con_Printf("LibAvcodec error: %s\n", message); + Con_Printf(CON_ERROR "LibAvcodec error: %s\n", message); else if (level == LIBAVW_PRINT_FATAL) - Con_Printf("LibAvcodec fatal error: %s\n", message); + Con_Printf(CON_ERROR "LibAvcodec fatal error: %s\n", message); else - Con_Printf("LibAvcodec panic: %s\n", message); + Con_Printf(CON_ERROR "LibAvcodec panic: %s\n", message); } -static qboolean LibAvW_OpenLibrary(void) +qbool LibAvW_OpenLibrary(void) { int errorcode; // COMMANDLINEOPTION: Video: -nolibavw disables libavcodec wrapper support - if (COM_CheckParm("-nolibavw")) + if (Sys_CheckParm("-nolibavw")) return false; // load DLL's - Sys_LoadLibrary(dllnames_libavw, &libavw_dll, libavwfuncs); + Sys_LoadDependency(dllnames_libavw, &libavw_dll, libavwfuncs); if (!libavw_dll) return false; // initialize libav wrapper if ((errorcode = qLibAvW_Init(&libavw_message))) { - Con_Printf("LibAvW failed to initialize: %s\n", qLibAvW_ErrorString(errorcode)); - Sys_UnloadLibrary(&libavw_dll); + Con_Printf(CON_ERROR "LibAvW failed to initialize: %s\n", qLibAvW_ErrorString(errorcode)); + Sys_FreeLibrary(&libavw_dll); } Cvar_RegisterVariable(&cl_video_libavw_minwidth); @@ -379,8 +382,7 @@ static qboolean LibAvW_OpenLibrary(void) return true; } -static void LibAvW_CloseLibrary(void) +void LibAvW_CloseLibrary(void) { - Sys_UnloadLibrary(&libavw_dll); + Sys_FreeLibrary(&libavw_dll); } -