]> git.sesse.net Git - nageru/blobdiff - theme.cpp
If not using VA-API zerocopy, don't write extra copy textures.
[nageru] / theme.cpp
index 14560c2d2e8192cb703cba6884b4f9da75a16129..0cc498e8ba0a4297be74bb320440f6c75cba2f7f 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -265,19 +265,32 @@ int EffectChain_finalize(lua_State* L)
                // happens in a pass not run by Movit (see ChromaSubsampler::subsample_chroma()).
                output_ycbcr_format.chroma_subsampling_x = 1;
                output_ycbcr_format.chroma_subsampling_y = 1;
+
+               // This will be overridden if HDMI/SDI output is in force.
                if (global_flags.ycbcr_rec709_coefficients) {
                        output_ycbcr_format.luma_coefficients = YCBCR_REC_709;
                } else {
                        output_ycbcr_format.luma_coefficients = YCBCR_REC_601;
                }
+
                output_ycbcr_format.full_range = false;
-               output_ycbcr_format.num_levels = 256;
+               output_ycbcr_format.num_levels = 1 << global_flags.x264_bit_depth;
+
+               GLenum type = global_flags.x264_bit_depth > 8 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
 
-               chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_SPLIT_Y_AND_CBCR);
-               chain->set_dither_bits(8);
+               chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_SPLIT_Y_AND_CBCR, type);
+
+               // If we're using zerocopy video encoding (so the destination
+               // Y texture is owned by VA-API and will be unavailable for
+               // display), add a copy, where we'll only be using the Y component.
+               if (global_flags.use_zerocopy) {
+                       chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_INTERLEAVED, type);  // Add a copy where we'll only be using the Y component.
+               }
+               chain->set_dither_bits(global_flags.x264_bit_depth > 8 ? 16 : 8);
                chain->set_output_origin(OUTPUT_ORIGIN_TOP_LEFT);
+       } else {
+               chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
        }
-       chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
 
        chain->finalize();
        return 0;