[MPlayer-dev-eng] [PATCH 2/2] demux_avs: unix port using avxsynth
Gianluigi Tiesi
mplayer at netfarm.it
Fri Nov 1 06:46:06 CET 2013
I've made some preliminar tests and it seems to work
---
Makefile | 2 +-
libmpdemux/demux_avs.c | 59 +++++++++++++++++++++++++-------------------------
libmpdemux/demux_avs.h | 7 +++---
libmpdemux/demuxer.c | 2 --
4 files changed, 33 insertions(+), 37 deletions(-)
diff --git a/Makefile b/Makefile
index 2119cda..c959a13 100644
--- a/Makefile
+++ b/Makefile
@@ -246,7 +246,6 @@ SRCS_COMMON-$(WIN32DLL) += libmpcodecs/ad_acm.c \
libmpcodecs/vd_dsnative.c \
libmpcodecs/vd_vfw.c \
libmpcodecs/vd_vfwex.c \
- libmpdemux/demux_avs.c \
loader/afl.c \
loader/drv.c \
loader/vfl.c \
@@ -415,6 +414,7 @@ SRCS_COMMON = asxparser.c \
libmpdemux/demux_asf.c \
libmpdemux/demux_audio.c \
libmpdemux/demux_avi.c \
+ libmpdemux/demux_avs.c \
libmpdemux/demux_demuxers.c \
libmpdemux/demux_film.c \
libmpdemux/demux_fli.c \
diff --git a/libmpdemux/demux_avs.c b/libmpdemux/demux_avs.c
index da5c3a1..c6e2737 100644
--- a/libmpdemux/demux_avs.c
+++ b/libmpdemux/demux_avs.c
@@ -33,11 +33,23 @@
#include "stheader.h"
#include "libvo/fastmemcpy.h"
-#include "loader/wine/winbase.h"
-#include "loader/wine/windef.h"
-
-#ifdef WIN32_LOADER
-#include "loader/ldt_keeper.h"
+#ifdef WIN32
+ #include "loader/wine/winbase.h"
+ #include "loader/wine/windef.h"
+ #define AVISYNTH_LIB "avisynth"
+#else
+ #include <dlfcn.h>
+ #if defined (__APPLE__)
+ #define AVISYNTH_LIB "libavxsynth.dylib"
+ #else
+ #define AVISYNTH_LIB "libavxsynth.so"
+ #endif
+
+ #define LoadLibraryA(x) dlopen(x, RTLD_NOW | RTLD_GLOBAL)
+ #define GetProcAddress dlsym
+ #define FreeLibrary dlclose
+ #define HMODULE void *
+ #define WINAPI
#endif
#include "demux_avs.h"
@@ -55,7 +67,7 @@ typedef WINAPI int (*imp_avs_get_audio)(AVS_Clip *, void * buf, uint64_t start,
#define Q(string) # string
#define IMPORT_FUNC(x) \
- AVS->x = ( imp_##x ) GetProcAddress(AVS->dll, Q(x)); \
+ AVS->x = ( imp_##x ) GetProcAddress(AVS->library, Q(x)); \
if (!AVS->x) { mp_msg(MSGT_DEMUX,MSGL_V,"AVS: failed to load "Q(x)"()\n"); return 0; }
typedef struct tagAVS
@@ -64,12 +76,9 @@ typedef struct tagAVS
AVS_Value handler;
AVS_Clip *clip;
const AVS_VideoInfo *video_info;
-#ifdef WIN32_LOADER
- ldt_fs_t* ldt_fs;
-#endif
- HMODULE dll;
+ HMODULE library;
int frameno;
- uint64_t sampleno;
+ int64_t sampleno;
int init;
imp_avs_create_script_environment avs_create_script_environment;
@@ -88,18 +97,14 @@ static AVS_T *initAVS(const char *filename)
AVS_Value arg0 = avs_new_value_string(filename);
AVS_Value args = avs_new_value_array(&arg0, 1);
-#ifdef WIN32_LOADER
- AVS->ldt_fs = Setup_LDT_Keeper();
-#endif
-
- AVS->dll = LoadLibraryA("avisynth.dll");
- if(!AVS->dll)
+ AVS->library = LoadLibraryA(AVISYNTH_LIB);
+ if(!AVS->library)
{
- mp_msg(MSGT_DEMUX ,MSGL_V, "AVS: failed to load avisynth.dll\n");
+ mp_msg(MSGT_DEMUX, MSGL_V, "AVS: failed to load " AVISYNTH_LIB "\n");
goto avs_err;
}
- /* Dynamic import of needed stuff from avisynth.dll */
+ /* Dynamic import of needed stuff from avisynth library */
IMPORT_FUNC(avs_create_script_environment);
IMPORT_FUNC(avs_invoke);
IMPORT_FUNC(avs_get_video_info);
@@ -134,10 +139,7 @@ static AVS_T *initAVS(const char *filename)
return AVS;
avs_err:
- if (AVS->dll) FreeLibrary(AVS->dll);
-#ifdef WIN32_LOADER
- Restore_LDT_Keeper(AVS->ldt_fs);
-#endif
+ if (AVS->library) FreeLibrary(AVS->library);
free(AVS);
return NULL;
}
@@ -386,16 +388,13 @@ static void demux_close_avs(demuxer_t* demuxer)
if (AVS)
{
- if (AVS->dll)
+ if (AVS->library)
{
if (AVS->clip)
AVS->avs_release_clip(AVS->clip);
- mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Unloading avisynth.dll\n");
- FreeLibrary(AVS->dll);
+ mp_msg(MSGT_DEMUX, MSGL_V, "AVS: Unloading " AVISYNTH_LIB "\n");
+ FreeLibrary(AVS->library);
}
-#ifdef WIN32_LOADER
- Restore_LDT_Keeper(AVS->ldt_fs);
-#endif
free(AVS);
}
}
@@ -463,7 +462,7 @@ const demuxer_desc_t demuxer_desc_avs = {
"avs",
"AVS",
"Gianluigi Tiesi",
- "Requires binary dll",
+ "Requires binary library",
DEMUXER_TYPE_AVS,
0, // unsafe autodetect
avs_check_file,
diff --git a/libmpdemux/demux_avs.h b/libmpdemux/demux_avs.h
index 7b54657..170e3fe 100644
--- a/libmpdemux/demux_avs.h
+++ b/libmpdemux/demux_avs.h
@@ -1,6 +1,6 @@
/*
* Demuxer for avisynth
- * Copyright (c) 2005 Gianluigi Tiesi <sherpya at netfarm.it>
+ * Copyright (c) 2005-2013 Gianluigi Tiesi <sherpya at netfarm.it>
*
* Avisynth C Interface Version 0.20
* Copyright 2003 Kevin Atkinson
@@ -26,7 +26,6 @@
#define MPLAYER_DEMUX_AVS_H
#include <stdint.h>
-#include "loader/wine/windef.h"
enum { AVISYNTH_INTERFACE_VERSION = 2 };
@@ -99,7 +98,7 @@ typedef struct AVS_VideoInfo {
int audio_samples_per_second; // 0 means no audio
int sample_type;
- uint64_t num_audio_samples;
+ int64_t num_audio_samples;
int nchannels;
// Imagetype properties
@@ -108,7 +107,7 @@ typedef struct AVS_VideoInfo {
} AVS_VideoInfo;
typedef struct AVS_VideoFrameBuffer {
- BYTE * data;
+ unsigned char * data;
int data_size;
// sequence_number is incremented every time the buffer is changed, so
// that stale views can tell they're no longer valid.
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index 153cd45..65afc54 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -152,9 +152,7 @@ const demuxer_desc_t *const demuxer_list[] = {
#ifdef CONFIG_OGGVORBIS
&demuxer_desc_ogg,
#endif
-#ifdef CONFIG_WIN32DLL
&demuxer_desc_avs,
-#endif
&demuxer_desc_pva,
&demuxer_desc_mpeg_ts,
&demuxer_desc_lmlm4,
--
1.8.4.2
--
Gianluigi Tiesi <sherpya at netfarm.it>
EDP Project Leader
Netfarm S.r.l. - http://www.netfarm.it/
Free Software: http://oss.netfarm.it/
More information about the MPlayer-dev-eng
mailing list