[x265] [PATCH] primitves: add c primitives for the following :
Aarthi Thirumalai
aarthi at multicorewareinc.com
Fri Oct 11 12:40:26 CEST 2013
# HG changeset patch
# User Aarthi Thirumalai
# Date 1381488011 -19800
# Fri Oct 11 16:10:11 2013 +0530
# Node ID 9b9c6766967dc99cab93c3e09514346606125b3e
# Parent c6d89dc62e191f56f63dbcb1781a6494da50a70d
primitves: add c primitives for the following :
compute AC energy for each block
copy pixels of chroma plane
diff -r c6d89dc62e19 -r 9b9c6766967d source/common/pixel.cpp
--- a/source/common/pixel.cpp Fri Oct 11 01:47:53 2013 -0500
+++ b/source/common/pixel.cpp Fri Oct 11 16:10:11 2013 +0530
@@ -688,6 +688,33 @@
}
return ssim;
}
+
+template<int w, int h>
+uint64_t pixel_var(pixel *pix, intptr_t i_stride)
+{
+ uint32_t sum = 0, sqr = 0;
+ for (int y = 0; y < h; y++)
+ {
+ for (int x = 0; x < w; x++)
+ {
+ sum += pix[x];
+ sqr += pix[x] * pix[x];
+ }
+ pix += i_stride;
+ }
+ return sum + ((uint64_t)sqr << 32);
+}
+
+void plane_copy_deinterleave_chroma(pixel *dstu, intptr_t dstuStride, pixel *dstv, intptr_t dstvStride,
+ pixel *src, intptr_t srcStride, int w, int h)
+{
+ for (int y = 0; y < h; y++, dstu += dstuStride, dstv += dstvStride, src += srcStride)
+ for (int x = 0; x < w; x++)
+ {
+ dstu[x] = src[2 * x];
+ dstv[x] = src[2 * x + 1];
+ }
+}
} // end anonymous namespace
namespace x265 {
@@ -905,5 +932,9 @@
p.frame_init_lowres_core = frame_init_lowres_core;
p.ssim_4x4x2_core = ssim_4x4x2_core;
p.ssim_end_4 = ssim_end_4;
+
+ p.var[PARTITION_16x16] = pixel_var<16,16>;
+ p.var[PARTITION_8x8] = pixel_var<8,8>;
+ p.plane_copy_deinterleave_c = plane_copy_deinterleave_chroma;
}
}
diff -r c6d89dc62e19 -r 9b9c6766967d source/common/primitives.h
--- a/source/common/primitives.h Fri Oct 11 01:47:53 2013 -0500
+++ b/source/common/primitives.h Fri Oct 11 16:10:11 2013 +0530
@@ -202,6 +202,8 @@
typedef void (*extendCURowBorder_t)(pixel* txt, intptr_t stride, int width, int height, int marginX);
typedef void (*ssim_4x4x2_core_t)(const pixel *pix1, intptr_t stride1, const pixel *pix2, intptr_t stride2, ssim_t sums[2][4]);
typedef float (*ssim_end4_t)(ssim_t sum0[5][4], ssim_t sum1[5][4], int width);
+typedef uint64_t (*var_t)(pixel *pix, intptr_t stride);
+typedef void (*plane_copy_deinterleave_t)(pixel *dstu, intptr_t dstuStride, pixel *dstv, intptr_t dstvStride, pixel *src, intptr_t srcStride, int w, int h);
/* Define a structure containing function pointers to optimized encoder
* primitives. Each pointer can reference either an assembly routine,
@@ -261,6 +263,8 @@
downscale_t frame_init_lowres_core;
ssim_4x4x2_core_t ssim_4x4x2_core;
ssim_end4_t ssim_end_4;
+ var_t var[NUM_PARTITIONS];
+ plane_copy_deinterleave_t plane_copy_deinterleave_c;
};
/* This copy of the table is what gets used by the encoder.
More information about the x265-devel
mailing list