mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
Use YUV colorspaces instead of a global YUV conversion mode
Fixes https://github.com/libsdl-org/SDL/issues/8669
This commit is contained in:
@@ -555,6 +555,11 @@ typedef enum
|
||||
#define SDL_COLORSPACETRANSFER(X) (SDL_TransferCharacteristics)(((X) >> 5) & 0x1F)
|
||||
#define SDL_COLORSPACEMATRIX(X) (SDL_MatrixCoefficients)((X) & 0x1F)
|
||||
|
||||
#define SDL_ISCOLORSPACE_YUV_BT601(X) (SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT601 || SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT470BG)
|
||||
#define SDL_ISCOLORSPACE_YUV_BT709(X) (SDL_COLORSPACEMATRIX(X) == SDL_MATRIX_COEFFICIENTS_BT709)
|
||||
#define SDL_ISCOLORSPACE_LIMITED_RANGE(X) (SDL_COLORSPACERANGE(X) == SDL_COLOR_RANGE_LIMITED)
|
||||
#define SDL_ISCOLORSPACE_FULL_RANGE(X) (SDL_COLORSPACERANGE(X) == SDL_COLOR_RANGE_LIMITED)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_COLORSPACE_UNKNOWN,
|
||||
@@ -620,6 +625,10 @@ typedef enum
|
||||
|
||||
/* The default colorspace for RGB surfaces if no colorspace is specified */
|
||||
SDL_COLORSPACE_RGB_DEFAULT = SDL_COLORSPACE_SRGB,
|
||||
|
||||
/* The default colorspace for YUV surfaces if no colorspace is specified */
|
||||
SDL_COLORSPACE_YUV_DEFAULT = SDL_COLORSPACE_BT601_LIMITED,
|
||||
|
||||
} SDL_Colorspace;
|
||||
|
||||
/**
|
||||
|
@@ -458,7 +458,7 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *
|
||||
* - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_ColorSpace value
|
||||
* describing the texture colorspace, defaults to SDL_COLORSPACE_SCRGB for
|
||||
* floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
|
||||
* SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_BT709_FULL
|
||||
* SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_BT601_LIMITED
|
||||
* for YUV textures.
|
||||
* - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
|
||||
* SDL_PixelFormatEnum, defaults to the best RGBA format for the renderer
|
||||
|
@@ -138,17 +138,6 @@ typedef int (SDLCALL *SDL_blit) (struct SDL_Surface *src, const SDL_Rect *srcrec
|
||||
struct SDL_Surface *dst, const SDL_Rect *dstrect);
|
||||
|
||||
|
||||
/**
|
||||
* The formula used for converting between YUV and RGB
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */
|
||||
SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */
|
||||
SDL_YUV_CONVERSION_BT709, /**< BT.709 */
|
||||
SDL_YUV_CONVERSION_AUTOMATIC /**< BT.601 for SD content, BT.709 for HD content */
|
||||
} SDL_YUV_CONVERSION_MODE;
|
||||
|
||||
/**
|
||||
* Allocate a new RGB surface with a specific pixel format.
|
||||
*
|
||||
@@ -1031,36 +1020,6 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, con
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
|
||||
|
||||
/**
|
||||
* Set the YUV conversion mode
|
||||
*
|
||||
* \param mode YUV conversion mode
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
|
||||
|
||||
/**
|
||||
* Get the YUV conversion mode
|
||||
*
|
||||
* \returns YUV conversion mode
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
|
||||
|
||||
/**
|
||||
* Get the YUV conversion mode, returning the correct mode for the resolution
|
||||
* when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
|
||||
*
|
||||
* \param width width
|
||||
* \param height height
|
||||
* \returns YUV conversion mode
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Reference in New Issue
Block a user