filters/color.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. | ||
| 2 | // http://avisynth.nl | ||
| 3 | |||
| 4 | // This program is free software; you can redistribute it and/or modify | ||
| 5 | // it under the terms of the GNU General Public License as published by | ||
| 6 | // the Free Software Foundation; either version 2 of the License, or | ||
| 7 | // (at your option) any later version. | ||
| 8 | // | ||
| 9 | // This program is distributed in the hope that it will be useful, | ||
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | // GNU General Public License for more details. | ||
| 13 | // | ||
| 14 | // You should have received a copy of the GNU General Public License | ||
| 15 | // along with this program; if not, write to the Free Software | ||
| 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit | ||
| 17 | // http://www.gnu.org/copyleft/gpl.html . | ||
| 18 | // | ||
| 19 | // Linking Avisynth statically or dynamically with other modules is making a | ||
| 20 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU | ||
| 21 | // General Public License cover the whole combination. | ||
| 22 | // | ||
| 23 | // As a special exception, the copyright holders of Avisynth give you | ||
| 24 | // permission to link Avisynth with independent modules that communicate with | ||
| 25 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license | ||
| 26 | // terms of these independent modules, and to copy and distribute the | ||
| 27 | // resulting combined work under terms of your choice, provided that | ||
| 28 | // every copy of the combined work is accompanied by a complete copy of | ||
| 29 | // the source code of Avisynth (the version of Avisynth used to produce the | ||
| 30 | // combined work), being distributed under the terms of the GNU General | ||
| 31 | // Public License plus this exception. An independent module is a module | ||
| 32 | // which is not derived from or based on Avisynth, such as 3rd-party filters, | ||
| 33 | // import and export plugins, or graphical user interfaces. | ||
| 34 | |||
| 35 | |||
| 36 | #ifndef __Color_h | ||
| 37 | #define __Color_h | ||
| 38 | |||
| 39 | #include <avisynth.h> | ||
| 40 | |||
| 41 | enum | ||
| 42 | { | ||
| 43 | COLORYUV_RANGE_NONE, | ||
| 44 | COLORYUV_RANGE_TV_PC, | ||
| 45 | COLORYUV_RANGE_PC_TV, | ||
| 46 | COLORYUV_RANGE_PC_TVY | ||
| 47 | }; | ||
| 48 | |||
| 49 | struct ColorYUVPlaneData | ||
| 50 | { | ||
| 51 | double average; | ||
| 52 | float real_min, real_max; | ||
| 53 | int loose_min, loose_max; | ||
| 54 | }; | ||
| 55 | |||
| 56 | struct ColorYUVPlaneConfig | ||
| 57 | { | ||
| 58 | double gain, offset, gamma, contrast; | ||
| 59 | int range, plane; | ||
| 60 | bool clip_tv; | ||
| 61 | bool changed; // for lut recalc | ||
| 62 | bool force_tv_range; // telling to have TV range for gamma when no other parameters | ||
| 63 | }; | ||
| 64 | |||
| 65 | class ColorYUV : public GenericVideoFilter | ||
| 66 | { | ||
| 67 | public: | ||
| 68 | ColorYUV(PClip child, | ||
| 69 | double gain_y, double offset_y, double gamma_y, double contrast_y, | ||
| 70 | double gain_u, double offset_u, double gamma_u, double contrast_u, | ||
| 71 | double gain_v, double offset_v, double gamma_v, double contrast_v, | ||
| 72 | const char* level, const char* opt, | ||
| 73 | bool showyuv, bool analyse, bool autowhite, bool autogain, bool conditional, | ||
| 74 | int bits, bool showyuv_fullrange, // avs+ | ||
| 75 | bool tweaklike_params, // ColorYUV2: 0.0/0.5/1.0/2.0/3.0 instead of -256/-128/0/256/512 | ||
| 76 | const char *condVarSuffix, | ||
| 77 | bool optForceUseExpr, | ||
| 78 | IScriptEnvironment* env); | ||
| 79 | |||
| 80 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 81 | |||
| 82 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) override | |
| 83 | { | ||
| 84 | AVS_UNUSED(frame_range); | ||
| 85 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 86 | } | ||
| 87 | |||
| 88 | static AVSValue Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 89 | |||
| 90 | ~ColorYUV(); | ||
| 91 | |||
| 92 | private: | ||
| 93 | ColorYUVPlaneConfig configY, configU, configV; | ||
| 94 | int colorbar_bits; | ||
| 95 | bool colorbar_fullrange; | ||
| 96 | bool analyse, autowhite, autogain, conditional; | ||
| 97 | bool tweaklike_params; | ||
| 98 | const char* condVarSuffix; | ||
| 99 | bool optForceUseExpr; | ||
| 100 | BYTE *luts[3]; | ||
| 101 | |||
| 102 | int theColorRange; | ||
| 103 | int theOutColorRange; | ||
| 104 | int theMatrix; | ||
| 105 | int theChromaLocation; | ||
| 106 | |||
| 107 | }; | ||
| 108 | |||
| 109 | #endif // __Color_h | ||
| 110 |