mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
@@ -34,12 +34,14 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// parameter types available to change in a \ref NSC_CONTEXT See [MS-RDPNSC] 2.2.1 NSCodec
|
||||
/// Capability Set (TS_NSCODEC_CAPABILITYSET) for details
|
||||
typedef enum
|
||||
{
|
||||
NSC_COLOR_LOSS_LEVEL,
|
||||
NSC_ALLOW_SUBSAMPLING,
|
||||
NSC_DYNAMIC_COLOR_FIDELITY,
|
||||
NSC_COLOR_FORMAT
|
||||
NSC_COLOR_LOSS_LEVEL, /**< \b colorLossLevel */
|
||||
NSC_ALLOW_SUBSAMPLING, /**< \b fAllowSubsampling */
|
||||
NSC_DYNAMIC_COLOR_FIDELITY, /**< \b fAllowDynamicFidelity */
|
||||
NSC_COLOR_FORMAT /**< \ref PIXEL_FORMAT color format used for internal bitmap buffer */
|
||||
} NSC_PARAMETER;
|
||||
|
||||
typedef struct S_NSC_CONTEXT NSC_CONTEXT;
|
||||
@@ -50,12 +52,20 @@ extern "C"
|
||||
UINT32 pixel_format));
|
||||
#endif
|
||||
|
||||
/** @brief Set a \ref NSC_PARAMETER for a \ref NSC_CONTEXT
|
||||
*
|
||||
* @param context The \ref NSC_CONTEXT context to work on. Must not be \b NULL
|
||||
* @param what A \ref NSC_PARAMETER to identify what to change
|
||||
* @param value The value to set
|
||||
*
|
||||
* @return \b TRUE if successful, \b FALSE otherwise
|
||||
*/
|
||||
FREERDP_API BOOL nsc_context_set_parameters(NSC_CONTEXT* WINPR_RESTRICT context,
|
||||
NSC_PARAMETER what, UINT32 value);
|
||||
|
||||
/** @brief decode a NSC message
|
||||
*
|
||||
* @param context The context to work on
|
||||
* @param context The \ref NSC_CONTEXT context to work on. Must not be \b NULL
|
||||
* @param bpp The bit depth of the data
|
||||
* @param width The width in pixels of the NSC surface
|
||||
* @param height The height in pixels of the NSC surface
|
||||
@@ -80,15 +90,42 @@ extern "C"
|
||||
UINT32 DstFormat, UINT32 nDstStride, UINT32 nXDst,
|
||||
UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 flip);
|
||||
|
||||
/** @brief Encode a bitmap with \b NSC
|
||||
*
|
||||
* @param context The \ref NSC_CONTEXT context to work on. Must not be \b NULL
|
||||
* @param s a \ref wStream used to write \b NSC encoded data to. Must not be \b NULL
|
||||
* @param bmpdata A pointer to the bitmap to encode. Format must match \b NSC_COLOR_FORMAT
|
||||
* @param width The width of the bitmap in pixels
|
||||
* @param height The height of the bitmap in pixels
|
||||
* @param scanline The stride of a bitmap line in bytes. If \b 0 the value of \b width * bytes
|
||||
* \b NSC_COLOR_FORMAT is used.
|
||||
*
|
||||
* @bug Versions < 3.23.0 do not support \b 0 for scanlines and abort.
|
||||
*/
|
||||
FREERDP_API BOOL nsc_compose_message(NSC_CONTEXT* WINPR_RESTRICT context,
|
||||
wStream* WINPR_RESTRICT s,
|
||||
const BYTE* WINPR_RESTRICT bmpdata, UINT32 width,
|
||||
UINT32 height, UINT32 rowstride);
|
||||
FREERDP_API BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context,
|
||||
wStream* WINPR_RESTRICT s, BYTE* WINPR_RESTRICT bmpdata,
|
||||
UINT32 x, UINT32 y, UINT32 width, UINT32 height,
|
||||
UINT32 rowstride, UINT32 format, UINT32 flip);
|
||||
UINT32 height, UINT32 scanline);
|
||||
|
||||
#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
|
||||
|
||||
WINPR_DEPRECATED_VAR(
|
||||
"[since 3.23.0] deprecated, insecure! missing length checks. use nsc_process_message",
|
||||
FREERDP_API BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context,
|
||||
wStream* WINPR_RESTRICT s,
|
||||
BYTE* WINPR_RESTRICT bmpdata, UINT32 x, UINT32 y,
|
||||
UINT32 width, UINT32 height, UINT32 rowstride,
|
||||
UINT32 format, UINT32 flip));
|
||||
#endif
|
||||
|
||||
/** @brief This function resets a \ref NSC_CONTEXT to a new resolution
|
||||
*
|
||||
* @param context The \ref NSC_CONTEXT context to work on. Must not be \b NULL
|
||||
* @param width The width of the context in pixels
|
||||
* @param height The height of the context in pixels
|
||||
*
|
||||
* @return \b TRUE if successful, \b FALSE otherwise
|
||||
*/
|
||||
FREERDP_API BOOL nsc_context_reset(NSC_CONTEXT* WINPR_RESTRICT context, UINT32 width,
|
||||
UINT32 height);
|
||||
|
||||
|
||||
@@ -133,7 +133,8 @@ static BOOL convert_color(BYTE* WINPR_RESTRICT dst, UINT32 nDstStep, UINT32 DstF
|
||||
static BOOL clear_decompress_nscodec(NSC_CONTEXT* WINPR_RESTRICT nsc, UINT32 width, UINT32 height,
|
||||
wStream* WINPR_RESTRICT s, UINT32 bitmapDataByteCount,
|
||||
BYTE* WINPR_RESTRICT pDstData, UINT32 DstFormat,
|
||||
UINT32 nDstStep, UINT32 nXDstRel, UINT32 nYDstRel)
|
||||
UINT32 nDstStep, UINT32 nXDstRel, UINT32 nYDstRel,
|
||||
UINT32 nDstWidth, UINT32 nDstHeight)
|
||||
{
|
||||
BOOL rc = 0;
|
||||
|
||||
@@ -141,8 +142,8 @@ static BOOL clear_decompress_nscodec(NSC_CONTEXT* WINPR_RESTRICT nsc, UINT32 wid
|
||||
return FALSE;
|
||||
|
||||
rc = nsc_process_message(nsc, 32, width, height, Stream_Pointer(s), bitmapDataByteCount,
|
||||
pDstData, DstFormat, nDstStep, nXDstRel, nYDstRel, width, height,
|
||||
FREERDP_FLIP_NONE);
|
||||
pDstData, DstFormat, nDstStep, nXDstRel, nYDstRel, nDstWidth,
|
||||
nDstHeight, FREERDP_FLIP_NONE);
|
||||
Stream_Seek(s, bitmapDataByteCount);
|
||||
return rc;
|
||||
}
|
||||
@@ -532,7 +533,8 @@ static BOOL clear_decompress_subcodecs_data(CLEAR_CONTEXT* WINPR_RESTRICT clear,
|
||||
|
||||
case 1: /* NSCodec */
|
||||
if (!clear_decompress_nscodec(clear->nsc, width, height, s, bitmapDataByteCount,
|
||||
pDstData, DstFormat, nDstStep, nXDstRel, nYDstRel))
|
||||
pDstData, DstFormat, nDstStep, nXDstRel, nYDstRel,
|
||||
nDstWidth, nDstHeight))
|
||||
return FALSE;
|
||||
|
||||
break;
|
||||
|
||||
@@ -433,18 +433,32 @@ BOOL nsc_context_set_parameters(NSC_CONTEXT* WINPR_RESTRICT context, NSC_PARAMET
|
||||
BOOL nsc_process_message(NSC_CONTEXT* WINPR_RESTRICT context, UINT16 bpp, UINT32 width,
|
||||
UINT32 height, const BYTE* data, UINT32 length,
|
||||
BYTE* WINPR_RESTRICT pDstData, UINT32 DstFormat, UINT32 nDstStride,
|
||||
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth,
|
||||
WINPR_ATTR_UNUSED UINT32 nHeight, UINT32 flip)
|
||||
UINT32 nXDst, UINT32 nYDst, UINT32 nWidth, UINT32 nHeight, UINT32 flip)
|
||||
{
|
||||
WINPR_ASSERT(context);
|
||||
WINPR_ASSERT(context->priv);
|
||||
|
||||
wStream sbuffer = { 0 };
|
||||
BOOL ret = 0;
|
||||
if (!context || !data || !pDstData)
|
||||
if (!data || !pDstData)
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "Invalid argument: data=%p, pDstData=%p",
|
||||
(const void*)data, (void*)pDstData);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nXDst > nWidth)
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "nXDst %" PRIu32 " > nWidth %" PRIu32, nXDst,
|
||||
nWidth);
|
||||
return FALSE;
|
||||
}
|
||||
if (nYDst > nHeight)
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "nYDst %" PRIu32 " > nHeight %" PRIu32, nYDst,
|
||||
nHeight);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
wStream* s = Stream_StaticConstInit(&sbuffer, data, length);
|
||||
if (!s)
|
||||
@@ -454,7 +468,11 @@ BOOL nsc_process_message(NSC_CONTEXT* WINPR_RESTRICT context, UINT16 bpp, UINT32
|
||||
if (nDstStride == 0)
|
||||
nDstStride = minStride;
|
||||
if (nDstStride < minStride)
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR,
|
||||
"nDstStride %" PRIu32 " < minimum stride %" PRIu32, nDstStride, minStride);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (bpp)
|
||||
{
|
||||
|
||||
@@ -463,6 +463,9 @@ BOOL nsc_compose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RES
|
||||
if (!context || !s || !data)
|
||||
return FALSE;
|
||||
|
||||
if (scanline == 0)
|
||||
scanline = width * FreeRDPGetBytesPerPixel(context->format);
|
||||
|
||||
context->width = WINPR_ASSERTING_INT_CAST(UINT16, width);
|
||||
context->height = WINPR_ASSERTING_INT_CAST(UINT16, height);
|
||||
|
||||
@@ -495,6 +498,7 @@ BOOL nsc_compose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RES
|
||||
return nsc_write_message(context, s, &message);
|
||||
}
|
||||
|
||||
#if !defined(WITHOUT_FREERDP_3x_DEPRECATED)
|
||||
BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_RESTRICT s,
|
||||
BYTE* WINPR_RESTRICT bmpdata, UINT32 x, UINT32 y, UINT32 width,
|
||||
UINT32 height, UINT32 rowstride, UINT32 format, UINT32 flip)
|
||||
@@ -511,3 +515,4 @@ BOOL nsc_decompose_message(NSC_CONTEXT* WINPR_RESTRICT context, wStream* WINPR_R
|
||||
Stream_Seek(s, size);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1144,8 +1144,9 @@ static BOOL gdi_surface_bits(rdpContext* context, const SURFACE_BITS_COMMAND* cm
|
||||
if (!nsc_process_message(
|
||||
context->codecs->nsc, cmd->bmp.bpp, cmd->bmp.width, cmd->bmp.height,
|
||||
cmd->bmp.bitmapData, cmd->bmp.bitmapDataLength, gdi->primary_buffer, format,
|
||||
gdi->stride, cmdRect.left, cmdRect.top, cmdRect.right - cmdRect.left,
|
||||
cmdRect.bottom - cmdRect.top, FREERDP_FLIP_VERTICAL))
|
||||
gdi->stride, cmdRect.left, cmdRect.top,
|
||||
WINPR_ASSERTING_INT_CAST(UINT32, gdi->width),
|
||||
WINPR_ASSERTING_INT_CAST(UINT32, gdi->height), FREERDP_FLIP_VERTICAL))
|
||||
{
|
||||
WLog_ERR(TAG, "Failed to process NSCodec message");
|
||||
goto out;
|
||||
|
||||
Reference in New Issue
Block a user