|
Packit |
1fb8d4 |
/* test_YCoCg.c
|
|
Packit |
1fb8d4 |
* vi:ts=4 sw=4
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
Packit |
1fb8d4 |
* you may not use this file except in compliance with the License.
|
|
Packit |
1fb8d4 |
* You may obtain a copy of the License at
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
Packit |
1fb8d4 |
*
|
|
Packit |
1fb8d4 |
* Unless required by applicable law or agreed to in writing, software
|
|
Packit |
1fb8d4 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
Packit |
1fb8d4 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
Packit |
1fb8d4 |
* See the License for the specific language governing permissions and
|
|
Packit |
1fb8d4 |
* limitations under the License.
|
|
Packit |
1fb8d4 |
*/
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
#ifdef HAVE_CONFIG_H
|
|
Packit |
1fb8d4 |
#include "config.h"
|
|
Packit |
1fb8d4 |
#endif
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
#include <winpr/sysinfo.h>
|
|
Packit |
1fb8d4 |
#include "prim_test.h"
|
|
Packit |
1fb8d4 |
#include <freerdp/utils/profiler.h>
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
/* ------------------------------------------------------------------------- */
|
|
Packit |
1fb8d4 |
static BOOL test_YCoCgRToRGB_8u_AC4R_func(UINT32 width, UINT32 height)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
pstatus_t status = -1;
|
|
Packit |
1fb8d4 |
BYTE* out_sse = NULL;
|
|
Packit |
1fb8d4 |
BYTE* in = NULL;
|
|
Packit |
1fb8d4 |
BYTE* out_c = NULL;
|
|
Packit |
1fb8d4 |
UINT32 i, x;
|
|
Packit |
1fb8d4 |
const UINT32 srcStride = width * 4;
|
|
Packit |
1fb8d4 |
const UINT32 size = srcStride * height;
|
|
Packit Service |
5a9772 |
const UINT32 formats[] = { PIXEL_FORMAT_ARGB32, PIXEL_FORMAT_ABGR32, PIXEL_FORMAT_RGBA32,
|
|
Packit Service |
5a9772 |
PIXEL_FORMAT_RGBX32, PIXEL_FORMAT_BGRA32, PIXEL_FORMAT_BGRX32 };
|
|
Packit |
1fb8d4 |
PROFILER_DEFINE(genericProf)
|
|
Packit |
1fb8d4 |
PROFILER_DEFINE(optProf)
|
|
Packit |
1fb8d4 |
in = _aligned_malloc(size, 16);
|
|
Packit |
1fb8d4 |
out_c = _aligned_malloc(size, 16);
|
|
Packit |
1fb8d4 |
out_sse = _aligned_malloc(size, 16);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (!in || !out_c || !out_sse)
|
|
Packit |
1fb8d4 |
goto fail;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
winpr_RAND(in, size);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
for (x = 0; x < sizeof(formats) / sizeof(formats[0]); x++)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
const UINT32 format = formats[x];
|
|
Packit |
1fb8d4 |
const UINT32 dstStride = width * GetBytesPerPixel(format);
|
|
Packit |
1fb8d4 |
const char* formatName = FreeRDPGetColorFormatName(format);
|
|
Packit |
1fb8d4 |
PROFILER_CREATE(genericProf, "YCoCgRToRGB_8u_AC4R-GENERIC")
|
|
Packit |
1fb8d4 |
PROFILER_CREATE(optProf, "YCoCgRToRGB_8u_AC4R-OPT")
|
|
Packit |
1fb8d4 |
PROFILER_ENTER(genericProf)
|
|
Packit Service |
5a9772 |
status = generic->YCoCgToRGB_8u_AC4R(in, srcStride, out_c, format, dstStride, width, height,
|
|
Packit Service |
5a9772 |
2, TRUE);
|
|
Packit |
1fb8d4 |
PROFILER_EXIT(genericProf)
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (status != PRIMITIVES_SUCCESS)
|
|
Packit |
1fb8d4 |
goto loop_fail;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
PROFILER_ENTER(optProf)
|
|
Packit Service |
5a9772 |
status = optimized->YCoCgToRGB_8u_AC4R(in, srcStride, out_sse, format, dstStride, width,
|
|
Packit Service |
5a9772 |
height, 2, TRUE);
|
|
Packit |
1fb8d4 |
PROFILER_EXIT(optProf)
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (status != PRIMITIVES_SUCCESS)
|
|
Packit |
1fb8d4 |
goto loop_fail;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (memcmp(out_c, out_sse, dstStride * height) != 0)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
for (i = 0; i < width * height; ++i)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
const UINT32 c = ReadColor(out_c + 4 * i, format);
|
|
Packit |
1fb8d4 |
const UINT32 sse = ReadColor(out_sse + 4 * i, format);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (c != sse)
|
|
Packit |
1fb8d4 |
{
|
|
Packit Service |
5a9772 |
printf("optimized->YCoCgRToRGB FAIL[%s] [%" PRIu32 "]: 0x%08" PRIx32
|
|
Packit Service |
5a9772 |
" -> C 0x%08" PRIx32 " vs optimized 0x%08" PRIx32 "\n",
|
|
Packit |
1fb8d4 |
formatName, i, in[i + 1], c, sse);
|
|
Packit |
1fb8d4 |
status = -1;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit Service |
5a9772 |
printf("--------------------------- [%s] [%" PRIu32 "x%" PRIu32
|
|
Packit Service |
5a9772 |
"] ---------------------------\n",
|
|
Packit |
1fb8d4 |
formatName, width, height);
|
|
Packit |
1fb8d4 |
PROFILER_PRINT_HEADER
|
|
Packit |
1fb8d4 |
PROFILER_PRINT(genericProf)
|
|
Packit |
1fb8d4 |
PROFILER_PRINT(optProf)
|
|
Packit |
1fb8d4 |
PROFILER_PRINT_FOOTER
|
|
Packit |
1fb8d4 |
loop_fail:
|
|
Packit |
1fb8d4 |
PROFILER_FREE(genericProf)
|
|
Packit |
1fb8d4 |
PROFILER_FREE(optProf)
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (status != PRIMITIVES_SUCCESS)
|
|
Packit |
1fb8d4 |
goto fail;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
fail:
|
|
Packit |
1fb8d4 |
_aligned_free(in);
|
|
Packit |
1fb8d4 |
_aligned_free(out_c);
|
|
Packit |
1fb8d4 |
_aligned_free(out_sse);
|
|
Packit |
1fb8d4 |
return status == PRIMITIVES_SUCCESS;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
int TestPrimitivesYCoCg(int argc, char* argv[])
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
prim_test_setup(FALSE);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
/* Random resolution tests */
|
|
Packit |
1fb8d4 |
if (argc < 2)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
UINT32 x;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
for (x = 0; x < 10; x++)
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
UINT32 w, h;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
do
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
winpr_RAND((BYTE*)&w, sizeof(w));
|
|
Packit |
1fb8d4 |
w %= 2048;
|
|
Packit Service |
5a9772 |
} while (w < 16);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
do
|
|
Packit |
1fb8d4 |
{
|
|
Packit |
1fb8d4 |
winpr_RAND((BYTE*)&h, sizeof(h));
|
|
Packit |
1fb8d4 |
h %= 2048;
|
|
Packit Service |
5a9772 |
} while (h < 16);
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
if (!test_YCoCgRToRGB_8u_AC4R_func(w, h))
|
|
Packit |
1fb8d4 |
return 1;
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
}
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
/* Test once with full HD */
|
|
Packit |
1fb8d4 |
if (!test_YCoCgRToRGB_8u_AC4R_func(1920, 1080))
|
|
Packit |
1fb8d4 |
return 1;
|
|
Packit |
1fb8d4 |
|
|
Packit |
1fb8d4 |
return 0;
|
|
Packit |
1fb8d4 |
}
|