From patchwork Wed Sep 28 10:06:02 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: 38423 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp98544pzh; Wed, 28 Sep 2022 03:06:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53tJVexg6D23Qpzqdc5zdmqWEryMIPpwHc94vN55tLsn7b2isP+Ind5CXeTJHHy58kWYRv X-Received: by 2002:a05:6402:1911:b0:451:6e0b:7eee with SMTP id e17-20020a056402191100b004516e0b7eeemr32648243edz.170.1664359572980; Wed, 28 Sep 2022 03:06:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664359572; cv=none; d=google.com; s=arc-20160816; b=konIDTn6gx0VUeF5YdFooS00l1Ip1T5H46spafJ8tfwuPdLO+1K3Qv1pww9SaAZnUJ JTxFk2L+uvVajLaJibccGd+iRrVZUxIdlpj8LP6jUKy+MlGSU0AjzMdnucxvDlZ5aky1 XNKiJBy4FAo/Kxhgmko+foR2xU3HP0qxRADnurxaCxpnRZccaUWt+z05a/M95Xg/UxNq f4oy6lTjWJyXm2bbwu0CZkOeBpbKbbxRZI4p1wHdhTgZvRJsYfEhXMaa9ghQLbQDnOjc GS+yS/cuVOs1jYDuLyjNht3mBRWQ6Mem3E+15HYe0ekXIWOMucy8bl9REyZK6l/Tp/4u JFRA== 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:delivered-to; bh=LsJuzrQp4d1udPFVaTXNj0KHnZqnHPKeBu7sHjDKYvw=; b=F+LgAqlhT6x/qvpdkrlzurWEVZLuk+Hz+VH7xje6L5/PEikAFkaghYDm5NwgScI15F ytb/alSyQgw/seCxP/cs5MZQ21lI0SHHSJumZ9AgvMChUb8AwP88P1Vg7FI3z+PgUVmC 2ZtacTUeX3vX3JO2aptr4f8ZhSRcGEm3GOc2YllX/GAN/Wh53cHG+Mb9SQvrmjeXH+kd T4pY7cR1TTxYQ1Vn5xPaPtbBFKTMk/AlKmxI4J8VG1ui7bgFxP9Ob41FlR2wrASNPQhw FKWWWIyaN9258cMMaLG+m25ftHjUK6iS+uSLZg+PWzq72ckHg5XpDtNxx4w9slxXdM/P FhOw== 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 t5-20020a056402524500b0044eae9d65c4si5342778edd.75.2022.09.28.03.06.12; Wed, 28 Sep 2022 03:06: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 DFB3E68BC30; Wed, 28 Sep 2022 13:06:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.frobbit.se (mail.frobbit.se [85.30.129.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C38C68BC23 for ; Wed, 28 Sep 2022 13:06:04 +0300 (EEST) Received: from debian.lan (unknown [IPv6:2a00:66c0:a::72c]) by mail.frobbit.se (Postfix) with ESMTPSA id 9A23C215EC for ; Wed, 28 Sep 2022 12:06:03 +0200 (CEST) Message-ID: From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Wed, 28 Sep 2022 12:06:02 +0200 In-Reply-To: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se> References: <65e79fe701374868bb2f4b70ce8fd220938e2e86.camel@haerdin.se> User-Agent: Evolution 3.38.3-1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/11] 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: QY9lcDEd/4rv This is the one that needs the new execute2() From 4e7c65a7a3e049396ce5e3c01db335a532889115 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 04/11] lavc/jpeg2000dec: Thread init_tile() --- libavcodec/jpeg2000dec.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c index 273346538f..00aa73e261 100644 --- a/libavcodec/jpeg2000dec.c +++ b/libavcodec/jpeg2000dec.c @@ -1019,12 +1019,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; + const 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); @@ -1034,12 +1041,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]; @@ -1063,7 +1064,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; } @@ -2371,9 +2372,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; } @@ -2668,6 +2666,9 @@ 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; + if ((ret = avctx->execute2(avctx, init_tile, NULL, NULL, s->numXtiles * s->numYtiles * s->ncomponents)) < 0) + goto end; + if (ret = jpeg2000_read_bitstream_packets(s)) goto end; -- 2.30.2