convert/convert_bits.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 __Convert_bits_H__ | ||
| 36 | #define __Convert_bits_H__ | ||
| 37 | |||
| 38 | #include <avisynth.h> | ||
| 39 | #include <stdint.h> | ||
| 40 | #include "convert.h" | ||
| 41 | |||
| 42 | |||
| 43 | // in convert_bits.cpp | ||
| 44 | // repeated 8x for sse size 16 | ||
| 45 | extern const BYTE dither2x2a_data[4]; | ||
| 46 | // cycle: 2 | ||
| 47 | extern const BYTE dither2x2a_data_sse2[2 * 16]; | ||
| 48 | // e.g. 10->8 bits | ||
| 49 | // repeated 8x for sse size 16 | ||
| 50 | extern const BYTE dither2x2_data[4]; | ||
| 51 | // cycle: 2 | ||
| 52 | extern const BYTE dither2x2_data_sse2[2 * 16]; | ||
| 53 | // e.g. 8->5 bits | ||
| 54 | extern const BYTE dither4x4a_data[16]; | ||
| 55 | // cycle: 4 | ||
| 56 | extern const BYTE dither4x4a_data_sse2[4 * 16]; | ||
| 57 | // e.g. 12->8 bits | ||
| 58 | extern const BYTE dither4x4_data[16]; | ||
| 59 | // cycle: 4 | ||
| 60 | extern const BYTE dither4x4_data_sse2[4 * 16]; | ||
| 61 | // e.g. 14->9 bits | ||
| 62 | extern const BYTE dither8x8a_data[8][8]; | ||
| 63 | // cycle: 8 | ||
| 64 | extern const BYTE dither8x8a_data_sse2[8][16]; | ||
| 65 | // e.g. 14->8 bits | ||
| 66 | extern const BYTE dither8x8_data[8][8]; | ||
| 67 | // cycle: 8 | ||
| 68 | extern const BYTE dither8x8_data_sse2[8][16]; | ||
| 69 | // e.g. 16->9 or 8->1 bits | ||
| 70 | // cycle: 16x. No special 16 byte sse2 | ||
| 71 | extern const BYTE dither16x16a_data[16][16]; | ||
| 72 | // 16->8 | ||
| 73 | // cycle: 16x. No special 16 byte sse2 | ||
| 74 | extern const BYTE dither16x16_data[16][16]; | ||
| 75 | |||
| 76 | typedef void (*BitDepthConvFuncPtr)(const BYTE *srcp, BYTE *dstp, int src_rowsize, int src_height, int src_pitch, int dst_pitch, int source_bitdepth, int target_bitdepth, int dither_target_bitdepth); | ||
| 77 | |||
| 78 | class ConvertBits : public GenericVideoFilter | ||
| 79 | { | ||
| 80 | public: | ||
| 81 | ConvertBits(PClip _child, const int _dither_mode, const int _target_bitdepth, bool _truerange, int _ColorRange_src, int _ColorRange_dest, int _dither_bitdepth, IScriptEnvironment* env); | ||
| 82 | PVideoFrame __stdcall GetFrame(int n,IScriptEnvironment* env) override; | ||
| 83 | |||
| 84 | 11 | int __stdcall SetCacheHints(int cachehints, int frame_range) override { | |
| 85 | AVS_UNUSED(frame_range); | ||
| 86 |
2/2✓ Branch 2 → 3 taken 3 times.
✓ Branch 2 → 4 taken 8 times.
|
11 | return cachehints == CACHE_GET_MTMODE ? MT_NICE_FILTER : 0; |
| 87 | } | ||
| 88 | |||
| 89 | static AVSValue __cdecl Create(AVSValue args, void*, IScriptEnvironment* env); | ||
| 90 | private: | ||
| 91 | BitDepthConvFuncPtr conv_function; | ||
| 92 | BitDepthConvFuncPtr conv_function_chroma; // 32bit float YUV chroma | ||
| 93 | BitDepthConvFuncPtr conv_function_a; | ||
| 94 | int target_bitdepth; | ||
| 95 | int dither_mode; | ||
| 96 | int dither_bitdepth; | ||
| 97 | bool fulls; // source is full range (defaults: rgb=true, yuv=false (bit shift)) | ||
| 98 | bool fulld; // destination is full range (defaults: rgb=true, yuv=false (bit shift)) | ||
| 99 | bool truerange; // if 16->10 range reducing or e.g. 14->16 bit range expansion needed | ||
| 100 | int pixelsize; | ||
| 101 | int bits_per_pixel; | ||
| 102 | bool format_change_only; | ||
| 103 | }; | ||
| 104 | |||
| 105 | void get_convert_any_bits_functions(int dither_mode, int source_bitdepth, int target_bitdepth, bool fulls, bool fulld, | ||
| 106 | #ifdef INTEL_INTRINSICS | ||
| 107 | bool sse2, bool sse4, bool avx2, | ||
| 108 | #endif | ||
| 109 | BitDepthConvFuncPtr& conv_function, BitDepthConvFuncPtr& conv_function_chroma, BitDepthConvFuncPtr& conv_function_a); | ||
| 110 | |||
| 111 | /********************************** | ||
| 112 | ****** Bitdepth conversions ***** | ||
| 113 | **********************************/ | ||
| 114 | |||
| 115 | #endif // __Convert_bits_H__ | ||
| 116 |