]> git.sesse.net Git - nageru/blobdiff - chroma_subsampler.cpp
Allow symlinked frame files. Useful for testing.
[nageru] / chroma_subsampler.cpp
index 28bd0a3e4fc6487cf3476599f15f21b50df8a4b9..d064bc7c1d821d29bf9de86fc0194de0cfddba78 100644 (file)
@@ -1,13 +1,15 @@
 #include "chroma_subsampler.h"
 
-#include <string>
 #include <movit/util.h>
+#include <string>
+
+#include "embedded_files.h"
 
 #define BUFFER_OFFSET(i) ((char *)nullptr + (i))
 
 using namespace std;
 
-string read_file(const string &filename);
+string read_file(const string &filename, const unsigned char *start = nullptr, const size_t size = 0);
 GLuint compile_shader(const string &shader_src, GLenum type);
 GLuint link_program(GLuint vs_obj, GLuint fs_obj);
 void bind_sampler(GLuint program, GLint location, GLuint texture_unit, GLuint tex, GLuint sampler);
@@ -69,8 +71,8 @@ ChromaSubsampler::ChromaSubsampler()
        //
        // See also http://www.poynton.com/PDFs/Merging_RGB_and_422.pdf, pages 6–7.
 
-       cbcr_vs_obj = compile_shader(read_file("chroma_subsample.vert"), GL_VERTEX_SHADER);
-       cbcr_fs_obj = compile_shader(read_file("chroma_subsample.frag"), GL_FRAGMENT_SHADER);
+       cbcr_vs_obj = compile_shader(read_file("chroma_subsample.vert", _binary_chroma_subsample_vert_data, _binary_chroma_subsample_vert_size), GL_VERTEX_SHADER);
+       cbcr_fs_obj = compile_shader(read_file("chroma_subsample.frag", _binary_chroma_subsample_frag_data, _binary_chroma_subsample_frag_size), GL_FRAGMENT_SHADER);
        cbcr_program = link_program(cbcr_vs_obj, cbcr_fs_obj);
 
        // Set up the VAO containing all the required position data.
@@ -83,10 +85,10 @@ ChromaSubsampler::ChromaSubsampler()
                2.0f, 0.0f
        };
        glCreateBuffers(1, &vbo);
-        glNamedBufferData(vbo, sizeof(vertices), vertices, GL_STATIC_DRAW);
+       glNamedBufferData(vbo, sizeof(vertices), vertices, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
 
-        GLint position_attrib = 0;  // Hard-coded in every vertex shader.
+       GLint position_attrib = 0;  // Hard-coded in every vertex shader.
        glEnableVertexArrayAttrib(vao, position_attrib);
        glVertexAttribPointer(position_attrib, 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
 
@@ -112,7 +114,7 @@ void ChromaSubsampler::subsample_chroma(GLuint cbcr_tex, unsigned width, unsigne
        glProgramUniform2f(cbcr_program, uniform_chroma_offset_0, -1.0f / width, 0.0f);
        glProgramUniform2f(cbcr_program, uniform_chroma_offset_1, -0.0f / width, 0.0f);
 
-       glViewport(0, 0, width/2, height);
+       glViewport(0, 0, width / 2, height);
        fbos.render_to(cb_tex, cr_tex);
 
        glBindVertexArray(vao);