filters/histogram.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 | #ifndef __Histogram_H__ | ||
| 35 | #define __Histogram_H__ | ||
| 36 | |||
| 37 | #include <avisynth.h> | ||
| 38 | #include <vector> | ||
| 39 | #include "stdint.h" | ||
| 40 | #include "../convert/convert_matrix.h" | ||
| 41 | #include <string> | ||
| 42 | |||
| 43 | /******************************************************************** | ||
| 44 | ********************************************************************/ | ||
| 45 | |||
| 46 | struct histogram_color2_params { | ||
| 47 | enum GraticuleType { | ||
| 48 | GRATICULE_OFF=0, | ||
| 49 | GRATICULE_ON, | ||
| 50 | GRATICULE_AUTO | ||
| 51 | }; | ||
| 52 | GraticuleType graticule_type; // paint graticule on histogram on off auto | ||
| 53 | bool targets; // the 6 color bar boxes | ||
| 54 | bool axes; // paint axes horizontal + vertical cross | ||
| 55 | bool iq; // paint +-I/+Q boxes on histogram | ||
| 56 | bool iq_lines; // paint I/Q diagonal lines on histogram | ||
| 57 | bool circle; // paint circle on histogram, originally only at "color2" | ||
| 58 | bool targets100; // the 6 color bar boxes at 100% | ||
| 59 | }; | ||
| 60 | |||
| 61 | class Histogram : public GenericVideoFilter | ||
| 62 | /** | ||
| 63 | * Class to display histogram based on video input | ||
| 64 | **/ | ||
| 65 | { | ||
| 66 | public: | ||
| 67 | enum Mode { | ||
| 68 | ModeClassic=0, | ||
| 69 | ModeLevels, | ||
| 70 | ModeColor, | ||
| 71 | ModeColor2, | ||
| 72 | ModeLuma, | ||
| 73 | ModeStereoY8, | ||
| 74 | ModeStereo, | ||
| 75 | ModeOverlay, | ||
| 76 | ModeAudioLevels | ||
| 77 | }; | ||
| 78 | |||
| 79 | Histogram(PClip _child, Mode _mode, AVSValue _option, int _show_bits, bool _keepsource, bool _markers, const char* _matrix_name, histogram_color2_params _color2_params, IScriptEnvironment* env); | ||
| 80 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 81 | PVideoFrame DrawModeClassic (int n, IScriptEnvironment* env); | ||
| 82 | PVideoFrame DrawModeLevels (int n, IScriptEnvironment* env); | ||
| 83 | PVideoFrame DrawModeColor (int n, IScriptEnvironment* env); | ||
| 84 | PVideoFrame DrawModeColor2 (int n, IScriptEnvironment* env); | ||
| 85 | PVideoFrame DrawModeLuma (int n, IScriptEnvironment* env); | ||
| 86 | PVideoFrame DrawModeStereo (int n, IScriptEnvironment* env); | ||
| 87 | PVideoFrame DrawModeOverlay (int n, IScriptEnvironment* env); | ||
| 88 | PVideoFrame DrawModeAudioLevels(int n, IScriptEnvironment* env); | ||
| 89 | |||
| 90 | 11 | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 91 |
2/2✓ Branch 2 → 3 taken 8 times.
✓ Branch 2 → 4 taken 3 times.
|
11 | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; |
| 92 | } | ||
| 93 | |||
| 94 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 95 | private: | ||
| 96 | Mode mode; | ||
| 97 | int deg15c[24], deg15s[24]; | ||
| 98 | double color2_innerF; | ||
| 99 | PClip aud_clip; | ||
| 100 | AVSValue option; | ||
| 101 | int pixelsize; | ||
| 102 | int bits_per_pixel; | ||
| 103 | int show_bits; // e.g. levels for 10 bits | ||
| 104 | bool keepsource; // return only the Histogram drawing | ||
| 105 | bool markers; // paint hazardous YUV area "levels": draw unsafe zone, "classic" | ||
| 106 | |||
| 107 | histogram_color2_params color2_params; | ||
| 108 | |||
| 109 | int origwidth; | ||
| 110 | int origheight; | ||
| 111 | |||
| 112 | // read from defaults/props/matrix overrides | ||
| 113 | int theMatrix; | ||
| 114 | int theColorRange; | ||
| 115 | bool full_range; | ||
| 116 | // separate out set for rgb target | ||
| 117 | int theOutColorRange; | ||
| 118 | ConversionMatrix matrix; | ||
| 119 | |||
| 120 | int E167; | ||
| 121 | std::vector<uint16_t> exptab; | ||
| 122 | void ClassicLUTInit(); | ||
| 123 | PVideoFrame VectorscopePrelude( | ||
| 124 | int n, IScriptEnvironment* env, | ||
| 125 | PVideoFrame& src, | ||
| 126 | // out: | ||
| 127 | int& dst_pitch, int& dst_height, | ||
| 128 | int& dst_pitchUV, int& dst_heightUV, | ||
| 129 | int& dst_pitchA, int& dst_heightA, | ||
| 130 | BYTE*& panel, BYTE*& panelU, BYTE*& panelV, BYTE*& panelA); | ||
| 131 | }; | ||
| 132 | |||
| 133 | |||
| 134 | #endif // __Histogram_H__ | ||
| 135 |