From patchwork Mon Oct 21 00:48:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15872 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4EE5C448281 for ; Mon, 21 Oct 2019 03:48:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2057068AFBF; Mon, 21 Oct 2019 03:48:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B7E168AF83 for ; Mon, 21 Oct 2019 03:48:24 +0300 (EEST) Received: by mail-pg1-f193.google.com with SMTP id 23so6666271pgk.3 for ; Sun, 20 Oct 2019 17:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xRvgy18RYb9RUhn8DIlPIinll7hYZFJ3aybWpMraU8Y=; b=VVXnxrh2E4uf0bERfi0NhpaHhAnu41aN7/Xcm6iQWQ2T+/my4o8Be8nDgF9DaWaQib i56bNMboHvGPQEddtIwQOZ4hnZIg1Rw27NXZ80ORMrQP05yyDIWQxa/zSp0SAP1DQ3an +O6C+FcpNDQc9ANWS9EwOkMle3pTJklIpQ87fDknA6Kbr6Yi0fEIRByBxUhLL3fgdwBP gcSCl96qWaPYz3R5BGXqJPhQkUtPttThrSqBWEmUrbAF2gQfdRQycENFM3smb2uDbkr4 CY1qS/LEWBELgGQ4t+rrX8PX8QViVH8lUrZoGuLm+9jrx5Nlo/WUss+paUbVdh1nkOBq 4jDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xRvgy18RYb9RUhn8DIlPIinll7hYZFJ3aybWpMraU8Y=; b=GjV+2UdgoSJ2GE4tO7LglCFZxkb7D7/X72EHOINygL/bYlWUjFVPdMQ5f804hihLUb AiMnfNowhFaNWbTtJF7CqH0zLM+b+d9g3IGVOzAumv3Hth478/YAubYcRNRJypcBsuth ZD5Nbq0CVcUI4tksrItgEpAnRpMAn/QfzQPwm3st826JD0pW6kA9L9Jkfp4zD0pGoJ8C sZAl3vCVrdH/859QpvKxB8P4Gqbtp4zc7GoKdS82Y4SwZn3WWwA/plL7npG+GBtm4ilS EQ9Ig9wDww8UvHGtneQ9hosKGJyEq/lLrrYlPufZ2BGO/GMbJDhWTHLVcEqVfa0f81w4 HcJA== X-Gm-Message-State: APjAAAXOK0B6YMIc8yqaUR5DPsnZSXxmy6W/L2k0mND105PHj5izzLSV DiDf3bLIGYNHac9GgpuMEoEVrpbWCXQ= X-Google-Smtp-Source: APXvYqznvCjZDP+sqTkewSC2mvXePbgiYc0WaKRGxcksSW3SVE9Yz//IVg3rJYWS0oOIWai+azV/tg== X-Received: by 2002:a17:90a:d205:: with SMTP id o5mr25557194pju.46.1571618902218; Sun, 20 Oct 2019 17:48:22 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id x19sm17154813pgc.59.2019.10.20.17.48.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 17:48:21 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2019 08:48:14 +0800 Message-Id: <20191021004814.13935-2-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20191021004814.13935-1-lance.lmwang@gmail.com> References: <20190830033752.26454-2-lance.lmwang@gmail.com> <20191021004814.13935-1-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 2/2] avcodec/hapdec: simplify the calculation of slice start and end X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/hapdec.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/libavcodec/hapdec.c b/libavcodec/hapdec.c index 8c845770cf..dd325bb51a 100644 --- a/libavcodec/hapdec.c +++ b/libavcodec/hapdec.c @@ -246,7 +246,7 @@ static int decompress_chunks_thread(AVCodecContext *avctx, void *arg, } static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg, - int slice, int thread_nb, int texture_num) + int jobnr, int thread_nb, int texture_num) { HapContext *ctx = avctx->priv_data; AVFrame *frame = arg; @@ -254,21 +254,8 @@ static int decompress_texture_thread_internal(AVCodecContext *avctx, void *arg, int w_block = avctx->coded_width / TEXTURE_BLOCK_W; int h_block = avctx->coded_height / TEXTURE_BLOCK_H; int x, y; - int start_slice, end_slice; - int base_blocks_per_slice = h_block / ctx->slice_count; - int remainder_blocks = h_block % ctx->slice_count; - - /* When the frame height (in blocks) doesn't divide evenly between the - * number of slices, spread the remaining blocks evenly between the first - * operations */ - start_slice = slice * base_blocks_per_slice; - /* Add any extra blocks (one per slice) that have been added before this slice */ - start_slice += FFMIN(slice, remainder_blocks); - - end_slice = start_slice + base_blocks_per_slice; - /* Add an extra block if there are still remainder blocks to be accounted for */ - if (slice < remainder_blocks) - end_slice++; + int start_slice = (h_block * jobnr) / ctx->slice_count; + int end_slice = (h_block * (jobnr+1)) / ctx->slice_count; for (y = start_slice; y < end_slice; y++) { uint8_t *p = frame->data[0] + y * frame->linesize[0] * TEXTURE_BLOCK_H;