Hi Marc,I just saw another memory allocation can be completely eliminated and should have big improvement. Please try attach patch.
Vic On 06/07/2011 07:57 AM, Marc-André Moreau wrote:
And boom, here's a memory pool for RemoteFX tiles :P (my last commit) It can play youtube videos when not in fullscreen mode very smoothly, I don't recall if that was the case prior to optimizations though. In all cases, it does feel much better. There are still others places that need optimizations.
>From 87f7198c830436ce409fd71129453b001a640134 Mon Sep 17 00:00:00 2001 From: Vic Lee <ll...@163.com> Date: Tue, 7 Jun 2011 20:47:28 +0800 Subject: [PATCH] libfreerdp-rfx: remove memory allocation in bitstream module. Signed-off-by: Vic Lee <ll...@163.com> --- libfreerdp-rfx/rfx_bitstream.c | 10 +++------- libfreerdp-rfx/rfx_bitstream.h | 4 ++-- libfreerdp-rfx/rfx_rlgr.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/libfreerdp-rfx/rfx_bitstream.c b/libfreerdp-rfx/rfx_bitstream.c index a4ff74a..ce741fc 100644 --- a/libfreerdp-rfx/rfx_bitstream.c +++ b/libfreerdp-rfx/rfx_bitstream.c @@ -35,10 +35,9 @@ rfx_bitstream_new(void) } void -rfx_bitstream_put_bytes(RFX_BITSTREAM * bs, const uint8 * bytes, int nbytes) +rfx_bitstream_put_buffer(RFX_BITSTREAM * bs, uint8 * buffer, int nbytes) { - bs->bytes = (uint8*) malloc(nbytes); - memcpy(bs->bytes, bytes, nbytes); + bs->buffer = buffer; bs->nbytes = nbytes; bs->byte_pos = 0; bs->bits_left = 8; @@ -60,7 +59,7 @@ rfx_bitstream_get_bits(RFX_BITSTREAM * bs, int nbits) if (n) n <<= b; - n |= (bs->bytes[bs->byte_pos] >> (bs->bits_left - b)) & ((1 << b) - 1); + n |= (bs->buffer[bs->byte_pos] >> (bs->bits_left - b)) & ((1 << b) - 1); bs->bits_left -= b; nbits -= b; @@ -94,9 +93,6 @@ rfx_bitstream_free(RFX_BITSTREAM * bs) { if (bs != NULL) { - if (bs->bytes != NULL) - free(bs->bytes); - free(bs); } } diff --git a/libfreerdp-rfx/rfx_bitstream.h b/libfreerdp-rfx/rfx_bitstream.h index f95146c..93d12b7 100644 --- a/libfreerdp-rfx/rfx_bitstream.h +++ b/libfreerdp-rfx/rfx_bitstream.h @@ -24,7 +24,7 @@ struct _RFX_BITSTREAM { - uint8 * bytes; + uint8 * buffer; int nbytes; int byte_pos; int bits_left; @@ -34,7 +34,7 @@ typedef struct _RFX_BITSTREAM RFX_BITSTREAM; RFX_BITSTREAM * rfx_bitstream_new(void); void -rfx_bitstream_put_bytes(RFX_BITSTREAM * bs, const uint8 * bytes, int nbytes); +rfx_bitstream_put_buffer(RFX_BITSTREAM * bs, uint8 * buffer, int nbytes); unsigned int rfx_bitstream_get_bits(RFX_BITSTREAM * bs, int nbits); int diff --git a/libfreerdp-rfx/rfx_rlgr.c b/libfreerdp-rfx/rfx_rlgr.c index 7dfd7c7..9801b21 100644 --- a/libfreerdp-rfx/rfx_rlgr.c +++ b/libfreerdp-rfx/rfx_rlgr.c @@ -131,7 +131,7 @@ rfx_rlgr_decode(RLGR_MODE mode, const uint8 * data, int data_size, uint32 * buff RFX_BITSTREAM * bs; bs = rfx_bitstream_new(); - rfx_bitstream_put_bytes(bs, data, data_size); + rfx_bitstream_put_buffer(bs, (uint8 *) data, data_size); dst = buffer; /* initialize the parameters */ -- 1.7.4.4
------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________ Freerdp-devel mailing list Freerdp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freerdp-devel