rfx_dwt.h
rfx_encode.c
rfx_encode.h
- rfx_pool.c
- rfx_pool.h
rfx_quantization.c
rfx_quantization.h
rfx_rlgr.c
MONOLITHIC ${MONOLITHIC_BUILD} INTERNAL
MODULE freerdp
MODULES freerdp-primitives freerdp-utils)
-
-message(STATUS "libfreerdp-codec libs: ${${MODULE_PREFIX}_LIBS}")
+
+set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
+ MONOLITHIC ${MONOLITHIC_BUILD}
+ MODULE winpr
+ MODULES winpr-crt winpr-utils)
if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
#include "rfx_constants.h"
#include "rfx_types.h"
-#include "rfx_pool.h"
#include "rfx_decode.h"
#include "rfx_encode.h"
#include "rfx_quantization.h"
context->priv = (RFX_CONTEXT_PRIV*) malloc(sizeof(RFX_CONTEXT_PRIV));
ZeroMemory(context->priv, sizeof(RFX_CONTEXT_PRIV));
- context->priv->pool = rfx_pool_new();
+ context->priv->TilePool = Queue_New(TRUE, -1, -1);
+ context->priv->TileQueue = Queue_New(TRUE, -1, -1);
/* initialize the default pixel format */
rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_B8G8R8A8);
{
free(context->quants);
- rfx_pool_free(context->priv->pool);
+ Queue_Free(context->priv->TilePool);
+ Queue_Free(context->priv->TileQueue);
rfx_profiler_print(context);
rfx_profiler_free(context);
void rfx_context_set_pixel_format(RFX_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format)
{
context->pixel_format = pixel_format;
+
switch (pixel_format)
{
case RDP_PIXEL_FORMAT_B8G8R8A8:
context->frame_idx = 0;
}
+RFX_TILE* rfx_tile_pool_take(RFX_CONTEXT* context)
+{
+ RFX_TILE* tile = NULL;
+
+ if (WaitForSingleObject(Queue_Event(context->priv->TilePool), 0) == WAIT_OBJECT_0)
+ tile = Queue_Dequeue(context->priv->TilePool);
+
+ if (!tile)
+ {
+ tile = (RFX_TILE*) malloc(sizeof(RFX_TILE));
+
+ tile->x = tile->y = 0;
+ tile->data = (BYTE*) malloc(4096 * 4); /* 64x64 * 4 */
+ }
+
+ return tile;
+}
+
+int rfx_tile_pool_return(RFX_CONTEXT* context, RFX_TILE* tile)
+{
+ Queue_Enqueue(context->priv->TilePool, tile);
+ return 0;
+}
+
static void rfx_process_message_sync(RFX_CONTEXT* context, STREAM* s)
{
UINT32 magic;
YLen, context->quants + (quantIdxY * 10),
CbLen, context->quants + (quantIdxCb * 10),
CrLen, context->quants + (quantIdxCr * 10),
- tile->data, 64*sizeof(UINT32));
+ tile->data, 64 * sizeof(UINT32));
}
static void rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* message, STREAM* s)
context->quants[i * 10 + 8], context->quants[i * 10 + 9]);
}
- message->tiles = rfx_pool_get_tiles(context->priv->pool, message->num_tiles);
+ message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * message->num_tiles);
+ ZeroMemory(message->tiles, sizeof(RFX_TILE*) * message->num_tiles);
/* tiles */
for (i = 0; i < message->num_tiles; i++)
break;
}
+ message->tiles[i] = rfx_tile_pool_take(context);
rfx_process_message_tile(context, message->tiles[i], s);
stream_set_pos(s, pos);
void rfx_message_free(RFX_CONTEXT* context, RFX_MESSAGE* message)
{
+ int i;
+
if (message != NULL)
{
free(message->rects);
- if (message->tiles != NULL)
+ if (message->tiles)
{
- rfx_pool_put_tiles(context->priv->pool, message->tiles, message->num_tiles);
+ for (i = 0; i < message->num_tiles; i++)
+ rfx_tile_pool_return(context, message->tiles[i]);
+
free(message->tiles);
}
static void rfx_compose_message_tileset(RFX_CONTEXT* context, STREAM* s,
BYTE* image_data, int width, int height, int rowstride)
{
+ int i;
int size;
int start_pos, end_pos;
- int i;
int numQuants;
const UINT32* quantVals;
const UINT32* quantValsPtr;
+++ /dev/null
-/**
- * FreeRDP: A Remote Desktop Protocol Implementation
- * RemoteFX Codec Library - Memory Pool
- *
- * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
- *
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <winpr/crt.h>
-
-#include "rfx_pool.h"
-
-RFX_POOL* rfx_pool_new()
-{
- RFX_POOL* pool;
-
- pool = (RFX_POOL*) malloc(sizeof(RFX_POOL));
- ZeroMemory(pool, sizeof(RFX_POOL));
-
- pool->size = 64;
- pool->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * pool->size);
- ZeroMemory(pool->tiles, sizeof(RFX_TILE*) * pool->size);
-
- return pool;
-}
-
-void rfx_pool_free(RFX_POOL* pool)
-{
- int i;
- RFX_TILE* tile;
-
- for (i = 0; i < pool->count; i++)
- {
- tile = pool->tiles[i];
-
- if (tile != NULL)
- {
- if (tile->data != NULL)
- free(tile->data);
-
- free(tile);
- }
- }
-
- free(pool->tiles);
- free(pool);
-}
-
-void rfx_pool_put_tile(RFX_POOL* pool, RFX_TILE* tile)
-{
- if (pool->count >= pool->size)
- {
- pool->size *= 2;
- pool->tiles = (RFX_TILE**) realloc((void*) pool->tiles, sizeof(RFX_TILE*) * pool->size);
- }
-
- pool->tiles[(pool->count)++] = tile;
-}
-
-RFX_TILE* rfx_pool_get_tile(RFX_POOL* pool)
-{
- RFX_TILE* tile;
-
- if (pool->count < 1)
- {
- tile = (RFX_TILE*) malloc(sizeof(RFX_TILE));
- ZeroMemory(tile, sizeof(RFX_TILE));
-
- tile->data = (BYTE*) malloc(4096 * 4); /* 64x64 * 4 */
- }
- else
- {
- tile = pool->tiles[--(pool->count)];
- }
-
- return tile;
-}
-
-void rfx_pool_put_tiles(RFX_POOL* pool, RFX_TILE** tiles, int count)
-{
- int i;
-
- for (i = 0; i < count; i++)
- {
- rfx_pool_put_tile(pool, tiles[i]);
- }
-}
-
-RFX_TILE** rfx_pool_get_tiles(RFX_POOL* pool, int count)
-{
- int i;
- RFX_TILE** tiles;
-
- tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * count);
-
- for (i = 0; i < count; i++)
- {
- tiles[i] = rfx_pool_get_tile(pool);
- }
-
- return tiles;
-}
+++ /dev/null
-/**
- * FreeRDP: A Remote Desktop Protocol Implementation
- * RemoteFX Codec Library - Memory Pool
- *
- * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
- *
- * 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 __RFX_POOL_H
-#define __RFX_POOL_H
-
-#include <freerdp/codec/rfx.h>
-
-struct _RFX_POOL
-{
- int size;
- int count;
- RFX_TILE** tiles;
-};
-typedef struct _RFX_POOL RFX_POOL;
-
-RFX_POOL* rfx_pool_new();
-void rfx_pool_free(RFX_POOL* pool);
-void rfx_pool_put_tile(RFX_POOL* pool, RFX_TILE* tile);
-RFX_TILE* rfx_pool_get_tile(RFX_POOL* pool);
-void rfx_pool_put_tiles(RFX_POOL* pool, RFX_TILE** tiles, int count);
-RFX_TILE** rfx_pool_get_tiles(RFX_POOL* pool, int count);
-
-#endif /* __RFX_POOL_H */
#include "config.h"
#endif
+#include <winpr/crt.h>
+#include <winpr/collections.h>
+
#include <freerdp/utils/debug.h>
#include <freerdp/utils/profiler.h>
#define DEBUG_RFX(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
#endif
-#include "rfx_pool.h"
-
struct _RFX_CONTEXT_PRIV
{
/* pre-allocated buffers */
- RFX_POOL* pool; /* memory pool */
+ wQueue* TilePool;
+ wQueue* TileQueue;
INT16 y_r_mem[4096 + 8]; /* 4096 = 64x64 (+ 8x2 = 16 for mem align) */
INT16 cb_g_mem[4096 + 8]; /* 4096 = 64x64 (+ 8x2 = 16 for mem align) */
if (queue->size == queue->capacity)
{
- queue->capacity *= queue->growthFactor;
+ int old_capacity;
+ int new_capacity;
+
+ old_capacity = queue->capacity;
+ new_capacity = queue->capacity * queue->growthFactor;
+
+ queue->capacity = new_capacity;
queue->array = (void**) realloc(queue->array, sizeof(void*) * queue->capacity);
+ ZeroMemory(&(queue->array[old_capacity]), old_capacity * sizeof(void*));
+
+ if (queue->tail < (old_capacity - 1))
+ {
+ CopyMemory(&(queue->array[old_capacity]), queue->array, queue->tail * sizeof(void*));
+ queue->tail += old_capacity;
+ }
}
queue->array[queue->tail] = obj;
}
count = Queue_Count(queue);
-
printf("queue count: %d\n", count);
for (index = 1; index <= 10; index++)
return -1;
}
+ count = Queue_Count(queue);
+ printf("queue count: %d\n", count);
+
+ Queue_Enqueue(queue, (void*) (size_t) 1);
+ Queue_Enqueue(queue, (void*) (size_t) 2);
+ Queue_Enqueue(queue, (void*) (size_t) 3);
+
+ Queue_Dequeue(queue);
+ Queue_Dequeue(queue);
+
+ Queue_Enqueue(queue, (void*) (size_t) 4);
+ Queue_Enqueue(queue, (void*) (size_t) 5);
+ Queue_Enqueue(queue, (void*) (size_t) 6);
+
+ Queue_Dequeue(queue);
+ Queue_Dequeue(queue);
+ Queue_Dequeue(queue);
+ Queue_Dequeue(queue);
+
Queue_Clear(queue);
Queue_Free(queue);