21 #include "../SDL_internal.h" 60 const int sz_plane = w *
h;
61 const int sz_plane_chroma = ((w + 1) / 2) * ((h + 1) / 2);
62 const int sz_plane_packed = ((w + 1) / 2) *
h;
68 dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
74 dst_size = 4 * sz_plane_packed;
79 dst_size = sz_plane + sz_plane_chroma + sz_plane_chroma;
83 SDL_assert(0 &&
"We should never get here (caught above)");
108 swdata->
pitches[0] = ((w + 1) / 2) * 4;
121 SDL_assert(0 &&
"We should never get here (caught above)");
133 *pixels = swdata->
planes[0];
140 const void *
pixels,
int pitch)
145 if (rect->
x == 0 && rect->
y == 0 &&
146 rect->
w == swdata->
w && rect->
h == swdata->
h) {
148 (swdata->
h * swdata->
w) + 2* ((swdata->
h + 1) /2) * ((swdata->
w + 1) / 2));
155 src = (
Uint8 *) pixels;
156 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
158 for (row = 0; row < rect->
h; ++
row) {
165 src = (
Uint8 *) pixels + rect->
h * pitch;
166 dst = swdata->
pixels + swdata->
h * swdata->
w;
167 dst += rect->
y/2 * ((swdata->
w + 1) / 2) + rect->
x/2;
168 length = (rect->
w + 1) / 2;
169 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
171 src += (pitch + 1)/2;
172 dst += (swdata->
w + 1)/2;
176 src = (
Uint8 *) pixels + rect->
h * pitch + ((rect->
h + 1) / 2) * ((pitch + 1) / 2);
177 dst = swdata->
pixels + swdata->
h * swdata->
w +
178 ((swdata->
h + 1)/2) * ((swdata->
w+1) / 2);
179 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
180 length = (rect->
w + 1) / 2;
181 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
183 src += (pitch + 1)/2;
184 dst += (swdata->
w + 1)/2;
196 src = (
Uint8 *) pixels;
200 length = 4 * ((rect->
w + 1) / 2);
201 for (row = 0; row < rect->
h; ++
row) {
211 if (rect->
x == 0 && rect->
y == 0 && rect->
w == swdata->
w && rect->
h == swdata->
h) {
213 (swdata->
h * swdata->
w) + 2* ((swdata->
h + 1) /2) * ((swdata->
w + 1) / 2));
221 src = (
Uint8 *) pixels;
222 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
224 for (row = 0; row < rect->
h; ++
row) {
231 src = (
Uint8 *) pixels + rect->
h * pitch;
232 dst = swdata->
pixels + swdata->
h * swdata->
w;
233 dst += 2 * ((rect->
y + 1)/2) * ((swdata->
w + 1) / 2) + 2 * (rect->
x/2);
234 length = 2 * ((rect->
w + 1) / 2);
235 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
237 src += 2 * ((pitch + 1)/2);
238 dst += 2 * ((swdata->
w + 1)/2);
248 const Uint8 *Yplane,
int Ypitch,
249 const Uint8 *Uplane,
int Upitch,
250 const Uint8 *Vplane,
int Vpitch)
259 dst = swdata->
pixels + rect->
y * swdata->
w + rect->
x;
261 for (row = 0; row < rect->
h; ++
row) {
270 dst = swdata->
pixels + swdata->
h * swdata->
w;
272 dst = swdata->
pixels + swdata->
h * swdata->
w +
273 ((swdata->
h + 1) / 2) * ((swdata->
w + 1) / 2);
275 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
276 length = (rect->
w + 1) / 2;
277 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
280 dst += (swdata->
w + 1)/2;
286 dst = swdata->
pixels + swdata->
h * swdata->
w;
288 dst = swdata->
pixels + swdata->
h * swdata->
w +
289 ((swdata->
h + 1) / 2) * ((swdata->
w + 1) / 2);
291 dst += rect->
y/2 * ((swdata->
w + 1)/2) + rect->
x/2;
292 length = (rect->
w + 1) / 2;
293 for (row = 0; row < (rect->
h + 1)/2; ++
row) {
296 dst += (swdata->
w + 1)/2;
303 void **
pixels,
int *pitch)
311 && (rect->
x != 0 || rect->
y != 0 || rect->
w != swdata->
w 312 || rect->
h != swdata->
h)) {
314 (
"YV12, IYUV, NV12, NV21 textures only support full surface locks");
320 *pixels = swdata->
planes[0] + rect->
y * swdata->
pitches[0] + rect->
x * 2;
322 *pixels = swdata->
planes[0];
347 if (srcrect->
x || srcrect->
y || srcrect->
w < swdata->
w || srcrect->
h < swdata->
h) {
354 }
else if ((srcrect->
w != w) || (srcrect->
h != h)) {
359 Uint32 Rmask, Gmask, Bmask, Amask;
372 Gmask, Bmask, Amask);
383 Gmask, Bmask, Amask);
393 target_format, pixels, pitch) < 0) {
void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata)
SDL_SW_YUVTexture * SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
GLfloat GLfloat GLfloat GLfloat h
int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch)
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp
#define SDL_CreateRGBSurfaceFrom
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch)
GLubyte GLubyte GLubyte GLubyte w
#define SDL_PixelFormatEnumToMasks
void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata)
GLint GLint GLsizei GLsizei GLsizei GLint GLenum GLenum const GLvoid * pixels
#define SDL_assert(condition)
#define SDL_OutOfMemory()
int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch)
#define SDL_CreateRGBSurface
int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch)
int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, Uint32 target_format, int w, int h, void *pixels, int pitch)
#define SDL_ConvertPixels
GLuint GLsizei GLsizei * length
A rectangle, with the origin at the upper left.