filters/focus.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 | #ifndef __Focus_H__ | ||
| 36 | #define __Focus_H__ | ||
| 37 | |||
| 38 | #include <avisynth.h> | ||
| 39 | |||
| 40 | template<bool packedRGB3264> | ||
| 41 | int calculate_sad_sse2(const BYTE* cur_ptr, const BYTE* other_ptr, int cur_pitch, int other_pitch, size_t rowsize, size_t height); | ||
| 42 | template<typename pixel_t, bool packedRGB3264> | ||
| 43 | int64_t calculate_sad_8_or_16_sse2(const BYTE* cur_ptr, const BYTE* other_ptr, int cur_pitch, int other_pitch, size_t rowsize, size_t height); | ||
| 44 | |||
| 45 | class AdjustFocusV : public GenericVideoFilter | ||
| 46 | /** | ||
| 47 | * Class to adjust focus in the vertical direction, helper for sharpen/blue | ||
| 48 | **/ | ||
| 49 | { | ||
| 50 | public: | ||
| 51 | AdjustFocusV(double _amount, PClip _child); | ||
| 52 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 53 | |||
| 54 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 55 | AVS_UNUSED(frame_range); | ||
| 56 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 57 | } | ||
| 58 | |||
| 59 | private: | ||
| 60 | const double amountd; | ||
| 61 | int half_amount; | ||
| 62 | }; | ||
| 63 | |||
| 64 | |||
| 65 | class AdjustFocusH : public GenericVideoFilter | ||
| 66 | /** | ||
| 67 | * Class to adjust focus in the horizontal direction, helper for sharpen/blue | ||
| 68 | **/ | ||
| 69 | { | ||
| 70 | public: | ||
| 71 | AdjustFocusH(double _amount, PClip _child); | ||
| 72 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 73 | |||
| 74 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 75 | AVS_UNUSED(frame_range); | ||
| 76 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 77 | } | ||
| 78 | |||
| 79 | private: | ||
| 80 | const double amountd; | ||
| 81 | int half_amount; | ||
| 82 | }; | ||
| 83 | |||
| 84 | AVSValue __cdecl Create_Sharpen(AVSValue args, void*, IScriptEnvironment* env); | ||
| 85 | AVSValue __cdecl Create_Blur(AVSValue args, void*, IScriptEnvironment* env); | ||
| 86 | |||
| 87 | |||
| 88 | /*** Soften classes ***/ | ||
| 89 | |||
| 90 | class TemporalSoften : public GenericVideoFilter | ||
| 91 | /** | ||
| 92 | * Class to soften the focus on the temporal axis | ||
| 93 | **/ | ||
| 94 | { | ||
| 95 | public: | ||
| 96 | TemporalSoften( PClip _child, unsigned radius, unsigned luma_thresh, unsigned chroma_thresh,int _scenechange, IScriptEnvironment* env ); | ||
| 97 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 98 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 99 | |||
| 100 | 1 | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 101 | AVS_UNUSED(frame_range); | ||
| 102 |
1/2✓ Branch 2 → 3 taken 1 time.
✗ Branch 2 → 4 not taken.
|
1 | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; |
| 103 | } | ||
| 104 | |||
| 105 | private: | ||
| 106 | typedef struct { | ||
| 107 | int planeId; | ||
| 108 | int threshold; | ||
| 109 | } planeInfo; | ||
| 110 | planeInfo planes[4]; | ||
| 111 | int scenechange; | ||
| 112 | int pixelsize; | ||
| 113 | int bits_per_pixel; | ||
| 114 | |||
| 115 | // YUY2: | ||
| 116 | const unsigned luma_threshold, chroma_threshold; | ||
| 117 | const int kernel; | ||
| 118 | |||
| 119 | enum { MAX_RADIUS=7 }; | ||
| 120 | }; | ||
| 121 | |||
| 122 | |||
| 123 | class SpatialSoften : public GenericVideoFilter | ||
| 124 | /** | ||
| 125 | * Class to soften the focus on the spatial axis | ||
| 126 | **/ | ||
| 127 | { | ||
| 128 | public: | ||
| 129 | SpatialSoften(PClip _child, int _radius, unsigned _luma_threshold, unsigned _chroma_threshold, IScriptEnvironment* env); | ||
| 130 | PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) override; | ||
| 131 | |||
| 132 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 133 | |||
| 134 | ✗ | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 135 | AVS_UNUSED(frame_range); | ||
| 136 | ✗ | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; | |
| 137 | } | ||
| 138 | |||
| 139 | private: | ||
| 140 | const unsigned luma_threshold, chroma_threshold; | ||
| 141 | const int diameter; | ||
| 142 | |||
| 143 | }; | ||
| 144 | |||
| 145 | #endif // __Focus_H__ | ||
| 146 |