This repository has been archived by the owner on Jun 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yuv.h
120 lines (98 loc) · 3.49 KB
/
yuv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*****************************************************************************
* sdlyuvaddon.h : RGB to YUV conversion functions
*
*****************************************************************************
* Copyright (C) 2001 Xavier Servettaz <[email protected]>
*
* Authors: Xavier Servettaz <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/** @author Xavier Servettaz
RGB to YUV conversion functions
*/
#ifndef SDLYUVADDON_H
#define SDLYUVADDON_H
#if HAVE_CONFIG_H
#include <config.h>
#endif
#include <SDL/SDL.h>
#include <SDL/SDL_endian.h>
#ifdef __cplusplus
extern "C" {
#endif
/********************************************************************
* Type definitions
* *******************************************************************/
/**
YUV Surface type
*/
typedef struct SDL_YUVSurface{
int w, h; /* Read-only */
Uint16 pitch; /* Read-only */
Uint8 * y_data; /* Read-write */
Uint8 * u_data; /* Read-write */
Uint8 * v_data; /* Read-write */
} SDL_YUVSurface;
/*****************************************************************************
* Prototypes
*****************************************************************************/
/** Create an empty YUV Surface
@param width surface width in pixel
@param height surface height in pixel
@return pointer to newly allocated SDL_YUVSurface
@author Xavier Servettaz
@version 0.1
@see SDL_CreateSurface from http://www.libsdl.org
*/
SDL_YUVSurface *SDL_CreateYUVSurface (int width, int height);
/** Free yuv surface
@param surface to be freed
@return nothing
@author Xavier Servettaz
@version 0.1
@see SDL_FreeSurface from http://www.libsdl.org
*/
void SDL_FreeYUVSurface (SDL_YUVSurface *surface);
/** Blit yuv surface to an overlay
@param src pointer to the YUV surface to copy
@param srcrect pointer to the source rect
@param dst pointer to destination overlay
@param dstrect pointer to destination rect
@return int (0 if ok -1 if error)
@author Xavier Servettaz
@version 0.1
*/
int SDL_BlitOverlay (SDL_YUVSurface *src, SDL_Rect *srcrect, SDL_Overlay *dst, SDL_Rect *dstrect);
/** Get YUV components from an RGB Surface
@param image pointer to the RGB source surface
@param yuv_surface pointer to the destination yuv surface
@return int (0 if ok -1 if error)
@author Xavier Servettaz
@version 0.1
*/
int Get_YUV_From_Surface (SDL_Surface * image,SDL_YUVSurface * yuv_surface);
/** May be broken convert an RGB surface to an YUV surface
@param image pointer to the RGB source surface
@param yuv_surface pointer to the destination yuv surface
@return int (0 if ok -1 if error)
@author Xavier Servettaz
@version 0.1
*/
int ConvertRGBtoYUV ( SDL_Surface *image, SDL_YUVSurface * yuv_surface);
#ifdef __cplusplus
}
#endif
#endif