2 #define _MOVIT_YCBCR_H 1
4 // Shared utility functions between YCbCrInput and YCbCr422InterleavedInput.
6 #include "image_format.h"
13 // Which formula for Y' to use.
14 YCbCrLumaCoefficients luma_coefficients;
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.
21 // Sampling factors for chroma components. For no subsampling (4:4:4),
23 unsigned chroma_subsampling_x, chroma_subsampling_y;
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;
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);
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);
44 #endif // !defined(_MOVIT_YCBCR_INPUT_H)