]> git.sesse.net Git - movit/blob - ycbcr.h
Support timer queries for phases.
[movit] / ycbcr.h
1 #ifndef _MOVIT_YCBCR_H
2 #define _MOVIT_YCBCR_H 1
3
4 // Shared utility functions between YCbCrInput and YCbCr422InterleavedInput.
5
6 #include "image_format.h"
7
8 #include <Eigen/Core>
9
10 namespace movit {
11
12 struct YCbCrFormat {
13         // Which formula for Y' to use.
14         YCbCrLumaCoefficients luma_coefficients;
15
16         // If true, assume Y'CbCr coefficients are full-range, ie. go from 0 to 255
17         // instead of the limited 220/225 steps in classic MPEG. For instance,
18         // JPEG uses the Rec. 601 luma coefficients, but full range.
19         bool full_range;
20
21         // Sampling factors for chroma components. For no subsampling (4:4:4),
22         // set both to 1.
23         unsigned chroma_subsampling_x, chroma_subsampling_y;
24
25         // Positioning of the chroma samples. MPEG-1 and JPEG is (0.5, 0.5);
26         // MPEG-2 and newer typically are (0.0, 0.5).
27         float cb_x_position, cb_y_position;
28         float cr_x_position, cr_y_position;
29 };
30
31 // Convert texel sampling offset for the given chroma channel, given that
32 // chroma position is <pos> (0..1), we are downsampling this chroma channel
33 // by a factor of <subsampling_factor> and the texture we are sampling from
34 // is <resolution> pixels wide/high.
35 float compute_chroma_offset(float pos, unsigned subsampling_factor, unsigned resolution);
36
37 // Given <ycbcr_format>, compute the values needed to turn Y'CbCr into R'G'B';
38 // first subtract the returned offset, then left-multiply the returned matrix
39 // (the scaling is already folded into it).
40 void compute_ycbcr_matrix(YCbCrFormat ycbcr_format, float *offset, Eigen::Matrix3d *ycbcr_to_rgb);
41
42 }  // namespace movit
43
44 #endif // !defined(_MOVIT_YCBCR_INPUT_H)