ccvt.h
1 /* CCVT: ColourConVerT: simple library for converting colourspaces
2  Copyright (C) 2002 Nemosoft Unv.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 
18  For questions, remarks, patches, etc. for this program, the author can be
19  reached at nemosoft@smcc.demon.nl.
20 */
21 
22 /*
23  $Log$
24  Revision 1.1 2005/05/04 06:53:17 section314
25  Added YUV420P-->RGB conversion
26 
27  Revision 1.10 2003/10/24 16:55:18 nemosoft
28  removed erronous log messages
29 
30  Revision 1.9 2002/11/03 22:46:25 nemosoft
31  Adding various RGB to RGB functions.
32  Adding proper copyright header too.
33 
34  Revision 1.8 2002/04/14 01:00:27 nemosoft
35  Finishing touches: adding const, adding libs for 'show'
36 */
37 
38 
39 #ifndef CCVT_H
40 #define CCVT_H
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /* Colour ConVerT: going from one colour space to another.
47  ** NOTE: the set of available functions is far from complete! **
48 
49  Format descriptions:
50  420i = "4:2:0 interlaced"
51  YYYY UU YYYY UU even lines
52  YYYY VV YYYY VV odd lines
53  U/V data is subsampled by 2 both in horizontal
54  and vertical directions, and intermixed with the Y values.
55 
56  420p = "4:2:0 planar"
57  YYYYYYYY N lines
58  UUUU N/2 lines
59  VVVV N/2 lines
60  U/V is again subsampled, but all the Ys, Us and Vs are placed
61  together in separate buffers. The buffers may be placed in
62  one piece of contiguous memory though, with Y buffer first,
63  followed by U, followed by V.
64 
65  yuyv = "4:2:2 interlaced"
66  YUYV YUYV YUYV ... N lines
67  The U/V data is subsampled by 2 in horizontal direction only.
68 
69  bgr24 = 3 bytes per pixel, in the order Blue Green Red (whoever came up
70  with that idea...)
71  rgb24 = 3 bytes per pixel, in the order Red Green Blue (which is sensible)
72  rgb32 = 4 bytes per pixel, in the order Red Green Blue Alpha, with
73  Alpha really being a filler byte (0)
74  bgr32 = last but not least, 4 bytes per pixel, in the order Blue Green Red
75  Alpha, Alpha again a filler byte (0)
76  */
77 
78 /* 4:2:0 YUV planar to RGB/BGR */
79 void ccvt_420p_bgr24(int width, int height, const void *src, void *dst);
80 void ccvt_420p_rgb24(int width, int height, const void *src, void *dst);
81 void ccvt_420p_bgr32(int width, int height, const void *src, void *dst);
82 void ccvt_420p_rgb32(int width, int height, const void *src, void *dst);
83 
84 /* 4:2:2 YUYV interlaced to RGB/BGR */
85 void ccvt_yuyv_rgb32(int width, int height, const void *src, void *dst);
86 void ccvt_yuyv_bgr32(int width, int height, const void *src, void *dst);
87 
88 /* 4:2:2 YUYV interlaced to 4:2:0 YUV planar */
89 void ccvt_yuyv_420p(int width, int height, const void *src, void *dsty, void *dstu, void *dstv);
90 
91 /* RGB/BGR to 4:2:0 YUV interlaced */
92 
93 /* RGB/BGR to 4:2:0 YUV planar */
94 void ccvt_rgb24_420p(int width, int height, const void *src, void *dsty, void *dstu, void *dstv);
95 void ccvt_bgr24_420p(int width, int height, const void *src, void *dsty, void *dstu, void *dstv);
96 
97 /* RGB/BGR to RGB/BGR */
98 void ccvt_bgr24_bgr32(int width, int height, const void *const src, void *const dst);
99 void ccvt_bgr24_rgb32(int width, int height, const void *const src, void *const dst);
100 void ccvt_bgr32_bgr24(int width, int height, const void *const src, void *const dst);
101 void ccvt_bgr32_rgb24(int width, int height, const void *const src, void *const dst);
102 void ccvt_rgb24_bgr32(int width, int height, const void *const src, void *const dst);
103 void ccvt_rgb24_rgb32(int width, int height, const void *const src, void *const dst);
104 void ccvt_rgb32_bgr24(int width, int height, const void *const src, void *const dst);
105 void ccvt_rgb32_rgb24(int width, int height, const void *const src, void *const dst);
106 
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif
static bool MatchMessage(player_msghdr_t *hdr, int type, int subtype, player_devaddr_t addr)
Helper for message processing.
Definition: message.h:158
float pan
Pan [rad].
Definition: player_interfaces.h:1231
#define PLAYER_PTZ_DATA_STATE
Data subtype: state.
Definition: player_interfaces.h:1208
float tilt
Tilt [rad].
Definition: player_interfaces.h:1233
Generic message header.
Definition: player.h:160
virtual int MainSetup(void)
Sets up the resources needed by the driver thread.
Definition: driver.h:657
virtual void MainQuit(void)
Cleanup method for driver thread (called when main exits)
Definition: driver.h:663
Data: state (PLAYER_PTZ_DATA_STATE)
Definition: player_interfaces.h:1228
float tilt
Desired tilt angle [rad].
Definition: player_interfaces.h:1253
Command: state (PLAYER_PTZ_CMD_STATE)
Definition: player_interfaces.h:1248
const char * ReadString(int section, const char *name, const char *value)
Read a string value.
float zoom
Desired field of view [rad].
Definition: player_interfaces.h:1255
float zoom
Field of view [rad].
Definition: player_interfaces.h:1235
uint8_t subtype
Message subtype; interface specific.
Definition: player.h:167
virtual void Main(void)=0
Main method for driver thread.
#define PLAYER_PTZ_REQ_GENERIC
Request/reply subtype: generic.
Definition: player_interfaces.h:1196
#define PLAYER_MSGTYPE_DATA
A data message.
Definition: player.h:94
#define PLAYER_MSGTYPE_RESP_ACK
A positive response message.
Definition: player.h:111
virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr *hdr, void *data)
Message handler.
uint32_t * config
Buffer for command/reply.
Definition: player_interfaces.h:1292
#define PLAYER_MSGTYPE_REQ
A request message.
Definition: player.h:105
#define PLAYER_MSGTYPE_RESP_NACK
A negative response message.
Definition: player.h:124
double ReadTupleAngle(int section, const char *name, int index, double value)
Read an angle form a tuple (includes units conversion)
float pan
Desired pan angle [rad].
Definition: player_interfaces.h:1251
Class for loading configuration file information.
Definition: configfile.h:195
An autopointer for the message queue.
Definition: message.h:72
Request/reply: Generic request.
Definition: player_interfaces.h:1287
uint32_t config_count
Length of data in config buffer.
Definition: player_interfaces.h:1290
Base class for drivers which oeprate with a thread.
Definition: driver.h:551
#define PLAYER_PTZ_CMD_STATE
Command subtype: state.
Definition: player_interfaces.h:1214
uint32_t size
Size in bytes of the payload to follow.
Definition: player.h:173
#define PLAYER_MSGTYPE_CMD
A command message.
Definition: player.h:98
Base class for all drivers.
Definition: driver.h:107
#define PLAYER_MSGQUEUE_DEFAULT_MAXLEN
Default maximum length for a message queue.
Definition: player.h:75