From patchwork Wed Mar 11 10:50:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hutchinson X-Patchwork-Id: 18123 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D55FA44A573 for ; Wed, 11 Mar 2020 12:58:44 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE0A168AD7A; Wed, 11 Mar 2020 12:58:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26776688106 for ; Wed, 11 Mar 2020 12:58:38 +0200 (EET) Received: by mail-ot1-f67.google.com with SMTP id a9so1459263otl.6 for ; Wed, 11 Mar 2020 03:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=BJW5HSn35GiH6KxWIW0VvhN3ExqdWB1Dm87INV6tIKc=; b=X16CAnACjxCebtENsSJMn4Ue5FyS2f86jMPpt1q0o78/VYmTQALAIC0zz8kX09QCgU rAVYJf1uMkgoVtVUa8xbAOyrsXaM2Ovf0rV7nujqPGyIKYKtE201tTRc4uevqHLxJxWd KxWYS5aAQO9WVXOhxkBdxozeq+OwIcvZL7FO0CqCqFSqN/vVv0sif8wG37RDnCpmdjtP qliBfI2iE2e7rrPenYKl3uqRnNMhyKo0lFUSGZllGjfnBkNwWOfPintGyyPESfvcAg2g QvnBFoLDNWTLU73O5WUdhR5Ko3dvxADF0ylLyfuKa+w76zQvzAmzKu1nGmeiX/QiDKdZ oRQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BJW5HSn35GiH6KxWIW0VvhN3ExqdWB1Dm87INV6tIKc=; b=RTXpseD4pzIaDrwcf1eVAnvRHiXOGfyxcLYpiKTjHKg8v2b8EBozjszrCs+n2jdfGY C3MbvOG+o71CQMO3USnBYMxDBUfqKAKzAKlawKwvl2gfJ309PB8CbUD8M08CJJoOjXSp cYB9WVp2kLJNK5GwOJwV/Wp3HPRVS1bvujIjYYS2iLwEiqryllQPfeMnweA9BB0bAa2w MqgcKVOLlqA/21FJ6clE1yaRSPxAadoWr+UI2rEhNXMmgdwB8QeGjJw/KkIZJVy/llqH ocb8MJmzgrUpQ0lhzKk2ILM5iVxtI0bPpjapyJd9X66miWvFo6f1U7OrkqbGGBaTbEQy yB+w== X-Gm-Message-State: ANhLgQ1BkLCPwBW1+CgjmTjHbZRosQKUI3MDicfp8ISMxr1uqaa3f+gO aPFGeubWhQEy56tQzyHihG3eiBl5 X-Google-Smtp-Source: ADFU+vsADWAfDN2KW8Y0tu9O8EHawnty8Ks/gAWiQiZqEBdq54ITdK5POfBgBwZYX4dNnEXNT2rkcQ== X-Received: by 2002:a5b:48e:: with SMTP id n14mr2179972ybp.462.1583923826658; Wed, 11 Mar 2020 03:50:26 -0700 (PDT) Received: from localhost.localdomain ([75.115.109.114]) by smtp.gmail.com with ESMTPSA id t186sm4344839ywb.37.2020.03.11.03.50.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 03:50:26 -0700 (PDT) From: Stephen Hutchinson To: ffmpeg-devel@ffmpeg.org Date: Wed, 11 Mar 2020 06:50:16 -0400 Message-Id: <20200311105019.8553-3-qyot27@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200311105019.8553-1-qyot27@gmail.com> References: <20200311105019.8553-1-qyot27@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avisynth: switch to AviSynth+ on Linux X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" AviSynth+ now supports non-Windows OSes, making AvxSynth obsolete. Since we no longer support AviSynth 2.5 (which is essentially what AvxSynth is), remove AvxSynth support and replace it with AviSynth+. As a result, the USING_AVISYNTH defines can be switched back to generic _WIN32. --- libavformat/avisynth.c | 56 +++++++++++------------------------------- 1 file changed, 15 insertions(+), 41 deletions(-) diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 55a2efd884..1970553e49 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -1,5 +1,5 @@ /* - * AviSynth/AvxSynth support + * AviSynth(+) support * Copyright (c) 2012 AvxSynth Team * * This file is part of FFmpeg @@ -31,20 +31,19 @@ /* Enable function pointer definitions for runtime loading. */ #define AVSC_NO_DECLSPEC -/* Platform-specific directives for AviSynth vs AvxSynth. */ +/* Platform-specific directives. */ #ifdef _WIN32 #include "compat/w32dlfcn.h" #undef EXTERN_C - #include "compat/avisynth/avisynth_c.h" #define AVISYNTH_LIB "avisynth" - #define USING_AVISYNTH #else #include - #include "compat/avisynth/avxsynth_c.h" - #define AVISYNTH_NAME "libavxsynth" + #define AVISYNTH_NAME "libavisynth" #define AVISYNTH_LIB AVISYNTH_NAME SLIBSUF #endif +#include "compat/avisynth/avisynth_c.h" + typedef struct AviSynthLibrary { void *library; #define AVSC_DECLARE_FUNC(name) name ## _func name @@ -62,7 +61,6 @@ typedef struct AviSynthLibrary { AVSC_DECLARE_FUNC(avs_release_value); AVSC_DECLARE_FUNC(avs_release_video_frame); AVSC_DECLARE_FUNC(avs_take_clip); -#ifdef USING_AVISYNTH AVSC_DECLARE_FUNC(avs_bits_per_pixel); AVSC_DECLARE_FUNC(avs_get_height_p); AVSC_DECLARE_FUNC(avs_get_pitch_p); @@ -70,7 +68,6 @@ typedef struct AviSynthLibrary { AVSC_DECLARE_FUNC(avs_get_row_size_p); AVSC_DECLARE_FUNC(avs_is_planar_rgb); AVSC_DECLARE_FUNC(avs_is_planar_rgba); -#endif #undef AVSC_DECLARE_FUNC } AviSynthLibrary; @@ -97,14 +94,12 @@ static const int avs_planes_packed[1] = { 0 }; static const int avs_planes_grey[1] = { AVS_PLANAR_Y }; static const int avs_planes_yuv[3] = { AVS_PLANAR_Y, AVS_PLANAR_U, AVS_PLANAR_V }; -#ifdef USING_AVISYNTH static const int avs_planes_rgb[3] = { AVS_PLANAR_G, AVS_PLANAR_B, AVS_PLANAR_R }; static const int avs_planes_yuva[4] = { AVS_PLANAR_Y, AVS_PLANAR_U, AVS_PLANAR_V, AVS_PLANAR_A }; static const int avs_planes_rgba[4] = { AVS_PLANAR_G, AVS_PLANAR_B, AVS_PLANAR_R, AVS_PLANAR_A }; -#endif /* A conflict between C++ global objects, atexit, and dynamic loading requires * us to register our own atexit handler to prevent double freeing. */ @@ -142,7 +137,6 @@ 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); -#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); @@ -150,7 +144,6 @@ static av_cold int avisynth_load_library(void) LOAD_AVS_FUNC(avs_get_row_size_p, 1); LOAD_AVS_FUNC(avs_is_planar_rgb, 1); LOAD_AVS_FUNC(avs_is_planar_rgba, 1); -#endif #undef LOAD_AVS_FUNC atexit(avisynth_atexit_handler); @@ -249,7 +242,6 @@ 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) { -#ifdef USING_AVISYNTH /* 10~16-bit YUV pix_fmts (AviSynth+) */ case AVS_CS_YUV444P10: st->codecpar->format = AV_PIX_FMT_YUV444P10; @@ -434,8 +426,7 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) case AVS_CS_BGR64: st->codecpar->format = AV_PIX_FMT_BGRA64; break; -#endif - /* AviSynth 2.5 and AvxSynth pix_fmts */ + /* AviSynth 2.5 pix_fmts */ case AVS_CS_BGR24: st->codecpar->format = AV_PIX_FMT_BGR24; break; @@ -461,7 +452,6 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) } switch (planar) { -#ifdef USING_AVISYNTH case 5: // Planar RGB + Alpha avs->n_planes = 4; avs->planes = avs_planes_rgba; @@ -474,7 +464,6 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st) avs->n_planes = 3; avs->planes = avs_planes_rgb; break; -#endif case 2: // Y8 avs->n_planes = 1; avs->planes = avs_planes_grey; @@ -556,7 +545,7 @@ static int avisynth_open_file(AVFormatContext *s) AviSynthContext *avs = s->priv_data; AVS_Value arg, val; int ret; -#ifdef USING_AVISYNTH +#ifdef _WIN32 char filename_ansi[MAX_PATH * 4]; wchar_t filename_wc[MAX_PATH * 4]; #endif @@ -564,7 +553,7 @@ static int avisynth_open_file(AVFormatContext *s) if (ret = avisynth_context_create(s)) return ret; -#ifdef USING_AVISYNTH +#ifdef _WIN32 /* 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, @@ -588,11 +577,9 @@ 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); -#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. */ + * and excludes 2.5 and the 2.6 alphas. */ if (avs_library.avs_get_version(avs->clip) < 6) { av_log(s, AV_LOG_ERROR, @@ -600,7 +587,6 @@ static int avisynth_open_file(AVFormatContext *s) ret = AVERROR_UNKNOWN; goto fail; } -#endif /* Release the AVS_Value as it will go out of scope. */ avs_library.avs_release_value(val); @@ -652,23 +638,21 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, if (discard) return 0; -#ifdef USING_AVISYNTH +#ifdef _WIN32 /* 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) avsplus = 0; else avsplus = 1; - - /* avs_bits_per_pixel changed to AVSC_API with AviSynth 2.6, which - * requires going through avs_library, while AvxSynth has it under - * the older AVSC_INLINE type, so special-case this. */ - - bits = avs_library.avs_bits_per_pixel(avs->vi); #else - bits = avs_bits_per_pixel(avs->vi); + /* AviSynth+ is now the only variant of AviSynth we support + * on Linux and macOS. */ + avsplus = 1; #endif + bits = avs_library.avs_bits_per_pixel(avs->vi); + /* Without the cast to int64_t, calculation overflows at about 9k x 9k * resolution. */ pkt->size = (((int64_t)avs->vi->width * @@ -696,19 +680,11 @@ 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]; -#ifdef USING_AVISYNTH src_p = avs_library.avs_get_read_ptr_p(frame, plane); pitch = avs_library.avs_get_pitch_p(frame, plane); rowsize = avs_library.avs_get_row_size_p(frame, plane); planeheight = avs_library.avs_get_height_p(frame, plane); -#else - src_p = avs_get_read_ptr_p(frame, plane); - pitch = avs_get_pitch_p(frame, plane); - - rowsize = avs_get_row_size_p(frame, plane); - planeheight = avs_get_height_p(frame, plane); -#endif /* Flip RGB video. */ if (avs_is_rgb24(avs->vi) || avs_is_rgb(avs->vi)) { @@ -716,14 +692,12 @@ static int avisynth_read_packet_video(AVFormatContext *s, AVPacket *pkt, pitch = -pitch; } -#ifdef USING_AVISYNTH /* Flip Planar RGB video */ if (avsplus && (avs_library.avs_is_planar_rgb(avs->vi) || avs_library.avs_is_planar_rgba(avs->vi))) { src_p = src_p + (planeheight - 1) * pitch; pitch = -pitch; } -#endif avs_library.avs_bit_blt(avs->env, dst_p, rowsize, src_p, pitch, rowsize, planeheight);