Path: blob/master/thirdparty/libwebp/sharpyuv/sharpyuv_csp.h
9898 views
// Copyright 2022 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// Colorspace utilities.1011#ifndef WEBP_SHARPYUV_SHARPYUV_CSP_H_12#define WEBP_SHARPYUV_SHARPYUV_CSP_H_1314#include "sharpyuv/sharpyuv.h"1516#ifdef __cplusplus17extern "C" {18#endif1920// Range of YUV values.21typedef enum {22kSharpYuvRangeFull, // YUV values between [0;255] (for 8 bit)23kSharpYuvRangeLimited // Y in [16;235], YUV in [16;240] (for 8 bit)24} SharpYuvRange;2526// Constants that define a YUV color space.27typedef struct {28// Kr and Kb are defined such that:29// Y = Kr * r + Kg * g + Kb * b where Kg = 1 - Kr - Kb.30float kr;31float kb;32int bit_depth; // 8, 10 or 1233SharpYuvRange range;34} SharpYuvColorSpace;3536// Fills in 'matrix' for the given YUVColorSpace.37SHARPYUV_EXTERN void SharpYuvComputeConversionMatrix(38const SharpYuvColorSpace* yuv_color_space,39SharpYuvConversionMatrix* matrix);4041// Enums for precomputed conversion matrices.42typedef enum {43// WebP's matrix, similar but not identical to kSharpYuvMatrixRec601Limited44kSharpYuvMatrixWebp = 0,45// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeLimited46kSharpYuvMatrixRec601Limited,47// Kr=0.2990f Kb=0.1140f bit_depth=8 range=kSharpYuvRangeFull48kSharpYuvMatrixRec601Full,49// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeLimited50kSharpYuvMatrixRec709Limited,51// Kr=0.2126f Kb=0.0722f bit_depth=8 range=kSharpYuvRangeFull52kSharpYuvMatrixRec709Full,53kSharpYuvMatrixNum54} SharpYuvMatrixType;5556// Returns a pointer to a matrix for one of the predefined colorspaces.57SHARPYUV_EXTERN const SharpYuvConversionMatrix* SharpYuvGetConversionMatrix(58SharpYuvMatrixType matrix_type);5960#ifdef __cplusplus61} // extern "C"62#endif6364#endif // WEBP_SHARPYUV_SHARPYUV_CSP_H_656667