2014-07-03 00:30:04 +04:00
|
|
|
/* test_YCoCg.c
|
|
|
|
* vi:ts=4 sw=4
|
|
|
|
*
|
|
|
|
* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <winpr/sysinfo.h>
|
|
|
|
#include "prim_test.h"
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
2016-07-13 15:04:48 +03:00
|
|
|
static BOOL test_YCoCgRToRGB_8u_AC4R_func(void)
|
2014-07-03 00:30:04 +04:00
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
BOOL result = TRUE;
|
|
|
|
pstatus_t status;
|
2016-03-02 16:53:55 +03:00
|
|
|
INT32 ALIGN(out_sse[4098]), ALIGN(out_sse_inv[4098]);
|
2014-07-03 00:30:04 +04:00
|
|
|
INT32 ALIGN(in[4098]);
|
|
|
|
INT32 ALIGN(out_c[4098]), ALIGN(out_c_inv[4098]);
|
2016-07-13 15:04:48 +03:00
|
|
|
|
|
|
|
UINT32 i, x;
|
|
|
|
const UINT32 formats[] = {
|
|
|
|
PIXEL_FORMAT_ARGB32,
|
|
|
|
PIXEL_FORMAT_ABGR32,
|
|
|
|
PIXEL_FORMAT_RGBA32,
|
|
|
|
PIXEL_FORMAT_RGBX32,
|
|
|
|
PIXEL_FORMAT_BGRA32,
|
|
|
|
PIXEL_FORMAT_BGRX32
|
|
|
|
};
|
|
|
|
|
|
|
|
winpr_RAND((BYTE*)in, sizeof(in));
|
|
|
|
|
|
|
|
for (x=0; x<sizeof(formats)/sizeof(formats[0]); x++)
|
2014-07-03 00:30:04 +04:00
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
UINT32 format = formats[x];
|
|
|
|
|
|
|
|
status = generic->YCoCgToRGB_8u_AC4R(
|
|
|
|
(const BYTE*)(in + 1), 63 * 4,
|
|
|
|
(BYTE*) out_c, format, 63 * 4, 63, 61, 2, TRUE);
|
|
|
|
if (status != PRIMITIVES_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
status = generic->YCoCgToRGB_8u_AC4R(
|
|
|
|
(const BYTE*)(in + 1), 63 * 4,
|
|
|
|
(BYTE*) out_c_inv, format, 63 * 4, 63, 61, 2, TRUE);
|
|
|
|
if (status != PRIMITIVES_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
status = optimized->YCoCgToRGB_8u_AC4R(
|
|
|
|
(const BYTE*)(in + 1), 63 * 4,
|
|
|
|
(BYTE*) out_sse, format, 63 * 4, 63, 61, 2, TRUE);
|
|
|
|
if (status != PRIMITIVES_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
status = optimized->YCoCgToRGB_8u_AC4R(
|
|
|
|
(const BYTE*)(in + 1), 63 * 4,
|
|
|
|
(BYTE*) out_sse_inv, format, 63 * 4, 63, 61, 2, TRUE);
|
|
|
|
if (status != PRIMITIVES_SUCCESS)
|
|
|
|
return FALSE;
|
2014-07-03 00:30:04 +04:00
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
for (i = 0; i < 63 * 61; ++i)
|
2014-07-03 00:30:04 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
if (out_c[i] != out_sse[i])
|
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
printf("optimized->YCoCgRToRGB FAIL[%d]: 0x%08x -> C 0x%08x vs optimized 0x%08x\n", i,
|
2016-04-05 18:07:45 +03:00
|
|
|
in[i + 1], out_c[i], out_sse[i]);
|
2016-07-13 15:04:48 +03:00
|
|
|
result = FALSE;
|
2014-07-03 00:30:04 +04:00
|
|
|
}
|
|
|
|
}
|
2016-04-05 18:07:45 +03:00
|
|
|
|
|
|
|
for (i = 0; i < 63 * 61; ++i)
|
2014-07-03 00:30:04 +04:00
|
|
|
{
|
2016-04-05 18:07:45 +03:00
|
|
|
if (out_c_inv[i] != out_sse_inv[i])
|
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
printf("optimized->YCoCgRToRGB inverted FAIL[%d]: 0x%08x -> C 0x%08x vs optimized 0x%08x\n",
|
2016-04-05 18:07:45 +03:00
|
|
|
i,
|
|
|
|
in[i + 1], out_c_inv[i], out_sse_inv[i]);
|
2016-07-13 15:04:48 +03:00
|
|
|
result = FALSE;
|
2014-07-03 00:30:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-13 15:04:48 +03:00
|
|
|
return result;
|
2014-07-03 00:30:04 +04:00
|
|
|
}
|
|
|
|
|
2016-04-05 18:07:45 +03:00
|
|
|
static int test_YCoCgRToRGB_8u_AC4R_speed(void)
|
2014-07-03 00:30:04 +04:00
|
|
|
{
|
|
|
|
INT32 ALIGN(in[4096]);
|
|
|
|
INT32 ALIGN(out[4096]);
|
2016-07-13 15:04:48 +03:00
|
|
|
|
|
|
|
winpr_RAND((BYTE*)in, sizeof(in));
|
|
|
|
|
|
|
|
if (!speed_test("YCoCgToRGB_8u_AC4R", "aligned", g_Iterations,
|
|
|
|
(speed_test_fkt)generic->YCoCgToRGB_8u_AC4R,
|
|
|
|
(speed_test_fkt)optimized->YCoCgToRGB_8u_AC4R,
|
|
|
|
in, 64 * 4, out, 64 * 4, 64, 64, 2, FALSE, FALSE))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
2014-07-03 00:30:04 +04:00
|
|
|
}
|
2014-09-04 23:46:20 +04:00
|
|
|
|
|
|
|
int TestPrimitivesYCoCg(int argc, char* argv[])
|
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
prim_test_setup(FALSE);
|
2014-09-04 23:46:20 +04:00
|
|
|
|
2016-07-13 15:04:48 +03:00
|
|
|
if (!test_YCoCgRToRGB_8u_AC4R_func())
|
2014-09-04 23:46:20 +04:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
if (g_TestPrimitivesPerformance)
|
|
|
|
{
|
2016-07-13 15:04:48 +03:00
|
|
|
if (!test_YCoCgRToRGB_8u_AC4R_speed())
|
2014-09-04 23:46:20 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|