diff options
Diffstat (limited to 'libavformat/avisynth.c')
-rw-r--r-- | libavformat/avisynth.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index d0fe0fd7ea..56700288f7 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -2,20 +2,20 @@ * AviSynth/AvxSynth support * Copyright (c) 2012 AvxSynth Team * - * This file is part of Libav. + * This file is part of FFmpeg * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -32,20 +32,17 @@ #define AVSC_NO_DECLSPEC /* Platform-specific directives for AviSynth vs AvxSynth. */ -#if CONFIG_AVISYNTH - #include <windows.h> +#ifdef _WIN32 + #include "compat/w32dlfcn.h" #undef EXTERN_C - #include <avisynth/avisynth_c.h> + #include "compat/avisynth/avisynth_c.h" #define AVISYNTH_LIB "avisynth" + #define USING_AVISYNTH #else #include <dlfcn.h> - #include <avxsynth/avxsynth_c.h> + #include "compat/avisynth/avxsynth_c.h" #define AVISYNTH_NAME "libavxsynth" #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF - - #define LoadLibrary(x) dlopen(x, RTLD_NOW | RTLD_LOCAL) - #define GetProcAddress dlsym - #define FreeLibrary dlclose #endif typedef struct AviSynthLibrary { @@ -65,7 +62,7 @@ typedef struct AviSynthLibrary { AVSC_DECLARE_FUNC(avs_release_value); AVSC_DECLARE_FUNC(avs_release_video_frame); AVSC_DECLARE_FUNC(avs_take_clip); -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH AVSC_DECLARE_FUNC(avs_bits_per_pixel); AVSC_DECLARE_FUNC(avs_get_height_p); AVSC_DECLARE_FUNC(avs_get_pitch_p); @@ -121,13 +118,12 @@ static av_cold void avisynth_atexit_handler(void); static av_cold int avisynth_load_library(void) { - avs_library.library = LoadLibrary(AVISYNTH_LIB); + avs_library.library = dlopen(AVISYNTH_LIB, RTLD_NOW | RTLD_LOCAL); if (!avs_library.library) return AVERROR_UNKNOWN; #define LOAD_AVS_FUNC(name, continue_on_fail) \ - avs_library.name = (name ## _func) \ - GetProcAddress(avs_library.library, #name); \ + avs_library.name = dlsym(avs_library.library, #name); \ if (!continue_on_fail && !avs_library.name) \ goto fail; @@ -145,7 +141,7 @@ static av_cold int avisynth_load_library(void) LOAD_AVS_FUNC(avs_release_value, 0); LOAD_AVS_FUNC(avs_release_video_frame, 0); LOAD_AVS_FUNC(avs_take_clip, 0); -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH LOAD_AVS_FUNC(avs_bits_per_pixel, 1); LOAD_AVS_FUNC(avs_get_height_p, 1); LOAD_AVS_FUNC(avs_get_pitch_p, 1); @@ -160,7 +156,7 @@ static av_cold int avisynth_load_library(void) return 0; fail: - FreeLibrary(avs_library.library); + dlclose(avs_library.library); return AVERROR_UNKNOWN; } @@ -228,7 +224,7 @@ static av_cold void avisynth_atexit_handler(void) avisynth_context_destroy(avs); avs = next; } - FreeLibrary(avs_library.library); + dlclose(avs_library.library); avs_atexit_called = 1; } @@ -252,7 +248,7 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) avpriv_set_pts_info(st, 32, avs->vi->fps_denominator, avs->vi->fps_numerator); switch (avs->vi->pixel_type) { -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH /* 10~16-bit YUV pix_fmts (AviSynth+) */ case AVS_CS_YUV444P10: st->codecpar->format = AV_PIX_FMT_YUV444P10; @@ -278,6 +274,18 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->format = AV_PIX_FMT_YUV420P12; planar = 1; break; + case AVS_CS_YUV444P14: + st->codecpar->format = AV_PIX_FMT_YUV444P14; + planar = 1; + break; + case AVS_CS_YUV422P14: + st->codecpar->format = AV_PIX_FMT_YUV422P14; + planar = 1; + break; + case AVS_CS_YUV420P14: + st->codecpar->format = AV_PIX_FMT_YUV420P14; + planar = 1; + break; case AVS_CS_YUV444P16: st->codecpar->format = AV_PIX_FMT_YUV444P16; planar = 1; @@ -340,6 +348,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->format = AV_PIX_FMT_GBRP12; planar = 3; break; + case AVS_CS_RGBP14: + st->codecpar->format = AV_PIX_FMT_GBRP14; + planar = 3; + break; case AVS_CS_RGBP16: st->codecpar->format = AV_PIX_FMT_GBRP16; planar = 3; @@ -349,6 +361,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) st->codecpar->format = AV_PIX_FMT_GBRAP; planar = 5; break; + case AVS_CS_RGBAP10: + st->codecpar->format = AV_PIX_FMT_GBRAP10; + planar = 5; + break; case AVS_CS_RGBAP12: st->codecpar->format = AV_PIX_FMT_GBRAP12; planar = 5; @@ -508,7 +524,7 @@ static int avisynth_open_file(AVFormatContext *s) AviSynthContext *avs = s->priv_data; AVS_Value arg, val; int ret; -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH char filename_ansi[MAX_PATH * 4]; wchar_t filename_wc[MAX_PATH * 4]; #endif @@ -516,7 +532,7 @@ static int avisynth_open_file(AVFormatContext *s) if (ret = avisynth_context_create(s)) return ret; -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH /* Convert UTF-8 to ANSI code page */ MultiByteToWideChar(CP_UTF8, 0, s->filename, -1, filename_wc, MAX_PATH * 4); WideCharToMultiByte(CP_THREAD_ACP, 0, filename_wc, -1, filename_ansi, @@ -540,8 +556,8 @@ static int avisynth_open_file(AVFormatContext *s) avs->clip = avs_library.avs_take_clip(val, avs->env); avs->vi = avs_library.avs_get_video_info(avs->clip); -#if CONFIG_AVISYNTH - /* On Windows, libav supports AviSynth interface version 6 or higher. +#ifdef USING_AVISYNTH + /* On Windows, FFmpeg supports AviSynth interface version 6 or higher. * This includes AviSynth 2.6 RC1 or higher, and AviSynth+ r1718 or higher, * and excludes 2.5 and the 2.6 alphas. Since AvxSynth identifies itself * as interface version 3 like 2.5.8, this needs to be special-cased. */ @@ -604,7 +620,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, if (discard) return 0; -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH /* Detect whether we're using AviSynth 2.6 or AviSynth+ by * looking for whether avs_is_planar_rgb exists. */ if (GetProcAddress(avs_library.library, "avs_is_planar_rgb") == NULL) @@ -648,7 +664,7 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, dst_p = pkt->data; for (i = 0; i < avs->n_planes; i++) { plane = avs->planes[i]; -#if CONFIG_AVISYNTH +#ifdef USING_AVISYNTH src_p = avs_library.avs_get_read_ptr_p(frame, plane); pitch = avs_library.avs_get_pitch_p(frame, plane); |