{
PROFILER_CREATE(context->priv->prof_rfx_decode_rgb, "rfx_decode_rgb");
PROFILER_CREATE(context->priv->prof_rfx_decode_component,
- "rfx_decode_component");
+ "rfx_decode_component");
PROFILER_CREATE(context->priv->prof_rfx_rlgr_decode, "rfx_rlgr_decode");
PROFILER_CREATE(context->priv->prof_rfx_differential_decode,
- "rfx_differential_decode");
+ "rfx_differential_decode");
PROFILER_CREATE(context->priv->prof_rfx_quantization_decode,
- "rfx_quantization_decode");
+ "rfx_quantization_decode");
PROFILER_CREATE(context->priv->prof_rfx_dwt_2d_decode, "rfx_dwt_2d_decode");
PROFILER_CREATE(context->priv->prof_rfx_ycbcr_to_rgb, "prims->yCbCrToRGB");
PROFILER_CREATE(context->priv->prof_rfx_decode_format_rgb,
- "rfx_decode_format_rgb");
+ "rfx_decode_format_rgb");
PROFILER_CREATE(context->priv->prof_rfx_encode_rgb, "rfx_encode_rgb");
PROFILER_CREATE(context->priv->prof_rfx_encode_component,
- "rfx_encode_component");
+ "rfx_encode_component");
PROFILER_CREATE(context->priv->prof_rfx_rlgr_encode, "rfx_rlgr_encode");
PROFILER_CREATE(context->priv->prof_rfx_differential_encode,
- "rfx_differential_encode");
+ "rfx_differential_encode");
PROFILER_CREATE(context->priv->prof_rfx_quantization_encode,
- "rfx_quantization_encode");
+ "rfx_quantization_encode");
PROFILER_CREATE(context->priv->prof_rfx_dwt_2d_encode, "rfx_dwt_2d_encode");
PROFILER_CREATE(context->priv->prof_rfx_rgb_to_ycbcr, "prims->RGBToYCbCr");
PROFILER_CREATE(context->priv->prof_rfx_encode_format_rgb,
- "rfx_encode_format_rgb");
+ "rfx_encode_format_rgb");
}
static void rfx_profiler_free(RFX_CONTEXT* context)
verinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
GetVersionExA(&verinfo);
isVistaOrLater = ((verinfo.dwMajorVersion >= 6)
- && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE;
+ && (verinfo.dwMinorVersion >= 0)) ? TRUE : FALSE;
priv->UseThreads = isVistaOrLater;
}
#else
priv->MinThreadCount = sysinfo.dwNumberOfProcessors;
priv->MaxThreadCount = 0;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, RFX_KEY, 0,
- KEY_READ | KEY_WOW64_64KEY, &hKey);
+ KEY_READ | KEY_WOW64_64KEY, &hKey);
if (status == ERROR_SUCCESS)
{
dwSize = sizeof(dwValue);
if (RegQueryValueEx(hKey, _T("UseThreads"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->UseThreads = dwValue ? 1 : 0;
if (RegQueryValueEx(hKey, _T("MinThreadCount"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->MinThreadCount = dwValue;
if (RegQueryValueEx(hKey, _T("MaxThreadCount"), NULL, &dwType, (BYTE*) &dwValue,
- &dwSize) == ERROR_SUCCESS)
+ &dwSize) == ERROR_SUCCESS)
priv->MaxThreadCount = dwValue;
RegCloseKey(hKey);
free(priv->tileWorkParams);
#ifdef WITH_PROFILER
WLog_VRB(TAG,
- "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!");
+ "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!");
#endif
}
}
Stream_Read_UINT16(s,
- context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */
+ context->version); /* version (2 bytes), WF_VERSION_1_0 (0x0100) */
if (context->version != WF_VERSION_1_0)
{
Stream_Read_UINT8(s, numCodecs); /* numCodecs (1 byte), must be set to 0x01 */
Stream_Read_UINT8(s,
- context->codec_id); /* codecId (1 byte), must be set to 0x01 */
+ context->codec_id); /* codecId (1 byte), must be set to 0x01 */
Stream_Read_UINT16(s,
- context->codec_version); /* version (2 bytes), must be set to WF_VERSION_1_0 (0x0100) */
+ context->codec_version); /* version (2 bytes), must be set to WF_VERSION_1_0 (0x0100) */
if (numCodecs != 1)
{
if (context->codec_version != WF_VERSION_1_0)
{
WLog_ERR(TAG, "%s: invalid codec version (0x%04X)", __FUNCTION__,
- context->codec_version);
+ context->codec_version);
return FALSE;
}
WLog_Print(context->priv->log, WLOG_DEBUG, "id %d version 0x%X.",
- context->codec_id, context->codec_version);
+ context->codec_id, context->codec_version);
context->decodedHeaderBlocks |= _RFX_DECODED_VERSIONS;
return TRUE;
}
}
Stream_Read_UINT8(s,
- numChannels); /* numChannels (1 byte), must bet set to 0x01 */
+ numChannels); /* numChannels (1 byte), must bet set to 0x01 */
/* In RDVH sessions, numChannels will represent the number of virtual monitors
* configured and does not always be set to 0x01 as [MS-RDPRFX] said.
if (Stream_GetRemainingLength(s) < (size_t)(numChannels * 5))
{
WLog_ERR(TAG, "RfxMessageChannels packet too small for numChannels=%d",
- numChannels);
+ numChannels);
return FALSE;
}
if (!context->width || !context->height)
{
WLog_ERR(TAG, "%s: invalid channel with/height: %ux%u", __FUNCTION__,
- context->width, context->height);
+ context->width, context->height);
return FALSE;
}
/* Now, only the first monitor can be used, therefore the other channels will be ignored. */
Stream_Seek(s, 5 * (numChannels - 1));
WLog_Print(context->priv->log, WLOG_DEBUG, "numChannels %d id %d, %dx%d.",
- numChannels, channelId, context->width, context->height);
+ numChannels, channelId, context->width, context->height);
context->decodedHeaderBlocks |= _RFX_DECODED_CHANNELS;
return TRUE;
}
Stream_Read_UINT8(s, ctxId); /* ctxId (1 byte), must be set to 0x00 */
Stream_Read_UINT16(s,
- tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */
+ tileSize); /* tileSize (2 bytes), must be set to CT_TILE_64x64 (0x0040) */
Stream_Read_UINT16(s, properties); /* properties (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG,
- "ctxId %d tileSize %d properties 0x%X.",
- ctxId, tileSize, properties);
+ "ctxId %d tileSize %d properties 0x%X.",
+ ctxId, tileSize, properties);
context->properties = properties;
context->flags = (properties & 0x0007);
}
static BOOL rfx_process_message_frame_begin(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
UINT32 frameIdx;
UINT16 numRegions;
}
Stream_Read_UINT32(s,
- frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */
+ frameIdx); /* frameIdx (4 bytes), if codec is in video mode, must be ignored */
Stream_Read_UINT16(s, numRegions); /* numRegions (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG,
- "RFX_FRAME_BEGIN: frameIdx: %d numRegions: %d", frameIdx, numRegions);
+ "RFX_FRAME_BEGIN: frameIdx: %d numRegions: %d", frameIdx, numRegions);
return TRUE;
}
static BOOL rfx_process_message_frame_end(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
if (*pExpectedBlockType != WBT_FRAME_END)
{
}
static BOOL rfx_process_message_region(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpectedBlockType)
{
int i;
UINT16 regionType;
if (Stream_GetRemainingLength(s) < (size_t)(8 * message->numRects))
{
WLog_ERR(TAG, "%s: packet too small for num_rects=%d", __FUNCTION__,
- message->numRects);
+ message->numRects);
return FALSE;
}
Stream_Read_UINT16(s, rect->width); /* width (2 bytes) */
Stream_Read_UINT16(s, rect->height); /* height (2 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG, "rect %d (x,y=%d,%d w,h=%d %d).", i,
- rect->x, rect->y,
- rect->width, rect->height);
+ rect->x, rect->y,
+ rect->width, rect->height);
}
if (Stream_GetRemainingLength(s) < 4)
}
Stream_Read_UINT16(s,
- regionType); /* regionType (2 bytes): MUST be set to CBT_REGION (0xCAC1) */
+ regionType); /* regionType (2 bytes): MUST be set to CBT_REGION (0xCAC1) */
Stream_Read_UINT16(s,
- numTileSets); /* numTilesets (2 bytes): MUST be set to 0x0001. */
+ numTileSets); /* numTilesets (2 bytes): MUST be set to 0x0001. */
if (regionType != CBT_REGION)
{
}
static BOOL rfx_process_message_tileset(RFX_CONTEXT* context,
- RFX_MESSAGE* message, wStream* s, UINT16* pExpecedBlockType)
+ RFX_MESSAGE* message, wStream* s, UINT16* pExpecedBlockType)
{
BOOL rc;
int i, close_cnt;
}
Stream_Read_UINT16(s,
- subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */
+ subtype); /* subtype (2 bytes) must be set to CBT_TILESET (0xCAC2) */
if (subtype != CBT_TILESET)
{
Stream_Read_UINT32(s, tilesDataSize); /* tilesDataSize (4 bytes) */
if (!(pmem = realloc((void*) context->quants,
- context->numQuant * 10 * sizeof(UINT32))))
+ context->numQuant * 10 * sizeof(UINT32))))
return FALSE;
quants = context->quants = (UINT32*) pmem;
if (Stream_GetRemainingLength(s) < (size_t)(context->numQuant * 5))
{
WLog_ERR(TAG, "RfxMessageTileSet packet too small for num_quants=%d",
- context->numQuant);
+ context->numQuant);
return FALSE;
}
*quants++ = (quant & 0x0F);
*quants++ = (quant >> 4);
WLog_Print(context->priv->log, WLOG_DEBUG,
- "quant %d (%d %d %d %d %d %d %d %d %d %d).",
- i, context->quants[i * 10], context->quants[i * 10 + 1],
- context->quants[i * 10 + 2], context->quants[i * 10 + 3],
- context->quants[i * 10 + 4], context->quants[i * 10 + 5],
- context->quants[i * 10 + 6], context->quants[i * 10 + 7],
- context->quants[i * 10 + 8], context->quants[i * 10 + 9]);
+ "quant %d (%d %d %d %d %d %d %d %d %d %d).",
+ i, context->quants[i * 10], context->quants[i * 10 + 1],
+ context->quants[i * 10 + 2], context->quants[i * 10 + 3],
+ context->quants[i * 10 + 4], context->quants[i * 10 + 5],
+ context->quants[i * 10 + 6], context->quants[i * 10 + 7],
+ context->quants[i * 10 + 8], context->quants[i * 10 + 9]);
}
if (!(message->tiles = (RFX_TILE**) calloc(message->numTiles,
- sizeof(RFX_TILE*))))
+ sizeof(RFX_TILE*))))
{
message->numTiles = 0;
return FALSE;
{
work_objects = (PTP_WORK*) calloc(message->numTiles, sizeof(PTP_WORK));
params = (RFX_TILE_PROCESS_WORK_PARAM*) calloc(message->numTiles,
- sizeof(RFX_TILE_PROCESS_WORK_PARAM));
+ sizeof(RFX_TILE_PROCESS_WORK_PARAM));
if (!work_objects)
{
if (Stream_GetRemainingLength(s) < 6)
{
WLog_ERR(TAG, "RfxMessageTileSet packet too small to read tile %d/%d", i,
- message->numTiles);
+ message->numTiles);
rc = FALSE;
break;
}
Stream_Read_UINT16(s,
- blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
+ blockType); /* blockType (2 bytes), must be set to CBT_TILE (0xCAC3) */
Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
if (Stream_GetRemainingLength(s) < blockLen - 6)
{
WLog_ERR(TAG,
- "RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
- i, message->numTiles, blockLen);
+ "RfxMessageTileSet not enough bytes to read tile %d/%d with blocklen=%d",
+ i, message->numTiles, blockLen);
rc = FALSE;
break;
}
if (blockType != CBT_TILE)
{
WLog_ERR(TAG, "unknown block type 0x%X, expected CBT_TILE (0xCAC3).",
- blockType);
+ blockType);
rc = FALSE;
break;
}
params[i].tile = message->tiles[i];
if (!(work_objects[i] = CreateThreadpoolWork((PTP_WORK_CALLBACK)
- rfx_process_message_tile_work_callback,
- (void*) ¶ms[i], &context->priv->ThreadPoolEnv)))
+ rfx_process_message_tile_work_callback,
+ (void*) ¶ms[i], &context->priv->ThreadPoolEnv)))
{
WLog_ERR(TAG, "CreateThreadpoolWork failed.");
rc = FALSE;
}
BOOL rfx_process_message(RFX_CONTEXT* context, const BYTE* data,
- UINT32 format, UINT32 length,
- UINT32 left, UINT32 top,
- BYTE* dst, UINT32 dstFormat,
- UINT32 dstStride, UINT32 dstHeight,
- REGION16* invalidRegion)
+ UINT32 format, UINT32 length,
+ UINT32 left, UINT32 top,
+ BYTE* dst, UINT32 dstFormat,
+ UINT32 dstStride, UINT32 dstHeight,
+ REGION16* invalidRegion)
{
int pos;
REGION16 updateRegion;
Stream_Read_UINT16(s, blockType); /* blockType (2 bytes) */
Stream_Read_UINT32(s, blockLen); /* blockLen (4 bytes) */
WLog_Print(context->priv->log, WLOG_DEBUG, "blockType 0x%X blockLen %d",
- blockType, blockLen);
+ blockType, blockLen);
if (blockLen == 0)
{
Stream_Read_UINT8(s, codecId); /* codecId (1 byte) must be set to 0x01 */
Stream_Read_UINT8(s,
- channelId); /* channelId (1 byte) 0xFF or 0x00, see below */
+ channelId); /* channelId (1 byte) 0xFF or 0x00, see below */
if (codecId != 0x01)
{
if (channelId != 0xFF)
{
WLog_ERR(TAG, "%s: invalid channelId 0x%02X for blockType 0x%04X", __FUNCTION__,
- channelId, blockType);
+ channelId, blockType);
goto fail;
}
}
if (channelId != 0x00)
{
WLog_ERR(TAG, "%s: invalid channelId 0x%02X for blockType WBT_CONTEXT",
- __FUNCTION__, channelId);
+ __FUNCTION__, channelId);
goto fail;
}
}
case WBT_FRAME_BEGIN:
ok = rfx_process_message_frame_begin(context, message, s,
- &expectedDataBlockType);
+ &expectedDataBlockType);
break;
case WBT_REGION:
for (j = 0; j < nbUpdateRects; j++)
{
+ UINT32 stride = 64 * GetBytesPerPixel(format);
UINT32 nXDst = updateRects[j].left;
UINT32 nYDst = updateRects[j].top;
- UINT32 nWidth = updateRects[j].right - updateRects[j].left;
- UINT32 nHeight = updateRects[j].bottom - updateRects[j].top;
+ UINT32 nXSrc = nXDst - updateRect.left;
+ UINT32 nYSrc = nYDst - updateRect.top;
+ UINT32 nWidth = MIN(64, updateRects[j].right - updateRects[j].left);
+ UINT32 nHeight = MIN(64, updateRects[j].bottom - updateRects[j].top);
if (!freerdp_image_copy(dst, dstFormat, dstStride,
- nXDst, nYDst, nWidth, nHeight,
- tile->data, format, 64 * GetBytesPerPixel(format), 0, 0, NULL))
+ nXDst, nYDst, nWidth, nHeight,
+ tile->data, format, stride, nXSrc, nYSrc, NULL))
goto fail;
if (invalidRegion)
properties |= (COL_CONV_ICT << 4); /* cct */
properties |= (CLW_XFORM_DWT_53_A << 6); /* xft */
properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3)
- << 10); /* et */
+ << 10); /* et */
properties |= (SCALAR_QUANTIZATION << 14); /* qt */
context->properties = properties;
}
properties |= (COL_CONV_ICT << 3); /* cct */
properties |= (CLW_XFORM_DWT_53_A << 5); /* xft */
properties |= ((context->mode == RLGR1 ? CLW_ENTROPY_RLGR1 : CLW_ENTROPY_RLGR3)
- << 9); /* et */
+ << 9); /* et */
properties |= (SCALAR_QUANTIZATION << 13); /* qt */
Stream_Write_UINT16(s, properties); /* properties (2 bytes) */
rfx_update_context_properties(context);
};
void CALLBACK rfx_compose_message_tile_work_callback(PTP_CALLBACK_INSTANCE
- instance, void* context, PTP_WORK work)
+ instance, void* context, PTP_WORK work)
{
RFX_TILE_COMPOSE_WORK_PARAM* param = (RFX_TILE_COMPOSE_WORK_PARAM*) context;
rfx_encode_rgb(param->context, param->tile);
static BOOL computeRegion(const RFX_RECT* rects, int numRects, REGION16* region,
- int width, int height)
+ int width, int height)
{
int i;
const RFX_RECT* rect = rects;
priv->workObjects = (PTP_WORK*) pmem;
if (!(pmem = realloc((void*) priv->tileWorkParams,
- sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * nbTiles)))
+ sizeof(RFX_TILE_COMPOSE_WORK_PARAM) * nbTiles)))
return FALSE;
priv->tileWorkParams = (RFX_TILE_COMPOSE_WORK_PARAM*) pmem;
}
RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
- int numRects,
- BYTE* data, int width, int height, int scanline)
+ int numRects,
+ BYTE* data, int width, int height, int scanline)
{
UINT32 i, maxNbTiles, maxTilesX, maxTilesY;
UINT32 xIdx, yIdx, regionNbRects;
if (!context->numQuant)
{
if (!(context->quants = (UINT32*) malloc(sizeof(
- rfx_default_quantization_values))))
+ rfx_default_quantization_values))))
goto skip_encoding_loop;
CopyMemory(context->quants, &rfx_default_quantization_values,
- sizeof(rfx_default_quantization_values));
+ sizeof(rfx_default_quantization_values));
context->numQuant = 1;
context->quantIdxY = 0;
context->quantIdxCb = 0;
workParam->tile = tile;
if (!(*workObject = CreateThreadpoolWork(
- (PTP_WORK_CALLBACK)rfx_compose_message_tile_work_callback,
- (void*) workParam,
- &context->priv->ThreadPoolEnv)))
+ (PTP_WORK_CALLBACK)rfx_compose_message_tile_work_callback,
+ (void*) workParam,
+ &context->priv->ThreadPoolEnv)))
{
goto skip_encoding_loop;
}
if (message->numTiles > 0)
{
void* pmem = realloc((void*) message->tiles,
- sizeof(RFX_TILE*) * message->numTiles);
+ sizeof(RFX_TILE*) * message->numTiles);
if (pmem)
message->tiles = (RFX_TILE**) pmem;
}
RFX_MESSAGE* rfx_split_message(RFX_CONTEXT* context, RFX_MESSAGE* message,
- int* numMessages, int maxDataSize)
+ int* numMessages, int maxDataSize)
{
int i, j;
UINT32 tileDataSize;
messages[j].freeArray = TRUE;
if (!(messages[j].tiles = (RFX_TILE**) calloc(message->numTiles,
- sizeof(RFX_TILE*))))
+ sizeof(RFX_TILE*))))
goto free_messages;
}
}
RFX_MESSAGE* rfx_encode_messages(RFX_CONTEXT* context, const RFX_RECT* rects,
- int numRects,
- BYTE* data, int width, int height, int scanline, int* numMessages,
- int maxDataSize)
+ int numRects,
+ BYTE* data, int width, int height, int scanline, int* numMessages,
+ int maxDataSize)
{
RFX_MESSAGE* message;
RFX_MESSAGE* messageList;
if (!(message = rfx_encode_message(context, rects, numRects, data, width,
- height, scanline)))
+ height, scanline)))
return NULL;
if (!(messageList = rfx_split_message(context, message, numMessages,
- maxDataSize)))
+ maxDataSize)))
{
message->freeRects = TRUE;
rfx_message_free(context, message);
}
static BOOL rfx_write_message_tileset(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
int i;
RFX_TILE* tile;
#ifdef WITH_DEBUG_RFX
WLog_Print(context->priv->log, WLOG_DEBUG,
- "numQuant: %d numTiles: %d tilesDataSize: %d",
- message->numQuant, message->numTiles, message->tilesDataSize);
+ "numQuant: %d numTiles: %d tilesDataSize: %d",
+ message->numQuant, message->numTiles, message->tilesDataSize);
#endif
return TRUE;
}
static BOOL rfx_write_message_frame_begin(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
if (!Stream_EnsureRemainingCapacity(s, 14))
return FALSE;
}
static BOOL rfx_write_message_region(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
int i;
UINT32 blockLen;
}
BOOL rfx_write_message_frame_end(RFX_CONTEXT* context, wStream* s,
- RFX_MESSAGE* message)
+ RFX_MESSAGE* message)
{
if (!Stream_EnsureRemainingCapacity(s, 8))
return FALSE;
}
BOOL rfx_compose_message(RFX_CONTEXT* context, wStream* s,
- const RFX_RECT* rects, int numRects, BYTE* data, int width, int height,
- int scanline)
+ const RFX_RECT* rects, int numRects, BYTE* data, int width, int height,
+ int scanline)
{
RFX_MESSAGE* message;
BOOL ret = TRUE;
if (!(message = rfx_encode_message(context, rects, numRects, data, width,
- height, scanline)))
+ height, scanline)))
return FALSE;
ret = rfx_write_message(context, s, message);