mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 08:24:16 +09:00
codec: use the CODEC_ID_* names instead of magic numbers
This commit is contained in:
@@ -107,7 +107,8 @@ void xf_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
||||
}
|
||||
|
||||
void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* data, int width, int height, int bpp, int length, int compressed)
|
||||
uint8* data, int width, int height, int bpp, int length,
|
||||
boolean compressed, int codec_id)
|
||||
{
|
||||
uint16 size;
|
||||
RFX_MESSAGE* msg;
|
||||
@@ -115,6 +116,8 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* dst;
|
||||
int yindex;
|
||||
int xindex;
|
||||
xfInfo* xfi;
|
||||
boolean status;
|
||||
|
||||
size = width * height * (bpp + 7) / 8;
|
||||
|
||||
@@ -123,57 +126,57 @@ void xf_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
else
|
||||
bitmap->data = (uint8*) xrealloc(bitmap->data, size);
|
||||
|
||||
if (compressed == 4)
|
||||
switch (codec_id)
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: nsc not done\n");
|
||||
}
|
||||
else if (compressed == 3)
|
||||
{
|
||||
xfInfo* xfi = ((xfContext*)context)->xfi;
|
||||
rfx_context_set_pixel_format(xfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
msg = rfx_process_message(xfi->rfx_context, data, length);
|
||||
if (msg == NULL)
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: rfx Decompression Failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (yindex = 0; yindex < height; yindex++)
|
||||
case CODEC_ID_NSCODEC:
|
||||
printf("xf_Bitmap_Decompress: nsc not done\n");
|
||||
break;
|
||||
case CODEC_ID_REMOTEFX:
|
||||
xfi = ((xfContext*)context)->xfi;
|
||||
rfx_context_set_pixel_format(xfi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
msg = rfx_process_message(xfi->rfx_context, data, length);
|
||||
if (msg == NULL)
|
||||
{
|
||||
src = msg->tiles[0]->data + yindex * 64 * 4;
|
||||
dst = bitmap->data + yindex * width * 3;
|
||||
for (xindex = 0; xindex < width; xindex++)
|
||||
printf("xf_Bitmap_Decompress: rfx Decompression Failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (yindex = 0; yindex < height; yindex++)
|
||||
{
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
src++;
|
||||
src = msg->tiles[0]->data + yindex * 64 * 4;
|
||||
dst = bitmap->data + yindex * width * 3;
|
||||
for (xindex = 0; xindex < width; xindex++)
|
||||
{
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
src++;
|
||||
}
|
||||
}
|
||||
rfx_message_free(xfi->rfx_context, msg);
|
||||
}
|
||||
break;
|
||||
case CODEC_ID_JPEG:
|
||||
if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp))
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: jpeg Decompression Failed\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (compressed)
|
||||
{
|
||||
status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
|
||||
|
||||
if (status == false)
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: Bitmap Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
rfx_message_free(xfi->rfx_context, msg);
|
||||
}
|
||||
}
|
||||
else if (compressed == 2)
|
||||
{
|
||||
if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp))
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: jpeg Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
else if (compressed == 1)
|
||||
{
|
||||
boolean status;
|
||||
|
||||
status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
|
||||
|
||||
if (status == false)
|
||||
{
|
||||
printf("xf_Bitmap_Decompress: Bitmap Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freerdp_image_flip(data, bitmap->data, width, height, bpp);
|
||||
else
|
||||
{
|
||||
freerdp_image_flip(data, bitmap->data, width, height, bpp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
bitmap->compressed = false;
|
||||
|
||||
@@ -35,7 +35,8 @@ typedef void (*pBitmap_New)(rdpContext* context, rdpBitmap* bitmap);
|
||||
typedef void (*pBitmap_Free)(rdpContext* context, rdpBitmap* bitmap);
|
||||
typedef void (*pBitmap_Paint)(rdpContext* context, rdpBitmap* bitmap);
|
||||
typedef void (*pBitmap_Decompress)(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* data, int width, int height, int bpp, int length, int compressed);
|
||||
uint8* data, int width, int height, int bpp, int length,
|
||||
boolean compressed, int codec_id);
|
||||
typedef void (*pBitmap_SetSurface)(rdpContext* context, rdpBitmap* bitmap, boolean primary);
|
||||
|
||||
struct rdp_bitmap
|
||||
|
||||
@@ -75,7 +75,8 @@ void update_gdi_cache_bitmap(rdpContext* context, CACHE_BITMAP_ORDER* cache_bitm
|
||||
|
||||
bitmap->Decompress(context, bitmap,
|
||||
cache_bitmap->bitmapDataStream, cache_bitmap->bitmapWidth, cache_bitmap->bitmapHeight,
|
||||
cache_bitmap->bitmapBpp, cache_bitmap->bitmapLength, cache_bitmap->compressed);
|
||||
cache_bitmap->bitmapBpp, cache_bitmap->bitmapLength,
|
||||
cache_bitmap->compressed, CODEC_ID_NONE);
|
||||
|
||||
bitmap->New(context, bitmap);
|
||||
|
||||
@@ -103,18 +104,10 @@ void update_gdi_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cach
|
||||
cache_bitmap_v2->bitmapBpp = context->instance->settings->color_depth;
|
||||
}
|
||||
|
||||
if (cache_bitmap_v2->compressed && (cache_bitmap_v2->flags & 0x80))
|
||||
{
|
||||
bitmap->Decompress(context, bitmap,
|
||||
cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapWidth, cache_bitmap_v2->bitmapHeight,
|
||||
cache_bitmap_v2->bitmapBpp, cache_bitmap_v2->bitmapLength, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bitmap->Decompress(context, bitmap,
|
||||
cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapWidth, cache_bitmap_v2->bitmapHeight,
|
||||
cache_bitmap_v2->bitmapBpp, cache_bitmap_v2->bitmapLength, cache_bitmap_v2->compressed);
|
||||
}
|
||||
bitmap->Decompress(context, bitmap,
|
||||
cache_bitmap_v2->bitmapDataStream, cache_bitmap_v2->bitmapWidth, cache_bitmap_v2->bitmapHeight,
|
||||
cache_bitmap_v2->bitmapBpp, cache_bitmap_v2->bitmapLength,
|
||||
cache_bitmap_v2->compressed, CODEC_ID_NONE);
|
||||
|
||||
bitmap->New(context, bitmap);
|
||||
|
||||
@@ -132,7 +125,6 @@ void update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cach
|
||||
rdpBitmap* prevBitmap;
|
||||
rdpCache* cache = context->cache;
|
||||
BITMAP_DATA_EX* bitmapData = &cache_bitmap_v3->bitmapData;
|
||||
boolean compression;
|
||||
|
||||
bitmap = Bitmap_Alloc(context);
|
||||
|
||||
@@ -144,25 +136,10 @@ void update_gdi_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cach
|
||||
cache_bitmap_v3->bitmapData.bpp = context->instance->settings->color_depth;
|
||||
}
|
||||
|
||||
switch (bitmapData->codecID)
|
||||
{
|
||||
case CODEC_ID_JPEG:
|
||||
compression = 2;
|
||||
break;
|
||||
case CODEC_ID_REMOTEFX:
|
||||
compression = 3;
|
||||
break;
|
||||
case CODEC_ID_NSCODEC:
|
||||
compression = 4;
|
||||
break;
|
||||
default:
|
||||
compression = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
bitmap->Decompress(context, bitmap,
|
||||
bitmapData->data, bitmap->width, bitmap->height,
|
||||
bitmapData->bpp, bitmapData->length, compression);
|
||||
bitmapData->bpp, bitmapData->length, true,
|
||||
bitmapData->codecID);
|
||||
|
||||
bitmap->New(context, bitmap);
|
||||
|
||||
@@ -207,7 +184,8 @@ void update_gdi_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap_update)
|
||||
|
||||
bitmap->Decompress(context, bitmap,
|
||||
bitmap_data->bitmapDataStream, bitmap_data->width, bitmap_data->height,
|
||||
bitmap_data->bitsPerPixel, bitmap_data->bitmapLength, bitmap_data->compressed);
|
||||
bitmap_data->bitsPerPixel, bitmap_data->bitmapLength,
|
||||
bitmap_data->compressed, CODEC_ID_NONE);
|
||||
|
||||
if (reused)
|
||||
bitmap->Free(context, bitmap);
|
||||
|
||||
@@ -89,7 +89,8 @@ void gdi_Bitmap_Paint(rdpContext* context, rdpBitmap* bitmap)
|
||||
}
|
||||
|
||||
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* data, int width, int height, int bpp, int length, int compressed)
|
||||
uint8* data, int width, int height, int bpp, int length,
|
||||
boolean compressed, int codec_id)
|
||||
{
|
||||
uint16 size;
|
||||
RFX_MESSAGE* msg;
|
||||
@@ -97,6 +98,8 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* dst;
|
||||
int yindex;
|
||||
int xindex;
|
||||
rdpGdi* gdi;
|
||||
boolean status;
|
||||
|
||||
size = width * height * (bpp + 7) / 8;
|
||||
|
||||
@@ -105,58 +108,57 @@ void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
else
|
||||
bitmap->data = (uint8*) xrealloc(bitmap->data, size);
|
||||
|
||||
if (compressed == 4)
|
||||
switch (codec_id)
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: nsc not done\n");
|
||||
}
|
||||
else if (compressed == 3)
|
||||
{
|
||||
rdpGdi* gdi = context->gdi;
|
||||
rfx_context_set_pixel_format(gdi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
msg = rfx_process_message(gdi->rfx_context, data, length);
|
||||
if (msg == NULL)
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: rfx Decompression Failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (yindex = 0; yindex < height; yindex++)
|
||||
case CODEC_ID_NSCODEC:
|
||||
printf("gdi_Bitmap_Decompress: nsc not done\n");
|
||||
break;
|
||||
case CODEC_ID_REMOTEFX:
|
||||
gdi = context->gdi;
|
||||
rfx_context_set_pixel_format(gdi->rfx_context, RDP_PIXEL_FORMAT_B8G8R8A8);
|
||||
msg = rfx_process_message(gdi->rfx_context, data, length);
|
||||
if (msg == NULL)
|
||||
{
|
||||
src = msg->tiles[0]->data + yindex * 64 * 4;
|
||||
dst = bitmap->data + yindex * width * 3;
|
||||
for (xindex = 0; xindex < width; xindex++)
|
||||
printf("gdi_Bitmap_Decompress: rfx Decompression Failed\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (yindex = 0; yindex < height; yindex++)
|
||||
{
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
src++;
|
||||
src = msg->tiles[0]->data + yindex * 64 * 4;
|
||||
dst = bitmap->data + yindex * width * 3;
|
||||
for (xindex = 0; xindex < width; xindex++)
|
||||
{
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
*(dst++) = *(src++);
|
||||
src++;
|
||||
}
|
||||
}
|
||||
rfx_message_free(gdi->rfx_context, msg);
|
||||
}
|
||||
break;
|
||||
case CODEC_ID_JPEG:
|
||||
if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp))
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: jpeg Decompression Failed\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (compressed)
|
||||
{
|
||||
status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
|
||||
|
||||
if (status == false)
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: Bitmap Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
rfx_message_free(gdi->rfx_context, msg);
|
||||
}
|
||||
}
|
||||
else if (compressed == 2)
|
||||
{
|
||||
if (!jpeg_decompress(data, bitmap->data, width, height, length, bpp))
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: jpeg Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
else if (compressed)
|
||||
{
|
||||
boolean status;
|
||||
|
||||
status = bitmap_decompress(data, bitmap->data, width, height, length, bpp, bpp);
|
||||
|
||||
if (status == false)
|
||||
{
|
||||
printf("gdi_Bitmap_Decompress: Bitmap Decompression Failed\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
freerdp_image_flip(data, bitmap->data, width, height, bpp);
|
||||
|
||||
else
|
||||
{
|
||||
freerdp_image_flip(data, bitmap->data, width, height, bpp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
bitmap->width = width;
|
||||
|
||||
@@ -28,7 +28,8 @@ HGDI_BITMAP gdi_create_bitmap(rdpGdi* gdi, int width, int height, int bpp, uint8
|
||||
void gdi_Bitmap_New(rdpContext* context, rdpBitmap* bitmap);
|
||||
void gdi_Bitmap_Free(rdpContext* context, rdpBitmap* bitmap);
|
||||
void gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,
|
||||
uint8* data, int width, int height, int bpp, int length, int compressed);
|
||||
uint8* data, int width, int height, int bpp, int length,
|
||||
boolean compressed, int codec_id);
|
||||
void gdi_register_graphics(rdpGraphics* graphics);
|
||||
|
||||
#endif /* __GDI_GRAPHICS_H */
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/constants.h>
|
||||
#include <freerdp/utils/print.h>
|
||||
#include <freerdp/utils/memory.h>
|
||||
#include <freerdp/utils/args.h>
|
||||
@@ -361,17 +362,17 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
|
||||
if (strcmp("rfx", argv[index]) == 0)
|
||||
{
|
||||
printf("setting rfx\n");
|
||||
settings->preferred_codec_id = 3; /* CODEC_ID_REMOTEFX */
|
||||
settings->preferred_codec_id = CODEC_ID_REMOTEFX;
|
||||
}
|
||||
else if (strcmp("nsc", argv[index]) == 0)
|
||||
{
|
||||
printf("setting codec nsc\n");
|
||||
settings->preferred_codec_id = 1; /* CODEC_ID_NSCODEC */
|
||||
settings->preferred_codec_id = CODEC_ID_NSCODEC;
|
||||
}
|
||||
else if (strcmp("jpeg", argv[index]) == 0)
|
||||
{
|
||||
printf("setting codec jpeg\n");
|
||||
settings->preferred_codec_id = 2;
|
||||
settings->preferred_codec_id = CODEC_ID_JPEG;
|
||||
}
|
||||
}
|
||||
else if (strcmp("--jpeg", argv[index]) == 0)
|
||||
|
||||
Reference in New Issue
Block a user