]> git.sesse.net Git - nageru/blob - chroma_subsampler.h
Add UYVY support to ChromaSubsampler.
[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         void subsample_chroma(GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex);
21
22         // Subsamples and interleaves luma and chroma to give 4:2:2 packed Y'CbCr (UYVY).
23         // Chroma positioning is left (H.264 convention).
24         // width and height are the dimensions (in pixels) of the input textures.
25         void create_uyvy(GLuint y_tex, GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex);
26
27 private:
28         movit::ResourcePool *resource_pool;
29
30         GLuint vbo;  // Holds position and texcoord data.
31
32         GLuint cbcr_program_num;  // Owned by <resource_pool>.
33         GLuint cbcr_texture_sampler_uniform;
34         GLuint cbcr_position_attribute_index, cbcr_texcoord_attribute_index;
35
36         GLuint uyvy_program_num;  // Owned by <resource_pool>.
37         GLuint uyvy_y_texture_sampler_uniform, uyvy_cbcr_texture_sampler_uniform;
38         GLuint uyvy_position_attribute_index, uyvy_texcoord_attribute_index;
39 };
40
41 #endif  // !defined(_CHROMA_SUBSAMPLER_H)