From patchwork Mon Oct 21 00:48:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 15873 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 42C7D449FC3 for ; Mon, 21 Oct 2019 04:13:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D82468AFD7; Mon, 21 Oct 2019 04:13:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1796E68AFC5 for ; Mon, 21 Oct 2019 04:13:08 +0300 (EEST) Received: by mail-pg1-f195.google.com with SMTP id k20so6703654pgi.1 for ; Sun, 20 Oct 2019 18:13:08 -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=n5AJKpbLXb1m815ahxe+bF8zewWSEyq7zBg7gi4ypCo=; b=UkgJPaHcpyYtnOxaGPXLAAvUSEldRkaQVnFfgFKEnH3AohZum8ALbX1Kco/1Zk4F3i c8ZYiYm1xaPXvKDK2n9XlViu/5phtbftx3zfr0C5zhYCLTdkwWLtetLhdRbENwYE3fP+ BX7Wy2TryxlWhdlt0rqeAB9OlCwoukqIhT8MjxVosVbgVsZlHctrIxLrsT46opVFj6oz ZO0SU/5cV70S89FrNzvadnIfBpP5UQz6mE+TKgShzekq2m28OmufhsR2sl3Kg2SExD8M a3ZkqpwUXX9LyyovDdd1USyUyGbGChZdJ6b0KteqcxHcSzkNDKhALBhiwe8PZzBrJt29 GNoQ== 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=n5AJKpbLXb1m815ahxe+bF8zewWSEyq7zBg7gi4ypCo=; b=nSpt0OBCaRJgVO2EGcG7HWZlxqHha+Y2vYgqsuIhNflZxTnPMZFqKyK4Cpwi/GIqVJ MTAZMn9w9ObUdDSfYf+A80DDVbwdKbDfQXja9IV8qUWBTtD3qLlAI79Dki72K7vnOGXW 0ymFcLSlFD65O/YqSEVqrahmHNPu3jjqHSCQr5DKX24qwvnfELykfYUySclUbNurc35w A9BTzw1ANNDEqMoTWDf6EuEoXfX1fFnUmnn2hnRjbHnzKECU8bAP49p/ejxkxj+jWExE +U+hbyRfLS/Lqs7UnpL4PKMvH0CylSzvxuZLmqBZSe8JPNl5erkEkU8bdgZTEgOoao5X ytHQ== X-Gm-Message-State: APjAAAWtzWAouQ5Oezrsx3wFekkG6MUIh/KD2WgT/2N6U5+b7ywCDZoB B8yDgN3dQHO9mLx9i2537IccAVqC+wg= X-Google-Smtp-Source: APXvYqy6ihR//Xa2SD84rLJHS28pTS69pQ514TJEdTxab92m4I01FyAXvBCtAZHLyufUSjOBMjfsvw== X-Received: by 2002:a63:ce4b:: with SMTP id r11mr21768166pgi.194.1571618899540; Sun, 20 Oct 2019 17:48:19 -0700 (PDT) Received: from vpn.localdomain ([47.90.99.151]) by smtp.gmail.com with ESMTPSA id x19sm17154813pgc.59.2019.10.20.17.48.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Oct 2019 17:48:19 -0700 (PDT) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Mon, 21 Oct 2019 08:48:13 +0800 Message-Id: <20191021004814.13935-1-lance.lmwang@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20190830033752.26454-2-lance.lmwang@gmail.com> References: <20190830033752.26454-2-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v1 1/2] avcodec/dds: 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/dds.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 9154f692fa..7c0ad9ee72 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -434,7 +434,7 @@ static int parse_pixel_format(AVCodecContext *avctx) } static int decompress_texture_thread(AVCodecContext *avctx, void *arg, - int slice, int thread_nb) + int jobnr, int thread_nb) { DDSContext *ctx = avctx->priv_data; AVFrame *frame = arg; @@ -442,21 +442,8 @@ static int decompress_texture_thread(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;