]> git.sesse.net Git - nageru/blob - ycbcr_converter.h
Move Y'CbCr conversion into a common utility class.
[nageru] / ycbcr_converter.h
1 #ifndef _YCBCR_CONVERTER_H
2 #define _YCBCR_CONVERTER_H 1
3
4 #include <memory>
5
6 #include <movit/ycbcr_input.h>
7
8 namespace movit {
9
10 class EffectChain;
11 class MixEffect;
12 class ResourcePool;
13 struct YCbCrFormat;
14
15 }  // namespace movit
16
17 struct Frame;
18
19 struct YCbCrConverter {
20 public:
21         enum OutputMode {
22                 OUTPUT_TO_RGBA,         // One texture (bottom-left origin): RGBA
23                 OUTPUT_TO_DUAL_YCBCR    // Two textures (top-left origin):   Y'CbCr, Y'CbCr
24         };
25         YCbCrConverter(OutputMode output_mode, movit::ResourcePool *resource_pool);
26
27         // Returns the appropriate chain for rendering.
28         movit::EffectChain *prepare_chain_for_conversion(std::shared_ptr<Frame> frame);
29
30 private:
31         movit::YCbCrFormat ycbcr_format;
32
33         // Effectively only converts from 4:2:2 to 4:4:4.
34         // TODO: Have a separate version with ResampleEffect, for scaling?
35         std::unique_ptr<movit::EffectChain> planar_chain, semiplanar_chain;
36         movit::YCbCrInput *ycbcr_planar_input, *ycbcr_semiplanar_input;
37 };
38
39 // TODO: make private
40 void setup_input_for_frame(std::shared_ptr<Frame> frame, const movit::YCbCrFormat &ycbcr_format, movit::YCbCrInput *input);
41
42 #endif   // !defined(_YCBCR_CONVERTER_H)