From patchwork Mon Aug 31 21:09:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 22035 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 101C544B3A0 for ; Tue, 1 Sep 2020 00:10:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EABD368AD19; Tue, 1 Sep 2020 00:10:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 79E1D68034C for ; Tue, 1 Sep 2020 00:10:03 +0300 (EEST) Received: by mail-wm1-f66.google.com with SMTP id b79so741965wmb.4 for ; Mon, 31 Aug 2020 14:10:03 -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 :mime-version:content-transfer-encoding; bh=PlIOZJpY8qrBFgTMR49Ofv1PtEzDM/leDqkZ3qRMjHs=; b=tacQhbl7B9PXNmd5FeGvhIGLlzxYsKgpkwC6BLPV3vE91TG/SByzi4VH9OHiS5yR5R 16j2hh5ZXxcReWJP9TvoI5z34xOMYAO6IpXoViF/vZWDKIyqcSvECdVWhdrhbabuqU/K S3AqBvkKB4rfQ+HDBwbQaGyR7mVyceVRuZHWvqFn2N1kdbhWsEO2YQy2DlWEsuoBIOfD yFbt73WU726k/ROSUlsmjjiRnqDCUnuflbIAs4hRxP03Ar+lY4jNzQuHXf+oM7OHnsiV XNElGGgykbF83md8ISuo5T3i8kKwZL5BOZRivYmwnh6H3kN1pt0sYI3I0VX+tImf1XnL 1AXw== 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:mime-version:content-transfer-encoding; bh=PlIOZJpY8qrBFgTMR49Ofv1PtEzDM/leDqkZ3qRMjHs=; b=cNbnbqE8QLuG0TvnA+e8sybEXnFEKbWCuVzwMYmvMXPjRxPjBQ4Q5AEmamM+DjYwNJ EzS7VMFFAvSIrKM9NJ42dW5Zgg28zPZW+yyUrE/wt8Kc1yOj886SNqq7z6n1YDpabikW ZTWy46Qq2WkIj/ykqCa1dyUsrfZPSOqa+FoYdT0o6UU8aNDBQRT5wUPkRCjFvBcJD57V ZYevkRWyjEHYPHsqMQUsj2eFyw3tonA0DQx/ibD2FUwHIVG3I4u+aHULZ6HKS3l6iP31 gJfZGWY2eCEmSFz2xVQ9KjDagItuZFoU5H+sgsB3TxbK8tBGm7t+mNT22NOUYCozsBxU mvcA== X-Gm-Message-State: AOAM530h5K/DXGEtdUGAzo46hrye+85WohD/LxljOHzQtY/Glpuyl0Ch C7rWuRclM33rkda8BOTT0tfOMdz+pj4= X-Google-Smtp-Source: ABdhPJw1iSwIwrIFDGaSDIqw8VaT0Q7sX5mPuY0rqysggNojkPT7iMSsyURK/eA7HGE0xdAuYCDLuQ== X-Received: by 2002:a1c:9a48:: with SMTP id c69mr999793wme.43.1598908202530; Mon, 31 Aug 2020 14:10:02 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1fb0f.dynamic.kabel-deutschland.de. [188.193.251.15]) by smtp.gmail.com with ESMTPSA id s124sm1035798wme.29.2020.08.31.14.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 14:10:02 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 31 Aug 2020 23:09:25 +0200 Message-Id: <20200831210930.18900-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200831210930.18900-1-andreas.rheinhardt@gmail.com> References: <20200831210930.18900-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] avcodec/magicyuv: Unify qsort comparison functions 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Up until now, there were three comparison functions depending upon bitness. But they all are actually the same, namely a lexical ordering: entry a > entry b iff a.len > b.len or a.len == b.len and a.sym < b.sym. So they can be easily unified. Signed-off-by: Andreas Rheinhardt --- libavcodec/magicyuv.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index f630464162..5578374429 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -77,18 +77,6 @@ typedef struct MagicYUVContext { } MagicYUVContext; static int huff_cmp_len(const void *a, const void *b) -{ - const HuffEntry *aa = a, *bb = b; - return (aa->len - bb->len) * 256 + bb->sym - aa->sym; -} - -static int huff_cmp_len10(const void *a, const void *b) -{ - const HuffEntry *aa = a, *bb = b; - return (aa->len - bb->len) * 1024 + bb->sym - aa->sym; -} - -static int huff_cmp_len12(const void *a, const void *b) { const HuffEntry *aa = a, *bb = b; return (aa->len - bb->len) * 4096 + bb->sym - aa->sym; @@ -106,7 +94,7 @@ static int huff_build10(VLC *vlc, uint8_t *len) if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; } - AV_QSORT(he, 1024, HuffEntry, huff_cmp_len10); + AV_QSORT(he, 1024, HuffEntry, huff_cmp_len); code = 1; for (i = 1023; i >= 0; i--) { @@ -133,7 +121,7 @@ static int huff_build12(VLC *vlc, uint8_t *len) if (len[i] == 0 || len[i] > 32) return AVERROR_INVALIDDATA; } - AV_QSORT(he, 4096, HuffEntry, huff_cmp_len12); + AV_QSORT(he, 4096, HuffEntry, huff_cmp_len); code = 1; for (i = 4095; i >= 0; i--) {