summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontend_svr.c99
-rw-r--r--osd.c27
-rw-r--r--xine_input_vdr.c38
-rw-r--r--xine_osd_command.h28
4 files changed, 107 insertions, 85 deletions
diff --git a/frontend_svr.c b/frontend_svr.c
index 15eb43ce..017a033d 100644
--- a/frontend_svr.c
+++ b/frontend_svr.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: frontend_svr.c,v 1.7 2006-07-04 02:06:31 phintuka Exp $
+ * $Id: frontend_svr.c,v 1.8 2006-07-06 02:57:59 phintuka Exp $
*
*/
@@ -42,7 +42,7 @@
#include "frontend_svr.h"
#include "device.h"
-#define LOG_OSD_BANDWIDTH (128*1024)
+#define LOG_OSD_BANDWIDTH (128*1024) /* log messages if OSD bandwidth > 1 Mbit/s */
class cStcFuture : public cFuture<int64_t> {};
class cReplyFuture : public cFuture<int>, public cListObject {};
@@ -164,6 +164,23 @@ void cXinelibServer::CloseConnection(int cli)
}
}
+static int recompress_osd_net(uint8_t *raw, xine_rle_elem_t *data, int elems)
+{
+ uint8_t *raw0 = raw;
+ for(int i=0; i<elems; i++) {
+ uint16_t len = data[i].len;
+ uint16_t color = data[i].color;
+ if(len >= 0x80) {
+ *(raw++) = (len>>8) | 0x80;
+ *(raw++) = (len & 0xff);
+ } else {
+ *(raw++) = (len & 0x7f);
+ }
+ *(raw++) = color;
+ }
+ return (raw-raw0);
+}
+
void cXinelibServer::OsdCmd(void *cmd_gen)
{
TRACEF("cXinelibServer::OsdCmd");
@@ -180,6 +197,44 @@ void cXinelibServer::OsdCmd(void *cmd_gen)
if(cmd_gen) {
osd_command_t *cmd = (osd_command_t*)cmd_gen;
+ osd_command_t cmdnet;
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ /* -> network order */
+ cmdnet.cmd = htonl(cmd->cmd);
+ cmdnet.wnd = htonl(cmd->wnd);
+ cmdnet.pts = htonll(cmd->pts);
+ cmdnet.delay_ms = htonl(cmd->delay_ms);
+ cmdnet.x = htons(cmd->x);
+ cmdnet.y = htons(cmd->y);
+ cmdnet.w = htons(cmd->w);
+ cmdnet.h = htons(cmd->h);
+ cmdnet.datalen = htonl(cmd->datalen);
+ cmdnet.num_rle = htonl(cmd->num_rle);
+ cmdnet.colors = htonl(cmd->colors);
+ if(cmd->data) {
+ cmdnet.raw_data = (uint8_t*)malloc(cmd->datalen);
+ cmdnet.datalen = htonl( recompress_osd_net(cmdnet.raw_data, cmd->data, cmd->num_rle));
+ } else {
+ cmdnet.data = NULL;
+ }
+ cmdnet.palette = cmd->palette;
+#elif __BYTE_ORDER == __BIG_ENDIAN
+ memcpy(&cmdnet, cmd, sizeof(osd_command_t));
+ cmdnet.raw_data = (uint8_t *)malloc(cmd->datalen);
+ cmdnet.datalen = recompress_osd_net(cmdnet.raw_data, cmd->data, cmd->num_rle);
+#else
+# error __BYTE_ORDER not defined !
+#endif
+
+ for(i=0; i<MAXCLIENTS; i++)
+ if(fd_control[i] >= 0 &&
+ !write_osd_command(fd_control[i], &cmdnet)) {
+ LOGMSG("Send OSD command failed");
+ CloseConnection(i);
+ }
+
+ free(cmdnet.data);
+
#ifdef LOG_OSD_BANDWIDTH
{
static int64_t timer = 0LL;
@@ -196,47 +251,9 @@ void cXinelibServer::OsdCmd(void *cmd_gen)
timer = now;
bytes = 0;
}
- bytes += cmd->datalen;
+ bytes += sizeof(osd_command_t) + ntohl(cmdnet.datalen);
}
#endif
-
- /* -> network order */
- osd_command_t cmdnet;
-
- if(ntohl(0x12345678) != 0x12345678) {
- cmdnet.cmd = htonl(cmd->cmd);
- cmdnet.wnd = htonl(cmd->wnd);
- cmdnet.pts = htonll(cmd->pts);
- cmdnet.delay_ms = htonl(cmd->delay_ms);
- cmdnet.x = htons(cmd->x);
- cmdnet.y = htons(cmd->y);
- cmdnet.w = htons(cmd->w);
- cmdnet.h = htons(cmd->h);
- cmdnet.datalen = htonl(cmd->datalen);
- cmdnet.colors = htonl(cmd->colors);
- if(cmd->data) {
- cmdnet.data = (xine_rle_elem_t*)malloc(cmd->datalen);
- for(unsigned int i=0; i<cmd->datalen/4; i++) {
- cmdnet.data[i].len = htons(cmd->data[i].len);
- cmdnet.data[i].color = htons(cmd->data[i].color);
- }
- } else {
- cmdnet.data = NULL;
- }
- cmdnet.palette = cmd->palette;
- } else {
- memcpy(&cmdnet, cmd, sizeof(osd_command_t));
- }
-
- for(i=0; i<MAXCLIENTS; i++)
- if(fd_control[i] >= 0 &&
- !write_osd_command(fd_control[i], &cmdnet)) {
- LOGMSG("Send OSD command failed");
- CloseConnection(i);
- }
-
- if(ntohl(0x12345678) != 0x12345678 && cmdnet.data)
- free(cmdnet.data);
}
}
diff --git a/osd.c b/osd.c
index 513a061c..379fbf84 100644
--- a/osd.c
+++ b/osd.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.c,v 1.2 2006-06-11 10:21:43 phintuka Exp $
+ * $Id: osd.c,v 1.3 2006-07-06 02:57:59 phintuka Exp $
*
*/
@@ -90,21 +90,6 @@ static inline void RleCmd(cXinelibDevice *Device, int wnd,
for(int c=0; c<colors; c++) {
int alpha = (palette[c] & 0xff000000)>>24;
alpha = alpha + xc.alpha_correction*alpha/100 + xc.alpha_correction_abs;
-#if 0 // FLOAT_COLORSPACE_CONVERSION
- float R = (float)((palette[c] & 0x00ff0000)>>16);
- float G = (float)((palette[c] & 0x0000ff00)>>8);
- float B = (float)((palette[c] & 0x000000ff));
- float Y = + (0.2578125 * R) + (0.50390625 * G) + (0.09765625 * B) + 16.0;
- float CR = + (0.4375000 * R) - (0.36718750 * G) - (0.07031250 * B) + 128.0;
- float CB = - (0.1484375 * R) - (0.28906250 * G) + (0.43750000 * B) + 128.0;
- int y = (int)Y;
- int cr = (int)CR;
- int cb = (int)CB;
- clut[c].y = y<0?0 : y>0xff?0xff : y;
- clut[c].cb = cb<0?0 : cb>0xff?0xff : cb;
- clut[c].cr = cr<0?0 : cr>0xff?0xff : cr;
- clut[c].alpha = alpha<0?0 : alpha>0xff?0xff : alpha;
-#else
int R = ((palette[c] & 0x00ff0000) >> 16);
int G = ((palette[c] & 0x0000ff00) >> 8);
int B = ((palette[c] & 0x000000ff));
@@ -115,7 +100,6 @@ static inline void RleCmd(cXinelibDevice *Device, int wnd,
clut[c].cb = saturate( CB, 16, 240);
clut[c].cr = saturate( CR, 16, 240);
clut[c].alpha = saturate(alpha, 0, 255);
-#endif
}
}
@@ -154,6 +138,7 @@ static inline void RleCmd(cXinelibDevice *Device, int wnd,
num_rle++;
}
osdcmd.datalen = 4 * num_rle;
+ osdcmd.num_rle = num_rle;
TRACE("xinelib_osd.c:RleCmd uncompressed="<< (w*h) <<", compressed=" << (4*num_rle));
@@ -248,14 +233,14 @@ void cXinelibOsd::Flush(void)
if(SendDone) {
static int64_t last_refresh = 0LL;
int64_t now = cTimeMs::Now();
- if(now - last_refresh < 100LL) {
+ if(now - last_refresh < 100) {
/* too fast refresh rate, delay ... */
- cCondWait::SleepMs(100);
+ cCondWait::SleepMs(40); /* Can't update faster anyway ... */
#if 0
- LOGDBG("cXinelibOsd::Flush: OSD refreshing too fast ! (>10Hz) -> Sleeping 100ms");
+ LOGDBG("cXinelibOsd::Flush: OSD refreshing too fast ! (>10Hz) -> Sleeping 50ms");
#endif
}
- last_refresh = cTimeMs::Now();
+ last_refresh = now;
}
#endif
diff --git a/xine_input_vdr.c b/xine_input_vdr.c
index b40a77f0..2258d198 100644
--- a/xine_input_vdr.c
+++ b/xine_input_vdr.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_input_vdr.c,v 1.12 2006-07-05 03:14:45 phintuka Exp $
+ * $Id: xine_input_vdr.c,v 1.13 2006-07-06 02:57:59 phintuka Exp $
*
*/
@@ -1383,6 +1383,23 @@ static int update_video_size(vdr_input_plugin_t *this)
return 0;
}
+static xine_rle_elem_t *uncompress_osd_net(uint8_t *raw, int elems, int datalen)
+{
+ xine_rle_elem_t *data = (xine_rle_elem_t*)malloc(elems*sizeof(xine_rle_elem_t));
+ int i;
+
+ for(i=0; i<elems; i++) {
+ if((*raw) & 0x80) {
+ data[i].len = ((*(raw++)) & 0x7f) << 8;
+ data[i].len |= *(raw++);
+ } else
+ data[i].len = *(raw++);
+ data[i].color = *(raw++);
+ }
+
+ return data;
+}
+
/* re-scale compressed RLE image */
static xine_rle_elem_t *scale_rle_image(osd_command_t *osdcmd,
int new_w, int new_h)
@@ -2286,7 +2303,7 @@ static int handle_control_osdcmd(vdr_input_plugin_t *this)
return CONTROL_DISCONNECTED;
}
- /*if(0x12345678 != ntohl(0x12345678)) {*/
+#if __BYTE_ORDER == __LITTLE_ENDIAN
/* -> host order */
osdcmd.cmd = ntohl(osdcmd.cmd);
osdcmd.wnd = ntohl(osdcmd.wnd);
@@ -2297,8 +2314,12 @@ static int handle_control_osdcmd(vdr_input_plugin_t *this)
osdcmd.w = ntohs(osdcmd.w);
osdcmd.h = ntohs(osdcmd.h);
osdcmd.datalen = ntohl(osdcmd.datalen);
+ osdcmd.num_rle = ntohl(osdcmd.num_rle);
osdcmd.colors = ntohl(osdcmd.colors);
- /*}*/
+#elif __BYTE_ORDER == __BIG_ENDIAN
+#else
+# error __BYTE_ORDER undefined !
+#endif
if(osdcmd.palette && osdcmd.colors>0) {
int bytes = sizeof(xine_clut_t)*(osdcmd.colors);
@@ -2319,13 +2340,10 @@ static int handle_control_osdcmd(vdr_input_plugin_t *this)
LOGMSG("control: error reading OSDCMD bitmap");
err = CONTROL_DISCONNECTED;
} else {
- if(0x1234 != ntohs(0x1234)) {
- int i;
- for(i=0; i<osdcmd.datalen/4; i++) {
- osdcmd.data[i].len = ntohs(osdcmd.data[i].len);
- osdcmd.data[i].color = ntohs(osdcmd.data[i].color);
- }
- }
+ uint8_t *raw = osdcmd.raw_data;
+ osdcmd.data = uncompress_osd_net(raw, osdcmd.num_rle, osdcmd.datalen);
+ osdcmd.datalen = osdcmd.num_rle*4;
+ free(raw);
}
} else {
osdcmd.data = NULL;
diff --git a/xine_osd_command.h b/xine_osd_command.h
index 1c169dda..c100a394 100644
--- a/xine_osd_command.h
+++ b/xine_osd_command.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: xine_osd_command.h,v 1.2 2006-07-02 16:45:24 phintuka Exp $
+ * $Id: xine_osd_command.h,v 1.3 2006-07-06 02:57:59 phintuka Exp $
*
*/
@@ -17,14 +17,14 @@
extern "C" {
#endif
-typedef enum {
- OSD_Nop = 0, /* Do nothing ; used to initialize delay_ms counter */
- OSD_Size = 1, /* Set size of VDR OSD area (usually 720x576) */
- OSD_Set_RLE = 2, /* Create/update OSD window. Data is rle-compressed. */
- OSD_SetPalette = 3, /* Modify palette of already created OSD window */
- OSD_Move = 4, /* Change x/y position of already created OSD window */
- OSD_Close = 5, /* Close OSD window */
- OSD_Set_YUV = 6 /* Create/update OSD window. Data is in YUV420 format. */
+typedef enum {
+ OSD_Nop = 0, /* Do nothing ; used to initialize delay_ms counter */
+ OSD_Size = 1, /* Set size of VDR OSD area (usually 720x576) */
+ OSD_Set_RLE = 2, /* Create/update OSD window. Data is rle-compressed. */
+ OSD_SetPalette = 3, /* Modify palette of already created OSD window */
+ OSD_Move = 4, /* Change x/y position of already created OSD window */
+ OSD_Close = 5, /* Close OSD window */
+ OSD_Set_YUV = 6 /* Create/update OSD window. Data is in YUV420 format. */
} osd_command_id_t;
typedef struct xine_clut_s {
@@ -52,15 +52,17 @@ typedef struct osd_command_s {
uint16_t w; /* window width */
uint16_t h; /* window height */
- uint32_t datalen; /* size of image data, in bytes */
+ uint32_t datalen; /* size of image data, in bytes */
+ uint32_t num_rle;
union {
xine_rle_elem_t *data; /* RLE compressed image */
- uint64_t dummy01;
+ uint8_t *raw_data;
+ uint64_t dummy01;
};
uint32_t colors; /* palette size */
union {
- xine_clut_t *palette; /* palette (YCrCb) */
- uint64_t dummy02;
+ xine_clut_t *palette; /* palette (YCrCb) */
+ uint64_t dummy02;
};
} __attribute__((packed)) osd_command_t;