From patchwork Tue Jun 14 14:41:14 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: 36225 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1a22:b0:84:42e0:ad30 with SMTP id cj34csp1114117pzb; Tue, 14 Jun 2022 07:41:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyapOiBhCi7DosaS45jQRQbYylxvPSw3WP0yS0JPnlTYpi8GwPVmcm2OoED9qaPb3ppADbd X-Received: by 2002:a05:6402:d:b0:431:98fe:c5fd with SMTP id d13-20020a056402000d00b0043198fec5fdmr6418597edu.170.1655217684827; Tue, 14 Jun 2022 07:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655217684; cv=none; d=google.com; s=arc-20160816; b=gsVwpSbXzPoTFmLjq0JM9tDtDpS+y0eU5b1TyvZReDHLcTySRxixbtKn4ws94NPMjq Dk88hcFkzPNbBS1WyH84u2BE6zA11n7D/CeXOCaFAkK/dLRPR4xq0AqEU87nuoVSSId+ S+9NaNwzShxBPAmlM+t9Sp/xJCduFF4JRyyBoSwbFkVdUd3OU21C6p1Vgzq6o7cD18cl yemZclK2YyAI/7LVV644IrgO9CMMT7OALAvSwTN/qqcavPT3fah6mlOVpXoNdHcbu483 y8tHeDb0IwyFXQTK9VqXzoW4zemfcrdALoP1/EaiWC75zp5fUIko13dXcCHk42MqrFCi sVow== 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=ar2xY9mfQ9B5XuZ+FYC/ubLa22/MKfl/aN/dhepPjF4=; b=MqEf88Q4xqIrqDFo7BKcbLqDhPqh21pVuAe4umB4MiiKtwJMHIPrfY+uW5bi9CnnEy X3Nc07z4sS6s/VU4aDy8swXcsDJZtXSd84hD0TNHlsxXTQ49pBsChq3a8W2Q/I1xs3TQ ruYreWR35g3aCrTsXoCDSs9bLPeOzMqR/CmFpRaFWKYODor7wovv0l3A5JAHkaOqYOoG JI1WMiylpxGtNRn/RtuRWgOTlavHmmokPi4/Y+hCHEipdhXFoPmUqYEyeNmPddnsi6u6 PgKJrivSTfgi28x+7EhCyVO2Q1U7ySwI8KBEUGgIWsVpYFa5IJUy6c6nI23MIZsb9YZM PTpQ== 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=pyOyG1w7; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=HmhfRqsN; 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 e9-20020a170906044900b0070b6d46c7eesi10624662eja.105.2022.06.14.07.41.24; Tue, 14 Jun 2022 07:41:24 -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=pyOyG1w7; dkim=neutral (body hash did not verify) header.i=@acc.umu.se header.s=mail1 header.b=HmhfRqsN; 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 4475D680C0D; Tue, 14 Jun 2022 17:41:22 +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 7C659680C0D for ; Tue, 14 Jun 2022 17:41:15 +0300 (EEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by amavisd-new (Postfix) with ESMTP id 13EE644DCB for ; Tue, 14 Jun 2022 16:41:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1655217675; bh=0dslA+wrBsmStcQCPb9M6AtxQtfZa1VDs9drVWXRR0I=; h=Subject:From:To:Date:In-Reply-To:References:From; b=pyOyG1w73I0coAMI0qND3uSHxSGZxEtbojcRqr6yJj1qgMu73RWj2mofMMrl07DOm ylkZuPdc6IZy7hCv7jayx4pL2/n272TCX/HBnhrvHLQ/8FzYYN6gIgLrC8dc4dD4F5 dsxx7nlc8O3iF5bGfDJZa9v+UzD5gRgPXoK+GZgKTmsSro/jxkAA2Ou7JZ0diDVEve +I6xf3+qH0IJQaQ4l2OT3gAohNRoFN1W6/mtMc5RYsEbfL7/FdVDX8fZ7dKO9QSFcu WsoV4gp3dXdvacpBSmV/rsamsSwj8eaiTKeYvDlKVNGV6e4IOdlndop25zNqhWCy5t F8tVUiGTO+xwQ== 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 8F59D44DC6 for ; Tue, 14 Jun 2022 16:41:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=acc.umu.se; s=mail1; t=1655217674; bh=0dslA+wrBsmStcQCPb9M6AtxQtfZa1VDs9drVWXRR0I=; h=Subject:From:To:Date:In-Reply-To:References:From; b=HmhfRqsNFgRbKUHg3n9E3A1uap/yz88XipT1YLFg31LLnzvvYAnEFg+SSLlcMLjeu TBqiQIjH158zN0kBlGhTQufBeMxs9/RMY2FH+X6y4HTUsYPcY0nEj7lXJRLXbeMWXQ g/xtAAXO+cYg55OPvc0maiDHRAOYU3iHw+Gohz7F+CGjUmsOPhsEGmQZQEwHbE26t5 6EXPLEqRcUdpOAB/f6zqywkgSlUKGcKgPLpICFj/kPylfVbN7hKPducnKuN+ZAN2+P Aa9AyFRWIUFEKT+unZDTTynzoI27oKJFnjczTBlEOym9feSnHj5uUzwFBdzYlom7qB a2PZqWoJW4sDw== Message-ID: <2ab7238154c98289a19f655c87a20c339561b3e8.camel@acc.umu.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Tue, 14 Jun 2022 16:41:14 +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 05/13] lavc/jpeg2000dec: Thread init_tile() 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: d29nA3pqe2Su From 080ebdc9bad130098bff575f9ce690b8a522c9f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Mon, 13 Jun 2022 15:09:17 +0200 Subject: [PATCH 05/13] lavc/jpeg2000dec: Thread init_tile() --- libavcodec/jpeg2000dec.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 9344630c6f..ef5167c29e 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1015,12 +1015,19 @@ static int get_ppt(Jpeg2000DecoderContext *s, int n) return 0; } -static int init_tile(Jpeg2000DecoderContext *s, int tileno) +static int init_tile(AVCodecContext *avctx, void *td, + int jobnr, int threadnr) { - int compno; - int tilex = tileno % s->numXtiles; - int tiley = tileno / s->numXtiles; - Jpeg2000Tile *tile = s->tile + tileno; + Jpeg2000DecoderContext *s = avctx->priv_data; + int tileno = jobnr / s->ncomponents; + int tilex = tileno % s->numXtiles; + int tiley = tileno / s->numXtiles; + int compno = jobnr % s->ncomponents; + Jpeg2000Tile *tile = s->tile + tileno; + Jpeg2000Component *comp = tile->comp + compno; + Jpeg2000CodingStyle *codsty = tile->codsty + compno; + Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; + int ret; // global bandno if (!tile->comp) return AVERROR(ENOMEM); @@ -1030,12 +1037,6 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno) tile->coord[1][0] = av_clip(tiley * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); tile->coord[1][1] = av_clip((tiley + 1) * (int64_t)s->tile_height + s->tile_offset_y, s->image_offset_y, s->height); - for (compno = 0; compno < s->ncomponents; compno++) { - Jpeg2000Component *comp = tile->comp + compno; - Jpeg2000CodingStyle *codsty = tile->codsty + compno; - Jpeg2000QuantStyle *qntsty = tile->qntsty + compno; - int ret; // global bandno - comp->coord_o[0][0] = tile->coord[0][0]; comp->coord_o[0][1] = tile->coord[0][1]; comp->coord_o[1][0] = tile->coord[1][0]; @@ -1059,7 +1060,7 @@ static int init_tile(Jpeg2000DecoderContext *s, int tileno) s->cbps[compno], s->cdx[compno], s->cdy[compno], s->avctx, s->slices)) return ret; - } + return 0; } @@ -2367,9 +2368,6 @@ static int jpeg2000_read_bitstream_packets(Jpeg2000DecoderContext *s) for (tileno = 0; tileno < s->numXtiles * s->numYtiles; tileno++) { Jpeg2000Tile *tile = s->tile + tileno; - if ((ret = init_tile(s, tileno)) < 0) - return ret; - if ((ret = jpeg2000_decode_packets(s, tile)) < 0) return ret; } @@ -2656,6 +2654,8 @@ static int jpeg2000_decode_frame(AVCodecContext *avctx, AVFrame *picture, picture->key_frame = 1; s->slices = avctx->active_thread_type == FF_THREAD_SLICE ? avctx->thread_count : 1; + avctx->execute2(avctx, init_tile, NULL, NULL, s->numXtiles * s->numYtiles * s->ncomponents); + if (ret = jpeg2000_read_bitstream_packets(s)) goto end; -- 2.30.2