From patchwork Tue Jun 14 14:43:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 36228 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1115172pzb; Tue, 14 Jun 2022 07:43:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v1f3cxCHKzz5WuzIkyhnBnJKtHxxRJoSGgh/sjmi11CfxUSBqLDXPv/ad9uoTUXPI41rJF X-Received: by 2002:a17:906:a245:b0:708:ce69:e38b with SMTP id bi5-20020a170906a24500b00708ce69e38bmr4644458ejb.100.1655217825578; Tue, 14 Jun 2022 07:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655217825; cv=none; d=google.com; s=arc-20160816; b=FtxI3dPEU2yreSb6B4n5SNUz3itGJxbbnh+JjxtUKaz9pBdMtpQhI04y1hgITGv/Ni 46swyc+ont+kIxJFi0pDPexxYjVXss6mKKoDprYPCnuSXEONExUUGJE1TIL0AVCvttja cAvWNDp8vxYD9vheXNo9nJZmt5nWJpBjHPiVZNRpMrCCFOeETu4ECbnMKoRtnidaAI+G fIdee3crS8c+roJXmgotKtDpkdl5yU78geoutfuDkOsJHQFhAN6H7+dW72CHAhrf5rW2 zODi1aY4C6S1thJ5KzHZEv97M0OSbR3m6iNzDKCnBZvRm4106Kmnv7t8P02gYh1LcrZR 0HxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:references:in-reply-to:date:to:from :message-id:dkim-signature:dkim-signature:delivered-to; bh=4HGA4VYTRD+acS5IWUzNkWdsy7I92RTIgYp0Vbqssxo=; b=wrjU5L6ASADFns8eRNiro1h/POYqaA1cmd9QUuPWEVlHhWUWpdx8qKPrqVxm6z+fO6 /e5EygDWcunEWKGK/FuLdVRKyXug8ywYR0x7UrtusvN4Sdlv6RIFUWu1pvJ2sWUSOG2J k1iNEYUjlkuH02yeMvzE5+yhvnCM3Eq0D7IYrZn0BSefZ67+8P5/oXF5YQv7VXrPlYcs aoQFjOeGw8SgjJitK3nVlrth53lHV7iJ/weNrM1ttZpTiM4cb4qpEg6HubOZ5c4wctxv BthiyJ7Z5itjGkeuoi2gjIURyfF3At7QvowJbGQM34YOKSUvEz/GzvnxeCCsRQS1mB9b IAqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=UOiyHew2; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=UOiyHew2; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acc.umu.se Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cs16-20020a170906dc9000b006f3d2558d4bsi12802793ejc.496.2022.06.14.07.43.45; Tue, 14 Jun 2022 07:43: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; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=UOiyHew2; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=UOiyHew2; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acc.umu.se Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9B0D368B6A3; Tue, 14 Jun 2022 17:43:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.acc.umu.se (mail.acc.umu.se [130.239.18.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79CFC68B68F for ; Tue, 14 Jun 2022 17:43:40 +0300 (EEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id F1CD444DCB for ; Tue, 14 Jun 2022 16:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1655217819; bh=aAd4xBRACtCKL98UF8NpKE3Pz1io6OF2n63x82J/P8k=; h=Subject:From:To:Date:In-Reply-To:References:From; b=UOiyHew2ePEFPXwj/Ck97L1/hFJPCYwyHyPEWGhfJ/LICSPM29n7EfesYSx5A14Ff ZJKVUtjQI6N4VSAFX9V/vj65ZKvqY24CW8q1vtSoNDMErj2tO2vpX5Axgpktpfg2v8 v71/sHXzqeH16FbuRTb7C1dcvUWZfr9wlM7X00550yFCiBnlmJ9/g66GkxBIb/XZKk SIz5gn/aTDblf79oaFzMIemNPFAuTNr4MavU2aL32et1ytXHHlwMqDiOXUViFSgTN0 LLnGUeWs3kOHhn61qbkFIilXg9E+1ONH+NeTbUfm/TYwcsNGXYO5ENOS7FhZ6ne4K7 8L43xs40fvaUQ== Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: tjoppen) by mail.acc.umu.se (Postfix) with ESMTPSA id 3D86A44DC6 for ; Tue, 14 Jun 2022 16:43:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1655217819; bh=aAd4xBRACtCKL98UF8NpKE3Pz1io6OF2n63x82J/P8k=; h=Subject:From:To:Date:In-Reply-To:References:From; b=UOiyHew2ePEFPXwj/Ck97L1/hFJPCYwyHyPEWGhfJ/LICSPM29n7EfesYSx5A14Ff ZJKVUtjQI6N4VSAFX9V/vj65ZKvqY24CW8q1vtSoNDMErj2tO2vpX5Axgpktpfg2v8 v71/sHXzqeH16FbuRTb7C1dcvUWZfr9wlM7X00550yFCiBnlmJ9/g66GkxBIb/XZKk SIz5gn/aTDblf79oaFzMIemNPFAuTNr4MavU2aL32et1ytXHHlwMqDiOXUViFSgTN0 LLnGUeWs3kOHhn61qbkFIilXg9E+1ONH+NeTbUfm/TYwcsNGXYO5ENOS7FhZ6ne4K7 8L43xs40fvaUQ== Message-ID: <5141c5587ce703481b716b9898e086e47f763a49.camel@acc.umu.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Tue, 14 Jun 2022 16:43:38 +0200 In-Reply-To: <10ec51ef44325c2de6d5de7b994a9b6c8eb5e3a2.camel@acc.umu.se> References: <10ec51ef44325c2de6d5de7b994a9b6c8eb5e3a2.camel@acc.umu.se> User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/13] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4 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: EQtZhfqdPJyZ From 03b806f89453571310dcb14edbd9f51e059b7476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Wed, 8 Jun 2022 10:08:15 +0200 Subject: [PATCH 09/13] lavc/jpeg2000: Speed up ff_jpeg2000_tag_tree_init() using stereotypes for sizes <= 4x4 --- libavcodec/jpeg2000.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c index 0bec2e187d..b80e68bcba 100644 --- a/libavcodec/jpeg2000.c +++ b/libavcodec/jpeg2000.c @@ -51,6 +51,31 @@ static int32_t tag_tree_size(int w, int h) return (int32_t)(res + 1); } +#define T(x) (x*sizeof(Jpeg2000TgtNode)) + +static const size_t tt_sizes[16] = { + T(1),T(3),T(6),T(7),T(3),T(5),T(9),T(11),T(6),T(9),T(14),T(17),T(7),T(11),T(17),T(21), +}; + +static const Jpeg2000TgtNode tt_stereotypes[16][21] = { + {{-1},}, + {{2},{2},{-1},}, + {{3},{3},{4},{5},{5},{-1},}, + {{4},{4},{5},{5},{6},{6},{-1},}, + {{2},{2},{-1},}, + {{4},{4},{4},{4},{-1},}, + {{6},{6},{7},{6},{6},{7},{8},{8},{-1},}, + {{8},{8},{9},{9},{8},{8},{9},{9},{10},{10},{-1},}, + {{3},{3},{4},{5},{5},{-1},}, + {{6},{6},{6},{6},{7},{7},{8},{8},{-1},}, + {{9},{9},{10},{9},{9},{10},{11},{11},{12},{13},{13},{13},{13},{-1},}, + {{12},{12},{13},{13},{12},{12},{13},{13},{14},{14},{15},{15},{16},{16},{16},{16},{-1},}, + {{4},{4},{5},{5},{6},{6},{-1},}, + {{8},{8},{8},{8},{9},{9},{9},{9},{10},{10},{-1},}, + {{12},{12},{13},{12},{12},{13},{14},{14},{15},{14},{14},{15},{16},{16},{16},{16},{-1},}, + {{16},{16},{17},{17},{16},{16},{17},{17},{18},{18},{19},{19},{18},{18},{19},{19},{20},{20},{20},{20},{-1},}, +}; + /* allocate the memory for tag tree */ static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size, int w, int h) { @@ -59,6 +84,15 @@ static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size, int32_t tt_size, ofs = 0; size_t prod; + if (w <= 4 && h <= 4) { + int idx = w-1 + (h-1)*4; + size_t sz = tt_sizes[idx]; + av_fast_malloc(old, size, sz); + if (*old) { + memcpy(*old, tt_stereotypes[idx], sz); + } + return 0; + } else { tt_size = tag_tree_size(w, h); if (av_size_mult(tt_size, sizeof(*t), &prod)) @@ -87,6 +121,7 @@ static int ff_jpeg2000_tag_tree_init(Jpeg2000TgtNode **old, unsigned int *size, } t[0].parent = -1; return 0; + } } void ff_tag_tree_zero(Jpeg2000TgtNode *t, int w, int h, int val) -- 2.30.2