Merge pull request #2741 from awakecoding/master

egfx progressive codec frame handling
This commit is contained in:
Marc-André Moreau 2015-06-28 15:14:04 -04:00
commit 084b365be7
5 changed files with 228 additions and 129 deletions

View File

@ -41,6 +41,8 @@
#include "rdpgfx_main.h"
#define TAG CHANNELS_TAG("rdpgfx.client")
int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback)
{
int status;
@ -85,7 +87,7 @@ int rdpgfx_send_caps_advertise_pdu(RDPGFX_CHANNEL_CALLBACK* callback)
header.pduLength = RDPGFX_HEADER_SIZE + 2 + (pdu.capsSetCount * RDPGFX_CAPSET_SIZE);
WLog_Print(gfx->log, WLOG_DEBUG, "SendCapsAdvertisePdu");
WLog_DBG(TAG, "SendCapsAdvertisePdu");
s = Stream_New(NULL, header.pduLength);
@ -130,7 +132,7 @@ int rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
/*TODO: interpret this answer*/
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCapsConfirmPdu: version: 0x%04X flags: 0x%04X",
WLog_DBG(TAG, "RecvCapsConfirmPdu: version: 0x%04X flags: 0x%04X",
capsSet.version, capsSet.flags);
return 1;
@ -147,7 +149,7 @@ int rdpgfx_send_frame_acknowledge_pdu(RDPGFX_CHANNEL_CALLBACK* callback, RDPGFX_
header.cmdId = RDPGFX_CMDID_FRAMEACKNOWLEDGE;
header.pduLength = RDPGFX_HEADER_SIZE + 12;
WLog_Print(gfx->log, WLOG_DEBUG, "SendFrameAcknowledgePdu: %d", pdu->frameId);
WLog_DBG(TAG, "SendFrameAcknowledgePdu: %d", pdu->frameId);
s = Stream_New(NULL, header.pduLength);
@ -210,7 +212,7 @@ int rdpgfx_recv_reset_graphics_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s
Stream_Seek(s, pad); /* pad (total size is 340 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvResetGraphicsPdu: width: %d height: %d count: %d",
WLog_DBG(TAG, "RecvResetGraphicsPdu: width: %d height: %d count: %d",
pdu.width, pdu.height, pdu.monitorCount);
if (context && context->ResetGraphics)
@ -234,7 +236,7 @@ int rdpgfx_recv_evict_cache_entry_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream
Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEvictCacheEntryPdu: cacheSlot: %d", pdu.cacheSlot);
WLog_DBG(TAG, "RecvEvictCacheEntryPdu: cacheSlot: %d", pdu.cacheSlot);
if (context && context->EvictCacheEntry)
{
@ -269,7 +271,7 @@ int rdpgfx_recv_cache_import_reply_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
Stream_Read_UINT16(s, pdu.cacheSlots[index]); /* cacheSlot (2 bytes) */
}
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCacheImportReplyPdu: importedEntriesCount: %d",
WLog_DBG(TAG, "RecvCacheImportReplyPdu: importedEntriesCount: %d",
pdu.importedEntriesCount);
if (context && context->CacheImportReply)
@ -296,7 +298,7 @@ int rdpgfx_recv_create_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s
Stream_Read_UINT16(s, pdu.height); /* height (2 bytes) */
Stream_Read_UINT8(s, pdu.pixelFormat); /* RDPGFX_PIXELFORMAT (1 byte) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCreateSurfacePdu: surfaceId: %d width: %d height: %d pixelFormat: 0x%02X",
WLog_DBG(TAG, "RecvCreateSurfacePdu: surfaceId: %d width: %d height: %d pixelFormat: 0x%02X",
pdu.surfaceId, pdu.width, pdu.height, pdu.pixelFormat);
if (context && context->CreateSurface)
@ -318,7 +320,7 @@ int rdpgfx_recv_delete_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvDeleteSurfacePdu: surfaceId: %d", pdu.surfaceId);
WLog_DBG(TAG, "RecvDeleteSurfacePdu: surfaceId: %d", pdu.surfaceId);
if (context && context->DeleteSurface)
{
@ -340,7 +342,7 @@ int rdpgfx_recv_start_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
Stream_Read_UINT32(s, pdu.timestamp); /* timestamp (4 bytes) */
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvStartFramePdu: frameId: %d timestamp: 0x%04X",
WLog_DBG(TAG, "RecvStartFramePdu: frameId: %d timestamp: 0x%04X",
pdu.frameId, pdu.timestamp);
if (context && context->StartFrame)
@ -365,7 +367,7 @@ int rdpgfx_recv_end_frame_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
Stream_Read_UINT32(s, pdu.frameId); /* frameId (4 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvEndFramePdu: frameId: %d", pdu.frameId);
WLog_DBG(TAG, "RecvEndFramePdu: frameId: %d", pdu.frameId);
if (context && context->EndFrame)
{
@ -410,7 +412,7 @@ int rdpgfx_recv_wire_to_surface_1_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream
pdu.bitmapData = Stream_Pointer(s);
Stream_Seek(s, pdu.bitmapDataLength);
WLog_Print(gfx->log, WLOG_DEBUG, "RecvWireToSurface1Pdu: surfaceId: %d codecId: %s (0x%04X) pixelFormat: 0x%04X "
WLog_DBG(TAG, "RecvWireToSurface1Pdu: surfaceId: %d codecId: %s (0x%04X) pixelFormat: 0x%04X "
"destRect: left: %d top: %d right: %d bottom: %d bitmapDataLength: %d",
(int) pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId, pdu.pixelFormat,
pdu.destRect.left, pdu.destRect.top, pdu.destRect.right, pdu.destRect.bottom,
@ -464,9 +466,10 @@ int rdpgfx_recv_wire_to_surface_2_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream
pdu.bitmapData = Stream_Pointer(s);
Stream_Seek(s, pdu.bitmapDataLength);
WLog_Print(gfx->log, WLOG_DEBUG, "RecvWireToSurface2Pdu: surfaceId: %d codecId: 0x%04X "
WLog_DBG(TAG, "RecvWireToSurface2Pdu: surfaceId: %d codecId: %s (0x%04X) "
"codecContextId: %d pixelFormat: 0x%04X bitmapDataLength: %d",
(int) pdu.surfaceId, pdu.codecId, pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength);
(int) pdu.surfaceId, rdpgfx_get_codec_id_string(pdu.codecId), pdu.codecId,
pdu.codecContextId, pdu.pixelFormat, pdu.bitmapDataLength);
cmd.surfaceId = pdu.surfaceId;
cmd.codecId = pdu.codecId;
@ -501,7 +504,7 @@ int rdpgfx_recv_delete_encoding_context_pdu(RDPGFX_CHANNEL_CALLBACK* callback, w
Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */
Stream_Read_UINT32(s, pdu.codecContextId); /* codecContextId (4 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvDeleteEncodingContextPdu: surfaceId: %d codecContextId: %d",
WLog_DBG(TAG, "RecvDeleteEncodingContextPdu: surfaceId: %d codecContextId: %d",
pdu.surfaceId, pdu.codecContextId);
if (context && context->DeleteEncodingContext)
@ -541,7 +544,7 @@ int rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
rdpgfx_read_rect16(s, fillRect);
}
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSolidFillPdu: surfaceId: %d fillRectCount: %d",
WLog_DBG(TAG, "RecvSolidFillPdu: surfaceId: %d fillRectCount: %d",
pdu.surfaceId, pdu.fillRectCount);
if (context && context->SolidFill)
@ -584,7 +587,7 @@ int rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
rdpgfx_read_point16(s, destPt);
}
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSurfaceToSurfacePdu: surfaceIdSrc: %d surfaceIdDest: %d "
WLog_DBG(TAG, "RecvSurfaceToSurfacePdu: surfaceIdSrc: %d surfaceIdDest: %d "
"left: %d top: %d right: %d bottom: %d destPtsCount: %d",
pdu.surfaceIdSrc, pdu.surfaceIdDest,
pdu.rectSrc.left, pdu.rectSrc.top, pdu.rectSrc.right, pdu.rectSrc.bottom,
@ -614,7 +617,7 @@ int rdpgfx_recv_surface_to_cache_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream*
Stream_Read_UINT16(s, pdu.cacheSlot); /* cacheSlot (2 bytes) */
rdpgfx_read_rect16(s, &(pdu.rectSrc)); /* rectSrc (8 bytes ) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvSurfaceToCachePdu: surfaceId: %d cacheKey: 0x%08X cacheSlot: %d "
WLog_DBG(TAG, "RecvSurfaceToCachePdu: surfaceId: %d cacheKey: 0x%08X cacheSlot: %d "
"left: %d top: %d right: %d bottom: %d",
pdu.surfaceId, (int) pdu.cacheKey, pdu.cacheSlot,
pdu.rectSrc.left, pdu.rectSrc.top,
@ -657,7 +660,7 @@ int rdpgfx_recv_cache_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream*
rdpgfx_read_point16(s, destPt);
}
WLog_Print(gfx->log, WLOG_DEBUG, "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %d surfaceId: %d destPtsCount: %d",
WLog_DBG(TAG, "RdpGfxRecvCacheToSurfacePdu: cacheSlot: %d surfaceId: %d destPtsCount: %d",
pdu.cacheSlot, (int) pdu.surfaceId, pdu.destPtsCount);
if (context && context->CacheToSurface)
@ -684,7 +687,7 @@ int rdpgfx_recv_map_surface_to_output_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wSt
Stream_Read_UINT32(s, pdu.outputOriginX); /* outputOriginX (4 bytes) */
Stream_Read_UINT32(s, pdu.outputOriginY); /* outputOriginY (4 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvMapSurfaceToOutputPdu: surfaceId: %d outputOriginX: %d outputOriginY: %d",
WLog_DBG(TAG, "RecvMapSurfaceToOutputPdu: surfaceId: %d outputOriginX: %d outputOriginY: %d",
(int) pdu.surfaceId, pdu.outputOriginX, pdu.outputOriginY);
if (context && context->MapSurfaceToOutput)
@ -709,7 +712,7 @@ int rdpgfx_recv_map_surface_to_window_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wSt
Stream_Read_UINT32(s, pdu.mappedWidth); /* mappedWidth (4 bytes) */
Stream_Read_UINT32(s, pdu.mappedHeight); /* mappedHeight (4 bytes) */
WLog_Print(gfx->log, WLOG_DEBUG, "RecvMapSurfaceToWindowPdu: surfaceId: %d windowId: 0x%04X mappedWidth: %d mappedHeight: %d",
WLog_DBG(TAG, "RecvMapSurfaceToWindowPdu: surfaceId: %d windowId: 0x%04X mappedWidth: %d mappedHeight: %d",
pdu.surfaceId, (int) pdu.windowId, pdu.mappedWidth, pdu.mappedHeight);
if (context && context->MapSurfaceToWindow)
@ -735,7 +738,7 @@ int rdpgfx_recv_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
return -1;
#if 1
WLog_Print(gfx->log, WLOG_DEBUG, "cmdId: %s (0x%04X) flags: 0x%04X pduLength: %d",
WLog_DBG(TAG, "cmdId: %s (0x%04X) flags: 0x%04X pduLength: %d",
rdpgfx_get_cmd_id_string(header.cmdId), header.cmdId, header.flags, header.pduLength);
#endif
@ -863,9 +866,6 @@ static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
}
Stream_Free(s, TRUE);
//free(Stream_Buffer(data));
//Stream_Free(data,TRUE);
return status;
}
@ -875,7 +875,7 @@ static int rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback)
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
WLog_Print(gfx->log, WLOG_DEBUG, "OnOpen");
WLog_DBG(TAG, "OnOpen");
rdpgfx_send_caps_advertise_pdu(callback);
@ -887,7 +887,7 @@ static int rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
WLog_Print(gfx->log, WLOG_DEBUG, "OnClose");
WLog_DBG(TAG, "OnClose");
free(callback);
@ -938,7 +938,7 @@ static int rdpgfx_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelManag
gfx->listener->pInterface = gfx->iface.pInterface;
WLog_Print(gfx->log, WLOG_DEBUG, "Initialize");
WLog_DBG(TAG, "Initialize");
return status;
}
@ -951,7 +951,7 @@ static int rdpgfx_plugin_terminated(IWTSPlugin* pPlugin)
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) pPlugin;
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
WLog_Print(gfx->log, WLOG_DEBUG, "Terminated");
WLog_DBG(TAG, "Terminated");
if (gfx->listener_callback)
{
@ -1108,7 +1108,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
if (!gfx)
return -1;
gfx->log = WLog_Get(TAG);
gfx->settings = (rdpSettings*) pEntryPoints->GetRdpSettings(pEntryPoints);
gfx->iface.Initialize = rdpgfx_plugin_initialize;
@ -1117,6 +1116,7 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
gfx->iface.Terminated = rdpgfx_plugin_terminated;
gfx->SurfaceTable = HashTable_New(TRUE);
if (!gfx->SurfaceTable)
{
free (gfx);

View File

@ -31,8 +31,6 @@
#include <freerdp/channels/log.h>
#include <freerdp/codec/zgfx.h>
#define TAG CHANNELS_TAG("rdpgfx.client")
struct _RDPGFX_CHANNEL_CALLBACK
{
IWTSVirtualChannelCallback iface;
@ -60,7 +58,6 @@ struct _RDPGFX_PLUGIN
IWTSListener* listener;
RDPGFX_LISTENER_CALLBACK* listener_callback;
wLog* log;
rdpSettings* settings;
BOOL ThinClient;

View File

@ -46,10 +46,6 @@ typedef struct _PROGRESSIVE_CONTEXT PROGRESSIVE_CONTEXT;
#define PROGRESSIVE_WBT_TILE_FIRST 0xCCC6
#define PROGRESSIVE_WBT_TILE_UPGRADE 0xCCC7
#define PROGRESSIVE_BLOCKS_ALL 0x0001
#define PROGRESSIVE_BLOCKS_REGION 0x0002
#define PROGRESSIVE_BLOCKS_TILE 0x0004
struct _RFX_COMPONENT_CODEC_QUANT
{
BYTE LL3;
@ -102,77 +98,6 @@ struct _PROGRESSIVE_BLOCK_CONTEXT
};
typedef struct _PROGRESSIVE_BLOCK_CONTEXT PROGRESSIVE_BLOCK_CONTEXT;
struct _PROGRESSIVE_BLOCK_TILE_SIMPLE
{
UINT16 blockType;
UINT32 blockLen;
BYTE quantIdxY;
BYTE quantIdxCb;
BYTE quantIdxCr;
UINT16 xIdx;
UINT16 yIdx;
BYTE flags;
UINT16 yLen;
UINT16 cbLen;
UINT16 crLen;
UINT16 tailLen;
BYTE* yData;
BYTE* cbData;
BYTE* crData;
BYTE* tailData;
};
typedef struct _PROGRESSIVE_BLOCK_TILE_SIMPLE PROGRESSIVE_BLOCK_TILE_SIMPLE;
struct _PROGRESSIVE_BLOCK_TILE_FIRST
{
UINT16 blockType;
UINT32 blockLen;
BYTE quantIdxY;
BYTE quantIdxCb;
BYTE quantIdxCr;
UINT16 xIdx;
UINT16 yIdx;
BYTE flags;
BYTE quality;
UINT16 yLen;
UINT16 cbLen;
UINT16 crLen;
UINT16 tailLen;
BYTE* yData;
BYTE* cbData;
BYTE* crData;
BYTE* tailData;
};
typedef struct _PROGRESSIVE_BLOCK_TILE_FIRST PROGRESSIVE_BLOCK_TILE_FIRST;
struct _PROGRESSIVE_BLOCK_TILE_UPGRADE
{
UINT16 blockType;
UINT32 blockLen;
BYTE quantIdxY;
BYTE quantIdxCb;
BYTE quantIdxCr;
UINT16 xIdx;
UINT16 yIdx;
BYTE quality;
UINT16 ySrlLen;
UINT16 yRawLen;
UINT16 cbSrlLen;
UINT16 cbRawLen;
UINT16 crSrlLen;
UINT16 crRawLen;
BYTE* ySrlData;
BYTE* yRawData;
BYTE* cbSrlData;
BYTE* cbRawData;
BYTE* crSrlData;
BYTE* crRawData;
};
typedef struct _PROGRESSIVE_BLOCK_TILE_UPGRADE PROGRESSIVE_BLOCK_TILE_UPGRADE;
struct _RFX_PROGRESSIVE_TILE
{
UINT16 blockType;
@ -285,7 +210,6 @@ struct _PROGRESSIVE_CONTEXT
BOOL invert;
wLog* log;
wBufferPool* bufferPool;
UINT32 cRects;

View File

@ -224,6 +224,12 @@ BOOL progressive_rfx_quant_cmp_equal(RFX_COMPONENT_CODEC_QUANT* q1, RFX_COMPONEN
return TRUE;
}
void progressive_rfx_quant_print(RFX_COMPONENT_CODEC_QUANT* q, const char* name)
{
fprintf(stderr, "%s: HL1: %d LH1: %d HH1: %d HL2: %d LH2: %d HH2: %d HL3: %d LH3: %d HH3: %d LL3: %d\n",
name, q->HL1, q->LH1, q->HH1, q->HL2, q->LH2, q->HH2, q->HL3, q->LH3, q->HH3, q->LL3);
}
int progressive_set_surface_data(PROGRESSIVE_CONTEXT* progressive, UINT16 surfaceId, void* pData)
{
ULONG_PTR key;
@ -270,7 +276,7 @@ PROGRESSIVE_SURFACE_CONTEXT* progressive_surface_context_new(UINT16 surfaceId, U
if (!surface->tiles)
{
free (surface);
free(surface);
return NULL;
}
@ -727,10 +733,9 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG
diff = tile->flags & RFX_TILE_DIFFERENCE;
#if 0
WLog_INFO(TAG, "ProgressiveTileFirst: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d",
tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen);
#endif
WLog_DBG(TAG, "ProgressiveTile%s: quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d flags: 0x%02X quality: %d yLen: %d cbLen: %d crLen: %d tailLen: %d",
(tile->blockType == PROGRESSIVE_WBT_TILE_FIRST) ? "First" : "Simple",
tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->flags, tile->quality, tile->yLen, tile->cbLen, tile->crLen, tile->tailLen);
region = &(progressive->region);
@ -825,8 +830,6 @@ int progressive_decompress_tile_first(PROGRESSIVE_CONTEXT* progressive, RFX_PROG
BufferPool_Return(progressive->bufferPool, pBuffer);
//WLog_Image(progressive->log, WLOG_TRACE, tile->data, 64, 64, 32);
return 1;
}
@ -1134,10 +1137,8 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR
tile->pass++;
#if 0
WLog_INFO(TAG, "ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d",
WLog_DBG(TAG, "ProgressiveTileUpgrade: pass: %d quantIdx Y: %d Cb: %d Cr: %d xIdx: %d yIdx: %d quality: %d ySrlLen: %d yRawLen: %d cbSrlLen: %d cbRawLen: %d crSrlLen: %d crRawLen: %d",
tile->pass, tile->quantIdxY, tile->quantIdxCb, tile->quantIdxCr, tile->xIdx, tile->yIdx, tile->quality, tile->ySrlLen, tile->yRawLen, tile->cbSrlLen, tile->cbRawLen, tile->crSrlLen, tile->crRawLen);
#endif
region = &(progressive->region);
@ -1246,8 +1247,6 @@ int progressive_decompress_tile_upgrade(PROGRESSIVE_CONTEXT* progressive, RFX_PR
BufferPool_Return(progressive->bufferPool, pBuffer);
//WLog_Image(progressive->log, WLOG_TRACE, tile->data, 64, 64, 32);
return 1;
}
@ -1281,7 +1280,7 @@ int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, BYTE* blocks, UI
blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */
boffset += 6;
//WLog_INFO(TAG, "%s", progressive_get_block_type_string(blockType));
//WLog_DBG(TAG, "%s", progressive_get_block_type_string(blockType));
if ((blocksLen - offset) < blockLen)
return -1003;
@ -1507,6 +1506,11 @@ int progressive_process_tiles(PROGRESSIVE_CONTEXT* progressive, BYTE* blocks, UI
if (offset != blocksLen)
return -1041;
if (count != region->numTiles)
{
WLog_WARN(TAG, "numTiles inconsistency: actual: %d, expected: %d\n", count, region->numTiles);
}
for (index = 0; index < region->numTiles; index++)
{
tile = tiles[index];
@ -1537,6 +1541,14 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
BYTE* block;
BYTE* blocks;
UINT16 index;
UINT16 boxLeft;
UINT16 boxTop;
UINT16 boxRight;
UINT16 boxBottom;
UINT16 idxLeft;
UINT16 idxTop;
UINT16 idxRight;
UINT16 idxBottom;
UINT32 boffset;
UINT16 blockType;
UINT32 blockLen;
@ -1573,7 +1585,6 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
blockType = *((UINT16*) &block[boffset + 0]); /* blockType (2 bytes) */
blockLen = *((UINT32*) &block[boffset + 2]); /* blockLen (4 bytes) */
boffset += 6;
//WLog_INFO(TAG, "%s", progressive_get_block_type_string(blockType));
if ((blocksLen - offset) < blockLen)
return -1003;
@ -1582,6 +1593,8 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
{
case PROGRESSIVE_WBT_SYNC:
WLog_DBG(TAG, "ProgressiveSync");
sync.blockType = blockType;
sync.blockLen = blockLen;
@ -1612,6 +1625,9 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
frameBegin.regionCount = (UINT32) *((UINT16*) &block[boffset + 4]); /* regionCount (2 bytes) */
boffset += 6;
WLog_DBG(TAG, "ProgressiveFrameBegin: frameIndex: %d regionCount: %d",
frameBegin.frameIndex, frameBegin.regionCount);
/**
* If the number of elements specified by the regionCount field is
* larger than the actual number of elements in the regions field,
@ -1622,6 +1638,8 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
case PROGRESSIVE_WBT_FRAME_END:
WLog_DBG(TAG, "ProgressiveFrameEnd");
frameEnd.blockType = blockType;
frameEnd.blockLen = blockLen;
@ -1646,6 +1664,13 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
if (context.tileSize != 64)
return -1010;
WLog_DBG(TAG, "ProgressiveContext: flags: 0x%02X", context.flags);
if (!(context.flags & RFX_SUBBAND_DIFFING))
{
WLog_WARN(TAG, "RFX_SUBBAND_DIFFING is not set");
}
break;
case PROGRESSIVE_WBT_REGION:
@ -1755,11 +1780,11 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
if ((blockLen - boffset) < region->tileDataSize)
return -1021;
if (region->numTiles > progressive->cTiles)
if (progressive->cTiles < surface->gridSize)
{
progressive->tiles = (RFX_PROGRESSIVE_TILE**) realloc(progressive->tiles,
region->numTiles * sizeof(RFX_PROGRESSIVE_TILE*));
progressive->cTiles = region->numTiles;
surface->gridSize * sizeof(RFX_PROGRESSIVE_TILE*));
progressive->cTiles = surface->gridSize;
}
region->tiles = progressive->tiles;
@ -1767,14 +1792,67 @@ int progressive_decompress(PROGRESSIVE_CONTEXT* progressive, BYTE* pSrcData, UIN
if (!region->tiles)
return -1;
//WLog_INFO(TAG, "numRects: %d numTiles: %d numQuant: %d numProgQuant: %d",
// region->numRects, region->numTiles, region->numQuant, region->numProgQuant);
WLog_DBG(TAG, "ProgressiveRegion: numRects: %d numTiles: %d tileDataSize: %d flags: 0x%02X numQuant: %d numProgQuant: %d",
region->numRects, region->numTiles, region->tileDataSize, region->flags, region->numQuant, region->numProgQuant);
if (!(region->flags & RFX_DWT_REDUCE_EXTRAPOLATE))
{
WLog_WARN(TAG, "RFX_DWT_REDUCE_EXTRAPOLATE is not set");
}
boxLeft = surface->gridWidth;
boxTop = surface->gridHeight;
boxRight = 0;
boxBottom = 0;
for (index = 0; index < region->numRects; index++)
{
rect = &(region->rects[index]);
idxLeft = rect->x / 64;
idxTop = rect->y / 64;
idxRight = (rect->x + rect->width + 63) / 64;
idxBottom = (rect->y + rect->height + 63) / 64;
if (idxLeft < boxLeft)
boxLeft = idxLeft;
if (idxTop < boxTop)
boxTop = idxTop;
if (idxRight > boxRight)
boxRight = idxRight;
if (idxBottom > boxBottom)
boxBottom = idxBottom;
WLog_DBG(TAG, "rect[%d]: x: %d y: %d w: %d h: %d",
index, rect->x, rect->y, rect->width, rect->height);
}
status = progressive_process_tiles(progressive, &block[boffset], region->tileDataSize, surface);
if (status < 0)
return status;
region->numTiles = 0;
for (index = 0; index < surface->gridSize; index++)
{
RFX_PROGRESSIVE_TILE* tile = &(surface->tiles[index]);
if (!tile->data)
continue;
if ((tile->xIdx < boxLeft) || (tile->xIdx > boxRight))
continue;
if ((tile->yIdx < boxTop) || (tile->yIdx > boxBottom))
continue;
region->tiles[region->numTiles++] = tile;
}
boffset += (UINT32) status;
break;
@ -1817,8 +1895,6 @@ PROGRESSIVE_CONTEXT* progressive_context_new(BOOL Compressor)
{
progressive->Compressor = Compressor;
progressive->log = WLog_Get(TAG);
progressive->bufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16);
progressive->cRects = 64;

View File

@ -40,6 +40,11 @@
#include <fcntl.h>
#endif
#ifdef __APPLE__
#define WSAIOCTL_IFADDRS
#include <ifaddrs.h>
#endif
/**
* ws2_32.dll:
*
@ -707,6 +712,103 @@ int WSAIoctl(SOCKET s, DWORD dwIoControlCode, LPVOID lpvInBuffer,
pInterfaces = (INTERFACE_INFO*) lpvOutBuffer;
maxNumInterfaces = cbOutBuffer / sizeof(INTERFACE_INFO);
#ifdef WSAIOCTL_IFADDRS
{
struct ifaddrs* ifa = NULL;
struct ifaddrs* ifap = NULL;
if (getifaddrs(&ifap) != 0)
{
WSASetLastError(WSAENETDOWN);
return SOCKET_ERROR;
}
index = 0;
numInterfaces = 0;
for (ifa = ifap; ifa; ifa = ifa->ifa_next)
{
pInterface = &pInterfaces[index];
pAddress = (struct sockaddr_in*) &pInterface->iiAddress;
pBroadcast = (struct sockaddr_in*) &pInterface->iiBroadcastAddress;
pNetmask = (struct sockaddr_in*) &pInterface->iiNetmask;
nFlags = 0;
if (ifa->ifa_flags & IFF_UP)
nFlags |= _IFF_UP;
if (ifa->ifa_flags & IFF_BROADCAST)
nFlags |= _IFF_BROADCAST;
if (ifa->ifa_flags & IFF_LOOPBACK)
nFlags |= _IFF_LOOPBACK;
if (ifa->ifa_flags & IFF_POINTOPOINT)
nFlags |= _IFF_POINTTOPOINT;
if (ifa->ifa_flags & IFF_MULTICAST)
nFlags |= _IFF_MULTICAST;
pInterface->iiFlags = nFlags;
if (ifa->ifa_addr)
{
if ((ifa->ifa_addr->sa_family != AF_INET) && (ifa->ifa_addr->sa_family != AF_INET6))
continue;
getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr),
address, sizeof(address), 0, 0, NI_NUMERICHOST);
inet_pton(ifa->ifa_addr->sa_family, address, (void*) &pAddress->sin_addr);
}
else
{
ZeroMemory(pAddress, sizeof(struct sockaddr_in));
}
if (ifa->ifa_dstaddr)
{
if ((ifa->ifa_dstaddr->sa_family != AF_INET) && (ifa->ifa_dstaddr->sa_family != AF_INET6))
continue;
getnameinfo(ifa->ifa_dstaddr, sizeof(struct sockaddr),
broadcast, sizeof(broadcast), 0, 0, NI_NUMERICHOST);
inet_pton(ifa->ifa_dstaddr->sa_family, broadcast, (void*) &pBroadcast->sin_addr);
}
else
{
ZeroMemory(pBroadcast, sizeof(struct sockaddr_in));
}
if (ifa->ifa_netmask)
{
if ((ifa->ifa_netmask->sa_family != AF_INET) && (ifa->ifa_netmask->sa_family != AF_INET6))
continue;
getnameinfo(ifa->ifa_netmask, sizeof(struct sockaddr),
netmask, sizeof(netmask), 0, 0, NI_NUMERICHOST);
inet_pton(ifa->ifa_netmask->sa_family, netmask, (void*) &pNetmask->sin_addr);
}
else
{
ZeroMemory(pNetmask, sizeof(struct sockaddr_in));
}
numInterfaces++;
index++;
}
*lpcbBytesReturned = (DWORD) (numInterfaces * sizeof(INTERFACE_INFO));
freeifaddrs(ifap);
return 0;
}
#endif
ifconf.ifc_len = sizeof(buffer);
ifconf.ifc_buf = buffer;