From patchwork Mon May 31 07:54:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28006 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2655933iof; Mon, 31 May 2021 00:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw88PJwi6AwieQGrnNy4boXkM2GHOGIPLlLRcSDfkXwg1+TpIrvhxgxk47d5yHH0gzyMz1 X-Received: by 2002:a05:6402:4381:: with SMTP id o1mr24781934edc.188.1622447734520; Mon, 31 May 2021 00:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447734; cv=none; d=google.com; s=arc-20160816; b=rdfiaAfL1BJHYv4KB8CRNlQys3a8pM1RYVLM46/VdnaU//8ecBSOmAVSgGTuBsTK2R RhelOgQ3BvCWQqS5yMPezfK9Xu2qasji6053IubsbvI8j9nvRDY4e3EqmgNyJCvKJqES gkK+65Y9tP919T/jRFCh7Yro8mgKhkf81tv3JXW46S//GFqrimCMctDUf74UbYi5Ay6K zSfUZI27g+eM3rdECWbQk+LTwiQ5P4ZVFjwWJ57vDUwq5keE/z6ei4aYQMzl1SUHi9GX kfubdntvWtkEh+YU644FlUBCHa0wTY3IisOSszRxHl13qQuDp/CiVRl/sNiVeK9M0FMu cEFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=UjQEgr9ZjJPjuvws2m+aEdWB4t3WBYAOXxygKKR4vDw=; b=Lz3zq2pWVRw34bNSygYynttczBW8gkXvNFw+u9H3e8ZplJFlkn8z7/TaSaShRKkinu 5OBBS1kYO4HIlWf+XR1S4WUuIA0RP2RbdPMBxq3SM/3a8Sk9aWCAyAFDLhPyUVLKBBcp pfncf1KEBAdBTtetgI1qe5OWzeQIhUnrVp+vbcHYHHFM8coZS3JdjIb1Ywzur0dPED5F diFpt+1DQpsVG9sHv+ZDyY/y+CNeIpn+LbnHtEfxeFAiLofWH6pt8w/o642spyc/LZcA h6AiKOoetF8FP5iUqYLIjCVSwZ88cb67EvomVbPTrFP0z5ZTzRmqpiGtj7F5QA+M/OAV hz1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j3si2760177ejv.180.2021.05.31.00.55.33; Mon, 31 May 2021 00:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C820168803D; Mon, 31 May 2021 10:55:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E22E2687FE1 for ; Mon, 31 May 2021 10:55:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 0D85924069B for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id aecrUFcXVrQt for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 80644240476 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id D110C3A125B; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:52 +0200 Message-Id: <20210531075515.19544-1-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/24] sws: remove unnecessary braces X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: lyXT2RY6a9uM There used to be more code inside them, but it was removed in 6de58b49032a206985602effec91e5e46c886ea2. --- libswscale/swscale.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 12160a169a..6b73c71e41 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -487,10 +487,8 @@ static int swscale(SwsContext *c, const uint8_t *src[], yuv2packed1, yuv2packed2, yuv2packedX, yuv2anyX, use_mmx_vfilter); } - { - for (i = vStart; i < vEnd; ++i) - desc[i].process(c, &desc[i], dstY, 1); - } + for (i = vStart; i < vEnd; ++i) + desc[i].process(c, &desc[i], dstY, 1); } if (isPlanar(dstFormat) && isALPHA(dstFormat) && !needAlpha) { int length = dstW; From patchwork Mon May 31 07:54:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27994 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656018iof; Mon, 31 May 2021 00:55:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaUnn7i9XfyQjA2wHzDD35mKkqkdxUBc8TrzrfOiiCrIq6RIuDZ1whjBVEvO7YI1pjsglj X-Received: by 2002:aa7:d853:: with SMTP id f19mr24227851eds.371.1622447745359; Mon, 31 May 2021 00:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447745; cv=none; d=google.com; s=arc-20160816; b=sDKbM7NfgHW13C5NVAWmvTtV75v0/pZiyDIbAKHMwwkET2Q41+s4202mjgcIFdWqOa af78ortSfayQtCKg8sRceJqAD3OOSRNDURMEna+nU2XVAdf7Y0BgjiSVHbKXdglOagER Mz6sUgY8RE3JNx0Yosl+hVP1O4+juJDV3bvBRQMLYJhI6bosjukzwXsTUeCWyQREFjpr vgguWLQuICwWgfghUbwA8qLkSBRXT965IQszjkg5dqNMplciJ2z/Uv/PQvOJruOfpy8G foep00c2WHIhUnQwbX4grkhymHNt72R4zYfUA+5OCbxgzkDlfeSUSajnzMUDH3lYWjwn H/Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=yponZFAQhRQHgceewPfGkJbG5Zy6G+9vycqZE6HlUBs=; b=VSink4TBbfSiL2rl8KMRVnJ+THnZLxPtuYoshMV5JMSKYOXbgdC0a9WANFlUyqpn+/ KLXHbGIQ8iXkkfB257rEZOUslTa8wffVVxrDJarvuUVFOMN2f1Exp8sgJPk7mXQcGGFW /jlYtYBNg/40sGib42arPLKQru2gdk7Mi34jP0ErcDW8/hwTq3wSalNj714Mul2qcuGG kujEVPiNwTxCg1vBdcPye7yS3mLM+aG7ZSYy7d9FS3rMFW0W4dPlYP6LkPWvMPGDyl6p RArEuQpBeTKjdIU1w51TCdIfKAe2+4nVtsBsFE9pXaTTctSoD1eMA5UPosc6R3fSvft3 dh7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x14si6180085ejw.176.2021.05.31.00.55.45; Mon, 31 May 2021 00:55:45 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 164FA6804B3; Mon, 31 May 2021 10:55:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DFC7D6808F5 for ; Mon, 31 May 2021 10:55:22 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 3032E24069D for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id h_1ZeUAZBKT1 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 7EDCE24042A for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id D56123A13B6; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:53 +0200 Message-Id: <20210531075515.19544-2-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/24] sws: factor out updating the palette X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: fVnZxgNUcREM --- libswscale/swscale.c | 150 ++++++++++++++++++++++--------------------- 1 file changed, 77 insertions(+), 73 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 6b73c71e41..7690f81450 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -736,6 +736,81 @@ static void rgb48Toxyz12(struct SwsContext *c, uint16_t *dst, } } +static void update_palette(SwsContext *c, const uint32_t *pal) +{ + for (int i = 0; i < 256; i++) { + int r, g, b, y, u, v, a = 0xff; + if (c->srcFormat == AV_PIX_FMT_PAL8) { + uint32_t p = pal[i]; + a = (p >> 24) & 0xFF; + r = (p >> 16) & 0xFF; + g = (p >> 8) & 0xFF; + b = p & 0xFF; + } else if (c->srcFormat == AV_PIX_FMT_RGB8) { + r = ( i >> 5 ) * 36; + g = ((i >> 2) & 7) * 36; + b = ( i & 3) * 85; + } else if (c->srcFormat == AV_PIX_FMT_BGR8) { + b = ( i >> 6 ) * 85; + g = ((i >> 3) & 7) * 36; + r = ( i & 7) * 36; + } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { + r = ( i >> 3 ) * 255; + g = ((i >> 1) & 3) * 85; + b = ( i & 1) * 255; + } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { + r = g = b = i; + } else { + av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); + b = ( i >> 3 ) * 255; + g = ((i >> 1) & 3) * 85; + r = ( i & 1) * 255; + } +#define RGB2YUV_SHIFT 15 +#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) +#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) + + y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24); + + switch (c->dstFormat) { + case AV_PIX_FMT_BGR32: +#if !HAVE_BIGENDIAN + case AV_PIX_FMT_RGB24: +#endif + c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24); + break; + case AV_PIX_FMT_BGR32_1: +#if HAVE_BIGENDIAN + case AV_PIX_FMT_BGR24: +#endif + c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24); + break; + case AV_PIX_FMT_RGB32_1: +#if HAVE_BIGENDIAN + case AV_PIX_FMT_RGB24: +#endif + c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24); + break; + case AV_PIX_FMT_RGB32: +#if !HAVE_BIGENDIAN + case AV_PIX_FMT_BGR24: +#endif + default: + c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24); + } + } +} + /** * swscale wrapper, so we don't need to export the SwsContext. * Assumes planar YUV to be in YUV order instead of YVU. @@ -833,79 +908,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } - if (usePal(c->srcFormat)) { - for (i = 0; i < 256; i++) { - int r, g, b, y, u, v, a = 0xff; - if (c->srcFormat == AV_PIX_FMT_PAL8) { - uint32_t p = ((const uint32_t *)(srcSlice[1]))[i]; - a = (p >> 24) & 0xFF; - r = (p >> 16) & 0xFF; - g = (p >> 8) & 0xFF; - b = p & 0xFF; - } else if (c->srcFormat == AV_PIX_FMT_RGB8) { - r = ( i >> 5 ) * 36; - g = ((i >> 2) & 7) * 36; - b = ( i & 3) * 85; - } else if (c->srcFormat == AV_PIX_FMT_BGR8) { - b = ( i >> 6 ) * 85; - g = ((i >> 3) & 7) * 36; - r = ( i & 7) * 36; - } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { - r = ( i >> 3 ) * 255; - g = ((i >> 1) & 3) * 85; - b = ( i & 1) * 255; - } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { - r = g = b = i; - } else { - av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); - b = ( i >> 3 ) * 255; - g = ((i >> 1) & 3) * 85; - r = ( i & 1) * 255; - } -#define RGB2YUV_SHIFT 15 -#define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define BU ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define GY ( (int) (0.587 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define GV (-(int) (0.419 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define GU (-(int) (0.331 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define RY ( (int) (0.299 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) -#define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) - - y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24); - - switch (c->dstFormat) { - case AV_PIX_FMT_BGR32: -#if !HAVE_BIGENDIAN - case AV_PIX_FMT_RGB24: -#endif - c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24); - break; - case AV_PIX_FMT_BGR32_1: -#if HAVE_BIGENDIAN - case AV_PIX_FMT_BGR24: -#endif - c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24); - break; - case AV_PIX_FMT_RGB32_1: -#if HAVE_BIGENDIAN - case AV_PIX_FMT_RGB24: -#endif - c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24); - break; - case AV_PIX_FMT_RGB32: -#if !HAVE_BIGENDIAN - case AV_PIX_FMT_BGR24: -#endif - default: - c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24); - } - } - } + if (usePal(c->srcFormat)) + update_palette(c, (const uint32_t *)srcSlice[1]); if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; From patchwork Mon May 31 07:54:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28000 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656219iof; Mon, 31 May 2021 00:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2KqRQawadwBqBA9tIMHxxJd2mZ7b+N7nftulTZNsaNKot517E7XYhxBFRqjdj1hNYOXBD X-Received: by 2002:a50:ed13:: with SMTP id j19mr24185620eds.190.1622447765991; Mon, 31 May 2021 00:56:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447765; cv=none; d=google.com; s=arc-20160816; b=h1iRlFyhM/LRgb+t3fpSi99vrqNjqWW1sl1PPOznGz5CouXe5Tm2K9XH6VUo/GIw3t nN5g06Frv/sYbL3YJLjafgyhdrsQQ/soDg0y1/M+mEKar8TfgFPIq2HYMk3n/XGxkKbq 0CTkFfXy8lqg1jmyJ6cWhWyuzmbLdLJ9s61noHZxjFlP6zoq2EiRJgYcH7scYVkS7OWT wdJjOdnliVjAtYqfGke6QtQqhTLV+at075EnpRPO2HQq3n1KhbaBE5pE6PZnpS+RlCCJ CQD71tceKVAnF4eLlUNbARRfPxt0EYA1y/XGsURI+SXrlkSw2jVi387j5XLz2UYb47n9 7/ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=WBOrwTeHd9faULZf3Ryq9126CDY5FrOXK7x5TyfUv+8=; b=W9kc+lo+5+vKzrtEhy1LOpz8dILm/7IiRPoP9iWckQYI1TZhQJWi0/uAc03Ic9/8cb TlbyF9Luccag7xDcEybIB8ZsYWP6ITIz5tSZCkIbhNn+vpZwDR57IL5nBapHBFti0lxj PVdCHpe2LGOTey3Kd7nZ6eFBeyjg03YF9ABgWndR1j+2lNgX9y+OXVq/spYZizcuwFi0 CYM1uQp26hVIX+8svRDql4XwasvksXCDRH3HSMET7ucrOw8hNNIltck1rC9hsLfA5Syz YBFBHynAm/Z6O6qHjTkTe/gTMYRWgL10DpyGI/2VUnMIMEPhe3IqjTgE4G5S4e6cVydX 0jBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 2si14073615edw.66.2021.05.31.00.56.05; Mon, 31 May 2021 00:56:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D3F9B688041; Mon, 31 May 2021 10:55:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 81C656808F5 for ; Mon, 31 May 2021 10:55:23 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D5FFD24068A for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id DCBziwpSg4Xq for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 8154D240477 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id D96723A13C0; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:54 +0200 Message-Id: <20210531075515.19544-3-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/24] sws: reindent after previous commit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: oeeaT+QoXyNQ --- libswscale/swscale.c | 100 +++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7690f81450..05e716dcc9 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -738,34 +738,34 @@ static void rgb48Toxyz12(struct SwsContext *c, uint16_t *dst, static void update_palette(SwsContext *c, const uint32_t *pal) { - for (int i = 0; i < 256; i++) { - int r, g, b, y, u, v, a = 0xff; - if (c->srcFormat == AV_PIX_FMT_PAL8) { - uint32_t p = pal[i]; - a = (p >> 24) & 0xFF; - r = (p >> 16) & 0xFF; - g = (p >> 8) & 0xFF; - b = p & 0xFF; - } else if (c->srcFormat == AV_PIX_FMT_RGB8) { - r = ( i >> 5 ) * 36; - g = ((i >> 2) & 7) * 36; - b = ( i & 3) * 85; - } else if (c->srcFormat == AV_PIX_FMT_BGR8) { - b = ( i >> 6 ) * 85; - g = ((i >> 3) & 7) * 36; - r = ( i & 7) * 36; - } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { - r = ( i >> 3 ) * 255; - g = ((i >> 1) & 3) * 85; - b = ( i & 1) * 255; - } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { - r = g = b = i; - } else { - av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); - b = ( i >> 3 ) * 255; - g = ((i >> 1) & 3) * 85; - r = ( i & 1) * 255; - } + for (int i = 0; i < 256; i++) { + int r, g, b, y, u, v, a = 0xff; + if (c->srcFormat == AV_PIX_FMT_PAL8) { + uint32_t p = pal[i]; + a = (p >> 24) & 0xFF; + r = (p >> 16) & 0xFF; + g = (p >> 8) & 0xFF; + b = p & 0xFF; + } else if (c->srcFormat == AV_PIX_FMT_RGB8) { + r = ( i >> 5 ) * 36; + g = ((i >> 2) & 7) * 36; + b = ( i & 3) * 85; + } else if (c->srcFormat == AV_PIX_FMT_BGR8) { + b = ( i >> 6 ) * 85; + g = ((i >> 3) & 7) * 36; + r = ( i & 7) * 36; + } else if (c->srcFormat == AV_PIX_FMT_RGB4_BYTE) { + r = ( i >> 3 ) * 255; + g = ((i >> 1) & 3) * 85; + b = ( i & 1) * 255; + } else if (c->srcFormat == AV_PIX_FMT_GRAY8 || c->srcFormat == AV_PIX_FMT_GRAY8A) { + r = g = b = i; + } else { + av_assert1(c->srcFormat == AV_PIX_FMT_BGR4_BYTE); + b = ( i >> 3 ) * 255; + g = ((i >> 1) & 3) * 85; + r = ( i & 1) * 255; + } #define RGB2YUV_SHIFT 15 #define BY ( (int) (0.114 * 219 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define BV (-(int) (0.081 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) @@ -777,38 +777,38 @@ static void update_palette(SwsContext *c, const uint32_t *pal) #define RV ( (int) (0.500 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) #define RU (-(int) (0.169 * 224 / 255 * (1 << RGB2YUV_SHIFT) + 0.5)) - y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); - c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24); + y = av_clip_uint8((RY * r + GY * g + BY * b + ( 33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + u = av_clip_uint8((RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + v = av_clip_uint8((RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT); + c->pal_yuv[i]= y + (u<<8) + (v<<16) + ((unsigned)a<<24); - switch (c->dstFormat) { - case AV_PIX_FMT_BGR32: + switch (c->dstFormat) { + case AV_PIX_FMT_BGR32: #if !HAVE_BIGENDIAN - case AV_PIX_FMT_RGB24: + case AV_PIX_FMT_RGB24: #endif - c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24); - break; - case AV_PIX_FMT_BGR32_1: + c->pal_rgb[i]= r + (g<<8) + (b<<16) + ((unsigned)a<<24); + break; + case AV_PIX_FMT_BGR32_1: #if HAVE_BIGENDIAN - case AV_PIX_FMT_BGR24: + case AV_PIX_FMT_BGR24: #endif - c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24); - break; - case AV_PIX_FMT_RGB32_1: + c->pal_rgb[i]= a + (r<<8) + (g<<16) + ((unsigned)b<<24); + break; + case AV_PIX_FMT_RGB32_1: #if HAVE_BIGENDIAN - case AV_PIX_FMT_RGB24: + case AV_PIX_FMT_RGB24: #endif - c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24); - break; - case AV_PIX_FMT_RGB32: + c->pal_rgb[i]= a + (b<<8) + (g<<16) + ((unsigned)r<<24); + break; + case AV_PIX_FMT_RGB32: #if !HAVE_BIGENDIAN - case AV_PIX_FMT_BGR24: + case AV_PIX_FMT_BGR24: #endif - default: - c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24); - } + default: + c->pal_rgb[i]= b + (g<<8) + (r<<16) + ((unsigned)a<<24); } + } } /** From patchwork Mon May 31 07:54:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28015 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656106iof; Mon, 31 May 2021 00:55:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt6Y3u/xENAQQGj4Pz+tzYSh5JxL2p1bkNrJN2QSfHBrm7SxJhrrdDTeEupyNaMhjSKxm8 X-Received: by 2002:a17:906:1815:: with SMTP id v21mr21539452eje.376.1622447755531; Mon, 31 May 2021 00:55:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447755; cv=none; d=google.com; s=arc-20160816; b=xyw4zeIfo/XxpQFJdeW8xmulDFkgPO7FDQc2jA6MEofJXiQr38RNawEmfgK4qnWaOx 4hn4gyyZ38gpMvHFC7xUdTw57mUqlc116k/noRIUNclam3YR30iUaYVOZG6u1hGKAYQq 97yTv9ciEhKiGMxdW0gP9wfqlV3+uBa93KrxL8Xy59QPw1DXchjPfh1Qg04e4TS+cpbX J4ezYWGC18dvC69J2WTKxqVTABIQ5KhJSFmheTfCn1lvDdcSMmf388RBtCTgJD5wn+1U L4DXmhUlTo/jaU3Un+hR2H1x7JQbq4NX+Sveog3j091tYbFRlJ6rTeO2imamiAhffZxr enhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=qCVHp2/VhxaceM1pTOCHfprO5b43tLoWnDsMwDnFSCo=; b=D/ccRd3aEQlynnbLyOOE8K6Ic6gVKpZgJDSSWwonkLhGCv5V7W8oOULQDlHXCNjlQ7 cusLfKDQEecBf7MYGftgEXxtN76au7FyyrbWOyNy9bAYvLIqraXJzMotgDQUqyzomasT NqdJo4t2/vk3PjOy22g3xaeqag1bcwN8umvgus4b7QlZR7uThsBbZm7aL+FVUJBqhdir ZgWZL1bhi53FrSnfFiFHJ3OlpizgT9pWmyPT0piC31brzexARpnxN+mt60n3USAwotSi glKmWKtx5siipn4YKJHnPuAlzmZE1WXfmscxFV7Sr3xc7/oyjmyvrR4Dusio2lBDZPhJ D7mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o15si7259529eju.373.2021.05.31.00.55.55; Mon, 31 May 2021 00:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E28936882FD; Mon, 31 May 2021 10:55:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 494C56808F5 for ; Mon, 31 May 2021 10:55:23 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9DAA52406A6 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id y0BYoLARD7pM for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 841C724068A for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id DD6D33A13C3; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:55 +0200 Message-Id: <20210531075515.19544-4-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/24] sws: return an error code on invalid parameters to sws_scale() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: Mf0L+kiy/aQy --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 05e716dcc9..9743c56295 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -833,7 +833,7 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (!srcStride || !dstStride || !dst || !srcSlice) { av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n"); - return 0; + return AVERROR(EINVAL); } for (i=0; i<4; i++) { From patchwork Mon May 31 07:54:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28002 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656303iof; Mon, 31 May 2021 00:56:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB/yK0f9rMClQbYzZwU74eNBdZ6NcL4v1m0qogCKCBu2mHuk7xFeydg/8IX4FwX9fC999n X-Received: by 2002:a17:906:2510:: with SMTP id i16mr515157ejb.218.1622447775498; Mon, 31 May 2021 00:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447775; cv=none; d=google.com; s=arc-20160816; b=xTZ3IGAeiex7X4/wkvO4pp1V6pTRq3mcStd/LoTV2I3q3eZtC6DUyjemcUjFydBl0L N8/Cp9VFKhUAQC3yHZIwoVHDjqMSNml3rrQpOJba11jmjfJYRuFTWHLdnlawy8rHpX7P Tb1shBtLzPcIiXZ3zC2GQAR+jrig/UQ9zDKZ/2gvrUK+ewI3isMuLvlWVBPLdL4he9un y6wID4ww5Zk+2/tiOYtWpvEXv3IC7OV2E5PiquI/cL4qdV0kkW3VfK6o9kRSoeqAB0oV EFAeZhYI079nSfDzVFhKWVuqOKnIJfmzfzKqFSumKR7vDTwTTtsSICq4SiKb+9o6E+FZ Yf/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=CQqHJ0F7ksD67OScuh1L2y8v6UO5ycW15Pn/khwz/gM=; b=RF18dtfQ09Mebdjs+wj1QZxfwN2SAsm/EvQMXq4rcoSSWRfe2F+ddyYZxJBn4hWMjV lfI0S4r3JxtQwW5RSTO1YmuLrYm2cfVgz9WNA7mnvXiwmsdNZF35oqs/++jgfHIo14xM E8ynm1F5TAXJfqa9qpd5f5gokZ0wVYfXHtKAHLG1qod7OusEC4DpmklJ6ROuXg+lYlj6 hhDpOZuika3G8ksnMo1QRR4Tkrti1vOK+bNMHW7fA33WjaLT/RIueoY97eQCfEhbJ0bT TtG0xVKDagMUAYn4mFQG+Q7P+PO3pr3sjfX9FaEZmzpZH04MfcpoKojZ/bwYhNcsA9wL 3IhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ga25si10857027ejc.349.2021.05.31.00.56.15; Mon, 31 May 2021 00:56:15 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CAE29688078; Mon, 31 May 2021 10:55:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B3A7F6808F5 for ; Mon, 31 May 2021 10:55:23 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 145D4240477 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id c0PAopKKyYNy for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 82BFE2405C5 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id E19B53A13D9; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:56 +0200 Message-Id: <20210531075515.19544-5-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/24] sws: factor out gamma-correct scaling X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: G5xrY01Uye4a --- libswscale/swscale.c | 53 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 9743c56295..876dc05442 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -811,6 +811,34 @@ static void update_palette(SwsContext *c, const uint32_t *pal) } } +static int scale_gamma(SwsContext *c, + const uint8_t * const srcSlice[], const int srcStride[], + int srcSliceY, int srcSliceH, + uint8_t * const dst[], const int dstStride[]) +{ + int ret = sws_scale(c->cascaded_context[0], + srcSlice, srcStride, srcSliceY, srcSliceH, + c->cascaded_tmp, c->cascaded_tmpStride); + + if (ret < 0) + return ret; + + if (c->cascaded_context[2]) + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride); + else + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); + + if (ret < 0) + return ret; + + if (c->cascaded_context[2]) { + ret = sws_scale(c->cascaded_context[2], + (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY, + dst, dstStride); + } + return ret; +} + /** * swscale wrapper, so we don't need to export the SwsContext. * Assumes planar YUV to be in YUV order instead of YVU. @@ -848,29 +876,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } - if (c->gamma_flag && c->cascaded_context[0]) { - ret = sws_scale(c->cascaded_context[0], - srcSlice, srcStride, srcSliceY, srcSliceH, - c->cascaded_tmp, c->cascaded_tmpStride); - - if (ret < 0) - return ret; - - if (c->cascaded_context[2]) - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride); - else - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); - - if (ret < 0) - return ret; - - if (c->cascaded_context[2]) { - ret = sws_scale(c->cascaded_context[2], - (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY, - dst, dstStride); - } - return ret; - } + if (c->gamma_flag && c->cascaded_context[0]) + return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) { ret = sws_scale(c->cascaded_context[0], From patchwork Mon May 31 07:54:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28003 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657740iof; Mon, 31 May 2021 00:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM+2Rxlr8BDpqhvBzfBKxyxGbksCZJyTzuPcdIm8vKIjZp33tdima7OtuF86vCCMZVkBoG X-Received: by 2002:a05:6402:1d8e:: with SMTP id dk14mr24312301edb.385.1622447939104; Mon, 31 May 2021 00:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447939; cv=none; d=google.com; s=arc-20160816; b=Wr580tUGPV7H6XUiDW0osXjrAZ0qbJuphiVOgyCUEJnYc0IoFyMVUvmyoAsjIvfmBb sAmDzoSOb1Rl/Y75n6XS4KMewty9MgYDqBmPad5x51yvHzXXDKwrcqU58wZBDX7L3o74 Nb3Kd8Q0G/1HSZqRKRxPljovgG0q2aT4NAM++Ppoh8ckaJeMp3yMG+JQHtBkal2z7DjY ectPB+qLRTXWZb3rny+AaJLwzHRLmyfyJ3D5BInyadLSScx/CZRzh+axs9d5gE3nxosJ EAdwBG2a2gb/o0u2Z26Wc3JefZN0VFAaioi6vqIPgeCh1/2v0w60X4nXf64mFBYKM3gq hx0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=7qsre8CWpv2nLrouJCNafJds5HDlLlGeCGR3pSsoE6Q=; b=NdH2y2vcTFiih7d5iA77/UQt0iyozPxKgPJVx9KCLh9NC2o5Cpd/HhcmN4osIUl0vN DNREUsMaf+qkitH0783GzLmjBT8evK2Bs1R6Dr4Mp1ccbdrT+dju5Z+juZV+w+CymbZM UAsm0Fo5JkkWlqtYy1YkfQJQaCTLnvxP4ongOLfPja0O/Tb0Fp5vytWZmyH8cdInd3eg 7mJRQuw/FNsb/ZyIL05zmzhGI/+SVFG+0yzLESiTmpkboFNxmpe43WPSgymYpufeDMGE epjebmb6q3G0j5Uw6UfzkzbmN/bKFy5ZKQHtYPwxQi1vMr1LV+JWt7ZAbsRJCkMW0LEv vrzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q19si13605030edv.125.2021.05.31.00.58.58; Mon, 31 May 2021 00:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8D487689B0B; Mon, 31 May 2021 10:55:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 28D006883BF for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5122D240698 for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id breB3SRsIVdB for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E4C0A240696 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id E5B7E3A13E8; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:57 +0200 Message-Id: <20210531075515.19544-6-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/24] sws: cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: /ZIC7slN722N Reindent after previous commit, split long lines. --- libswscale/swscale.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 876dc05442..72285c3547 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -816,27 +816,30 @@ static int scale_gamma(SwsContext *c, int srcSliceY, int srcSliceH, uint8_t * const dst[], const int dstStride[]) { - int ret = sws_scale(c->cascaded_context[0], - srcSlice, srcStride, srcSliceY, srcSliceH, - c->cascaded_tmp, c->cascaded_tmpStride); + int ret = sws_scale(c->cascaded_context[0], + srcSlice, srcStride, srcSliceY, srcSliceH, + c->cascaded_tmp, c->cascaded_tmpStride); - if (ret < 0) - return ret; + if (ret < 0) + return ret; - if (c->cascaded_context[2]) - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, c->cascaded1_tmpStride); - else - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); + if (c->cascaded_context[2]) + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, + c->cascaded1_tmpStride); + else + ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); - if (ret < 0) - return ret; - - if (c->cascaded_context[2]) { - ret = sws_scale(c->cascaded_context[2], - (const uint8_t * const *)c->cascaded1_tmp, c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, c->cascaded_context[1]->dstY, - dst, dstStride); - } + if (ret < 0) return ret; + + if (c->cascaded_context[2]) { + ret = sws_scale(c->cascaded_context[2], (const uint8_t * const *)c->cascaded1_tmp, + c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, + c->cascaded_context[1]->dstY, dst, dstStride); + } + return ret; } /** From patchwork Mon May 31 07:54:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28011 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657428iof; Mon, 31 May 2021 00:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTxiyrEUJlVorzp3Ts4FPQ/dSpwvo1WvkcpeO/aRUIMFgnUbPdsIcLP+MdGPmc33kCY/vm X-Received: by 2002:a17:906:80ce:: with SMTP id a14mr21027682ejx.311.1622447909196; Mon, 31 May 2021 00:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447909; cv=none; d=google.com; s=arc-20160816; b=Pt8tvBTtxKBa6//Cuqhuu3F6QBQFhxfVR4YEcyxXoyGOE9dhinU1NrFrgjRhdZhkxO O06SnDrtos4IUFxKwtHhjWmEboS29nSs/AHr9dj9/J5jDmlkosLget28qocjndrxTnbn Rp6ERxlbYW1Q6CdI6BEo50VSUsQm4zFV1KxzzxEI/T93NPsb2Td9DqbXtX9+sQDWYlvx QiYC2L3xkOgDBuH3c6qO10sF21pZaI9V3WHdZzX+lxhlohsbW9rI6+1Ucvcjb3T+3kOu HoHX8CeFi+TrEsAq8+TeAO5zZOtb0ebOlAmVnVJCXZFTY8nwICUHbjyhchgMQGz2ykFF lBQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=sHgXpE/FV+LmWUX+O56oY0T/+mfiVEUiDUe3V/v2+aM=; b=M2gsaBRFkyRYM9oJyQwZ2pWW4nrvhd0ZG/h1KsETG5MnzdRf6lRBMItCxCmaAYcZoN 9+7OK1G2dsKwCnu1+Q8mIvZ1HaNFlw/4KORTketeVgmvQyBCHPAGFNH3dI5ybZ2En2xl Ts5BFqt1++JuAgxYX7NzNXefYq8gRaueDnihkoOiSccJvkRTnlg4YnsvoFoeZvZ9m/7A Ps2pwneodWturvy8y5Gs3Bg4zNYS9x4iycV5fA+jH5kFVDPo1vJwf2mUhCNr3lzxn6Xh QriEr4L1U6bgzxD6tJhjwRIaM2K4MIn2UdKn2p5yJIPCOsvyrX7tgTSr/ETKv5sA+Aae y9VQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r13si4393507eds.77.2021.05.31.00.58.28; Mon, 31 May 2021 00:58:29 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7E645689A1E; Mon, 31 May 2021 10:55:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1F2B168836F for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4FC242405C5 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id wMsp_4ic_nJY for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E200B240693 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id E9CBF3A1420; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:58 +0200 Message-Id: <20210531075515.19544-7-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/24] sws: factor out cascaded scaling X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: cm3t8075Yk4t --- libswscale/swscale.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 72285c3547..867995c9c7 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -842,6 +842,22 @@ static int scale_gamma(SwsContext *c, return ret; } +static int scale_cascaded(SwsContext *c, + const uint8_t * const srcSlice[], const int srcStride[], + int srcSliceY, int srcSliceH, + uint8_t * const dst[], const int dstStride[]) +{ + int ret = sws_scale(c->cascaded_context[0], + srcSlice, srcStride, srcSliceY, srcSliceH, + c->cascaded_tmp, c->cascaded_tmpStride); + if (ret < 0) + return ret; + ret = sws_scale(c->cascaded_context[1], + (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH, + dst, dstStride); + return ret; +} + /** * swscale wrapper, so we don't need to export the SwsContext. * Assumes planar YUV to be in YUV order instead of YVU. @@ -882,17 +898,8 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (c->gamma_flag && c->cascaded_context[0]) return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); - if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) { - ret = sws_scale(c->cascaded_context[0], - srcSlice, srcStride, srcSliceY, srcSliceH, - c->cascaded_tmp, c->cascaded_tmpStride); - if (ret < 0) - return ret; - ret = sws_scale(c->cascaded_context[1], - (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH, - dst, dstStride); - return ret; - } + if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) + return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); memcpy(src2, srcSlice, sizeof(src2)); memcpy(dst2, dst, sizeof(dst2)); From patchwork Mon May 31 07:54:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28009 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657834iof; Mon, 31 May 2021 00:59:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGKTfzfyQyFB4M42AzgdBnybseRZ5rB4yTyy7jobIdouvGnksjER6EXzMsmvypypOLNQat X-Received: by 2002:a17:906:dc92:: with SMTP id cs18mr5223559ejc.327.1622447948206; Mon, 31 May 2021 00:59:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447948; cv=none; d=google.com; s=arc-20160816; b=Hsf3xtML/P5Y3rL5qtm951YiOMaKSrCbwIq90fWEFtdVdOckFMAuSgiFYYmVxc20n0 +CTqA7ePNQOtrzPdTw3oEkQqTM/NJFX665dg4dUsKT9zf2+xw+QE39gC9wxOUWOa3QVN /JLGjglttZ+cEIAn+5r49yWx6onNpLifM6c2SPvGwhfUEBXpbJAo71rjFCrlYd+nxgvK gGeyQIlmZxmtVV4oPQ1Ep9S1P3kSZMhErrHHB1Hl4GO0hgQBtXX405wlksADC8MsQjLT wTC3ad/vwUqS4RwRLdeasaq7lGEiWS7F7d+QxWNog4clQ933pWsLF1hPtoe+gkUGFH3q BJsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=T9fmO54Bj7g2/GUCK++iZHchw+T/JMBj/x3gPGdxVh0=; b=bHEPvZsxW9NVBjv88gQpmgOvL/mGVAwVkxAWn8YBIGAyp93gkWOiCGyuA22iZTgMw5 KbmDW+K4noeRWXW/Hw2IXny6WN0cocBZgAyLcfXax/pVlDNIQuzyN8kik/DDVLQH1q7G RAQs16vfOoUbsVg80ALbG25piFiTcgFMxBh/PpZCWbp1qtJnfQsiBcU4CUXJHzTdg20x cIzX4TjA6WyRTad4u5ALvCNlJk7X8v1nbpuSy73I6EpJFBytKFrb/mQzOLWfr09JioND 2xfe0wneCjXXQFMKQReoPgd1+VV3LAGlSUnwZy6YWE/grurl4M3YZ8yTnTlpk5FosE6f suFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l23si15035847ejb.573.2021.05.31.00.59.07; Mon, 31 May 2021 00:59:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BC54689B62; Mon, 31 May 2021 10:55:52 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7CB2C6883BF for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B3328240696 for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id UkDXjGplLxp0 for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E1DDA240692 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id ED9ED3A1421; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:54:59 +0200 Message-Id: <20210531075515.19544-8-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/24] sws: cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: seK9TXcyNbu/ Reindent after previous commit, rewrap long lines. --- libswscale/swscale.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 867995c9c7..7dbe0f59c5 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -847,15 +847,15 @@ static int scale_cascaded(SwsContext *c, int srcSliceY, int srcSliceH, uint8_t * const dst[], const int dstStride[]) { - int ret = sws_scale(c->cascaded_context[0], + int ret = sws_scale(c->cascaded_context[0], srcSlice, srcStride, srcSliceY, srcSliceH, c->cascaded_tmp, c->cascaded_tmpStride); - if (ret < 0) - return ret; - ret = sws_scale(c->cascaded_context[1], - (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, 0, c->cascaded_context[0]->dstH, - dst, dstStride); + if (ret < 0) return ret; + ret = sws_scale(c->cascaded_context[1], + (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, + 0, c->cascaded_context[0]->dstH, dst, dstStride); + return ret; } /** From patchwork Mon May 31 07:55:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28004 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656552iof; Mon, 31 May 2021 00:56:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw95mMYI/b7ZfjOC4nzxpjzwM0fec/nzaUSI4r/PlNDUdpZjcN91PismFCYHqhBw8goXlY5 X-Received: by 2002:aa7:c0c4:: with SMTP id j4mr23945667edp.168.1622447806190; Mon, 31 May 2021 00:56:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447806; cv=none; d=google.com; s=arc-20160816; b=y+ksGkTC+VyJNrtQFnTjVw1UxLOXCmD8wUqUEHES3XP70LDyRdmG6aUJbBiG6QBFOM 0iUhGaJr334cQNGOO6WWQnKtEIEzMVtytVU6VEIAXaKR/1osBo94xXshQQOopl77ccSP WzO0f1VETa0uwpYP+Z5Ztcgye4Qs3VT5Ln5mJaqfU3gZl/9kSOJpza/02ixR2x4JHfKa IQJWlIuP+7wP1/qVFSaKzPgXmZoKwwpUPCgJ01UrYKkZ16uiCxnujMfHljifE2z5QxM9 0TyCiJuXky67Ss8BnOWrkqXif1rcUvIFHEbxGwe/65OcT/U69gBp6jy1YZ/y348NmtR+ zhLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=CM6ytZH3Dnd+BCUSZUT5k9sKHqtjC6+S9rnmiZZXyBY=; b=kZSes2AaNBpuFU8zOe/buBnW8Vhpqa8RbfOAa7fcvvYSk5+8iXWVTd7c9iSWAS4805 DyqMAiZV+Ybhzkh9ZViFJJJ8ucb3JEMn64heq/JHTMlV9VPIqmg6l7uoguPA/SIiEjy6 TxDkAgV+rzlaaPdNENCT8Bmh/aFj492F3xvNGWcDuHN18szG0hF6/meRDMA7gPov+MgG 6Vs9ucIauVV4zTn5bD+ncv4ggBBSCXvOVfwcIww9cmUy6w3feO6HzYVn6/dvu/5j0fS1 PJGi1FkqewcMs1jZOAQ6GlHKXg29VnCAexS/zSW8Dx2ENFPrSVSa2eoCKHP4WHQO1u5/ dB9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gn42si3400287ejc.155.2021.05.31.00.56.45; Mon, 31 May 2021 00:56:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D36766881A8; Mon, 31 May 2021 10:55:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA47C687FF1 for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 7134B24069A for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 1B6ZYG3qQsTw for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 251C5240476 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id F1C153A142D; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:00 +0200 Message-Id: <20210531075515.19544-9-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/24] sws: initialize {src, dst}Stride2 consistently with {src, dst}2 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: OwUxH2i77saR --- libswscale/swscale.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 7dbe0f59c5..1cf89e4684 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -883,11 +883,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } - for (i=0; i<4; i++) { - srcStride2[i] = srcStride[i]; - dstStride2[i] = dstStride[i]; - } - if ((srcSliceY & (macro_height-1)) || ((srcSliceH& (macro_height-1)) && srcSliceY + srcSliceH != c->srcH) || srcSliceY + srcSliceH > c->srcH) { @@ -901,8 +896,10 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); - memcpy(src2, srcSlice, sizeof(src2)); - memcpy(dst2, dst, sizeof(dst2)); + memcpy(src2, srcSlice, sizeof(src2)); + memcpy(dst2, dst, sizeof(dst2)); + memcpy(srcStride2, srcStride, sizeof(srcStride2)); + memcpy(dstStride2, dstStride, sizeof(dstStride2)); // do not mess up sliceDir if we have a "trailing" 0-size slice if (srcSliceH == 0) From patchwork Mon May 31 07:55:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656438iof; Mon, 31 May 2021 00:56:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ60zQad6D7ojOMV2ob1S7R1EJKNLyPhdoJcyciRKOS1Roe6jUZYC8ZURWV728LHUl3P4o X-Received: by 2002:a17:906:131a:: with SMTP id w26mr21050974ejb.198.1622447795206; Mon, 31 May 2021 00:56:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447795; cv=none; d=google.com; s=arc-20160816; b=XqQiUugtlD51Wvc3jR2NjSdvZXdlF/UWgkIs7Rim3e+o2wKYwWKeLA+Bkaz5hISgcQ ag0uDBxyOvjkFDa35WgM6dfuHHAdJki980l+FkfoVYSkWxm6ihtw9RJ9XohTdA06G05W t0cGyUg42Ly0nFAigdzjtFZa8QRgZFNvV6Qujr7r5V00uS+tByI1v9DE0HsovDAnbpbD bSp/bjvEjbAUHE8Rgh9AP4EkdkCwhaYP0P2NUCScHsgBSxpM+RSz6L7t7SYS93l/iWda Q8bsugJCfFRMaowgz96sDWFQpw3go1zCcNO7EXCVLBg3csRYlNsY001hN/FpLSZOPQQM RUng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=qCVv06I1AzdGWpSvnruDsug4EwmY7hkT2zReOrkbpkE=; b=Avit06pFYiSv/1k5Lex8ipCwLXeRChBih30Ja+K+aj39JrT9Is6V19tjtZDdi2Kx6K JixF7QAG6W0rIbQi0fQC4llXWiicSZQKIS+pG6aCcYzxD42ELsxWsmBMkYBDh0iGOG+3 /8mzQpyaP4ejRkqI4Tif4s8zIwPn80dPuDa67mBRJi75RIeka5uk1AE4Dt60wBC/SZxe Z9eG2BGPsCdEzFFddupNDyZnCb7LFkm1KMHawDczoSYIRDIEBGIaif5vYbHoW90t1kds IViX5NxaO1AabqH9Dxzje0jZhI3DfLej5LpIQf5HNmrKJ6i/te5olpJ5wHIdGZtD+ZDn HuOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w9si12742250edx.381.2021.05.31.00.56.34; Mon, 31 May 2021 00:56:35 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EB3D4689247; Mon, 31 May 2021 10:55:35 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BC20868804B for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4B349240694 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id ZsuJy9QnGD1o for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id F01CA24069A for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 016C83A1563; Mon, 31 May 2021 09:55:20 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:01 +0200 Message-Id: <20210531075515.19544-10-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/24] sws: group the parameters validity checks together X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 8wbOdvINrfOO Also, fail with an error code rather than 0. --- libswscale/swscale.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 1cf89e4684..37c7cf60dd 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -890,6 +890,15 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } + if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { + av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); + return AVERROR(EINVAL); + } + if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { + av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); + return AVERROR(EINVAL); + } + if (c->gamma_flag && c->cascaded_context[0]) return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); @@ -905,15 +914,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (srcSliceH == 0) return 0; - if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { - av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); - return 0; - } - if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { - av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); - return 0; - } - if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0; From patchwork Mon May 31 07:55:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27995 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656703iof; Mon, 31 May 2021 00:57:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjCvS0CH9ws2687bMNPVNOZJb83Ee1d4h2BRKncsw4AvgjGAbDaLOy+mKs4W61+QbRIX32 X-Received: by 2002:a05:6402:3495:: with SMTP id v21mr17919593edc.185.1622447825094; Mon, 31 May 2021 00:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447825; cv=none; d=google.com; s=arc-20160816; b=KFVLMwb6VJGBanlFn/kSpcTBKnXd/7zSoE2hUoI6q4HWK1vLTwlgwTP5Z2lidAojIA 7oq4d9aUxuod9g9ReqiYo3svIyKRql+3OEYx3f4u1X3SY3ZBoczBuREH1/0NY3ug58xY ZDY36zQxeH6am/cDb2Js1gkuheMxr/CoTbT7SDpkKLBTrJ7WmHLlY1K5UNCHgHEugliN f2y5tQ6F8TflWakvXAu9Pds+N//CB3JivDE6nMMAy4YCaoQes5jq6MBk5lq7GQEAB+Wy ENofz4jCBKXRHyn11YmCuP8Q9rlTgUtuB2AHi2v/umWnk3L/L9qhoKdTY9h2dbGLvQGi NBsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=LhhhNSwY03cgT9P6YL7e3Ew+3JK8Hdk1DLxL/2GJ5G4=; b=ucSK0x033ifvUcAFytFKRuEBD73ueXXahf8yjDcNpqBb3UxaTr56Z7k7sdaB9UjmRZ 027T0HpcO6zVqf47AWlj2uqLv+QTfMwy/7xb6OXxcCTzvpdHtky4/jXb8qdP0tgvoLwY t+mdej3fvuLX0VFfFb5iNtRqodu+HMReTyZk7WkLASoSgULklwLzQv8BU0Ddl/Efr0Gm PJh9/dAjBUDdPr+h1L36oD2v77MYNwuYNfyM34wVl8rGJSaGZFUPaacme+qmur8kTHK7 Fk2WaOfYo7TETD8XJQDLCmWmZMfLxi/F9ATL/rNDRQRfNZEbK+UXWW/DrPZ/sWyVeofm kPig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s3si10969853edd.497.2021.05.31.00.57.03; Mon, 31 May 2021 00:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D6CE768979B; Mon, 31 May 2021 10:55:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F08B6687FE1 for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AA4E4240476 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id n3ZNpZxfx-Zh for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 2520924069C for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 0551F3A15EB; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:02 +0200 Message-Id: <20210531075515.19544-11-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/24] sws: do not reallocate scratch buffers for each slice X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: il4mNRRuLOt0 --- libswscale/swscale.c | 20 ++++++++++++-------- libswscale/swscale_internal.h | 6 ++++++ libswscale/utils.c | 3 +++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 37c7cf60dd..2db40a6807 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -871,7 +871,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, int i, ret; const uint8_t *src2[4]; uint8_t *dst2[4]; - uint8_t *rgb0_tmp = NULL; int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample); // copy strides, so they can safely be modified int srcStride2[4]; @@ -928,11 +927,14 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; int x,y; - rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32); - if (!rgb0_tmp) + + av_fast_malloc(&c->rgb0_scratch, &c->rgb0_scratch_allocated, + FFABS(srcStride[0]) * srcSliceH + 32); + if (!c->rgb0_scratch) return AVERROR(ENOMEM); - base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp; + base = srcStride[0] < 0 ? c->rgb0_scratch - srcStride[0] * (srcSliceH-1) : + c->rgb0_scratch; for (y=0; ysrcW); for (x=c->src0Alpha-1; x<4*c->srcW; x+=4) { @@ -944,11 +946,14 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (c->srcXYZ && !(c->dstXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) { uint8_t *base; - rgb0_tmp = av_malloc(FFABS(srcStride[0]) * srcSliceH + 32); - if (!rgb0_tmp) + + av_fast_malloc(&c->xyz_scratch, &c->xyz_scratch_allocated, + FFABS(srcStride[0]) * srcSliceH + 32); + if (!c->xyz_scratch) return AVERROR(ENOMEM); - base = srcStride[0] < 0 ? rgb0_tmp - srcStride[0] * (srcSliceH-1) : rgb0_tmp; + base = srcStride[0] < 0 ? c->xyz_scratch - srcStride[0] * (srcSliceH-1) : + c->xyz_scratch; xyz12Torgb48(c, (uint16_t*)base, (const uint16_t*)src2[0], srcStride[0]/2, srcSliceH); src2[0] = base; @@ -996,6 +1001,5 @@ int attribute_align_arg sws_scale(struct SwsContext *c, rgb48Toxyz12(c, dst16, dst16, dstStride2[0]/2, ret); } - av_free(rgb0_tmp); return ret; } diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index a1de95cee0..e8a434427b 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -626,6 +626,12 @@ typedef struct SwsContext { SwsDither dither; SwsAlphaBlend alphablend; + + uint8_t *rgb0_scratch; + unsigned int rgb0_scratch_allocated; + + uint8_t *xyz_scratch; + unsigned int xyz_scratch_allocated; } SwsContext; //FIXME check init (where 0) diff --git a/libswscale/utils.c b/libswscale/utils.c index 6bac7b658d..d45d7afcbf 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -2293,6 +2293,9 @@ void sws_freeContext(SwsContext *c) av_freep(&c->gamma); av_freep(&c->inv_gamma); + av_freep(&c->rgb0_scratch); + av_freep(&c->xyz_scratch); + ff_free_filters(c); av_free(c); From patchwork Mon May 31 07:55:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28001 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657640iof; Mon, 31 May 2021 00:58:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5FjvmHgplXzf4oCeJ7Bcxzeae1Kibv23kkR7nGkOrMeVj61+lFSjM47Z/2HTm+1RB4XCd X-Received: by 2002:a17:906:13cb:: with SMTP id g11mr3788433ejc.169.1622447930015; Mon, 31 May 2021 00:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447930; cv=none; d=google.com; s=arc-20160816; b=vKFoKbkOvuf2lbpfmkrjvvsglSWvUe6tFEp/wny9JrjUazvaTfqNHlonDKBRjNVXQj XsevEx8rZe+H8jjsYq3svF6UY7E2tDItCisCz9qgX7ntLNa3l14vbWsxvIlWkHG8eyUA I3I0UrVbN1KlVF2gnC8SqPFs7vgTUjvtGF85q6FtRcF1msYBySyu1x7h0jRZ+ms9/J9t vcPoPMrpb+ZiDwDJCv0A6T11SJV+ARgPuoG6ixp75uaFNFnYss2V7vAA96Gh4ayRCnkV IXjryh8/9NrDgz7cg4bAs5zbPFN8rcwBvmKxtmWh5Iy4Qof5m6YXA1Ja3RjCMsFMB6kd wHOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=Z2Qkzgsyuv86LIF0rvmUA6eDDWiiieB5uMYIUXK4Z3A=; b=XYakaLsIXWLxPDX8fkO5OyrCTd454ebODLWzuifBdHN1/u5R7ppmCD4gUZs+WqDHt5 hQ+VcbKasDQzJv3RxhsWX0MXK/uw44PppldkCaIRxilln4b+kPryLZpEZtF+B//0x6pI SVlecNPbOLOjszv2wzyllyffYyv1gRNxSelkaiYFKKhTnUUeQhPNd7itaZ7i2rJQfBF6 u0ohBxEMWYsqeL9XPa4SN6gSY5wrgkQd/5GIPd4Mt3TFWjWSPmfZwPIoze7pgZo72Yx0 YQZ13bnv99FKVqQdg8j5QoG2n17Ulyma6BREsqohjpKyDrYPo8x08VDLd9Of4Knxhbpo aq7g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m1si14319858ejj.42.2021.05.31.00.58.49; Mon, 31 May 2021 00:58:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A6FFE689AEE; Mon, 31 May 2021 10:55:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2166E68838E for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D4049240697 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id AanHuG7WjbmQ for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id EBF93240698 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 098723A1601; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:03 +0200 Message-Id: <20210531075515.19544-12-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/24] sws: separate the calls to scaled vs unscaled conversion X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: T5kzpRmoouTo Call the scaler function directly rather than through a function pointer. Drop the now-unused return value from ff_getSwsFunc() and rename the function to reflect its new role. This will be useful in the following commits, where it will become important that the amount of output is different for scaled vs unscaled case. --- libswscale/swscale.c | 10 ++++++---- libswscale/swscale_internal.h | 6 +----- libswscale/utils.c | 3 ++- tests/checkasm/sw_scale.c | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2db40a6807..4b577ef263 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -579,7 +579,7 @@ static av_cold void sws_init_swscale(SwsContext *c) c->needs_hcscale = 1; } -SwsFunc ff_getSwsFunc(SwsContext *c) +void ff_sws_init_scale(SwsContext *c) { sws_init_swscale(c); @@ -591,8 +591,6 @@ SwsFunc ff_getSwsFunc(SwsContext *c) ff_sws_init_swscale_aarch64(c); if (ARCH_ARM) ff_sws_init_swscale_arm(c); - - return swscale; } static void reset_ptr(const uint8_t *src[], enum AVPixelFormat format) @@ -988,7 +986,11 @@ int attribute_align_arg sws_scale(struct SwsContext *c, /* reset slice direction at end of frame */ if (srcSliceY_internal + srcSliceH == c->srcH) c->sliceDir = 0; - ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); + + if (c->swscale) + ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); + else + ret = swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) { int dstY = c->dstY ? c->dstY : srcSliceY + srcSliceH; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index e8a434427b..02a45e7adb 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -872,11 +872,7 @@ void ff_get_unscaled_swscale_ppc(SwsContext *c); void ff_get_unscaled_swscale_arm(SwsContext *c); void ff_get_unscaled_swscale_aarch64(SwsContext *c); -/** - * Return function pointer to fastest main scaler path function depending - * on architecture and available optimizations. - */ -SwsFunc ff_getSwsFunc(SwsContext *c); +void ff_sws_init_scale(SwsContext *c); void ff_sws_init_input_funcs(SwsContext *c); void ff_sws_init_output_funcs(SwsContext *c, diff --git a/libswscale/utils.c b/libswscale/utils.c index d45d7afcbf..42bef3753f 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1845,7 +1845,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, } } - c->swscale = ff_getSwsFunc(c); + ff_sws_init_scale(c); + return ff_init_filters(c); nomem: ret = AVERROR(ENOMEM); diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index 3ac0f9082f..40c5eb3aa8 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -93,7 +93,7 @@ static void check_yuv2yuvX(void) if (sws_init_context(ctx, NULL, NULL) < 0) fail(); - ff_getSwsFunc(ctx); + ff_sws_init_scale(ctx); for(isi = 0; isi < INPUT_SIZES; ++isi){ dstW = input_sizes[isi]; for(osi = 0; osi < 64; osi += 16){ @@ -210,7 +210,7 @@ static void check_hscale(void) filter[SRC_PIXELS * width + i] = rnd(); } - ff_getSwsFunc(ctx); + ff_sws_init_scale(ctx); if (check_func(ctx->hcScale, "hscale_%d_to_%d_width%d", ctx->srcBpc, ctx->dstBpc + 1, width)) { memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0])); From patchwork Mon May 31 07:55:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28013 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656365iof; Mon, 31 May 2021 00:56:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+LGBWp/fXv4gC9LDpZYQQhuB6tASNgEgY2PeiQ1n2YdKjylekyGXSP4TItzPWW+i8jT6g X-Received: by 2002:a17:906:131a:: with SMTP id w26mr21050526ejb.198.1622447785487; Mon, 31 May 2021 00:56:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447785; cv=none; d=google.com; s=arc-20160816; b=kEPMqMooAOX3Ozc7ysN9prNkOIkXjOIM8r8EPScwHMVLlHud4+uS88w6oVIOUf4EYg VAneLHKj4iP7garpPAaIhzj3iGsiUDbUdSfl6zLoOETt1y7EsPfmZrxeQvIMDyy5sVe0 vEvmCmKPx6cXNkYc5jJEiYUVhZ3rteiSw9nfZX9v7yCdnEgoPw2mZf8yHBUrFK0qnTPS G1tQ9Ahqelz9SeapH1l8bdCeznywAI1A2wVwZV39UY6lDvjBrhD7K78rKl5UPb62dRQz Pv4VwdUO9B13UeyypiBo7X62RBd14X9PF0W1dFNxbF+smkJ+ZsyaTt92BHGu92ZS+ZoY UT/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=gn6Osq2Ckq6aUnlCr1F+Gj0+dci9DWR8gnrEG/ACAC8=; b=QAPn3igruKEi6LDRefPgW2kKxgQfqleiD+e8E2ocNAmjJYtxC1nOZKsTj8UvRL0Eft 9OhxhoqFBpjBoaFmPg27usXERsva+yx2I8ak7S4ze3DG+8d2/lNVuDlgFFPg6Yzhvj2K cBn0o9jT3sYkexDOs87LAdnVJBHBofLlvKOBZmnx9sDhlleBmoh/mg7BVUXl8DPPTDmg Kp/bajQpun7DdyIKvnwZApQ+Ck2/jxoEAnypTqJ2++OO9OoyFy0JkcPn+AmMjhqTqmL7 +UZdp0Ne9Ohgkn0ru8AK23mYQyCe9NDVyU/T2+COhrz+acUjDQvxjvvk+tDj/rTYFD0X hNsQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f15si12201991ejk.164.2021.05.31.00.56.25; Mon, 31 May 2021 00:56:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DA681689200; Mon, 31 May 2021 10:55:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B6F69688041 for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 24E5D240699 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id MExfO4yOETaE for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E47B7240694 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 0D82E3A165F; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:04 +0200 Message-Id: <20210531075515.19544-13-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/24] sws: reset sliceDir at the end of sws_scale() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: OZaffPYKZbI2 Makes it more clear that resetting it does not interact with the scaling code that it is currently intermixed with. --- libswscale/swscale.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 4b577ef263..cc3700c704 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -983,10 +983,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); - /* reset slice direction at end of frame */ - if (srcSliceY_internal + srcSliceH == c->srcH) - c->sliceDir = 0; - if (c->swscale) ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); else @@ -1003,5 +999,9 @@ int attribute_align_arg sws_scale(struct SwsContext *c, rgb48Toxyz12(c, dst16, dst16, dstStride2[0]/2, ret); } + /* reset slice direction at end of frame */ + if (srcSliceY_internal + srcSliceH == c->srcH) + c->sliceDir = 0; + return ret; } From patchwork Mon May 31 07:55:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28008 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657939iof; Mon, 31 May 2021 00:59:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMdYe3+mO5igGbjZNrC0Tu3r96uE6rJqVNKbHPA2pnKAXlUKv0j/iSg+mpLS5Lw4iBttD+ X-Received: by 2002:a17:906:a0d3:: with SMTP id bh19mr22315340ejb.205.1622447957784; Mon, 31 May 2021 00:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447957; cv=none; d=google.com; s=arc-20160816; b=PRBaAug6yVgs7opxS7Z/QRdz6A3lvy4KcmedE1kCBx1HLQnZdwabSI/oWFWWRLUc4Q +nIQL5Kymx4K0dpyma250Angmeu6j4N1t2GQcbCRKf8WrZ8snxfnLR3Ge+j87KznlQSd v1PmREj5cOdNWp3bACOpNFJyRBrZNYRSV8WYrEaO2w/HvgsWzZFrx0vwyga63QNtR0FO 4m6cOlXbuRBGz8yn4YihP7/JQFJYUFckyCsh+FgT80R/sqzVCTuVwyKkTFzFYK6EXKQZ eln8sVRzGNB9Uyb75iQc2OnDHtYboV1E5A0G9kSf4heOiutzPBSSnUi9TZi06ErO/Gel LDcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=9ASLDZFCZnXD04bydRpf7/QiGVKhrDYjEpOQ3LqpRzI=; b=oCKnf9FG9VFFzcMZd4B56/sXlCcGbArW/JEDBxqhQj/zdWK6ikNcKtlL87vtTk4sly RvmfC/jOkIQqkorJXeKhWOhi5RemQAOt2n+cS4bw++N3aYw83qON6gCpY2e9tiLcQVK+ aFJ5RM+w6aEstBEXbbKIA7A0d164QHh4BeFF1kRWkIEQd3d6uAzrNM2XE5Ye763G5tw+ PW3yeHh9h1Sx11xQaZZN2wVa5hVw7BgUjCiwCDgCq2mAdqDTZA90IEf0wWoDAciQu8OK SNCjuTO3dEHuSt8nvcySYGucA7BGE1QSElxJUTEqIYLiDd5IbXKLLS3BnIDKpWWz3P1z eypw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m26si12984613edp.58.2021.05.31.00.59.17; Mon, 31 May 2021 00:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 60F3F6801CA; Mon, 31 May 2021 10:55:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 829E0688078 for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D6AD9240692 for ; Mon, 31 May 2021 09:55:24 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id j7eLZ99_CPqI for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id EE9F6240699 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 114143A1727; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:05 +0200 Message-Id: <20210531075515.19544-14-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/24] sws: make checking for the start of a new frame more explicit X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 2kXqPtAFsKtU --- libswscale/swscale.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index cc3700c704..74da1bf42c 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -866,6 +866,7 @@ int attribute_align_arg sws_scale(struct SwsContext *c, int srcSliceH, uint8_t *const dst[], const int dstStride[]) { + const int frame_start = !c->sliceDir; int i, ret; const uint8_t *src2[4]; uint8_t *dst2[4]; @@ -911,11 +912,11 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (srcSliceH == 0) return 0; - if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { + if (frame_start && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return 0; } - if (c->sliceDir == 0) { + if (frame_start) { if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } From patchwork Mon May 31 07:55:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27992 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657528iof; Mon, 31 May 2021 00:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR3WJ7abBjayX/764/VkZ0IuXbSfn/lFBzcSs08xCk7ptd5Xim3wPBoMROEwyQkx2IkUHx X-Received: by 2002:a17:906:ad9a:: with SMTP id la26mr21940702ejb.122.1622447919951; Mon, 31 May 2021 00:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447919; cv=none; d=google.com; s=arc-20160816; b=rzkkpLB2zpBOdq3bi+jk/Kj90ICk8nUADAlzOprrHW8ovQGoMHcvA9Kunsf16v3WfC 4/mysHz+xg4ti0ysPloKqNC1lgTqni55zThINsorUWkLsZFkFEjVf06Z3/ILluEhUY4v Z/Ot5nejGi5xSdp+OLwmbZTAH+TagqLdUrtgi86rzWTwUqtGvoSaidJKQWAmLMUAviVS uB8oj+ktM24+g4E0asaH9wdwsciuMZtmjaApt3+DWInMtiQR1cPhNrp+2x/gjfze+R67 vWKx6MbY/Y1VzlC4bzFwD9tiPgWW82J92ov4/urydMArsaKnEcjWsDHS7VdcRaY5ojsg DG6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=8igbb4REmQiMjisjIfX7RdtBjWdgi+0/iQSzbhJpVWQ=; b=QrodNXE5nqttiJh+rkpU1eTm8U7txiTnPSHw0wwmScOpRZ/MuXUh+pUjnu8do+zvs8 yaa2yXuWlYCIzglNLrT4dKFDwmcDllk+JWhQG/G8HDW6mj9+DqZmnX82zEEQsu6zkn/K lcfiOy6MDUgSX1MGsW5qzwzFDTEPTflRCz7GIMpZ2B5IyFkCDvD1DiEHthKjiQMhbwax hTtaTtfAMqcHN43I67F6qwOOhO1tT/oTjNhQS6gYTDKL11/l0NcN0UIcrz9CDWO2ieGO zV/urzlK0P+YUYvOXtw6wL5qShQlnFtrmOuKH9IUqdlpAXB2G83A3wgDdM4qkyysK+Wa b99Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h14si12643326edr.451.2021.05.31.00.58.39; Mon, 31 May 2021 00:58:39 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C2CD689A63; Mon, 31 May 2021 10:55:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 20FF4688374 for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 6FECC240693 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id KwUzHKnmpzH2 for ; Mon, 31 May 2021 09:55:23 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id E5086240697 for ; Mon, 31 May 2021 09:55:21 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 150923A173A; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:06 +0200 Message-Id: <20210531075515.19544-15-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/24] sws: merge handling frame start into a single block X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: MI4u4D0zzZ1m Also, return an error code on failure rather than 0. --- libswscale/swscale.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 74da1bf42c..73bc0c5617 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -912,11 +912,12 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (srcSliceH == 0) return 0; - if (frame_start && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { - av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); - return 0; - } if (frame_start) { + if (srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { + av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); + return AVERROR(EINVAL); + } + if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; } From patchwork Mon May 31 07:55:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27993 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656927iof; Mon, 31 May 2021 00:57:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9xN9gKZ+DARcu+XVhCsBY2H3fPRETZbxMoB1m5rELADh9N/mx81qruwgDKud9wE7dXdLN X-Received: by 2002:a17:906:1dd1:: with SMTP id v17mr21631523ejh.31.1622447850823; Mon, 31 May 2021 00:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447850; cv=none; d=google.com; s=arc-20160816; b=RKt17cB31yvE2R4r6Ce2T3Vgik628NME2k+dBfu45Pz8MayUyz3QbMesDNqmbJCSRK K/v09sZnlNp1uEJbm+irmlhkgdvDm/l2WMd7A8ZflWCCjXP3+Cx4CQBkoOVKT1DZyf3f 7v41+wuFM6l9amxO02mzs+HR+ckMjFR9NK0XBKQpNsthZTFvG4nOU3BwfgtLEua86qBu VK2yxUmWYupESfZlFbGakU6Q6bbHoSRSESeND7d4K7nfpwjoEf6PcRFPvixs4Ay5gra1 YEOtM8drAhlbeuMEEMYpe1HR7T7y8CauFJUa/pFjWJADwJjUNE3PIRZmwv3EfXuPjpEC JpxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=6K88j8yXX+86RgiD3XCiyER2Y30+3BHvfyGG/ys7V4A=; b=Ed0hTstOrDyyOyupRisQoodNSTPI2IDT8WDim+YTc5Emdcv3Za7T20RW5Re8s5Nud5 CVozeWP2LroI8CyLWoWh3pvD0iR8OHWie8uXgR6K3RFXVMDFt1jA3QJxUd7oZPp2jxcG et5ltzpQopz5JqeJGwr9DwgvF/FPXNeepNpU0bHnnqeSu3sIsgvILyDp8xtgYst9jkPr 0OkzfFnlIn8aqsZ1FTnzhhYcAFmQBhYPQ3Co9UvEYE55KkvBOYYlOqUbB76aj2p7uqTj M+u6dy1ek153oTD5OqZ6NVp5UHU4Zey4t9dq3ff5b0sMdj7Pwdj81FxkPOcHTJIFFa2O gnZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w11si15480325ede.2.2021.05.31.00.57.30; Mon, 31 May 2021 00:57:30 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C776D68991B; Mon, 31 May 2021 10:55:41 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1750E687FF1 for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 15C9924069F for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id OfYF0CeYXlTX for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4C8A624069E for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 18F6C3A177F; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:07 +0200 Message-Id: <20210531075515.19544-16-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/24] sws: simplify setting sliceDir X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 42rBFlFSgay0 --- libswscale/swscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 73bc0c5617..270adcc072 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -918,7 +918,7 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } - if (srcSliceY == 0) c->sliceDir = 1; else c->sliceDir = -1; + c->sliceDir = (srcSliceY == 0) ? 1 : -1; } if (usePal(c->srcFormat)) From patchwork Mon May 31 07:55:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28007 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656854iof; Mon, 31 May 2021 00:57:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzvN4pR9NjYD6GyrthYwvY394X5XpoTR7uxuwrxRGooB3Z9CD5SWi2YGc0/+Iemhqak6TK X-Received: by 2002:a17:906:7842:: with SMTP id p2mr21106611ejm.487.1622447841553; Mon, 31 May 2021 00:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447841; cv=none; d=google.com; s=arc-20160816; b=lrtAuf4bR6jwxtEWkNEndNBXnD2HgZWu2iLbkffinEqi7Ga0yodQ/Hw0Xw2AVVxMDb +gvsaQ6NLGxDLsdXk2PhiSBp8Qu06RBRjGL4/2nZ2StK48O+v5Sa1XT7W5y5nciep/Jw 8Hr8Ee6ASMoQS92aBmiN37wZpbbzpis12g/x5GFnXB0Zz5WEaL+alNk4xtR39jgvlpDy oZk8QEzTuPdIoPh5UalSrLfs6cdmRslAPJdJQqKpC/VjZ1RJT8sNF+g7Bznu9xjaAcfw kGO3rbv83q93/0Uw4JtTVOG7g1FoK7n9+DYeSc5b0RaSIc0IPwE1xeCsTy5a2AFGMHjC kkZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=qROP6JTAar9QySyytiPn0s0ePjPEsmiJBEu5DtRQFrQ=; b=rbH3VOJK7a4+GRXf6MnZdKdDSNUlfWpOkKTYnx9kOT3TvkdzBJSt/lcmSG8Nwv8OQm Y3IvGQqV5nxyb6k0z1iyTslGyTFGc/3sQ83HUIGwZ41US6d+MejN7Dx0yTRJ7NRQYTAC Gb4atE+KhQdgloYaTh2YHtlfiFWLHQL1TDe7vFvFAzq7f9z2wPFTMVKAPlz6mugf0xEe GRrsorvLNFUIhBdKdHcLZysBAMEBAEw7+mSZwUqyTTgbuqyn1PMQfUtkn19Eh3SoO1s5 SkCL1a0KEUO2bcDRI15NRlKpPcxv1Sb0QKhvYyMpMQr7R+shr2q6ZazqTI7IwTY++QnX 22XA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id nb27si12049328ejc.548.2021.05.31.00.57.21; Mon, 31 May 2021 00:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D695968803C; Mon, 31 May 2021 10:55:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17F7368804C for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 46DE024069E for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6-rxFBb7_9R5 for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4C65124042A for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 1CE153A178D; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:08 +0200 Message-Id: <20210531075515.19544-17-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 17/24] sws: move the early return for zero-sized slices higher up X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: IQgw7TjKJUts Place it right after the input parameter validation. There is no point in performing any setup if the sws_scale() call won't do anything. --- libswscale/swscale.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 270adcc072..2d6ed95cfb 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -897,6 +897,10 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return AVERROR(EINVAL); } + // do not mess up sliceDir if we have a "trailing" 0-size slice + if (srcSliceH == 0) + return 0; + if (c->gamma_flag && c->cascaded_context[0]) return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); @@ -908,10 +912,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, memcpy(srcStride2, srcStride, sizeof(srcStride2)); memcpy(dstStride2, dstStride, sizeof(dstStride2)); - // do not mess up sliceDir if we have a "trailing" 0-size slice - if (srcSliceH == 0) - return 0; - if (frame_start) { if (srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); From patchwork Mon May 31 07:55:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27996 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657148iof; Mon, 31 May 2021 00:58:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuWAKQ2WYhNxVUUCPQSZCBV2tNIx362z6LqBQsIvA6l4ClKVIT9OwzrQQgVcYugwAYjhcx X-Received: by 2002:a17:906:c833:: with SMTP id dd19mr9597748ejb.255.1622447880034; Mon, 31 May 2021 00:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447880; cv=none; d=google.com; s=arc-20160816; b=SAL7J6Wmc+CfQcTEzndqpzvAfSvJOOgnYn+XSPvwe6+hKVLncRDN39EV5Fy/rn3cNp ipgGpT1H3R+siwamd8QX9UvNLptFDVq4xlQ3xMuzFWC8D8hS43PnX59auSARWZQAecKf d6wcLi4+jVvn8+c4a278IzRXoxh3oEj6rYXIfyYkKCg9/B2Xv4i8Ih9DPlmh/BXlRsBv 5DOyM1IN27rhqvS3PSqsWDxxnuG50shi233m7HN2qKnfcjfT/hQimFxD/l3qQGgJdMjz Imna54iaFQXEdbuVqnUS0Qo3Nvo1v7c3XQktD4KRMpagle2h94Wk8EzRK6EKpkAmkwif FPLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=1PFvVLMYlxteqU6wVUt2VlyLE8c4jlFoel0e9nS2vbM=; b=upSo2W4HEks8qPDZvNUqHSoQ7tQ3rvRrofzo8VnxQTbPsNYaT8oOiWz5JCxH/wLmsJ rOqK83UzNxfzaJqrUnK0xxH93pMtKlhT6wCVNfJtlAGULN/zW+vcwgSW+GBej2NqW8Vv //tqxWw8VqZqSR93wH0sUm4yBLKi/cDnnom+ozB+aKQh2v+akINBUOuIfWjeR5DW1G4I 5n5ZyNlcDjOssBwsAGq6RjEzMZsC4f66QwGlrRvRYpoEQICf76geRra2jg5bu1rIPkpi L8LbiFbVOi777wEmiPXbzdXVR51G8oACdt8vjIUn8Gm/n2K9SftQ4AqN8uM3n2B6FOkR pjXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w12si11852477edd.352.2021.05.31.00.57.59; Mon, 31 May 2021 00:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 96206689969; Mon, 31 May 2021 10:55:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3654F687FE1 for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id B4B822406A4 for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Jg0QBgZRP-_f for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4FECD2406A1 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 21E1F3A1844; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:09 +0200 Message-Id: <20210531075515.19544-18-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 18/24] sws: move initializing dither_error higher up X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: MlJgYpy0rahR It does not interact in any way with the code setting up the image pointers/strides, so it should not be intermixed with it. --- libswscale/swscale.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2d6ed95cfb..b9b2826911 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -907,6 +907,10 @@ int attribute_align_arg sws_scale(struct SwsContext *c, if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); + if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0]) + for (i = 0; i < 4; i++) + memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2)); + memcpy(src2, srcSlice, sizeof(src2)); memcpy(dst2, dst, sizeof(dst2)); memcpy(srcStride2, srcStride, sizeof(srcStride2)); @@ -959,10 +963,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, src2[0] = base; } - if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0]) - for (i = 0; i < 4; i++) - memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2)); - if (c->sliceDir != 1) { // slices go from bottom to top => we flip the image internally for (i=0; i<4; i++) { From patchwork Mon May 31 07:55:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27998 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656624iof; Mon, 31 May 2021 00:56:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLVekNQBNqmKI7Y/fh+vShKCKU6+p2mEjOjl/yfx/tYY9OnhOA7k+jgmHslsI+nP2i/Kj9 X-Received: by 2002:a17:906:68c1:: with SMTP id y1mr19938360ejr.32.1622447814795; Mon, 31 May 2021 00:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447814; cv=none; d=google.com; s=arc-20160816; b=lSCb99vZcYJJvneA/kwBCwwDmglrAaICtW/9Dh4Ns8S5s9vL8+p4nbnM4ZdLhF5dyN GyNIb1S+QnLJZu85tq7urFcmZ1b9PN5eTmwcQvswsZ92+bDJNuQVpgEVLvsJ3fLDiTyI fMU9I9ireLzvk/TrZ8m+lzGAdfdnnVzWGZS2dYRG7bHPX8g9lU+1Iccs/cK4Go14Gr7T Pa2yKlnLRApF/mh7cPZxN26ANxe0p164aOz4IC5Ti0Ij9jOksv3hm7zzuiik/hVLmijC Lrz4NsjHIbd0c/3YtqMpPh7vz0CQ97Gtg9FVM+r4aONPhCztjqgxrkdsu708jR58yO0w gPyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=IAxK3BNuyU0q+hpLhS1k2WwewuvPDh5yIiLFoOvEbGg=; b=zbQR3lEVp3tjrkCn3KEXr6jwZkzO48URoy4QDI0jWQKmssDJUSWkLmfE0v2QBW+Z1p 8w4RsW9gFQPT8F84audDdGbOWD9iWfsE6VHKv0GV70wbJ1DnwsDAwCtPOhONj6lOrEtz anR9fIinsQo10trzU8Nbp7dGHPZoiU2iNZORhwIKPsZA7a7YUL8LPv3TOIbN+IhxU1gB ekd7GIWw3vz2xnXWIOH/n7ZyIafw3RqiOV0LhlcEQMgT5YmW9lCCZFPwrFBl9Xx6PWzc oi7iwXZl5at31CFzqcU2e0cvSTxEGhIb2bm5QMrPaMWgjs+TmU8BFp/LkEhSS2E08Vxr CWJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t7si2002239ejj.44.2021.05.31.00.56.54; Mon, 31 May 2021 00:56:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDED9689248; Mon, 31 May 2021 10:55:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EBEF86805BE for ; Mon, 31 May 2021 10:55:28 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id D4E5224069C for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id nAZQRREXs7WK for ; Mon, 31 May 2021 09:55:25 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4D46924069F for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 256E73A1853; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:10 +0200 Message-Id: <20210531075515.19544-19-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 19/24] sws: move updating the palette higher up X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: jDKx+bjIEBJr It does not interact in any way with the code setting up the image pointers/strides, so it should not be intermixed with it. --- libswscale/swscale.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index b9b2826911..3b03fd16dd 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -911,6 +911,9 @@ int attribute_align_arg sws_scale(struct SwsContext *c, for (i = 0; i < 4; i++) memset(c->dither_error[i], 0, sizeof(c->dither_error[0][0]) * (c->dstW+2)); + if (usePal(c->srcFormat)) + update_palette(c, (const uint32_t *)srcSlice[1]); + memcpy(src2, srcSlice, sizeof(src2)); memcpy(dst2, dst, sizeof(dst2)); memcpy(srcStride2, srcStride, sizeof(srcStride2)); @@ -925,9 +928,6 @@ int attribute_align_arg sws_scale(struct SwsContext *c, c->sliceDir = (srcSliceY == 0) ? 1 : -1; } - if (usePal(c->srcFormat)) - update_palette(c, (const uint32_t *)srcSlice[1]); - if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; int x,y; From patchwork Mon May 31 07:55:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28012 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657331iof; Mon, 31 May 2021 00:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/B5J7pKBBruQ1AHOLi4PYaH1OhtOBjn0xaZCa588fQwFNOdDhDDeEVFuF9gcLTtNyVNvI X-Received: by 2002:a17:906:edaf:: with SMTP id sa15mr21416828ejb.174.1622447898477; Mon, 31 May 2021 00:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447898; cv=none; d=google.com; s=arc-20160816; b=rkihHgK42rEMht6wT69vXfCyitR8dyNONl78KcHcYaR7TKsjcu9KwkmREwFGWIFMJt r2fH/yqqXyRWjeLTmERQEZkKWb5+cpIU5KpnzLOv7WIwoSSHvnveM/zqIYTKJvAs/aTO gZlGI/PkUNo2++aBSds/cOT1xYYsBk3+VRLc+Y6q1/q23DYqnZQKcB+p774m7YQ9SE33 SNWjp774GIpkibshQiLImgBeK5S7AIdcdRvLyx0STv1UDk3rwTFPnY42wRl/W3NHtfPw //L/jeWjwVoYFxvU3NzAh8hHY/o/00zyzfEo3Be7LpT2bg08uX5RrIDS9LEZ2WAdv7d0 nLeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=5D9+TRTQAuvAtaYZ2L7p1+JFwrddxxn2mlQPNFgp9rE=; b=crR+TEkbPqEa9e9SCfAuaWQRtea8Qv92QNlCr7Nujm5nBsZwHD4KG0dvMhUnXMZVvV aB9xN6qFPoUm72bflGsOGmlj6usJmcs1U6TMFFR1lXNPTmkBRvnOdz+NgtqL3LyOn8UK viteJ+pxt8uZQ/Q9C07AofV/xnm+3YNLR7gainTrnxGwy2swRD5jbx3btjDEG4L8Yj88 AhZVMkHplgfKZ43xYZgDx41aKBBSh8bENCU1sZL/Abvwih5ulHdc5a8SedVu00nYW+k+ yHir+KDaRhx7f8tW2lvLS1kyCTV6k28BSDLqEchYa8z+cAM1YvtTsZ22InkObp3xc7dn tFcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z9si13001488edi.208.2021.05.31.00.58.18; Mon, 31 May 2021 00:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 811806899CF; Mon, 31 May 2021 10:55:47 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3D89968803D for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 95EB724068A for ; Mon, 31 May 2021 09:55:28 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id NFgTthhsRNBW for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 52EE82406A3 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 29E813A189A; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:11 +0200 Message-Id: <20210531075515.19544-20-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 20/24] sws: add a function for scaling dst slices X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: ozxsGoCNqNuA Currently existing sws_scale() accepts as input a user-determined slice of input data and produces an indeterminate number of output lines. Since the calling code does not know the amount of output, it cannot easily parallelize scaling by calling sws_scale() simultaneously on different parts of the frame. Add a new function - sws_scale_dst_slice() - that accepts as input the entire input frame and produces a specified slice of the output. This function can be called simultaneously on different slices of the output frame (using different sws contexts) to implement slice threading. --- doc/APIchanges | 3 + libswscale/swscale.c | 186 +++++++++++++++++++++++++++++-------------- libswscale/swscale.h | 30 +++++++ libswscale/version.h | 2 +- 4 files changed, 162 insertions(+), 59 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index c46f4d5304..e5cdd8ee77 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-xx-xx - xxxxxxxxxx - sws 6.1.100 - swscale.h + Add sws_scale_dst_slice(). + 2021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h Constified AVCodecParserContext.parser. diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 3b03fd16dd..748e606935 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -236,13 +236,16 @@ static void lumRangeFromJpeg16_c(int16_t *_dst, int width) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) static int swscale(SwsContext *c, const uint8_t *src[], - int srcStride[], int srcSliceY, - int srcSliceH, uint8_t *dst[], int dstStride[]) + int srcStride[], int srcSliceY, int srcSliceH, + uint8_t *dst[], int dstStride[], + int dstSliceY, int dstSliceH) { + const int scale_dst = dstSliceY > 0 || dstSliceH < c->dstH; + /* load a few things into local vars to make the code more readable? * and faster */ const int dstW = c->dstW; - const int dstH = c->dstH; + int dstH = c->dstH; const enum AVPixelFormat dstFormat = c->dstFormat; const int flags = c->flags; @@ -331,10 +334,15 @@ static int swscale(SwsContext *c, const uint8_t *src[], } } - /* Note the user might start scaling the picture in the middle so this - * will not get executed. This is not really intended but works - * currently, so people might do it. */ - if (srcSliceY == 0) { + if (scale_dst) { + dstY = dstSliceY; + dstH = dstY + dstSliceH; + lastInLumBuf = -1; + lastInChrBuf = -1; + } else if (srcSliceY == 0) { + /* Note the user might start scaling the picture in the middle so this + * will not get executed. This is not really intended but works + * currently, so people might do it. */ dstY = 0; lastInLumBuf = -1; lastInChrBuf = -1; @@ -352,8 +360,8 @@ static int swscale(SwsContext *c, const uint8_t *src[], srcSliceY, srcSliceH, chrSrcSliceY, chrSrcSliceH, 1); ff_init_slice_from_src(vout_slice, (uint8_t**)dst, dstStride, c->dstW, - dstY, dstH, dstY >> c->chrDstVSubSample, - AV_CEIL_RSHIFT(dstH, c->chrDstVSubSample), 0); + dstY, dstSliceH, dstY >> c->chrDstVSubSample, + AV_CEIL_RSHIFT(dstSliceH, c->chrDstVSubSample), scale_dst); if (srcSliceY == 0) { hout_slice->plane[0].sliceY = lastInLumBuf + 1; hout_slice->plane[1].sliceY = lastInChrBuf + 1; @@ -373,7 +381,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], // First line needed as input const int firstLumSrcY = FFMAX(1 - vLumFilterSize, vLumFilterPos[dstY]); - const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), dstH - 1)]); + const int firstLumSrcY2 = FFMAX(1 - vLumFilterSize, vLumFilterPos[FFMIN(dstY | ((1 << c->chrDstVSubSample) - 1), c->dstH - 1)]); // First line needed as input const int firstChrSrcY = FFMAX(1 - vChrFilterSize, vChrFilterPos[chrDstY]); @@ -477,7 +485,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], c->chrDither8 = ff_dither_8x8_128[chrDstY & 7]; c->lumDither8 = ff_dither_8x8_128[dstY & 7]; } - if (dstY >= dstH - 2) { + if (dstY >= c->dstH - 2) { /* hmm looks like we can't use MMX here without overwriting * this array's tail */ ff_sws_init_output_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX, @@ -491,21 +499,22 @@ static int swscale(SwsContext *c, const uint8_t *src[], desc[i].process(c, &desc[i], dstY, 1); } if (isPlanar(dstFormat) && isALPHA(dstFormat) && !needAlpha) { + int offset = lastDstY - dstSliceY; int length = dstW; int height = dstY - lastDstY; if (is16BPS(dstFormat) || isNBPS(dstFormat)) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); - fillPlane16(dst[3], dstStride[3], length, height, lastDstY, + fillPlane16(dst[3], dstStride[3], length, height, offset, 1, desc->comp[3].depth, isBE(dstFormat)); } else if (is32BPS(dstFormat)) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); - fillPlane32(dst[3], dstStride[3], length, height, lastDstY, + fillPlane32(dst[3], dstStride[3], length, height, offset, 1, desc->comp[3].depth, isBE(dstFormat), desc->flags & AV_PIX_FMT_FLAG_FLOAT); } else - fillPlane(dst[3], dstStride[3], length, height, lastDstY, 255); + fillPlane(dst[3], dstStride[3], length, height, offset, 255); } #if HAVE_MMXEXT_INLINE @@ -809,33 +818,42 @@ static void update_palette(SwsContext *c, const uint32_t *pal) } } +static int scale_internal(SwsContext *c, + const uint8_t * const srcSlice[], const int srcStride[], + int srcSliceY, int srcSliceH, + uint8_t *const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH); + static int scale_gamma(SwsContext *c, const uint8_t * const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, - uint8_t * const dst[], const int dstStride[]) + uint8_t * const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH) { - int ret = sws_scale(c->cascaded_context[0], - srcSlice, srcStride, srcSliceY, srcSliceH, - c->cascaded_tmp, c->cascaded_tmpStride); + int ret = scale_internal(c->cascaded_context[0], + srcSlice, srcStride, srcSliceY, srcSliceH, + c->cascaded_tmp, c->cascaded_tmpStride, 0, c->srcH); if (ret < 0) return ret; if (c->cascaded_context[2]) - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, - c->cascaded_tmpStride, srcSliceY, srcSliceH, c->cascaded1_tmp, - c->cascaded1_tmpStride); + ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, + c->cascaded1_tmp, c->cascaded1_tmpStride, 0, c->dstH); else - ret = sws_scale(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, - c->cascaded_tmpStride, srcSliceY, srcSliceH, dst, dstStride); + ret = scale_internal(c->cascaded_context[1], (const uint8_t * const *)c->cascaded_tmp, + c->cascaded_tmpStride, srcSliceY, srcSliceH, + dstSlice, dstStride, dstSliceY, dstSliceH); if (ret < 0) return ret; if (c->cascaded_context[2]) { - ret = sws_scale(c->cascaded_context[2], (const uint8_t * const *)c->cascaded1_tmp, - c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, - c->cascaded_context[1]->dstY, dst, dstStride); + ret = scale_internal(c->cascaded_context[2], (const uint8_t * const *)c->cascaded1_tmp, + c->cascaded1_tmpStride, c->cascaded_context[1]->dstY - ret, + c->cascaded_context[1]->dstY, + dstSlice, dstStride, dstSliceY, dstSliceH); } return ret; } @@ -843,56 +861,64 @@ static int scale_gamma(SwsContext *c, static int scale_cascaded(SwsContext *c, const uint8_t * const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, - uint8_t * const dst[], const int dstStride[]) + uint8_t * const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH) { - int ret = sws_scale(c->cascaded_context[0], - srcSlice, srcStride, srcSliceY, srcSliceH, - c->cascaded_tmp, c->cascaded_tmpStride); + int ret = scale_internal(c->cascaded_context[0], + srcSlice, srcStride, srcSliceY, srcSliceH, + c->cascaded_tmp, c->cascaded_tmpStride, + 0, c->cascaded_context[0]->dstH); if (ret < 0) return ret; - ret = sws_scale(c->cascaded_context[1], - (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, - 0, c->cascaded_context[0]->dstH, dst, dstStride); + ret = scale_internal(c->cascaded_context[1], + (const uint8_t * const * )c->cascaded_tmp, c->cascaded_tmpStride, + 0, c->cascaded_context[0]->dstH, + dstSlice, dstStride, dstSliceY, dstSliceH); return ret; } -/** - * swscale wrapper, so we don't need to export the SwsContext. - * Assumes planar YUV to be in YUV order instead of YVU. - */ -int attribute_align_arg sws_scale(struct SwsContext *c, - const uint8_t * const srcSlice[], - const int srcStride[], int srcSliceY, - int srcSliceH, uint8_t *const dst[], - const int dstStride[]) +static int scale_internal(SwsContext *c, + const uint8_t * const srcSlice[], const int srcStride[], + int srcSliceY, int srcSliceH, + uint8_t *const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH) { - const int frame_start = !c->sliceDir; + const int scale_dst = dstSliceY > 0 || dstSliceH < c->dstH; + const int frame_start = scale_dst || !c->sliceDir; int i, ret; const uint8_t *src2[4]; uint8_t *dst2[4]; - int macro_height = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample); + int macro_height_src = isBayer(c->srcFormat) ? 2 : (1 << c->chrSrcVSubSample); + int macro_height_dst = isBayer(c->dstFormat) ? 2 : (1 << c->chrDstVSubSample); // copy strides, so they can safely be modified int srcStride2[4]; int dstStride2[4]; int srcSliceY_internal = srcSliceY; - if (!srcStride || !dstStride || !dst || !srcSlice) { + if (!srcStride || !dstStride || !dstSlice || !srcSlice) { av_log(c, AV_LOG_ERROR, "One of the input parameters to sws_scale() is NULL, please check the calling code\n"); return AVERROR(EINVAL); } - if ((srcSliceY & (macro_height-1)) || - ((srcSliceH& (macro_height-1)) && srcSliceY + srcSliceH != c->srcH) || + if ((srcSliceY & (macro_height_src - 1)) || + ((srcSliceH & (macro_height_src - 1)) && srcSliceY + srcSliceH != c->srcH) || srcSliceY + srcSliceH > c->srcH) { av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", srcSliceY, srcSliceH); return AVERROR(EINVAL); } + if ((dstSliceY & (macro_height_dst - 1)) || + ((dstSliceH & (macro_height_dst - 1)) && dstSliceY + dstSliceH != c->dstH) || + dstSliceY + dstSliceH > c->dstH) { + av_log(c, AV_LOG_ERROR, "Slice parameters %d, %d are invalid\n", dstSliceY, dstSliceH); + return AVERROR(EINVAL); + } + if (!check_image_pointers(srcSlice, c->srcFormat, srcStride)) { av_log(c, AV_LOG_ERROR, "bad src image pointers\n"); return AVERROR(EINVAL); } - if (!check_image_pointers((const uint8_t* const*)dst, c->dstFormat, dstStride)) { + if (!check_image_pointers((const uint8_t* const*)dstSlice, c->dstFormat, dstStride)) { av_log(c, AV_LOG_ERROR, "bad dst image pointers\n"); return AVERROR(EINVAL); } @@ -902,10 +928,12 @@ int attribute_align_arg sws_scale(struct SwsContext *c, return 0; if (c->gamma_flag && c->cascaded_context[0]) - return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); + return scale_gamma(c, srcSlice, srcStride, srcSliceY, srcSliceH, + dstSlice, dstStride, dstSliceY, dstSliceH); if (c->cascaded_context[0] && srcSliceY == 0 && srcSliceH == c->cascaded_context[0]->srcH) - return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, dst, dstStride); + return scale_cascaded(c, srcSlice, srcStride, srcSliceY, srcSliceH, + dstSlice, dstStride, dstSliceY, dstSliceH); if (!srcSliceY && (c->flags & SWS_BITEXACT) && c->dither == SWS_DITHER_ED && c->dither_error[0]) for (i = 0; i < 4; i++) @@ -915,18 +943,19 @@ int attribute_align_arg sws_scale(struct SwsContext *c, update_palette(c, (const uint32_t *)srcSlice[1]); memcpy(src2, srcSlice, sizeof(src2)); - memcpy(dst2, dst, sizeof(dst2)); + memcpy(dst2, dstSlice, sizeof(dst2)); memcpy(srcStride2, srcStride, sizeof(srcStride2)); memcpy(dstStride2, dstStride, sizeof(dstStride2)); - if (frame_start) { + if (frame_start && !scale_dst) { if (srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) { av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n"); return AVERROR(EINVAL); } c->sliceDir = (srcSliceY == 0) ? 1 : -1; - } + } else if (scale_dst) + c->sliceDir = 1; if (c->src0Alpha && !c->dst0Alpha && isALPHA(c->dstFormat)) { uint8_t *base; @@ -985,10 +1014,27 @@ int attribute_align_arg sws_scale(struct SwsContext *c, reset_ptr(src2, c->srcFormat); reset_ptr((void*)dst2, c->dstFormat); - if (c->swscale) - ret = c->swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); - else - ret = swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, dst2, dstStride2); + if (c->swscale) { + int offset = srcSliceY_internal; + int slice_h = srcSliceH; + + // for dst slice scaling, offset the src pointers to match the dst slice + if (scale_dst) { + av_assert0(offset == 0); + for (i = 0; i < 4 && src2[i]; i++) { + if (!src2[i] || (i > 0 && usePal(c->srcFormat))) + break; + src2[i] += (dstSliceY >> ((i == 1 || i == 2) ? c->chrSrcVSubSample : 0)) * srcStride2[i]; + } + offset = 0; + slice_h = dstSliceH; + } + + ret = c->swscale(c, src2, srcStride2, offset, slice_h, dst2, dstStride2); + } else { + ret = swscale(c, src2, srcStride2, srcSliceY_internal, srcSliceH, + dst2, dstStride2, dstSliceY, dstSliceH); + } if (c->dstXYZ && !(c->srcXYZ && c->srcW==c->dstW && c->srcH==c->dstH)) { int dstY = c->dstY ? c->dstY : srcSliceY + srcSliceH; @@ -1002,8 +1048,32 @@ int attribute_align_arg sws_scale(struct SwsContext *c, } /* reset slice direction at end of frame */ - if (srcSliceY_internal + srcSliceH == c->srcH) + if ((srcSliceY_internal + srcSliceH == c->srcH) || scale_dst) c->sliceDir = 0; return ret; } + +/** + * swscale wrapper, so we don't need to export the SwsContext. + * Assumes planar YUV to be in YUV order instead of YVU. + */ +int attribute_align_arg sws_scale(struct SwsContext *c, + const uint8_t * const srcSlice[], + const int srcStride[], int srcSliceY, + int srcSliceH, uint8_t *const dst[], + const int dstStride[]) +{ + return scale_internal(c, srcSlice, srcStride, srcSliceY, srcSliceH, + dst, dstStride, 0, c->dstH); +} + +int attribute_align_arg +sws_scale_dst_slice(struct SwsContext *c, + const uint8_t *const src[], const int srcStride[], + uint8_t *const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH) +{ + return scale_internal(c, src, srcStride, 0, c->srcH, + dstSlice, dstStride, dstSliceY, dstSliceH); +} diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 50d6d46553..9a284bca03 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -218,6 +218,36 @@ int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[], const int srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const int dstStride[]); +/** + * Scale the image in src to produce a slice of the output image. A slice is a + * sequence of consecutive rows in an image. + * + * Unlike sws_scale() - which consumes a fixed slice of input data to produce a + * variable amount of output data - this function takes in the entire input + * image to produce a fixed slice of output. + * + * @param c the scaling context previously created with + * sws_getContext() + * @param src the array containing the pointers to the planes of + * the source image + * @param srcStride the array containing the strides for each plane of + * the source image + * @param dstSlice the array containing the pointers to the planes of + * the destination slice + * @param dstStride the array containing the strides for each plane of + * the destination image + * @param dstSliceY the position in the destination image of the slice to + * output, that is the number (counted starting from + * zero) in the image of the first row of the slice + * @param dstSliceH the height of the destination slice, that is the number + * of rows in the slice + * @return 0 on success, a negative error code on failure + */ +int sws_scale_dst_slice(struct SwsContext *c, + const uint8_t *const src[], const int srcStride[], + uint8_t *const dstSlice[], const int dstStride[], + int dstSliceY, int dstSliceH); + /** * @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg) * @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg) diff --git a/libswscale/version.h b/libswscale/version.h index f86a8049c1..0d3b7cf363 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -27,7 +27,7 @@ #include "libavutil/version.h" #define LIBSWSCALE_VERSION_MAJOR 6 -#define LIBSWSCALE_VERSION_MINOR 0 +#define LIBSWSCALE_VERSION_MINOR 1 #define LIBSWSCALE_VERSION_MICRO 100 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ From patchwork Mon May 31 07:55:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27999 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657006iof; Mon, 31 May 2021 00:57:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKOKuavgeOzpAKFZqx145qUinPcaOOcAaN21DJjAV46U2RV3oeO/creI7lHFpApF4EOiLC X-Received: by 2002:a17:906:2844:: with SMTP id s4mr21554565ejc.263.1622447860678; Mon, 31 May 2021 00:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447860; cv=none; d=google.com; s=arc-20160816; b=BHSIAtd/d6kUvEcEsR4+yDlWfXi2eghb7CK6qCvNwk/ULQbUDhWL4hTsVx8jjP5mC/ Ar9OdKxyIhItk/ghDFLg0eFtQ+ONNiDb1tkxU2kiLndFCdOlTPUPqh9gNWs/IFp2b98+ 3/90c8Qpvtt+HscpOe+c36n0dfOcMGCW2jmwtvmLdU4mlIdP8syygNWOkJQzqaDro/Jh ARGgIc0lBoQGni+r6PSXLlgZieu988SMOry3/F377uwVK8nqm7q7u5pjk/pztlcgxJYA 2y+ASesfrOPIs8FxciiXakCwjMEAmReJP+fDJM2oOc+MpVG7GoPbINWWhvEK9PUv6wqJ PIEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=+Us3PRQMDckKaf9BnnfSPZsWM93AzpZgJh7xzLZ1+64=; b=LKNmNmeTBl+RSxZM83DysWvJhXUymXAnae0O71CmwLiiFJRrAWLSTr8wsL1+zERBkG Mws0palRVeb4296er+crZrMq9VVZv8SavxjkgFvomX7r0YHHxv84lyzJd9A31sjGddAu ppzWcWdGKDiKEFNL9i8pny/3AsBjjqzE8qbyZOM1fuDlPN12VqhItO4X0xMJP0rnV058 09WtkQklL6zbSCueiAR5ZEfJN65ftqr2p2vll8NBYDiU7Q2S9qYAYSvx2HtTnEGTparu 3CwSGM5PFSIRFey5FIaQWtIV3/Cen9yW2wEpOben8BNCG+LbfqXzWyi9lcwdpv0VjF+t RJYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p3si11605901ejz.123.2021.05.31.00.57.40; Mon, 31 May 2021 00:57:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B0FCC689922; Mon, 31 May 2021 10:55:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 30F8868814B for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 85B872406A0 for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id JM9shjm3C-ye for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 52F0A2406A4 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 2E04A3A18C1; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:12 +0200 Message-Id: <20210531075515.19544-21-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 21/24] lavfi/vf_scale: factorize freeing the sws contexts X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: WQQMYu17D9EW --- libavfilter/vf_scale.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 759499395f..8516919556 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -328,16 +328,24 @@ static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) return 0; } +static void scaler_free(ScaleContext *s) +{ + sws_freeContext(s->sws); + sws_freeContext(s->isws[0]); + sws_freeContext(s->isws[1]); + + s->sws = NULL; + s->isws[0] = NULL; + s->isws[1] = NULL; +} + static av_cold void uninit(AVFilterContext *ctx) { ScaleContext *scale = ctx->priv; av_expr_free(scale->w_pexpr); av_expr_free(scale->h_pexpr); scale->w_pexpr = scale->h_pexpr = NULL; - sws_freeContext(scale->sws); - sws_freeContext(scale->isws[0]); - sws_freeContext(scale->isws[1]); - scale->sws = NULL; + scaler_free(scale); av_dict_free(&scale->opts); } @@ -512,13 +520,8 @@ static int config_props(AVFilterLink *outlink) if (outfmt == AV_PIX_FMT_PAL8) outfmt = AV_PIX_FMT_BGR8; scale->output_is_pal = av_pix_fmt_desc_get(outfmt)->flags & AV_PIX_FMT_FLAG_PAL; - if (scale->sws) - sws_freeContext(scale->sws); - if (scale->isws[0]) - sws_freeContext(scale->isws[0]); - if (scale->isws[1]) - sws_freeContext(scale->isws[1]); - scale->isws[0] = scale->isws[1] = scale->sws = NULL; + scaler_free(scale); + if (inlink0->w == outlink->w && inlink0->h == outlink->h && !scale->out_color_matrix && From patchwork Mon May 31 07:55:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 27997 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2656764iof; Mon, 31 May 2021 00:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGNpIWMOJlbnNx3bJaiVAXuzOSBOenYJHg89nhJWWj2T89KFdwM6t5tymSwhx53Lrr+ePk X-Received: by 2002:a17:906:16d2:: with SMTP id t18mr21562233ejd.277.1622447832576; Mon, 31 May 2021 00:57:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447832; cv=none; d=google.com; s=arc-20160816; b=XrI0NlJJSFXMP4rk29C6czlMuYUD93DgOPffdm+G0jn7sHulFlBTMdZIutWFnSy879 +8wj05xKodC2BnLxevETCg4mnI4QOhNAqCrJGAAMAJ1Oxsu6yy6/9EiN6HTLV3Eb/hPG CeG7e9PXQCm4X88E3j3mztcwx9GZWCu0nLYmw3O4ud2xssjcDAva2DS90+2zMNL6xD3v ZvZ23PYM16iRlcJwrFDmDjJ8lV9OuT6YCBctADp3Gr7HkMHQgU6Ydr7ZElnU9KIArTZC vEytuv7xxCt2Mg23cPpLCJcT9XAqbYjTcS09wvenGuFFmeXLuz2v8bQiJtRynM7QEP30 9Z/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=4sukXWGaXWqSQZtTovtFiZOWKyCEGzCISR+5STjhQFY=; b=F/wgwuAwjVwVtew/iYwtI1B5d74Cl2fLT4BGhVACcOp420EuiLekzPSDBEx6pSDx70 V4SHBA6sZndEgbpB09EKTK0RCx864am50ZlOGYVmoph5/tM248Ik6HaXESvnUBSRl4Km nw73nzBXS158OitFtTnzRk98rAx7INUYMKhbxPXEXfFHzyKxCtuNhTatfUwSxxWelUM6 VZXUTImFmsHJULghsu2X9wBmthe2zjBvL4TKI5r8Sv+nMDyWf0EKKEwSfCJfrieyaeZI 91VxNVqL/X/6ckmoybSN+4B4g08XXnoHWPtT6tL1DQepDA7LCIFs7qMcI02ncdwAQngR 8kyQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a4si12718414ejj.485.2021.05.31.00.57.12; Mon, 31 May 2021 00:57:12 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C81256881C5; Mon, 31 May 2021 10:55:39 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17739688128 for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id AC66724042A for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id FQNW7C2EkNlA for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 504402406A2 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 31B563A18DA; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:13 +0200 Message-Id: <20210531075515.19544-22-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 22/24] lavfi/vf_scale: pass only the private context to scale_slice() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: S6XBk6X9ZvOG Not the input link. The function does nothing with the link except extract the private context from it. --- libavfilter/vf_scale.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 8516919556..37899de6a1 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -625,9 +625,8 @@ static int request_frame_ref(AVFilterLink *outlink) return ff_request_frame(outlink->src->inputs[1]); } -static int scale_slice(AVFilterLink *link, AVFrame *out_buf, AVFrame *cur_pic, struct SwsContext *sws, int y, int h, int mul, int field) +static int scale_slice(ScaleContext *scale, AVFrame *out_buf, AVFrame *cur_pic, struct SwsContext *sws, int y, int h, int mul, int field) { - ScaleContext *scale = link->dst->priv; const uint8_t *in[4]; uint8_t *out[4]; int in_stride[4],out_stride[4]; @@ -795,8 +794,8 @@ scale: INT_MAX); if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) { - scale_slice(link, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); - scale_slice(link, out, in, scale->isws[1], 0, link->h /2, 2, 1); + scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); + scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); } else if (scale->nb_slices) { int i, slice_h, slice_start, slice_end = 0; const int nb_slices = FFMIN(scale->nb_slices, link->h); @@ -804,10 +803,10 @@ scale: slice_start = slice_end; slice_end = (link->h * (i+1)) / nb_slices; slice_h = slice_end - slice_start; - scale_slice(link, out, in, scale->sws, slice_start, slice_h, 1, 0); + scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); } } else { - scale_slice(link, out, in, scale->sws, 0, link->h, 1, 0); + scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); } av_frame_free(&in); From patchwork Mon May 31 07:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657230iof; Mon, 31 May 2021 00:58:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjZwTZZHSjwjODihD+zJejwFDOBK3lPDgtWp+PAQY91cOb/qekwI7A1FYnfS5ukBoLq/Gz X-Received: by 2002:a17:906:3818:: with SMTP id v24mr13387372ejc.197.1622447888573; Mon, 31 May 2021 00:58:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447888; cv=none; d=google.com; s=arc-20160816; b=WSMpE8b1SZ5SGASPm3WS5zZcZWC/SCD4O8kqPS5OeTn5U7lXLfDsIO94WAcFAXewA9 QtjTB0Lse4vOyuysPojl2GE2ntm4mNaSZ98OrnP04RUnf62G0w+VqO4/CTiG+Z6zT8Uq s+lVp5d9ElLZgkCk4FQ0e9kQU2omQIo8ugb1/F6T2ekc9IZhUgLvbWqS6MRvx1aQlbyf EyZAt4JlvDSZOjWzU74qPVhV4XDZSl5BO4GzUWQ5FsWG1VXWsHF4jF1Agij5qy4jCYY4 gYe4DwqRJF5oy3LuiBWAH0Btrjfe0/8RQX0/vdWo02wYFs1eAWILnZM3tUiSy46Q8g9W Wb4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=TfV2bHhLd8JhNYM9GtoUjilznO/6Jkp84IGRthgYDz4=; b=gwyX+tzZVtnhiNAYCqJpXQLr+H3oihDHueWBOAuMf3PUmHxmMZBXveWrOh5FABIvPf kvda/gCs7siUqppCQnKvHF0s88iWvUUgcsNYKbPJzkO5+eAOyFBpQsS1PougeHEWEO0W XbAkb59XS3+m9BN8L6nDO7maZge6CezQpl+5L2zTYGnBHghwFL1h+4mMxXDH5kzpwk7t 9ehBH4Itmig7gI5COsraO4QFtKr5f5GCZfGyt3mROe45rlWH9plXamAkmdafg2dyMDFM uKf7ApdvNf4czO9Ib7Zl5RxLjjLfqDTmZEFM9YimexLK/G80p7xtuLkgvWo0KT7JZxVh GqaA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id u20si12875876edv.439.2021.05.31.00.58.08; Mon, 31 May 2021 00:58:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8B6076899A7; Mon, 31 May 2021 10:55:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3782E68803C for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id F06C524069B for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id 6-O9i4K2g5w5 for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 536C42406A5 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 3584A3A1901; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:14 +0200 Message-Id: <20210531075515.19544-23-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 23/24] lavfi/vf_scale: forward errors from swscale X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 6RsOq6agk6Vf --- libavfilter/vf_scale.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index 37899de6a1..cdd7c4da0d 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -658,6 +658,7 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) AVFrame *out; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); char buf[32]; + int ret; int in_range; int frame_changed; @@ -672,7 +673,6 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) in->sample_aspect_ratio.num != link->sample_aspect_ratio.num; if (scale->eval_mode == EVAL_MODE_FRAME || frame_changed) { - int ret; unsigned vars_w[VARS_NB] = { 0 }, vars_h[VARS_NB] = { 0 }; av_expr_count_vars(scale->w_pexpr, vars_w, VARS_NB); @@ -794,8 +794,9 @@ scale: INT_MAX); if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) { - scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); - scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); + ret = scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); + if (ret >= 0) + ret = scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); } else if (scale->nb_slices) { int i, slice_h, slice_start, slice_end = 0; const int nb_slices = FFMIN(scale->nb_slices, link->h); @@ -803,14 +804,18 @@ scale: slice_start = slice_end; slice_end = (link->h * (i+1)) / nb_slices; slice_h = slice_end - slice_start; - scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); + ret = scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); + if (ret < 0) + break; } } else { - scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); + ret = scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); } av_frame_free(&in); - return 0; + if (ret < 0) + av_frame_free(frame_out); + return ret; } static int filter_frame(AVFilterLink *link, AVFrame *in) From patchwork Mon May 31 07:55:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 28010 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2657078iof; Mon, 31 May 2021 00:57:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCQ4O4CnuHWIw0SA9u3CCmo/cF4NJSAHC+O9SKjAL+lscAXq8h8APa2OFWB4x9fY/1DPIy X-Received: by 2002:a05:6402:2207:: with SMTP id cq7mr23587345edb.216.1622447870689; Mon, 31 May 2021 00:57:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622447870; cv=none; d=google.com; s=arc-20160816; b=FlYjdsaRS67khdKFd+w7Gn6GKJ9hIyLzpVcwuigUbXb/MhWpHffMUSCUOAoF8K7ZIt FD2ZQhVa9iYijdRxWrjtIP3ppeA5ZRpJAiYUroVu6fonrh/JZKZh4s0XPReeOMYDIgW4 hYR/0Mb1OJwoOEOWF0nMKCXpkvmwOKawdh4BSOTB531MGFtJSh2CdDQMG0y762h0gGzj IveBSgMTFuQJzyiIllhTrne+WvO3domH97uNYcwYh/LKenM8IDsG8uCmsgIvn99nUSRz 5EJnjKqMLqYNs43UcC/LOb+dSSS+Zo8PrLyfu46pLKk7VjI5AH+jOBolf+gKA2lcG4xY 900w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=J6cyvZnErla3T8yIUaPW/O9wtedl2r/FSYAN/eOXHWM=; b=nSpO9hDrTa3nXC4yLt5QELLgTwzLh2KRQmG6fO5n0c5UHkMN+6mgRXP7op2/hJ6Yd8 Wnl32/VrG/eTBXiegihIVACkhy2jcGDw2aPMruDimNgZFQ9wo0Z/rWwLpjlQcPx+vmn9 dncZpDXbchwM38Tuqifxck0yAnpV+9fWXD5TI4K3wsvt5HBHsdf/qga5zgFhBd/z9fjv qVy9hI8ZeBd60JO8TbZtr8fQ/OoM7+FqmIjyf1PmQ0Bz/ydQ8M178VvQZlpTOSW1yZ0C WyxKwvwqIOz7jZPbxbJNRPPTA639yNmSG6HtRX4pZm54Y+Hadx5pWSrgDY2shtmINrZO HQoA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id kf11si8327596ejc.490.2021.05.31.00.57.50; Mon, 31 May 2021 00:57:50 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8914E689953; Mon, 31 May 2021 10:55:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D2E568813A for ; Mon, 31 May 2021 10:55:29 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 5232E2406A2 for ; Mon, 31 May 2021 09:55:27 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id z1nd8fRBl6Fl for ; Mon, 31 May 2021 09:55:26 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 4FDE12406A0 for ; Mon, 31 May 2021 09:55:22 +0200 (CEST) Received: by libav.khirnov.net (Postfix, from userid 1000) id 396DF3A1908; Mon, 31 May 2021 09:55:21 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 May 2021 09:55:15 +0200 Message-Id: <20210531075515.19544-24-anton@khirnov.net> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210531075515.19544-1-anton@khirnov.net> References: <20210531075515.19544-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 24/24] lavfi/vf_scale: implement slice threading X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: q7jTiG/oDhhO --- libavfilter/vf_scale.c | 182 +++++++++++++++++++++++++++++++---------- 1 file changed, 141 insertions(+), 41 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index cdd7c4da0d..87317393bd 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -106,8 +106,16 @@ enum EvalMode { typedef struct ScaleContext { const AVClass *class; - struct SwsContext *sws; ///< software scaler context - struct SwsContext *isws[2]; ///< software scaler context for interlaced material + + /** + * Scaler contexts. + * [0] - progressive + * [1/2] - top/bottom fields + */ + struct SwsContext *(*scalers)[3]; + unsigned int nb_scalers; + int *scaler_res; + AVDictionary *opts; /** @@ -122,6 +130,7 @@ typedef struct ScaleContext { double param[2]; // sws params int hsub, vsub; ///< chroma subsampling + int ohsub, ovsub; ///< output chroma subsampling int slice_y; ///< top of current output slice int input_is_pal; ///< set to 1 if the input format is paletted int output_is_pal; ///< set to 1 if the output format is paletted @@ -153,6 +162,7 @@ typedef struct ScaleContext { int eval_mode; ///< expression evaluation mode + int passthrough; } ScaleContext; const AVFilter ff_vf_scale2ref; @@ -330,13 +340,11 @@ static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) static void scaler_free(ScaleContext *s) { - sws_freeContext(s->sws); - sws_freeContext(s->isws[0]); - sws_freeContext(s->isws[1]); + for (int i = 0; i < s->nb_scalers; i++) + for (int j = 0; j < 3; j++) + sws_freeContext(s->scalers[i][j]); - s->sws = NULL; - s->isws[0] = NULL; - s->isws[1] = NULL; + av_freep(&s->scalers); } static av_cold void uninit(AVFilterContext *ctx) @@ -346,6 +354,7 @@ static av_cold void uninit(AVFilterContext *ctx) av_expr_free(scale->h_pexpr); scale->w_pexpr = scale->h_pexpr = NULL; scaler_free(scale); + av_freep(&scale->scaler_res); av_dict_free(&scale->opts); } @@ -522,19 +531,28 @@ static int config_props(AVFilterLink *outlink) scaler_free(scale); - if (inlink0->w == outlink->w && - inlink0->h == outlink->h && - !scale->out_color_matrix && - scale->in_range == scale->out_range && - inlink0->format == outlink->format) - ; - else { - struct SwsContext **swscs[3] = {&scale->sws, &scale->isws[0], &scale->isws[1]}; - int i; - - for (i = 0; i < 3; i++) { + scale->passthrough = inlink0->w == outlink->w && + inlink0->h == outlink->h && + !scale->out_color_matrix && + scale->in_range == scale->out_range && + inlink0->format == outlink->format; + + if (!scale->passthrough) { + int nb_scalers = ff_filter_get_nb_threads(ctx); + + scale->scalers = av_mallocz_array(nb_scalers, 3 * sizeof(struct SwsContext*)); + if (!scale->scalers) + return AVERROR(ENOMEM); + + ret = av_reallocp_array(&scale->scaler_res, nb_scalers, sizeof(*scale->scaler_res)); + if (ret < 0) + return ret; + + for (int i = 0; i < 3; i++) { + for (int t = 0; t < nb_scalers; t++) { int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos; - struct SwsContext **s = swscs[i]; + struct SwsContext **s = &scale->scalers[t][i]; + *s = sws_alloc_context(); if (!*s) return AVERROR(ENOMEM); @@ -580,9 +598,29 @@ static int config_props(AVFilterLink *outlink) if ((ret = sws_init_context(*s, NULL, NULL)) < 0) return ret; + + /* do not multithread error-diffusion dithering */ + if (i == 0 && t == 0) { + const AVOption *opt; + int64_t dither; + + av_opt_get_int(*s, "sws_dither", 0, &dither); + opt = av_opt_find2(*s, "ed", "sws_dither", 0, 0, NULL); + if (!opt) + return AVERROR_BUG; + + if (dither == opt->default_val.i64) { + av_log(ctx, AV_LOG_WARNING, "Error-diffusion dithering is " + "used, conversion will be single-threaded.\n"); + nb_scalers = 1; + } + } + } + if (!scale->interlaced) break; } + scale->nb_scalers = nb_scalers; } if (inlink0->sample_aspect_ratio.num){ @@ -625,7 +663,8 @@ static int request_frame_ref(AVFilterLink *outlink) return ff_request_frame(outlink->src->inputs[1]); } -static int scale_slice(ScaleContext *scale, AVFrame *out_buf, AVFrame *cur_pic, struct SwsContext *sws, int y, int h, int mul, int field) +static int scale_slice(ScaleContext *scale, AVFrame *out_buf, AVFrame *cur_pic, struct SwsContext *sws, + int y, int h, int mul, int field, int dst) { const uint8_t *in[4]; uint8_t *out[4]; @@ -633,9 +672,10 @@ static int scale_slice(ScaleContext *scale, AVFrame *out_buf, AVFrame *cur_pic, int i; for (i=0; i<4; i++) { - int vsub= ((i+1)&2) ? scale->vsub : 0; - ptrdiff_t in_offset = ((y>>vsub)+field) * cur_pic->linesize[i]; - ptrdiff_t out_offset = field * out_buf->linesize[i]; + int vsub = ((i+1)&2) ? scale->vsub : 0; + int ovsub = ((i+1)&2) ? scale->ovsub : 0; + ptrdiff_t in_offset = (((y * !dst) >> vsub) + field) * cur_pic->linesize[i]; + ptrdiff_t out_offset = (((y * dst) >> ovsub) + field) * out_buf->linesize[i]; in_stride[i] = cur_pic->linesize[i] * mul; out_stride[i] = out_buf->linesize[i] * mul; in[i] = FF_PTR_ADD(cur_pic->data[i], in_offset); @@ -646,17 +686,57 @@ static int scale_slice(ScaleContext *scale, AVFrame *out_buf, AVFrame *cur_pic, if (scale->output_is_pal) out[1] = out_buf->data[1]; + if (dst) + return sws_scale_dst_slice(sws, in, in_stride, + out, out_stride, y / mul, h); + return sws_scale(sws, in, in_stride, y/mul, h, out,out_stride); } +typedef struct ScaleThreadData { + AVFrame *frame_in; + AVFrame *frame_out; + int scaler_idx; +} ScaleThreadData; + +static int scaler_res(ScaleContext *scale) +{ + for (int i = 0; i < scale->nb_scalers; i++) + if (scale->scaler_res[i] < 0) + return scale->scaler_res[i]; + return 0; +} + +static int scale_job(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) +{ + ScaleContext *scale = ctx->priv; + ScaleThreadData *td = arg; + int stride_mul = 1 << (td->scaler_idx > 0); + int first_field = td->scaler_idx == 1; + int picture_height = (td->frame_out->height + first_field) / stride_mul; + int slice_height = FFALIGN(FFMAX((picture_height + nb_jobs - 1) / nb_jobs, 1), + 1 << scale->ovsub); + int slice_start = jobnr * slice_height; + int slice_end = FFMIN((jobnr + 1) * slice_height, picture_height); + + if (slice_start < slice_end) { + scale_slice(scale, td->frame_out, td->frame_in, + scale->scalers[jobnr][td->scaler_idx], slice_start, + slice_end - slice_start, stride_mul, td->scaler_idx == 2, 1); + } + + return 0; +} + static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) { AVFilterContext *ctx = link->dst; ScaleContext *scale = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format); + const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format); char buf[32]; int ret; int in_range; @@ -723,13 +803,15 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, AVFrame **frame_out) } scale: - if (!scale->sws) { + if (!scale->nb_scalers) { *frame_out = in; return 0; } scale->hsub = desc->log2_chroma_w; scale->vsub = desc->log2_chroma_h; + scale->ohsub = odesc->log2_chroma_w; + scale->ovsub = odesc->log2_chroma_h; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) { @@ -755,7 +837,7 @@ scale: int in_full, out_full, brightness, contrast, saturation; const int *inv_table, *table; - sws_getColorspaceDetails(scale->sws, (int **)&inv_table, &in_full, + sws_getColorspaceDetails(scale->scalers[0][0], (int **)&inv_table, &in_full, (int **)&table, &out_full, &brightness, &contrast, &saturation); @@ -773,17 +855,14 @@ scale: if (scale->out_range != AVCOL_RANGE_UNSPECIFIED) out_full = (scale->out_range == AVCOL_RANGE_JPEG); - sws_setColorspaceDetails(scale->sws, inv_table, in_full, + for (int i = 0; i < 3; i++) + for (int j = 0; j < scale->nb_scalers; j++) { + if (!scale->scalers[j][i]) + continue; + sws_setColorspaceDetails(scale->scalers[j][i], inv_table, in_full, table, out_full, brightness, contrast, saturation); - if (scale->isws[0]) - sws_setColorspaceDetails(scale->isws[0], inv_table, in_full, - table, out_full, - brightness, contrast, saturation); - if (scale->isws[1]) - sws_setColorspaceDetails(scale->isws[1], inv_table, in_full, - table, out_full, - brightness, contrast, saturation); + } out->color_range = out_full ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; } @@ -793,10 +872,22 @@ scale: (int64_t)in->sample_aspect_ratio.den * outlink->w * link->h, INT_MAX); + memset(scale->scaler_res, 0, scale->nb_scalers * sizeof(*scale->scaler_res)); + if (scale->interlaced>0 || (scale->interlaced<0 && in->interlaced_frame)) { - ret = scale_slice(scale, out, in, scale->isws[0], 0, (link->h+1)/2, 2, 0); - if (ret >= 0) - ret = scale_slice(scale, out, in, scale->isws[1], 0, link->h /2, 2, 1); + ScaleThreadData td = { + .scaler_idx = 1, + .frame_in = in, + .frame_out = out, + }; + + ctx->internal->execute(ctx, scale_job, &td, scale->scaler_res, scale->nb_scalers); + + if (scaler_res(scale) >= 0) { + td.scaler_idx = 2; + memset(scale->scaler_res, 0, scale->nb_scalers * sizeof(*scale->scaler_res)); + ctx->internal->execute(ctx, scale_job, &td, scale->scaler_res, scale->nb_scalers); + } } else if (scale->nb_slices) { int i, slice_h, slice_start, slice_end = 0; const int nb_slices = FFMIN(scale->nb_slices, link->h); @@ -804,14 +895,22 @@ scale: slice_start = slice_end; slice_end = (link->h * (i+1)) / nb_slices; slice_h = slice_end - slice_start; - ret = scale_slice(scale, out, in, scale->sws, slice_start, slice_h, 1, 0); + ret = scale_slice(scale, out, in, scale->scalers[0][0], slice_start, slice_h, 1, 0, 0); if (ret < 0) break; } } else { - ret = scale_slice(scale, out, in, scale->sws, 0, link->h, 1, 0); + ScaleThreadData td = { + .scaler_idx = 0, + .frame_in = in, + .frame_out = out, + }; + + ctx->internal->execute(ctx, scale_job, &td, scale->scaler_res, scale->nb_scalers); } + ret = scaler_res(scale); + av_frame_free(&in); if (ret < 0) av_frame_free(frame_out); @@ -984,6 +1083,7 @@ const AVFilter ff_vf_scale = { .inputs = avfilter_vf_scale_inputs, .outputs = avfilter_vf_scale_outputs, .process_command = process_command, + .flags = AVFILTER_FLAG_SLICE_THREADS, }; static const AVClass scale2ref_class = {