SDL_yuv_sw_c.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef SDL_yuv_sw_c_h_
  19. #define SDL_yuv_sw_c_h_
  20. #include "SDL_internal.h"
  21. // This is the software implementation of the YUV texture support
  22. struct SDL_SW_YUVTexture
  23. {
  24. SDL_PixelFormat format;
  25. SDL_Colorspace colorspace;
  26. SDL_PixelFormat target_format;
  27. int w, h;
  28. Uint8 *pixels;
  29. // These are just so we don't have to allocate them separately
  30. int pitches[3];
  31. Uint8 *planes[3];
  32. // This is a temporary surface in case we have to stretch copy
  33. SDL_Surface *stretch;
  34. SDL_Surface *display;
  35. };
  36. typedef struct SDL_SW_YUVTexture SDL_SW_YUVTexture;
  37. extern SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(SDL_PixelFormat format, SDL_Colorspace colorspace, int w, int h);
  38. extern bool SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture *swdata, void **pixels, int *pitch);
  39. extern bool SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, const void *pixels, int pitch);
  40. extern bool SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
  41. const Uint8 *Yplane, int Ypitch,
  42. const Uint8 *Uplane, int Upitch,
  43. const Uint8 *Vplane, int Vpitch);
  44. extern bool SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect,
  45. const Uint8 *Yplane, int Ypitch,
  46. const Uint8 *UVplane, int UVpitch);
  47. extern bool SDL_SW_LockYUVTexture(SDL_SW_YUVTexture *swdata, const SDL_Rect *rect, void **pixels, int *pitch);
  48. extern void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture *swdata);
  49. extern bool SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture *swdata, const SDL_Rect *srcrect, SDL_PixelFormat target_format, int w, int h, void *pixels, int pitch);
  50. extern void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture *swdata);
  51. #endif // SDL_yuv_sw_c_h_