[x265] Fwd: [PATCH 1 of 3] SEA motion search:Setup asm primitives for integral calculation
Praveen Tiwari
praveen at multicorewareinc.com
Tue May 2 15:42:23 CEST 2017
---------- Forwarded message ----------
From: <vignesh at multicorewareinc.com>
Date: Tue, May 2, 2017 at 3:16 PM
Subject: [x265] [PATCH 1 of 3] SEA motion search:Setup asm primitives for
integral calculation
To: x265-devel at videolan.org
# HG changeset patch
# User Vignesh Vijayakumar
# Date 1493699293 -19800
# Tue May 02 09:58:13 2017 +0530
# Node ID cb67dffd0e2a596c8d3c6d042b8e6c532487d427
# Parent 5bc5e73760cdb61d2674e74cc52149fa0603af8a
SEA motion search:Setup asm primitives for integral calculation
diff -r 5bc5e73760cd -r cb67dffd0e2a source/common/primitives.cpp
--- a/source/common/primitives.cpp Sat Apr 22 17:00:28 2017 -0700
+++ b/source/common/primitives.cpp Tue May 02 09:58:13 2017 +0530
@@ -57,6 +57,7 @@
void setupIntraPrimitives_c(EncoderPrimitives &p);
void setupLoopFilterPrimitives_c(EncoderPrimitives &p);
void setupSaoPrimitives_c(EncoderPrimitives &p);
+void setupSeaIntegralPrimitives_c(EncoderPrimitives &p);
void setupCPrimitives(EncoderPrimitives &p)
{
@@ -66,6 +67,7 @@
setupIntraPrimitives_c(p); // intrapred.cpp
setupLoopFilterPrimitives_c(p); // loopfilter.cpp
setupSaoPrimitives_c(p); // sao.cpp
+ setupSeaIntegralPrimitives_c(p); // framefilter.cpp
}
void setupAliasPrimitives(EncoderPrimitives &p)
diff -r 5bc5e73760cd -r cb67dffd0e2a source/common/primitives.h
--- a/source/common/primitives.h Sat Apr 22 17:00:28 2017 -0700
+++ b/source/common/primitives.h Tue May 02 09:58:13 2017 +0530
@@ -202,6 +202,18 @@
typedef void (*pelFilterLumaStrong_t)(pixel* src, intptr_t srcStep,
intptr_t offset, int32_t tcP, int32_t tcQ);
typedef void (*pelFilterChroma_t)(pixel* src, intptr_t srcStep, intptr_t
offset, int32_t tc, int32_t maskP, int32_t maskQ);
>>
+
typedef void(*integral4h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+typedef void(*integral8h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+typedef void(*integral12h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+typedef void(*integral16h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+typedef void(*integral24h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+typedef void(*integral32h_t)(uint32_t *sum, pixel *pix, intptr_t stride);
>>
+
typedef void(*integral4v_t)(uint32_t *sum, intptr_t stride);
>>
+typedef void(*integral8v_t)(uint32_t *sum, intptr_t stride);
>>
+typedef void(*integral12v_t)(uint32_t *sum, intptr_t stride);
>>
+typedef void(*integral16v_t)(uint32_t *sum, intptr_t stride);
>>
+typedef void(*integral24v_t)(uint32_t *sum, intptr_t stride);
>>
+typedef void(*integral32v_t)(uint32_t *sum, intptr_t stride);
Just needed two typedef here, one for horitontal and one for vertical
rest of the typedef are redudent here.
/* Function pointers to optimized encoder primitives. Each pointer can
reference
* either an assembly routine, a SIMD intrinsic primitive, or a C function
*/
@@ -342,6 +354,19 @@
pelFilterLumaStrong_t pelFilterLumaStrong[2]; // EDGE_VER = 0,
EDGE_HOR = 1
pelFilterChroma_t pelFilterChroma[2]; // EDGE_VER = 0,
EDGE_HOR = 1
>>
+ integral4h_t integral_init4h;
>>
+ integral8h_t integral_init8h;
>>
+ integral12h_t integral_init12h;
>>
+ integral16h_t integral_init16h;
>>
+ integral24h_t integral_init24h;
>>
+ integral32h_t integral_init32h;
>>
+ integral4v_t integral_init4v;
>>
+ integral8v_t integral_init8v;
>>
+ integral12v_t integral_init12v;
>>
+ integral16v_t integral_init16v;
>>
+ integral24v_t integral_init24v;
>>
+ integral32v_t integral_init32v;
>>
+
An array of appropiate size for horizontal and another for vertical.
/* There is one set of chroma primitives per color space. An encoder
will
* have just a single color space and thus it will only ever use one
entry
* in this array. However we always fill all entries in the array in
case
diff -r 5bc5e73760cd -r cb67dffd0e2a source/common/x86/asm-primitives.cpp
--- a/source/common/x86/asm-primitives.cpp Sat Apr 22 17:00:28 2017
-0700
+++ b/source/common/x86/asm-primitives.cpp Tue May 02 09:58:13 2017
+0530
@@ -114,6 +114,7 @@
#include "blockcopy8.h"
#include "intrapred.h"
#include "dct8.h"
+#include "seaintegral.h"
}
#define ALL_LUMA_CU_TYPED(prim, fncdef, fname, cpu) \
diff -r 5bc5e73760cd -r cb67dffd0e2a source/common/x86/seaintegral.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/source/common/x86/seaintegral.h Tue May 02 09:58:13 2017 +0530
@@ -0,0 +1,41 @@
+/**********************************************************
*******************
+* Copyright (C) 2013-2017 MulticoreWare, Inc
+*
+* Authors: Vignesh V Menon <vignesh at multicorewareinc.com>
+* Jayashri Murugan <jayashri at multicorewareinc.com>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111,
USA.
+*
+* This program is also available under a commercial proprietary license.
+* For more information, contact us at license @ x265.com.
+***********************************************************
******************/
+
+#ifndef X265_SEAINTEGRAL_H
+#define X265_SEAINTEGRAL_H
+
+void PFX(integral4h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral8h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral12h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral16h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral24h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral32h_avx2)(uint32_t *sum, pixel *pix, intptr_t stride);
+void PFX(integral4v_avx2)(uint32_t *sum, intptr_t stride);
+void PFX(integral8v_avx2)(uint32_t *sum, intptr_t stride);
+void PFX(integral12v_avx2)(uint32_t *sum, intptr_t stride);
+void PFX(integral16v_avx2)(uint32_t *sum, intptr_t stride);
+void PFX(integral24v_avx2)(uint32_t *sum, intptr_t stride);
+void PFX(integral32v_avx2)(uint32_t *sum, intptr_t stride);
+
+#endif //X265_SEAINTEGRAL_H
diff -r 5bc5e73760cd -r cb67dffd0e2a source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Sat Apr 22 17:00:28 2017 -0700
+++ b/source/encoder/framefilter.cpp Tue May 02 09:58:13 2017 +0530
@@ -34,108 +34,126 @@
static uint64_t computeSSD(pixel *fenc, pixel *rec, intptr_t stride,
uint32_t width, uint32_t height);
static float calculateSSIM(pixel *pix1, intptr_t stride1, pixel *pix2,
intptr_t stride2, uint32_t width, uint32_t height, void *buf, uint32_t&
cnt);
+namespace X265_NS
+{
+ void integral_init4h_c(uint32_t *sum, pixel *pix, intptr_t stride)
+ {
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3];
+ for (int16_t x = 0; x < stride - 4; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 4] - pix[x];
+ }
+ }
Why removed "ststic" from C primitives?
-static void integral_init4h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3];
- for (int16_t x = 0; x < stride - 4; x++)
+ void integral_init8h_c(uint32_t *sum, pixel *pix, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 4] - pix[x];
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7];
+ for (int16_t x = 0; x < stride - 8; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 8] - pix[x];
+ }
}
-}
-static void integral_init8h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7];
- for (int16_t x = 0; x < stride - 8; x++)
+ void integral_init12h_c(uint32_t *sum, pixel *pix, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 8] - pix[x];
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
+ pix[8] + pix[9] + pix[10] + pix[11];
+ for (int16_t x = 0; x < stride - 12; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 12] - pix[x];
+ }
}
-}
-static void integral_init12h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
- pix[8] + pix[9] + pix[10] + pix[11];
- for (int16_t x = 0; x < stride - 12; x++)
+ void integral_init16h_c(uint32_t *sum, pixel *pix, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 12] - pix[x];
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
+ pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] +
pix[14] + pix[15];
+ for (int16_t x = 0; x < stride - 16; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 16] - pix[x];
+ }
}
-}
-static void integral_init16h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
- pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] + pix[14]
+ pix[15];
- for (int16_t x = 0; x < stride - 16; x++)
+ void integral_init24h_c(uint32_t *sum, pixel *pix, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 16] - pix[x];
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
+ pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] +
pix[14] + pix[15] +
+ pix[16] + pix[17] + pix[18] + pix[19] + pix[20] + pix[21] +
pix[22] + pix[23];
+ for (int16_t x = 0; x < stride - 24; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 24] - pix[x];
+ }
}
-}
-static void integral_init24h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
- pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] + pix[14]
+ pix[15] +
- pix[16] + pix[17] + pix[18] + pix[19] + pix[20] + pix[21] +
pix[22] + pix[23];
- for (int16_t x = 0; x < stride - 24; x++)
+ void integral_init32h_c(uint32_t *sum, pixel *pix, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 24] - pix[x];
+ int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
+ pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] +
pix[14] + pix[15] +
+ pix[16] + pix[17] + pix[18] + pix[19] + pix[20] + pix[21] +
pix[22] + pix[23] +
+ pix[24] + pix[25] + pix[26] + pix[27] + pix[28] + pix[29] +
pix[30] + pix[31];
+ for (int16_t x = 0; x < stride - 32; x++)
+ {
+ sum[x] = v + sum[x - stride];
+ v += pix[x + 32] - pix[x];
+ }
}
-}
-static void integral_init32h(uint32_t *sum, pixel *pix, intptr_t stride)
-{
- int32_t v = pix[0] + pix[1] + pix[2] + pix[3] + pix[4] + pix[5] +
pix[6] + pix[7] +
- pix[8] + pix[9] + pix[10] + pix[11] + pix[12] + pix[13] + pix[14]
+ pix[15] +
- pix[16] + pix[17] + pix[18] + pix[19] + pix[20] + pix[21] +
pix[22] + pix[23] +
- pix[24] + pix[25] + pix[26] + pix[27] + pix[28] + pix[29] +
pix[30] + pix[31];
- for (int16_t x = 0; x < stride - 32; x++)
+ void integral_init4v_c(uint32_t *sum4, intptr_t stride)
{
- sum[x] = v + sum[x - stride];
- v += pix[x + 32] - pix[x];
+ for (int x = 0; x < stride; x++)
+ sum4[x] = sum4[x + 4 * stride] - sum4[x];
}
-}
-static void integral_init4v(uint32_t *sum4, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum4[x] = sum4[x + 4 * stride] - sum4[x];
-}
+ void integral_init8v_c(uint32_t *sum8, intptr_t stride)
+ {
+ for (int x = 0; x < stride; x++)
+ sum8[x] = sum8[x + 8 * stride] - sum8[x];
+ }
-static void integral_init8v(uint32_t *sum8, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum8[x] = sum8[x + 8 * stride] - sum8[x];
-}
+ void integral_init12v_c(uint32_t *sum12, intptr_t stride)
+ {
+ for (int x = 0; x < stride; x++)
+ sum12[x] = sum12[x + 12 * stride] - sum12[x];
+ }
-static void integral_init12v(uint32_t *sum12, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum12[x] = sum12[x + 12 * stride] - sum12[x];
-}
+ void integral_init16v_c(uint32_t *sum16, intptr_t stride)
+ {
+ for (int x = 0; x < stride; x++)
+ sum16[x] = sum16[x + 16 * stride] - sum16[x];
+ }
-static void integral_init16v(uint32_t *sum16, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum16[x] = sum16[x + 16 * stride] - sum16[x];
-}
+ void integral_init24v_c(uint32_t *sum24, intptr_t stride)
+ {
+ for (int x = 0; x < stride; x++)
+ sum24[x] = sum24[x + 24 * stride] - sum24[x];
+ }
-static void integral_init24v(uint32_t *sum24, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum24[x] = sum24[x + 24 * stride] - sum24[x];
-}
+ void integral_init32v_c(uint32_t *sum32, intptr_t stride)
+ {
+ for (int x = 0; x < stride; x++)
+ sum32[x] = sum32[x + 32 * stride] - sum32[x];
+ }
-static void integral_init32v(uint32_t *sum32, intptr_t stride)
-{
- for (int x = 0; x < stride; x++)
- sum32[x] = sum32[x + 32 * stride] - sum32[x];
+ void setupSeaIntegralPrimitives_c(EncoderPrimitives &p)
+ {
+ p.integral_init4h = integral_init4h_c;
+ p.integral_init8h = integral_init8h_c;
+ p.integral_init12h = integral_init12h_c;
+ p.integral_init16h = integral_init16h_c;
+ p.integral_init24h = integral_init24h_c;
+ p.integral_init32h = integral_init32h_c;
+ p.integral_init4v = integral_init4v_c;
+ p.integral_init8v = integral_init8v_c;
+ p.integral_init12v = integral_init12v_c;
+ p.integral_init16v = integral_init16v_c;
+ p.integral_init24v = integral_init24v_c;
+ p.integral_init32v = integral_init32v_c;
+ }
}
void FrameFilter::destroy()
@@ -833,47 +851,47 @@
uint32_t *sum4x4 = m_frame->m_encData->m_meIntegral[11] + (y +
1) * stride - padX;
/*For width = 32 */
- integral_init32h(sum32x32, pix, stride);
+ primitives.integral_init32h(sum32x32, pix, stride);
if (y >= 32 - padY)
- integral_init32v(sum32x32 - 32 * stride, stride);
- integral_init32h(sum32x24, pix, stride);
+ primitives.integral_init32v(sum32x32 - 32 * stride,
stride);
+ primitives.integral_init32h(sum32x24, pix, stride);
if (y >= 24 - padY)
- integral_init24v(sum32x24 - 24 * stride, stride);
- integral_init32h(sum32x8, pix, stride);
+ primitives.integral_init24v(sum32x24 - 24 * stride,
stride);
+ primitives.integral_init32h(sum32x8, pix, stride);
if (y >= 8 - padY)
- integral_init8v(sum32x8 - 8 * stride, stride);
+ primitives.integral_init8v(sum32x8 - 8 * stride, stride);
/*For width = 24 */
- integral_init24h(sum24x32, pix, stride);
+ primitives.integral_init24h(sum24x32, pix, stride);
if (y >= 32 - padY)
- integral_init32v(sum24x32 - 32 * stride, stride);
+ primitives.integral_init32v(sum24x32 - 32 * stride,
stride);
/*For width = 16 */
- integral_init16h(sum16x16, pix, stride);
+ primitives.integral_init16h(sum16x16, pix, stride);
if (y >= 16 - padY)
- integral_init16v(sum16x16 - 16 * stride, stride);
- integral_init16h(sum16x12, pix, stride);
+ primitives.integral_init16v(sum16x16 - 16 * stride,
stride);
+ primitives.integral_init16h(sum16x12, pix, stride);
if (y >= 12 - padY)
- integral_init12v(sum16x12 - 12 * stride, stride);
- integral_init16h(sum16x4, pix, stride);
+ primitives.integral_init12v(sum16x12 - 12 * stride,
stride);
+ primitives.integral_init16h(sum16x4, pix, stride);
if (y >= 4 - padY)
- integral_init4v(sum16x4 - 4 * stride, stride);
+ primitives.integral_init4v(sum16x4 - 4 * stride, stride);
/*For width = 12 */
- integral_init12h(sum12x16, pix, stride);
+ primitives.integral_init12h(sum12x16, pix, stride);
if (y >= 16 - padY)
- integral_init16v(sum12x16 - 16 * stride, stride);
+ primitives.integral_init16v(sum12x16 - 16 * stride,
stride);
/*For width = 8 */
- integral_init8h(sum8x32, pix, stride);
+ primitives.integral_init8h(sum8x32, pix, stride);
if (y >= 32 - padY)
- integral_init32v(sum8x32 - 32 * stride, stride);
- integral_init8h(sum8x8, pix, stride);
+ primitives.integral_init32v(sum8x32 - 32 * stride, stride);
+ primitives.integral_init8h(sum8x8, pix, stride);
if (y >= 8 - padY)
- integral_init8v(sum8x8 - 8 * stride, stride);
+ primitives.integral_init8v(sum8x8 - 8 * stride, stride);
/*For width = 4 */
- integral_init4h(sum4x16, pix, stride);
+ primitives.integral_init4h(sum4x16, pix, stride);
if (y >= 16 - padY)
- integral_init16v(sum4x16 - 16 * stride, stride);
- integral_init4h(sum4x4, pix, stride);
+ primitives.integral_init16v(sum4x16 - 16 * stride, stride);
+ primitives.integral_init4h(sum4x4, pix, stride);
if (y >= 4 - padY)
- integral_init4v(sum4x4 - 4 * stride, stride);
+ primitives.integral_init4v(sum4x4 - 4 * stride, stride);
Use size to calculate index for array of function pointers, once you
made the above mentioned changes.
}
m_parallelFilter[row].m_frameFilter->integralCompleted.set(1);
}
This does't apply to latest tip. Please update.
_______________________________________________
x265-devel mailing list
x265-devel at videolan.org
https://mailman.videolan.org/listinfo/x265-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170502/759f6455/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-1.patch
Type: text/x-patch
Size: 18557 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170502/759f6455/attachment-0001.bin>
More information about the x265-devel
mailing list