Xorg: avoid excessive malloc / free
This commit is contained in:
parent
372f247713
commit
6fc9b8dd8c
@ -272,6 +272,10 @@ struct _rdpRec
|
|||||||
yuv_to_rgb32_proc yv12_to_rgb32;
|
yuv_to_rgb32_proc yv12_to_rgb32;
|
||||||
yuv_to_rgb32_proc yuy2_to_rgb32;
|
yuv_to_rgb32_proc yuy2_to_rgb32;
|
||||||
yuv_to_rgb32_proc uyvy_to_rgb32;
|
yuv_to_rgb32_proc uyvy_to_rgb32;
|
||||||
|
char *xv_data;
|
||||||
|
int xv_data_bytes;
|
||||||
|
int xv_timer_schedualed;
|
||||||
|
OsTimerPtr xv_timer;
|
||||||
|
|
||||||
};
|
};
|
||||||
typedef struct _rdpRec rdpRec;
|
typedef struct _rdpRec rdpRec;
|
||||||
|
@ -420,6 +420,22 @@ stretch_RGB32_RGB32(int *src, int src_width, int src_height,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/* returns error */
|
||||||
|
static CARD32
|
||||||
|
rdpDeferredXv(OsTimerPtr timer, CARD32 now, pointer arg)
|
||||||
|
{
|
||||||
|
rdpPtr dev;
|
||||||
|
|
||||||
|
LLOGLN(0, ("rdpDeferredXv:"));
|
||||||
|
dev = (rdpPtr) arg;
|
||||||
|
dev->xv_timer_schedualed = 0;
|
||||||
|
dev->xv_data_bytes = 0;
|
||||||
|
g_free(dev->xv_data);
|
||||||
|
dev->xv_data = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* see hw/xfree86/common/xf86xv.c for info */
|
/* see hw/xfree86/common/xf86xv.c for info */
|
||||||
static int
|
static int
|
||||||
@ -442,7 +458,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
|
|||||||
int jndex;
|
int jndex;
|
||||||
int num_clips;
|
int num_clips;
|
||||||
int error;
|
int error;
|
||||||
void *mem;
|
|
||||||
RegionRec dreg;
|
RegionRec dreg;
|
||||||
BoxRec box;
|
BoxRec box;
|
||||||
|
|
||||||
@ -450,14 +465,31 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
|
|||||||
LLOGLN(10, ("xrdpVidPutImage: src_x %d srcy_y %d", src_x, src_y));
|
LLOGLN(10, ("xrdpVidPutImage: src_x %d srcy_y %d", src_x, src_y));
|
||||||
dev = XRDPPTR(pScrn);
|
dev = XRDPPTR(pScrn);
|
||||||
|
|
||||||
|
if (dev->xv_timer_schedualed)
|
||||||
|
{
|
||||||
|
TimerCancel(dev->xv_timer);
|
||||||
|
dev->xv_timer = TimerSet(dev->xv_timer, 0, 2000, rdpDeferredXv, dev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dev->xv_timer_schedualed = 1;
|
||||||
|
dev->xv_timer = TimerSet(dev->xv_timer, 0, 2000, rdpDeferredXv, dev);
|
||||||
|
}
|
||||||
|
|
||||||
index = width * height * 4 + drw_w * drw_h * 4 + 64;
|
index = width * height * 4 + drw_w * drw_h * 4 + 64;
|
||||||
mem = g_malloc(index, 0);
|
if (index > dev->xv_data_bytes)
|
||||||
if (mem == NULL)
|
{
|
||||||
|
g_free(dev->xv_data);
|
||||||
|
dev->xv_data = g_malloc(index, 0);
|
||||||
|
if (dev->xv_data == NULL)
|
||||||
{
|
{
|
||||||
LLOGLN(0, ("xrdpVidPutImage: memory alloc error"));
|
LLOGLN(0, ("xrdpVidPutImage: memory alloc error"));
|
||||||
|
dev->xv_data_bytes = 0;
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
rgborg32 = (int *) RDPALIGN(mem, 16);
|
dev->xv_data_bytes = index;
|
||||||
|
}
|
||||||
|
rgborg32 = (int *) RDPALIGN(dev->xv_data, 16);
|
||||||
rgbend32 = rgborg32 + width * height;
|
rgbend32 = rgborg32 + width * height;
|
||||||
rgbend32 = (int *) RDPALIGN(rgbend32, 16);
|
rgbend32 = (int *) RDPALIGN(rgbend32, 16);
|
||||||
error = 0;
|
error = 0;
|
||||||
@ -481,12 +513,10 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LLOGLN(0, ("xrdpVidPutImage: unknown format 0x%8.8x", format));
|
LLOGLN(0, ("xrdpVidPutImage: unknown format 0x%8.8x", format));
|
||||||
g_free(mem);
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
g_free(mem);
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
error = stretch_RGB32_RGB32(rgborg32, width, height,
|
error = stretch_RGB32_RGB32(rgborg32, width, height,
|
||||||
@ -494,7 +524,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
|
|||||||
rgbend32, drw_w, drw_h);
|
rgbend32, drw_w, drw_h);
|
||||||
if (error != 0)
|
if (error != 0)
|
||||||
{
|
{
|
||||||
g_free(mem);
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,8 +562,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
|
|||||||
rdpClientConAddAllReg(dev, &dreg, dst);
|
rdpClientConAddAllReg(dev, &dreg, dst);
|
||||||
rdpRegionUninit(&dreg);
|
rdpRegionUninit(&dreg);
|
||||||
|
|
||||||
g_free(mem);
|
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user