Skip to content

Commit

Permalink
rfx: rename pixel format constants.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vic Lee committed Mar 13, 2012
1 parent d1b32a7 commit b74d324
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 44 deletions.
6 changes: 3 additions & 3 deletions cunit/test_rfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void test_decode(void)

context = rfx_context_new();
context->mode = RLGR3;
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);
rfx_decode_rgb(context, s,
sizeof(y_data), test_quantization_values,
sizeof(cb_data), test_quantization_values,
Expand Down Expand Up @@ -336,7 +336,7 @@ void test_encode(void)

context = rfx_context_new();
context->mode = RLGR3;
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);

rfx_encode_rgb(context, rgb_data, 64, 64, 64 * 3,
test_quantization_values, test_quantization_values, test_quantization_values,
Expand Down Expand Up @@ -382,7 +382,7 @@ void test_message(void)
context->mode = RLGR3;
context->width = 800;
context->height = 600;
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_R8G8B8);

for (i = 0; i < 1000; i++)
{
Expand Down
18 changes: 3 additions & 15 deletions include/freerdp/codec/rfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <freerdp/api.h>
#include <freerdp/types.h>
#include <freerdp/constants.h>
#include <freerdp/utils/stream.h>

#ifdef __cplusplus
Expand All @@ -35,19 +36,6 @@ enum _RLGR_MODE
};
typedef enum _RLGR_MODE RLGR_MODE;

enum _RFX_PIXEL_FORMAT
{
RFX_PIXEL_FORMAT_BGRA,
RFX_PIXEL_FORMAT_RGBA,
RFX_PIXEL_FORMAT_BGR,
RFX_PIXEL_FORMAT_RGB,
RFX_PIXEL_FORMAT_BGR565_LE,
RFX_PIXEL_FORMAT_RGB565_LE,
RFX_PIXEL_FORMAT_PALETTE4_PLANER,
RFX_PIXEL_FORMAT_PALETTE8
};
typedef enum _RFX_PIXEL_FORMAT RFX_PIXEL_FORMAT;

struct _RFX_RECT
{
uint16 x;
Expand Down Expand Up @@ -97,7 +85,7 @@ struct _RFX_CONTEXT
uint32 version;
uint32 codec_id;
uint32 codec_version;
RFX_PIXEL_FORMAT pixel_format;
RDP_PIXEL_FORMAT pixel_format;
uint8 bits_per_pixel;

/* color palette allocated by the application */
Expand Down Expand Up @@ -128,7 +116,7 @@ typedef struct _RFX_CONTEXT RFX_CONTEXT;
FREERDP_API RFX_CONTEXT* rfx_context_new(void);
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
FREERDP_API void rfx_context_set_cpu_opt(RFX_CONTEXT* context, uint32 cpu_opt);
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_format);
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format);
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);

FREERDP_API RFX_MESSAGE* rfx_process_message(RFX_CONTEXT* context, uint8* data, uint32 length);
Expand Down
16 changes: 16 additions & 0 deletions include/freerdp/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ enum RDP_SVC_CHANNEL_EVENT
CHANNEL_EVENT_USER = 1000
};

/**
* Pixel format
*/
enum RDP_PIXEL_FORMAT
{
RDP_PIXEL_FORMAT_B8G8R8A8,
RDP_PIXEL_FORMAT_R8G8B8A8,
RDP_PIXEL_FORMAT_B8G8R8,
RDP_PIXEL_FORMAT_R8G8B8,
RDP_PIXEL_FORMAT_B5G6R5_LE,
RDP_PIXEL_FORMAT_R5G6B5_LE,
RDP_PIXEL_FORMAT_P4_PLANER,
RDP_PIXEL_FORMAT_P8
};
typedef enum RDP_PIXEL_FORMAT RDP_PIXEL_FORMAT;

/**
* Virtual Channel Constants
*/
Expand Down
20 changes: 10 additions & 10 deletions libfreerdp-codec/rfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ RFX_CONTEXT* rfx_context_new(void)
context->priv->pool = rfx_pool_new();

