From def0ce76d14f564ad728ff58d79ceb8f42691ad4 Mon Sep 17 00:00:00 2001 From: MaverickTse Date: Fri, 28 Oct 2016 22:42:41 +0800 Subject: [PATCH] Initial upload just basic functions, checkbox are decoration. --- SigColorFastAviUtl.sln | 22 + SigColorFastAviUtl/Histogram.cpp | 62 ++ SigColorFastAviUtl/Histogram.h | 13 + SigColorFastAviUtl/LUT.cpp | 73 ++ SigColorFastAviUtl/LUT.h | 28 + SigColorFastAviUtl/SigColorFastAviUtl.vcxproj | 109 ++ .../SigColorFastAviUtl.vcxproj.filters | 45 + .../SigColorFastAviUtl.vcxproj.user | 9 + SigColorFastAviUtl/SigmoidTable.cpp | 34 + SigColorFastAviUtl/SigmoidTable.h | 10 + SigColorFastAviUtl/filter.h | 958 ++++++++++++++++++ SigColorFastAviUtl/macro.props | 15 + SigColorFastAviUtl/sigcolorfastaviutl.cpp | 347 +++++++ 13 files changed, 1725 insertions(+) create mode 100644 SigColorFastAviUtl.sln create mode 100644 SigColorFastAviUtl/Histogram.cpp create mode 100644 SigColorFastAviUtl/Histogram.h create mode 100644 SigColorFastAviUtl/LUT.cpp create mode 100644 SigColorFastAviUtl/LUT.h create mode 100644 SigColorFastAviUtl/SigColorFastAviUtl.vcxproj create mode 100644 SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.filters create mode 100644 SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.user create mode 100644 SigColorFastAviUtl/SigmoidTable.cpp create mode 100644 SigColorFastAviUtl/SigmoidTable.h create mode 100644 SigColorFastAviUtl/filter.h create mode 100644 SigColorFastAviUtl/macro.props create mode 100644 SigColorFastAviUtl/sigcolorfastaviutl.cpp diff --git a/SigColorFastAviUtl.sln b/SigColorFastAviUtl.sln new file mode 100644 index 0000000..d78acf4 --- /dev/null +++ b/SigColorFastAviUtl.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SigColorFastAviUtl", "SigColorFastAviUtl\SigColorFastAviUtl.vcxproj", "{12C3C998-F502-4B2E-9A79-AF67D63094A5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {12C3C998-F502-4B2E-9A79-AF67D63094A5}.Debug|x86.ActiveCfg = Debug|Win32 + {12C3C998-F502-4B2E-9A79-AF67D63094A5}.Debug|x86.Build.0 = Debug|Win32 + {12C3C998-F502-4B2E-9A79-AF67D63094A5}.Release|x86.ActiveCfg = Release|Win32 + {12C3C998-F502-4B2E-9A79-AF67D63094A5}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/SigColorFastAviUtl/Histogram.cpp b/SigColorFastAviUtl/Histogram.cpp new file mode 100644 index 0000000..e08339e --- /dev/null +++ b/SigColorFastAviUtl/Histogram.cpp @@ -0,0 +1,62 @@ +#include "Histogram.h" +#include +#include + +template +Histogram::Histogram(T * image, size_t w, size_t h, size_t stride, int channels, int min, int step, int bin) +{ + if (image == nullptr) + { + throw (std::invalid_argument("Histogram: image pointer cannot be Null pointer.\n")); + } + if (w == 0) + { + throw (std::invalid_argument("Histogram: w cannot be ZERO.\n")); + } + if (h == 0) + { + throw (std::invalid_argument("Histogram: h cannot be ZERO.\n")); + + } + if (stride < sizeof(T)*channels*w) + { + throw (std::invalid_argument("Histogram: stride in bytes is smaller than the minimum possible for w and channels.\n")); + } + unsigned char* byte_ptr = reinterpret_cast(image); + kmin = std::max(min, std::numeric_limits().min()); + kstep = step; + kmax = kmin + kstep*bin; + // populate the independent variable + for (int i = kmin; i <= kmax; i++) + { + table.insert({ i, 0 }); + } + // count pixels, row-wise + double lb, ub, d; + size_t accumulator{ 0 }; + for (auto& b : table) + { + d = static_cast(step) * 0.5; + lb = static_cast(b.first) - d; + ub = static_cast(b.first) + d; + //loop row-wise to handle stride + for (int r = 0; r < h; r++) + { + T* row_ptr = reinterpret_cast(byte_ptr + stride*r); + for (int c = 0; c < w; c++) + { + double sample = static_cast(*row_ptr); + if ((sample >= lb) && (sample < ub)) // [a, b)[b, c) + { + accumulator++; + } + row_ptr += channels; + } + } // end of row + b.second = static_cast(accumulator); //set freq + accumulator = 0; + } + +} + + diff --git a/SigColorFastAviUtl/Histogram.h b/SigColorFastAviUtl/Histogram.h new file mode 100644 index 0000000..a9d9609 --- /dev/null +++ b/SigColorFastAviUtl/Histogram.h @@ -0,0 +1,13 @@ +#pragma once +#include "LUT.h" +#include +template class Histogram : + public LUT +{ +public: + Histogram(T* image, size_t w, size_t h, size_t stride, int channels=1, int min= std::numeric_limits().min(), int step=1, + int bin= std::min(std::numeric_limits().max()- std::numeric_limits().min(), 65535)); + ~Histogram() = default; + +}; + diff --git a/SigColorFastAviUtl/LUT.cpp b/SigColorFastAviUtl/LUT.cpp new file mode 100644 index 0000000..d56840b --- /dev/null +++ b/SigColorFastAviUtl/LUT.cpp @@ -0,0 +1,73 @@ +#include "LUT.h" + + + +LUT::LUT(): table{}, kmin{0}, kmax{0}, kstep{1} +{ // Nothing todo +} + + +LUT::~LUT() +{ +} + +int LUT::lookup(int key) +{ + /* Clamp to min max */ + if (key > kmax) + { + key = kmax; + } + else if (key < kmin) + { + key = kmin; + } + else + { + //OK + } + /** quantize key to the nearest valid value **/ + key = ((key - kmin) / kstep)*kstep + kmin; + /* lookup */ + int ret; + try + { + ret = table.at(key); + } + catch (std::out_of_range e) + { + ret = kmin; + } + return ret; +} + +int LUT::min() const +{ + + return kmin; +} + +int LUT::max() const +{ + return kmax; +} + +int LUT::step() const +{ + return kstep; +} + +void LUT::min(int key) +{ + kmin = key; +} + +void LUT::max(int key) +{ + kmax = key; +} + +void LUT::step(int delta) +{ + kstep = delta; +} diff --git a/SigColorFastAviUtl/LUT.h b/SigColorFastAviUtl/LUT.h new file mode 100644 index 0000000..6c3d341 --- /dev/null +++ b/SigColorFastAviUtl/LUT.h @@ -0,0 +1,28 @@ +#pragma once +#include +#include +#include +#include +#include + +/* Base class for Histogram and SigGraph */ +/* Use integer calculation for performance */ +class LUT +{ +public: + LUT(); + ~LUT(); + int lookup(int key); + //Getter + int min() const; + int max() const; + int step() const; + //Setter + void min(int key); + void max(int key); + void step(int delta); +protected: + std::map table; + int kmin, kmax, kstep; +}; + diff --git a/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj new file mode 100644 index 0000000..7a0c129 --- /dev/null +++ b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj @@ -0,0 +1,109 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {12C3C998-F502-4B2E-9A79-AF67D63094A5} + Win32Proj + SigColorFastAviUtl + 8.1 + + + + DynamicLibrary + true + v140 + MultiByte + + + DynamicLibrary + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + true + $(UtlPath) + .auf + + + false + $(UtlPath)plugins\ + .auf + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;SIGCOLORFASTAVIUTL_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;SIGCOLORFASTAVIUTL_EXPORTS;%(PreprocessorDefinitions) + true + Speed + StreamingSIMDExtensions2 + Fast + + + Windows + true + true + true + 6.1 + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.filters b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.filters new file mode 100644 index 0000000..ba4f6d7 --- /dev/null +++ b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.filters @@ -0,0 +1,45 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.user b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.user new file mode 100644 index 0000000..f2fff0f --- /dev/null +++ b/SigColorFastAviUtl/SigColorFastAviUtl.vcxproj.user @@ -0,0 +1,9 @@ + + + + $(UtlPath)aviutl.exe + $(UtlPath) + false + WindowsLocalDebugger + + \ No newline at end of file diff --git a/SigColorFastAviUtl/SigmoidTable.cpp b/SigColorFastAviUtl/SigmoidTable.cpp new file mode 100644 index 0000000..0b204ce --- /dev/null +++ b/SigColorFastAviUtl/SigmoidTable.cpp @@ -0,0 +1,34 @@ +#include "SigmoidTable.h" +#include +#include + + + +SigmoidTable::SigmoidTable(float midtone, float strength, int bin, float multiplier) +{ + kstep = static_cast(multiplier / static_cast(bin)); + kmin = kstep / 2; + kmax = kmin + kstep*bin; + for (int x = kmin; x <= kmax; x += kstep) + { + float u = static_cast(x) / multiplier; + float a = midtone; + float b = strength; + //float e1, e2, e3, e4; + float result[4]{ 0 }; + result[0] = std::expf(b*(a - u)); + result[1] = std::expf(a*b); + result[2] = std::expf(b*(a - 1)); + result[3] = result[1]; + + __m128 ei = _mm_loadu_ps(result); + __m128 v1 = _mm_set1_ps(1.0f); + __m128 dst = _mm_add_ps(ei, v1); + ei = _mm_div_ps(v1, dst); + + _mm_storeu_ps(result, ei); + float y = (result[0] - result[1]) / (result[2] - result[3]); + y *= multiplier; + table.insert({ x, static_cast(y) }); + } +} diff --git a/SigColorFastAviUtl/SigmoidTable.h b/SigColorFastAviUtl/SigmoidTable.h new file mode 100644 index 0000000..e5f4481 --- /dev/null +++ b/SigColorFastAviUtl/SigmoidTable.h @@ -0,0 +1,10 @@ +#pragma once +#include "LUT.h" +class SigmoidTable : + public LUT +{ +public: + SigmoidTable(float midtone, float strength, int bin, float multiplier); + ~SigmoidTable()=default; +}; + diff --git a/SigColorFastAviUtl/filter.h b/SigColorFastAviUtl/filter.h new file mode 100644 index 0000000..1a0f0c4 --- /dev/null +++ b/SigColorFastAviUtl/filter.h @@ -0,0 +1,958 @@ +#pragma once +#include +//---------------------------------------------------------------------------------- +// Filter Plugin Header file for AviUtl version 0.99k and later +// By Mr. Ken, Comment translated to English by Maverick Tse +// Translation completed on 2014-05-05 +//---------------------------------------------------------------------------------- + +// YC Struct +typedef struct { + short y; // Pixel data-Y ( 0 ~ 4096 ) + short cb; // Pixel data-Cb ( -2048 ~ 2048 ) + short cr; // Pixel data-Cr ( -2048 ~ 2048 ) + // Pixel data can get outside of the above range + // +} PIXEL_YC; + +// PIXEL Struct +typedef struct { + unsigned char b, g, r; // Pixel(RGB)Data (0~255) +} PIXEL; + +// Filter_PROC Struct +typedef struct { + int flag; // Filter flag + // FILTER_PROC_INFO_FLAG_INVERT_FIELD_ORDER : Reverse field order ( normally treat as BFF ) + // FILTER_PROC_INFO_FLAG_INVERT_INTERLACE : invert deinterlace method (For use with deinterlace filter only) + PIXEL_YC *ycp_edit; // Pointer to image data ( ycp_editand ycp_temp can be swapped ) + PIXEL_YC *ycp_temp; // pointer to temp area + int w, h; // image/frame size ( image size can be changed ) + int max_w, max_h; // Canvas size (set in ENVIRONMENT SETTINGS) + int frame; // Current frame no.( starts from zero ) + int frame_n; // Total frame count + int org_w, org_h; // Original image size + short *audiop; // Pointer to audio data ( For audio file only ) + // Audio format is PCM16bit ( for one sample, mono = 2byte , stereo = 4byte ) + int audio_n; // Total audio sample + int audio_ch; // No. of audio channel + PIXEL *pixelp; // Not used + void *editp; // Edit handle + int yc_size; // Size of total pixel data in bytes + int line_size; // Width of image area in bytes + int reserve[8]; // Reserved for future use +} FILTER_PROC_INFO; +#define FILTER_PROC_INFO_FLAG_INVERT_FIELD_ORDER 0x00010000 +#define FILTER_PROC_INFO_FLAG_INVERT_INTERLACE 0x00020000 +// ※For de-interlace filter, ycp_edit is not initialized with image data。 +// ※De-interlace filter cannot change ycp_edit,ycp_temp,w and h + +// Frame Status Struct +typedef struct { + int video; // Video data ID + int audio; // Audio data ID + int inter; // Interlace status + // FRAME_STATUS_INTER_NORMAL : Normal + // FRAME_STATUS_INTER_REVERSE : Reverse + // FRAME_STATUS_INTER_ODD : Odd + // FRAME_STATUS_INTER_EVEN : Even + // FRAME_STATUS_INTER_MIX : BOB + // FRAME_STATUS_INTER_AUTO : Auto + int index24fps; // Not used + int config; // Profile ID for frame + int vcm; // Compression setting ID for frame + int edit_flag; // Editing flag + // EDIT_FRAME_EDIT_FLAG_KEYFRAME : Keyframe + // EDIT_FRAME_EDIT_FLAG_MARKFRAME : Marked frame + // EDIT_FRAME_EDIT_FLAG_DELFRAME : preferred frame for decimation + // EDIT_FRAME_EDIT_FLAG_NULLFRAME : Copy frame + int reserve[9]; // Reserved for future expansion +} FRAME_STATUS; +#define FRAME_STATUS_INTER_NORMAL 0 +#define FRAME_STATUS_INTER_REVERSE 1 +#define FRAME_STATUS_INTER_ODD 2 +#define FRAME_STATUS_INTER_EVEN 3 +#define FRAME_STATUS_INTER_MIX 4 +#define FRAME_STATUS_INTER_AUTO 5 +#define EDIT_FRAME_EDIT_FLAG_KEYFRAME 1 +#define EDIT_FRAME_EDIT_FLAG_MARKFRAME 2 +#define EDIT_FRAME_EDIT_FLAG_DELFRAME 4 +#define EDIT_FRAME_EDIT_FLAG_NULLFRAME 8 + +// File info Struct +typedef struct { + int flag; // File flag + // FILE_INFO_FLAG_VIDEO : Video exists + // FILE_INFO_FLAG_AUDIO : Audio exists + LPSTR name; // File name ( avi_file_open() will give NULL ) + int w, h; // Original size + int video_rate, video_scale; // Frame rate + int audio_rate; // Audio sampling rate + int audio_ch; // Audio channel count + int frame_n; // Total frame count + DWORD video_decode_format; // Video decode format + int video_decode_bit; // bit count for video decode + int audio_n; // Total sample count for audio ( only set when calling avi_file_open()) + int reserve[4]; // Reserved for future use +} FILE_INFO; +#define FILE_INFO_FLAG_VIDEO 1 +#define FILE_INFO_FLAG_AUDIO 2 + +// System Info Struct +typedef struct { + int flag; // System flag + // SYS_INFO_FLAG_EDIT : Editing + // SYS_INFO_FLAG_VFAPI : VFAPI is running + // SYS_INFO_FLAG_USE_SSE : using SSE + // SYS_INFO_FLAG_USE_SSE2 : using SSE2 + LPSTR info; // Version info + int filter_n; // No. of registered filters + int min_w, min_h; // Min. editable image size + int max_w, max_h; // Max. editable image size + int max_frame; // Max. frame count that can be handled + LPSTR edit_name; // Editing file's name (Contains nothing if filename is not set) + LPSTR project_name; // Project file's name (Contains nothing if filename is not set) + LPSTR output_name; // Output file name (Contains nothing if filename is not set) + int vram_w, vram_h; // Size of image data for editing + int vram_yc_size; // Size of total pixel data in bytes + int vram_line_size; // Width of image data in bytes + HFONT hfont; // Font handle used by filter's setting dialog + int build; // Build No. (Increase with new version) + int reserve[2]; // Reserved for future use +} SYS_INFO; +#define SYS_INFO_FLAG_EDIT 1 +#define SYS_INFO_FLAG_VFAPI 2 +#define SYS_INFO_FLAG_USE_SSE 4 +#define SYS_INFO_FLAG_USE_SSE2 8 + +// Declaration for Multi-thread function +// thread_id : Thread ID ( 0 ~ thread_num-1 ) +// thread_num : Thread count ( 1 ~ ) +// param1 : general parameter +// param2 : general parameter +typedef void(*MULTI_THREAD_FUNC)(int thread_id, int thread_num, void *param1, void *param2); + +// Handle for Inputted AVI file +typedef void* AVI_FILE_HANDLE; + +// Struct for external functions +typedef struct { + // ※Use of get_ycp_source_cache() is preferred + // + // Obtains Image Data's pointer of Frame plus offset + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // ofs : Offset from Frame + // Return Value : pointer to Image Data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void(*get_ycp_ofs)(void *editp, int n, int ofs); + + // ※Use of get_ycp_source_cache() is preferred + // Obtains Image Data's pointer of specified Frame + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // Return Value : pointer to Image Data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void *(*get_ycp)(void *editp, int n); + + // Obtains Image Data's pointer for specified Frame in DIB format(RGB24bit) + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // Return Value : pointer to DIB-format data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void *(*get_pixelp)(void *editp, int n); + + // Read Audio Data of specified Frame + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // buf : Storage buffer (NULL to get sample count only) + // Return Value : Imported sample count + int(*get_audio)(void *editp, int n, void *buf); + + // Check if editing + // editp : Editing Handle + // Return Value : TRUE if editing + BOOL(*is_editing)(void *editp); + + // Check if saving + // editp : Editing Handle + // Return Value : TRUE if saving + BOOL(*is_saving)(void *editp); + + // Obtains Currently Displaying Frame + // editp : Editing Handle + // Return Value : Current Frame number + int(*get_frame)(void *editp); + + // Obtains total frame count + // editp : Editing Handle + // Return Value : Current total frame count + int(*get_frame_n)(void *editp); + + // Obtains Frame-size before filtering + // editp : Editing Handle + // w,h : pointers for storing image size + // Return Value : TRUE if successful + BOOL(*get_frame_size)(void *editp, int *w, int *h); + + // Change Currently Displaying frame + // editp : Editing Handle + // n : Frame number + // Return Value : Set Frame number + int(*set_frame)(void *editp, int n); + + // Change total frame count + // editp : Editing Handle + // n : Frame count + // Return Value : Set total frame count + int(*set_frame_n)(void *editp, int n); + + // Copy frame from one to another + // editp : Editing Handle + // d : Frame number of copy destination + // s : Frame number of copy source + // Return Value : TRUE if successful + BOOL(*copy_frame)(void *editp, int d, int s); + + // Copy ONLY image data to other frame + // editp : Editing Handle + // d : Frame number of copy destination + // s : Frame number of copy source + // Return Value : TRUE if successful + BOOL(*copy_video)(void *editp, int d, int s); + + // Copy ONLY audio data to other frame + // editp : Editing Handle + // d : Frame number of copy destination + // s : Frame number of copy source + // Return Value : TRUE if successful + BOOL(*copy_audio)(void *editp, int d, int s); + + // Copy DIB image(RGB24bit) to clipboard + // hwnd : Window handle + // pixelp Pointer to DIB-format data + // w,h : Image size + // Return Value : TRUE if successful + BOOL(*copy_clip)(HWND hwnd, void *pixelp, int w, int h); + + // Paste image from Clipboard + // hwnd : Window Handle + // editp : Editing Handle + // n : Frame number + // Return Value : TRUE if successful + BOOL(*paste_clip)(HWND hwnd, void *editp, int n); + + // Obtains Frame status + // editp : Editing Handle + // n : Frame number + // fps Pointer to Frame status + // Return Value : TRUE if successful + BOOL(*get_frame_status)(void *editp, int n, FRAME_STATUS *fsp); + + // Change Frame status + // editp : Editing Handle + // n : Frame number + // fsp Pointer to Frame status + // Return Value : TRUE if successful + BOOL(*set_frame_status)(void *editp, int n, FRAME_STATUS *fsp); + + // Check if frame was saved + // editp : Editing Handle + // n : Frame number + // Return Value : TRUE if saved + BOOL(*is_saveframe)(void *editp, int n); + + // Check if it is a Keyframe + // editp : Editing Handle + // n : Frame number + // Return Value : TRUE for Keyframe + BOOL(*is_keyframe)(void *editp, int n); + + // Check if re-compression is required + // editp : Editing Handle + // n : Frame number + // Return Value : TRUE for required + BOOL(*is_recompress)(void *editp, int n); + + // ReDraw sliders and checkboxes of setting dialog + // fp : pointer to FILTER Struct + // Return Value : TRUE if successful + BOOL(*filter_window_update)(void *fp); + + // Check if setting dialog is being shown + // fp : pointer to FILTER Struct + // Return Value : TRUE if being displayed + BOOL(*is_filter_window_disp)(void *fp); + + // Obtains info on the file being edited + // editp : Editing Handle + // fip Pointer to FileInfo Struct + // Return Value : TRUE if successful + BOOL(*get_file_info)(void *editp, FILE_INFO *fip); + + // Obtains Current Profile name + // editp : Editing Handle + // n : Profile Environment number + // Return Value : pointer to Profile name (Return NULL when Failed) + LPSTR(*get_config_name)(void *editp, int n); + + // Check if filter is active + // fp : pointer to FILTER Struct + // Return Value : TRUE is active + BOOL(*is_filter_active)(void *fp); + + // Read Image Data of specified Frame as DIB(RGB24bit) + // This is the post-filtered image + // editp : Editing Handle + // n : Frame number + // pixelp : pointer to DIB-formatted data (return image size only when NULL) + // w,h : Image size (Return DIB data only when NULL) + // Return Value : TRUE if successful + BOOL(*get_pixel_filtered)(void *editp, int n, void *pixelp, int *w, int *h); + + // Read Audio Data of specified Frame + // Post-filtered data + // editp* : Editing Handle + // n : Frame number + // buf : Storage buffer (Return sampling count only when NULL) + // Return Value : Imported sampling count + int(*get_audio_filtered)(void *editp, int n, void *buf); + + // Obtains Starting and Ending Frames of selection + // editp : Editing Handle + // s : Starting frame of selection + // e : Ending frame of selection + // Return Value : TRUE if successful + BOOL(*get_select_frame)(void *editp, int *s, int *e); + + // Set Starting and Ending Frames of selection + // editp : Editing Handle + // s : Starting frame of selection + // e : Ending frame of selection + // Return Value : TRUE if successful + BOOL(*set_select_frame)(void *editp, int s, int e); + + // Convert from PIXEL to PIXEL_YC + // ycp Pointer to PIXEL_YC Struct + // pixelp Pointer to PIXEL Struct + // w : No. of Struct + // Return Value : TRUE if successful + BOOL(*rgb2yc)(PIXEL_YC *ycp, PIXEL *pixelp, int w); + + // Convert from PIXEL_YC to PIXEL + // pixelp Pointer to PIXEL Struct + // ycp Pointer to PIXEL_YC Struct + // w : No. of Struct + // Return Value : TRUE if successful + BOOL(*yc2rgb)(PIXEL *pixelp, PIXEL_YC *ycp, int w); + + // Obtains Import filename passed from File Dialog + // name : Pointer to filename + // filter : File filter + // def : Default filename + // Return Value : TRUE if successful, FALSE for Cancel + BOOL(*dlg_get_load_name)(LPSTR name, LPSTR filter, LPSTR def); + + // Obtains save filename passed from File Dialog + // name : Pointer to filename + // filter : File filter + // def : Default filename + // Return Value : TRUE if successful, FALSE for Cancel + BOOL(*dlg_get_save_name)(LPSTR name, LPSTR filter, LPSTR def); + + // Read value from INI file + // fp : Pointer to FILTER Struct + // key : Name for access key + // n : Default value + // Return Value : Read value + int(*ini_load_int)(void *fp, LPSTR key, int n); + + // Write value to INI file + // fp : Pointer to FILTER Struct + // key : Name for access key + // n : Value to write + // Return Value : Written value + int(*ini_save_int)(void *fp, LPSTR key, int n); + + // Read text from INI file + // fp : Pointer to FILTER Struct + // key : Name for access key + // str : Text buffer + // def : Default text + // Return Value : TRUE if successful + BOOL(*ini_load_str)(void *fp, LPSTR key, LPSTR str, LPSTR def); + + // Write text to INI file + // fp : Pointer to FILTER Struct + // key : Name for access key + // n : Text to write + // Return Value : TRUE if successful + BOOL(*ini_save_str)(void *fp, LPSTR key, LPSTR str); + + // Obtains specified FileInfo from file ID + // editp : Editing Handle + // fip Pointer to FileInfo Struct + // souce_file_id + // : File ID + // Return Value : TRUE if successful + BOOL(*get_source_file_info)(void *editp, FILE_INFO *fip, int source_file_id); + + // Obtains source file's ID and frame count for a given frame + // editp : Editing Handle + // n : Frame number + // souce_file_id + // : pointer to file ID + // souce_video_number + // : pointer to frame count + // Return Value : TRUE if successful + BOOL(*get_source_video_number)(void *editp, int n, int *source_file_id, int *source_video_number); + + // Obtains System Info + // editp : Editing Handle (set NULL to invalidate all flags and filename associated with sip) + // sip Pointer to SystemInfo Struct + // Return Value : TRUE if successful + BOOL(*get_sys_info)(void *editp, SYS_INFO *sip); + + // Obtains the pointer to FILTER Struct with a specific Filter ID + // filter_id + // : Filter ID (0~Total filter count-1) + // Return Value : pointer to Filter Struct (Return NULL when Failed) + void *(*get_filterp)(int filter_id); + + // ※Please use get_ycp_filtering_cache_ex() instead whenever possible + // Obtains Image Data's pointer of specified Frame + // The image is the one JUST before processing by current filter + // fp : Pointer to FILTER Struct + // editp : Editing Handle + // n : Frame number + // reserve : NULL + // Return Value : pointer to Image Data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void *(*get_ycp_filtering)(void *fp, void *editp, int n, void *reserve); + + // Read Audio Data from specified Frame + // The data is the one JUST before processing by current filter + // fp : Pointer to FILTER Struct + // editp : Editing Handle + // n : Frame number + // buf : Storage buffer (NULL for getting sample count only) + // Return Value : Imported sample count + int(*get_audio_filtering)(void *fp, void *editp, int n, void *buf); + + // Set cache for get_ycp_filtering_cache_ex() + // Cache is re-allocated when setting changed + // Cache is allocated only when filter is active + // fp : Pointer to FILTER Struct + // w : Width of cache area + // h : Height of cache area + // d : Number of frames to cache + // flag : NULL + // Return Value : TRUE if successful + BOOL(*set_ycp_filtering_cache_size)(void *fp, int w, int h, int d, int flag); + + // ※Please use get_ycp_filtering_cache_ex() instead whenever possible + // Obtains Image Data's cache pointer for specified Frame + // Follow cache settings defined by set_ycp_filtering_cache_size() + // The data is the one just before processing by current filter + // fp : Pointer to FILTER Struct + // editp : Editing Handle + // n : Frame number + // Return Value : cache pointer to Image Data (Return NULL when Failed) + // Content in pointer will be valid until cache is discarded + void *(*get_ycp_filtering_cache)(void *fp, void *editp, int n); + + // Obtains Image Data's pointer of specified Frame + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // ofs : Frame offset w.r.t. original AVI + // Return Value : pointer to Image Data (Return NULL when Failed) + // Content in pointer will be valid until cache is discarded + void *(*get_ycp_source_cache)(void *editp, int n, int ofs); + + // Obtains Image Data's pointer for the frame being displayed + // Post-filtered data + // Usable in Display/Window Filter only + // editp : Editing Handle + // format : Image format( NULL = RGB24bit / 'Y''U''Y''2' = YUY2 ) + // Return Value : pointer to Image Data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void *(*get_disp_pixelp)(void *editp, DWORD format); + + // Read Image Data from specified Frame + // The data are those before any filtering + // editp : Editing Handle + // n : Frame number + // pixelp : pointer to DIB-format data + // format : Image format( NULL = RGB24bit / 'Y''U''Y''2' = YUY2 ) + // Return Value : TRUE if successful + BOOL(*get_pixel_source)(void *editp, int n, void *pixelp, DWORD format); + + // Read Image Data from specified Frame + // Post-filtered data + // editp : Editing Handle + // n : Frame number + // pixelp : pointer to DIB-format data pointer (set NULL to return image size only) + // w,h : Image size (set NULL to return DIB-format data only) + // format : Image format( NULL = RGB24bit / 'Y''U''Y''2' = YUY2 ) + // Return Value : TRUE if successful + BOOL(*get_pixel_filtered_ex)(void *editp, int n, void *pixelp, int *w, int *h, DWORD format); + + // Obtains Image cache pointer of specified Frame + // Follow cache setting defined by set_ycp_filtering_cache_size() + // The data is the one just before processing by current filter + // fp : Pointer to FILTER Struct + // editp : Editing Handle + // n : Frame number + // w,h : Obtained Image size (set NULL to ignore) + // Return Value : Cache pointer to Image Data (Return NULL when Failed) + // Content referred by pointer is valid unitl cache is discarded + PIXEL_YC *(*get_ycp_filtering_cache_ex)(void *fp, void *editp, int n, int *w, int *h); + + // Call specified function with threads as defined in system settings + // Please DO NOT call Win32API or External functions( except rgb2yc,yc2rgb) inside this function + // func : The function to be called + // param1 : General parameter passable to the called function + // param2 : General parameter passable to the called function + // Return Value : TRUE if successful + BOOL(*exec_multi_thread_func)(MULTI_THREAD_FUNC func, void *param1, void *param2); + + // Make empty image data + // Though this can be used by external function just like ycp_edit, + // this can not be swapped with ycp_edit,ycp_temp in FILTER_PROC_INFO + // Return Value : pointer to created Image Data (Return NULL when Failed) + PIXEL_YC *(*create_yc)(void); + + // Delete object created by create_yc + void(*delete_yc)(PIXEL_YC *ycp); + + // Read image data from BMP file + // ycp : pointer to the frame where the image is to be imported (set NULL to skip updating image) + // file : BMP filename + // w,h : Imported Image size (can be set to NULL) + // flag : NULL + // Return Value : TRUE if successful + BOOL(*load_image)(PIXEL_YC *ycp, LPSTR file, int *w, int *h, int flag); + + // Resize image data + // Transform original image to any arbitary size + // ycp : pointer to resized image data + // w,h : target resolution + // ycp_src : Pointer to original image data( same as ycp if set to NULL) + // sx,sy : Coordinate of Top-left corner of original image w.r.t. resized image + // sw,sh : Size of original image w.r.t. resized image + void(*resize_yc)(PIXEL_YC *ycp, int w, int h, PIXEL_YC *ycp_src, int sx, int sy, int sw, int sh); + + // Copy arbitary area from an image data + // The image will be clipped to fit max resolution + // Please do not overlap the area of source and destination + // ycp Pointer to copy destination + // x,y : Top-left corner of destination + // ycp_src Pointer to source image + // sx,sy : Top-left coordinate of source + // sw,sh : size of source + // tr : Transparency of source (0~4096) + void(*copy_yc)(PIXEL_YC *ycp, int x, int y, PIXEL_YC *ycp_src, int sx, int sy, int sw, int sh, int tr); + + // Draw text on frame image + // Clipping may occur to fit max resolution + // ycp : pointer to Image Data (NULL to skip drawing and just return the size) + // x,y : Top-left of the drawing coordinate + // text : The text itself + // r,g,b : Color (0~255) + // tr : Transparency (0~4096) + // hfont : Font (NULL for default font) + // w,h : Size of the resulting drawn text (can be NULL) + void(*draw_text)(PIXEL_YC *ycp, int x, int y, LPSTR text, int r, int g, int b, int tr, HFONT hfont, int *w, int *h); + + // Obtains a handle for use with avi_file_read_video() and avi_file_read_audio() + // when opening AVI file + // ※File and format can be different from the one being edited + // file : AVI filename (also accepts file that passthrough import plugins) + // fip : pointer to FileInfo Struct (Contains info for imported file) + // flag : Open flags + // AVI_FILE_OPEN_FLAG_ONLY_YUY2 : Expand to YUY2 + // AVI_FILE_OPEN_FLAG_ONLY_RGB24 : Expand to RGB24 + // AVI_FILE_OPEN_FLAG_ONLY_RGB32 : Expand to RGB32 + // AVI_FILE_OPEN_FLAG_VIDEO_ONLY : Read video stream only + // AVI_FILE_OPEN_FLAG_AUDIO_ONLY : Read audio stream only + // Return Value : AVI file handle (Return NULL when Failed) + AVI_FILE_HANDLE(*avi_file_open)(LPSTR file, FILE_INFO *fip, int flag); + + // Close AVI file + // afh : AVI file handle + void(*avi_file_close)(AVI_FILE_HANDLE afh); + + // Read Image Data from AVI file + // afh : AVI file handle + // ycp Pointer to Image Data + // n : Frame number + // Return Value : TRUE if successful + BOOL(*avi_file_read_video)(AVI_FILE_HANDLE afh, PIXEL_YC *ycp, int n); + + // Read audio from AVI file + // afh : AVI file handle + // buf Pointer to audio buffer + // n : Frame number + // Return Value : Opened sample count + int(*avi_file_read_audio)(AVI_FILE_HANDLE afh, void *buf, int n); + + // Obtains DIB Image Data's pointer from AVI file + // Image format depends on video decode format as defined in + // FILE_INFO, which in turn was obtained from avi_file_open() + // afh : AVI file handle + // n : Frame number + // Return Value : pointer to DIB-format data (Return NULL when Failed) + // Content of Image Data pointer is valid until external function or Main returns + void *(*avi_file_get_video_pixelp)(AVI_FILE_HANDLE afh, int n); + + // Obtains the file filter(format) as supported by avi_file_open() + // type : file type + // GET_AVI_FILE_FILTER_TYPE_VIDEO : Video + // GET_AVI_FILE_FILTER_TYPE_AUDIO : Audio + // Return Value Pointer to File filter + LPSTR(*get_avi_file_filter)(int type); + + // Read audio data from AVI file + // afh : AVI file handle + // start : sample number for reading to begin with + // length : sample counts to be read + // buf Pointer to audio buffer + // Return Value : Imported sample count + int(*avi_file_read_audio_sample)(AVI_FILE_HANDLE afh, int start, int length, void *buf); + + // Change sampling rate an others when using avi_file_read_audio_sample() + // afh : AVI file handle + // audio_rate : Sampling rate + // audio_ch : Channel count + // Return Value : Total sample count w.r.t. changed sampling rate + int(*avi_file_set_audio_sample_rate)(AVI_FILE_HANDLE afh, int audio_rate, int audio_ch); + + // Obtains pointer to Frame status buffer + // editp : Editing Handle + // type : type of status + // FARME_STATUS_TYPE_EDIT_FLAG : Editing flag + // FARME_STATUS_TYPE_INTER : Interlace flag + // Return Value Pointer to buffer + // Content referenced by pointer is valid until file is closed + BYTE *(*get_frame_status_table)(void *editp, int type); + + // Set current editing status in Undo buffer + // editp : Editing Handle + // Return Value : TRUE if successful + BOOL(*set_undo)(void *editp); + + // Add a new item under the Setting/Filter+ menu + // When the menu is selected, WM_FILTER_COMMAND's message will pass to + // specific window via hwnd + // Please call this function at least once from either func_init() or WM_FILTER_INIT + // fp : Pointer to FILTER Struct + // name : menu name + // hwnd : Window Handle that sends WM_FILTER_COMMAND + // id : WPARAM of WM_FILTER_COMMAND + // def_key : Virtual keycode for Shortcut key (NULL for no shortcut) + // flag : flags... + // ADD_MENU_ITEM_FLAG_KEY_SHIFT : Use SHIFT for shortcut key + // ADD_MENU_ITEM_FLAG_KEY_CTRL : Use Ctrl for shortcut key + // ADD_MENU_ITEM_FLAG_KEY_ALT : Use Alt for shortcut key + // Return Value : TRUE if successful + BOOL(*add_menu_item)(void *fp, LPSTR name, HWND hwnd, int id, int def_key, int flag); + + // Open file for editing + // editp : Editing Handle + // file : filename + // flag : flags... + // EDIT_OPEN_FLAG_ADD : Add/Append to current session + // EDIT_OPEN_FLAG_AUDIO : Import audio + // EDIT_OPEN_FLAG_PROJECT : Open project file + // EDIT_OPEN_FLAG_DIALOG : Show Open File dialog box + // Return Value : TRUE if successful + BOOL(*edit_open)(void *editp, LPSTR file, int flag); + + // Close editing file + // editp : Editing Handle + // Return Value : TRUE if successful + BOOL(*edit_close)(void *editp); + + // Export editing data to AVI + // Also allows "Export to WAV" or "Export with Plugin" + // editp : Editing Handle + // file : Output filename + // flag : flags... + // EDIT_OUTPUT_FLAG_NO_DIALOG : No export dialog + // EDIT_OUTPUT_FLAG_WAV : Export WAV + // type : name of export plugin (NULL for AVI/WAV Export) + // Return Value : TRUE if successful + BOOL(*edit_output)(void *editp, LPSTR file, int flag, LPSTR type); + + // Set profile + // editp : Editing Handle + // n : profile environment's number + // name : Profile name + // Return Value : TRUE if successful + BOOL(*set_config)(void *editp, int n, LPSTR name); + int reserve[7]; +} EXFUNC; +#define AVI_FILE_OPEN_FLAG_VIDEO_ONLY 16 +#define AVI_FILE_OPEN_FLAG_AUDIO_ONLY 32 +#define AVI_FILE_OPEN_FLAG_ONLY_YUY2 0x10000 +#define AVI_FILE_OPEN_FLAG_ONLY_RGB24 0x20000 +#define AVI_FILE_OPEN_FLAG_ONLY_RGB32 0x40000 +#define GET_AVI_FILE_FILTER_TYPE_VIDEO 0 +#define GET_AVI_FILE_FILTER_TYPE_AUDIO 1 +#define FARME_STATUS_TYPE_EDIT_FLAG 0 +#define FARME_STATUS_TYPE_INTER 1 +#define ADD_MENU_ITEM_FLAG_KEY_SHIFT 1 +#define ADD_MENU_ITEM_FLAG_KEY_CTRL 2 +#define ADD_MENU_ITEM_FLAG_KEY_ALT 4 +#define EDIT_OPEN_FLAG_ADD 2 +#define EDIT_OPEN_FLAG_AUDIO 16 +#define EDIT_OPEN_FLAG_PROJECT 512 +#define EDIT_OPEN_FLAG_DIALOG 65536 +#define EDIT_OUTPUT_FLAG_NO_DIALOG 2 +#define EDIT_OUTPUT_FLAG_WAV 4 + +// フィルタ Struct +typedef struct { + int flag; // Filter Flags... + // FILTER_FLAG_ALWAYS_ACTIVE : Filter is always active + // FILTER_FLAG_CONFIG_POPUP : Use pop-up menu for setting dialog + // FILTER_FLAG_CONFIG_CHECK : checkboxes became menu items under Settings/Filter+ + // FILTER_FLAG_CONFIG_RADIO : Only one of the checkboxs can be enabled at one time(i.e. mutually exclusive options) + // FILTER_FLAG_EX_DATA : Extended data can be saved + // FILTER_FLAG_PRIORITY_HIGHEST : Filter always has highest priority + // FILTER_FLAG_PRIORITY_LOWEST : Filter always has lowest priority + // FILTER_FLAG_WINDOW_THICKFRAME : Window size can be changed by user + // FILTER_FLAG_WINDOW_SIZE : Window size can be defined + // FILTER_FLAG_DISP_FILTER : This is a Display/Window filter + // FILTER_FLAG_REDRAW : Let plugin to handle refresh + // FILTER_FLAG_EX_INFORMATION : Allows setting of extra info for filter + // FILTER_FLAG_INFORMATION : Please use FILTER_FLAG_EX_INFORMATION instead + // FILTER_FLAG_NO_CONFIG : Hide setting window + // FILTER_FLAG_AUDIO_FILTER : Make this an audio filter + // FILTER_FLAG_RADIO_BUTTON : Change checkbox to radio button + // FILTER_FLAG_WINDOW_HSCROLL : Add a horizontal scroll bar + // FILTER_FLAG_WINDOW_VSCROLL : Add a vertical scroll bar + // FILTER_FLAG_INTERLACE_FILTER : Make this a deinterlace filter + // FILTER_FLAG_NO_INIT_DATA : Do not initialize image data for func_proc() + // FILTER_FLAG_IMPORT : Add item to Import menu + // FILTER_FLAG_EXPORT : Add item to Export menu + // FILTER_FLAG_MAIN_MESSAGE : func_WndProc()can send out WM_FILTER_MAIN_??? messages + int x, y; // When defining window size (FILTER_FLAG_WINDOW_SIZE) + // Use FILTER_WINDOW_SIZE_CLIENT to define size by Client area. + // Use FILTER_WINDOW_SIZE_ADD to define Extra area on top of standard size. + TCHAR *name; // Filter name + int track_n; // Slider count + TCHAR **track_name; // pointer to sliders' names (can be NULL if no slider used) + int *track_default; // pointer to sliders' default values (can be NULL if no slider used) + int *track_s, *track_e; // Sliders' range (NULL for all 0-256) + int check_n; // number of checkbox + TCHAR **check_name; // pointer to checkboxes' names(can be NULL if no checkbox) + int *check_default; // pointer to checkboxes's default values (can be NULL if no checkbox) + // The checkbox will becomes a BUTTON when default value is NEGATIVE. When the button is pushed, WM_COMMAND( WPARAM = MID_FILTER_BUTTON + n ) will be sent out. + BOOL(*func_proc)(void *fp, FILTER_PROC_INFO *fpip); + // pointer to filtering function (skip calling if NULL) + BOOL(*func_init)(void *fp); + // pointer to initialization function (skip calling if NULL) + BOOL(*func_exit)(void *fp); + // pointer to exit function (skip calling if NULL) + BOOL(*func_update)(void *fp, int status); + // pointer to function to be called whenever settings is changed (skip calling if NULL) + // FILTER_UPDATE_STATUS_ALL : All parameters was changed + // FILTER_UPDATE_STATUS_TRACK + n : The n-th slider was changed + // FILTER_UPDATE_STATUS_CHECK + n : The n-th checkbox was changed + BOOL(*func_WndProc)(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, void *editp, void *fp); + // pointer to function to be called whenever window message arrives(skip calling if NULL) + // Not to be called when VFAPI is working + // The following extra messages are sent on top of the standard one + // WM_FILTER_UPDATE : Sent immediately after filter setting is changed or editing content modified + // WM_FILTER_FILE_OPEN : Sent after file is opened for editing + // WM_FILTER_FILE_UPDATE : After editing file is updated(e.g. Appending file, Importing audio) + // WM_FILTER_FILE_CLOSE : Sent JUST before editing file is closed + // WM_FILTER_INIT : After initialization + // WM_FILTER_EXIT : Just before exit + // WM_FILTER_SAVE_START : Just before save + // WM_FILTER_SAVE_END : Just after save + // WM_FILTER_IMPORT : Just after selecting import + // WM_FILTER_EXPORT : Just after selecting export + // WM_FILTER_CHANGE_ACTIVE : Just after filter toggle + // WM_FILTER_CHANGE_WINDOW : After the filter window's hidden state was changed + // WM_FILTER_CHANGE_PARAM : Just after parameters for this filter was changed + // WM_FILTER_CHANGE_EDIT : Just after switching editng/non-editing mode + // The following messages will be sent ONLY WHEN FILTER_FLAG_MAIN_MESSAGE is enabled + // WM_FILTER_MAIN_MOUSE_DOWN : Left mouse press on main window + // WM_FILTER_MAIN_MOUSE_UP : Left mouse release on main window + // WM_FILTER_MAIN_MOUSE_MOVE : Mouse move on main window + // WM_FILTER_MAIN_MOUSE_DBLCLK : Double click on main window + // WM_FILTER_MAIN_MOUSE_R_DOWN : Right mouse down + // WM_FILTER_MAIN_MOUSE_R_UP : Right mouse release + // WM_FILTER_MAIN_MOUSE_WHEEL : Mouse scroll + // WM_FILTER_MAIN_KEY_DOWN : Some key is pressed + // WM_FILTER_MAIN_KEY_UP : Some key is released + // WM_FILTER_MAIN_MOVESIZE : When main window size or position has changed + // WM_FILTER_MAIN_CONTEXTMENU : When context menu is invoked on main window + // WM_FILTER_MAIN_MOUSE_???'s lparam holds the mouse coordinate w.r.t. editing image (0 when not editing) + // WM_FILTER_MAIN_MOUSE_WHEEL's wparam holds wheel's turn amount in its upper WORD + // WM_FILTER_MAIN_KEY_???'s wparam holds virtual key code + // WM_FILTER_MAIN_MOVESIZE's lparam holds main windows's Window Handle + // WM_FILTER_MAIN_CONTEXTMENU's lparam holds screen coordinate + // When menu is shown using WM_FILTER_MAIN_CONTEXTMENU please set Return Value to FALSE(no refresh) + // When Return Value is TRUE, editing content is completely redrawn + int *track; // pointer to sliders' settings (Set by AviUtl) + int *check; // pointer to checkboxes' setting (Set by AviUtl) + void *ex_data_ptr; // pointer to extended data (when FILTER_FLAG_EX_DATA is set) + int ex_data_size; // size of extended data ( when FILTER_FLAG_EX_DATAが is set) + TCHAR *information; // pointer to filter info (when FILTER_FLAG_EX_INFORMATION is set) + BOOL(*func_save_start)(void *fp, int s, int e, void *editp); + // pointer to function to be called just before saving begins (skip calling if NULL) + // s : First frame to be saved + // e : Last frame to be saved + // Return Value : TRUE if successful + BOOL(*func_save_end)(void *fp, void *editp); + // pointer to function to be called just before saving ends (skip calling if NULL) + EXFUNC *exfunc; // pointer to external function table (set by AviUtl) + HWND hwnd; // Window Handle (Set by AviUtl) + HINSTANCE dll_hinst; // Instance handle for DLL (Set by AviUtl) + void *ex_data_def; // pointer to initial data area of extended data (no initialization if NULL) + BOOL(*func_is_saveframe)(void *fp, void *editp, int saveno, int frame, int fps, int edit_flag, int inter); + // pointer to function to be called when a deinterlace filter decided which frame(s) should be saved (skip calling if NULL) + // saveno : First frame that should be saved + // frame : Editing frame number + // fps : settings for changing framerate (30,24,20,15,10) + // edit_flag : Edit flags + // inter : interlace state of frame + // Return Value : TRUE for Frame to be saved、FALSE for Frame to be dropped + BOOL(*func_project_load)(void *fp, void *editp, void *data, int size); + // pointer to function to be called when opening project file(skip calling if NULL) + // Will not be called when project is empty + // data : pointer to project data + // size : imported data size in bytes + // Return Value : TRUE if successful + BOOL(*func_project_save)(void *fp, void *editp, void *data, int *size); + // pointer to function to be called when saving project file (skip calling if NULL) + // Filter data is saved into project file + // In order to get saving size, AviUtl will initially call this function with data=NULL, then it will call again to get actual data. + // data : pointer to Storage buffer for project data to be written(NULL to return only the data size in bytes) + // size : pointer to data size to be written + // Return Value : TRUE if there are data to be saved + BOOL(*func_modify_title)(void *fp, void *editp, int frame, LPSTR title, int max_title); + // pointer to function to be called when title bar of main window is displayed (skip calling if NULL) + // Allows changing the text of title bar (will not be invoked when not editing or exporting file) + // frame : Editing frame number + // title : Text to be displayed + // max_title : buffer size of title + // Return Value : TRUE if successful + TCHAR *dll_path; // When a sub-directory of .\Plugins contains DLL, such folder name will be stored here. + int reserve[2]; // Reserved for expansion. Set to NULL. + +} FILTER; +#define FILTER_FLAG_ACTIVE 1 +#define FILTER_FLAG_ALWAYS_ACTIVE 4 +#define FILTER_FLAG_CONFIG_POPUP 8 +#define FILTER_FLAG_CONFIG_CHECK 16 +#define FILTER_FLAG_CONFIG_RADIO 32 +#define FILTER_FLAG_EX_DATA 1024 +#define FILTER_FLAG_PRIORITY_HIGHEST 2048 +#define FILTER_FLAG_PRIORITY_LOWEST 4096 +#define FILTER_FLAG_WINDOW_THICKFRAME 8192 +#define FILTER_FLAG_WINDOW_SIZE 16384 +#define FILTER_FLAG_DISP_FILTER 32768 +#define FILTER_FLAG_REDRAW 0x20000 +#define FILTER_FLAG_EX_INFORMATION 0x40000 +#define FILTER_FLAG_INFORMATION 0x80000 +#define FILTER_FLAG_NO_CONFIG 0x100000 +#define FILTER_FLAG_AUDIO_FILTER 0x200000 +#define FILTER_FLAG_RADIO_BUTTON 0x400000 +#define FILTER_FLAG_WINDOW_HSCROLL 0x800000 +#define FILTER_FLAG_WINDOW_VSCROLL 0x1000000 +#define FILTER_FLAG_INTERLACE_FILTER 0x4000000 +#define FILTER_FLAG_NO_INIT_DATA 0x8000000 +#define FILTER_FLAG_IMPORT 0x10000000 +#define FILTER_FLAG_EXPORT 0x20000000 +#define FILTER_FLAG_MAIN_MESSAGE 0x40000000 +#define WM_FILTER_UPDATE (WM_USER+100) +#define WM_FILTER_FILE_OPEN (WM_USER+101) +#define WM_FILTER_FILE_CLOSE (WM_USER+102) +#define WM_FILTER_INIT (WM_USER+103) +#define WM_FILTER_EXIT (WM_USER+104) +#define WM_FILTER_SAVE_START (WM_USER+105) +#define WM_FILTER_SAVE_END (WM_USER+106) +#define WM_FILTER_IMPORT (WM_USER+107) +#define WM_FILTER_EXPORT (WM_USER+108) +#define WM_FILTER_CHANGE_ACTIVE (WM_USER+109) +#define WM_FILTER_CHANGE_WINDOW (WM_USER+110) +#define WM_FILTER_CHANGE_PARAM (WM_USER+111) +#define WM_FILTER_CHANGE_EDIT (WM_USER+112) +#define WM_FILTER_COMMAND (WM_USER+113) +#define WM_FILTER_FILE_UPDATE (WM_USER+114) +#define WM_FILTER_MAIN_MOUSE_DOWN (WM_USER+120) +#define WM_FILTER_MAIN_MOUSE_UP (WM_USER+121) +#define WM_FILTER_MAIN_MOUSE_MOVE (WM_USER+122) +#define WM_FILTER_MAIN_KEY_DOWN (WM_USER+123) +#define WM_FILTER_MAIN_KEY_UP (WM_USER+124) +#define WM_FILTER_MAIN_MOVESIZE (WM_USER+125) +#define WM_FILTER_MAIN_MOUSE_DBLCLK (WM_USER+126) +#define WM_FILTER_MAIN_MOUSE_R_DOWN (WM_USER+127) +#define WM_FILTER_MAIN_MOUSE_R_UP (WM_USER+128) +#define WM_FILTER_MAIN_MOUSE_WHEEL (WM_USER+129) +#define WM_FILTER_MAIN_CONTEXTMENU (WM_USER+130) +#define FILTER_UPDATE_STATUS_ALL 0 +#define FILTER_UPDATE_STATUS_TRACK 0x10000 +#define FILTER_UPDATE_STATUS_CHECK 0x20000 +#define FILTER_WINDOW_SIZE_CLIENT 0x10000000 +#define FILTER_WINDOW_SIZE_ADD 0x30000000 + +// Struct for Filter DLL +typedef struct { + int flag; + int x, y; + TCHAR *name; + int track_n; + TCHAR **track_name; + int *track_default; + int *track_s, *track_e; + int check_n; + TCHAR **check_name; + int *check_default; + BOOL(*func_proc)(FILTER *fp, FILTER_PROC_INFO *fpip); + BOOL(*func_init)(FILTER *fp); + BOOL(*func_exit)(FILTER *fp); + BOOL(*func_update)(FILTER *fp, int status); + BOOL(*func_WndProc)(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, void *editp, FILTER *fp); + int *track, *check; + void *ex_data_ptr; + int ex_data_size; + TCHAR *information; + BOOL(*func_save_start)(FILTER *fp, int s, int e, void *editp); + BOOL(*func_save_end)(FILTER *fp, void *editp); + EXFUNC *exfunc; + HWND hwnd; + HINSTANCE dll_hinst; + void *ex_data_def; + BOOL(*func_is_saveframe)(FILTER *fp, void *editp, int saveno, int frame, int fps, int edit_flag, int inter); + BOOL(*func_project_load)(FILTER *fp, void *editp, void *data, int size); + BOOL(*func_project_save)(FILTER *fp, void *editp, void *data, int *size); + BOOL(*func_modify_title)(FILTER *fp, void *editp, int frame, LPSTR title, int max_title); + TCHAR *dll_path; + int reserve[2]; +} FILTER_DLL; + +#define MID_FILTER_BUTTON 12004 + +BOOL func_proc(FILTER *fp, FILTER_PROC_INFO *fpip); +BOOL func_init(FILTER *fp); +BOOL func_exit(FILTER *fp); +BOOL func_update(FILTER *fp, int status); +BOOL func_WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, void *editp, FILTER *fp); +BOOL func_save_start(FILTER *fp, int s, int e, void *editp); +BOOL func_save_end(FILTER *fp, void *editp); +BOOL func_is_saveframe(FILTER *fp, void *editp, int saveno, int frame, int fps, int edit_flag, int inter); +BOOL func_project_load(FILTER *fp, void *editp, void *data, int size); +BOOL func_project_save(FILTER *fp, void *editp, void *data, int *size); +BOOL func_modify_title(FILTER *fp, void *editp, int frame, LPSTR title, int max_title); + + diff --git a/SigColorFastAviUtl/macro.props b/SigColorFastAviUtl/macro.props new file mode 100644 index 0000000..af0ab60 --- /dev/null +++ b/SigColorFastAviUtl/macro.props @@ -0,0 +1,15 @@ + + + + + C:\AviUtlDBG\ + + + + + + $(UtlPath) + true + + + \ No newline at end of file diff --git a/SigColorFastAviUtl/sigcolorfastaviutl.cpp b/SigColorFastAviUtl/sigcolorfastaviutl.cpp new file mode 100644 index 0000000..72c8402 --- /dev/null +++ b/SigColorFastAviUtl/sigcolorfastaviutl.cpp @@ -0,0 +1,347 @@ +#define NOMINMAX +#include +#include "filter.h" //please set this to AviUtl SDK's filter.h +#include "SigmoidTable.h" + +// About setting multilingual UI // +/* +The slider and button text are all fixed when you export a FILTER_DLL struct to outside. +Once exported, you cannot change the UI text except the window title. +Hence, we need to set individual FILTER_DLL struct for EACH language. +It is actually copy-and-paste mostly, just need to change the slider name and checkbox/button name pointers. +The example below gives the UI in Japanese and Traditional Chinese. If the thread's codepage is neither 932(SJIS) or 950(BIG5), +it exports the English UI. +*/ + +// Define sliders +#define TRACK_N 2 // slider count. This creates 3 sliders +// i18n slider name +char* en_name[] = { "Midtone", "Strength" }; +char* jp_name[] = { "中間値", "強さ" }; +char* cht_name[] = { "中間值", "強度" }; + +int track_default[] = { 50, 5 }; // default values +int track_s[] = { 0, 1 }; // minimum values +int track_e[] = { 100, 30 }; // maximum values + + // Define checkboxes and buttons +#define CHECK_N 4 // total number of check box and button +char *check_name_en[] = { "Y", "R", "G", "B" }; // label name +char *check_name_jp[] = { "Y", "R", "G", "B" }; // label name:JP +char *check_name_cht[] = { "Y", "R", "G", "B" }; // label name:CHT +int check_default[] = { 1, 0, 0, 0 }; // for checkbox: 0(unchecked) or 1(checked); for button: must be -1 + +SigmoidTable* ST = nullptr; + + + // Define filter info +FILTER_DLL filter_en = { // English UI filter info + FILTER_FLAG_EX_INFORMATION | FILTER_FLAG_PRIORITY_LOWEST, // filter flags, use bitwise OR to add more + // FILTER_FLAG_ALWAYS_ACTIVE : フィルタを常にアクティブにします + // FILTER_FLAG_CONFIG_POPUP : 設定をポップアップメニューにします + // FILTER_FLAG_CONFIG_CHECK : 設定をチェックボックスメニューにします + // FILTER_FLAG_CONFIG_RADIO : Only one of the checkboxes can be ticked at one time. + // FILTER_FLAG_EX_DATA : 拡張データを保存出来るようにします。 + // FILTER_FLAG_PRIORITY_HIGHEST : Make this plugin highest priority(i.e. always run before other filters) + // FILTER_FLAG_PRIORITY_LOWEST : Make this plugin lowest priority + // FILTER_FLAG_WINDOW_THICKFRAME : user-draggable dialog box + // FILTER_FLAG_WINDOW_SIZE : Custom dialogbox size (size defined in argument 2 and 3) + // FILTER_FLAG_DISP_FILTER : 表示フィルタにします + // FILTER_FLAG_EX_INFORMATION : フィルタの拡張情報を設定できるようにします + // FILTER_FLAG_NO_CONFIG : 設定ウィンドウを表示しないようにします + // FILTER_FLAG_AUDIO_FILTER : オーディオフィルタにします + // FILTER_FLAG_RADIO_BUTTON : チェックボックスをラジオボタンにします + // FILTER_FLAG_WINDOW_HSCROLL : 水平スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_WINDOW_VSCROLL : 垂直スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_IMPORT : インポートメニューを作ります + // FILTER_FLAG_EXPORT : エクスポートメニューを作ります + 0, 0, // dialogbox size + "SigContrast Fast", // Filter plugin name + TRACK_N, // トラックバーの数 (0なら名前初期値等もNULLでよい) + en_name, // slider label names in English + track_default, // トラックバーの初期値郡へのポインタ + track_s, track_e, // トラックバーの数値の下限上限 (NULLなら全て0~256) + CHECK_N, // チェックボックスの数 (0なら名前初期値等もNULLでよい) + check_name_en, // チェックボックスの名前郡へのポインタ + check_default, // チェックボックスの初期値郡へのポインタ + func_proc, // main filter function, use NULL to skip + NULL, // initialization function, use NULL to skip + func_exit, // on-exit function, use NULL to skip + func_update, // invokes when when settings changed. use NULL to skip + NULL, // for capturing dialog's control messages. Essential if you use button or auto uncheck some checkboxes. + NULL, NULL, // Reserved. Do not use. + NULL, // pointer to extra data when FILTER_FLAG_EX_DATA is set + NULL, // extra data size + "SigContrast Fast 0.01 by MT", + // pointer or c-string for full filter info when FILTER_FLAG_EX_INFORMATION is set. + NULL, // invoke just before saving starts. NULL to skip + NULL, // invoke just after saving ends. NULL to skip +}; + +FILTER_DLL filter_jp = { // Japanese UI filter info + FILTER_FLAG_EX_INFORMATION | FILTER_FLAG_PRIORITY_LOWEST, // filter flags, use bitwise OR to add more + // FILTER_FLAG_ALWAYS_ACTIVE : フィルタを常にアクティブにします + // FILTER_FLAG_CONFIG_POPUP : 設定をポップアップメニューにします + // FILTER_FLAG_CONFIG_CHECK : 設定をチェックボックスメニューにします + // FILTER_FLAG_CONFIG_RADIO : Only one of the checkboxes can be ticked at one time. + // FILTER_FLAG_EX_DATA : 拡張データを保存出来るようにします。 + // FILTER_FLAG_PRIORITY_HIGHEST : Make this plugin highest priority(i.e. always run before other filters) + // FILTER_FLAG_PRIORITY_LOWEST : Make this plugin lowest priority + // FILTER_FLAG_WINDOW_THICKFRAME : user-draggable dialog box + // FILTER_FLAG_WINDOW_SIZE : Custom dialogbox size (size defined in argument 2 and 3) + // FILTER_FLAG_DISP_FILTER : 表示フィルタにします + // FILTER_FLAG_EX_INFORMATION : フィルタの拡張情報を設定できるようにします + // FILTER_FLAG_NO_CONFIG : 設定ウィンドウを表示しないようにします + // FILTER_FLAG_AUDIO_FILTER : オーディオフィルタにします + // FILTER_FLAG_RADIO_BUTTON : チェックボックスをラジオボタンにします + // FILTER_FLAG_WINDOW_HSCROLL : 水平スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_WINDOW_VSCROLL : 垂直スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_IMPORT : インポートメニューを作ります + // FILTER_FLAG_EXPORT : エクスポートメニューを作ります + 0, 0, // dialogbox size + "滑やか対比度", // Filter plugin name + TRACK_N, // トラックバーの数 (0なら名前初期値等もNULLでよい) + jp_name, // slider label names in Japanese + track_default, // トラックバーの初期値郡へのポインタ + track_s, track_e, // トラックバーの数値の下限上限 (NULLなら全て0~256) + CHECK_N, // チェックボックスの数 (0なら名前初期値等もNULLでよい) + check_name_jp, // チェックボックスの名前郡へのポインタ + check_default, // チェックボックスの初期値郡へのポインタ + func_proc, // main filter function, use NULL to skip + NULL, // initialization function, use NULL to skip + func_exit, // on-exit function, use NULL to skip + func_update, // invokes when when settings changed. use NULL to skip + NULL, // for capturing dialog's control messages. Essential if you use button or auto uncheck some checkboxes. + NULL, NULL, // Reserved. Do not use. + NULL, // pointer to extra data when FILTER_FLAG_EX_DATA is set + NULL, // extra data size + "滑やか対比度 0.01 by MT", + // pointer or c-string for full filter info when FILTER_FLAG_EX_INFORMATION is set. + NULL, // invoke just before saving starts. NULL to skip + NULL, // invoke just after saving ends. NULL to skip +}; + + +FILTER_DLL filter_cht = { // Chinese Traditional UI filter info + FILTER_FLAG_EX_INFORMATION | FILTER_FLAG_PRIORITY_LOWEST, // filter flags, use bitwise OR to add more + // FILTER_FLAG_ALWAYS_ACTIVE : フィルタを常にアクティブにします + // FILTER_FLAG_CONFIG_POPUP : 設定をポップアップメニューにします + // FILTER_FLAG_CONFIG_CHECK : 設定をチェックボックスメニューにします + // FILTER_FLAG_CONFIG_RADIO : Only one of the checkboxes can be ticked at one time. + // FILTER_FLAG_EX_DATA : 拡張データを保存出来るようにします。 + // FILTER_FLAG_PRIORITY_HIGHEST : Make this plugin highest priority(i.e. always run before other filters) + // FILTER_FLAG_PRIORITY_LOWEST : Make this plugin lowest priority + // FILTER_FLAG_WINDOW_THICKFRAME : user-draggable dialog box + // FILTER_FLAG_WINDOW_SIZE : Custom dialogbox size (size defined in argument 2 and 3) + // FILTER_FLAG_DISP_FILTER : 表示フィルタにします + // FILTER_FLAG_EX_INFORMATION : フィルタの拡張情報を設定できるようにします + // FILTER_FLAG_NO_CONFIG : 設定ウィンドウを表示しないようにします + // FILTER_FLAG_AUDIO_FILTER : オーディオフィルタにします + // FILTER_FLAG_RADIO_BUTTON : チェックボックスをラジオボタンにします + // FILTER_FLAG_WINDOW_HSCROLL : 水平スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_WINDOW_VSCROLL : 垂直スクロールバーを持つウィンドウを作ります + // FILTER_FLAG_IMPORT : インポートメニューを作ります + // FILTER_FLAG_EXPORT : エクスポートメニューを作ります + 0, 0, // dialogbox size + "順滑對比度", // Filter plugin name + TRACK_N, // トラックバーの数 (0なら名前初期値等もNULLでよい) + cht_name, // slider label names in Japanese + track_default, // トラックバーの初期値郡へのポインタ + track_s, track_e, // トラックバーの数値の下限上限 (NULLなら全て0~256) + CHECK_N, // チェックボックスの数 (0なら名前初期値等もNULLでよい) + check_name_cht, // チェックボックスの名前郡へのポインタ + check_default, // チェックボックスの初期値郡へのポインタ + func_proc, // main filter function, use NULL to skip + NULL, // initialization function, use NULL to skip + func_exit, // on-exit function, use NULL to skip + func_update, // invokes when when settings changed. use NULL to skip + NULL, // for capturing dialog's control messages. Essential if you use button or auto uncheck some checkboxes. + NULL, NULL, // Reserved. Do not use. + NULL, // pointer to extra data when FILTER_FLAG_EX_DATA is set + NULL, // extra data size + "順滑對比度 0.01 by MT", + // pointer or c-string for full filter info when FILTER_FLAG_EX_INFORMATION is set. + NULL, // invoke just before saving starts. NULL to skip + NULL, // invoke just after saving ends. NULL to skip +}; + + +// Export the above filter table +EXTERN_C __declspec(dllexport) FILTER_DLL* GetFilterTable(void) +{ + FILTER_DLL* UITable = nullptr; + LPCPINFOEX cpinfo = new CPINFOEX{ 0 }; + if (GetCPInfoEx(CP_THREAD_ACP, 0, cpinfo)) // try to get AviUtl's current codepage + { + if (cpinfo->CodePage == 932) // 932 is Japanese S-JIS; 950 is BIG5 Chinese + { + UITable = &filter_jp; + } + else if (cpinfo->CodePage == 950) + { + UITable = &filter_cht; + } + else // default to English to avoid scrambled text + { + UITable = &filter_en; + } + } + else // if something wrong with CP retrival, use English UI + { + UITable = &filter_en; + } + delete cpinfo; + + return UITable; +} + +/**************************************************************************************/ +/* IMPORTANT NOTE */ +/* The original SDK sample code use the following: + +EXTERN_C FILTER_DLL __declspec(dllexport) * __stdcall GetFilterTable( void ) +{ +return &filter; +} + +but MSVC seems to have problem parsing this and you will need an extra .def file +for proper export. +If the FILTER_DLL struct fails to export, the plugin will not show up in AviUtl's +"Filter+" menu. +*/ +/**************************************************************************************/ + +BOOL func_proc(FILTER *fp, FILTER_PROC_INFO *fpip) // This is the main image manipulation function +{ + //TODO + //MessageBoxExW(NULL, L"func_proc invoked!", L"DEMO", MB_OK | MB_ICONINFORMATION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK)); + // image data at: fpip->ycp_edit + // scratch area, same size as ycp_edit, at: fpip->ycp_temp + // max image dimension (depends on AviUtl setting): fpip->max_w fpip->max_h [READ-ONLY] + // View port(output) dimension (changeable): fpip->w, fpip->h + // a long list of utility function can be accessed under fp->exfunc-> + // default pixel format in ycp_edit is PIXEL_YC (see filter.h for details) + // The idea of "stride" or "step" is not used when accessing ycp_edit data. + // ycp_edit is a continous arrangement of pixels with a maximum of fpip->max_w*fpip->max_h pixels + // size of ycp_edit and ycp_temp is therefore fpip->max_w*fpip->max_h*sizeof(PIXEL_YC) + + // The principle idea is to make change on fpip->ycp_edit, then return TRUE when done. + + /* Create a sigmoid table if none exists */ + if (!ST) + { + ST = new SigmoidTable(static_cast(fp->track[0]/100.0f), static_cast(fp->track[1]), 4096, 4096); + } + /* Scan Y channel data */ + for (int r = 0; r < fpip->h; r++) + { + for (int c = 0; c < fpip->w; c++) + { + PIXEL_YC* px = fpip->ycp_edit + r* fpip->max_w + c; + try + { + short new_y = static_cast(ST->lookup(px->y)); + px->y = new_y; + } + catch (std::exception e) + { + continue; + } + } + } + + return TRUE; //TRUE to update frame image. FALSE to skip refresh. +} +BOOL func_init(FILTER *fp) +{ + //TODO + MessageBoxExW(NULL, L"func_init invoked!\nfunc_initを呼び出した!", L"DEMO", MB_OK | MB_ICONINFORMATION, MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN)); + + return TRUE; +} +BOOL func_exit(FILTER *fp) +{ + //DO NOT PUT MessageBox here, crash the application! + //MessageBox(NULL, "func_exit invoked!", "DEMO", MB_OK | MB_ICONINFORMATION); + if (ST) + { + delete ST; + } + return TRUE; +} +BOOL func_update(FILTER *fp, int status) +{ + //TODO + switch (status) + { + case FILTER_UPDATE_STATUS_TRACK: + //MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_TRACK", "DEMO", MB_OK | MB_ICONINFORMATION); + { + if (ST) delete ST; + ST= new SigmoidTable(static_cast(fp->track[0] / 100.0f), static_cast(fp->track[1]), 4096, 4096); + } + break; + case FILTER_UPDATE_STATUS_TRACK + 1: + //MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_TRACK+1", "DEMO", MB_OK | MB_ICONINFORMATION); + { + if (ST) delete ST; + ST = new SigmoidTable(static_cast(fp->track[0] / 100.0f), static_cast(fp->track[1]), 4096, 4096); + } + break; +// case FILTER_UPDATE_STATUS_TRACK + 2: +// MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_TRACK+2", "DEMO", MB_OK | MB_ICONINFORMATION); +// break; + //case FILTER_UPDATE_STATUS_CHECK: + // MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_CHECK", "DEMO", MB_OK | MB_ICONINFORMATION); + // break; + //case FILTER_UPDATE_STATUS_CHECK + 1: + // MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_CHECK+1", "DEMO", MB_OK | MB_ICONINFORMATION); + // break; + //case FILTER_UPDATE_STATUS_CHECK + 2: // no effect since our 3rd checkbox is a button. + // MessageBox(NULL, "func_update FILTER_UPDATE_STATUS_CHECK+2", "DEMO", MB_OK | MB_ICONINFORMATION); + // break; + //default: + //MessageBox(NULL, "func_update invoked!", "DEMO", MB_OK | MB_ICONINFORMATION); + } + + return FALSE; +} +BOOL func_WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, void *editp, FILTER *fp) +// This is used for capturing mouse click, button states, and getting mouse coordinates +{ + // + switch (message) + { + case WM_FILTER_MAIN_MOUSE_DOWN: + break; + case WM_FILTER_MAIN_MOUSE_MOVE: + break; + case WM_COMMAND: // This is for capturing dialog control's message, i.e. button-click + switch (wparam) + { + case MID_FILTER_BUTTON + 2: // This ID is the COMBINED order of checkbox and button. + // so MID_FILTER_BUTTON = checkbox1 + // MID_FILTER_BUTTON+1 = checkbox2 + // MID_FILTER_BUTTON+2 = button1 + // but since the checkboxes are not buttons, the first two MID_FILTER_BUTTON have no effect. + MessageBoxExW(NULL, L"This should show some Chinese text\n你好嗎?", L"BUTTON-CLICK", MB_OK | MB_ICONINFORMATION, MAKELANGID(LANG_CHINESE_TRADITIONAL, SUBLANG_CHINESE_HONGKONG)); + break; + default: + return FALSE; + + } + } + return FALSE; +} +BOOL func_save_start(FILTER *fp, int s, int e, void *editp) +{ + // + MessageBox(NULL, "func_save_start invoked!", "DEMO", MB_OK | MB_ICONINFORMATION); + return FALSE; +} +BOOL func_save_end(FILTER *fp, void *editp) +{ + // + MessageBox(NULL, "func_save_end invoked!", "DEMO", MB_OK | MB_ICONINFORMATION); + return FALSE; +} \ No newline at end of file