1// Copyright 2022 Google Inc. All Rights Reserved.
2//
3// Use of this source code is governed by a BSD-style license
4// that can be found in the COPYING file in the root of the source
5// tree. An additional intellectual property rights grant can be found
6// in the file PATENTS. All contributing project authors may
7// be found in the AUTHORS file in the root of the source tree.
8// -----------------------------------------------------------------------------
9//
10// Colorspace utilities.
11
12#ifndef WEBP_SHARPYUV_SHARPYUV_CSP_H_
13#define WEBP_SHARPYUV_SHARPYUV_CSP_H_
14
15#include "sharpyuv/sharpyuv.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21// Range of YUV values.
22typedef enum {
23 kSharpYuvRangeFull, // YUV values between [0;255] (for 8 bit)
24 kSharpYuvRangeLimited // Y in [16;235], YUV in [16;240] (for 8 bit)
25} SharpYuvRange;
26
27// Constants that define a YUV color space.
28typedef struct {
29 // Kr and Kb are defined such that:
30 // Y = Kr * r + Kg * g + Kb * b where Kg = 1 - Kr - Kb.
31 float kr;
32 float kb;
33 int bit_depth; // 8, 10 or 12
34 SharpYuvRange range;
35} SharpYuvColorSpace;
36
37// Fills in 'matrix' for the given YUVColorSpace.
38SHARPYUV_EXTERN void SharpYuvComputeConversionMatrix(
39 const SharpYuvColorSpace* yuv_color_space,
40 SharpYuvConversionMatrix* matrix);
41
42// Enums for precomputed conversion matrices.
43typedef enum {
44 kSharpYuvMatrixWebp = 0,
45 kSharpYuvMatrixRec601Limited,
46 kSharpYuvMatrixRec601Full,
47 kSharpYuvMatrixRec709Limited,
48 kSharpYuvMatrixRec709Full,
49 kSharpYuvMatrixNum
50} SharpYuvMatrixType;
51
52// Returns a pointer to a matrix for one of the predefined colorspaces.
53SHARPYUV_EXTERN const SharpYuvConversionMatrix* SharpYuvGetConversionMatrix(
54 SharpYuvMatrixType matrix_type);
55
56#ifdef __cplusplus
57} // extern "C"
58#endif
59
60#endif // WEBP_SHARPYUV_SHARPYUV_CSP_H_
61

source code of qtimageformats/src/3rdparty/libwebp/sharpyuv/sharpyuv_csp.h