From 545bd978a9ad74dfe12d5d8ad0cc8ef17a05dc02 Mon Sep 17 00:00:00 2001 From: phintuka Date: Sun, 16 Mar 2008 23:41:37 +0000 Subject: Byte order cnversion macros for osd_command_t --- xine_osd_command.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/xine_osd_command.h b/xine_osd_command.h index f36c387a..bb9956fc 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.8 2008-03-11 15:57:57 phintuka Exp $ + * $Id: xine_osd_command.h,v 1.9 2008-03-16 23:41:37 phintuka Exp $ * */ @@ -95,6 +95,55 @@ typedef struct osd_command_s { } PACKED osd_command_t; +#if __BYTE_ORDER == __LITTLE_ENDIAN +# define hton_osdcmd(cmdP) \ + do { \ + cmdP.cmd = htonl (cmdP.cmd); \ + cmdP.wnd = htonl (cmdP.wnd); \ + cmdP.pts = htonll(cmdP.pts); \ + cmdP.delay_ms = htonl (cmdP.delay_ms); \ + cmdP.x = htons (cmdP.x); \ + cmdP.y = htons (cmdP.y); \ + cmdP.w = htons (cmdP.w); \ + cmdP.h = htons (cmdP.h); \ + cmdP.datalen = htonl (cmdP.datalen); \ + cmdP.num_rle = htonl (cmdP.num_rle); \ + cmdP.colors = htonl (cmdP.colors); \ + cmdP.dirty_area.x1 = htons(cmdP.dirty_area.x1); \ + cmdP.dirty_area.y1 = htons(cmdP.dirty_area.y1); \ + cmdP.dirty_area.x2 = htons(cmdP.dirty_area.x2); \ + cmdP.dirty_area.y2 = htons(cmdP.dirty_area.y2); \ + } while(0) + +# define ntoh_osdcmd(cmdP) \ + do { \ + cmdP.cmd = ntohl (cmdP.cmd); \ + cmdP.wnd = ntohl (cmdP.wnd); \ + cmdP.pts = ntohll(cmdP.pts); \ + cmdP.delay_ms = ntohl (cmdP.delay_ms); \ + cmdP.x = ntohs (cmdP.x); \ + cmdP.y = ntohs (cmdP.y); \ + cmdP.w = ntohs (cmdP.w); \ + cmdP.h = ntohs (cmdP.h); \ + cmdP.datalen = ntohl (cmdP.datalen); \ + cmdP.num_rle = ntohl (cmdP.num_rle); \ + cmdP.colors = ntohl (cmdP.colors); \ + cmdP.dirty_area.x1 = ntohs(cmdP.dirty_area.x1); \ + cmdP.dirty_area.y1 = ntohs(cmdP.dirty_area.y1); \ + cmdP.dirty_area.x2 = ntohs(cmdP.dirty_area.x2); \ + cmdP.dirty_area.y2 = ntohs(cmdP.dirty_area.y2); \ + } while(0) + +#elif __BYTE_ORDER == __BIG_ENDIAN + +# define hton_osdcmd(cmd) do {} while(0) +# define ntoh_osdcmd(cmd) do {} while(0) + +#else +# error __BYTE_ORDER undefined ! +#endif + + #if defined __cplusplus } #endif -- cgit v1.2.3