From patchwork Fri Mar 17 13:18:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Darnley X-Patchwork-Id: 2984 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp260713vsy; Fri, 17 Mar 2017 06:25:15 -0700 (PDT) X-Received: by 10.223.129.183 with SMTP id 52mr14084465wra.88.1489757115076; Fri, 17 Mar 2017 06:25:15 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o5si11164931wrc.319.2017.03.17.06.25.14; Fri, 17 Mar 2017 06:25:15 -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=@ob-encoder-com.20150623.gappssmtp.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 441FD688368; Fri, 17 Mar 2017 15:24:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10A1068834D for ; Fri, 17 Mar 2017 15:24:40 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id x124so3297132wmf.3 for ; Fri, 17 Mar 2017 06:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ob-encoder-com.20150623.gappssmtp.com; s=20150623; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Bd70usw9Y3llP/vWbHvBPv/2AYTYrdqgDYc+f/UVXkw=; b=Ndw07dmqhVU6RINGDYoZAnD7W8IbXM3dne4/uwljq9wbFwS4Yb8Evihyp1VseMwChP JjAtTgaPfH64LdZJ427R13QBk9qW8+BG29xXcPtL1q1e5py0uovPhh0G+VknLRMDd4S+ yQE101XkyWwIR+hDK68332gxAMPOyf6Lm5G/bqoLblVeFWjYBhd9DuXHx+2hdewBjW3q jl14HMY7gxzCs1rK3HFhnwvu0TRjpbj6wa/B5sxLlQg1jDbvv8cI4zwQpNE5182Zyy8P 0XVlYZBSpYMVxzTVs/O60VnC6+gmxkjg9xv6lmDozg6fgP7mCcTpQLCUPm0T9K79/vqP VEeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Bd70usw9Y3llP/vWbHvBPv/2AYTYrdqgDYc+f/UVXkw=; b=ICZMI5bEj5p1RO+v75i5vepgskdQNZGAsTOocmRkYinGYfnFxe3ZgWVGz9l+hrYbYg 9mAw1IkDPpSrz9V8r2uUDTGdDfwU1C3fshAVIvWYqqUpEvtV9nWMwZN+GcuHCxCBJKVP 6mXHDCAOWJcCk9ZuiPll1LDXakz8aMpu2Wefwr0goYbbfbMlTmJi0wwja7arlseSw1/Z aHvItskIIbRNMsnVdxs0qBHv5LU4yMlU+iuRNQgRlfKj79rnH+Ka1uR8eHVRRajj2hSI vHu3G2quX2fcX1EkFfnZh59TA+McXbsdbs0FBQSa/EOl4PHHgVkFQNzGlnYIfYuiJfK5 fJmQ== X-Gm-Message-State: AFeK/H0jyjqAaR1yKqwLLdQMTGLtESwhnQ8xbfzAVbD9676gZ7r+6SJ2TIpbT1WTNW1VWg== X-Received: by 10.28.218.80 with SMTP id r77mr2916144wmg.0.1489756771277; Fri, 17 Mar 2017 06:19:31 -0700 (PDT) Received: from localhost.localdomain (d51a44418.access.telenet.be. [81.164.68.24]) by smtp.gmail.com with ESMTPSA id e72sm2676411wma.5.2017.03.17.06.19.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 06:19:30 -0700 (PDT) From: James Darnley To: FFmpeg development discussions and patches Date: Fri, 17 Mar 2017 14:18:44 +0100 Message-Id: <20170317131845.7760-10-jdarnley@obe.tv> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20170317131845.7760-1-jdarnley@obe.tv> References: <20170317131845.7760-1-jdarnley@obe.tv> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/10] h264_idct8_add4 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 1.00x faster (2884±63.9 vs. 2880±21.1 decicycles) compared with sse2 --- libavcodec/x86/h264_idct.asm | 60 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/h264dsp_init.c | 2 ++ 2 files changed, 62 insertions(+) diff --git a/libavcodec/x86/h264_idct.asm b/libavcodec/x86/h264_idct.asm index f1f2ce7..1515ea5 100644 --- a/libavcodec/x86/h264_idct.asm +++ b/libavcodec/x86/h264_idct.asm @@ -1237,3 +1237,63 @@ cglobal h264_idct_add16_8, 5, 5 + ARCH_X86_64, 8, dst_, block_offset_, block_, s add16_sse2_cycle 6, 0x1e add16_sse2_cycle 7, 0x26 RET + +; dst, block_offset, block, stride, nnzc, counter, coeff, dst2, picreg +; 0 1 2 3 4 5 6 7 8 +cglobal h264_idct8_add4_8, 5, 8 + npicregs, 10, dst_, block_offset_, block_, stride_, nnzc_, counter_, coeff_, dst2_, picreg + movsxdifnidn stride_q, stride_d + xor counter_q, counter_q + %ifdef PIC + lea picregq, [scan8_mem] + %endif + + .next_block: + movzx coeff_d, byte [scan8 + counter_q] + movzx coeff_d, byte [nnzc_q + coeff_q] + test coeff_d, coeff_d + jz .skip_block + + cmp coeff_d, 1 + jnz .no_dc + + movsx coeff_d, word [block_q] + test coeff_d, coeff_d + jz .no_dc + + mov word [block_q], 0 + DC_ADD_INIT r6 + %define stride3 r6 + %if ARCH_X86_64 == 0 + %define dst2_q r1 + %define dst2_d r1d + %endif + + mov dst2_d, dword [block_offset_q + 4*counter_q] + add dst2_q, dst_q + DC_ADD_MMXEXT_OP movq, dst2_q, stride_q, stride3 + lea dst2_q, [dst2_q + 4*stride_q] + DC_ADD_MMXEXT_OP movq, dst2_q, stride_q, stride3 + %if ARCH_X86_64 == 0 + mov block_offset_q, block_offset_m + %endif + + add counter_q, 4 + add block_q, 128 + cmp counter_q, 16 + jl .next_block + RET + + .no_dc: + mov dst2_d, dword [block_offset_q + 4*counter_q] + add dst2_q, dst_q + IDCT8_ADD_SSE dst2_q, block_q, stride_q, stride3 + %if ARCH_X86_64 == 0 + mov block_offset_q, block_offset_m + %endif + + .skip_block: + add counter_q, 4 + add block_q, 128 + cmp counter_q, 16 + jl .next_block +RET diff --git a/libavcodec/x86/h264dsp_init.c b/libavcodec/x86/h264dsp_init.c index 3396fd8..4050276 100644 --- a/libavcodec/x86/h264dsp_init.c +++ b/libavcodec/x86/h264dsp_init.c @@ -57,6 +57,7 @@ void ff_h264_idct ## NUM ## _add ## REP ## _ ## DEPTH ## _ ## OPT \ IDCT_ADD_REP_FUNC(8, 4, 8, mmx) IDCT_ADD_REP_FUNC(8, 4, 8, mmxext) IDCT_ADD_REP_FUNC(8, 4, 8, sse2) +IDCT_ADD_REP_FUNC(8, 4, 8, avx) IDCT_ADD_REP_FUNC(8, 4, 10, sse2) IDCT_ADD_REP_FUNC(8, 4, 10, avx) IDCT_ADD_REP_FUNC(, 16, 8, mmx) @@ -348,6 +349,7 @@ av_cold void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, c->h264_idct_dc_add = ff_h264_idct_dc_add_8_avx; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_avx; c->h264_idct_add16 = ff_h264_idct_add16_8_avx; + c->h264_idct8_add4 = ff_h264_idct8_add4_8_avx; } } else if (bit_depth == 10) { if (EXTERNAL_MMXEXT(cpu_flags)) {