/* initialize the default pixel format */
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_BGRA);
rfx_context_set_pixel_format(context, RDP_PIXEL_FORMAT_B8G8R8A8);

/* align buffers to 16 byte boundary (needed for SSE/SSE2 instructions) */
context->priv->y_r_buffer = (sint16*)(((uintptr_t)context->priv->y_r_mem + 16) & ~ 0x0F);
Expand Down Expand Up @@ -181,27 +181,27 @@ void rfx_context_free(RFX_CONTEXT* context)
xfree(context);
}

void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_format)
void rfx_context_set_pixel_format(RFX_CONTEXT* context, RDP_PIXEL_FORMAT pixel_format)
{
context->pixel_format = pixel_format;
switch (pixel_format)
{
case RFX_PIXEL_FORMAT_BGRA:
case RFX_PIXEL_FORMAT_RGBA:
case RDP_PIXEL_FORMAT_B8G8R8A8:
case RDP_PIXEL_FORMAT_R8G8B8A8:
context->bits_per_pixel = 32;
break;
case RFX_PIXEL_FORMAT_BGR:
case RFX_PIXEL_FORMAT_RGB:
case RDP_PIXEL_FORMAT_B8G8R8:
case RDP_PIXEL_FORMAT_R8G8B8:
context->bits_per_pixel = 24;
break;
case RFX_PIXEL_FORMAT_BGR565_LE:
case RFX_PIXEL_FORMAT_RGB565_LE:
case RDP_PIXEL_FORMAT_B5G6R5_LE:
case RDP_PIXEL_FORMAT_R5G6B5_LE:
context->bits_per_pixel = 16;
break;
case RFX_PIXEL_FORMAT_PALETTE4_PLANER:
case RDP_PIXEL_FORMAT_P4_PLANER:
context->bits_per_pixel = 4;
break;
case RFX_PIXEL_FORMAT_PALETTE8:
case RDP_PIXEL_FORMAT_P8:
context->bits_per_pixel = 8;
break;
default:
Expand Down
10 changes: 5 additions & 5 deletions libfreerdp-codec/rfx_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "rfx_decode.h"

static void rfx_decode_format_rgb(sint16* r_buf, sint16* g_buf, sint16* b_buf,
RFX_PIXEL_FORMAT pixel_format, uint8* dst_buf)
RDP_PIXEL_FORMAT pixel_format, uint8* dst_buf)
{
sint16* r = r_buf;
sint16* g = g_buf;
Expand All @@ -41,7 +41,7 @@ static void rfx_decode_format_rgb(sint16* r_buf, sint16* g_buf, sint16* b_buf,

switch (pixel_format)
{
case RFX_PIXEL_FORMAT_BGRA:
case RDP_PIXEL_FORMAT_B8G8R8A8:
for (i = 0; i < 4096; i++)
{
*dst++ = (uint8) (*b++);
Expand All @@ -50,7 +50,7 @@ static void rfx_decode_format_rgb(sint16* r_buf, sint16* g_buf, sint16* b_buf,
*dst++ = 0xFF;
}
break;
case RFX_PIXEL_FORMAT_RGBA:
case RDP_PIXEL_FORMAT_R8G8B8A8:
for (i = 0; i < 4096; i++)
{
*dst++ = (uint8) (*r++);
Expand All @@ -59,15 +59,15 @@ static void rfx_decode_format_rgb(sint16* r_buf, sint16* g_buf, sint16* b_buf,
*dst++ = 0xFF;
}
break;
case RFX_PIXEL_FORMAT_BGR:
case RDP_PIXEL_FORMAT_B8G8R8:
for (i = 0; i < 4096; i++)
{
*dst++ = (uint8) (*b++);
*dst++ = (uint8) (*g++);
*dst++ = (uint8) (*r++);
}
break;
case RFX_PIXEL_FORMAT_RGB:
case RDP_PIXEL_FORMAT_R8G8B8:
for (i = 0; i < 4096; i++)
{
*dst++ = (uint8) (*r++);
Expand Down
18 changes: 9 additions & 9 deletions libfreerdp-codec/rfx_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define MINMAX(_v,_l,_h) ((_v) < (_l) ? (_l) : ((_v) > (_h) ? (_h) : (_v)))

static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height, int rowstride,
RFX_PIXEL_FORMAT pixel_format, const uint8* palette, sint16* r_buf, sint16* g_buf, sint16* b_buf)
RDP_PIXEL_FORMAT pixel_format, const uint8* palette, sint16* r_buf, sint16* g_buf, sint16* b_buf)
{
int x, y;
int x_exceed;
Expand All @@ -50,7 +50,7 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,

switch (pixel_format)
{
case RFX_PIXEL_FORMAT_BGRA:
case RDP_PIXEL_FORMAT_B8G8R8A8:
for (x = 0; x < width; x++)
{
*b_buf++ = (sint16) (*src++);
Expand All @@ -59,7 +59,7 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
src++;
}
break;
case RFX_PIXEL_FORMAT_RGBA:
case RDP_PIXEL_FORMAT_R8G8B8A8:
for (x = 0; x < width; x++)
{
*r_buf++ = (sint16) (*src++);
Expand All @@ -68,23 +68,23 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
src++;
}
break;
case RFX_PIXEL_FORMAT_BGR:
case RDP_PIXEL_FORMAT_B8G8R8:
for (x = 0; x < width; x++)
{
*b_buf++ = (sint16) (*src++);
*g_buf++ = (sint16) (*src++);
*r_buf++ = (sint16) (*src++);
}
break;
case RFX_PIXEL_FORMAT_RGB:
case RDP_PIXEL_FORMAT_R8G8B8:
for (x = 0; x < width; x++)
{
*r_buf++ = (sint16) (*src++);
*g_buf++ = (sint16) (*src++);
*b_buf++ = (sint16) (*src++);
}
break;
case RFX_PIXEL_FORMAT_BGR565_LE:
case RDP_PIXEL_FORMAT_B5G6R5_LE:
for (x = 0; x < width; x++)
{
*b_buf++ = (sint16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
Expand All @@ -93,7 +93,7 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
src += 2;
}
break;
case RFX_PIXEL_FORMAT_RGB565_LE:
case RDP_PIXEL_FORMAT_R5G6B5_LE:
for (x = 0; x < width; x++)
{
*r_buf++ = (sint16) (((*(src + 1)) & 0xF8) | ((*(src + 1)) >> 5));
Expand All @@ -102,7 +102,7 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
src += 2;
}
break;
case RFX_PIXEL_FORMAT_PALETTE4_PLANER:
case RDP_PIXEL_FORMAT_P4_PLANER:
if (!palette)
break;
for (x = 0; x < width; x++)
Expand All @@ -123,7 +123,7 @@ static void rfx_encode_format_rgb(const uint8* rgb_data, int width, int height,
src += 4;
}
break;
case RFX_PIXEL_FORMAT_PALETTE8:
case RDP_PIXEL_FORMAT_P8:
if (!palette)
break;
for (x = 0; x < width; x++)
Expand Down
2 changes: 1 addition & 1 deletion server/X11/xf_peer.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context)
context->rfx_context->width = context->info->width;
context->rfx_context->height = context->info->height;

rfx_context_set_pixel_format(context->rfx_context, RFX_PIXEL_FORMAT_BGRA);
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);

context->s = stream_new(65536);
}
Expand Down
2 changes: 1 addition & 1 deletion server/test/tfreerdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void test_peer_context_new(freerdp_peer* client, testPeerContext* context)
context->rfx_context->mode = RLGR3;
context->rfx_context->width = client->settings->width;
context->rfx_context->height = client->settings->height;
rfx_context_set_pixel_format(context->rfx_context, RFX_PIXEL_FORMAT_RGB);
rfx_context_set_pixel_format(context->rfx_context, RDP_PIXEL_FORMAT_R8G8B8);

context->s = stream_new(65536);

Expand Down

0 comments on commit b74d324

Please sign in to comment.