UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
color.c
Go to the documentation of this file.
1
5/*
6 * Copyright (c) 2022-2024 CESNET
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, is permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * 3. Neither the name of CESNET nor the names of its contributors may be
21 * used to endorse or promote products derived from this software without
22 * specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
26 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
28 * EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
35 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 */
37
38#include "color.h"
39
40#include <stdio.h> // for fprintf, stderr
41#include <stdlib.h> // for abort
42
43#include "types.h" // for depth
44
45#define COEFFS(depth) \
46 { \
47 Y_R(depth), Y_G(depth), Y_B(depth),\
48 CB_R(depth), CB_G(depth), CB_B(depth),\
49 CR_R(depth), CR_G(depth), CR_B(depth),\
50\
51 SCALED(R_CR(depth, KR_709, KB_709)), \
52 SCALED(G_CB(depth, KR_709, KB_709)), \
53 SCALED(G_CR(depth, KR_709, KB_709)), \
54 SCALED(B_CB(depth, KR_709, KB_709)), \
55 }
56
57const struct color_coeffs *
58get_color_coeffs(int ycbcr_bit_depth)
59{
60 static const struct color_coeffs col_cfs_8 = COEFFS(DEPTH8);
61 static const struct color_coeffs col_cfs_10 = COEFFS(DEPTH10);
62 static const struct color_coeffs col_cfs_12 = COEFFS(DEPTH12);
63 static const struct color_coeffs col_cfs_16 = COEFFS(DEPTH16);
64 switch ((enum depth) ycbcr_bit_depth) {
65 case DEPTH8:
66 return &col_cfs_8;
67 case DEPTH10:
68 return &col_cfs_10;
69 case DEPTH12:
70 return &col_cfs_12;
71 case DEPTH16:
72 return &col_cfs_16;
73 }
74 fprintf(stderr, "%s: Wrong depth %d!\n", __func__,
75 ycbcr_bit_depth);
76 abort();
77}
#define COEFFS(depth)
Definition color.c:45
const struct color_coeffs * get_color_coeffs(int ycbcr_bit_depth)
Definition color.c:58
This file contains some common data types.
depth
Definition types.h:125
@ DEPTH16
Definition types.h:129
@ DEPTH10
Definition types.h:127
@ DEPTH12
Definition types.h:128
@ DEPTH8
Definition types.h:126