comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/webp/sharpyuv/sharpyuv_csp.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
comparison
equal deleted inserted replaced
67:0e9998148a16 69:33d812a61356
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
18 extern "C" {
19 #endif
20
21 // Range of YUV values.
22 typedef 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.
28 typedef 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.
38 SHARPYUV_EXTERN void SharpYuvComputeConversionMatrix(
39 const SharpYuvColorSpace* yuv_color_space,
40 SharpYuvConversionMatrix* matrix);
41
42 // Enums for precomputed conversion matrices.
43 typedef enum {
44 // WebP's matrix, similar but not identical to kSharpYuvMatrixRec601Limited
45 kSharpYuvMatrixWebp = 0,
46 // Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeLimited
47 kSharpYuvMatrixRec601Limited,
48 // Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeFull
49 kSharpYuvMatrixRec601Full,
50 // Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeLimited
51 kSharpYuvMatrixRec709Limited,
52 // Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeFull
53 kSharpYuvMatrixRec709Full,
54 kSharpYuvMatrixNum
55 } SharpYuvMatrixType;
56
57 // Returns a pointer to a matrix for one of the predefined colorspaces.
58 SHARPYUV_EXTERN const SharpYuvConversionMatrix* SharpYuvGetConversionMatrix(
59 SharpYuvMatrixType matrix_type);
60
61 #ifdef __cplusplus
62 } // extern "C"
63 #endif
64
65 #endif // WEBP_SHARPYUV_SHARPYUV_CSP_H_