]> git.sesse.net Git - nageru/blob - chroma_subsampler.h
Update the queue length metric after trimming, not before.
[nageru] / chroma_subsampler.h
1 #ifndef _CHROMA_SUBSAMPLER_H
2 #define _CHROMA_SUBSAMPLER_H 1
3
4 #include <epoxy/gl.h>
5
6 namespace movit {
7
8 class ResourcePool;
9
10 }  // namespace movit
11
12 class ChromaSubsampler {
13 public:
14         ChromaSubsampler(movit::ResourcePool *resource_pool);
15         ~ChromaSubsampler();
16
17         // Subsamples chroma (packed Cb and Cr) 2x2 to yield chroma suitable for
18         // NV12 (semiplanar 4:2:0). Chroma positioning is left/center (H.264 convention).
19         // width and height are the dimensions (in pixels) of the input texture.
20         //
21         // You can get two equal copies if you'd like; just set dst2_tex to a texture
22         // number and it will receive an exact copy of what goes into dst_tex.
23         void subsample_chroma(GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex, GLuint dst2_tex = 0);
24
25         // Subsamples and interleaves luma and chroma to give 4:2:2 packed Y'CbCr (UYVY).
26         // Chroma positioning is left (H.264 convention).
27         // width and height are the dimensions (in pixels) of the input textures.
28         void create_uyvy(GLuint y_tex, GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex);
29
30         // Subsamples and interleaves luma and chroma to give 10-bit 4:2:2
31         // packed Y'CbCr (v210); see v210converter.h for more information on
32         // the format. Luma and chroma are assumed to be 10-bit data packed
33         // into 16-bit textures. Chroma positioning is left (H.264 convention).
34         // width and height are the dimensions (in pixels) of the input textures;
35         // Requires compute shaders; check v210Converter::has_hardware_support().
36         void create_v210(GLuint y_tex, GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex);
37
38 private:
39         movit::ResourcePool *resource_pool;
40
41         GLuint vbo;  // Holds position and texcoord data.
42
43         GLuint cbcr_program_num;  // Owned by <resource_pool>.
44         GLuint cbcr_texture_sampler_uniform;
45         GLuint cbcr_position_attribute_index, cbcr_texcoord_attribute_index;
46
47         GLuint uyvy_program_num;  // Owned by <resource_pool>.
48         GLuint uyvy_y_texture_sampler_uniform, uyvy_cbcr_texture_sampler_uniform;
49         GLuint uyvy_position_attribute_index, uyvy_texcoord_attribute_index;
50
51         GLuint v210_program_num;  // Compute shader, so owned by ourselves. Can be 0.
52         GLuint v210_in_y_pos, v210_in_cbcr_pos, v210_outbuf_pos;
53         GLuint v210_inv_width_pos, v210_inv_height_pos;
54 };
55
56 #endif  // !defined(_CHROMA_SUBSAMPLER_H)