mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #10269 from akallabeth/image_copy_sse
Image copy sse
This commit is contained in:
185
libfreerdp/codec/CMakeLists.txt
Normal file
185
libfreerdp/codec/CMakeLists.txt
Normal file
@@ -0,0 +1,185 @@
|
||||
# codec
|
||||
|
||||
set(CODEC_SRCS
|
||||
bulk.c
|
||||
bulk.h
|
||||
dsp.c
|
||||
color.c
|
||||
color.h
|
||||
audio.c
|
||||
planar.c
|
||||
bitmap.c
|
||||
interleaved.c
|
||||
progressive.c
|
||||
rfx_bitstream.h
|
||||
rfx_constants.h
|
||||
rfx_decode.c
|
||||
rfx_decode.h
|
||||
rfx_differential.h
|
||||
rfx_dwt.c
|
||||
rfx_dwt.h
|
||||
rfx_encode.c
|
||||
rfx_encode.h
|
||||
rfx_quantization.c
|
||||
rfx_quantization.h
|
||||
rfx_rlgr.c
|
||||
rfx_rlgr.h
|
||||
rfx_types.h
|
||||
rfx.c
|
||||
region.c
|
||||
nsc.c
|
||||
nsc_encode.c
|
||||
nsc_encode.h
|
||||
nsc_types.h
|
||||
ncrush.c
|
||||
xcrush.c
|
||||
mppc.c
|
||||
zgfx.c
|
||||
clear.c
|
||||
jpeg.c
|
||||
h264.c
|
||||
yuv.c)
|
||||
|
||||
set(CODEC_SSE2_SRCS
|
||||
sse/rfx_sse2.c
|
||||
sse/rfx_sse2.h
|
||||
sse/nsc_sse2.c
|
||||
sse/nsc_sse2.h
|
||||
)
|
||||
|
||||
set(CODEC_NEON_SRCS
|
||||
neon/rfx_neon.c
|
||||
neon/rfx_neon.h
|
||||
neon/nsc_neon.c
|
||||
neon/nsc_neon.h
|
||||
)
|
||||
|
||||
# Append initializers
|
||||
set(CODEC_LIBS "")
|
||||
list(APPEND CODEC_SRCS ${CODEC_SSE2_SRCS})
|
||||
list(APPEND CODEC_SRCS ${CODEC_NEON_SRCS})
|
||||
|
||||
if(WITH_SSE2)
|
||||
if(CMAKE_COMPILER_IS_GNUCC OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
|
||||
if (CODEC_SSE2_SRCS)
|
||||
set_source_files_properties(${CODEC_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "-msse2" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if (CODEC_SSE2_SRCS)
|
||||
set_source_files_properties(${CODEC_SSE2_SRCS} PROPERTIES COMPILE_FLAGS "/arch:SSE2" )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_NEON)
|
||||
check_symbol_exists("_M_AMD64" "" MSVC_ARM64)
|
||||
check_symbol_exists("__aarch64__" "" ARCH_ARM64)
|
||||
|
||||
if (NOT MSVC_ARM64 AND NOT ARCH_ARM64)
|
||||
if (CODEC_SSE2_SRCS)
|
||||
set_source_files_properties(${CODEC_NEON_SRCS} PROPERTIES COMPILE_FLAGS "-mfpu=neon" )
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (WITH_DSP_FFMPEG)
|
||||
set(CODEC_SRCS
|
||||
${CODEC_SRCS}
|
||||
dsp_ffmpeg.c
|
||||
dsp_ffmpeg.h)
|
||||
include_directories(${FFMPEG_INCLUDE_DIRS})
|
||||
list(APPEND CODEC_LIBS ${FFMPEG_LIBRARIES})
|
||||
endif (WITH_DSP_FFMPEG)
|
||||
|
||||
if (WITH_SOXR)
|
||||
list(APPEND CODEC_LIBS ${SOXR_LIBRARIES})
|
||||
include_directories(${SOXR_INCLUDE_DIR})
|
||||
endif(WITH_SOXR)
|
||||
|
||||
if(GSM_FOUND)
|
||||
list(APPEND CODEC_LIBS ${GSM_LIBRARIES})
|
||||
include_directories(${GSM_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(LAME_FOUND)
|
||||
list(APPEND CODEC_LIBS ${LAME_LIBRARIES})
|
||||
include_directories(${LAME_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
set(OPUS_DEFAULT OFF)
|
||||
if (NOT WITH_DSP_FFMPEG)
|
||||
find_package(Opus)
|
||||
if (Opus_FOUND)
|
||||
set(OPUS_DEFAULT ${OPUS_FOUND})
|
||||
else()
|
||||
find_package(PkgConfig)
|
||||
if (PkgConfig_FOUND)
|
||||
pkg_check_modules(OPUS opus)
|
||||
set(OPUS_DEFAULT ${OPUS_FOUND})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message("Using OPUS: ${OPUS_DEFAULT}")
|
||||
endif()
|
||||
|
||||
option(WITH_OPUS "compile with opus codec support" ${OPUS_DEFAULT})
|
||||
if (WITH_OPUS)
|
||||
find_package(Opus)
|
||||
if (Opus_FOUND)
|
||||
list(APPEND CODEC_LIBS ${OPUS_LIBRARIES})
|
||||
else()
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(OPUS REQUIRED opus)
|
||||
if(OPUS_FOUND)
|
||||
list(APPEND CODEC_LIBS ${OPUS_LIBRARIES})
|
||||
include_directories(${OPUS_INCLUDE_DIRS})
|
||||
link_directories(${OPUS_LIBRARY_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(FAAD2_FOUND)
|
||||
list(APPEND CODEC_LIBS ${FAAD2_LIBRARIES})
|
||||
include_directories(${FAAD2_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(FAAC_FOUND)
|
||||
list(APPEND CODEC_LIBS ${FAAC_LIBRARIES})
|
||||
include_directories(${FAAC_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(WITH_OPENH264)
|
||||
set(CODEC_SRCS ${CODEC_SRCS} h264_openh264.c)
|
||||
include_directories(${OPENH264_INCLUDE_DIR})
|
||||
if (NOT WITH_OPENH264_LOADING)
|
||||
list(APPEND CODEC_LIBS ${OPENH264_LIBRARIES})
|
||||
endif (NOT WITH_OPENH264_LOADING)
|
||||
endif()
|
||||
|
||||
if(WITH_VIDEO_FFMPEG)
|
||||
set(CODEC_SRCS ${CODEC_SRCS} h264_ffmpeg.c)
|
||||
include_directories(${FFMPEG_INCLUDE_DIRS})
|
||||
list(APPEND CODEC_LIBS ${FFMPEG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32 AND WITH_MEDIA_FOUNDATION)
|
||||
set(CODEC_SRCS ${CODEC_SRCS} h264_mf.c)
|
||||
endif()
|
||||
|
||||
if(ANDROID AND WITH_MEDIACODEC)
|
||||
list(APPEND CODEC_SRCS h264_mediacodec.c)
|
||||
|
||||
find_library(MEDIACODEC mediandk REQUIRED)
|
||||
list(APPEND CODEC_LIBS ${MEDIACODEC})
|
||||
endif()
|
||||
|
||||
add_library(freerdp-codecs OBJECT
|
||||
${CODEC_SRCS}
|
||||
)
|
||||
freerdp_library_add(${CODEC_LIBS})
|
||||
freerdp_object_library_add(freerdp-codecs)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
@@ -39,17 +39,9 @@
|
||||
#include <libswscale/swscale.h>
|
||||
#endif
|
||||
|
||||
#define TAG FREERDP_TAG("color")
|
||||
#include "color.h"
|
||||
|
||||
static INLINE BOOL FreeRDPWriteColorIgnoreAlpha_int(BYTE* WINPR_RESTRICT dst, UINT32 format,
|
||||
UINT32 color);
|
||||
static INLINE BOOL FreeRDPWriteColor_int(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT32 color);
|
||||
static INLINE UINT32 FreeRDPReadColor_int(const BYTE* WINPR_RESTRICT src, UINT32 format);
|
||||
static INLINE DWORD FreeRDPAreColorFormatsEqualNoAlpha_int(DWORD first, DWORD second)
|
||||
{
|
||||
const DWORD mask = (DWORD) ~(8UL << 12UL);
|
||||
return (first & mask) == (second & mask);
|
||||
}
|
||||
#define TAG FREERDP_TAG("color")
|
||||
|
||||
BYTE* freerdp_glyph_convert(UINT32 width, UINT32 height, const BYTE* WINPR_RESTRICT data)
|
||||
{
|
||||
@@ -733,102 +725,6 @@ static INLINE BOOL freerdp_image_copy_no_overlap_dst_alpha(
|
||||
srcVMultiplier, srcVOffset, dstVMultiplier, dstVOffset);
|
||||
}
|
||||
|
||||
BOOL freerdp_image_copy_no_overlap(BYTE* WINPR_RESTRICT pDstData, DWORD DstFormat, UINT32 nDstStep,
|
||||
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
|
||||
const BYTE* WINPR_RESTRICT pSrcData, DWORD SrcFormat,
|
||||
UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
|
||||
const gdiPalette* WINPR_RESTRICT palette, UINT32 flags)
|
||||
{
|
||||
const SSIZE_T dstByte = FreeRDPGetBytesPerPixel(DstFormat);
|
||||
const SSIZE_T srcByte = FreeRDPGetBytesPerPixel(SrcFormat);
|
||||
const SSIZE_T copyDstWidth = nWidth * dstByte;
|
||||
const SSIZE_T xSrcOffset = nXSrc * srcByte;
|
||||
const SSIZE_T xDstOffset = nXDst * dstByte;
|
||||
const BOOL vSrcVFlip = (flags & FREERDP_FLIP_VERTICAL) ? TRUE : FALSE;
|
||||
SSIZE_T srcVOffset = 0;
|
||||
SSIZE_T srcVMultiplier = 1;
|
||||
SSIZE_T dstVOffset = 0;
|
||||
SSIZE_T dstVMultiplier = 1;
|
||||
|
||||
if ((nWidth == 0) || (nHeight == 0))
|
||||
return TRUE;
|
||||
|
||||
if ((nHeight > INT32_MAX) || (nWidth > INT32_MAX))
|
||||
return FALSE;
|
||||
|
||||
if (!pDstData || !pSrcData)
|
||||
return FALSE;
|
||||
|
||||
if (nDstStep == 0)
|
||||
nDstStep = nWidth * FreeRDPGetBytesPerPixel(DstFormat);
|
||||
|
||||
if (nSrcStep == 0)
|
||||
nSrcStep = nWidth * FreeRDPGetBytesPerPixel(SrcFormat);
|
||||
|
||||
if (vSrcVFlip)
|
||||
{
|
||||
srcVOffset = (nHeight - 1ll) * nSrcStep;
|
||||
srcVMultiplier = -1;
|
||||
}
|
||||
|
||||
if (((flags & FREERDP_KEEP_DST_ALPHA) != 0) && FreeRDPColorHasAlpha(DstFormat))
|
||||
return freerdp_image_copy_no_overlap_dst_alpha(
|
||||
pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight, pSrcData, SrcFormat,
|
||||
nSrcStep, nXSrc, nYSrc, palette, srcVMultiplier, srcVOffset, dstVMultiplier,
|
||||
dstVOffset);
|
||||
else if (FreeRDPAreColorFormatsEqualNoAlpha_int(SrcFormat, DstFormat))
|
||||
{
|
||||
if (!vSrcVFlip && (nDstStep == nSrcStep) && (xSrcOffset == 0) && (xDstOffset == 0))
|
||||
{
|
||||
const void* src = &pSrcData[1ull * nYSrc * nSrcStep];
|
||||
void* dst = &pDstData[1ull * nYDst * nDstStep];
|
||||
memcpy(dst, src, 1ull * nDstStep * nHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SSIZE_T y = 0; y < nHeight; y++)
|
||||
{
|
||||
const BYTE* WINPR_RESTRICT srcLine =
|
||||
&pSrcData[srcVMultiplier * (y + nYSrc) * nSrcStep + srcVOffset];
|
||||
BYTE* WINPR_RESTRICT dstLine =
|
||||
&pDstData[dstVMultiplier * (y + nYDst) * nDstStep + dstVOffset];
|
||||
memcpy(&dstLine[xDstOffset], &srcLine[xSrcOffset], copyDstWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (SSIZE_T y = 0; y < nHeight; y++)
|
||||
{
|
||||
const BYTE* WINPR_RESTRICT srcLine =
|
||||
&pSrcData[srcVMultiplier * (y + nYSrc) * nSrcStep + srcVOffset];
|
||||
BYTE* WINPR_RESTRICT dstLine =
|
||||
&pDstData[dstVMultiplier * (y + nYDst) * nDstStep + dstVOffset];
|
||||
|
||||
UINT32 color = FreeRDPReadColor_int(&srcLine[nXSrc * srcByte], SrcFormat);
|
||||
UINT32 oldColor = color;
|
||||
UINT32 dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette);
|
||||
FreeRDPWriteColor_int(&dstLine[nXDst * dstByte], DstFormat, dstColor);
|
||||
for (SSIZE_T x = 1; x < nWidth; x++)
|
||||
{
|
||||
color = FreeRDPReadColor_int(&srcLine[(x + nXSrc) * srcByte], SrcFormat);
|
||||
if (color == oldColor)
|
||||
{
|
||||
FreeRDPWriteColor_int(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
oldColor = color;
|
||||
dstColor = FreeRDPConvertColor(color, SrcFormat, DstFormat, palette);
|
||||
FreeRDPWriteColor_int(&dstLine[(x + nXDst) * dstByte], DstFormat, dstColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_image_copy_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32 nXDst,
|
||||
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, const BYTE* pSrcData,
|
||||
DWORD SrcFormat, UINT32 nSrcStep, UINT32 nXSrc, UINT32 nYSrc,
|
||||
@@ -1608,124 +1504,16 @@ BOOL FreeRDPWriteColorIgnoreAlpha(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT3
|
||||
return FreeRDPWriteColorIgnoreAlpha_int(dst, format, color);
|
||||
}
|
||||
|
||||
BOOL FreeRDPWriteColorIgnoreAlpha_int(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT32 color)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case PIXEL_FORMAT_XBGR32:
|
||||
case PIXEL_FORMAT_XRGB32:
|
||||
case PIXEL_FORMAT_ABGR32:
|
||||
case PIXEL_FORMAT_ARGB32:
|
||||
{
|
||||
const UINT32 tmp = ((UINT32)dst[0] << 24ULL) | (color & 0x00FFFFFFULL);
|
||||
return FreeRDPWriteColor_int(dst, format, tmp);
|
||||
}
|
||||
case PIXEL_FORMAT_BGRX32:
|
||||
case PIXEL_FORMAT_RGBX32:
|
||||
case PIXEL_FORMAT_BGRA32:
|
||||
case PIXEL_FORMAT_RGBA32:
|
||||
{
|
||||
const UINT32 tmp = ((UINT32)dst[3]) | (color & 0xFFFFFF00ULL);
|
||||
return FreeRDPWriteColor_int(dst, format, tmp);
|
||||
}
|
||||
default:
|
||||
return FreeRDPWriteColor_int(dst, format, color);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL FreeRDPWriteColor(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT32 color)
|
||||
{
|
||||
return FreeRDPWriteColor_int(dst, format, color);
|
||||
}
|
||||
BOOL FreeRDPWriteColor_int(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT32 color)
|
||||
{
|
||||
switch (FreeRDPGetBitsPerPixel(format))
|
||||
{
|
||||
case 32:
|
||||
dst[0] = (BYTE)(color >> 24);
|
||||
dst[1] = (BYTE)(color >> 16);
|
||||
dst[2] = (BYTE)(color >> 8);
|
||||
dst[3] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
dst[0] = (BYTE)(color >> 16);
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[2] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (!FreeRDPColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
UINT32 FreeRDPReadColor(const BYTE* WINPR_RESTRICT src, UINT32 format)
|
||||
{
|
||||
return FreeRDPReadColor_int(src, format);
|
||||
}
|
||||
|
||||
UINT32 FreeRDPReadColor_int(const BYTE* WINPR_RESTRICT src, UINT32 format)
|
||||
{
|
||||
UINT32 color = 0;
|
||||
|
||||
switch (FreeRDPGetBitsPerPixel(format))
|
||||
{
|
||||
case 32:
|
||||
color =
|
||||
((UINT32)src[0] << 24) | ((UINT32)src[1] << 16) | ((UINT32)src[2] << 8) | src[3];
|
||||
break;
|
||||
|
||||
case 24:
|
||||
color = ((UINT32)src[0] << 16) | ((UINT32)src[1] << 8) | src[2];
|
||||
break;
|
||||
|
||||
case 16:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
break;
|
||||
|
||||
case 15:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
|
||||
if (!FreeRDPColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 4:
|
||||
case 1:
|
||||
color = *src;
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
|
||||
color = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
UINT32 FreeRDPGetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a)
|
||||
{
|
||||
UINT32 _r = r;
|
||||
@@ -1817,3 +1605,20 @@ UINT32 FreeRDPGetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL freerdp_image_copy_no_overlap(BYTE* pDstData, DWORD DstFormat, UINT32 nDstStep, UINT32 nXDst,
|
||||
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight,
|
||||
const BYTE* pSrcData, DWORD SrcFormat, UINT32 nSrcStep,
|
||||
UINT32 nXSrc, UINT32 nYSrc, const gdiPalette* palette,
|
||||
UINT32 flags)
|
||||
{
|
||||
static primitives_t* prims = NULL;
|
||||
if (!prims)
|
||||
prims = primitives_get();
|
||||
|
||||
WINPR_ASSERT(prims);
|
||||
WINPR_ASSERT(prims->copy_no_overlap);
|
||||
return prims->copy_no_overlap(pDstData, DstFormat, nDstStep, nXDst, nYDst, nWidth, nHeight,
|
||||
pSrcData, SrcFormat, nSrcStep, nXSrc, nYSrc, palette,
|
||||
flags) == PRIMITIVES_SUCCESS;
|
||||
}
|
||||
|
||||
147
libfreerdp/codec/color.h
Normal file
147
libfreerdp/codec/color.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* codec color
|
||||
*
|
||||
* Copyright 2024 Armin Novak <anovak@thincast.com>
|
||||
* Copyright 2024 Thincast Technologies GmbH
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef FREERDP_LIB_CODEC_COLOR_H
|
||||
#define FREERDP_LIB_CODEC_COLOR_H
|
||||
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#include <freerdp/codec/color.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#define INT_COLOR_TAG FREERDP_TAG("codec.color.h")
|
||||
|
||||
static INLINE DWORD FreeRDPAreColorFormatsEqualNoAlpha_int(DWORD first, DWORD second)
|
||||
{
|
||||
const DWORD mask = (DWORD) ~(8UL << 12UL);
|
||||
return (first & mask) == (second & mask);
|
||||
}
|
||||
|
||||
static INLINE BOOL FreeRDPWriteColor_int(BYTE* WINPR_RESTRICT dst, UINT32 format, UINT32 color)
|
||||
{
|
||||
switch (FreeRDPGetBitsPerPixel(format))
|
||||
{
|
||||
case 32:
|
||||
dst[0] = (BYTE)(color >> 24);
|
||||
dst[1] = (BYTE)(color >> 16);
|
||||
dst[2] = (BYTE)(color >> 8);
|
||||
dst[3] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
dst[0] = (BYTE)(color >> 16);
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[2] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
if (!FreeRDPColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
dst[1] = (BYTE)(color >> 8);
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
dst[0] = (BYTE)color;
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(INT_COLOR_TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static INLINE BOOL FreeRDPWriteColorIgnoreAlpha_int(BYTE* WINPR_RESTRICT dst, UINT32 format,
|
||||
UINT32 color)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case PIXEL_FORMAT_XBGR32:
|
||||
case PIXEL_FORMAT_XRGB32:
|
||||
case PIXEL_FORMAT_ABGR32:
|
||||
case PIXEL_FORMAT_ARGB32:
|
||||
{
|
||||
const UINT32 tmp = ((UINT32)dst[0] << 24ULL) | (color & 0x00FFFFFFULL);
|
||||
return FreeRDPWriteColor_int(dst, format, tmp);
|
||||
}
|
||||
case PIXEL_FORMAT_BGRX32:
|
||||
case PIXEL_FORMAT_RGBX32:
|
||||
case PIXEL_FORMAT_BGRA32:
|
||||
case PIXEL_FORMAT_RGBA32:
|
||||
{
|
||||
const UINT32 tmp = ((UINT32)dst[3]) | (color & 0xFFFFFF00ULL);
|
||||
return FreeRDPWriteColor_int(dst, format, tmp);
|
||||
}
|
||||
default:
|
||||
return FreeRDPWriteColor_int(dst, format, color);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE UINT32 FreeRDPReadColor_int(const BYTE* WINPR_RESTRICT src, UINT32 format)
|
||||
{
|
||||
UINT32 color = 0;
|
||||
|
||||
switch (FreeRDPGetBitsPerPixel(format))
|
||||
{
|
||||
case 32:
|
||||
color =
|
||||
((UINT32)src[0] << 24) | ((UINT32)src[1] << 16) | ((UINT32)src[2] << 8) | src[3];
|
||||
break;
|
||||
|
||||
case 24:
|
||||
color = ((UINT32)src[0] << 16) | ((UINT32)src[1] << 8) | src[2];
|
||||
break;
|
||||
|
||||
case 16:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
break;
|
||||
|
||||
case 15:
|
||||
color = ((UINT32)src[1] << 8) | src[0];
|
||||
|
||||
if (!FreeRDPColorHasAlpha(format))
|
||||
color = color & 0x7FFF;
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 4:
|
||||
case 1:
|
||||
color = *src;
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(INT_COLOR_TAG, "Unsupported format %s", FreeRDPGetColorFormatName(format));
|
||||
color = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
#endif
|
||||
38
libfreerdp/codec/neon/nsc_neon.c
Normal file
38
libfreerdp/codec/neon/nsc_neon.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NSCodec Library - SSE2 Optimizations
|
||||
*
|
||||
* Copyright 2024 Armin Novak <anovak@thincast.com>
|
||||
* Copyright 2024 Thincast Technologies GmbH
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <winpr/sysinfo.h>
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include "../nsc_types.h"
|
||||
#include "nsc_neon.h"
|
||||
|
||||
#define TAG FREERDP_TAG("codec.nsc.neon")
|
||||
|
||||
void nsc_init_neon(NSC_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_NEON)
|
||||
if (!IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
WLog_WARN(TAG, "TODO: Implement neon optimized version of this function");
|
||||
#endif
|
||||
}
|
||||
28
libfreerdp/codec/neon/nsc_neon.h
Normal file
28
libfreerdp/codec/neon/nsc_neon.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* FreeRDP: A Remote Desktop Protocol Implementation
|
||||
* NSCodec Library - NEON Optimizations
|
||||
*
|
||||
* Copyright 2012 Vic Lee
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef FREERDP_LIB_CODEC_NSC_NEON_H
|
||||
#define FREERDP_LIB_CODEC_NSC_NEON_H
|
||||
|
||||
#include <freerdp/codec/nsc.h>
|
||||
#include <freerdp/api.h>
|
||||
|
||||
FREERDP_LOCAL void nsc_init_neon(NSC_CONTEXT* context);
|
||||
|
||||
#endif /* FREERDP_LIB_CODEC_NSC_NEON_H */
|
||||
@@ -18,6 +18,12 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include "../rfx_types.h"
|
||||
#include "rfx_neon.h"
|
||||
|
||||
#define TAG FREERDP_TAG("codec.rfx.neon")
|
||||
|
||||
#if defined(WITH_NEON)
|
||||
|
||||
@@ -27,9 +33,6 @@
|
||||
#include <arm_neon.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#include "rfx_types.h"
|
||||
#include "rfx_neon.h"
|
||||
|
||||
/* rfx_decode_YCbCr_to_RGB_NEON code now resides in the primitives library. */
|
||||
|
||||
static __inline void __attribute__((__gnu_inline__, __always_inline__, __artificial__))
|
||||
@@ -517,9 +520,11 @@ static void rfx_dwt_2d_extrapolate_decode_neon(INT16* buffer, INT16* temp)
|
||||
rfx_dwt_2d_decode_extrapolate_block_neon(&buffer[3007], temp, 2);
|
||||
rfx_dwt_2d_decode_extrapolate_block_neon(&buffer[0], temp, 1);
|
||||
}
|
||||
#endif // WITH_NEON
|
||||
|
||||
void rfx_init_neon(RFX_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_NEON)
|
||||
if (IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE))
|
||||
{
|
||||
DEBUG_RFX("Using NEON optimizations");
|
||||
@@ -531,6 +536,7 @@ void rfx_init_neon(RFX_CONTEXT* context)
|
||||
context->dwt_2d_decode = rfx_dwt_2d_decode_NEON;
|
||||
context->dwt_2d_extrapolate_decode = rfx_dwt_2d_extrapolate_decode_neon;
|
||||
}
|
||||
#else
|
||||
WINPR_UNUSED(context);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // WITH_NEON
|
||||
@@ -25,10 +25,4 @@
|
||||
|
||||
FREERDP_LOCAL void rfx_init_neon(RFX_CONTEXT* context);
|
||||
|
||||
#ifndef RFX_INIT_SIMD
|
||||
#if defined(WITH_NEON)
|
||||
#define RFX_INIT_SIMD(_rfx_context) rfx_init_neon(_rfx_context)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_LIB_CODEC_RFX_NEON_H */
|
||||
@@ -34,7 +34,8 @@
|
||||
#include "nsc_types.h"
|
||||
#include "nsc_encode.h"
|
||||
|
||||
#include "nsc_sse2.h"
|
||||
#include "sse/nsc_sse2.h"
|
||||
#include "neon/nsc_neon.h"
|
||||
|
||||
#include <freerdp/log.h>
|
||||
#define TAG FREERDP_TAG("codec.nsc")
|
||||
@@ -368,7 +369,8 @@ NSC_CONTEXT* nsc_context_new(void)
|
||||
context->ColorLossLevel = 3;
|
||||
context->ChromaSubsamplingLevel = 1;
|
||||
/* init optimized methods */
|
||||
NSC_INIT_SIMD(context);
|
||||
nsc_init_sse2(context);
|
||||
nsc_init_neon(context);
|
||||
return context;
|
||||
error:
|
||||
WINPR_PRAGMA_DIAG_PUSH
|
||||
|
||||
@@ -47,18 +47,11 @@
|
||||
#include "rfx_dwt.h"
|
||||
#include "rfx_rlgr.h"
|
||||
|
||||
#include "rfx_sse2.h"
|
||||
#include "rfx_neon.h"
|
||||
#include "sse/rfx_sse2.h"
|
||||
#include "neon/rfx_neon.h"
|
||||
|
||||
#define TAG FREERDP_TAG("codec")
|
||||
|
||||
#ifndef RFX_INIT_SIMD
|
||||
#define RFX_INIT_SIMD(_rfx_context) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define RFX_KEY "Software\\" FREERDP_VENDOR_STRING "\\" FREERDP_PRODUCT_STRING "\\RemoteFX"
|
||||
|
||||
/**
|
||||
@@ -338,7 +331,8 @@ RFX_CONTEXT* rfx_context_new_ex(BOOL encoder, UINT32 ThreadingFlags)
|
||||
context->dwt_2d_encode = rfx_dwt_2d_encode;
|
||||
context->rlgr_decode = rfx_rlgr_decode;
|
||||
context->rlgr_encode = rfx_rlgr_encode;
|
||||
RFX_INIT_SIMD(context);
|
||||
rfx_init_sse2(context);
|
||||
rfx_init_neon(context);
|
||||
context->state = RFX_STATE_SEND_HEADERS;
|
||||
context->expectedDataBlockType = WBT_FRAME_BEGIN;
|
||||
return context;
|
||||
|
||||
@@ -18,7 +18,14 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include "../nsc_types.h"
|
||||
#include "nsc_sse2.h"
|
||||
|
||||
#define TAG FREERDP_TAG("codec.nsc.sse2")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -30,9 +37,6 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/sysinfo.h>
|
||||
|
||||
#include "nsc_types.h"
|
||||
#include "nsc_sse2.h"
|
||||
|
||||
static BOOL nsc_encode_argb_to_aycocg_sse2(NSC_CONTEXT* context, const BYTE* data, UINT32 scanline)
|
||||
{
|
||||
UINT16 y = 0;
|
||||
@@ -373,12 +377,17 @@ static BOOL nsc_encode_sse2(NSC_CONTEXT* context, const BYTE* data, UINT32 scanl
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void nsc_init_sse2(NSC_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
PROFILER_RENAME(context->priv->prof_nsc_encode, "nsc_encode_sse2")
|
||||
context->encode = nsc_encode_sse2;
|
||||
#else
|
||||
WINPR_UNUSED(context);
|
||||
#endif
|
||||
}
|
||||
@@ -25,10 +25,4 @@
|
||||
|
||||
FREERDP_LOCAL void nsc_init_sse2(NSC_CONTEXT* context);
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#ifndef NSC_INIT_SIMD
|
||||
#define NSC_INIT_SIMD(_context) nsc_init_sse2(_context)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_LIB_CODEC_NSC_SSE2_H */
|
||||
@@ -19,7 +19,14 @@
|
||||
*/
|
||||
|
||||
#include <freerdp/config.h>
|
||||
#include <freerdp/log.h>
|
||||
|
||||
#include "../rfx_types.h"
|
||||
#include "rfx_sse2.h"
|
||||
|
||||
#define TAG FREERDP_TAG("codec.rfx.sse2")
|
||||
|
||||
#if defined(WITH_SSE2)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -28,9 +35,6 @@
|
||||
#include <xmmintrin.h>
|
||||
#include <emmintrin.h>
|
||||
|
||||
#include "rfx_types.h"
|
||||
#include "rfx_sse2.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __attribute__(...)
|
||||
#endif
|
||||
@@ -477,9 +481,11 @@ static void rfx_dwt_2d_encode_sse2(INT16* WINPR_RESTRICT buffer, INT16* WINPR_RE
|
||||
rfx_dwt_2d_encode_block_sse2(buffer + 3072, dwt_buffer, 16);
|
||||
rfx_dwt_2d_encode_block_sse2(buffer + 3840, dwt_buffer, 8);
|
||||
}
|
||||
#endif
|
||||
|
||||
void rfx_init_sse2(RFX_CONTEXT* context)
|
||||
{
|
||||
#if defined(WITH_SSE2)
|
||||
if (!IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
|
||||
return;
|
||||
|
||||
@@ -491,4 +497,7 @@ void rfx_init_sse2(RFX_CONTEXT* context)
|
||||
context->quantization_encode = rfx_quantization_encode_sse2;
|
||||
context->dwt_2d_decode = rfx_dwt_2d_decode_sse2;
|
||||
context->dwt_2d_encode = rfx_dwt_2d_encode_sse2;
|
||||
#else
|
||||
WINPR_UNUSED(context);
|
||||
#endif
|
||||
}
|
||||
@@ -25,10 +25,4 @@
|
||||
|
||||
FREERDP_LOCAL void rfx_init_sse2(RFX_CONTEXT* context);
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
#ifndef RFX_INIT_SIMD
|
||||
#define RFX_INIT_SIMD(_rfx_context) rfx_init_sse2(_rfx_context)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* FREERDP_LIB_CODEC_RFX_SSE2_H */
|
||||
Reference in New Issue
Block a user