]> git.sesse.net Git - nageru/blobdiff - chroma_subsampler.cpp
Display a copy of the Y'CbCr images instead of an RGB565 copy.
[nageru] / chroma_subsampler.cpp
index 63be1a9609013cfc7dd994b1dc3e31c03f8bb2f8..a9e535592634c53d9931e964fffecb6f9b85cf88 100644 (file)
@@ -94,9 +94,10 @@ ChromaSubsampler::ChromaSubsampler(ResourcePool *resource_pool)
                "#version 130 \n"
                "in vec2 tc0, tc1; \n"
                "uniform sampler2D cbcr_tex; \n"
-               "out vec4 FragColor; \n"
+               "out vec4 FragColor, FragColor2; \n"
                "void main() { \n"
                "    FragColor = 0.5 * (texture(cbcr_tex, tc0) + texture(cbcr_tex, tc1)); \n"
+               "    FragColor2 = FragColor; \n"
                "} \n";
        cbcr_program_num = resource_pool->compile_glsl_program(cbcr_vert_shader, cbcr_frag_shader, frag_shader_outputs);
        check_error();
@@ -181,7 +182,7 @@ ChromaSubsampler::~ChromaSubsampler()
        check_error();
 }
 
-void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex)
+void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigned height, GLuint dst_tex, GLuint dst2_tex)
 {
        GLuint vao;
        glGenVertexArrays(1, &vao);
@@ -191,7 +192,12 @@ void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigne
        check_error();
 
        // Extract Cb/Cr.
-       GLuint fbo = resource_pool->create_fbo(dst_tex);
+       GLuint fbo;
+       if (dst2_tex <= 0) {
+               fbo = resource_pool->create_fbo(dst_tex);
+       } else {
+               fbo = resource_pool->create_fbo(dst_tex, dst2_tex);
+       }
        glBindFramebuffer(GL_FRAMEBUFFER, fbo);
        glViewport(0, 0, width/2, height/2);
        check_error();