1 #ifndef _YCBCR_CONVERTER_H
2 #define _YCBCR_CONVERTER_H 1
6 #include <movit/effect.h>
7 #include <movit/ycbcr_input.h>
14 class WhiteBalanceEffect;
21 class YCbCrConverter {
24 OUTPUT_TO_RGBA, // One texture (bottom-left origin): RGBA
25 OUTPUT_TO_SEMIPLANAR, // Two textures (top-left origin): Y, CbCr
26 OUTPUT_TO_DUAL_YCBCR // Two textures (top-left origin): Y'CbCr, Y'CbCr
28 YCbCrConverter(OutputMode output_mode, movit::ResourcePool *resource_pool);
30 // Returns the appropriate chain for rendering. Fades apply white balance,
31 // straight-up conversion does not.
32 movit::EffectChain *prepare_chain_for_conversion(std::shared_ptr<Frame> frame);
33 movit::EffectChain *prepare_chain_for_fade(std::shared_ptr<Frame> frame, std::shared_ptr<Frame> secondary_frame, float fade_alpha);
35 // <tex> must be interleaved Y'CbCr.
36 movit::EffectChain *prepare_chain_for_fade_from_texture(GLuint tex, movit::RGBTriplet neutral_color, unsigned width, unsigned height, std::shared_ptr<Frame> secondary_frame, float fade_alpha);
39 movit::YCbCrFormat ycbcr_format;
41 // Effectively only converts from 4:2:2 to 4:4:4.
42 // TODO: Have a separate version with ResampleEffect, for scaling?
43 std::unique_ptr<movit::EffectChain> planar_chain, semiplanar_chain;
44 movit::YCbCrInput *ycbcr_planar_input, *ycbcr_semiplanar_input;
46 // These do fades, parametrized on whether the two inputs are planar
49 std::unique_ptr<movit::EffectChain> chain;
50 movit::YCbCrInput *input[2];
51 movit::WhiteBalanceEffect *wb_effect[2];
52 movit::MixEffect *mix_effect;
54 FadeChain fade_chains[2][2];
56 // These do fades, where the first input is interleaved and the second is
57 // either planar or semiplanar.
58 FadeChain interleaved_fade_chains[2];
62 void setup_input_for_frame(std::shared_ptr<Frame> frame, const movit::YCbCrFormat &ycbcr_format, movit::YCbCrInput *input);
64 #endif // !defined(_YCBCR_CONVERTER_H)