diff options
author | jonasno <jonasno@users.sourceforge.net> | 2010-02-21 21:50:41 +0300 |
---|---|---|
committer | jonasno <jonasno@users.sourceforge.net> | 2010-02-21 21:50:41 +0300 |
commit | 3244957f4563575d22bf109de27a703558611b19 (patch) | |
tree | 749080f5503fe3fd31e28587000b60b90aacf995 | |
parent | c7a41c0086a8bfcd07530779645d98c80039bd84 (diff) |
Merged VSFilterMod rev20, only 64 bit code enabled for the time being
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk@1688 10f7b99b-c216-0410-bff0-8a66a9350fd8
92 files changed, 6933 insertions, 803 deletions
diff --git a/include/UserConfig.h b/include/UserConfig.h new file mode 100644 index 000000000..682c5b13b --- /dev/null +++ b/include/UserConfig.h @@ -0,0 +1,2 @@ +#pragma once
+//#ifdef ENABLE_MINIDUMP
diff --git a/include/avisynth/avisynth1.h b/include/avisynth/avisynth1.h index ce0089f1f..070820356 100644 --- a/include/avisynth/avisynth1.h +++ b/include/avisynth/avisynth1.h @@ -135,7 +135,7 @@ class VideoFrame { VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height);
- void* operator new(unsigned size);
+ void* operator new(size_t size);
public:
int GetPitch() const { return pitch; }
diff --git a/include/avisynth/avisynth25.h b/include/avisynth/avisynth25.h index 21de2eca4..b8bf791c1 100644 --- a/include/avisynth/avisynth25.h +++ b/include/avisynth/avisynth25.h @@ -305,7 +305,7 @@ class VideoFrame { VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height);
VideoFrame(VideoFrameBuffer* _vfb, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV);
- void* operator new(unsigned size);
+ void* operator new(size_t size);
// TESTME: OFFSET U/V may be switched to what could be expected from AVI standard!
public:
int GetPitch() const { return pitch; }
diff --git a/include/vd2/Copying b/include/vd2/Copying new file mode 100644 index 000000000..928511020 --- /dev/null +++ b/include/vd2/Copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/include/vd2/OldFilterSDK/Filter.h b/include/vd2/OldFilterSDK/Filter.h new file mode 100644 index 000000000..40515ba7e --- /dev/null +++ b/include/vd2/OldFilterSDK/Filter.h @@ -0,0 +1,57 @@ +#ifndef f_FILTER_H
+#define f_FILTER_H
+
+#include <vd2\plugin\vdvideofilt.h>
+#include <windows.h>
+
+// This is really dumb, but necessary to support VTbls in C++.
+
+typedef struct VDXFilterVTbls {
+ void *pvtblVBitmap;
+} FilterVTbls;
+
+#ifdef VDEXT_MAIN
+ VDXFilterVTbls g_vtbls;
+#elif defined(VDEXT_NOTMAIN)
+ extern VDXFilterVTbls g_vtbls;
+#endif
+
+#define INITIALIZE_VTBLS ff->InitVTables(&g_vtbls)
+
+#include "VBitmap.h"
+
+typedef ::VDXFilterInitProc FilterInitProc;
+typedef ::VDXFilterDeinitProc FilterDeinitProc;
+typedef ::VDXFilterRunProc FilterRunProc;
+typedef ::VDXFilterParamProc FilterParamProc;
+typedef ::VDXFilterConfigProc FilterConfigProc;
+typedef ::VDXFilterStringProc FilterStringProc;
+typedef ::VDXFilterStartProc FilterStartProc;
+typedef ::VDXFilterEndProc FilterEndProc;
+typedef ::VDXFilterScriptStrProc FilterScriptStrProc;
+typedef ::VDXFilterStringProc2 FilterStringProc2;
+typedef ::VDXFilterSerialize FilterSerialize;
+typedef ::VDXFilterDeserialize FilterDeserialize;
+typedef ::VDXFilterCopy FilterCopy;
+
+typedef ::VDXFilterModuleInitProc FilterModuleInitProc;
+typedef ::VDXFilterModuleDeinitProc FilterModuleDeinitProc;
+
+//////////
+
+typedef ::VDXFilterPreviewButtonCallback FilterPreviewButtonCallback;
+typedef ::VDXFilterPreviewSampleCallback FilterPreviewSampleCallback;
+
+typedef ::IVDXFilterPreview IFilterPreview;
+
+//////////
+
+typedef ::VDXFilterModule FilterModule;
+typedef ::VDXFilterDefinition FilterDefinition;
+typedef ::VDXFilterStateInfo FilterStateInfo;
+typedef ::VDXFBitmap VFBitmap;
+
+typedef ::VDXFilterActivation FilterActivation;
+typedef ::VDXFilterFunctions FilterFunctions;
+
+#endif
diff --git a/include/vd2/OldFilterSDK/ScriptError.h b/include/vd2/OldFilterSDK/ScriptError.h new file mode 100644 index 000000000..900a9fc07 --- /dev/null +++ b/include/vd2/OldFilterSDK/ScriptError.h @@ -0,0 +1,8 @@ +#ifndef f_SYLIA_SCRIPTERROR_H
+#define f_SYLIA_SCRIPTERROR_H
+
+#include <vd2/plugin/vdvideofilt.h>
+
+typedef ::VDXScriptError CScriptError;
+
+#endif
diff --git a/include/vd2/OldFilterSDK/ScriptInterpreter.h b/include/vd2/OldFilterSDK/ScriptInterpreter.h new file mode 100644 index 000000000..fd12e969e --- /dev/null +++ b/include/vd2/OldFilterSDK/ScriptInterpreter.h @@ -0,0 +1,11 @@ +#ifndef f_SYLIA_SCRIPTINTERPRETER_H
+#define f_SYLIA_SCRIPTINTERPRETER_H
+
+#include <vd2/plugin/vdvideofilt.h>
+
+typedef ::VDXScriptValue CScriptValue;
+typedef ::VDXScriptError CScriptError;
+typedef ::VDXScriptObject CScriptObject;
+typedef ::IVDXScriptInterpreter IScriptInterpreter;
+
+#endif
diff --git a/include/vd2/OldFilterSDK/ScriptValue.h b/include/vd2/OldFilterSDK/ScriptValue.h new file mode 100644 index 000000000..0d8628469 --- /dev/null +++ b/include/vd2/OldFilterSDK/ScriptValue.h @@ -0,0 +1,17 @@ +#ifndef f_SYLIA_SCRIPTVALUE_H
+#define f_SYLIA_SCRIPTVALUE_H
+
+#include <vd2/plugin/vdvideofilt.h>
+
+typedef ::VDXScriptObject CScriptObject;
+typedef ::VDXScriptValue CScriptValue;
+typedef ::IVDXScriptInterpreter IScriptInterpreter;
+
+typedef ::VDXScriptFunctionPtr ScriptFunctionPtr;
+typedef ::VDXVoidScriptFunctionPtr ScriptVoidFunctionPtr;
+typedef ::VDXIntScriptFunctionPtr ScriptIntFunctionPtr;
+
+typedef ::VDXScriptFunctionDef ScriptFunctionDef;
+typedef ::VDXScriptObject CScriptObject;
+
+#endif
diff --git a/include/vd2/OldFilterSDK/VBitmap.h b/include/vd2/OldFilterSDK/VBitmap.h new file mode 100644 index 000000000..08795ac5f --- /dev/null +++ b/include/vd2/OldFilterSDK/VBitmap.h @@ -0,0 +1,16 @@ +#ifndef f_VIRTUALDUB_VBITMAP_H
+#define f_VIRTUALDUB_VBITMAP_H
+
+#include <windows.h>
+#include <vd2/plugin/vdvideofilt.h>
+
+typedef unsigned Pixel;
+typedef unsigned Pixel32;
+typedef unsigned char Pixel8;
+typedef int PixCoord;
+typedef int PixDim;
+typedef ptrdiff_t PixOffset;
+
+typedef ::VDXBitmap VBitmap;
+
+#endif
diff --git a/include/vd2/OldFilterSDK/VirtualDub.h b/include/vd2/OldFilterSDK/VirtualDub.h new file mode 100644 index 000000000..25e5fd475 --- /dev/null +++ b/include/vd2/OldFilterSDK/VirtualDub.h @@ -0,0 +1,7 @@ +#pragma once
+
+#include "Filter.h"
+#include "ScriptInterpreter.h"
+#include "ScriptError.h"
+#include "ScriptValue.h"
+#include "VBitmap.h"
diff --git a/include/vd2/PluginSDK.chm b/include/vd2/PluginSDK.chm Binary files differnew file mode 100644 index 000000000..1eaccd9dc --- /dev/null +++ b/include/vd2/PluginSDK.chm diff --git a/include/vd2/VDXFrame/Unknown.h b/include/vd2/VDXFrame/Unknown.h new file mode 100644 index 000000000..34de61f46 --- /dev/null +++ b/include/vd2/VDXFrame/Unknown.h @@ -0,0 +1,110 @@ +// VDXFrame - Helper library for VirtualDub plugins
+// Copyright (C) 2008 Avery Lee
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_VDXFRAME_UNKNOWN_H
+#define f_VD2_VDXFRAME_UNKNOWN_H
+
+#include <vd2/plugin/vdplugin.h>
+
+extern "C" long _InterlockedExchangeAdd(volatile long *p, long v);
+#pragma intrinsic(_InterlockedExchangeAdd)
+
+template<class T> class vdxunknown : public T {
+public:
+ vdxunknown() : mRefCount(0) {}
+ vdxunknown(const vdxunknown<T>& src) : mRefCount(0) {} // do not copy the refcount
+ virtual ~vdxunknown() {}
+
+ vdxunknown<T>& operator=(const vdxunknown<T>&) {} // do not copy the refcount
+
+ virtual int VDXAPIENTRY AddRef() {
+ return _InterlockedExchangeAdd(&mRefCount, 1) + 1;
+ }
+
+ virtual int VDXAPIENTRY Release() {
+ long rc = _InterlockedExchangeAdd(&mRefCount, -1) - 1;
+ if (!mRefCount) {
+ mRefCount = 1;
+ delete this;
+ return 0;
+ }
+
+ return rc;
+ }
+
+ virtual void *VDXAPIENTRY AsInterface(uint32 iid) {
+ if (iid == T::kIID)
+ return static_cast<T *>(this);
+
+ if (iid == IVDXUnknown::kIID)
+ return static_cast<IVDXUnknown *>(this);
+
+ return NULL;
+ }
+
+protected:
+ volatile long mRefCount;
+};
+
+template<class T1, class T2> class vdxunknown2 : public T1, public T2 {
+public:
+ vdxunknown2() : mRefCount(0) {}
+ vdxunknown2(const vdxunknown2& src) : mRefCount(0) {} // do not copy the refcount
+ virtual ~vdxunknown2() {}
+
+ vdxunknown2& operator=(const vdxunknown2&) {} // do not copy the refcount
+
+ virtual int VDXAPIENTRY AddRef() {
+ return _InterlockedExchangeAdd(&mRefCount, 1) + 1;
+ }
+
+ virtual int VDXAPIENTRY Release() {
+ long rc = _InterlockedExchangeAdd(&mRefCount, -1) - 1;
+ if (!mRefCount) {
+ mRefCount = 1;
+ delete this;
+ return 0;
+ }
+
+ return rc;
+ }
+
+ virtual void *VDXAPIENTRY AsInterface(uint32 iid) {
+ if (iid == T1::kIID)
+ return static_cast<T1 *>(this);
+
+ if (iid == T2::kIID)
+ return static_cast<T2 *>(this);
+
+ if (iid == IVDXUnknown::kIID)
+ return static_cast<IVDXUnknown *>(static_cast<T1 *>(this));
+
+ return NULL;
+ }
+
+protected:
+ volatile long mRefCount;
+};
+
+#endif
diff --git a/include/vd2/VDXFrame/VideoFilter.h b/include/vd2/VDXFrame/VideoFilter.h new file mode 100644 index 000000000..78ef03bd1 --- /dev/null +++ b/include/vd2/VDXFrame/VideoFilter.h @@ -0,0 +1,221 @@ +// VDXFrame - Helper library for VirtualDub plugins
+// Copyright (C) 2008 Avery Lee
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_VDXFRAME_VIDEOFILTER_H
+#define f_VD2_VDXFRAME_VIDEOFILTER_H
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <new>
+
+#include <vd2/plugin/vdvideofilt.h>
+
+///////////////////////////////////////////////////////////////////////////
+/// \class VDXVideoFilter
+///
+/// This class handles most of the grimy work of creating the interface
+/// between your filter and VirtualDub.
+///
+class VDXVideoFilter {
+public:
+ VDXVideoFilter();
+ virtual ~VDXVideoFilter();
+
+ void SetHooks(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+
+ // linkage routines
+
+ virtual bool Init();
+ virtual uint32 GetParams()=0;
+ virtual void Start();
+ virtual void Run() = 0;
+ virtual void End();
+ virtual bool Configure(VDXHWND hwnd);
+ virtual void GetSettingString(char *buf, int maxlen);
+ virtual void GetScriptString(char *buf, int maxlen);
+ virtual int Serialize(char *buf, int maxbuf);
+ virtual int Deserialize(const char *buf, int maxbuf);
+ virtual sint64 Prefetch(sint64 frame);
+ virtual bool Prefetch2(sint64 frame, IVDXVideoPrefetcher *prefetcher);
+
+ virtual bool OnEvent(uint32 event, const void *eventData);
+ virtual bool OnInvalidateCaches();
+
+ static void __cdecl FilterDeinit (VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+ static int __cdecl FilterRun (const VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+ static long __cdecl FilterParam (VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+ static int __cdecl FilterConfig (VDXFilterActivation *fa, const VDXFilterFunctions *ff, VDXHWND hWnd);
+ static int __cdecl FilterStart (VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+ static int __cdecl FilterEnd (VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+ static void __cdecl FilterString (const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf);
+ static bool __cdecl FilterScriptStr(VDXFilterActivation *fa, const VDXFilterFunctions *, char *, int);
+ static void __cdecl FilterString2 (const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxlen);
+ static int __cdecl FilterSerialize (VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxbuf);
+ static void __cdecl FilterDeserialize (VDXFilterActivation *fa, const VDXFilterFunctions *ff, const char *buf, int maxbuf);
+ static sint64 __cdecl FilterPrefetch(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame);
+ static bool __cdecl FilterPrefetch2(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame, IVDXVideoPrefetcher *prefetcher);
+ static bool __cdecl FilterEvent(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, uint32 event, const void *eventData);
+
+ // member variables
+ VDXFilterActivation *fa;
+ const VDXFilterFunctions *ff;
+
+ static const VDXScriptFunctionDef sScriptMethods[];
+
+protected:
+ void SafePrintf(char *buf, int maxbuf, const char *format, ...);
+};
+
+///////////////////////////////////////////////////////////////////////////
+// Script method support
+//
+// To declare a Config() script method, add
+//
+// VDXVF_DECLARE_SCRIPT_METHODS()
+//
+// to the public portion of your class definition, and then add a method
+// table at namespace scope:
+//
+// VDXVF_BEGIN_SCRIPT_METHODS(YUVTransformFilter)
+// VDXVF_DEFINE_SCRIPT_METHOD(YUVTransformFilter, ScriptConfig, "iii")
+// VDXVF_END_SCRIPT_METHODS()
+//
+// Use VDXVF_DEFINE_SCRIPT_METHOD() for the first method, and then
+// VDXVF_DEFINE_SCRIPT_METHOD2() for any overloads.
+
+#define VDXVF_DECLARE_SCRIPT_METHODS() static const VDXScriptFunctionDef sScriptMethods[]
+
+#define VDXVF_BEGIN_SCRIPT_METHODS(klass) const VDXScriptFunctionDef klass::sScriptMethods[] = {
+#define VDXVF_DEFINE_SCRIPT_METHOD(klass, method, args) { (VDXScriptFunctionPtr)VDXVideoFilterScriptAdapter<klass, &klass::method>::AdaptFn, "Config", "0" args },
+#define VDXVF_DEFINE_SCRIPT_METHOD2(klass, method, args) { (VDXScriptFunctionPtr)VDXVideoFilterScriptAdapter<klass, &klass::method>::AdaptFn, NULL, "0" args },
+#define VDXVF_END_SCRIPT_METHODS() { NULL } };
+
+extern char VDXVideoFilterConfigureOverloadTest(bool (VDXVideoFilter::*)(VDXHWND));
+extern double VDXVideoFilterConfigureOverloadTest(...);
+extern char VDXVideoFilterPrefetchOverloadTest(sint64 (VDXVideoFilter::*)(sint64));
+extern double VDXVideoFilterPrefetchOverloadTest(...);
+extern char VDXVideoFilterPrefetch2OverloadTest(bool (VDXVideoFilter::*)(sint64, IVDXVideoPrefetcher *));
+extern double VDXVideoFilterPrefetch2OverloadTest(...);
+
+template<class T, void (T::*T_Method)(IVDXScriptInterpreter *, const VDXScriptValue *, int)>
+class VDXVideoFilterScriptAdapter
+{
+public:
+ static void AdaptFn(IVDXScriptInterpreter *isi, void *fa0, const VDXScriptValue *argv, int argc) {
+ VDXFilterActivation *fa = (VDXFilterActivation *)fa0;
+ VDXVideoFilter *base = *(VDXVideoFilter **)fa->filter_data;
+ (static_cast<T *>(base)->*T_Method)(isi, argv, argc);
+ }
+};
+
+template<class T>
+class VDXVideoFilterScriptObjectAdapter {
+public:
+ static const VDXScriptObject sScriptObject;
+};
+
+template<class T>
+const VDXScriptObject VDXVideoFilterScriptObjectAdapter<T>::sScriptObject = {
+ NULL, (T::sScriptMethods == VDXVideoFilter::sScriptMethods) ? NULL : (VDXScriptFunctionDef *)static_cast<const VDXScriptFunctionDef *>(T::sScriptMethods), NULL
+};
+
+///////////////////////////////////////////////////////////////////////////
+/// \class VDXVideoFilterDefinition
+///
+/// This template creates the FilterDefinition structure for you based on
+/// your filter class.
+///
+template<class T>
+class VDXVideoFilterDefinition : public VDXFilterDefinition {
+public:
+ VDXVideoFilterDefinition(const char *pszAuthor, const char *pszName, const char *pszDescription) {
+ _next = NULL;
+ _prev = NULL;
+ _module = NULL;
+
+ name = pszName;
+ desc = pszDescription;
+ maker = pszAuthor;
+ private_data = NULL;
+ inst_data_size = sizeof(T) + sizeof(VDXVideoFilter *);
+
+ initProc = FilterInit;
+ deinitProc = T::FilterDeinit;
+ runProc = T::FilterRun;
+ paramProc = T::FilterParam;
+ configProc = sizeof(VDXVideoFilterConfigureOverloadTest(&T::Configure)) > 1 ? T::FilterConfig : NULL;
+ stringProc = T::FilterString;
+ startProc = T::FilterStart;
+ endProc = T::FilterEnd;
+
+ script_obj = T::sScriptMethods ? const_cast<VDXScriptObject *>(&VDXVideoFilterScriptObjectAdapter<T>::sScriptObject) : 0;
+ fssProc = T::FilterScriptStr;
+
+ stringProc2 = T::FilterString2;
+ serializeProc = T::FilterSerialize;
+ deserializeProc = T::FilterDeserialize;
+ copyProc = FilterCopy;
+ copyProc2 = FilterCopy2;
+
+ prefetchProc = sizeof(VDXVideoFilterPrefetchOverloadTest(&T::Prefetch)) > 1 ? T::FilterPrefetch : NULL;
+ prefetchProc2 = sizeof(VDXVideoFilterPrefetch2OverloadTest(&T::Prefetch2)) > 1 || sizeof(VDXVideoFilterPrefetchOverloadTest(&T::Prefetch)) > 1 ? T::FilterPrefetch2 : NULL;
+
+ eventProc = T::FilterEvent;
+ }
+
+private:
+ static int __cdecl FilterInit (VDXFilterActivation *fa, const VDXFilterFunctions *ff) {
+ T *pThis = new((char *)fa->filter_data + sizeof(VDXVideoFilter *)) T;
+ *(VDXVideoFilter **)fa->filter_data = static_cast<VDXVideoFilter *>(pThis);
+
+ pThis->SetHooks(fa, ff);
+
+ try {
+ if (!pThis->Init()) {
+ pThis->~T();
+ return 1;
+ }
+
+ return 0;
+ } catch(...) {
+ pThis->~T();
+ throw;
+ }
+ }
+
+ static void __cdecl FilterCopy (VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst) {
+ T *p = new((char *)dst + sizeof(VDXVideoFilter *)) T(*static_cast<T *>(*reinterpret_cast<VDXVideoFilter **>(fa->filter_data)));
+ p->ff = ff;
+ *(VDXVideoFilter **)dst = p;
+ }
+
+ static void __cdecl FilterCopy2 (VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst, VDXFilterActivation *fanew, const VDXFilterFunctions *ffnew) {
+ T *p = new((char *)dst + sizeof(VDXVideoFilter *)) T(*static_cast<T *>(*reinterpret_cast<VDXVideoFilter **>(fa->filter_data)));
+ p->ff = ffnew;
+ p->fa = fanew;
+ *(VDXVideoFilter **)dst = p;
+ }
+};
+
+#endif
diff --git a/include/vd2/VDXFrame/VideoFilterDialog.h b/include/vd2/VDXFrame/VideoFilterDialog.h new file mode 100644 index 000000000..1e9aa4917 --- /dev/null +++ b/include/vd2/VDXFrame/VideoFilterDialog.h @@ -0,0 +1,46 @@ +// VDXFrame - Helper library for VirtualDub plugins
+// Copyright (C) 2008 Avery Lee
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_VDXFRAME_VIDEOFILTERDIALOG_H
+#define f_VD2_VDXFRAME_VIDEOFILTERDIALOG_H
+
+#include <windows.h>
+
+class VDXVideoFilterDialog {
+public:
+ VDXVideoFilterDialog();
+
+protected:
+ HWND mhdlg;
+
+ LRESULT Show(HINSTANCE hInst, LPCSTR templName, HWND parent);
+ LRESULT Show(HINSTANCE hInst, LPCWSTR templName, HWND parent);
+ HWND ShowModeless(HINSTANCE hInst, LPCSTR templName, HWND parent);
+ HWND ShowModeless(HINSTANCE hInst, LPCWSTR templName, HWND parent);
+
+ static INT_PTR CALLBACK StaticDlgProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ virtual INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam);
+};
+
+#endif
diff --git a/include/vd2/VDXFrame/VideoFilterEntry.h b/include/vd2/VDXFrame/VideoFilterEntry.h new file mode 100644 index 000000000..112f02c3f --- /dev/null +++ b/include/vd2/VDXFrame/VideoFilterEntry.h @@ -0,0 +1,84 @@ +// VDXFrame - Helper library for VirtualDub plugins
+// Copyright (C) 2008 Avery Lee
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_VDXFRAME_VIDEOFILTERENTRY_H
+#define f_VD2_VDXFRAME_VIDEOFILTERENTRY_H
+
+#include <vd2/plugin/vdvideofilt.h>
+
+#ifdef _MSC_VER
+ #pragma once
+#endif
+
+struct VDXFilterModule;
+struct VDXFilterFunctions;
+struct VDXFilterDefinition;
+
+///////////////////////////////////////////////////////////////////////////////
+/// Video filter module entry point declaration macros
+///
+/// To declare the module init and deinit functions:
+///
+/// VDX_DECLARE_VFMODULE()
+///
+/// By default this declares the module as requiring copy contructor support
+/// (V9 / VirtualDub 1.4.12). If you need to declare a different minimum
+/// version, use:
+///
+/// VDX_DECLARE_VFMODULE_APIVER(version)
+///
+#define VDX_DECLARE_VFMODULE() VDX_DECLARE_VFMODULE_APIVER(VIRTUALDUB_FILTERDEF_COMPATIBLE_COPYCTOR)
+#define VDX_DECLARE_VFMODULE_APIVER(apiver) \
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(struct VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat) { \
+ return VDXVideoFilterModuleInit2(fm, ff, vdfd_ver, vdfd_compat, (apiver)); \
+ } \
+ \
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(struct VDXFilterModule *fm, const VDXFilterFunctions *ff) { \
+ VDXVideoFilterModuleDeinit(fm, ff); \
+ }
+
+///////////////////////////////////////////////////////////////////////////////
+/// Video filter declaration macros
+///
+/// To declare video filters, use the following pattern:
+///
+/// VDX_DECLARE_VIDEOFILTERS_BEGIN()
+/// VDX_DECLARE_VIDEOFILTER(definitionSymbolName)
+/// VDX_DECLARE_VIDEOFILTERS_END()
+///
+/// Each entry points to a variable of type VDXFilterDefinition. Note that these must
+/// be declared as _non-const_ for compatibility with older versions of VirtualDub.
+/// Video filters declared this way are automatically registered by the module init
+/// routine.
+///
+#define VDX_DECLARE_VIDEOFILTERS_BEGIN() VDXFilterDefinition *VDXGetVideoFilterDefinition(int index) {
+#define VDX_DECLARE_VIDEOFILTER(defVarName) if (!index--) { extern VDXFilterDefinition defVarName; return &defVarName; }
+#define VDX_DECLARE_VIDEOFILTERS_END() return NULL; \
+ }
+int VDXVideoFilterModuleInit2(struct VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat, int ver_compat_target);
+void VDXVideoFilterModuleDeinit(struct VDXFilterModule *fm, const VDXFilterFunctions *ff);
+
+int VDXGetVideoFilterAPIVersion();
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/Filter.h b/include/vd2/extras/FilterSDK/Filter.h new file mode 100644 index 000000000..a8747a4a6 --- /dev/null +++ b/include/vd2/extras/FilterSDK/Filter.h @@ -0,0 +1,244 @@ +// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2002 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//
+// FILTER EXEMPTION:
+//
+// As a special exemption to the GPL in order to permit creation of
+// filters that work with multiple programs as well as VirtualDub,
+// compiling with this header file shall not be considered creation
+// of a derived work; that is, the act of compiling with this header
+// file does not require your source code or the resulting module
+// to be released in source code form or under a GPL-compatible
+// license according to parts (2) and (3) of the GPL. A filter built
+// using this header file may thus be licensed or dual-licensed so
+// that it may be used with VirtualDub as well as an alternative
+// product whose license is incompatible with the GPL.
+//
+// Nothing in this exemption shall be construed as applying to
+// VirtualDub itself -- that is, this exemption does not give you
+// permission to use parts of VirtualDub's source besides this
+// header file, or to dynamically link with VirtualDub as part
+// of the filter load process, in a fashion not permitted by the
+// GPL.
+
+
+#ifndef f_FILTER_H
+#define f_FILTER_H
+
+#include <windows.h>
+
+// This is really dumb, but necessary to support VTbls in C++.
+
+struct FilterVTbls {
+ void *pvtblVBitmap;
+};
+
+#ifdef VDEXT_MAIN
+struct FilterVTbls g_vtbls;
+#elif defined(VDEXT_NOTMAIN)
+extern struct FilterVTbls g_vtbls;
+#endif
+
+#define INITIALIZE_VTBLS ff->InitVTables(&g_vtbls)
+
+#include "VBitmap.h"
+
+//////////////////
+
+struct CScriptObject;
+
+//////////////////
+
+enum {
+ FILTERPARAM_SWAP_BUFFERS = 0x00000001L,
+ FILTERPARAM_NEEDS_LAST = 0x00000002L,
+};
+
+#define FILTERPARAM_HAS_LAG(frames) ((int)(frames) << 16)
+
+///////////////////
+
+class VFBitmap;
+class FilterActivation;
+struct FilterFunctions;
+
+typedef int (*FilterInitProc )(FilterActivation *fa, const FilterFunctions *ff);
+typedef void (*FilterDeinitProc )(FilterActivation *fa, const FilterFunctions *ff);
+typedef int (*FilterRunProc )(const FilterActivation *fa, const FilterFunctions *ff);
+typedef long (*FilterParamProc )(FilterActivation *fa, const FilterFunctions *ff);
+typedef int (*FilterConfigProc )(FilterActivation *fa, const FilterFunctions *ff, HWND hWnd);
+typedef void (*FilterStringProc )(const FilterActivation *fa, const FilterFunctions *ff, char *buf);
+typedef int (*FilterStartProc )(FilterActivation *fa, const FilterFunctions *ff);
+typedef int (*FilterEndProc )(FilterActivation *fa, const FilterFunctions *ff);
+typedef bool (*FilterScriptStrProc)(FilterActivation *fa, const FilterFunctions *, char *, int);
+typedef void (*FilterStringProc2 )(const FilterActivation *fa, const FilterFunctions *ff, char *buf, int maxlen);
+typedef int (*FilterSerialize )(FilterActivation *fa, const FilterFunctions *ff, char *buf, int maxbuf);
+typedef void (*FilterDeserialize )(FilterActivation *fa, const FilterFunctions *ff, const char *buf, int maxbuf);
+typedef void (*FilterCopy )(FilterActivation *fa, const FilterFunctions *ff, void *dst);
+
+typedef int (__cdecl *FilterModuleInitProc)(struct FilterModule *fm, const FilterFunctions *ff, int& vdfd_ver, int& vdfd_compat);
+typedef void (__cdecl *FilterModuleDeinitProc)(struct FilterModule *fm, const FilterFunctions *ff);
+
+//////////
+
+typedef void (__cdecl *FilterPreviewButtonCallback)(bool fNewState, void *pData);
+typedef void (__cdecl *FilterPreviewSampleCallback)(VFBitmap *, long lFrame, long lCount, void *pData);
+
+class IFilterPreview {
+public:
+ virtual void SetButtonCallback(FilterPreviewButtonCallback, void *)=0;
+ virtual void SetSampleCallback(FilterPreviewSampleCallback, void *)=0;
+
+ virtual bool isPreviewEnabled()=0;
+ virtual void Toggle(HWND)=0;
+ virtual void Display(HWND, bool)=0;
+ virtual void RedoFrame()=0;
+ virtual void RedoSystem()=0;
+ virtual void UndoSystem()=0;
+ virtual void InitButton(HWND)=0;
+ virtual void Close()=0;
+ virtual bool SampleCurrentFrame()=0;
+ virtual long SampleFrames()=0;
+};
+
+//////////
+
+#define VIRTUALDUB_FILTERDEF_VERSION (8)
+#define VIRTUALDUB_FILTERDEF_COMPATIBLE (4)
+
+// v3: added lCurrentSourceFrame to FrameStateInfo
+// v4 (1.2): lots of additions (VirtualDub 1.2)
+// v5 (1.3d): lots of bugfixes - stretchblt bilinear, and non-zero startproc
+// v6 (1.4): added error handling functions
+// v7 (1.4d): added frame lag, exception handling
+// v8 (1.4.11):
+
+typedef struct FilterModule {
+ struct FilterModule *next, *prev;
+ HINSTANCE hInstModule;
+ FilterModuleInitProc initProc;
+ FilterModuleDeinitProc deinitProc;
+} FilterModule;
+
+typedef struct FilterDefinition {
+
+ struct FilterDefinition *next, *prev;
+ FilterModule *module;
+
+ const char * name;
+ const char * desc;
+ const char * maker;
+ void * private_data;
+ int inst_data_size;
+
+ FilterInitProc initProc;
+ FilterDeinitProc deinitProc;
+ FilterRunProc runProc;
+ FilterParamProc paramProc;
+ FilterConfigProc configProc;
+ FilterStringProc stringProc;
+ FilterStartProc startProc;
+ FilterEndProc endProc;
+
+ CScriptObject *script_obj;
+
+ FilterScriptStrProc fssProc;
+
+ // NEW - 1.4.11
+ FilterStringProc2 stringProc2;
+ FilterSerialize serializeProc;
+ FilterDeserialize deserializeProc;
+ FilterCopy copyProc;
+} FilterDefinition;
+
+//////////
+
+// FilterStateInfo: contains dynamic info about file being processed
+
+class FilterStateInfo {
+public:
+ long lCurrentFrame; // current output frame
+ long lMicrosecsPerFrame; // microseconds per output frame
+ long lCurrentSourceFrame; // current source frame
+ long lMicrosecsPerSrcFrame; // microseconds per source frame
+ long lSourceFrameMS; // source frame timestamp
+ long lDestFrameMS; // output frame timestamp
+};
+
+// VFBitmap: VBitmap extended to hold filter-specific information
+
+class VFBitmap : public VBitmap {
+public:
+ enum {
+ NEEDS_HDC = 0x00000001L,
+ };
+
+ DWORD dwFlags;
+ HDC hdc;
+};
+
+// FilterActivation: This is what is actually passed to filters at runtime.
+
+class FilterActivation {
+public:
+ FilterDefinition *filter;
+ void *filter_data;
+ VFBitmap &dst, &src;
+ VFBitmap *__reserved0, *const last;
+ unsigned long x1, y1, x2, y2;
+
+ FilterStateInfo *pfsi;
+ IFilterPreview *ifp;
+
+ FilterActivation(VFBitmap& _dst, VFBitmap& _src, VFBitmap *_last) : dst(_dst), src(_src), last(_last) {}
+ FilterActivation(const FilterActivation& fa, VFBitmap& _dst, VFBitmap& _src, VFBitmap *_last);
+};
+
+// These flags must match those in cpuaccel.h!
+
+#ifndef f_VIRTUALDUB_CPUACCEL_H
+#define CPUF_SUPPORTS_CPUID (0x00000001L)
+#define CPUF_SUPPORTS_FPU (0x00000002L)
+#define CPUF_SUPPORTS_MMX (0x00000004L)
+#define CPUF_SUPPORTS_INTEGER_SSE (0x00000008L)
+#define CPUF_SUPPORTS_SSE (0x00000010L)
+#define CPUF_SUPPORTS_SSE2 (0x00000020L)
+#define CPUF_SUPPORTS_3DNOW (0x00000040L)
+#define CPUF_SUPPORTS_3DNOW_EXT (0x00000080L)
+#endif
+
+struct FilterFunctions {
+ FilterDefinition *(*addFilter)(FilterModule *, FilterDefinition *, int fd_len);
+ void (*removeFilter)(FilterDefinition *);
+ bool (*isFPUEnabled)();
+ bool (*isMMXEnabled)();
+ void (*InitVTables)(struct FilterVTbls *);
+
+ // These functions permit you to throw MyError exceptions from a filter.
+ // YOU MUST ONLY CALL THESE IN runProc, initProc, and startProc.
+
+ void (*ExceptOutOfMemory)(); // ADDED: V6 (VirtualDub 1.4)
+ void (*Except)(const char *format, ...); // ADDED: V6 (VirtualDub 1.4)
+
+ // These functions are callable at any time.
+
+ long (*getCPUFlags)(); // ADDED: V6 (VirtualDub 1.4)
+ long (*getHostVersionInfo)(char *buffer, int len); // ADDED: V7 (VirtualDub 1.4d)
+};
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/ScriptError.h b/include/vd2/extras/FilterSDK/ScriptError.h new file mode 100644 index 000000000..ceaad8bb0 --- /dev/null +++ b/include/vd2/extras/FilterSDK/ScriptError.h @@ -0,0 +1,93 @@ +// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2002 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//
+// FILTER EXEMPTION:
+//
+// As a special exemption to the GPL in order to permit creation of
+// filters that work with multiple programs as well as VirtualDub,
+// compiling with this header file shall not be considered creation
+// of a derived work; that is, the act of compiling with this header
+// file does not require your source code or the resulting module
+// to be released in source code form or under a GPL-compatible
+// license according to parts (2) and (3) of the GPL. A filter built
+// using this header file may thus be licensed or dual-licensed so
+// that it may be used with VirtualDub as well as an alternative
+// product whose license is incompatible with the GPL.
+//
+// Nothing in this exemption shall be construed as applying to
+// VirtualDub itself -- that is, this exemption does not give you
+// permission to use parts of VirtualDub's source besides this
+// header file, or to dynamically link with VirtualDub as part
+// of the filter load process, in a fashion not permitted by the
+// GPL.
+
+#ifndef f_SYLIA_SCRIPTERROR_H
+#define f_SYLIA_SCRIPTERROR_H
+
+class CScriptError {
+public:
+ int err;
+
+ enum {
+ PARSE_ERROR=1,
+ SEMICOLON_EXPECTED,
+ IDENTIFIER_EXPECTED,
+
+ TYPE_INT_REQUIRED,
+ TYPE_ARRAY_REQUIRED,
+ TYPE_FUNCTION_REQUIRED,
+ TYPE_OBJECT_REQUIRED,
+
+ OBJECT_MEMBER_NAME_REQUIRED,
+ FUNCCALLEND_EXPECTED,
+ TOO_MANY_PARAMS,
+ DIVIDE_BY_ZERO,
+ VAR_NOT_FOUND,
+ MEMBER_NOT_FOUND,
+ OVERLOADED_FUNCTION_NOT_FOUND,
+ IDENT_TOO_LONG,
+ OPERATOR_EXPECTED,
+ CLOSEPARENS_EXPECTED,
+ CLOSEBRACKET_EXPECTED,
+
+ VAR_UNDEFINED,
+
+ OUT_OF_STRING_SPACE,
+ OUT_OF_MEMORY,
+ INTERNAL_ERROR,
+ EXTERNAL_ERROR,
+
+ FCALL_OUT_OF_RANGE,
+ FCALL_INVALID_PTYPE,
+ FCALL_UNKNOWN_STR,
+ };
+
+ CScriptError(int err_num) : err(err_num) { }
+
+ int getErr() { return err; }
+};
+
+#define SCRIPT_ERROR(x) throw CScriptError(CScriptError::##x)
+
+extern "C" __declspec(dllexport) char * __stdcall TranslateScriptError(int);
+
+char inline *TranslateScriptError(CScriptError cse) {
+ return TranslateScriptError(cse.getErr());
+}
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/ScriptInterpreter.h b/include/vd2/extras/FilterSDK/ScriptInterpreter.h new file mode 100644 index 000000000..ad0197118 --- /dev/null +++ b/include/vd2/extras/FilterSDK/ScriptInterpreter.h @@ -0,0 +1,70 @@ +// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2002 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//
+// FILTER EXEMPTION:
+//
+// As a special exemption to the GPL in order to permit creation of
+// filters that work with multiple programs as well as VirtualDub,
+// compiling with this header file shall not be considered creation
+// of a derived work; that is, the act of compiling with this header
+// file does not require your source code or the resulting module
+// to be released in source code form or under a GPL-compatible
+// license according to parts (2) and (3) of the GPL. A filter built
+// using this header file may thus be licensed or dual-licensed so
+// that it may be used with VirtualDub as well as an alternative
+// product whose license is incompatible with the GPL.
+//
+// Nothing in this exemption shall be construed as applying to
+// VirtualDub itself -- that is, this exemption does not give you
+// permission to use parts of VirtualDub's source besides this
+// header file, or to dynamically link with VirtualDub as part
+// of the filter load process, in a fashion not permitted by the
+// GPL.
+
+#ifndef f_SYLIA_SCRIPTINTERPRETER_H
+#define f_SYLIA_SCRIPTINTERPRETER_H
+
+class CScriptValue;
+class CScriptError;
+struct CScriptObject;
+class IScriptInterpreter;
+
+typedef CScriptValue (*ScriptRootHandlerPtr)(IScriptInterpreter *,char *,void *);
+
+class IScriptInterpreter {
+public:
+ virtual void Destroy() =0;
+
+ virtual void SetRootHandler(ScriptRootHandlerPtr, void *) =0;
+
+ virtual void ExecuteLine(char *s) =0;
+
+ virtual void ScriptError(int e) =0;
+ virtual char* TranslateScriptError(CScriptError& cse) =0;
+ virtual char** AllocTempString(long l) =0;
+
+ virtual CScriptValue LookupObjectMember(CScriptObject *obj, void *, char *szIdent) = 0;
+};
+
+extern "C" __declspec(dllexport) IScriptInterpreter * __stdcall CreateScriptInterpreter();
+
+#define GETPROC_CREATESCRIPTINTERPRETER(hInst) ((IScriptInterpreter *(__stdcall *)())GetProcAddress(hInst, "_CreateScriptInterpreter@0"))
+
+#define EXT_SCRIPT_ERROR(x) (isi->ScriptError((CScriptError::x)))
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/ScriptValue.h b/include/vd2/extras/FilterSDK/ScriptValue.h new file mode 100644 index 000000000..52e629a3f --- /dev/null +++ b/include/vd2/extras/FilterSDK/ScriptValue.h @@ -0,0 +1,126 @@ +// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2002 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//
+// FILTER EXEMPTION:
+//
+// As a special exemption to the GPL in order to permit creation of
+// filters that work with multiple programs as well as VirtualDub,
+// compiling with this header file shall not be considered creation
+// of a derived work; that is, the act of compiling with this header
+// file does not require your source code or the resulting module
+// to be released in source code form or under a GPL-compatible
+// license according to parts (2) and (3) of the GPL. A filter built
+// using this header file may thus be licensed or dual-licensed so
+// that it may be used with VirtualDub as well as an alternative
+// product whose license is incompatible with the GPL.
+//
+// Nothing in this exemption shall be construed as applying to
+// VirtualDub itself -- that is, this exemption does not give you
+// permission to use parts of VirtualDub's source besides this
+// header file, or to dynamically link with VirtualDub as part
+// of the filter load process, in a fashion not permitted by the
+// GPL.
+
+#ifndef f_SYLIA_SCRIPTVALUE_H
+#define f_SYLIA_SCRIPTVALUE_H
+
+class CScriptArray;
+struct CScriptObject;
+class CScriptValue;
+class IScriptInterpreter;
+class VariableTableEntry;
+
+typedef CScriptValue (*ScriptObjectLookupFuncPtr)(IScriptInterpreter *, CScriptObject *, void *lpVoid, char *szName);
+typedef CScriptValue (*ScriptFunctionPtr)(IScriptInterpreter *, void *, CScriptValue *, int);
+typedef void (*ScriptVoidFunctionPtr)(IScriptInterpreter *, void *, CScriptValue *, int);
+typedef int (*ScriptIntFunctionPtr)(IScriptInterpreter *, void *, CScriptValue *, int);
+typedef CScriptValue (*ScriptArrayFunctionPtr)(IScriptInterpreter *, void *, int);
+
+typedef struct ScriptFunctionDef {
+ ScriptFunctionPtr func_ptr;
+ char *name;
+ char *arg_list;
+} ScriptFunctionDef;
+
+typedef struct ScriptObjectDef {
+ char *name;
+ CScriptObject *obj;
+} ScriptObjectDef;
+
+typedef struct CScriptObject {
+ ScriptObjectLookupFuncPtr Lookup;
+ ScriptFunctionDef *func_list;
+ ScriptObjectDef *obj_list;
+} CScriptObject;
+
+class CScriptValue {
+public:
+ enum { T_VOID, T_INT, T_PINT, T_STR, T_ARRAY, T_OBJECT, T_FNAME, T_FUNCTION, T_VARLV } type;
+ CScriptObject *thisPtr;
+ union {
+ int i;
+ int *pi;
+ char **s;
+ ScriptArrayFunctionPtr ary;
+ CScriptObject *obj;
+ ScriptFunctionPtr func;
+ ScriptFunctionDef *fname;
+ VariableTableEntry *vte;
+ } u;
+ void *lpVoid;
+
+ CScriptValue() { type = T_VOID; }
+ CScriptValue(int i) { type = T_INT; u.i = i; }
+ CScriptValue(int *pi) { type = T_PINT; u.pi = pi; }
+ CScriptValue(char **s) { type = T_STR; u.s = s; }
+ CScriptValue(CScriptObject *obj) { type = T_OBJECT; u.obj = obj; }
+ CScriptValue(CScriptObject *_thisPtr, ScriptArrayFunctionPtr csa) {
+ type = T_ARRAY;
+ u.ary = csa;
+ thisPtr = _thisPtr;
+ }
+ CScriptValue(CScriptObject *_thisPtr, ScriptFunctionDef *sfd) {
+ type = T_FNAME;
+ u.fname = sfd;
+ thisPtr = _thisPtr;
+ }
+ CScriptValue(CScriptObject *_thisPtr, ScriptFunctionPtr fn) {
+ type = T_FUNCTION;
+ u.func = fn;
+ thisPtr = _thisPtr;
+ }
+ CScriptValue(VariableTableEntry *vte) { type = T_VARLV; u.vte = vte; }
+
+ bool isVoid() { return type == T_VOID; }
+ bool isInt() { return type == T_INT; }
+ bool isString() { return type == T_STR; }
+ bool isArray() { return type == T_ARRAY; }
+ bool isObject() { return type == T_OBJECT; }
+ bool isFName() { return type == T_FNAME; }
+ bool isFunction() { return type == T_FUNCTION; }
+ bool isVarLV() { return type == T_VARLV; }
+
+ int asInt() { return u.i; }
+ char ** asString() { return u.s; }
+ ScriptArrayFunctionPtr asArray() { return u.ary; }
+ CScriptObject * asObject() { return u.obj; }
+ ScriptFunctionPtr asFunction() { return u.func; }
+ VariableTableEntry* asVarLV() { return u.vte; }
+};
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/VBitmap.h b/include/vd2/extras/FilterSDK/VBitmap.h new file mode 100644 index 000000000..0b95066fc --- /dev/null +++ b/include/vd2/extras/FilterSDK/VBitmap.h @@ -0,0 +1,172 @@ +// VirtualDub - Video processing and capture application
+// Copyright (C) 1998-2002 Avery Lee
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+//
+// FILTER EXEMPTION:
+//
+// As a special exemption to the GPL in order to permit creation of
+// filters that work with multiple programs as well as VirtualDub,
+// compiling with this header file shall not be considered creation
+// of a derived work; that is, the act of compiling with this header
+// file does not require your source code or the resulting module
+// to be released in source code form or under a GPL-compatible
+// license according to parts (2) and (3) of the GPL. A filter built
+// using this header file may thus be licensed or dual-licensed so
+// that it may be used with VirtualDub as well as an alternative
+// product whose license is incompatible with the GPL.
+//
+// Nothing in this exemption shall be construed as applying to
+// VirtualDub itself -- that is, this exemption does not give you
+// permission to use parts of VirtualDub's source besides this
+// header file, or to dynamically link with VirtualDub as part
+// of the filter load process, in a fashion not permitted by the
+// GPL.
+
+#ifndef f_VIRTUALDUB_VBITMAP_H
+#define f_VIRTUALDUB_VBITMAP_H
+
+#include <windows.h>
+
+typedef unsigned long Pixel;
+typedef unsigned long Pixel32;
+typedef unsigned char Pixel8;
+typedef long PixCoord;
+typedef long PixDim;
+typedef long PixOffset;
+
+#ifdef VDEXT_VIDEO_FILTER
+#define NOVTABLE __declspec(novtable)
+#else
+#define NOVTABLE
+#endif
+
+class NOVTABLE VBitmap {
+public:
+ Pixel * data;
+ Pixel * palette;
+ int depth;
+ PixCoord w, h;
+ PixOffset pitch;
+ PixOffset modulo;
+ PixOffset size;
+ PixOffset offset;
+
+ Pixel *Address(PixCoord x, PixCoord y) const {
+ return Addressi(x, h-y-1);
+ }
+
+ Pixel *Addressi(PixCoord x, PixCoord y) const {
+ return (Pixel *)((char *)data + y*pitch + x*(depth>>3));
+ }
+
+ Pixel *Address16(PixCoord x, PixCoord y) const {
+ return Address16i(x, h-y-1);
+ }
+
+ Pixel *Address16i(PixCoord x, PixCoord y) const {
+ return (Pixel *)((char *)data + y*pitch + x*2);
+ }
+
+ Pixel *Address32(PixCoord x, PixCoord y) const {
+ return Address32i(x, h-y-1);
+ }
+
+ Pixel *Address32i(PixCoord x, PixCoord y) const {
+ return (Pixel *)((char *)data + y*pitch + x*sizeof(Pixel));
+ }
+
+ PixOffset PitchAlign4() {
+ return ((w * depth + 31)/32)*4;
+ }
+
+ PixOffset PitchAlign8() {
+ return ((w * depth + 63)/64)*8;
+ }
+
+ PixOffset Modulo() {
+ return pitch - (w*depth+7)/8;
+ }
+
+ PixOffset Size() {
+ return pitch*h;
+ }
+
+ //////
+
+ VBitmap() throw() {
+#ifdef VDEXT_VIDEO_FILTER
+ init();
+#endif
+ }
+ VBitmap(void *data, PixDim w, PixDim h, int depth) throw();
+ VBitmap(void *data, BITMAPINFOHEADER *) throw();
+
+#ifdef VDEXT_VIDEO_FILTER
+ void init() throw() { *(void **)this = g_vtbls.pvtblVBitmap; }
+#endif
+
+ virtual VBitmap& init(void *data, PixDim w, PixDim h, int depth) throw();
+ virtual VBitmap& init(void *data, BITMAPINFOHEADER *) throw();
+
+ virtual void MakeBitmapHeader(BITMAPINFOHEADER *bih) const throw();
+
+ virtual void AlignTo4() throw();
+ virtual void AlignTo8() throw();
+
+ virtual void BitBlt(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
+ virtual void BitBltDither(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy, bool to565) const throw();
+ virtual void BitBlt565(PixCoord x2, PixCoord y2, const VBitmap *src, PixDim x1, PixDim y1, PixDim dx, PixDim dy) const throw();
+
+ virtual bool BitBltXlat1(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel8 *tbl) const throw();
+ virtual bool BitBltXlat3(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const Pixel32 *tbl) const throw();
+
+ virtual bool StretchBltNearestFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
+
+ virtual bool StretchBltBilinearFast(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, const VBitmap *src, double x2, double y2, double dx1, double dy1) const throw();
+
+ virtual bool RectFill(PixCoord x1, PixCoord y1, PixDim dx, PixDim dy, Pixel32 c) const throw();
+
+ enum {
+ HISTO_LUMA,
+ HISTO_GRAY,
+ HISTO_RED,
+ HISTO_GREEN,
+ HISTO_BLUE,
+ };
+
+ virtual bool Histogram(PixCoord x, PixCoord y, PixCoord dx, PixCoord dy, long *pHisto, int iHistoType) const throw();
+
+ //// NEW AS OF VIRTUALDUB V1.2B
+
+ virtual bool BitBltFromYUY2(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
+ virtual bool BitBltFromI420(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
+
+ //// NEW AS OF VIRTUALDUB V1.4C
+
+ virtual void MakeBitmapHeaderNoPadding(BITMAPINFOHEADER *bih) const throw();
+
+ ///////////
+
+ bool BitBltFromYUY2Fullscale(PixCoord x2, PixCoord y2, const VBitmap *src, PixCoord x1, PixCoord y1, PixDim dx, PixDim dy) const throw();
+
+private:
+ bool dualrectclip(PixCoord& x2, PixCoord& y2, const VBitmap *src, PixCoord& x1, PixCoord& y1, PixDim& dx, PixDim& dy) const throw();
+};
+
+#undef NOVTABLE
+
+#endif
diff --git a/include/vd2/extras/FilterSDK/VirtualDub.h b/include/vd2/extras/FilterSDK/VirtualDub.h new file mode 100644 index 000000000..25e5fd475 --- /dev/null +++ b/include/vd2/extras/FilterSDK/VirtualDub.h @@ -0,0 +1,7 @@ +#pragma once
+
+#include "Filter.h"
+#include "ScriptInterpreter.h"
+#include "ScriptError.h"
+#include "ScriptValue.h"
+#include "VBitmap.h"
diff --git a/include/vd2/extras/FilterSDK/readme.txt b/include/vd2/extras/FilterSDK/readme.txt new file mode 100644 index 000000000..5ccf63548 --- /dev/null +++ b/include/vd2/extras/FilterSDK/readme.txt @@ -0,0 +1,6 @@ +There are the header files that were included with the last version of the
+Filter SDK. You can use these if you need to rebuild a filter that doesn't
+compile with the new headers, or otherwise need to know the full API supported
+by that SDK (such as if you are building a new filter host). If possible,
+you should use the migration headers in include/vd2/OldFilterSDK instead,
+and new filters should use <vd2/plugin/vdvideofilt.h> directly.
diff --git a/include/vd2/plugin/vdaudiofilt.h b/include/vd2/plugin/vdaudiofilt.h new file mode 100644 index 000000000..2680ad794 --- /dev/null +++ b/include/vd2/plugin/vdaudiofilt.h @@ -0,0 +1,148 @@ +#ifndef f_VD2_PLUGIN_VDAUDIOFILT_H
+#define f_VD2_PLUGIN_VDAUDIOFILT_H
+
+///////////////////////////////////////////////////////////////////////////
+//
+// Audio filter support
+
+struct VDAudioFilterDefinition;
+struct VDXWaveFormat;
+struct VDPluginCallbacks;
+
+enum {
+ kVDPlugin_AudioAPIVersion = 2
+};
+
+struct VDAudioFilterPin {
+ unsigned mGranularity; // Block size a filter reads/writes this pin.
+ unsigned mDelay; // Delay in samples on this input.
+ unsigned mBufferSize; // The size, in samples, of the buffer.
+ unsigned mCurrentLevel; // The number of samples currently in the buffer.
+ sint64 mLength; // Approximate length of this stream in us.
+ const VDXWaveFormat *mpFormat;
+ bool mbVBR;
+ bool mbEnded;
+ char _pad[2];
+ void *mpBuffer;
+ unsigned mSamplesWritten; // The number of samples just written to the buffer.
+ unsigned mAvailSpace; // Available room pointed to by mpBuffer (output pins only).
+
+ uint32 (VDAPIENTRY *mpReadProc)(VDAudioFilterPin *pPin, void *dst, uint32 samples, bool bAllowFill, int format);
+
+ // These helpers are non-virtual inlines and are compiled into filters.
+ uint32 Read(void *dst, uint32 samples, bool bAllowFill, int format) {
+ return mpReadProc(this, dst, samples, bAllowFill, format);
+ }
+};
+
+struct VDAudioFilterContext;
+
+struct VDAudioFilterCallbacks {
+ VDXWaveFormat *(VDAPIENTRY *AllocPCMWaveFormat)(unsigned sampling_rate, unsigned channels, unsigned bits, bool bFloat);
+ VDXWaveFormat *(VDAPIENTRY *AllocCustomWaveFormat)(unsigned extra_size);
+ VDXWaveFormat *(VDAPIENTRY *CopyWaveFormat)(const VDXWaveFormat *);
+ void (VDAPIENTRY *FreeWaveFormat)(const VDXWaveFormat *);
+ void (VDAPIENTRY *Wake)(const VDAudioFilterContext *pContext);
+};
+
+struct VDAudioFilterContext {
+ void *mpFilterData;
+ VDAudioFilterPin **mpInputs;
+ VDAudioFilterPin **mpOutputs;
+ IVDPluginCallbacks *mpServices;
+ const VDAudioFilterCallbacks *mpAudioCallbacks;
+ const VDAudioFilterDefinition *mpDefinition;
+ uint32 mAPIVersion;
+ uint32 mInputSamples; // Number of input samples available on all pins.
+ uint32 mInputGranules; // Number of input granules available on all pins.
+ uint32 mInputsEnded; // Number of inputs that have ended.
+ uint32 mOutputSamples; // Number of output sample spaces available on all pins.
+ uint32 mOutputGranules; // Number of output granule spaces available on all pins.
+ uint32 mCommonSamples; // Number of input samples and output sample spaces.
+ uint32 mCommonGranules; // Number of input and output granules.
+};
+
+// This structure is intentionally identical to WAVEFORMATEX, with one
+// exception -- mExtraSize is *always* present, even for PCM.
+
+struct VDXWaveFormat {
+ enum { kTagPCM = 1 };
+
+ uint16 mTag;
+ uint16 mChannels;
+ uint32 mSamplingRate;
+ uint32 mDataRate;
+ uint16 mBlockSize;
+ uint16 mSampleBits;
+ uint16 mExtraSize;
+};
+
+enum {
+ kVFARun_OK = 0,
+ kVFARun_Finished = 1,
+ kVFARun_InternalWork = 2,
+
+ kVFAPrepare_OK = 0,
+ kVFAPrepare_BadFormat = 1
+};
+
+enum {
+ kVFARead_Native = 0,
+ kVFARead_PCM8 = 1,
+ kVFARead_PCM16 = 2,
+ kVFARead_PCM32F = 3
+};
+
+typedef void * (VDAPIENTRY *VDAudioFilterExtProc )(const VDAudioFilterContext *pContext, const char *pInterfaceName);
+typedef uint32 (VDAPIENTRY *VDAudioFilterRunProc )(const VDAudioFilterContext *pContext);
+typedef sint64 (VDAPIENTRY *VDAudioFilterSeekProc )(const VDAudioFilterContext *pContext, sint64 microsecs);
+typedef uint32 (VDAPIENTRY *VDAudioFilterPrepareProc )(const VDAudioFilterContext *pContext);
+typedef void (VDAPIENTRY *VDAudioFilterStartProc )(const VDAudioFilterContext *pContext);
+typedef void (VDAPIENTRY *VDAudioFilterStopProc )(const VDAudioFilterContext *pContext);
+typedef void (VDAPIENTRY *VDAudioFilterInitProc )(const VDAudioFilterContext *pContext);
+typedef void (VDAPIENTRY *VDAudioFilterDestroyProc )(const VDAudioFilterContext *pContext);
+typedef unsigned (VDAPIENTRY *VDAudioFilterSuspendProc )(const VDAudioFilterContext *pContext, void *dst, unsigned size);
+typedef void (VDAPIENTRY *VDAudioFilterResumeProc )(const VDAudioFilterContext *pContext, const void *src, unsigned size);
+typedef unsigned (VDAPIENTRY *VDAudioFilterGetParamProc )(const VDAudioFilterContext *pContext, unsigned idx, void *dst, unsigned size);
+typedef void (VDAPIENTRY *VDAudioFilterSetParamProc )(const VDAudioFilterContext *pContext, unsigned idx, const void *src, unsigned variant_count);
+typedef bool (VDAPIENTRY *VDAudioFilterConfigProc )(const VDAudioFilterContext *pContext, struct HWND__ *hwnd);
+
+enum {
+ kVFAF_Zero = 0,
+ kVFAF_HasConfig = 1, // Filter has a configuration dialog.
+ kVFAF_SerializedIO = 2, // Filter must execute in the serialized I/O thread.
+
+ kVFAF_Max = 0xFFFFFFFF,
+};
+
+struct VDAudioFilterVtbl {
+ uint32 mSize;
+ VDAudioFilterDestroyProc mpDestroy;
+ VDAudioFilterPrepareProc mpPrepare;
+ VDAudioFilterStartProc mpStart;
+ VDAudioFilterStopProc mpStop;
+ VDAudioFilterRunProc mpRun;
+ VDAudioFilterSeekProc mpSeek;
+ VDAudioFilterSuspendProc mpSuspend;
+ VDAudioFilterResumeProc mpResume;
+ VDAudioFilterGetParamProc mpGetParam;
+ VDAudioFilterSetParamProc mpSetParam;
+ VDAudioFilterConfigProc mpConfig;
+ VDAudioFilterExtProc mpExt;
+};
+
+struct VDAudioFilterDefinition {
+ uint32 mSize; // size of this structure in bytes
+ uint32 mFlags;
+
+ uint32 mFilterDataSize;
+ uint32 mInputPins;
+ uint32 mOutputPins;
+
+ const VDXPluginConfigEntry *mpConfigInfo;
+
+ VDAudioFilterInitProc mpInit;
+ const VDAudioFilterVtbl *mpVtbl;
+};
+
+#endif
diff --git a/include/vd2/plugin/vdinputdriver.h b/include/vd2/plugin/vdinputdriver.h new file mode 100644 index 000000000..b75738c98 --- /dev/null +++ b/include/vd2/plugin/vdinputdriver.h @@ -0,0 +1,284 @@ +// VirtualDub - Video processing and capture application
+// Plugin headers
+// Copyright (C) 1998-2007 Avery Lee, All Rights Reserved.
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_PLUGIN_VDINPUTDRIVER_H
+#define f_VD2_PLUGIN_VDINPUTDRIVER_H
+
+#ifdef _MSC_VER
+ #pragma once
+ #pragma pack(push, 8)
+#endif
+
+#include "vdplugin.h"
+
+/// Unsigned 32-bit fraction.
+struct VDXFraction {
+ uint32 mNumerator;
+ uint32 mDenominator;
+};
+
+typedef struct VDXHWNDStruct *VDXHWND;
+typedef struct VDXBITMAPINFOHEADERStruct {
+ enum { kCompressionRGB = 0 };
+ uint32 mSize;
+ sint32 mWidth;
+ sint32 mHeight;
+ uint16 mPlanes;
+ uint16 mBitCount;
+ uint32 mCompression;
+ uint32 mSizeImage;
+ sint32 mXPelsPerMeter;
+ sint32 mYPelsPerMeter;
+ uint32 mClrUsed;
+ uint32 mClrImportant;
+} VDXBITMAPINFOHEADER;
+
+typedef struct VDXWAVEFORMATEXStruct {
+ enum { kFormatPCM = 1 };
+ uint16 mFormatTag;
+ uint16 mChannels;
+ uint32 mSamplesPerSec;
+ uint32 mAvgBytesPerSec;
+ uint16 mBlockAlign;
+ uint16 mBitsPerSample;
+ uint16 mExtraSize;
+} VDXWAVEFORMATEX;
+
+struct VDXStreamSourceInfo {
+ VDXFraction mSampleRate;
+ sint64 mSampleCount;
+ VDXFraction mPixelAspectRatio;
+};
+
+// V3+ (1.7.X) only
+struct VDXStreamSourceInfoV3 {
+ VDXStreamSourceInfo mInfo;
+
+ enum {
+ kFlagVariableSizeSamples = 0x00000001
+ };
+
+ uint32 mFlags;
+ uint32 mfccHandler; ///< If non-zero, specifies the FOURCC of a codec handler that should be preferred.
+};
+
+class IVDXStreamSource : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 's', 't', 's') };
+
+ virtual void VDXAPIENTRY GetStreamSourceInfo(VDXStreamSourceInfo&) = 0;
+
+ virtual bool VDXAPIENTRY Read(sint64 lStart, uint32 lCount, void *lpBuffer, uint32 cbBuffer, uint32 *lBytesRead, uint32 *lSamplesRead) = 0;
+
+ virtual const void * VDXAPIENTRY GetDirectFormat() = 0;
+ virtual int VDXAPIENTRY GetDirectFormatLen() = 0;
+
+ enum ErrorMode {
+ kErrorModeReportAll = 0,
+ kErrorModeConceal,
+ kErrorModeDecodeAnyway,
+ kErrorModeCount
+ };
+
+ virtual ErrorMode VDXAPIENTRY GetDecodeErrorMode() = 0;
+ virtual void VDXAPIENTRY SetDecodeErrorMode(ErrorMode mode) = 0;
+ virtual bool VDXAPIENTRY IsDecodeErrorModeSupported(ErrorMode mode) = 0;
+
+ virtual bool VDXAPIENTRY IsVBR() = 0;
+ virtual sint64 VDXAPIENTRY TimeToPositionVBR(sint64 us) = 0;
+ virtual sint64 VDXAPIENTRY PositionToTimeVBR(sint64 samples) = 0;
+};
+
+// V3+ (1.7.X)
+class IVDXStreamSourceV3 : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 's', 't', '2') };
+
+ virtual void VDXAPIENTRY GetStreamSourceInfoV3(VDXStreamSourceInfoV3&) = 0;
+};
+
+class IVDXVideoDecoderModel : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'm') };
+
+ virtual void VDXAPIENTRY Reset() = 0;
+ virtual void VDXAPIENTRY SetDesiredFrame(sint64 frame_num) = 0;
+ virtual sint64 VDXAPIENTRY GetNextRequiredSample(bool& is_preroll) = 0;
+ virtual int VDXAPIENTRY GetRequiredCount() = 0;
+};
+
+class IVDXVideoDecoder : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 'e') };
+
+ virtual const void * VDXAPIENTRY DecodeFrame(const void *inputBuffer, uint32 data_len, bool is_preroll, sint64 sampleNumber, sint64 targetFrame) = 0;
+ virtual uint32 VDXAPIENTRY GetDecodePadding() = 0;
+ virtual void VDXAPIENTRY Reset() = 0;
+ virtual bool VDXAPIENTRY IsFrameBufferValid() = 0;
+ virtual const VDXPixmap& VDXAPIENTRY GetFrameBuffer() = 0;
+ virtual bool VDXAPIENTRY SetTargetFormat(int format, bool useDIBAlignment) = 0;
+ virtual bool VDXAPIENTRY SetDecompressedFormat(const VDXBITMAPINFOHEADER *pbih) = 0;
+
+ virtual bool VDXAPIENTRY IsDecodable(sint64 sample_num) = 0;
+ virtual const void * VDXAPIENTRY GetFrameBufferBase() = 0;
+};
+
+enum VDXVideoFrameType {
+ kVDXVFT_Independent,
+ kVDXVFT_Predicted,
+ kVDXVFT_Bidirectional,
+ kVDXVFT_Null,
+};
+
+struct VDXVideoFrameInfo {
+ char mTypeChar;
+ uint8 mFrameType;
+ sint64 mBytePosition;
+};
+
+struct VDXVideoSourceInfo {
+ enum DecoderModel {
+ kDecoderModelCustom, ///< A custom decoder model is provided.
+ kDecoderModelDefaultIP ///< Use the default I/P decoder model.
+ };
+
+ enum Flags {
+ kFlagNone = 0,
+ kFlagKeyframeOnly = 0x00000001,
+ kFlagAll = 0xFFFFFFFF
+ };
+
+public:
+ uint32 mFlags;
+ uint32 mWidth;
+ uint32 mHeight;
+ uint8 mDecoderModel;
+ uint8 unused[3];
+};
+
+class IVDXVideoSource : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'v', 'd', 's') };
+
+ virtual void VDXAPIENTRY GetVideoSourceInfo(VDXVideoSourceInfo& info) = 0;
+
+ virtual bool VDXAPIENTRY CreateVideoDecoderModel(IVDXVideoDecoderModel **) = 0;
+ virtual bool VDXAPIENTRY CreateVideoDecoder(IVDXVideoDecoder **) = 0;
+
+ virtual void VDXAPIENTRY GetSampleInfo(sint64 sample_num, VDXVideoFrameInfo& frameInfo) = 0;
+
+ virtual bool VDXAPIENTRY IsKey(sint64 sample_num) = 0;
+
+ virtual sint64 VDXAPIENTRY GetFrameNumberForSample(sint64 sample_num) = 0;
+ virtual sint64 VDXAPIENTRY GetSampleNumberForFrame(sint64 frame_num) = 0;
+ virtual sint64 VDXAPIENTRY GetRealFrame(sint64 frame_num) = 0;
+
+ virtual sint64 VDXAPIENTRY GetSampleBytePosition(sint64 sample_num) = 0;
+};
+
+struct VDXAudioSourceInfo {
+public:
+ uint32 mFlags;
+};
+
+class IVDXAudioSource : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'a', 'd', 's') };
+
+ virtual void VDXAPIENTRY GetAudioSourceInfo(VDXAudioSourceInfo& info) = 0;
+};
+
+class IVDXInputOptions : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'i', 'o', 'p') };
+
+ virtual uint32 VDXAPIENTRY Write(void *buf, uint32 buflen) = 0;
+};
+
+class IVDXInputFile : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'l') };
+
+ virtual bool VDXAPIENTRY PromptForOptions(VDXHWND, IVDXInputOptions **ppOptions) = 0;
+ virtual bool VDXAPIENTRY CreateOptions(const void *buf, uint32 len, IVDXInputOptions **ppOptions) = 0;
+
+ virtual void VDXAPIENTRY Init(const wchar_t *path, IVDXInputOptions *options) = 0;
+ virtual bool VDXAPIENTRY Append(const wchar_t *path) = 0;
+
+ virtual void VDXAPIENTRY DisplayInfo(VDXHWND hwndParent) = 0;
+
+ virtual bool VDXAPIENTRY GetVideoSource(int index, IVDXVideoSource **ppVS) = 0;
+ virtual bool VDXAPIENTRY GetAudioSource(int index, IVDXAudioSource **ppAS) = 0;
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// IVDXInputFileDriver
+//
+class IVDXInputFileDriver : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'i', 'f', 'd') };
+
+ virtual int VDXAPIENTRY DetectBySignature(const void *pHeader, sint32 nHeaderSize, const void *pFooter, sint32 nFooterSize, sint64 nFileSize) = 0;
+ virtual bool VDXAPIENTRY CreateInputFile(uint32 flags, IVDXInputFile **ppFile) = 0;
+};
+
+struct VDXInputDriverContext {
+ uint32 mAPIVersion;
+ IVDPluginCallbacks *mpCallbacks;
+};
+
+typedef bool (VDXAPIENTRY *VDXInputDriverCreateProc)(const VDXInputDriverContext *pContext, IVDXInputFileDriver **);
+
+struct VDXInputDriverDefinition {
+ enum {
+ kFlagNone = 0x00000000,
+ kFlagSupportsVideo = 0x00000001,
+ kFlagSupportsAudio = 0x00000002,
+ kFlagCustomSignature = 0x00010000,
+ kFlagAll = 0xFFFFFFFF
+ };
+ uint32 mSize; // size of this structure in bytes
+ uint32 mFlags;
+ sint32 mPriority;
+ uint32 mSignatureLength;
+ const void *mpSignature;
+ const wchar_t *mpFilenameDetectPattern;
+ const wchar_t *mpFilenamePattern;
+ const wchar_t *mpDriverTagName;
+
+ VDXInputDriverCreateProc mpCreate;
+};
+
+enum {
+ // V1 (1.7.4.28204): Initial version
+ // V2 (1.7.5): Default I/P frame model fixed.
+ kVDXPlugin_InputDriverAPIVersion = 2
+};
+
+#ifdef _MSC_VER
+ #pragma pack(pop)
+#endif
+
+#endif
diff --git a/include/vd2/plugin/vdplugin.h b/include/vd2/plugin/vdplugin.h new file mode 100644 index 000000000..cec344d37 --- /dev/null +++ b/include/vd2/plugin/vdplugin.h @@ -0,0 +1,206 @@ +// VirtualDub - Video processing and capture application
+// Plugin headers
+// Copyright (C) 1998-2007 Avery Lee, All Rights Reserved.
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_PLUGIN_VDPLUGIN_H
+#define f_VD2_PLUGIN_VDPLUGIN_H
+
+#ifdef _MSC_VER
+ #pragma once
+ #pragma pack(push, 8)
+#endif
+
+#include <stddef.h>
+
+// Copied from <vd2/system/vdtypes.h>. Must be in sync.
+#ifndef VD_STANDARD_TYPES_DECLARED
+ #if defined(_MSC_VER)
+ typedef signed __int64 sint64;
+ typedef unsigned __int64 uint64;
+ #elif defined(__GNUC__)
+ typedef signed long long sint64;
+ typedef unsigned long long uint64;
+ #endif
+ typedef signed int sint32;
+ typedef unsigned int uint32;
+ typedef signed short sint16;
+ typedef unsigned short uint16;
+ typedef signed char sint8;
+ typedef unsigned char uint8;
+
+ typedef sint64 int64;
+ typedef sint32 int32;
+ typedef sint16 int16;
+ typedef sint8 int8;
+
+ typedef ptrdiff_t sintptr;
+ typedef size_t uintptr;
+#endif
+
+#ifndef VDXAPIENTRY
+ #define VDXAPIENTRY __stdcall
+#endif
+
+#ifndef VDXAPIENTRYV
+ #define VDXAPIENTRYV __cdecl
+#endif
+
+enum VDXCPUFeatureFlags {
+ kVDXCPUF_CPUID = 0x00000001,
+ kVDXCPUF_MMX = 0x00000004,
+ kVDXCPUF_ISSE = 0x00000008,
+ kVDXCPUF_SSE = 0x00000010,
+ kVDXCPUF_SSE2 = 0x00000020,
+ kVDXCPUF_3DNOW = 0x00000040,
+ kVDXCPUF_3DNOW_EXT = 0x00000080,
+ kVDXCPUF_SSE3 = 0x00000100,
+ kVDXCPUF_SSSE3 = 0x00000200
+};
+
+enum {
+ kVDXPlugin_APIVersion = 10
+};
+
+
+enum {
+ kVDXPluginType_Video, // Updated video filter API is not yet complete.
+ kVDXPluginType_Audio,
+ kVDXPluginType_Input
+};
+
+struct VDXPluginInfo {
+ uint32 mSize; // size of this structure in bytes
+ const wchar_t *mpName;
+ const wchar_t *mpAuthor;
+ const wchar_t *mpDescription;
+ uint32 mVersion; // (major<<24) + (minor<<16) + build. 1.4.1000 would be 0x010403E8.
+ uint32 mType;
+ uint32 mFlags;
+ uint32 mAPIVersionRequired;
+ uint32 mAPIVersionUsed;
+ uint32 mTypeAPIVersionRequired;
+ uint32 mTypeAPIVersionUsed;
+ const void * mpTypeSpecificInfo;
+};
+
+typedef const VDXPluginInfo *const *(VDXAPIENTRY *tpVDXGetPluginInfo)();
+
+typedef VDXPluginInfo VDPluginInfo;
+typedef tpVDXGetPluginInfo tpVDPluginInfo;
+
+class IVDXPluginCallbacks {
+public:
+ virtual void * VDXAPIENTRY GetExtendedAPI(const char *pExtendedAPIName) = 0;
+ virtual void VDXAPIENTRYV SetError(const char *format, ...) = 0;
+ virtual void VDXAPIENTRY SetErrorOutOfMemory() = 0;
+ virtual uint32 VDXAPIENTRY GetCPUFeatureFlags() = 0;
+};
+
+typedef IVDXPluginCallbacks IVDPluginCallbacks;
+
+struct VDXPluginConfigEntry {
+ enum Type {
+ kTypeInvalid = 0,
+ kTypeU32 = 1,
+ kTypeS32,
+ kTypeU64,
+ kTypeS64,
+ kTypeDouble,
+ kTypeAStr,
+ kTypeWStr,
+ kTypeBlock
+ };
+
+ const VDXPluginConfigEntry *next;
+
+ unsigned idx;
+ uint32 type;
+ const wchar_t *name;
+ const wchar_t *label;
+ const wchar_t *desc;
+};
+
+struct VDXPixmap {
+ void *data;
+ const uint32 *palette;
+ sint32 w;
+ sint32 h;
+ ptrdiff_t pitch;
+ sint32 format;
+
+ // Auxiliary planes are always byte-per-pixel.
+ void *data2; // Cb (U) for YCbCr
+ ptrdiff_t pitch2;
+ void *data3; // Cr (V) for YCbCr
+ ptrdiff_t pitch3;
+};
+
+struct VDXPixmapLayout {
+ ptrdiff_t data;
+ const uint32 *palette;
+ sint32 w;
+ sint32 h;
+ ptrdiff_t pitch;
+ sint32 format;
+
+ // Auxiliary planes are always byte-per-pixel.
+ ptrdiff_t data2; // Cb (U) for YCbCr
+ ptrdiff_t pitch2;
+ ptrdiff_t data3; // Cr (V) for YCbCr
+ ptrdiff_t pitch3;
+};
+
+namespace nsVDXPixmap {
+ enum VDXPixmapFormat {
+ kPixFormat_Null = 0,
+ kPixFormat_XRGB1555 = 5,
+ kPixFormat_RGB565 = 6,
+ kPixFormat_RGB888 = 7,
+ kPixFormat_XRGB8888 = 8,
+ kPixFormat_Y8 = 9,
+ kPixFormat_YUV422_UYVY = 10,
+ kPixFormat_YUV422_YUYV = 11,
+ kPixFormat_YUV444_Planar = 13,
+ kPixFormat_YUV422_Planar = 14,
+ kPixFormat_YUV420_Planar = 15,
+ kPixFormat_YUV411_Planar = 16,
+ kPixFormat_YUV410_Planar = 17
+ };
+};
+
+#define VDXMAKEFOURCC(a, b, c, d) ((uint32)(uint8)(d) + ((uint32)(uint8)(c) << 8) + ((uint32)(uint8)(b) << 16) + ((uint32)(uint8)(a) << 24))
+
+class IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'u', 'n', 'k') };
+ virtual int VDXAPIENTRY AddRef() = 0;
+ virtual int VDXAPIENTRY Release() = 0;
+ virtual void *VDXAPIENTRY AsInterface(uint32 iid) = 0;
+};
+
+#ifdef _MSC_VER
+ #pragma pack(pop)
+#endif
+
+#endif
diff --git a/include/vd2/plugin/vdvideofilt.h b/include/vd2/plugin/vdvideofilt.h new file mode 100644 index 000000000..aab8e023f --- /dev/null +++ b/include/vd2/plugin/vdvideofilt.h @@ -0,0 +1,517 @@ +// VirtualDub - Video processing and capture application
+// Plugin headers
+// Copyright (C) 1998-2007 Avery Lee, All Rights Reserved.
+//
+// The plugin headers in the VirtualDub plugin SDK are licensed differently
+// differently than VirtualDub and the Plugin SDK themselves. This
+// particular file is thus licensed as follows (the "zlib" license):
+//
+// This software is provided 'as-is', without any express or implied
+// warranty. In no event will the authors be held liable for any
+// damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it
+// freely, subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented; you must
+// not claim that you wrote the original software. If you use this
+// software in a product, an acknowledgment in the product
+// documentation would be appreciated but is not required.
+// 2. Altered source versions must be plainly marked as such, and must
+// not be misrepresented as being the original software.
+// 3. This notice may not be removed or altered from any source
+// distribution.
+
+#ifndef f_VD2_PLUGIN_VDVIDEOFILT_H
+#define f_VD2_PLUGIN_VDVIDEOFILT_H
+
+#ifdef _MSC_VER
+ #pragma once
+ #pragma pack(push, 8)
+#endif
+
+#include <stddef.h>
+
+#include "vdplugin.h"
+
+typedef struct VDXHINSTANCEStruct *VDXHINSTANCE;
+typedef struct VDXHDCStruct *VDXHDC;
+typedef struct VDXHWNDStruct *VDXHWND;
+
+//////////////////
+
+struct VDXScriptObject;
+struct VDXFilterVTbls;
+
+//////////////////
+
+enum {
+ /// Request distinct source and destination buffers. Otherwise, the source and destination buffers
+ /// alias (in-place mode).
+ FILTERPARAM_SWAP_BUFFERS = 0x00000001L,
+
+ /// Request an extra buffer for the previous source frame.
+ FILTERPARAM_NEEDS_LAST = 0x00000002L,
+
+ /// Filter supports image formats other than RGB32. Filters that support format negotiation must
+ /// set this flag for all calls to paramProc.
+ FILTERPARAM_SUPPORTS_ALTFORMATS = 0x00000004L,
+
+ /// Filter requests 16 byte alignment for source and destination buffers. This guarantees that:
+ ///
+ /// - data and pitch fields are multiples of 16 bytes (aligned)
+ /// - an integral number of 16 byte vectors may be read, even if the last vector includes
+ /// some bytes beyond the end of the scanline (their values are undefined)
+ /// - an integral number of 16 byte vectors may be written, even if the last vector includes
+ /// some bytes beyong the end of the scanline (their values are ignored)
+ ///
+ FILTERPARAM_ALIGN_SCANLINES = 0x00000008L,
+
+ /// Filter's output is purely a function of configuration parameters and source image data, and not
+ /// source or output frame numbers. In other words, two output frames produced by a filter instance
+ /// can be assumed to be identical images if:
+ ///
+ /// - the same number of source frames are prefetched
+ /// - the same type of prefetches are performed (direct vs. non-direct)
+ /// - the frame numbers for the two prefetch lists, taken in order, correspond to identical
+ /// source frames
+ /// - the prefetch cookies match
+ ///
+ /// Enabling this flag improves the ability of the host to identify identical frames and drop them
+ /// in preview or in the output file.
+ ///
+ FILTERPARAM_PURE_TRANSFORM = 0x00000010L,
+
+ /// Filter cannot support the requested source format. Note that this sets all bits, so the meaning
+ /// of other bits is ignored. The one exception is that FILTERPARAM_SUPPORTS_ALTFORMATS is assumed
+ /// to be implicitly set.
+ FILTERPARAM_NOT_SUPPORTED = (long)0xFFFFFFFF
+};
+
+/// The filter has a delay from source to output. For instance, a lag of 3 indicates that the
+/// filter internally buffers three frames, so when it is fed frames in sequence, frame 0 emerges
+/// after frame 3 has been processed. The host attempts to correct timestamps in order to compensate.
+///
+/// VirtualDub 1.9.1 or later: Setting this flag can have a performance penalty, as it causes the host
+/// to request additional frames to try to produce the correct requested output frames.
+///
+#define FILTERPARAM_HAS_LAG(frames) ((int)(frames) << 16)
+
+///////////////////
+
+class VDXFBitmap;
+class VDXFilterActivation;
+struct VDXFilterFunctions;
+struct VDXFilterModule;
+class IVDXVideoPrefetcher;
+
+enum {
+ kVDXVFEvent_None = 0,
+ kVDXVFEvent_InvalidateCaches = 1
+};
+
+typedef int (__cdecl *VDXFilterInitProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef void (__cdecl *VDXFilterDeinitProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef int (__cdecl *VDXFilterRunProc )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef long (__cdecl *VDXFilterParamProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef int (__cdecl *VDXFilterConfigProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, VDXHWND hWnd);
+typedef void (__cdecl *VDXFilterStringProc )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf);
+typedef int (__cdecl *VDXFilterStartProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef int (__cdecl *VDXFilterEndProc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff);
+typedef bool (__cdecl *VDXFilterScriptStrProc)(VDXFilterActivation *fa, const VDXFilterFunctions *, char *, int);
+typedef void (__cdecl *VDXFilterStringProc2 )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxlen);
+typedef int (__cdecl *VDXFilterSerialize )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, char *buf, int maxbuf);
+typedef void (__cdecl *VDXFilterDeserialize )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, const char *buf, int maxbuf);
+typedef void (__cdecl *VDXFilterCopy )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst);
+typedef sint64 (__cdecl *VDXFilterPrefetch )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame);
+typedef void (__cdecl *VDXFilterCopy2Proc )(VDXFilterActivation *fa, const VDXFilterFunctions *ff, void *dst, VDXFilterActivation *fa2, const VDXFilterFunctions *ff2);
+typedef bool (__cdecl *VDXFilterPrefetch2Proc)(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, sint64 frame, IVDXVideoPrefetcher *prefetcher);
+typedef bool (__cdecl *VDXFilterEventProc )(const VDXFilterActivation *fa, const VDXFilterFunctions *ff, uint32 event, const void *eventData);
+
+typedef int (__cdecl *VDXFilterModuleInitProc)(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat);
+typedef void (__cdecl *VDXFilterModuleDeinitProc)(VDXFilterModule *fm, const VDXFilterFunctions *ff);
+
+//////////
+
+typedef void (__cdecl *VDXFilterPreviewButtonCallback)(bool fNewState, void *pData);
+typedef void (__cdecl *VDXFilterPreviewSampleCallback)(VDXFBitmap *, long lFrame, long lCount, void *pData);
+
+class IVDXFilterPreview {
+public:
+ virtual void SetButtonCallback(VDXFilterPreviewButtonCallback, void *)=0;
+ virtual void SetSampleCallback(VDXFilterPreviewSampleCallback, void *)=0;
+
+ virtual bool isPreviewEnabled()=0;
+ virtual void Toggle(VDXHWND)=0;
+ virtual void Display(VDXHWND, bool)=0;
+ virtual void RedoFrame()=0;
+ virtual void RedoSystem()=0;
+ virtual void UndoSystem()=0;
+ virtual void InitButton(VDXHWND)=0;
+ virtual void Close()=0;
+ virtual bool SampleCurrentFrame()=0;
+ virtual long SampleFrames()=0;
+};
+
+class IVDXFilterPreview2 : public IVDXFilterPreview {
+public:
+ virtual bool IsPreviewDisplayed() = 0;
+};
+
+class IVDXVideoPrefetcher : public IVDXUnknown {
+public:
+ enum { kIID = VDXMAKEFOURCC('X', 'v', 'p', 'f') };
+
+ /// Request a video frame fetch from an upstream source.
+ virtual void VDXAPIENTRY PrefetchFrame(sint32 srcIndex, sint64 frame, uint64 cookie) = 0;
+
+ /// Request a video frame fetch from an upstream source in direct mode.
+ /// This specifies that the output frame is the same as the input frame.
+ /// There cannot be more than one direct fetch and there must be no standard
+ /// fetches at the same time. There can, however, be symbolic fetches.
+ virtual void VDXAPIENTRY PrefetchFrameDirect(sint32 srcIndex, sint64 frame) = 0;
+
+ /// Request a symbolic fetch from a source. This does not actually fetch
+ /// any frames, but marks an association from source to output. This is
+ /// useful for indicating the approximate center of where an output derives
+ /// in a source, even if those frames aren't fetched (perhaps due to caching).
+ /// There may be either zero or one symbolic fetch per source.
+ ///
+ /// If no symbolic fetches are performed, the symbolic frame is assumed to
+ /// be the rounded mean of the fetched source frames.
+ virtual void VDXAPIENTRY PrefetchFrameSymbolic(sint32 srcIndex, sint64 frame) = 0;
+};
+
+//////////
+
+enum {
+ // This is the highest API version supported by this header file.
+ VIRTUALDUB_FILTERDEF_VERSION = 14,
+
+ // This is the absolute lowest API version supported by this header file.
+ // Note that V4 is rather old, corresponding to VirtualDub 1.2.
+ // Chances are you will need to declare a higher version.
+ VIRTUALDUB_FILTERDEF_COMPATIBLE = 4,
+
+ // API V9 is a slightly saner baseline, since it is the first API
+ // version that has copy constructor support. You may still need to
+ // declare a higher vdfd_compat version in your module init if you
+ // need features beyond V9 (VirtualDub 1.4.12).
+ VIRTUALDUB_FILTERDEF_COMPATIBLE_COPYCTOR = 9
+
+};
+
+// v3: added lCurrentSourceFrame to FrameStateInfo
+// v4 (1.2): lots of additions (VirtualDub 1.2)
+// v5 (1.3d): lots of bugfixes - stretchblt bilinear, and non-zero startproc
+// v6 (1.4): added error handling functions
+// v7 (1.4d): added frame lag, exception handling
+// v8 (1.4.11): added string2 proc
+// v9 (1.4.12): added (working) copy constructor
+// v10 (1.5.10): added preview flag
+// v11 (1.7.0): guaranteed src structure setup before configProc; added IVDFilterPreview2
+// v12 (1.8.0): support for frame alteration
+// v13 (1.8.2): added mOutputFrame field to VDXFilterStateInfo
+// v14 (1.9.1): added copyProc2, prefetchProc2, input/output frame arrays
+
+struct VDXFilterDefinition {
+ void *_next; // deprecated - set to NULL
+ void *_prev; // deprecated - set to NULL
+ void *_module; // deprecated - set to NULL
+
+ const char * name;
+ const char * desc;
+ const char * maker;
+ void * private_data;
+ int inst_data_size;
+
+ VDXFilterInitProc initProc;
+ VDXFilterDeinitProc deinitProc;
+ VDXFilterRunProc runProc;
+ VDXFilterParamProc paramProc;
+ VDXFilterConfigProc configProc;
+ VDXFilterStringProc stringProc;
+ VDXFilterStartProc startProc;
+ VDXFilterEndProc endProc;
+
+ VDXScriptObject *script_obj;
+
+ VDXFilterScriptStrProc fssProc;
+
+ // NEW - 1.4.11
+ VDXFilterStringProc2 stringProc2;
+ VDXFilterSerialize serializeProc;
+ VDXFilterDeserialize deserializeProc;
+ VDXFilterCopy copyProc;
+
+ VDXFilterPrefetch prefetchProc; // (V12/V1.7.4+)
+
+ // NEW - V14 / 1.9.1
+ VDXFilterCopy2Proc copyProc2;
+ VDXFilterPrefetch2Proc prefetchProc2;
+ VDXFilterEventProc eventProc;
+};
+
+//////////
+
+// FilterStateInfo: contains dynamic info about file being processed
+
+class VDXFilterStateInfo {
+public:
+ sint32 lCurrentFrame; // current sequence frame (previously called output frame)
+ sint32 lMicrosecsPerFrame; // microseconds per sequence frame
+ sint32 lCurrentSourceFrame; // current source frame
+ sint32 lMicrosecsPerSrcFrame; // microseconds per source frame
+ sint32 lSourceFrameMS; // source frame timestamp
+ sint32 lDestFrameMS; // output frame timestamp
+
+ enum {
+ kStateNone = 0x00000000,
+ kStatePreview = 0x00000001, // (V1.5.10+) Job output is not being saved to disk.
+ kStateRealTime = 0x00000002, // (V1.5.10+) Operation is running in real-time (capture, playback).
+ kStateMax = 0xFFFFFFFF
+ };
+
+ uint32 flags; // (V10 / 1.5.10+ only)
+
+ sint32 mOutputFrame; // (V13/V1.8.2+) current output frame
+};
+
+// VDXFBitmap: VBitmap extended to hold filter-specific information
+
+class VDXBitmap {
+public:
+ void * _vtable; // Reserved - do not use.
+ uint32 * data; // Pointer to start of _bottom-most_ scanline of plane 0.
+ uint32 * palette; // Pointer to palette (reserved - set to NULL).
+ sint32 depth; // Bit depth, in bits. Set to zero if mpPixmap/mpPixmapLayout are active.
+ sint32 w; // Width of bitmap, in pixels.
+ sint32 h; // Height of bitmap, in pixels.
+ ptrdiff_t pitch; // Distance, in bytes, from the start of one scanline in plane 0 to the next.
+ ptrdiff_t modulo; // Distance, in bytes, from the end of one scanline in plane 0 to the start of the next.
+ ptrdiff_t size; // Size of plane 0, including padding.
+ ptrdiff_t offset; // Offset from beginning of buffer to beginning of plane 0.
+
+ uint32 *Address32(int x, int y) const {
+ return Address32i(x, h-y-1);
+ }
+
+ uint32 *Address32i(int x, int y) const {
+ return (uint32 *)((char *)data + y*pitch + x*4);
+ }
+
+ void AlignTo4() {
+ pitch = w << 2;
+ }
+
+ void AlignTo8() {
+ pitch = ((w+1)&~1) << 2;
+ }
+};
+
+class VDXFBitmap : public VDXBitmap {
+public:
+ enum {
+ /// Set in paramProc if the filter requires a Win32 GDI display context
+ /// for a bitmap. (Deprecated as of API V12 - do not use)
+ NEEDS_HDC = 0x00000001L,
+ };
+
+ uint32 dwFlags;
+ VDXHDC hdc;
+
+ uint32 mFrameRateHi; // Frame rate numerator (V1.7.4+)
+ uint32 mFrameRateLo; // Frame rate denominator (V1.7.4+)
+ sint64 mFrameCount; // Frame count; -1 if unlimited or indeterminate (V1.7.4+)
+
+ VDXPixmapLayout *mpPixmapLayout;
+ const VDXPixmap *mpPixmap;
+
+ uint32 mAspectRatioHi; ///< Pixel aspect ratio fraction (numerator). 0/0 = unknown
+ uint32 mAspectRatioLo; ///< Pixel aspect ratio fraction (denominator).
+
+ sint64 mFrameNumber; ///< Current frame number (zero based).
+ sint64 mFrameTimestampStart; ///< Starting timestamp of frame, in 100ns units.
+ sint64 mFrameTimestampEnd; ///< Ending timestamp of frame, in 100ns units.
+ sint64 mCookie; ///< Cookie supplied when frame was requested.
+};
+
+// VDXFilterActivation: This is what is actually passed to filters at runtime.
+
+class VDXFilterActivation {
+public:
+ const VDXFilterDefinition *filter; //
+ void *filter_data;
+ VDXFBitmap& dst;
+ VDXFBitmap& src;
+ VDXFBitmap *_reserved0;
+ VDXFBitmap *const last;
+ uint32 x1;
+ uint32 y1;
+ uint32 x2;
+ uint32 y2;
+
+ VDXFilterStateInfo *pfsi;
+ IVDXFilterPreview *ifp;
+ IVDXFilterPreview2 *ifp2; // (V11+)
+
+ uint32 mSourceFrameCount; // (V14+)
+ VDXFBitmap *const *mpSourceFrames; // (V14+)
+ VDXFBitmap *const *mpOutputFrames; // (V14+)
+};
+
+// These flags must match those in cpuaccel.h!
+
+#ifndef f_VIRTUALDUB_CPUACCEL_H
+#define CPUF_SUPPORTS_CPUID (0x00000001L)
+#define CPUF_SUPPORTS_FPU (0x00000002L)
+#define CPUF_SUPPORTS_MMX (0x00000004L)
+#define CPUF_SUPPORTS_INTEGER_SSE (0x00000008L)
+#define CPUF_SUPPORTS_SSE (0x00000010L)
+#define CPUF_SUPPORTS_SSE2 (0x00000020L)
+#define CPUF_SUPPORTS_3DNOW (0x00000040L)
+#define CPUF_SUPPORTS_3DNOW_EXT (0x00000080L)
+#endif
+
+struct VDXFilterFunctions {
+ VDXFilterDefinition *(__cdecl *addFilter)(VDXFilterModule *, VDXFilterDefinition *, int fd_len);
+ void (__cdecl *removeFilter)(VDXFilterDefinition *);
+ bool (__cdecl *isFPUEnabled)();
+ bool (__cdecl *isMMXEnabled)();
+ void (__cdecl *InitVTables)(VDXFilterVTbls *);
+
+ // These functions permit you to throw MyError exceptions from a filter.
+ // YOU MUST ONLY CALL THESE IN runProc, initProc, and startProc.
+
+ void (__cdecl *ExceptOutOfMemory)(); // ADDED: V6 (VirtualDub 1.4)
+ void (__cdecl *Except)(const char *format, ...); // ADDED: V6 (VirtualDub 1.4)
+
+ // These functions are callable at any time.
+
+ long (__cdecl *getCPUFlags)(); // ADDED: V6 (VirtualDub 1.4)
+ long (__cdecl *getHostVersionInfo)(char *buffer, int len); // ADDED: V7 (VirtualDub 1.4d)
+};
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////////
+
+class VDXScriptValue;
+class VDXScriptError;
+struct VDXScriptObject;
+
+class VDXScriptError {
+public:
+ enum {
+ PARSE_ERROR=1,
+ SEMICOLON_EXPECTED,
+ IDENTIFIER_EXPECTED,
+
+ TYPE_INT_REQUIRED,
+ TYPE_ARRAY_REQUIRED,
+ TYPE_FUNCTION_REQUIRED,
+ TYPE_OBJECT_REQUIRED,
+
+ OBJECT_MEMBER_NAME_REQUIRED,
+ FUNCCALLEND_EXPECTED,
+ TOO_MANY_PARAMS,
+ DIVIDE_BY_ZERO,
+ VAR_NOT_FOUND,
+ MEMBER_NOT_FOUND,
+ OVERLOADED_FUNCTION_NOT_FOUND,
+ IDENT_TOO_LONG,
+ OPERATOR_EXPECTED,
+ CLOSEPARENS_EXPECTED,
+ CLOSEBRACKET_EXPECTED,
+
+ VAR_UNDEFINED,
+
+ OUT_OF_STRING_SPACE,
+ OUT_OF_MEMORY,
+ INTERNAL_ERROR,
+ EXTERNAL_ERROR,
+
+ FCALL_OUT_OF_RANGE,
+ FCALL_INVALID_PTYPE,
+ FCALL_UNKNOWN_STR,
+
+ ARRAY_INDEX_OUT_OF_BOUNDS,
+
+ NUMERIC_OVERFLOW,
+ STRING_NOT_AN_INTEGER_VALUE,
+ STRING_NOT_A_REAL_VALUE,
+
+ ASSERTION_FAILED,
+ AMBIGUOUS_CALL,
+ CANNOT_CAST
+ };
+};
+
+class IVDXScriptInterpreter {
+public:
+ virtual void _placeholder1() {}
+ virtual void _placeholder2(void *, void *) {}
+ virtual void _placeholder3(char *s) {}
+
+ virtual void ScriptError(int e)=0;
+ virtual void _placeholder4(VDXScriptError& cse) {}
+ virtual char** AllocTempString(long l)=0;
+
+ virtual void _placeholder5() {}
+};
+
+#define EXT_SCRIPT_ERROR(x) (isi->ScriptError((VDXScriptError::x)))
+
+typedef VDXScriptValue (*VDXScriptFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
+typedef void (*VDXScriptVoidFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
+typedef int (*VDXScriptIntFunctionPtr)(IVDXScriptInterpreter *, void *, const VDXScriptValue *, int);
+
+struct VDXScriptFunctionDef {
+ VDXScriptFunctionPtr func_ptr;
+ char *name;
+ char *arg_list;
+};
+
+struct VDXScriptObject {
+ void *_lookup; // reserved - set to NULL
+ VDXScriptFunctionDef *func_list;
+ void *_obj_list; // reserved - set to NULL
+};
+
+class VDXScriptValue {
+public:
+ enum { T_VOID, T_INT, T_PINT, T_STR, T_ARRAY, T_OBJECT, T_FNAME, T_FUNCTION, T_VARLV, T_LONG, T_DOUBLE } type;
+ VDXScriptObject *thisPtr;
+ union {
+ int i;
+ char **s;
+ sint64 l;
+ double d;
+ } u;
+
+ VDXScriptValue() { type = T_VOID; }
+ VDXScriptValue(int i) { type = T_INT; u.i = i; }
+ VDXScriptValue(sint64 l) { type = T_LONG; u.l = l; }
+ VDXScriptValue(double d) { type = T_DOUBLE; u.d = d; }
+ VDXScriptValue(char **s) { type = T_STR; u.s = s; }
+
+ bool isVoid() const { return type == T_VOID; }
+ bool isInt() const { return type == T_INT; }
+ bool isString() const { return type == T_STR; }
+ bool isLong() const { return type == T_LONG; }
+ bool isDouble() const { return type == T_DOUBLE; }
+
+ int asInt() const { return u.i; }
+ sint64 asLong() const { return u.l; }
+ double asDouble() const { return u.d; }
+ char ** asString() const { return u.s; }
+};
+
+#ifdef _MSC_VER
+ #pragma pack(pop)
+#endif
+
+#endif
diff --git a/include/vd2/plugin/vdvideoutil.h b/include/vd2/plugin/vdvideoutil.h new file mode 100644 index 000000000..8379e4f7d --- /dev/null +++ b/include/vd2/plugin/vdvideoutil.h @@ -0,0 +1,121 @@ +#ifndef f_VD2_PLUGIN_VDVIDEOUTIL_H
+#define f_VD2_PLUGIN_VDVIDEOUTIL_H
+
+template<class T>
+T *vd_ptroffset(T *p, ptrdiff_t diff) {
+ return (T *)((char *)p + diff);
+}
+
+template<class T>
+class vd_row_iter {
+public:
+ vd_row_iter() {}
+ vd_row_iter(T *p, ptrdiff_t pitch) : mp(p), mpitch(pitch) {}
+ vd_row_iter(T *p, ptrdiff_t pitch, int y) : mp(vd_ptroffset(p, pitch*y)), mpitch(pitch) {}
+
+ vd_row_iter(const VFBitmap& bm, int x = 0, int y = 0) : mp(vd_ptroffset((T*)bm.data, bm.pitch*(bm.h - 1 - y))+x), mpitch(-bm.pitch) {}
+
+ operator T*() const { return mp; }
+ T& operator[](int x) const { return mp[x]; }
+
+ void mulstep(int x) {
+ mpitch *= x;
+ }
+
+ const vd_row_iter<T>& operator+=(int y) {
+ mp = vd_ptroffset(mp, mpitch * y);
+ return *this;
+ }
+
+ const vd_row_iter<T>& operator-=(int y) {
+ mp = vd_ptroffset(mp, -(mpitch * y));
+ return *this;
+ }
+
+ const vd_row_iter<T>& operator++() {
+ mp = vd_ptroffset(mp, mpitch);
+ return *this;
+ }
+
+ const vd_row_iter<T> operator++(int) {
+ const vd_row_iter<T> temp(*this);
+ mp = vd_ptroffset(mp, mpitch);
+ return temp;
+ }
+
+ const vd_row_iter<T>& operator--() {
+ mp = vd_ptroffset(mp, -mpitch);
+ return *this;
+ }
+
+ const vd_row_iter<T> operator--(int) {
+ const vd_row_iter<T> temp(*this);
+ mp = vd_ptroffset(mp, -mpitch);
+ return temp;
+ }
+
+protected:
+ T *mp;
+ ptrdiff_t mpitch;
+};
+
+typedef vd_row_iter<uint32> vd_pixrow_iter;
+
+inline uint32 vd_pixavg_down(uint32 x, uint32 y) {
+ return (x&y) + (((x^y)&0xfefefefe)>>1);
+}
+
+inline uint32 vd_pixavg_up(uint32 x, uint32 y) {
+ return (x|y) - (((x^y)&0xfefefefe)>>1);
+}
+
+inline void vd_pixunpack(uint32 px, int& r, int& g, int& b) {
+ r = (px>>16)&255;
+ g = (px>> 8)&255;
+ b = (px )&255;
+}
+
+inline uint32 vd_pixpack(int r, int g, int b) {
+ if ((unsigned)r >= 256) r = ~(r>>31) & 255;
+ if ((unsigned)g >= 256) g = ~(g>>31) & 255;
+ if ((unsigned)b >= 256) b = ~(b>>31) & 255;
+
+ return (r<<16) + (g<<8) + b;
+}
+
+inline uint32 vd_pixpackfast(int r, int g, int b) {
+ return (r<<16) + (g<<8) + b;
+}
+
+struct vd_transform_pixmap_helper {
+ vd_transform_pixmap_helper(const VFBitmap& dst)
+ : p((uint32 *)dst.data)
+ , pitch(dst.pitch)
+ , w(dst.w)
+ , h(dst.h) {}
+
+ operator bool() const { return false; }
+
+ uint32 *p;
+ const ptrdiff_t pitch;
+ const int w, h;
+};
+
+#define vd_transform_pixmap_blt(dst, src) \
+ if(vd_transform_pixmap_helper dstinfo = dst);else \
+ if(vd_transform_pixmap_helper srcinfo = src);else \
+ for(int y = 0, h = dstinfo.h, w = dstinfo.w; y < h; ++y, dstinfo.p=vd_ptroffset(dstinfo.p, dstinfo.pitch), srcinfo.p=vd_ptroffset(srcinfo.p, srcinfo.pitch)) \
+ for(int x = 0; x < dstinfo.w; ++x) \
+ switch(unsigned& out = dstinfo.p[x]) case 0: default: \
+ switch(const unsigned& in = srcinfo.p[x]) case 0: default:
+
+#define vd_transform_pixmap_inplace(dst) \
+ if(vd_transform_pixmap_helper dstinfo = dst);else \
+ for(int y = 0, h = dstinfo.h, w = dstinfo.w; y < h; ++y, dstinfo.p=vd_ptroffset(dstinfo.p, dstinfo.pitch)) \
+ for(int x = 0; x < dstinfo.w; ++x) \
+ switch(unsigned& px = dstinfo.p[x]) case 0: default: \
+
+#define vd_maketable256_16(x) formula((x+0)),formula((x+1)),formula((x+2)),formula((x+3)),formula((x+4)),formula((x+5)),formula((x+6)),formula((x+7)),formula((x+8)),formula((x+9)),formula((x+10)),formula((x+11)),formula((x+12)),formula((x+13)),formula((x+14)),formula((x+15))
+#define vd_maketable256 vd_maketable256_16(0x00),vd_maketable256_16(0x10),vd_maketable256_16(0x20),vd_maketable256_16(0x30),vd_maketable256_16(0x40),vd_maketable256_16(0x50),vd_maketable256_16(0x60),vd_maketable256_16(0x70),vd_maketable256_16(0x80),vd_maketable256_16(0x90),vd_maketable256_16(0xA0),vd_maketable256_16(0xB0),vd_maketable256_16(0xC0),vd_maketable256_16(0xD0),vd_maketable256_16(0xE0),vd_maketable256_16(0xF0),
+
+#endif
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp index 4544e16da..07862fc0f 100644 --- a/src/DSUtil/DSMPropertyBag.cpp +++ b/src/DSUtil/DSMPropertyBag.cpp @@ -237,7 +237,7 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag) {
if(tag)
{
- for(int i = m_resources.GetCount() - 1; i >= 0; i--)
+ for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
if(m_resources[i].tag == tag)
m_resources.RemoveAt(i);
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp index 4ef3254b7..772fac0cb 100644 --- a/src/DSUtil/DSUtil.cpp +++ b/src/DSUtil/DSUtil.cpp @@ -49,7 +49,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap) if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS))
{
- for(int i = 0; i < cnt; i++)
+ for(ptrdiff_t i = 0; i < cnt; i++)
{
AM_MEDIA_TYPE* pmt = NULL;
@@ -590,7 +590,7 @@ void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types) {
bool fFound = false;
- for(int i = 0; !fFound && i < (int)types.GetCount(); i += 2)
+ for(ptrdiff_t i = 0; !fFound && i < (int)types.GetCount(); i += 2)
{
if(types[i] == pmt->majortype && types[i+1] == pmt->subtype)
fFound = true;
@@ -745,7 +745,7 @@ void CStringToBin(CString str, CAtlArray<BYTE>& data) BYTE b = 0;
str.MakeUpper();
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
{
TCHAR c = str[i];
if(c >= '0' && c <= '9')
@@ -840,7 +840,7 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files) CDROM_TOC TOC;
if(DeviceIoControl(hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &TOC, sizeof(TOC), &BytesReturned, 0))
{
- for(int i = TOC.FirstTrack; i <= TOC.LastTrack; i++)
+ for(ptrdiff_t i = TOC.FirstTrack; i <= TOC.LastTrack; i++)
{
// MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
TOC.TrackData[i-1].Control &= 5;
@@ -908,11 +908,11 @@ bool GetKeyFrames(CString fn, CUIntArray& kfs) if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES)
{
kfs.SetSize(si.dwLength);
- for(int kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
+ for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
}
else
{
- for(int kf = 0; ; kf++)
+ for(ptrdiff_t kf = 0; ; kf++)
{
kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
if(kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) break;
@@ -2037,7 +2037,7 @@ CString ISO6391ToLanguage(LPCSTR code) strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
if(!strcmp(s_isolangs[i].iso6391, tmp))
{
CString ret = CString(CStringA(s_isolangs[i].name));
@@ -2054,7 +2054,7 @@ CString ISO6392ToLanguage(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6392, tmp))
{
@@ -2073,7 +2073,7 @@ LCID ISO6391ToLcid(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6391, code))
{
@@ -2089,7 +2089,7 @@ LCID ISO6392ToLcid(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
if(!strcmp(s_isolangs[i].iso6392, tmp))
{
@@ -2105,7 +2105,7 @@ CString ISO6391To6392(LPCSTR code) strncpy_s(tmp, code, 2);
tmp[2] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
if(!strcmp(s_isolangs[i].iso6391, tmp))
return CString(CStringA(s_isolangs[i].iso6392));
return _T("");
@@ -2117,7 +2117,7 @@ CString ISO6392To6391(LPCSTR code) strncpy_s(tmp, code, 3);
tmp[3] = 0;
_strlwr_s(tmp);
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
if(!strcmp(s_isolangs[i].iso6392, tmp))
return CString(CStringA(s_isolangs[i].iso6391));
return _T("");
@@ -2127,7 +2127,7 @@ CString LanguageToISO6392(LPCTSTR lang) {
CString str = lang;
str.MakeLower();
- for(int i = 0, j = countof(s_isolangs); i < j; i++)
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
{
CAtlList<CString> sl;
Explode(CString(s_isolangs[i].name), sl, ';');
@@ -2284,7 +2284,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi CString subtype = CStringFromGUID(subtype2);
POSITION pos = chkbytes.GetHeadPosition();
- for(int i = 0; pos; i++)
+ for(ptrdiff_t i = 0; pos; i++)
{
CString idx;
idx.Format(_T("%d"), i);
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp index 2ac1183a0..35dfea8be 100644 --- a/src/DSUtil/HdmvClipInfo.cpp +++ b/src/DSUtil/HdmvClipInfo.cpp @@ -66,7 +66,7 @@ BYTE CHdmvClipInfo::ReadByte() return bVal;
}
-void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, int nLen)
+void CHdmvClipInfo::ReadBuffer(BYTE* pBuff, DWORD nLen)
{
DWORD dwRead;
ReadFile (m_hFile, pBuff, nLen, &dwRead, NULL);
@@ -85,14 +85,14 @@ HRESULT CHdmvClipInfo::ReadProgramInfo() ReadByte(); //reserved_for_word_align
number_of_program_sequences = (BYTE)ReadByte();
int iStream = 0;
- for (int i=0; i<number_of_program_sequences; i++)
+ for (size_t i=0; i<number_of_program_sequences; i++)
{
ReadDword(); //SPN_program_sequence_start
ReadShort(); //program_map_PID
number_of_streams_in_ps = (BYTE)ReadByte(); //number_of_streams_in_ps
ReadByte(); //reserved_for_future_use
- for (int stream_index=0; stream_index<number_of_streams_in_ps; stream_index++)
+ for (size_t stream_index=0; stream_index<number_of_streams_in_ps; stream_index++)
{
m_Streams.SetCount(iStream + 1);
m_Streams[iStream].m_PID = ReadShort(); // stream_PID
@@ -199,8 +199,8 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile) CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
{
- int nStreams = int(m_Streams.GetCount());
- for (int i=0; i<nStreams; i++)
+ size_t nStreams = m_Streams.GetCount();
+ for (size_t i=0; i<nStreams; i++)
{
if (m_Streams[i].m_PID == wPID)
return &m_Streams[i];
@@ -289,7 +289,7 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD dwPos += 10;
rtDuration = 0;
- for (int i=0; i<nPlaylistItems; i++)
+ for (size_t i=0; i<nPlaylistItems; i++)
{
PlaylistItem Item;
SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h index 0f129035b..fe1030af0 100644 --- a/src/DSUtil/HdmvClipInfo.h +++ b/src/DSUtil/HdmvClipInfo.h @@ -117,7 +117,7 @@ public: REFERENCE_TIME m_rtIn;
REFERENCE_TIME m_rtOut;
- REFERENCE_TIME Duration() const
+ REFERENCE_TIME Duration()
{
return m_rtOut - m_rtIn;
}
@@ -133,9 +133,9 @@ public: HRESULT ReadInfo(LPCTSTR strFile);
Stream* FindStream(SHORT wPID);
- bool IsHdmv() const { return m_bIsHdmv; };
- int GetStreamNumber() { return int(m_Streams.GetCount()); };
- Stream* GetStreamByIndex(int nIndex){ return (unsigned(nIndex) < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
+ bool IsHdmv() { return m_bIsHdmv; };
+ size_t GetStreamNumber() { return m_Streams.GetCount(); };
+ Stream* GetStreamByIndex(size_t nIndex){ return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL; };
HRESULT FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile, CAtlList<PlaylistItem>& MainPlaylist);
HRESULT ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtDuration, CAtlList<PlaylistItem>& Playlist);
@@ -153,7 +153,7 @@ private : DWORD ReadDword();
SHORT ReadShort();
BYTE ReadByte();
- void ReadBuffer(BYTE* pBuff, int nLen);
+ void ReadBuffer(BYTE* pBuff, DWORD nLen);
HRESULT ReadProgramInfo();
HRESULT CloseFile(HRESULT hr);
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp index 9b3607379..027808a3a 100644 --- a/src/DSUtil/MediaTypeEx.cpp +++ b/src/DSUtil/MediaTypeEx.cpp @@ -215,7 +215,7 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression {
BYTE* b = (BYTE*)&biCompression;
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
if(b[i] >= 'a' && b[i] <= 'z')
b[i] = toupper(b[i]);
@@ -618,25 +618,25 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl) {
sl.AddTail(_T("pbFormat:"));
- for(int i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
+ for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
{
str.Format(_T("%04x:"), i);
- for(int k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
{
CString byte;
byte.Format(_T("%c%02x"), fmtsize > 0 && fmtsize == k ? '|' : ' ', pbFormat[k]);
str += byte;
}
- for(int k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
+ for(ptrdiff_t k = min(i + 16, (int)cbFormat), l = i + 16; k < l; k++)
{
str += _T(" ");
}
str += ' ';
- for(int k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
+ for(ptrdiff_t k = i, l = min(i + 16, (int)cbFormat); k < l; k++)
{
unsigned char c = (unsigned char)pbFormat[k];
CStringA ch;
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp index b7ccd18a1..47a45c607 100644 --- a/src/DSUtil/MediaTypes.cpp +++ b/src/DSUtil/MediaTypes.cpp @@ -348,7 +348,7 @@ void CorrectMediaType(AM_MEDIA_TYPE* pmt) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for(int i = 0; i < VIHSIZE; i++)
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
{
if(mt.subtype == *vihs[i].subtype
&& vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
@@ -364,7 +364,7 @@ void CorrectMediaType(AM_MEDIA_TYPE* pmt) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for(int i = 0; i < VIHSIZE; i++)
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++)
{
if(mt.subtype == *vih2s[i].subtype
&& vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
diff --git a/src/DSUtil/cpuid64.asm b/src/DSUtil/cpuid64.asm new file mode 100644 index 000000000..4c3d4c35b --- /dev/null +++ b/src/DSUtil/cpuid64.asm @@ -0,0 +1,35 @@ +; ml64 /c /Cx /nologo /Fo"$(OutDir)\$(InputName).obj" "$(InputPath)"
+; call cpuid with args in eax, ecx
+; store eax, ebx, ecx, edx to p
+
+ _TEXT64 segment page 'CODE'
+
+ align 8
+
+ PUBLIC cpuid64
+
+ cpuid64 PROC FRAME
+ ; void cpuid64(CPUID_ARGS* p);
+ ; rcx <= p
+ sub rsp, 32
+ .allocstack 32
+ push rbx
+ .pushreg rbx
+ .endprolog
+ mov r8, rcx
+ mov eax, DWORD PTR [r8+0]
+ mov ecx, DWORD PTR [r8+8]
+ cpuid
+ mov DWORD PTR [r8+0], eax
+ mov DWORD PTR [r8+4], ebx
+ mov DWORD PTR [r8+8], ecx
+ mov DWORD PTR [r8+12], edx
+ pop rbx
+ add rsp, 32
+ ret
+
+ ALIGN 8
+ cpuid64 ENDP
+_TEXT64 ENDS
+
+END
\ No newline at end of file diff --git a/src/DSUtil/cpuid_32_64.cpp b/src/DSUtil/cpuid_32_64.cpp new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/DSUtil/cpuid_32_64.cpp diff --git a/src/DSUtil/cpuid_32_64.h b/src/DSUtil/cpuid_32_64.h new file mode 100644 index 000000000..29990b681 --- /dev/null +++ b/src/DSUtil/cpuid_32_64.h @@ -0,0 +1,15 @@ +#pragma once
+
+typedef struct cpuid_args_s {
+DWORD eax;
+DWORD ebx;
+DWORD ecx;
+DWORD edx;
+} CPUID_ARGS;
+
+extern "C" {
+#ifdef _WIN64 // For 64-bit apps
+ void cpuid64(CPUID_ARGS* p);
+#define _CPUID cpuid64
+#endif
+}
\ No newline at end of file diff --git a/src/DSUtil/dsutil.vcproj b/src/DSUtil/dsutil.vcproj index ba520b044..c8680014f 100644 --- a/src/DSUtil/dsutil.vcproj +++ b/src/DSUtil/dsutil.vcproj @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="windows-1250"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="DSUtil"
ProjectGUID="{FC70988B-1AE5-4381-866D-4F405E28AC42}"
RootNamespace="dsutil"
@@ -404,6 +404,50 @@ </FileConfiguration>
</File>
<File
+ RelativePath=".\cpuid64.asm"
+ >
+ <FileConfiguration
+ Name="Debug Unicode|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug Unicode|x64"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="cpuid64.asm"
+ CommandLine="ml64 /c /Cx /nologo /Fo"$(OutDir)\$(InputName).obj" "$(InputPath)""
+ Outputs="$(OutDir)\$(InputName).obj"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release Unicode|x64"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="cpuid64.asm"
+ CommandLine="ml64 /c /Cx /nologo /Fo"$(OutDir)\$(InputName).obj" "$(InputPath)""
+ Outputs="$(OutDir)\$(InputName).obj"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\cpuid_32_64.cpp"
+ >
+ </File>
+ <File
RelativePath=".\DSMPropertyBag.cpp"
>
</File>
@@ -509,6 +553,10 @@ Filter="h;hpp;hxx;hm;inl;inc"
>
<File
+ RelativePath=".\cpuid_32_64.h"
+ >
+ </File>
+ <File
RelativePath=".\DSMPropertyBag.h"
>
</File>
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp index 382ee5301..99d61f702 100644 --- a/src/DSUtil/text.cpp +++ b/src/DSUtil/text.cpp @@ -11,7 +11,7 @@ CString Explode(CString str, CAtlList<CString>& sl, TCHAR sep, int limit) if(!str.IsEmpty() && str[str.GetLength()-1] != sep)
str += sep;
- for(int i = 0, j = 0; (j = str.Find(sep, i)) >= 0; i = j+1)
+ for(ptrdiff_t i = 0, j = 0; (j = str.Find(sep, i)) >= 0; i = j+1)
{
CString tmp = str.Mid(i, j-i);
tmp.TrimLeft(sep); tmp.TrimRight(sep);
@@ -108,7 +108,7 @@ CStringA UrlEncode(CStringA str, bool fRaw) {
CStringA urlstr;
- for(int i = 0; i < str.GetLength(); i++)
+ for(size_t i = 0; i < str.GetLength(); i++)
{
CHAR c = str[i];
if(fRaw && c == '+') urlstr += "%2B";
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h index 14cd1149a..caef07a1a 100644 --- a/src/DSUtil/text.h +++ b/src/DSUtil/text.h @@ -7,11 +7,11 @@ // extern CString Implode(CAtlList<CString>& sl, TCHAR sep);
template<class T, typename SEP>
-T Explode(T str, CAtlList<T>& sl, SEP sep, int limit = 0)
+T Explode(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
sl.RemoveAll();
- for(int i = 0, j = 0; ; i = j+1)
+ for(ptrdiff_t i = 0, j = 0; ; i = j+1)
{
j = str.Find(sep, i);
@@ -30,7 +30,7 @@ T Explode(T str, CAtlList<T>& sl, SEP sep, int limit = 0) }
template<class T, typename SEP>
-T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, int limit = 0)
+T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
Explode(str, sl, sep, limit);
POSITION pos = sl.GetHeadPosition();
diff --git a/src/DSUtil/vd.cpp b/src/DSUtil/vd.cpp index 410308a74..0b06b043b 100644 --- a/src/DSUtil/vd.cpp +++ b/src/DSUtil/vd.cpp @@ -24,6 +24,7 @@ #include "stdafx.h"
#include "vd.h"
+#include "cpuid_32_64.h"
#pragma warning(disable : 4799) // no emms... blahblahblah
@@ -34,7 +35,27 @@ CCpuID g_cpuid; CCpuID::CCpuID()
{
// TODOX64 : ??
- m_flags = (flag_t)7;
+ CPUID_ARGS ca;
+ ca.eax = 1;
+ _CPUID(&ca);
+
+ int t = ca.edx;
+
+ int mflags = 0;
+ mflags |= ((t&0x00800000)!=0) ? mmx : 0; // STD MMX
+ mflags |= ((t&0x02000000)!=0) ? ssemmx+ssefpu : 0;// STD SSE
+ mflags |= ((t&0x04000000)!=0) ? sse2 : 0; // SSE2
+
+ // 3dnow
+ ca.eax = 0x80000001;
+ _CPUID(&ca);
+ t = ca.edx;
+ mflags |= ((t&0x80000000)!=0) ? _3dnow : 0; // 3D NOW
+ mflags |= ((t&0x00400000)!=0) ? ssemmx : 0; // SSE MMX
+
+ // result
+ //m_flags = (flag_t)7;
+ m_flags = (flag_t)mflags;
}
static void yuvtoyuy2row_c(BYTE* dst, BYTE* srcy, BYTE* srcu, BYTE* srcv, DWORD width)
@@ -86,7 +107,7 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int {
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
memcpy(dsty, srcy, pitch);
srcpitch >>= 1;
@@ -94,10 +115,10 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
memcpy(dstu, srcu, pitch);
- for(int y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
memcpy(dstv, srcv, pitch);
}
@@ -139,7 +160,7 @@ bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int {
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy(dst, src, pitch);
}
@@ -164,7 +185,7 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s }
else
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy(dst, src, rowbytes);
}
@@ -177,33 +198,33 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s if(dbpp == 16)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = (WORD)(((*((DWORD*)s)>>8)&0xf800)|((*((DWORD*)s)>>5)&0x07e0)|((*((DWORD*)s)>>3)&0x1f));
}
else if(sbpp == 32)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
*d = (WORD)(((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x1f));
}
}
}
else if(dbpp == 24)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s++, d+=3)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d+=3)
{ // not tested, r-g-b might be in reverse
d[0] = (*s&0x001f)<<3;
d[1] = (*s&0x07e0)<<5;
@@ -214,27 +235,27 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s {
BYTE* s = (BYTE*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s+=4, d+=3)
+ for(ptrdiff_t x = 0; x < w; x++, s+=4, d+=3)
{d[0] = s[0]; d[1] = s[1]; d[2] = s[2];}
}
}
}
else if(dbpp == 32)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
*d = ((*s&0xf800)<<8)|((*s&0x07e0)<<5)|((*s&0x001f)<<3);
}
else if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = *((DWORD*)s)&0xffffff;
}
}
@@ -292,7 +313,7 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch) BYTE* tmp = s;
{
- for(int i = pitch; i--; tmp++)
+ for(ptrdiff_t i = pitch; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -307,6 +328,76 @@ void AvgLines8(BYTE* dst, DWORD h, DWORD pitch) }
+void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
+{
+ if(h <= 1) return;
+
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
+
+ for(; s < d; s += pitch*2)
+ {
+ WORD* tmp = (WORD*)s;
+
+ for(ptrdiff_t wd=(pitch>>3);wd--;tmp++)
+ {
+ tmp[0] =
+ ((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
+ ((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
+ {
+ tmp[pitch] =
+ ((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
+ ((((*tmp&0x03e0) + (tmp[pitch<<1]&0x03e0)) >> 1)&0x03e0)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
+
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
+}
+
+void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
+{
+ if(h <= 1) return;
+
+ BYTE* s = dst;
+ BYTE* d = dst + (h-2)*pitch;
+
+ for(; s < d; s += pitch*2)
+ {
+ WORD* tmp = (WORD*)s;
+
+ for(ptrdiff_t wd=(pitch>>3);wd--;tmp++)
+ {
+ tmp[0] =
+ ((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
+ ((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
+ {
+ tmp[pitch] =
+ ((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
+ ((((*tmp&0x07e0) + (tmp[pitch<<1]&0x07e0)) >> 1)&0x07e0)|
+ ((((*tmp&0x001f) + (tmp[pitch<<1]&0x001f)) >> 1)&0x001f);
+ }
+ }
+
+ if(!(h&1) && h >= 2)
+ {
+ dst += (h-2)*pitch;
+ memcpy(dst + pitch, dst, pitch);
+ }
+}
+
#else // _WIN64
CCpuID::CCpuID()
@@ -495,7 +586,7 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int {
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, srcy += srcpitch, dsty += dstpitch)
memcpy_accel(dsty, srcy, pitch);
srcpitch >>= 1;
@@ -503,10 +594,10 @@ bool BitBltFromI420ToI420(int w, int h, BYTE* dsty, BYTE* dstu, BYTE* dstv, int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcu += srcpitch, dstu += dstpitch)
memcpy_accel(dstu, srcu, pitch);
- for(int y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y+=2, srcv += srcpitch, dstv += dstpitch)
memcpy_accel(dstv, srcv, pitch);
}
@@ -523,7 +614,7 @@ bool BitBltFromYUY2ToYUY2(int w, int h, BYTE* dst, int dstpitch, BYTE* src, int {
int pitch = min(abs(srcpitch), abs(dstpitch));
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy_accel(dst, src, pitch);
}
@@ -545,7 +636,7 @@ bool BitBltFromI420ToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* if(w<=0 || h<=0 || (w&1) || (h&1))
return(false);
- void (*asm_YUVtoRGB_row)(void* ARGB1, void* ARGB2, BYTE* Y1, BYTE* Y2, BYTE* U, BYTE* V, long width) = NULL;
+ void (*asm_YUVtoRGB_row)(void* ARGB1, void* ARGB2, BYTE* Y1, BYTE* Y2, BYTE* U, BYTE* V, long width) = NULL;;
if((g_cpuid.m_flags & CCpuID::ssefpu) && !(w&7))
{
@@ -1070,7 +1161,7 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s }
else
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
memcpy_accel(dst, src, rowbytes);
}
@@ -1083,33 +1174,33 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s if(dbpp == 16)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = (WORD)(((*((DWORD*)s)>>8)&0xf800)|((*((DWORD*)s)>>5)&0x07e0)|((*((DWORD*)s)>>3)&0x1f));
}
else if(sbpp == 32)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
*d = (WORD)(((*s>>8)&0xf800)|((*s>>5)&0x07e0)|((*s>>3)&0x1f));
}
}
}
else if(dbpp == 24)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s++, d+=3)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d+=3)
{ // not tested, r-g-b might be in reverse
d[0] = (*s&0x001f)<<3;
d[1] = (*s&0x07e0)<<5;
@@ -1120,27 +1211,27 @@ bool BitBltFromRGBToRGB(int w, int h, BYTE* dst, int dstpitch, int dbpp, BYTE* s {
BYTE* s = (BYTE*)src;
BYTE* d = (BYTE*)dst;
- for(int x = 0; x < w; x++, s+=4, d+=3)
+ for(ptrdiff_t x = 0; x < w; x++, s+=4, d+=3)
{d[0] = s[0]; d[1] = s[1]; d[2] = s[2];}
}
}
}
else if(dbpp == 32)
{
- for(int y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
+ for(ptrdiff_t y = 0; y < h; y++, src += srcpitch, dst += dstpitch)
{
if(sbpp == 16)
{
WORD* s = (WORD*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s++, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s++, d++)
*d = ((*s&0xf800)<<8)|((*s&0x07e0)<<5)|((*s&0x001f)<<3);
}
else if(sbpp == 24)
{
BYTE* s = (BYTE*)src;
DWORD* d = (DWORD*)dst;
- for(int x = 0; x < w; x++, s+=3, d++)
+ for(ptrdiff_t x = 0; x < w; x++, s+=3, d++)
*d = *((DWORD*)s)&0xffffff;
}
}
@@ -1521,7 +1612,7 @@ AvgLines8_sse2_loop: mov tmp, esi
}
- for(int i = pitch&7; i--; tmp++)
+ for(ptrdiff_t i = pitch&7; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -1568,14 +1659,14 @@ AvgLines8_mmx_loop: mov tmp, esi
}
- for(int i = pitch&7; i--; tmp++)
+ for(ptrdiff_t i = pitch&7; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
}
else
{
- for(int i = pitch; i--; tmp++)
+ for(ptrdiff_t i = pitch; i--; tmp++)
{
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
@@ -1659,7 +1750,7 @@ AvgLines555_loop: mov tmp, esi
}
- for(int i = (pitch&7)>>1; i--; tmp++)
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
{
tmp[pitch] =
((((*tmp&0x7c00) + (tmp[pitch<<1]&0x7c00)) >> 1)&0x7c00)|
@@ -1745,7 +1836,7 @@ AvgLines565_loop: mov tmp, esi
}
- for(int i = (pitch&7)>>1; i--; tmp++)
+ for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
{
tmp[pitch] =
((((*tmp&0xf800) + (tmp[pitch<<1]&0xf800)) >> 1)&0xf800)|
diff --git a/src/DSUtil/vd.h b/src/DSUtil/vd.h index 434c214ec..9c4ddcc51 100644 --- a/src/DSUtil/vd.h +++ b/src/DSUtil/vd.h @@ -38,5 +38,4 @@ extern void DeinterlaceBob(BYTE* dst, BYTE* src, DWORD rowbytes, DWORD h, DWORD extern void AvgLines8(BYTE* dst, DWORD h, DWORD pitch);
extern void AvgLines555(BYTE* dst, DWORD h, DWORD pitch);
-extern void AvgLines565(BYTE* dst, DWORD h, DWORD pitch);
-
+extern void AvgLines565(BYTE* dst, DWORD h, DWORD pitch);
\ No newline at end of file diff --git a/src/SubPic/CoordGeom.cpp b/src/SubPic/CoordGeom.cpp index 7df30f8c8..2cfc8d08d 100644 --- a/src/SubPic/CoordGeom.cpp +++ b/src/SubPic/CoordGeom.cpp @@ -205,7 +205,7 @@ Vector Vector::operator % (Vector& v) return(Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x));
}
-float& Vector::operator [] (int i)
+float& Vector::operator [] (size_t i)
{
return(!i ? x : (i == 1) ? y : z);
}
@@ -498,9 +498,9 @@ XForm::Matrix XForm::Matrix::operator * (Matrix& m) {
Matrix ret;
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
- for(int j = 0; j < 4; j++)
+ for(ptrdiff_t j = 0; j < 4; j++)
{
ret.mat[i][j] = mat[i][0] * m.mat[0][j] +
mat[i][1] * m.mat[1][j] +
diff --git a/src/SubPic/CoordGeom.h b/src/SubPic/CoordGeom.h index 4084d8b25..0649bf61c 100644 --- a/src/SubPic/CoordGeom.h +++ b/src/SubPic/CoordGeom.h @@ -62,7 +62,7 @@ public: Vector Refract2(Vector& n, float nFrom, float nTo, float* nOut = NULL);
Vector operator - ();
- float& operator [] (int i);
+ float& operator [] (size_t i);
float operator | (Vector& v); // dot
Vector operator % (Vector& v); // cross
diff --git a/src/SubPic/DX7SubPic.cpp b/src/SubPic/DX7SubPic.cpp index 400db11bf..25384abcd 100644 --- a/src/SubPic/DX7SubPic.cpp +++ b/src/SubPic/DX7SubPic.cpp @@ -163,7 +163,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
/*
- for(int i = 0; i < countof(pVertices); i++)
+ for(ptrdiff_t i = 0; i < countof(pVertices); i++)
{
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
diff --git a/src/SubPic/DX9SubPic.cpp b/src/SubPic/DX9SubPic.cpp index c1c7b18b6..79b2b0f14 100644 --- a/src/SubPic/DX9SubPic.cpp +++ b/src/SubPic/DX9SubPic.cpp @@ -255,7 +255,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {(float)dst.right, (float)dst.bottom, 0.5f, 2.0f, (float)src.right / w, (float)src.bottom / h},
};
/*
- for(int i = 0; i < countof(pVertices); i++)
+ for(ptrdiff_t i = 0; i < countof(pVertices); i++)
{
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
diff --git a/src/SubPic/ISubPic.cpp b/src/SubPic/ISubPic.cpp index 6861a1906..4633f181a 100644 --- a/src/SubPic/ISubPic.cpp +++ b/src/SubPic/ISubPic.cpp @@ -421,7 +421,7 @@ CSubPicQueue::CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator* {if(phr) *phr = E_INVALIDARG; return;}
m_fBreakBuffering = false;
- for(int i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
CAMThread::Create();
}
@@ -431,7 +431,7 @@ CSubPicQueue::~CSubPicQueue() m_fBreakBuffering = true;
SetEvent(m_ThreadEvents[EVENT_EXIT]);
CAMThread::Close();
- for(int i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
CloseHandle(m_ThreadEvents[i]);
}
@@ -1127,7 +1127,7 @@ void ISubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4]) Vector center(r.CenterPoint().x, r.CenterPoint().y, 0);
int l = (int)(Vector(r.Size().cx, r.Size().cy, 0).Length()*1.5f)+1;
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
v[i] = m_xform << (v[i] - center);
v[i].z = v[i].z / l + 0.5f;
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp index 4157460a7..23ae14449 100644 --- a/src/SubPic/MemSubPic.cpp +++ b/src/SubPic/MemSubPic.cpp @@ -141,7 +141,7 @@ STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic) BYTE* s = (BYTE*)src.bits + src.pitch*m_rcDirty.top + m_rcDirty.left*4;
BYTE* d = (BYTE*)dst.bits + dst.pitch*m_rcDirty.top + m_rcDirty.left*4;
- for(int j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
memcpy(d, s, w*4);
return S_OK;
@@ -153,13 +153,13 @@ STDMETHODIMP CMemSubPic::ClearDirtyRect(DWORD color) return S_FALSE;
BYTE* p = (BYTE*)m_spd.bits + m_spd.pitch*m_rcDirty.top + m_rcDirty.left*(m_spd.bpp>>3);
- for(int j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch)
+ for(ptrdiff_t j = 0, h = m_rcDirty.Height(); j < h; j++, p += m_spd.pitch)
{
-// memsetd(p, 0, m_rcDirty.Width());
+//
int w = m_rcDirty.Width();
#ifdef _WIN64
- ASSERT(FALSE); // TODOX64
+ memsetd(p, color, w*4); // nya
#else
__asm
{
@@ -291,6 +291,11 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect) return S_OK;
}
+#ifdef _WIN64
+// For CPUID usage
+#include "../dsutil/vd.h"
+#include <emmintrin.h>
+#endif
STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget);
@@ -341,7 +346,7 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) dst.pitch = -dst.pitch;
}
- for(int j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
{
if(dst.type == MSP_RGBA)
{
@@ -365,15 +370,24 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
+
DWORD* d2 = (DWORD*)d;
for(; s2 < s2end; s2 += 4, d2++)
{
-
+#ifdef _WIN64
+ DWORD ia = 256-s2[3];
+ if(s2[3] < 0xff)
+ {
+ *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (((*((DWORD*)s2)&0x00ff00ff)*ia)>>8)&0x00ff00ff)
+ | ((((*d2&0x0000ff00)*s2[3])>>8) + (((*((DWORD*)s2)&0x0000ff00)*ia)>>8)&0x0000ff00);
+ }
+#else
if(s2[3] < 0xff)
{
- *d2 = (((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff))&0x00ff00ff)
- | (((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00))&0x0000ff00);
+ *d2 = ((((*d2&0x00ff00ff)*s2[3])>>8) + (*((DWORD*)s2)&0x00ff00ff)&0x00ff00ff)
+ | ((((*d2&0x0000ff00)*s2[3])>>8) + (*((DWORD*)s2)&0x0000ff00)&0x0000ff00);
}
+#endif
}
}
else if(dst.type == MSP_RGB24)
@@ -403,10 +417,6 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) *d2 = (WORD)((((((*d2&0xf81f)*s2[3])>>5) + (*(DWORD*)s2&0xf81f))&0xf81f)
| (((((*d2&0x07e0)*s2[3])>>5) + (*(DWORD*)s2&0x07e0))&0x07e0));
-/* *d2 = (WORD)((((((*d2&0xf800)*s2[3])>>8) + (*(DWORD*)s2&0xf800))&0xf800)
- | (((((*d2&0x07e0)*s2[3])>>8) + (*(DWORD*)s2&0x07e0))&0x07e0)
- | (((((*d2&0x001f)*s2[3])>>8) + (*(DWORD*)s2&0x001f))&0x001f));
-*/
}
}
}
@@ -421,40 +431,61 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) {
*d2 = (WORD)((((((*d2&0x7c1f)*s2[3])>>5) + (*(DWORD*)s2&0x7c1f))&0x7c1f)
| (((((*d2&0x03e0)*s2[3])>>5) + (*(DWORD*)s2&0x03e0))&0x03e0));
-/* *d2 = (WORD)((((((*d2&0x7c00)*s2[3])>>8) + (*(DWORD*)s2&0x7c00))&0x7c00)
- | (((((*d2&0x03e0)*s2[3])>>8) + (*(DWORD*)s2&0x03e0))&0x03e0)
- | (((((*d2&0x001f)*s2[3])>>8) + (*(DWORD*)s2&0x001f))&0x001f));
-*/ }
+ }
}
}
else if(dst.type == MSP_YUY2)
- {
-// BYTE y1, y2, u, v;
+ {
unsigned int ia, c;
+#ifdef _WIN64
+ // CPUID from VDub
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+#endif
+ DWORD* d2 = (DWORD*)d;
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
- DWORD* d2 = (DWORD*)d;
+ static const __int64 _8181 = 0x0080001000800010i64;
+
for(; s2 < s2end; s2 += 8, d2++)
{
ia = (s2[3]+s2[7])>>1;
if(ia < 0xff)
{
-/* y1 = (BYTE)(((((*d2&0xff)-0x10)*s2[3])>>8) + s2[1]); // + y1;
- y2 = (BYTE)((((((*d2>>16)&0xff)-0x10)*s2[7])>>8) + s2[5]); // + y2;
- u = (BYTE)((((((*d2>>8)&0xff)-0x80)*ia)>>8) + s2[0]); // + u;
- v = (BYTE)((((((*d2>>24)&0xff)-0x80)*ia)>>8) + s2[4]); // + v;
-
- *d2 = (v<<24)|(y2<<16)|(u<<8)|y1;
-*/
- static const __int64 _8181 = 0x0080001000800010i64;
-
- ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
-
#ifdef _WIN64
- ASSERT(FALSE); // TODOX64
+ if(fSSE2)
+ {
+ ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
+ // SSE2
+ __m128i mm_zero = _mm_setzero_si128();
+ __m128i mm_8181 = _mm_move_epi64(_mm_cvtsi64_si128(_8181));
+ __m128i mm_c = _mm_cvtsi32_si128(c);
+ mm_c = _mm_unpacklo_epi8(mm_c, mm_zero);
+ __m128i mm_d = _mm_cvtsi32_si128(*d2);
+ mm_d = _mm_unpacklo_epi8(mm_d, mm_zero);
+ __m128i mm_a = _mm_cvtsi32_si128(ia);
+ mm_a = _mm_unpacklo_epi8(mm_a, mm_zero);
+ mm_a = _mm_srli_epi16(mm_a,1);
+ mm_d = _mm_sub_epi16(mm_d,mm_8181);
+ mm_d = _mm_mullo_epi16(mm_d,mm_a);
+ mm_d = _mm_srai_epi16(mm_d,7);
+ mm_d = _mm_adds_epi16(mm_d,mm_c);
+ mm_d = _mm_packus_epi16(mm_d,mm_d);
+ *d2 = (DWORD)_mm_cvtsi128_si32(mm_d);
+ }
+ else
+ {
+ // YUY2 colorspace fix. rewrited from sse2 asm
+ DWORD y1 = (DWORD)(((((*d2&0xff)-0x10)*(s2[3]>>1))>>7)+s2[1])&0xff; // y1
+ DWORD uu = (DWORD)((((((*d2>>8)&0xff)-0x80)*(ia>>1))>>7)+s2[0])&0xff; // u
+ DWORD y2 = (DWORD)((((((*d2>>16)&0xff)-0x10)*(s2[7]>>1))>>7)+s2[5])&0xff; // y2
+ DWORD vv = (DWORD)((((((*d2>>24)&0xff)-0x80)*(ia>>1))>>7)+s2[4])&0xff; // v
+ *d2 = (y1)|(uu<<8)|(y2<<16)|(vv<<24);
+ }
+
#else
+ ia = (ia<<24)|(s2[7]<<16)|(ia<<8)|s2[3];
__asm
{
mov esi, s2
@@ -539,11 +570,11 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) dst.pitchUV = -dst.pitchUV;
}
- for(int i = 0; i < 2; i++)
+ for(ptrdiff_t i = 0; i < 2; i++)
{
s = ss[i]; d = dd[i];
BYTE* is = ss[1-i];
- for(int j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2)
+ for(ptrdiff_t j = 0; j < h2; j++, s += src.pitch*2, d += dst.pitchUV, is += src.pitch*2)
{
BYTE* s2 = s;
BYTE* s2end = s2 + w*4;
@@ -562,9 +593,7 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget) }
-#ifdef _WIN64
- ASSERT(FALSE); // TODOX64
-#else
+#ifndef _WIN64
__asm emms;
#endif
diff --git a/src/filters/BaseClasses/amfilter.cpp b/src/filters/BaseClasses/amfilter.cpp index 03c13d147..e3c7fa658 100644 --- a/src/filters/BaseClasses/amfilter.cpp +++ b/src/filters/BaseClasses/amfilter.cpp @@ -314,7 +314,7 @@ STDMETHODIMP CBaseFilter::NonDelegatingQueryInterface(REFIID riid, }
}
-#ifdef DEBUG
+#ifdef _DEBUG
STDMETHODIMP_(ULONG) CBaseFilter::NonDelegatingRelease()
{
if (m_cRef == 1) {
@@ -980,7 +980,7 @@ CEnumPins::CEnumPins(__in CBaseFilter *pFilter, m_PinCache(NAME("Pin Cache"))
{
-#ifdef DEBUG
+#ifdef _DEBUG
m_dwCookie = DbgRegisterObjectCreation("CEnumPins", 0);
#endif
@@ -1015,7 +1015,7 @@ CEnumPins::~CEnumPins() {
m_pFilter->Release();
-#ifdef DEBUG
+#ifdef _DEBUG
DbgRegisterObjectDestruction(m_dwCookie);
#endif
}
@@ -1233,7 +1233,7 @@ CEnumMediaTypes::CEnumMediaTypes(__in CBasePin *pPin, m_cRef(1)
{
-#ifdef DEBUG
+#ifdef _DEBUG
m_dwCookie = DbgRegisterObjectCreation("CEnumMediaTypes", 0);
#endif
@@ -1263,7 +1263,7 @@ CEnumMediaTypes::CEnumMediaTypes(__in CBasePin *pPin, CEnumMediaTypes::~CEnumMediaTypes()
{
-#ifdef DEBUG
+#ifdef _DEBUG
DbgRegisterObjectDestruction(m_dwCookie);
#endif
m_pPin->Release();
@@ -1524,7 +1524,7 @@ CBasePin::CBasePin(__in_opt LPCTSTR pObjectName, }
}
-#ifdef DEBUG
+#ifdef _DEBUG
m_cRef = 0;
#endif
}
@@ -1577,7 +1577,7 @@ CBasePin::CBasePin(__in_opt LPCSTR pObjectName, }
-#ifdef DEBUG
+#ifdef _DEBUG
m_cRef = 0;
#endif
}
@@ -1643,7 +1643,7 @@ CBasePin::NonDelegatingRelease() /* Displays pin connection information */
-#ifdef DEBUG
+#ifdef _DEBUG
void
CBasePin::DisplayPinInfo(IPin *pReceivePin)
{
@@ -1674,7 +1674,7 @@ CBasePin::DisplayPinInfo(IPin *pReceivePin) /* Displays general information on the pin media type */
-#ifdef DEBUG
+#ifdef _DEBUG
void CBasePin::DisplayTypeInfo(IPin *pPin, const CMediaType *pmt)
{
UNREFERENCED_PARAMETER(pPin);
@@ -4005,7 +4005,7 @@ STDMETHODIMP CDynamicOutputPin::Block(DWORD dwBlockFlags, HANDLE hEvent) }
}
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4023,7 +4023,7 @@ STDMETHODIMP CDynamicOutputPin::Block(DWORD dwBlockFlags, HANDLE hEvent) hr = UnblockOutputPin();
}
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4172,7 +4172,7 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void) CAutoLock alBlockStateLock(&m_BlockStateLock);
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4198,7 +4198,7 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void) m_BlockStateLock.Lock();
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4220,7 +4220,7 @@ HRESULT CDynamicOutputPin::StartUsingOutputPin(void) m_dwNumOutstandingOutputPinUsers++;
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4231,7 +4231,7 @@ void CDynamicOutputPin::StopUsingOutputPin(void) {
CAutoLock alBlockStateLock(&m_BlockStateLock);
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
@@ -4241,7 +4241,7 @@ void CDynamicOutputPin::StopUsingOutputPin(void) BlockOutputPin();
}
- #ifdef DEBUG
+ #ifdef _DEBUG
AssertValid();
#endif // DEBUG
}
@@ -4479,7 +4479,7 @@ HRESULT CDynamicOutputPin::CompleteConnect(IPin *pReceivePin) return hr;
}
-#ifdef DEBUG
+#ifdef _DEBUG
void CDynamicOutputPin::AssertValid(void)
{
// Make sure the object was correctly initialized.
diff --git a/src/filters/BaseClasses/amfilter.h b/src/filters/BaseClasses/amfilter.h index 14f17cd42..82e0268f4 100644 --- a/src/filters/BaseClasses/amfilter.h +++ b/src/filters/BaseClasses/amfilter.h @@ -199,7 +199,7 @@ public: // override this to say what interfaces we support where
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void ** ppv);
-#ifdef DEBUG
+#ifdef _DEBUG
STDMETHODIMP_(ULONG) NonDelegatingRelease();
#endif
@@ -349,13 +349,13 @@ protected: CRefTime m_tStop; // time from NewSegment
double m_dRate; // rate from NewSegment
-#ifdef DEBUG
+#ifdef _DEBUG
LONG m_cRef; // Ref count tracing
#endif
// displays pin connection information
-#ifdef DEBUG
+#ifdef _DEBUG
void DisplayPinInfo(IPin *pReceivePin);
void DisplayTypeInfo(IPin *pPin, const CMediaType *pmt);
#else
@@ -593,7 +593,7 @@ class CEnumPins : public IEnumPins // The interface we support // so they should not be dereferenced. They are
// merely kept to ID which pins have been enumerated.
-#ifdef DEBUG
+#ifdef _DEBUG
DWORD m_dwCookie;
#endif
@@ -655,7 +655,7 @@ class CEnumMediaTypes : public IEnumMediaTypes // The interface we support CBasePin *m_pPin; // The pin who owns us
LONG m_Version; // Media type version value
LONG m_cRef;
-#ifdef DEBUG
+#ifdef _DEBUG
DWORD m_dwCookie;
#endif
@@ -981,7 +981,7 @@ public: // Set graph config info
void SetConfigInfo(IGraphConfig *pGraphConfig, HANDLE hStopEvent);
- #ifdef DEBUG
+ #ifdef _DEBUG
virtual HRESULT Deliver(IMediaSample *pSample);
virtual HRESULT DeliverEndOfStream(void);
virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
@@ -1075,7 +1075,7 @@ private: HRESULT Initialize(void);
HRESULT ChangeMediaTypeHelper(const CMediaType *pmt);
- #ifdef DEBUG
+ #ifdef _DEBUG
void AssertValid(void);
#endif // DEBUG
};
@@ -1118,7 +1118,7 @@ inline CAutoUsingOutputPin::~CAutoUsingOutputPin() }
}
-#ifdef DEBUG
+#ifdef _DEBUG
inline HRESULT CDynamicOutputPin::Deliver(IMediaSample *pSample)
{
@@ -1354,7 +1354,7 @@ class AM_NOVTABLE CBaseAllocator : public CUnknown,// A non delegating IUnknown {
public:
CSampleList() : m_List(NULL), m_nOnList(0) {};
-#ifdef DEBUG
+#ifdef _DEBUG
~CSampleList()
{
ASSERT(m_nOnList == 0);
diff --git a/src/filters/BaseClasses/combase.cpp b/src/filters/BaseClasses/combase.cpp index ec62a88cb..25ed0c65d 100644 --- a/src/filters/BaseClasses/combase.cpp +++ b/src/filters/BaseClasses/combase.cpp @@ -24,7 +24,7 @@ CBaseObject::CBaseObject(__in_opt LPCTSTR pName) /* Increment the number of active objects */
InterlockedIncrement(&m_cObjects);
-#ifdef DEBUG
+#ifdef _DEBUG
#ifdef UNICODE
m_dwCookie = DbgRegisterObjectCreation(0, pName);
@@ -41,7 +41,7 @@ CBaseObject::CBaseObject(const char *pName) /* Increment the number of active objects */
InterlockedIncrement(&m_cObjects);
-#ifdef DEBUG
+#ifdef _DEBUG
m_dwCookie = DbgRegisterObjectCreation(pName, 0);
#endif
}
@@ -63,7 +63,7 @@ CBaseObject::~CBaseObject() };
-#ifdef DEBUG
+#ifdef _DEBUG
DbgRegisterObjectDestruction(m_dwCookie);
#endif
}
diff --git a/src/filters/BaseClasses/combase.h b/src/filters/BaseClasses/combase.h index fb3515e91..7b0d1edae 100644 --- a/src/filters/BaseClasses/combase.h +++ b/src/filters/BaseClasses/combase.h @@ -171,7 +171,7 @@ private: static LONG m_cObjects; /* Total number of objects active */
protected:
-#ifdef DEBUG
+#ifdef _DEBUG
DWORD m_dwCookie; /* Cookie identifying this object */
#endif
diff --git a/src/filters/BaseClasses/ctlutil.cpp b/src/filters/BaseClasses/ctlutil.cpp index 4236d46f9..8ccb9dc3c 100644 --- a/src/filters/BaseClasses/ctlutil.cpp +++ b/src/filters/BaseClasses/ctlutil.cpp @@ -743,20 +743,20 @@ CPosPassThru::GetCurrentPosition(__out LONGLONG *pCurrent) STDMETHODIMP
CPosPassThru::GetStopPosition(__out LONGLONG *pStop)
{
- return GetSeekingLongLong( &IMediaSeeking::GetStopPosition, pStop );
+ return GetSeekingLongLong( &IMediaSeeking::GetStopPosition, pStop );;
}
STDMETHODIMP
CPosPassThru::GetDuration(__out LONGLONG *pDuration)
{
- return GetSeekingLongLong( &IMediaSeeking::GetDuration, pDuration );
+ return GetSeekingLongLong( &IMediaSeeking::GetDuration, pDuration );;
}
STDMETHODIMP
CPosPassThru::GetPreroll(__out LONGLONG *pllPreroll)
{
- return GetSeekingLongLong( &IMediaSeeking::GetPreroll, pllPreroll );
+ return GetSeekingLongLong( &IMediaSeeking::GetPreroll, pllPreroll );;
}
@@ -1295,7 +1295,7 @@ HRESULT CSourceSeeking::GetPositions( __out_opt LONGLONG * pCurrent, __out_opt L *pStop = m_rtStop;
}
- return S_OK;
+ return S_OK;;
}
diff --git a/src/filters/BaseClasses/dllentry.cpp b/src/filters/BaseClasses/dllentry.cpp index 130aad6ac..81a8673a9 100644 --- a/src/filters/BaseClasses/dllentry.cpp +++ b/src/filters/BaseClasses/dllentry.cpp @@ -11,7 +11,7 @@ #include <streams.h>
#include <initguid.h>
-#ifdef DEBUG
+#ifdef _DEBUG
#ifdef UNICODE
#ifndef _UNICODE
#define _UNICODE
@@ -259,7 +259,29 @@ DllCanUnloadNow() // --- standard WIN32 entrypoints --------------------------------------
+BOOL SetHeapOptions() {
+ HMODULE hLib = LoadLibrary(L"kernel32.dll");
+ if (hLib == NULL) return FALSE;
+
+ typedef BOOL (WINAPI *HSI)
+ (HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
+ HSI pHsi = (HSI)GetProcAddress(hLib,"HeapSetInformation");
+ if (!pHsi) {
+ FreeLibrary(hLib);
+ return FALSE;
+ }
+
+#ifndef HeapEnableTerminationOnCorruption
+# define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
+#endif
+
+ BOOL fRet = (pHsi)(NULL,HeapEnableTerminationOnCorruption,NULL,0)
+ ? TRUE
+ : FALSE;
+ if (hLib) FreeLibrary(hLib);
+ return fRet;
+}
extern "C" void __cdecl __security_init_cookie(void);
extern "C" BOOL WINAPI _DllEntryPoint(HINSTANCE, ULONG, __inout_opt LPVOID);
@@ -292,7 +314,7 @@ _DllEntryPoint( __inout_opt LPVOID pv
)
{
-#ifdef DEBUG
+#ifdef _DEBUG
extern bool g_fDbgInDllEntryPoint;
g_fDbgInDllEntryPoint = true;
#endif
@@ -305,7 +327,8 @@ _DllEntryPoint( DbgInitialise(hInstance);
{
- // The platform identifier is used to work out whether
+ SetHeapOptions();
+ // The platform identifier is used to work out whether
// full unicode support is available or not. Hence the
// default will be the lowest common denominator - i.e. N/A
g_amPlatform = VER_PLATFORM_WIN32_WINDOWS; // win95 assumed in case GetVersionEx fails
@@ -325,7 +348,7 @@ _DllEntryPoint( case DLL_PROCESS_DETACH:
DllInitClasses(FALSE);
-#ifdef DEBUG
+#ifdef _DEBUG
if (CBaseObject::ObjectsActive()) {
DbgSetModuleLevel(LOG_MEMORY, 2);
TCHAR szInfo[512];
@@ -358,7 +381,7 @@ _DllEntryPoint( break;
}
-#ifdef DEBUG
+#ifdef _DEBUG
g_fDbgInDllEntryPoint = false;
#endif
return TRUE;
diff --git a/src/filters/BaseClasses/refclock.cpp b/src/filters/BaseClasses/refclock.cpp index 8ae25f44b..814a60f8a 100644 --- a/src/filters/BaseClasses/refclock.cpp +++ b/src/filters/BaseClasses/refclock.cpp @@ -263,7 +263,7 @@ REFERENCE_TIME CBaseReferenceClock::GetPrivateTime() STDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME & TimeDelta)
{
-#ifdef DEBUG
+#ifdef _DEBUG
// Just break if passed an improper time delta value
LONGLONG llDelta = TimeDelta > 0 ? TimeDelta : -TimeDelta;
diff --git a/src/filters/BaseClasses/renbase.cpp b/src/filters/BaseClasses/renbase.cpp index c6e196272..c9766baf1 100644 --- a/src/filters/BaseClasses/renbase.cpp +++ b/src/filters/BaseClasses/renbase.cpp @@ -163,7 +163,7 @@ HRESULT CBaseRenderer::SourceThreadCanWait(BOOL bCanWait) }
-#ifdef DEBUG
+#ifdef _DEBUG
// Dump the current renderer state to the debug terminal. The hardest part of
// the renderer is the window where we unlock everything to wait for a clock
// to signal it is time to draw or for the application to cancel everything
@@ -262,7 +262,7 @@ HRESULT CBaseRenderer::WaitForRenderTime() while (Result == WAIT_TIMEOUT) {
Result = WaitForMultipleObjects(2,WaitObjects,FALSE,RENDER_TIMEOUT);
-#ifdef DEBUG
+#ifdef _DEBUG
if (Result == WAIT_TIMEOUT) DisplayRendererState();
#endif
diff --git a/src/filters/BaseClasses/renbase.h b/src/filters/BaseClasses/renbase.h index c2685bb23..695f07837 100644 --- a/src/filters/BaseClasses/renbase.h +++ b/src/filters/BaseClasses/renbase.h @@ -110,7 +110,7 @@ public: virtual HRESULT SourceThreadCanWait(BOOL bCanWait);
-#ifdef DEBUG
+#ifdef _DEBUG
// Debug only dump of the renderer state
void DisplayRendererState();
#endif
diff --git a/src/filters/BaseClasses/schedule.cpp b/src/filters/BaseClasses/schedule.cpp index 7d7983060..1b4a38190 100644 --- a/src/filters/BaseClasses/schedule.cpp +++ b/src/filters/BaseClasses/schedule.cpp @@ -125,7 +125,7 @@ HRESULT CAMSchedule::Unadvise(DWORD_PTR dwAdviseCookie) --m_dwAdviseCount;
hr = S_OK;
// Having found one cookie that matches, there should be no more
- #ifdef DEBUG
+ #ifdef _DEBUG
while (p_n = p_prev->Next())
{
ASSERT(p_n->m_dwAdviseCookie != dwAdviseCookie);
@@ -150,7 +150,7 @@ REFERENCE_TIME CAMSchedule::Advise( const REFERENCE_TIME & rtTime ) CAutoLock lck(&m_Serialize);
- #ifdef DEBUG
+ #ifdef _DEBUG
if (DbgCheckModuleLevel(LOG_TIMING, 4)) DumpLinkedList();
#endif
@@ -254,7 +254,7 @@ void CAMSchedule::ShuntHead() head.m_next = pPacket->m_next;
(p_prev->m_next = pPacket)->m_next = p_n;
}
- #ifdef DEBUG
+ #ifdef _DEBUG
DbgLog((LOG_TIMING, 2, TEXT("Periodic advise %lu, shunted to %lu"),
pPacket->m_dwAdviseCookie, (pPacket->m_rtEventTime / (UNITS / MILLISECONDS)) ));
#endif
@@ -262,7 +262,7 @@ void CAMSchedule::ShuntHead() }
-#ifdef DEBUG
+#ifdef _DEBUG
void CAMSchedule::DumpLinkedList()
{
m_Serialize.Lock();
diff --git a/src/filters/BaseClasses/schedule.h b/src/filters/BaseClasses/schedule.h index c16700a2b..058d76442 100644 --- a/src/filters/BaseClasses/schedule.h +++ b/src/filters/BaseClasses/schedule.h @@ -117,7 +117,7 @@ private: // Attributes and methods for debugging
public:
-#ifdef DEBUG
+#ifdef _DEBUG
void DumpLinkedList();
#else
void DumpLinkedList() {}
diff --git a/src/filters/BaseClasses/streams.h b/src/filters/BaseClasses/streams.h index 1926321df..7d1afd0d5 100644 --- a/src/filters/BaseClasses/streams.h +++ b/src/filters/BaseClasses/streams.h @@ -195,7 +195,7 @@ LONG_PTR _SetWindowLongPtr(HWND hwnd, int nIndex, T p) #else
- #ifdef DEBUG
+ #ifdef _DEBUG
#pragma message("STREAMS.H included TWICE")
#endif
#endif // __STREAMS__
diff --git a/src/filters/BaseClasses/transfrm.cpp b/src/filters/BaseClasses/transfrm.cpp index 3d1707799..62b4cc3f4 100644 --- a/src/filters/BaseClasses/transfrm.cpp +++ b/src/filters/BaseClasses/transfrm.cpp @@ -940,7 +940,7 @@ CTransformOutputPin::SetMediaType(const CMediaType* pmtOut) return hr;
}
-#ifdef DEBUG
+#ifdef _DEBUG
if (FAILED(m_pTransformFilter->CheckTransform(&m_pTransformFilter->
m_pInput->CurrentMediaType(),pmtOut))) {
DbgLog((LOG_ERROR,0,TEXT("*** This filter is accepting an output media type")));
diff --git a/src/filters/BaseClasses/vtrans.cpp b/src/filters/BaseClasses/vtrans.cpp index cb4fa9982..27502970f 100644 --- a/src/filters/BaseClasses/vtrans.cpp +++ b/src/filters/BaseClasses/vtrans.cpp @@ -110,7 +110,7 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample) ASSERT(CritCheckIn(&m_csReceive));
AM_MEDIA_TYPE *pmtOut, *pmt;
-#ifdef DEBUG
+#ifdef _DEBUG
FOURCCMap fccOut;
#endif
HRESULT hr;
@@ -134,7 +134,7 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample) // spew some debug output
ASSERT(!IsEqualGUID(pmt->majortype, GUID_NULL));
-#ifdef DEBUG
+#ifdef _DEBUG
fccOut.SetFOURCC(&pmt->subtype);
LONG lCompression = HEADER(pmt->pbFormat)->biCompression;
LONG lBitCount = HEADER(pmt->pbFormat)->biBitCount;
@@ -194,7 +194,7 @@ HRESULT CVideoTransformFilter::Receive(IMediaSample *pSample) // spew some debug output
ASSERT(!IsEqualGUID(pmtOut->majortype, GUID_NULL));
-#ifdef DEBUG
+#ifdef _DEBUG
fccOut.SetFOURCC(&pmtOut->subtype);
LONG lCompression = HEADER(pmtOut->pbFormat)->biCompression;
LONG lBitCount = HEADER(pmtOut->pbFormat)->biBitCount;
diff --git a/src/filters/BaseClasses/winctrl.cpp b/src/filters/BaseClasses/winctrl.cpp index 4d1f52e39..9b2c0df6d 100644 --- a/src/filters/BaseClasses/winctrl.cpp +++ b/src/filters/BaseClasses/winctrl.cpp @@ -828,7 +828,7 @@ CBaseControlWindow::SetWindowPosition(long Left,long Top,long Width,long Height) Height, // Window height
WindowFlags); // Show window flags
ASSERT(bSuccess);
-#ifdef DEBUG
+#ifdef _DEBUG
DbgLog((LOG_TRACE, 1, TEXT("SWP failed error %d"), GetLastError()));
#endif
if (bSuccess == FALSE) {
diff --git a/src/filters/BaseClasses/winutil.cpp b/src/filters/BaseClasses/winutil.cpp index 6653f4570..e5a63cc02 100644 --- a/src/filters/BaseClasses/winutil.cpp +++ b/src/filters/BaseClasses/winutil.cpp @@ -31,7 +31,7 @@ CBaseWindow::CBaseWindow(BOOL bDoGetDC, bool bDoPostToDestroy) : m_MemoryDC(NULL),
m_hPalette(NULL),
m_bBackground(FALSE),
-#ifdef DEBUG
+#ifdef _DEBUG
m_bRealizing(FALSE),
#endif
m_bNoRealize(FALSE),
@@ -94,7 +94,7 @@ HRESULT CBaseWindow::PrepareWindow() // Derived classes MUST call DoneWithWindow in their destructors so
// that no messages arrive after the derived class constructor ends
-#ifdef DEBUG
+#ifdef _DEBUG
CBaseWindow::~CBaseWindow()
{
ASSERT(m_hwnd == NULL);
@@ -449,14 +449,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, // Window handle }
// Set the window LONG to be the object who created us
-#ifdef DEBUG
+#ifdef _DEBUG
SetLastError(0); // because of the way SetWindowLong works
#endif
LONG_PTR rc = _SetWindowLongPtr(hwnd, (DWORD) 0, pBaseWindow);
-#ifdef DEBUG
+#ifdef _DEBUG
if (0 == rc) {
// SetWindowLong MIGHT have failed. (Read the docs which admit
// that it is awkward to work out if you have had an error.)
@@ -650,7 +650,7 @@ HRESULT CBaseWindow::DoCreateWindow() // The base class provides some default handling and calls DefWindowProc
-LRESULT CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
+INT_PTR CBaseWindow::OnReceiveMessage(HWND hwnd, // Window handle
UINT uMsg, // Message ID
WPARAM wParam, // First parameter
LPARAM lParam) // Other parameter
@@ -782,11 +782,11 @@ LRESULT CBaseWindow::OnPaletteChange(HWND hwnd,UINT Message) }
// Avoid recursion with multiple graphs in the same app
-#ifdef DEBUG
+#ifdef _DEBUG
m_bRealizing = TRUE;
#endif
DoRealisePalette(Message != WM_QUERYNEWPALETTE);
-#ifdef DEBUG
+#ifdef _DEBUG
m_bRealizing = FALSE;
#endif
@@ -869,7 +869,7 @@ HDC CBaseWindow::GetMemoryHDC() }
-#ifdef DEBUG
+#ifdef _DEBUG
HPALETTE CBaseWindow::GetPalette()
{
// The palette lock should always be held when accessing
@@ -940,7 +940,7 @@ CDrawImage::CDrawImage(__inout CBaseWindow *pBaseWindow) : void CDrawImage::DisplaySampleTimes(IMediaSample *pSample)
{
-#ifdef DEBUG
+#ifdef _DEBUG
//
// Only allow the "annoying" time messages if the users has turned the
// logging "way up"
@@ -1106,7 +1106,7 @@ void CDrawImage::FastRender(IMediaSample *pMediaSample) // draw the times into the offscreen device context however that actually
// writes the text into the image data buffer which may not be writable
- #ifdef DEBUG
+ #ifdef _DEBUG
DisplaySampleTimes(pMediaSample);
#endif
@@ -1201,7 +1201,7 @@ void CDrawImage::SlowRender(IMediaSample *pMediaSample) // the screen, unfortunately this has considerable performance penalties
// and also means that this code is not executed when compiled retail
- #ifdef DEBUG
+ #ifdef _DEBUG
DisplaySampleTimes(pMediaSample);
#endif
}
@@ -1460,7 +1460,7 @@ CImageAllocator::CImageAllocator(__inout CBaseFilter *pFilter, // Check our DIB buffers have been released
-#ifdef DEBUG
+#ifdef _DEBUG
CImageAllocator::~CImageAllocator()
{
ASSERT(m_bCommitted == FALSE);
@@ -1783,7 +1783,7 @@ CImagePalette::CImagePalette(__inout CBaseFilter *pBaseFilter, // Destructor
-#ifdef DEBUG
+#ifdef _DEBUG
CImagePalette::~CImagePalette()
{
ASSERT(m_hPalette == NULL);
diff --git a/src/filters/BaseClasses/winutil.h b/src/filters/BaseClasses/winutil.h index 6bd623543..27358f9fd 100644 --- a/src/filters/BaseClasses/winutil.h +++ b/src/filters/BaseClasses/winutil.h @@ -74,7 +74,7 @@ public: CBaseWindow(BOOL bDoGetDC = TRUE, bool bPostToDestroy = false);
-#ifdef DEBUG
+#ifdef _DEBUG
virtual ~CBaseWindow();
#endif
@@ -121,13 +121,13 @@ public: HDC GetMemoryHDC();
HDC GetWindowHDC();
- #ifdef DEBUG
+ #ifdef _DEBUG
HPALETTE GetPalette();
#endif // DEBUG
// This is the window procedure the derived object should override
- virtual LRESULT OnReceiveMessage(HWND hwnd, // Window handle
+ virtual INT_PTR OnReceiveMessage(HWND hwnd, // Window handle
UINT uMsg, // Message ID
WPARAM wParam, // First parameter
LPARAM lParam); // Other parameter
@@ -299,7 +299,7 @@ public: // Constructor and destructor
CImageAllocator(__inout CBaseFilter *pFilter,__in_opt LPCTSTR pName,__inout HRESULT *phr);
-#ifdef DEBUG
+#ifdef _DEBUG
~CImageAllocator();
#endif
@@ -339,7 +339,7 @@ public: __inout CBaseWindow *pBaseWindow,
__inout CDrawImage *pDrawImage);
-#ifdef DEBUG
+#ifdef _DEBUG
virtual ~CImagePalette();
#endif
diff --git a/src/filters/BaseClasses/wxdebug.cpp b/src/filters/BaseClasses/wxdebug.cpp index 3c4330319..4f0e9bdd8 100644 --- a/src/filters/BaseClasses/wxdebug.cpp +++ b/src/filters/BaseClasses/wxdebug.cpp @@ -15,7 +15,7 @@ #include <stdio.h>
#include <dvdmedia.h>
-#ifdef DEBUG
+#ifdef _DEBUG
#ifdef UNICODE
#ifndef _UNICODE
#define _UNICODE
@@ -26,7 +26,7 @@ #include <tchar.h>
#include <strsafe.h>
-#ifdef DEBUG
+#ifdef _DEBUG
static void DisplayBITMAPINFO(const BITMAPINFOHEADER* pbmi);
static void DisplayRECT(LPCTSTR szLabel, const RECT& rc);
@@ -1264,7 +1264,7 @@ CDisp::CDisp(double d) We also display the fields in the BITMAPINFOHEADER structure, this should
succeed as we do not accept input types unless the format is big enough */
-#ifdef DEBUG
+#ifdef _DEBUG
void WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn)
{
diff --git a/src/filters/BaseClasses/wxdebug.h b/src/filters/BaseClasses/wxdebug.h index d4c69dbb0..34ceefeec 100644 --- a/src/filters/BaseClasses/wxdebug.h +++ b/src/filters/BaseClasses/wxdebug.h @@ -73,7 +73,7 @@ typedef struct tag_ObjectDesc { #define DLLIMPORT __declspec(dllimport)
#define DLLEXPORT __declspec(dllexport)
-#ifdef DEBUG
+#ifdef _DEBUG
#define NAME(x) TEXT(x)
diff --git a/src/filters/BaseClasses/wxlist.cpp b/src/filters/BaseClasses/wxlist.cpp index 2ec67a457..e8fda9d6c 100644 --- a/src/filters/BaseClasses/wxlist.cpp +++ b/src/filters/BaseClasses/wxlist.cpp @@ -79,7 +79,7 @@ for ( cursor = (list).GetTailPositionI() \ */
CBaseList::CBaseList(__in_opt LPCTSTR pName, // Descriptive list name
INT iItems) : // Node cache size
-#ifdef DEBUG
+#ifdef _DEBUG
CBaseObject(pName),
#endif
m_pFirst(NULL),
@@ -90,7 +90,7 @@ CBaseList::CBaseList(__in_opt LPCTSTR pName, // Descriptive list name } // constructor
CBaseList::CBaseList(__in_opt LPCTSTR pName) : // Descriptive list name
-#ifdef DEBUG
+#ifdef _DEBUG
CBaseObject(pName),
#endif
m_pFirst(NULL),
@@ -103,7 +103,7 @@ CBaseList::CBaseList(__in_opt LPCTSTR pName) : // Descriptive list name #ifdef UNICODE
CBaseList::CBaseList(__in_opt LPCSTR pName, // Descriptive list name
INT iItems) : // Node cache size
-#ifdef DEBUG
+#ifdef _DEBUG
CBaseObject(pName),
#endif
m_pFirst(NULL),
@@ -114,7 +114,7 @@ CBaseList::CBaseList(__in_opt LPCSTR pName, // Descriptive list name } // constructor
CBaseList::CBaseList(__in_opt LPCSTR pName) : // Descriptive list name
-#ifdef DEBUG
+#ifdef _DEBUG
CBaseObject(pName),
#endif
m_pFirst(NULL),
diff --git a/src/filters/BaseClasses/wxlist.h b/src/filters/BaseClasses/wxlist.h index 47e712308..900792883 100644 --- a/src/filters/BaseClasses/wxlist.h +++ b/src/filters/BaseClasses/wxlist.h @@ -62,7 +62,7 @@ const int DEFAULTCACHE = 10; /* Default node object cache size */ All of these pointers can be retrieved or set through member functions.
*/
class CBaseList
-#ifdef DEBUG
+#ifdef _DEBUG
: public CBaseObject
#endif
{
@@ -73,7 +73,7 @@ class CBaseList public:
-#ifdef DEBUG
+#ifdef _DEBUG
class CNode : public CBaseObject {
#else
class CNode {
@@ -87,7 +87,7 @@ public: /* Constructor - initialise the object's pointers */
CNode()
-#ifdef DEBUG
+#ifdef _DEBUG
: CBaseObject(NAME("List node"))
#endif
{
diff --git a/src/filters/BaseClasses/wxutil.cpp b/src/filters/BaseClasses/wxutil.cpp index 9e84cd338..271f68da0 100644 --- a/src/filters/BaseClasses/wxutil.cpp +++ b/src/filters/BaseClasses/wxutil.cpp @@ -457,7 +457,7 @@ HRESULT AMSafeMemMoveOffset( }
-#ifdef DEBUG
+#ifdef _DEBUG
/******************************Public*Routine******************************\
* Debug CCritSec helpers
*
diff --git a/src/filters/BaseClasses/wxutil.h b/src/filters/BaseClasses/wxutil.h index a1866ed9c..caef83c56 100644 --- a/src/filters/BaseClasses/wxutil.h +++ b/src/filters/BaseClasses/wxutil.h @@ -24,7 +24,7 @@ class CCritSec { CRITICAL_SECTION m_CritSec;
-#ifdef DEBUG
+#ifdef _DEBUG
public:
DWORD m_currentOwner;
DWORD m_lockCount;
@@ -71,7 +71,7 @@ public: // traced. This is NOT on by default - there are far too many.
//
-#ifdef DEBUG
+#ifdef _DEBUG
BOOL WINAPI CritCheckIn(CCritSec * pcCrit);
BOOL WINAPI CritCheckIn(const CCritSec * pcCrit);
BOOL WINAPI CritCheckOut(CCritSec * pcCrit);
diff --git a/src/filters/transform/vsfilter/Copy.cpp b/src/filters/transform/vsfilter/Copy.cpp index 25038f83c..27153a3bf 100644 --- a/src/filters/transform/vsfilter/Copy.cpp +++ b/src/filters/transform/vsfilter/Copy.cpp @@ -112,9 +112,19 @@ void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype) }
}
+#ifdef WIN64
+// For CPUID usage
+#include "../../../dsutil/vd.h"
+#include <emmintrin.h>
+#endif
/* ResX2 */
void Scale2x(const GUID& subtype, BYTE* d, int dpitch, BYTE* s, int spitch, int w, int h)
{
+#ifdef WIN64
+ // CPUID from VDub
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+#endif
+
if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
{
BYTE* s1;
@@ -162,6 +172,51 @@ void Scale2x(const GUID& subtype, BYTE* d, int dpitch, BYTE* s, int spitch, int // ->
// row0, 8 pixels: y1|u1|(y1+y2)/2|v1|y2|(u1+u2)/2|(y2+y3)/2|(v1+v2)/2
+#ifdef WIN64
+ if(fSSE2)
+ {
+ __m128i mm4 = _mm_cvtsi64_si128(__0x00ff00ff00ff00ff);
+ __m128i mm5 = _mm_cvtsi64_si128(__0x00000000ffffffff);
+ __m128i mm6 = _mm_cvtsi64_si128(__0xffffffff00000000);
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
+ {
+ __m128i mm0 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm0, [esi]
+ __m128i mm2 = _mm_move_epi64(mm0); //movq mm2, mm0
+ mm0 = _mm_and_si128(mm0, mm4); //pand mm0, mm4 // mm0 = 00y400y300y200y1
+ mm2 = _mm_srli_epi16(mm2, 8); //psrlw mm2, 8 // mm2 = 00u200v200u100v1
+ __m128i mm1 = _mm_move_epi64(mm0); //movq mm1, mm0
+ mm0 = _mm_and_si128(mm0, mm5); //pand mm0, mm5 // mm0 = 0000000000y200y1
+ mm1 = _mm_slli_epi64(mm1, 16); //psllq mm1, 16
+ mm1 = _mm_and_si128(mm1, mm6); //pand mm1, mm6 // mm1 = 00y300y200000000
+ mm1 = _mm_or_si128(mm1, mm0); //por mm1, mm0 // mm1 = 00y300y200y200y1
+ mm0 = _mm_unpacklo_epi8(mm0, mm0); //punpcklwd mm0, mm0 // mm0 = 00y200y200y100y1
+ mm0 = _mm_adds_epi16(mm0,mm1); //paddw mm0, mm1
+ mm0 = _mm_srli_epi16(mm0, 1); //psrlw mm0, 1 // mm0 = (mm0 + mm1) / 2
+ mm1 = _mm_move_epi64(mm2); //movq mm1, mm2
+ mm1 = _mm_unpacklo_epi32(mm1, mm1); //punpckldq mm1, mm1 // mm1 = 00u100v100u100v1
+ mm1 = _mm_adds_epi16(mm1,mm2); //paddw mm1, mm2
+ mm1 = _mm_srli_epi16(mm1, 1); //psrlw mm1, 1 // mm1 = (mm1 + mm2) / 2
+ mm1 = _mm_slli_epi64(mm1, 8); //psllw mm1, 8
+ mm1 = _mm_or_si128(mm0, mm1); //por mm0, mm1 // mm0 = (v1+v2)/2|(y2+y3)/2|(u1+u2)/2|y2|v1|(y1+y2)/2|u1|y1
+ *(size_t*)d1 = (size_t)_mm_cvtsi128_si64(mm0); //movq [edi], mm0
+ }
+ }
+ else
+ {
+ for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
+ {
+ d1[0] = s1[0];
+ d1[1] = s1[1];
+ d1[2] = (s1[0]+s1[2])>>1;
+ d1[3] = s1[3];
+
+ d1[4] = s1[2];
+ d1[5] = (s1[1]+s1[5])>>1;
+ d1[6] = (s1[2]+s1[4])>>1;
+ d1[7] = (s1[3]+s1[7])>>1;
+ }
+ }
+#else
__asm
{
mov esi, s1
@@ -218,7 +273,7 @@ row_loop1: mov s1, esi
mov d1, edi
};
-
+#endif
*d1++ = s1[0];
*d1++ = s1[1];
*d1++ =(s1[0]+s1[2])>>1;
@@ -346,6 +401,43 @@ row_loop1: BYTE* stmp = s1 + spitch;
BYTE* dtmp = d1 + dpitch;
+#ifdef WIN64
+ if(fSSE2) // SSE2 code
+ {
+ __m128i mm_zero = _mm_setzero_si128();//pxor mm0, mm0
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 4, d1 += 8)
+ {
+
+ __m128i mm1 = _mm_cvtsi64_si128(*(size_t*)s1); //movq mm1, [esi]
+ __m128i mm2 = _mm_move_epi64(mm1); //movq mm2, mm1
+
+ mm1 = _mm_unpacklo_epi8(mm1,mm_zero);//punpcklbw mm1, mm0 // mm1 = 00xx00r100g100b1
+ mm2 = _mm_unpacklo_epi8(mm2,mm_zero);//punpckhbw mm2, mm0 // mm2 = 00xx00r200g200b2
+
+ mm2 = _mm_adds_epi16(mm2,mm1); //paddw mm2, mm1
+ mm2 = _mm_srli_epi16(mm2, 1); //psrlw mm2, 1 // mm2 = (mm1 + mm2) / 2
+
+ mm1 = _mm_packus_epi16(mm1,mm2); //packuswb mm1, mm2
+
+ *(size_t*)d1=(size_t)_mm_cvtsi128_si64(mm1);//movq [edi], mm1
+ }
+ }
+ else
+ {
+ for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6)
+ {
+ d1[0] = s1[0];
+ d1[1] = s1[1];
+ d1[2] = s1[2];
+ d1[3] = s1[3];
+
+ d1[4] = (s1[0]+s1[4])>>1;
+ d1[5] = (s1[1]+s1[5])>>1;
+ d1[6] = (s1[2]+s1[6])>>1;
+ d1[7] = (s1[4]+s1[7])>>1;
+ }
+ }
+#else
__asm
{
mov esi, s1
@@ -378,6 +470,7 @@ row_loop3: mov s1, esi
mov d1, edi
};
+#endif
*((DWORD*)d1) = *((DWORD*)s1);
*((DWORD*)d1+1) = *((DWORD*)s1);
@@ -392,7 +485,9 @@ row_loop3: AvgLines8(d, h*2, dpitch);
}
+#ifndef WIN64
__asm emms;
+#endif
}
HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, int bpp, const GUID& subtype, DWORD black)
@@ -434,7 +529,7 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in pSub + dpLeft, pitchSub, pIn, pitchIn,
in.cx, (min(j, hSub) - i) >> 1);
- for(int k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
{
memsetd(pSub, black, dpLeft);
memsetd(pSub + dpLeft+dpMid, black, dpRight);
@@ -442,7 +537,7 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in }
else
{
- for(int k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
+ for(ptrdiff_t k = min(j, hSub); i < k; i++, pIn += pitchIn, pSub += pitchSub)
{
memsetd(pSub, black, dpLeft);
memcpy(pSub + dpLeft, pIn, dpMid);
@@ -501,7 +596,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut) tmp.Format(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart/10000, rtStop/10000);
msg += tmp;
- for(int i = 0; i < nSubPics; i++)
+ for(ptrdiff_t i = 0; i < nSubPics; i++)
{
m_pSubPicQueue->GetStats(i, rtStart, rtStop);
tmp.Format(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart/10000, rtStop/10000);
@@ -550,7 +645,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut) pIn += pitchIn * r.top;
pOut += pitchOut * r.top;
- for(int w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut)
+ for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut)
{
BltLineRGB32((DWORD*)pOut, pIn, w, subtype);
memsetd(pIn, 0xff000000, r.right*4);
diff --git a/src/filters/transform/vsfilter/DirectVobSubFilter.cpp b/src/filters/transform/vsfilter/DirectVobSubFilter.cpp index 8a7a13c1c..2a8ead2f7 100644 --- a/src/filters/transform/vsfilter/DirectVobSubFilter.cpp +++ b/src/filters/transform/vsfilter/DirectVobSubFilter.cpp @@ -105,7 +105,7 @@ CDirectVobSubFilter::~CDirectVobSubFilter() if(m_hbm) {DeleteObject(m_hbm); m_hbm = 0;}
if(m_hdc) {DeleteObject(m_hdc); m_hdc = 0;}
- for(int i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
delete m_pTextInput[i];
m_frd.EndThreadEvent.Set();
@@ -626,7 +626,7 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo) if(nLangs <= 0) return(0);
- for(int i = 0; i < MAXPREFLANGS; i++)
+ for(ptrdiff_t i = 0; i < MAXPREFLANGS; i++)
{
CString tmp;
tmp.Format(IDS_RL_LANG, i);
@@ -635,7 +635,7 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo) if(!lang.IsEmpty())
{
- for(int ret = 0; ret < nLangs; ret++)
+ for(ptrdiff_t ret = 0; ret < nLangs; ret++)
{
CString l;
WCHAR* pName = NULL;
@@ -1233,7 +1233,7 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph) _T("GoogleDesktopCrawl."), // Google Desktop
};
- for(int i = 0; i < countof(blacklistedapps); i++)
+ for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++)
{
if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0)
return(false);
@@ -1354,7 +1354,7 @@ bool CDirectVobSubFilter::Open() CAtlArray<CString> paths;
- for(int i = 0; i < 10; i++)
+ for(ptrdiff_t i = 0; i < 10; i++)
{
CString tmp;
tmp.Format(IDS_RP_PATH, i);
@@ -1365,7 +1365,7 @@ bool CDirectVobSubFilter::Open() CAtlArray<SubFile> ret;
GetSubFileNames(m_FileName, paths, ret);
- for(int i = 0; i < ret.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < ret.GetCount(); i++)
{
if(m_frd.files.Find(ret[i].fn))
continue;
@@ -1408,7 +1408,7 @@ bool CDirectVobSubFilter::Open() }
}
- for(int i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
{
if(m_pTextInput[i]->IsConnected())
m_pSubStreams.AddTail(m_pTextInput[i]->GetSubStream());
@@ -1569,7 +1569,7 @@ void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream) if(!pos) m_pSubStreams.AddTail(pSubStream);
int len = m_pTextInput.GetCount();
- for(int i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
if(m_pTextInput[i]->IsConnected()) len--;
if(len == 0)
@@ -1609,7 +1609,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl {
CAutoLock cAutolock(&m_csSubLock);
- for(int i = 2; i < handles.GetCount(); i++)
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
{
FindCloseChangeNotification(handles[i]);
}
@@ -1623,7 +1623,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl m_frd.mtime.SetCount(m_frd.files.GetCount());
POSITION pos = m_frd.files.GetHeadPosition();
- for(int i = 0; pos; i++)
+ for(ptrdiff_t i = 0; pos; i++)
{
CString fn = m_frd.files.GetNext(pos);
@@ -1636,7 +1636,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl bool fFound = false;
- for(int j = 0; !fFound && j < paths.GetCount(); j++)
+ for(ptrdiff_t j = 0; !fFound && j < paths.GetCount(); j++)
{
if(paths[j] == fn) fFound = true;
}
@@ -1684,7 +1684,7 @@ DWORD CDirectVobSubFilter::ThreadProc() int j = 0;
POSITION pos = m_frd.files.GetHeadPosition();
- for(int i = 0; pos && j == 0; i++)
+ for(ptrdiff_t i = 0; pos && j == 0; i++)
{
CString fn = m_frd.files.GetNext(pos);
@@ -1717,7 +1717,7 @@ DWORD CDirectVobSubFilter::ThreadProc() Sleep(500);
POSITION pos = m_frd.files.GetHeadPosition();
- for(int i = 0; pos; i++)
+ for(ptrdiff_t i = 0; pos; i++)
{
CFileStatus status;
if(CFileGetStatus(m_frd.files.GetNext(pos), status)
@@ -1736,7 +1736,7 @@ DWORD CDirectVobSubFilter::ThreadProc() }
}
- for(int i = 2; i < handles.GetCount(); i++)
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
{
FindCloseChangeNotification(handles[i]);
}
diff --git a/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp b/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp index 675848a1a..5a3d9b0a6 100644 --- a/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp +++ b/src/filters/transform/vsfilter/DirectVobSubPropPage.cpp @@ -117,7 +117,7 @@ CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int Ti {
}
-BOOL CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
@@ -302,7 +302,7 @@ void CDVSMainPPage::FreeLangs() {
if(m_nLangs > 0 && m_ppLangs)
{
- for(int i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
CoTaskMemFree(m_ppLangs);
m_nLangs = 0;
m_ppLangs = NULL;
@@ -377,7 +377,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave) int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
}
@@ -393,7 +393,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave) int nLangs;
m_pDirectVobSub->get_LanguageCount(&nLangs);
AllocLangs(nLangs);
- for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
@@ -437,7 +437,7 @@ void CDVSMainPPage::UpdateControlData(bool fSave) m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
m_langs.ResetContent();
m_langs.EnableWindow(m_nLangs > 0);
- for(int i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
m_langs.SetCurSel(m_iSelectedLanguage);
m_PARCombo.ResetContent();
@@ -984,7 +984,7 @@ void CDVSColorPPage::UpdateControlData(bool fSave) {
BYTE* pData = new BYTE[VIHSIZE];
- for(int i = 0; i < m_preflist.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++)
pData[i] = (BYTE)m_preflist.GetItemData(i);
theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
@@ -1010,12 +1010,12 @@ void CDVSColorPPage::UpdateControlData(bool fSave) nSize = VIHSIZE;
pData = new BYTE[VIHSIZE];
- for(int i = 0; i < VIHSIZE; i++) pData[i] = i;
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) pData[i] = i;
}
if(pData)
{
- for(int i = 0; i < (int)nSize; i++)
+ for(ptrdiff_t i = 0; i < (int)nSize; i++)
{
m_dynchglist.AddString(VIH2String(pData[i]));
m_dynchglist.SetItemData(i, pData[i]);
@@ -1186,7 +1186,7 @@ void CDVSPathsPPage::UpdateControlData(bool fSave) if(fSave)
{
m_paths.RemoveAll();
- for(int i = 0; i < m_pathlist.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++)
{
CString path;
m_pathlist.GetText(i, path);
@@ -1196,7 +1196,7 @@ void CDVSPathsPPage::UpdateControlData(bool fSave) else
{
m_pathlist.ResetContent();
- for(int i = 0; i < m_paths.GetSize(); i++)
+ for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++)
m_pathlist.AddString(m_paths[i]);
m_remove.EnableWindow(FALSE);
diff --git a/src/filters/transform/vsfilter/DirectVobSubPropPage.h b/src/filters/transform/vsfilter/DirectVobSubPropPage.h index 5c77f515b..5e0d7fe07 100644 --- a/src/filters/transform/vsfilter/DirectVobSubPropPage.h +++ b/src/filters/transform/vsfilter/DirectVobSubPropPage.h @@ -47,7 +47,7 @@ private: BOOL m_bIsInitialized;
HRESULT OnConnect(IUnknown* pUnknown), OnDisconnect(), OnActivate(), OnDeactivate(), OnApplyChanges();
- BOOL OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
private:
bool m_fAttached;
diff --git a/src/filters/transform/vsfilter/StyleEditorDialog.cpp b/src/filters/transform/vsfilter/StyleEditorDialog.cpp index c947361b8..d7edcbc33 100644 --- a/src/filters/transform/vsfilter/StyleEditorDialog.cpp +++ b/src/filters/transform/vsfilter/StyleEditorDialog.cpp @@ -121,13 +121,13 @@ void CStyleEditorDialog::UpdateControlData(bool fSave) m_stss.scrAlignment = m_screenalignment+1;
m_stss.marginRect = m_margin;
- for(int i = 0; i < 4; i++) m_stss.alpha[i] = 255-m_alpha[i];
+ for(ptrdiff_t i = 0; i < 4; i++) m_stss.alpha[i] = 255-m_alpha[i];
}
else
{
m_font.SetWindowText(m_stss.fontName);
m_iCharset = -1;
- for(int i = 0; i < CharSetLen; i++)
+ for(ptrdiff_t i = 0; i < CharSetLen; i++)
{
CString str;
str.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
@@ -159,7 +159,7 @@ void CStyleEditorDialog::UpdateControlData(bool fSave) m_margintopspin.SetRange32(-10000, 10000);
m_marginbottomspin.SetRange32(-10000, 10000);
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
m_color[i].SetColorPtr(&m_stss.colors[i]);
m_alpha[i] = 255-m_stss.alpha[i];
@@ -227,7 +227,7 @@ void CStyleEditorDialog::OnBnClickedButton1() if(str.GetLength() > 16) str = str.Left(14) + _T("...");
m_font.SetWindowText(str);
- for(int i = 0, j = m_charset.GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++)
{
if(m_charset.GetItemData(i) == lf.lfCharSet)
{
@@ -265,9 +265,9 @@ void CStyleEditorDialog::OnBnClickedCheck1() UpdateData();
int avg = 0;
- for(int i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ for(ptrdiff_t i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
avg /= 4;
- for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
+ for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(avg);
}
void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
@@ -275,7 +275,7 @@ void CStyleEditorDialog::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollB if(m_linkalphasliders && pScrollBar)
{
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
diff --git a/src/filters/transform/vsfilter/Systray.cpp b/src/filters/transform/vsfilter/Systray.cpp index 3df0bafb4..00a25bf33 100644 --- a/src/filters/transform/vsfilter/Systray.cpp +++ b/src/filters/transform/vsfilter/Systray.cpp @@ -92,7 +92,7 @@ public: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnClose();
afx_msg void OnDestroy();
- afx_msg void OnTimer(UINT nIDEvent);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg LRESULT OnDVSPrevSub(WPARAM, LPARAM);
afx_msg LRESULT OnDVSNextSub(WPARAM, LPARAM);
afx_msg LRESULT OnDVSHideSub(WPARAM, LPARAM);
@@ -156,7 +156,7 @@ void CSystrayWindow::OnDestroy() PostQuitMessage(0);
}
-void CSystrayWindow::OnTimer(UINT nIDEvent)
+void CSystrayWindow::OnTimer(UINT_PTR nIDEvent)
{
if(nIDEvent == 1)
{
@@ -273,7 +273,7 @@ LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam) CMenu popup;
popup.CreatePopupMenu();
- for(int j = 0; j < pStreams.GetCount(); j++)
+ for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++)
{
bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
diff --git a/src/filters/transform/vsfilter/csriapi.cpp b/src/filters/transform/vsfilter/csriapi.cpp index 17dec964e..c10bd9b19 100644 --- a/src/filters/transform/vsfilter/csriapi.cpp +++ b/src/filters/transform/vsfilter/csriapi.cpp @@ -42,8 +42,11 @@ extern "C" struct csri_vsfilter_inst { };
typedef struct csri_vsfilter_inst csri_inst;
#include "csri.h"
+#ifdef _VSMOD
+static csri_rend csri_vsfilter = "vsfiltermod";
+#else
static csri_rend csri_vsfilter = "vsfilter";
-
+#endif
CSRIAPI csri_inst *csri_open_file(csri_rend *renderer, const char *filename, struct csri_openflag *flags)
{
@@ -185,10 +188,18 @@ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname) // Get info for renderer
static struct csri_info csri_vsfilter_info = {
#ifdef _DEBUG
- "vsfilter_textsub_debug", // name
+ #ifdef _VSMOD
+ "vsfiltermod_textsub_debug", // name
+ #else
+ "vsfilter_textsub_debug", // name
+ #endif
"2.39", // version (assumed version number, svn revision, patchlevel)
#else
- "vsfilter_textsub", // name
+ #ifdef _VSMOD
+ "vsfiltermod_textsub", // name
+ #else
+ "vsfilter_textsub", // name
+ #endif
"2.39", // version (assumed version number, svn revision, patchlevel)
#endif
// 2.38-0611 is base svn 611
@@ -197,7 +208,11 @@ static struct csri_info csri_vsfilter_info = { // 2.38-0611-3 fixes a bug in CSRI and adds fontcrash-fix and float-pos
// 2.38-0611-4 fixes be1-dots and ugly-fade bugs and adds xbord/ybord/xshad/yshad/blur tags and extends be
// 2.39 merges with guliverkli2 fork
+#ifdef _VSMOD
+ "VSFilterMod/TextSub (guliverkli2)", // longname
+#else
"VSFilter/TextSub (guliverkli2)", // longname
+#endif
"Gabest", // author
"Copyright (c) 2003-2008 by Gabest and others" // copyright
};
diff --git a/src/filters/transform/vsfilter/plugins.cpp b/src/filters/transform/vsfilter/plugins.cpp index cfd52a769..13f905623 100644 --- a/src/filters/transform/vsfilter/plugins.cpp +++ b/src/filters/transform/vsfilter/plugins.cpp @@ -27,7 +27,7 @@ #include "../../../subtitles/RTS.h"
#include "../../../subtitles/SSF.h"
#include "../../../SubPic/MemSubPic.h"
-#include "vfr.h"
+#include "vfr.h"
//
// Generic interface
@@ -94,7 +94,7 @@ public: return(true);
}
-
+
DWORD ThreadProc()
{
SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
@@ -161,7 +161,7 @@ public: m_hThread = 0;
- for(int i = 1; i < handles.GetCount(); i++)
+ for(ptrdiff_t i = 1; i < handles.GetCount(); i++)
FindCloseChangeNotification(handles[i]);
return 0;
@@ -235,14 +235,16 @@ public: }
};
+#ifndef WIN64
//
-// VirtualDub interface
+// old VirtualDub interface
//
namespace VirtualDub
{
- #include <VirtualDub/VirtualDub.h>
-
+ #include <VirtualDub\VirtualDub.h>
+ //#include <vd2\OldFilterSDK\VirtualDub.h>
+ //#include <vd2\extras\FilterSDK\VirtualDub.h>
class CVirtualDubFilter : virtual public CFilter
{
public:
@@ -322,13 +324,13 @@ namespace VirtualDub const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
- formats, CWnd::FromHandle(hwnd), OPENFILENAME_SIZE_VERSION_400 /*0*/);
-
- UINT CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+ formats, CWnd::FromHandle(hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0* /);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
fd.m_pOFN->hInstance = AfxGetResourceHandle();
fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
- fd.m_pOFN->lpfnHook = OpenHookProc;
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
if(fd.DoModal() != IDOK) return 1;
@@ -456,7 +458,11 @@ namespace VirtualDub struct FilterDefinition filterDef_textsub =
{
NULL, NULL, NULL, // next, prev, module
+#ifdef _VSMOD
+ "TextSubMod", // name
+#else
"TextSub", // name
+#endif
"Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
"Gabest", // maker
NULL, // private_data
@@ -493,15 +499,286 @@ namespace VirtualDub ff->removeFilter(fd_textsub);
ff->removeFilter(fd_vobsub);
}
-}
+}/**/
+#else
+//
+// VirtualDub new plugin interface sdk 1.1
+//
+namespace VirtualDubNew
+{
+ #include <vd2/plugin/vdplugin.h>
+ #include <vd2/plugin/vdvideofilt.h>
+
+ class CVirtualDubFilter : virtual public CFilter
+ {
+ public:
+ CVirtualDubFilter() {}
+ virtual ~CVirtualDubFilter() {}
+
+ virtual int RunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ SubPicDesc dst;
+ dst.type = MSP_RGB32;
+ dst.w = fa->src.w;
+ dst.h = fa->src.h;
+ dst.bpp = 32;
+ dst.pitch = fa->src.pitch;
+ dst.bits = (LPVOID)fa->src.data;
+
+ Render(dst, 10000i64*fa->pfsi->lSourceFrameMS, (float)1000 / fa->pfsi->lMicrosecsPerFrame);
+
+ return 0;
+ }
+
+ virtual long ParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ fa->dst.offset = fa->src.offset;
+ fa->dst.modulo = fa->src.modulo;
+ fa->dst.pitch = fa->src.pitch;
+
+ return 0;
+ }
+
+ virtual int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) = 0;
+ virtual void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) = 0;
+ virtual bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) = 0;
+ };
+
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
+
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle((HWND)hwnd), 0);
+
+ if(fd.DoModal() != IDOK) return 1;
+
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
+
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
+
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
+
+ class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
+ : CTextSubFilter(fn, CharSet) {}
+
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
+
+ /* off encoding changing */
+#ifndef _DEBUG
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLETEMPLATE|OFN_ENABLEHOOK,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+ //OPENFILENAME_SIZE_VERSION_400 /*0*/);
+ UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+
+ fd.m_pOFN->hInstance = AfxGetResourceHandle();
+ fd.m_pOFN->lpTemplateName = MAKEINTRESOURCE(IDD_TEXTSUBOPENTEMPLATE);
+ fd.m_pOFN->lpfnHook = (LPOFNHOOKPROC)OpenHookProc;
+ fd.m_pOFN->lCustData = (LPARAM)DEFAULT_CHARSET;
+#else
+ const TCHAR formats[] = _T("TextSub files (*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt)|*.sub;*.srt;*.smi;*.ssa;*.ass;*.xss;*.psb;*.txt||");
+ CFileDialog fd(TRUE, NULL, GetFileName(), OFN_ENABLESIZING|OFN_HIDEREADONLY,
+ formats, CWnd::FromHandle((HWND)hwnd), sizeof(OPENFILENAME));
+#endif
+ if(fd.DoModal() != IDOK) return 1;
+
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
+
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ else sprintf(str, " (empty)");
+ }
+
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
+
+ int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
+ }
+
+ int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
+ }
+
+ void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) delete f, f = NULL;
+ }
+
+ int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
+
+ long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
+
+ int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
+
+ void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) f->StringProc(fa, ff, str);
+ }
+
+ bool baseFssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->FssProc(fa, ff, buf, buflen) : false;
+ }
+
+ void vobsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) delete f;
+ f = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ void textsubScriptConfig(IVDXScriptInterpreter* isi, void* lpVoid, VDXScriptValue* argv, int argc)
+ {
+ VDXFilterActivation* fa = (VDXFilterActivation*)lpVoid;
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) delete f;
+ f = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
+
+ VDXScriptFunctionDef vobsub_func_defs[]={
+ { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
+ { NULL },
+ };
+
+ VDXScriptObject vobsub_obj={
+ NULL, vobsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_vobsub =
+ {
+ NULL, NULL, NULL, // next, prev, module
+ "VobSub", // name
+ "Adds subtitles from a vob sequence.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ vobsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &vobsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ VDXScriptFunctionDef textsub_func_defs[]={
+ { (VDXScriptFunctionPtr)textsubScriptConfig, "Config", "0si" },
+ { NULL },
+ };
+
+ VDXScriptObject textsub_obj={
+ NULL, textsub_func_defs
+ };
+
+ struct VDXFilterDefinition filterDef_textsub =
+ {
+ NULL, NULL, NULL, // next, prev, module
+#ifdef _VSMOD
+ "TextSubMod", // name
+#else
+ "TextSub", // name
+#endif
+ "Adds subtitles from srt, sub, psb, smi, ssa, ass file formats.", // desc
+ "Gabest", // maker
+ NULL, // private_data
+ sizeof(CVirtualDubFilter**), // inst_data_size
+ textsubInitProc, // initProc
+ baseDeinitProc, // deinitProc
+ baseRunProc, // runProc
+ baseParamProc, // paramProc
+ baseConfigProc, // configProc
+ baseStringProc, // stringProc
+ NULL, // startProc
+ NULL, // endProc
+ &textsub_obj, // script_obj
+ baseFssProc, // fssProc
+ };
+
+ static VDXFilterDefinition* fd_vobsub;
+ static VDXFilterDefinition* fd_textsub;
+
+ extern "C" __declspec(dllexport) int __cdecl VirtualdubFilterModuleInit2(VDXFilterModule *fm, const VDXFilterFunctions *ff, int& vdfd_ver, int& vdfd_compat)
+ {
+ if(!(fd_vobsub = ff->addFilter(fm, &filterDef_vobsub, sizeof(VDXFilterDefinition)))
+ || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))))
+ return 1;
+
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+
+ return 0;
+ }
+
+ extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
+ {
+ ff->removeFilter(fd_textsub);
+ ff->removeFilter(fd_vobsub);
+ }
+}
+#endif
//
// Avisynth interface
//
namespace AviSynth1
{
- #include <avisynth/avisynth1.h>
+ #include <avisynth\avisynth1.h>
class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
{
@@ -559,7 +836,11 @@ namespace AviSynth1 , CAvisynthFilter(c, env)
{
if(!m_pSubPicProvider)
+#ifdef _VSMOD
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+#else
env->ThrowError("TextSub: Can't open \"%s\"", fn);
+#endif
}
};
@@ -604,10 +885,17 @@ namespace AviSynth1 extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
{
env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+#ifdef _VSMOD
+ env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
+#else
env->AddFunction("TextSub", "cs", TextSubCreateS, 0);
env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
+#endif
env->SetVar(env->SaveString("RGBA"),false);
return(NULL);
}
@@ -615,16 +903,16 @@ namespace AviSynth1 namespace AviSynth25
{
- #include <avisynth/avisynth25.h>
+ #include <avisynth\avisynth25.h>
static bool s_fSwapUV = false;
class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
{
+ public:
VFRTranslator *vfr;
- public:
- CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+ CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env)
{
@@ -649,12 +937,14 @@ namespace AviSynth25 /*vi.IsIYUV()*/ vi.pixel_type == VideoInfo::CS_IYUV ? (s_fSwapUV?MSP_YV12:MSP_IYUV) :
-1;
- REFERENCE_TIME timestamp;
float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
- if (!vfr)
- timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
- else
- timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
+
+ REFERENCE_TIME timestamp;
+
+ if (!vfr)
+ timestamp = (REFERENCE_TIME)(10000000i64 * n / fps);
+ else
+ timestamp = (REFERENCE_TIME)(10000000 * vfr->TimeStampFromFrameNumber(n));
Render(dst, timestamp, fps);
@@ -682,31 +972,38 @@ namespace AviSynth25 class CTextSubAvisynthFilter : public CTextSubFilter, public CAvisynthFilter
{
public:
- CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0)
+ CTextSubAvisynthFilter(PClip c, IScriptEnvironment* env, const char* fn, int CharSet = DEFAULT_CHARSET, float fps = -1, VFRTranslator *vfr = 0) //vfr patch
: CTextSubFilter(CString(fn), CharSet, fps)
, CAvisynthFilter(c, env, vfr)
{
if(!m_pSubPicProvider)
+#ifdef _VSMOD
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+#else
env->ThrowError("TextSub: Can't open \"%s\"", fn);
+#endif
}
};
- AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
- {
+ AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
if (!args[1].Defined())
- env->ThrowError("TextSub: You must specify a subtitle file to use");
-
- VFRTranslator *vfr = 0;
- if (args[4].Defined())
- vfr = GetVFRTranslator(args[4].AsString());
-
- return(new CTextSubAvisynthFilter(
- args[0].AsClip(),
- env,
- args[1].AsString(),
- args[2].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
+#ifdef _VSMOD
+ env->ThrowError("TextSubMod: You must specify a subtitle file to use");
+#else
+ env->ThrowError("TextSub: You must specify a subtitle file to use");
+#endif
+ VFRTranslator *vfr = 0;
+ if (args[4].Defined())
+ vfr = GetVFRTranslator(args[4].AsString());
+
+ return(new CTextSubAvisynthFilter(
+ args[0].AsClip(),
+ env,
+ args[1].AsString(),
+ args[2].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
}
AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
@@ -715,24 +1012,30 @@ namespace AviSynth25 return(AVSValue());
}
- AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)
+ AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
{
if (!args[0].Defined())
+#ifdef _VSMOD
+ env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
+#else
env->ThrowError("MaskSub: You must specify a subtitle file to use");
-
+#endif
if (!args[3].Defined() && !args[6].Defined())
- env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
-
- VFRTranslator *vfr = 0;
- if (args[6].Defined())
+#ifdef _VSMOD
+ env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
+#else
+ env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
+#endif
+ VFRTranslator *vfr = 0;
+ if (args[6].Defined())
vfr = GetVFRTranslator(args[6].AsString());
AVSValue rgb32("RGB32");
- AVSValue fps(args[3].AsFloat(25));
+ AVSValue fps(args[3].AsFloat(25));
AVSValue tab[6] = {
args[1],
args[2],
- fps,
+ args[3],
args[4],
rgb32
};
@@ -744,25 +1047,30 @@ namespace AviSynth25 "length",
"pixel_type"
};
-
AVSValue clip(env->Invoke("Blackness",value,nom));
env->SetVar(env->SaveString("RGBA"),true);
-
- return(new CTextSubAvisynthFilter(
- clip.AsClip(),
- env,
- args[0].AsString(),
- args[5].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
+ //return(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ return(new CTextSubAvisynthFilter(
+ clip.AsClip(),
+ env,
+ args[0].AsString(),
+ args[5].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
}
extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
{
env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
- env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+#ifdef _VSMOD
+ env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+#else
+ env->AddFunction("TextSub", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
env->AddFunction("TextSubSwapUV", "b", TextSubSwapUV, 0);
env->AddFunction("MaskSub", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+#endif
env->SetVar(env->SaveString("RGBA"),false);
return(NULL);
}
@@ -770,7 +1078,7 @@ namespace AviSynth25 }
-UINT CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
+UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam)
{
switch(uiMsg)
{
@@ -788,9 +1096,13 @@ UINT CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG:
{
- SetWindowLong(hDlg, GWL_USERDATA, lParam);
+#ifdef WIN64
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+#else
+ SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
+#endif
- for(int i = 0; i < CharSetLen; i++)
+ for(ptrdiff_t i = 0; i < CharSetLen; i++)
{
CString s;
s.Format(_T("%s (%d)"), CharSetNames[i], CharSetList[i]);
diff --git a/src/filters/transform/vsfilter/valami.cpp b/src/filters/transform/vsfilter/valami.cpp index 4ebc21c84..660feaff0 100644 --- a/src/filters/transform/vsfilter/valami.cpp +++ b/src/filters/transform/vsfilter/valami.cpp @@ -138,7 +138,7 @@ void JajDeGonoszVagyok() DWORD mymerit = sudFilter[1].dwMerit;
- for(int i = 0; i < LEN1; i++)
+ for(ptrdiff_t i = 0; i < LEN1; i++)
{
HKEY hKey;
@@ -155,7 +155,7 @@ void JajDeGonoszVagyok() {
DWORD merit = *((DWORD*)(pData+4));
- if(merit < 0xffffffff) merit++;
+ if(merit < size_t(-1)) merit++;
if(mymerit < merit)
mymerit = merit;
@@ -213,7 +213,7 @@ bool HmGyanusVagyTeNekem(IPin* pPin) bool fFail = false;
- for(int i = 0; i < 3 && !fFail; i++)
+ for(ptrdiff_t i = 0; i < 3 && !fFail; i++)
{
BYTE* pData = NULL;
DWORD size = 0;
diff --git a/src/subtitles/CCDecoder.cpp b/src/subtitles/CCDecoder.cpp index 8ff68b5d2..47367d62a 100644 --- a/src/subtitles/CCDecoder.cpp +++ b/src/subtitles/CCDecoder.cpp @@ -72,11 +72,11 @@ void CCDecoder::SaveDisp(__int64 time) {
CStringW str;
- for(int row = 0; row < 16; row++)
+ for(ptrdiff_t row = 0; row < 16; row++)
{
bool fNonEmptyRow = false;
- for(int col = 0; col < 32; col++)
+ for(ptrdiff_t col = 0; col < 32; col++)
{
if(m_disp[row][col])
{
@@ -108,7 +108,7 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) (int)((time/1000)%60),
(int)(time%1000));
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
_ftprintf(f, _T("%02x"), buff[i]);
if(i < len-1) _ftprintf(f, _T(" "));
@@ -119,7 +119,7 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) }
}
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
BYTE c = buff[i]&0x7f;
if(c >= 0x20)
@@ -327,7 +327,7 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time) void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time)
{
- for(int i = 0; i < len-9; i++)
+ for(ptrdiff_t i = 0; i < len-9; i++)
{
if(*(DWORD*)&buff[i] == 0xb2010000 && *(DWORD*)&buff[i+4] == 0xf8014343)
{
@@ -344,7 +344,7 @@ void CCDecoder::ExtractCC(BYTE* buff, int len, __int64 time) {
int nBytes1 = 0, nBytes2 = 0;
- for(int j = 0; j < nBytes && i < 0x800;)
+ for(ptrdiff_t j = 0; j < nBytes && i < 0x800;)
{
if(buff[i++] == 0xff)
{
diff --git a/src/subtitles/GFN.cpp b/src/subtitles/GFN.cpp index 2fbcad7d1..d42f51de4 100644 --- a/src/subtitles/GFN.cpp +++ b/src/subtitles/GFN.cpp @@ -85,7 +85,7 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& WIN32_FIND_DATA wfd, wfd2;
HANDLE hFile, hFile2;
- for(int k = 0; k < paths.GetCount(); k++)
+ for(ptrdiff_t k = 0; k < paths.GetCount(); k++)
{
CString path = paths[k];
path.Replace('\\', '/');
@@ -120,9 +120,9 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>& // TODO: use 'sl' in the next step to find files (already a nice speedup as it is now...)
if(fEmpty) continue;
- for(int j = 0; j < extlistnum; j++)
+ for(ptrdiff_t j = 0; j < extlistnum; j++)
{
- for(int i = 0; i < extsubnum; i++)
+ for(ptrdiff_t i = 0; i < extsubnum; i++)
{
if((hFile = FindFirstFile(path + title + ext[j][i], &wfd)) != INVALID_HANDLE_VALUE)
{
diff --git a/src/subtitles/RTS.cpp b/src/subtitles/RTS.cpp index 3fd54aa13..749a320f8 100644 --- a/src/subtitles/RTS.cpp +++ b/src/subtitles/RTS.cpp @@ -47,6 +47,9 @@ CMyFont::CMyFont(STSStyle& style) lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf.lfQuality = ANTIALIASED_QUALITY;
lf.lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE;
+#ifdef _VSMOD // patch m007. symbol rotating
+ lf.lfOrientation = (LONG)style.mod_fontOrient;
+#endif
if(!CreateFontIndirect(&lf))
{
@@ -152,13 +155,73 @@ void CWord::Transform(CPoint org) double cay = cos((3.1415/180)*m_style.fontAngleY);
double say = sin((3.1415/180)*m_style.fontAngleY);
- for(int i = 0; i < mPathPoints; i++)
+#ifdef _VSMOD
+ // patch m003. random text points
+ double xrnd = m_style.mod_rand.X*100;
+ double yrnd = m_style.mod_rand.Y*100;
+ double zrnd = m_style.mod_rand.Z*100;
+
+ srand(m_style.mod_rand.Seed);
+
+ // patch m008. distort
+ int xsz,ysz;
+ double dst1x,dst1y,dst2x,dst2y,dst3x,dst3y;
+ int minx = INT_MAX, miny = INT_MAX, maxx = -INT_MAX, maxy = -INT_MAX;
+
+ bool is_dist = m_style.mod_distort.enabled;
+ if (is_dist)
+ {
+ for(int i = 0; i < mPathPoints; i++)
+ {
+ if(minx > mpPathPoints[i].x) minx = mpPathPoints[i].x;
+ if(miny > mpPathPoints[i].y) miny = mpPathPoints[i].y;
+ if(maxx < mpPathPoints[i].x) maxx = mpPathPoints[i].x;
+ if(maxy < mpPathPoints[i].y) maxy = mpPathPoints[i].y;
+ }
+
+ xsz = max(maxx - minx, 0);
+ ysz = max(maxy - miny, 0);
+
+ dst1x = m_style.mod_distort.pointsx[0];
+ dst1y = m_style.mod_distort.pointsy[0];
+ dst2x = m_style.mod_distort.pointsx[1];
+ dst2y = m_style.mod_distort.pointsy[1];
+ dst3x = m_style.mod_distort.pointsx[2];
+ dst3y = m_style.mod_distort.pointsy[2];
+ }
+#endif
+
+ for(ptrdiff_t i = 0; i < mPathPoints; i++)
{
double x, y, z, xx, yy, zz;
- x = scalex * (mpPathPoints[i].x + m_style.fontShiftX * mpPathPoints[i].y) - org.x;
- y = scaley * (mpPathPoints[i].y + m_style.fontShiftY * mpPathPoints[i].x) - org.y;
+ x = mpPathPoints[i].x;
+ y = mpPathPoints[i].y;
+#ifdef _VSMOD
+ // patch m002. Z-coord
+ z = m_style.mod_z;
+
+ double u, v;
+ if (is_dist)
+ {
+ u = (x-minx) / xsz;
+ v = (y-miny) / ysz;
+
+ x = minx+(0 + (dst1x - 0)*u + (dst3x-0)*v+(0+dst2x-dst1x-dst3x)*u*v)*xsz;
+ y = miny+(0 + (dst1y - 0)*u + (dst3y-0)*v+(0+dst2y-dst1y-dst3y)*u*v)*ysz;
+ //P = P0 + (P1 - P0)u + (P3 - P0)v + (P0 + P2 - P1 - P3)uv
+ }
+#else
z = 0;
+#endif
+
+#ifdef _VSMOD // patch m003. random text points
+ x = xrnd>0 ? (xrnd-rand()%(int)(xrnd*2+1))/100.0 + x : x;
+ y = yrnd>0 ? (yrnd-rand()%(int)(yrnd*2+1))/100.0 + y : y;
+ z = zrnd>0 ? (zrnd-rand()%(int)(zrnd*2+1))/100.0 + z : z;
+#endif
+ x = scalex * (x + m_style.fontShiftX * y) - org.x;
+ y = scaley * (y + m_style.fontShiftY * x) - org.y;
xx = x*caz + y*saz;
yy = -(x*saz - y*caz);
@@ -221,7 +284,12 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend) HFONT hOldFont = SelectFont(g_hDC, font);
+#ifdef _VSMOD // patch m007. symbol rotating
+ double t = (double)m_style.mod_fontOrient * 3.1415926 / 1800;
if(m_style.fontSpacing || (long)GetVersion() < 0)
+#else
+ if(m_style.fontSpacing || (long)GetVersion() < 0)
+#endif
{
bool bFirstPath = true;
@@ -229,7 +297,11 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend) {
CSize extent;
if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {SelectFont(g_hDC, hOldFont); ASSERT(0); return;}
+#ifdef _VSMOD // patch m007. symbol rotating
+ m_width += (int)(extent.cx*abs(cos(t)) + extent.cy*abs(sin(t)) + m_style.fontSpacing);
+#else
m_width += extent.cx + (int)m_style.fontSpacing;
+#endif
}
// m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
}
@@ -237,7 +309,11 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend) {
CSize extent;
if(!GetTextExtentPoint32W(g_hDC, m_str, wcslen(str), &extent)) {SelectFont(g_hDC, hOldFont); ASSERT(0); return;}
+#ifdef _VSMOD // patch m007. symbol rotating
+ m_width += (int)(extent.cx*abs(cos(t)) + extent.cy*abs(sin(t)));
+#else
m_width += extent.cx;
+#endif
}
m_width = (int)(m_style.fontScaleX/100*m_width + 4) >> 3;
@@ -407,64 +483,7 @@ bool CPolygon::ParseStr() break;
}
}
-/*
- LPCWSTR str = m_str;
- while(*str)
- {
- while(*str && *str != 'm' && *str != 'n' && *str != 'l' && *str != 'b' && *str != 's' && *str != 'p' && *str != 'c') str++;
-
- if(!*str) break;
- switch(*str++)
- {
- case 'm':
- lastmoveto = m_pathTypesOrg.GetCount();
- if(firstmoveto == -1) firstmoveto = lastmoveto;
- while(GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_MOVETO); m_pathPointsOrg.Add(p);}
- break;
- case 'n':
- while(GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_MOVETONC); m_pathPointsOrg.Add(p);}
- break;
- case 'l':
- while(GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_LINETO); m_pathPointsOrg.Add(p);}
- break;
- case 'b':
- j = m_pathTypesOrg.GetCount();
- while(GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_BEZIERTO); m_pathPointsOrg.Add(p); j++;}
- j = m_pathTypesOrg.GetCount() - ((m_pathTypesOrg.GetCount()-j)%3);
- m_pathTypesOrg.SetCount(j); m_pathPointsOrg.SetCount(j);
- break;
- case 's':
- j = lastsplinestart = m_pathTypesOrg.GetCount();
- i = 3;
- while(i-- && GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_BSPLINETO); m_pathPointsOrg.Add(p); j++;}
- if(m_pathTypesOrg.GetCount()-lastsplinestart < 3) {m_pathTypesOrg.SetCount(lastsplinestart); m_pathPointsOrg.SetCount(lastsplinestart); lastsplinestart = -1;}
- // no break here
- case 'p':
- while(GetPOINT(str, p)) {m_pathTypesOrg.Add(PT_BSPLINEPATCHTO); m_pathPointsOrg.Add(p); j++;}
- break;
- case 'c':
- if(lastsplinestart > 0)
- {
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- m_pathTypesOrg.Add(PT_BSPLINEPATCHTO);
- p = m_pathPointsOrg[lastsplinestart-1]; // we need p for temp storage, because operator [] will return a reference to CPoint and Add() may reallocate its internal buffer (this is true for MFC 7.0 but not for 6.0, hehe)
- m_pathPointsOrg.Add(p);
- p = m_pathPointsOrg[lastsplinestart];
- m_pathPointsOrg.Add(p);
- p = m_pathPointsOrg[lastsplinestart+1];
- m_pathPointsOrg.Add(p);
- lastsplinestart = -1;
- }
- break;
- default:
- break;
- }
-
- if(firstmoveto > 0) break;
- }
-*/
if(lastmoveto == -1 || firstmoveto > 0)
{
m_pathTypesOrg.RemoveAll();
@@ -551,7 +570,7 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool while(h--)
{
- for(int wt=0; wt<w; ++wt)
+ for(ptrdiff_t wt=0; wt<w; ++wt)
dst[wt] = src[wt*2];
src += 2*mOverlayWidth;
@@ -561,7 +580,7 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool if(inverse)
{
BYTE* dst = m_pAlphaMask;
- for(int i = size.cx*size.cy; i>0; --i, ++dst)
+ for(ptrdiff_t i = size.cx*size.cy; i>0; --i, ++dst)
*dst = 0x40 - *dst; // mask is 6 bit
}
}
@@ -645,7 +664,11 @@ void CLine::Compact() }
}
+#ifdef _VSMOD // patch m006. moveable vector clip
+CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt)
+#else
CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
+#endif
{
CRect bbox(0, 0, 0, 0);
@@ -659,24 +682,46 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo if(w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0)
{
int x = p.x + (int)(w->m_style.shadowDepthX+0.5);
+#ifdef _VSMOD // patch m001. Vertical fontspacing
+ int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
+#else
int y = p.y + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
-
+#endif
DWORD a = 0xff - w->m_style.alpha[3];
if(alpha > 0) a = MulDiv(a, 0xff - alpha, 0xff);
COLORREF shadow = revcolor(w->m_style.colors[3]) | (a<<24);
- long sw[6] = {shadow, -1};
-
+ DWORD sw[6] = {shadow, -1};
+
+#ifdef _VSMOD // patch m011. jitter
+ CPoint mod_jitter = w->m_style.mod_jitter.getOffset(rt);
+ x += mod_jitter.x;
+ y += mod_jitter.y;
+ // patch m010. png background
+ // subpixel positioning
+ w->m_style.mod_grad.subpixx = x&7;
+ w->m_style.mod_grad.subpixy = y&7;
+#endif
w->Paint(CPoint(x, y), org);
if(w->m_style.borderStyle == 0)
{
+#ifdef _VSMOD // patch m004. gradient colors
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
+ w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
+ (w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0) && !(w->m_ktype == 2 && time < w->m_kstart),3,w->m_style.mod_grad, mod_vc);
+#else
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
(w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0) && !(w->m_ktype == 2 && time < w->m_kstart));
+#endif
}
else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox)
{
+#ifdef _VSMOD // patch m004. gradient colors
+ bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,3,w->m_style.mod_grad, mod_vc);
+#else
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+#endif
}
}
@@ -686,7 +731,11 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo return(bbox);
}
+#ifdef _VSMOD // patch m006. moveable vector clip
+CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt)
+#else
CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
+#endif
{
CRect bbox(0, 0, 0, 0);
@@ -700,22 +749,43 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP if(w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart))
{
int x = p.x;
+#ifdef _VSMOD // patch m001. Vertical fontspacing
+ int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent;
+#else
int y = p.y + m_ascent - w->m_ascent;
-
+#endif
DWORD aoutline = w->m_style.alpha[2];
if(alpha > 0) aoutline += MulDiv(alpha, 0xff - w->m_style.alpha[2], 0xff);
COLORREF outline = revcolor(w->m_style.colors[2]) | ((0xff-aoutline)<<24);
- long sw[6] = {outline, -1};
+ DWORD sw[6] = {outline, -1};
+
+#ifdef _VSMOD // patch m011. jitter
+ CPoint mod_jitter = w->m_style.mod_jitter.getOffset(rt);
+ x += mod_jitter.x;
+ y += mod_jitter.y;
+ // patch m010. png background
+ // subpixel positioning
+ w->m_style.mod_grad.subpixx = x&7;
+ w->m_style.mod_grad.subpixy = y&7;
+#endif
w->Paint(CPoint(x, y), org);
if(w->m_style.borderStyle == 0)
{
+#ifdef _VSMOD // patch m004. gradient colors
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true,2,w->m_style.mod_grad, mod_vc);
+#else
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true);
+#endif
}
else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox)
{
+#ifdef _VSMOD // patch m004. gradient colors
+ bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,2,w->m_style.mod_grad, mod_vc);
+#else
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+#endif
}
}
@@ -725,7 +795,11 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP return(bbox);
}
+#ifdef _VSMOD // patch m006. moveable vector clip
+CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt)
+#else
CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha)
+#endif
{
CRect bbox(0, 0, 0, 0);
@@ -737,8 +811,11 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin if(w->m_fLineBreak) return(bbox); // should not happen since this class is just a line of text without any breaks
int x = p.x;
+#ifdef _VSMOD // patch m001. Vertical fontspacing
+ int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent;
+#else
int y = p.y + m_ascent - w->m_ascent;
-
+#endif
// colors
DWORD aprimary = w->m_style.alpha[0];
@@ -749,7 +826,7 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin if(alpha > 0) asecondary += MulDiv(alpha, 0xff - w->m_style.alpha[1], 0xff);
COLORREF secondary = revcolor(w->m_style.colors[1]) | ((0xff-asecondary)<<24);
- long sw[6] = {primary, 0, secondary};
+ DWORD sw[6] = {primary, 0, secondary};
// karaoke
@@ -778,17 +855,38 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin if(t >= 1)
{
- sw[1] = 0xffffffff;
+ sw[1] = 0xFFFFFFF;
}
- sw[3] = (int)(w->m_style.outlineWidthX + t*w->m_width) >> 3;
+ // move dividerpoint
+ int bluradjust = 0;
+ if (w->m_style.fGaussianBlur > 0)
+ bluradjust += (int)(w->m_style.fGaussianBlur*3*8 + 0.5) | 1;
+ if (w->m_style.fBlur)
+ bluradjust += 8;
+ double tx = w->m_style.fontAngleZ;
sw[4] = sw[2];
sw[5] = 0x00ffffff;
+#ifdef _VSMOD // patch m011. jitter
+ CPoint mod_jitter = w->m_style.mod_jitter.getOffset(rt);
+ x += mod_jitter.x;
+ y += mod_jitter.y;
+ // patch m010. png background
+ // subpixel positioning
+ w->m_style.mod_grad.subpixx = x&7;
+ w->m_style.mod_grad.subpixy = y&7;
+#endif
+
w->Paint(CPoint(x, y), org);
- bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+ sw[3] = (int)(w->m_style.outlineWidthX + t*w->getOverlayWidth() + t*bluradjust) >> 3;
+#ifdef _VSMOD // patch m004. gradient colors
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,0,w->m_style.mod_grad, mod_vc);
+#else
+ bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false);
+#endif
p.x += w->m_width;
}
@@ -819,7 +917,7 @@ void CSubtitle::Empty() pos = m_words.GetHeadPosition();
while(pos) delete m_words.GetNext(pos);
- for(int i = 0; i < EF_NUMBEROFEFFECTS; i++) {if(m_effects[i]) delete m_effects[i];}
+ for(ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++) {if(m_effects[i]) delete m_effects[i];}
memset(m_effects, 0, sizeof(Effect*)*EF_NUMBEROFEFFECTS);
if(m_pClipper) delete m_pClipper;
@@ -982,12 +1080,12 @@ void CSubtitle::CreateClippers(CSize size) int da = (64<<8)/width;
BYTE* am = m_pClipper->m_pAlphaMask;
- for(int j = 0; j < h; j++, am += w)
+ for(ptrdiff_t j = 0; j < h; j++, am += w)
{
int a = 0;
int k = min(width, w);
- for(int i = 0; i < k; i++, a += da)
+ for(ptrdiff_t i = 0; i < k; i++, a += da)
am[i] = (am[i]*a)>>14;
a = 0x40<<8;
@@ -995,7 +1093,7 @@ void CSubtitle::CreateClippers(CSize size) if(k < 0) {a -= -k*da; k = 0;}
- for(int i = k; i < w; i++, a -= da)
+ for(ptrdiff_t i = k; i < w; i++, a -= da)
am[i] = (am[i]*a)>>14;
}
}
@@ -1026,9 +1124,9 @@ void CSubtitle::CreateClippers(CSize size) memset(m_pClipper->m_pAlphaMask, 0, am - m_pClipper->m_pAlphaMask);
- for(int j = k; j < l; j++, a += da)
+ for(ptrdiff_t j = k; j < l; j++, a += da)
{
- for(int i = 0; i < w; i++, am++)
+ for(ptrdiff_t i = 0; i < w; i++, am++)
*am = ((*am)*a)>>14;
}
}
@@ -1047,7 +1145,7 @@ void CSubtitle::CreateClippers(CSize size) int j = k;
for(; j < l; j++, a += da)
{
- for(int i = 0; i < w; i++, am++)
+ for(ptrdiff_t i = 0; i < w; i++, am++)
*am = ((*am)*a)>>14;
}
@@ -1112,7 +1210,7 @@ void CScreenLayoutAllocator::AdvanceToSegment(int segment, const CAtlArray<int>& if(abs(sr.segment - segment) <= 1) // using abs() makes it possible to play the subs backwards, too :)
{
- for(int i = 0; i < sa.GetCount() && !fFound; i++)
+ for(ptrdiff_t i = 0; i < sa.GetCount() && !fFound; i++)
{
if(sa[i] == sr.entry)
{
@@ -1186,14 +1284,17 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in // CRenderedTextSubtitle
-CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOverride, bool doOverride)
- : ISubPicProviderImpl(pLock), m_doOverrideStyle(doOverride), m_pStyleOverride(styleOverride)
+ CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOverride, bool doOverride)
+ : ISubPicProviderImpl(pLock), m_doOverrideStyle(doOverride), m_pStyleOverride(styleOverride)
{
m_size = CSize(0, 0);
if(g_hDC_refcnt == 0)
{
g_hDC = CreateCompatibleDC(NULL);
+#ifdef _VSMOD // patch m007. symbol rotating
+ SetGraphicsMode(g_hDC, GM_ADVANCED); // patch for lfOrientation
+#endif
SetBkMode(g_hDC, TRANSPARENT);
SetTextColor(g_hDC, 0xffffff);
SetMapMode(g_hDC, MM_TEXT);
@@ -1330,7 +1431,7 @@ void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle& str.Replace(L"\\n", (sub->m_wrapStyle < 2 || sub->m_wrapStyle == 3) ? L" " : L"\n");
str.Replace(L"\\h", L"\x00A0");
- for(int i = 0, j = 0, len = str.GetLength(); j <= len; j++)
+ for(size_t i = 0, j = 0, len = str.GetLength(); j <= len; j++)
{
WCHAR c = str[j];
@@ -1398,14 +1499,21 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& if(str[j] == '(')
{
CStringW param;
- for(WCHAR c = str[++j]; c && c != ')'; param += c, c = str[++j]);
+ // complex tags search
+ int br = 1; // 1 bracket
+ for(WCHAR c = str[++j];c && br>0;param += c, c = str[++j])
+ {
+ if (c=='(') br++;
+ if (c==')') br--;
+ if (br==0) break;
+ }
param.Trim();
while(!param.IsEmpty())
{
int i = param.Find(','), j = param.Find('\\');
- if(i >= 0 && (j < 0 || i < j))
+ if(i >= 0 && (j < 0 || i < j))
{
CStringW s = param.Left(i).Trim();
if(!s.IsEmpty()) params.Add(s);
@@ -1424,6 +1532,16 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
else if(!cmd.Find(L"1a") || !cmd.Find(L"2a") || !cmd.Find(L"3a") || !cmd.Find(L"4a"))
params.Add(cmd.Mid(2).Trim(L"&H")), cmd = cmd.Left(2);
+#ifdef _VSMOD // patch m010. png background
+ else if(!cmd.Find(L"1img") || !cmd.Find(L"2img") || !cmd.Find(L"3img") || !cmd.Find(L"4img"))
+ ;//params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+#endif
+#ifdef _VSMOD // patch m004. gradient colors
+ else if(!cmd.Find(L"1vc") || !cmd.Find(L"2vc") || !cmd.Find(L"3vc") || !cmd.Find(L"4vc"))
+ ;//params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ else if(!cmd.Find(L"1va") || !cmd.Find(L"2va") || !cmd.Find(L"3va") || !cmd.Find(L"4va"))
+ ;//params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+#endif
else if(!cmd.Find(L"alpha"))
params.Add(cmd.Mid(5).Trim(L"&H")), cmd = cmd.Left(5);
else if(!cmd.Find(L"an"))
@@ -1442,6 +1560,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ;
else if(!cmd.Find(L"c"))
params.Add(cmd.Mid(1).Trim(L"&H")), cmd = cmd.Left(1);
+#ifdef _VSMOD // patch m008. distort
+ else if(!cmd.Find(L"distort"))
+ ;
+#endif
else if(!cmd.Find(L"fade"))
;
else if(!cmd.Find(L"fe"))
@@ -1450,6 +1572,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
else if(!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz"))
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+#ifdef _VSMOD // patch m007. symbol rotating
+ else if(!cmd.Find(L"frs"))
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+#endif
else if(!cmd.Find(L"fax") || !cmd.Find(L"fay"))
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
else if(!cmd.Find(L"fr"))
@@ -1460,16 +1586,36 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
else if(!cmd.Find(L"fsp"))
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+#ifdef _VSMOD// patch m001. Vertical fontspacing
+ else if(!cmd.Find(L"fsvp"))
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+#endif
else if(!cmd.Find(L"fs"))
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
else if(!cmd.Find(L"iclip"))
;
else if(!cmd.Find(L"i"))
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+#ifdef _VSMOD // patch m011. jitter
+ else if(!cmd.Find(L"jitter"))
+ ;
+#endif
else if(!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko"))
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
else if(!cmd.Find(L"k") || !cmd.Find(L"K"))
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+#ifdef _VSMOD // patch m005. add some move types
+ else if(!cmd.Find(L"mover")) // radial move
+ ;
+ else if(!cmd.Find(L"moves3")) // square spline
+ ;
+ else if(!cmd.Find(L"moves4")) // cubic spline
+ ;
+#endif
+#ifdef _VSMOD // patch m006. moveable vector clip
+ else if(!cmd.Find(L"movevc"))
+ ;
+#endif
else if(!cmd.Find(L"move"))
;
else if(!cmd.Find(L"org"))
@@ -1482,6 +1628,12 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
else if(!cmd.Find(L"q"))
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+#ifdef _VSMOD // patch m003. random text points
+ else if(!cmd.Find(L"rndx") || !cmd.Find(L"rndy") || !cmd.Find(L"rndz") || !cmd.Find(L"rnds"))
+ params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ else if(!cmd.Find(L"rnd"))
+ params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+#endif
else if(!cmd.Find(L"r"))
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
else if(!cmd.Find(L"shad"))
@@ -1500,6 +1652,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
else if(!cmd.Find(L"yshad"))
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+#ifdef _VSMOD // patch m002. Z-coord
+ else if(!cmd.Find(L"z"))
+ params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+#endif
else
nUnrecognizedTags++;
@@ -1519,22 +1675,211 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& |((int)CalcAnimation(c&0xff00, style.colors[i]&0xff00, fAnimate))&0xff00
|((int)CalcAnimation(c&0xff0000, style.colors[i]&0xff0000, fAnimate))&0xff0000)
: org.colors[i];
+#ifdef _VSMOD // patch m004. gradient colors
+ style.mod_grad.colors[i] = style.colors[i];
+ if (!fAnimate)
+ {
+ style.mod_grad.mode[i] = 0;
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.color[i][j] = !p.IsEmpty()
+ ? ((int)c&0xff
+ |(int)c&0xff00
+ |(int)c&0xff0000)
+ : org.mod_grad.color[i][j];
+ }
+ }
+ else if(style.mod_grad.mode[i] != 0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.color[i][j] = !p.IsEmpty()
+ ? (((int)CalcAnimation(c&0xff, style.mod_grad.color[i][j]&0xff, fAnimate))&0xff
+ |((int)CalcAnimation(c&0xff00, style.mod_grad.color[i][j]&0xff00, fAnimate))&0xff00
+ |((int)CalcAnimation(c&0xff0000, style.mod_grad.color[i][j]&0xff0000, fAnimate))&0xff0000)
+ : org.colors[i];
+ }
+ }
+#endif
}
else if(cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a")
{
+ DWORD al = wcstol(p, NULL, 16)&0xff;
int i = cmd[0] - '1';
style.alpha[i] = !p.IsEmpty()
- ? (BYTE)CalcAnimation(wcstol(p, NULL, 16), style.alpha[i], fAnimate)
+ ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
: org.alpha[i];
+#ifdef _VSMOD // patch m004. gradient colors
+ style.mod_grad.alphas[i] = style.alpha[i];
+ style.mod_grad.b_images[i].alpha = 255-style.alpha[i];
+ if (!fAnimate)
+ {
+ //style.mod_grad.mode[i] = 0;
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.alpha[i][j] = !p.IsEmpty()
+ ? al
+ : org.mod_grad.alpha[i][j];
+ }
+ }
+ else if (style.mod_grad.mode[i] != 0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.alpha[i][j] = !p.IsEmpty()
+ ? (((int)CalcAnimation(al, style.mod_grad.alpha[i][j], fAnimate)))
+ : org.alpha[i];
+ }
+ }
+#endif
}
+#ifdef _VSMOD // patch m010. png background
+ else if(cmd == L"1img" || cmd == L"2img" || cmd == L"3img" || cmd == L"4img")
+ {
+ int i = cmd[0] - '1';
+
+ if(params.GetCount() >= 1)// file[,xoffset,yoffset]
+ {
+ if (!fAnimate)
+ {
+ CString fpath = m_path.Left(m_path.ReverseFind('\\')+1);
+ bool t_init = false;
+ // buffer
+ for(ptrdiff_t k = 0, j = mod_images.GetCount(); k < j; k++)
+ {
+ MOD_PNGIMAGE t_temp = mod_images[k];
+ if(t_temp.filename==params[0]) // found buffered image
+ {
+
+ style.mod_grad.b_images[i] = t_temp;
+ t_init = true;
+ break;
+ }
+ if(t_temp.filename==fpath+params[0]) // found buffered image
+ {
+ style.mod_grad.b_images[i] = t_temp;
+ t_init = true;
+ break;
+ }
+ }
+ if(t_init)
+ {
+ style.mod_grad.mode[i] = 2;
+ }
+ else
+ {
+ // not found
+ MOD_PNGIMAGE t_temp;
+ if(t_temp.initImage(params[0])) // absolute path or default directory
+ {
+ style.mod_grad.mode[i] = 2;
+ style.mod_grad.b_images[i] = t_temp;
+ mod_images.Add(t_temp);
+ }
+ else if(t_temp.initImage(fpath+params[0])) // path + relative path
+ {
+ style.mod_grad.mode[i] = 2;
+ style.mod_grad.b_images[i] = t_temp;
+ mod_images.Add(t_temp);
+ }
+ }
+ }
+ if(params.GetCount() >= 3)
+ {
+ style.mod_grad.b_images[i].xoffset = !p.IsEmpty()
+ ? (BYTE)CalcAnimation(wcstol(params[1], NULL, 10), style.mod_grad.b_images[i].xoffset, fAnimate)
+ : org.mod_grad.b_images[i].xoffset;
+ style.mod_grad.b_images[i].yoffset = !p.IsEmpty()
+ ? (BYTE)CalcAnimation(wcstol(params[2], NULL, 10), style.mod_grad.b_images[i].yoffset, fAnimate)
+ : org.mod_grad.b_images[i].yoffset;
+ }
+ }
+ }
+#endif
+#ifdef _VSMOD // patch m004. gradient colors
+ else if(cmd == L"1vc" || cmd == L"2vc" || cmd == L"3vc" || cmd == L"4vc")
+ {
+ int i = cmd[0] - '1';
+
+ if(params.GetCount() >= 4)
+ {
+ DWORD c;
+ for (int j=0;j<4;j++)
+ {
+ c = wcstol(params[j].Trim(L"&H"), NULL, 16);
+ style.mod_grad.color[i][j] = !p.IsEmpty()
+ ? (((int)CalcAnimation(c&0xff, style.mod_grad.color[i][j]&0xff, fAnimate))&0xff
+ |((int)CalcAnimation(c&0xff00, style.mod_grad.color[i][j]&0xff00, fAnimate))&0xff00
+ |((int)CalcAnimation(c&0xff0000, style.mod_grad.color[i][j]&0xff0000, fAnimate))&0xff0000)
+ : org.mod_grad.color[i][j];
+ }
+ if (style.mod_grad.mode[i]==0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.alpha[i][j] = style.alpha[i];
+ }
+ }
+ if (!fAnimate) style.mod_grad.mode[i] = 1;
+ }
+ }
+ else if(cmd == L"1va" || cmd == L"2va" || cmd == L"3va" || cmd == L"4va")
+ {
+ int i = cmd[0] - '1';
+
+ if(params.GetCount() >= 4)
+ {
+ int a;
+ for (int j=0;j<4;j++)
+ {
+ a = wcstol(params[j].Trim(L"&H"), NULL, 16);
+ style.mod_grad.alpha[i][j] = !p.IsEmpty()
+ ? (int)CalcAnimation(a, style.mod_grad.alpha[i][j], fAnimate) : org.mod_grad.alpha[i][j];
+ }
+ if (style.mod_grad.mode[i]==0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.color[i][j] = style.colors[i];
+ }
+ }
+ if (!fAnimate) style.mod_grad.mode[i] = 1;
+ }
+ }
+#endif
else if(cmd == L"alpha")
{
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
+ DWORD al = wcstol(p, NULL, 16)&0xff;
style.alpha[i] = !p.IsEmpty()
- ? (BYTE)CalcAnimation(wcstol(p, NULL, 16), style.alpha[i], fAnimate)
+ ? (BYTE)CalcAnimation(al, style.alpha[i], fAnimate)
: org.alpha[i];
+#ifdef _VSMOD // patch m004. gradient colors
+ style.mod_grad.alphas[i] = style.alpha[i];
+ if (!fAnimate)
+ {
+ //style.mod_grad.mode[i] = 0;
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.alpha[i][j] = !p.IsEmpty()
+ ? al
+ : org.mod_grad.alpha[i][j];
+ style.mod_grad.b_images[i].alpha = 255-al;
+ }
+ }
+ else if(style.mod_grad.mode[i] != 0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.alpha[i][j] = !p.IsEmpty()
+ ? (((int)CalcAnimation(al, style.mod_grad.alpha[i][j], fAnimate)))
+ : org.alpha[i];
+ style.mod_grad.b_images[i].alpha = 255-style.alpha[i];
+ }
+ }
+#endif
}
}
else if(cmd == L"an")
@@ -1630,20 +1975,68 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& |((int)CalcAnimation(c&0xff00, style.colors[0]&0xff00, fAnimate))&0xff00
|((int)CalcAnimation(c&0xff0000, style.colors[0]&0xff0000, fAnimate))&0xff0000)
: org.colors[0];
+#ifdef _VSMOD // patch m004. gradient colors
+ style.mod_grad.colors[0] = style.colors[0];
+ if (!fAnimate)
+ {
+ style.mod_grad.mode[0] = 0;
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.color[0][j] = !p.IsEmpty()
+ ? ((int)c&0xff
+ |(int)c&0xff00
+ |(int)c&0xff0000)
+ : org.mod_grad.color[0][j];
+ }
+ }
+ else if (style.mod_grad.mode[0] != 0)
+ {
+ for (int j=0;j<4;j++)
+ {
+ style.mod_grad.color[0][j] = !p.IsEmpty()
+ ? (((int)CalcAnimation(c&0xff, style.mod_grad.color[0][j]&0xff, fAnimate))&0xff
+ |((int)CalcAnimation(c&0xff00, style.mod_grad.color[0][j]&0xff00, fAnimate))&0xff00
+ |((int)CalcAnimation(c&0xff0000, style.mod_grad.color[0][j]&0xff0000, fAnimate))&0xff0000)
+ : org.colors[0];
+ }
+ }
+#endif
+ }
+#ifdef _VSMOD // patch m008. distort
+ else if(cmd == L"distort")
+ {
+ if(params.GetCount() >= 6)
+ {
+ DWORD c;
+ for (int j=0;j<3;j++)
+ {
+ style.mod_distort.pointsx[j] = !p.IsEmpty()
+ ? (CalcAnimation(wcstod(params[j*2], NULL), style.mod_distort.pointsx[j], fAnimate))
+ : org.mod_distort.pointsx[j];
+ style.mod_distort.pointsy[j] = !p.IsEmpty()
+ ? (CalcAnimation(wcstod(params[j*2+1], NULL), style.mod_distort.pointsy[j], fAnimate))
+ : org.mod_distort.pointsy[j];
+ }
+ style.mod_distort.enabled = true;
+ }
}
+#endif
else if(cmd == L"fade" || cmd == L"fad")
{
if(params.GetCount() == 7 && !sub->m_effects[EF_FADE])// {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])
{
if(Effect* e = DNew Effect)
{
- for(int i = 0; i < 3; i++)
+ for(ptrdiff_t i = 0; i < 3; i++)
e->param[i] = wcstol(params[i], NULL, 10);
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
e->t[i] = wcstol(params[3+i], NULL, 10);
sub->m_effects[EF_FADE] = e;
}
+//#ifdef _VSMOD // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+//#endif
}
else if(params.GetCount() == 2 && !sub->m_effects[EF_FADE]) // {\fad(t1=t[1], t2=t[2])
{
@@ -1651,12 +2044,15 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& {
e->param[0] = e->param[2] = 0xff;
e->param[1] = 0x00;
- for(int i = 1; i < 3; i++)
+ for(ptrdiff_t i = 1; i < 3; i++)
e->t[i] = wcstol(params[i-1], NULL, 10);
e->t[0] = e->t[3] = -1; // will be substituted with "start" and "end"
sub->m_effects[EF_FADE] = e;
}
+#ifdef _VSMOD // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+#endif
}
}
else if(cmd == L"fax")
@@ -1684,6 +2080,16 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? CString(p).Trim()
: org.fontName;
}
+#ifdef _VSMOD // patch m007. symbol rotating
+ else if(cmd == L"frs")
+ {
+ double dst = wcstod(p, NULL)*10;
+
+ style.mod_fontOrient = !p.IsEmpty()
+ ? CalcAnimation(dst, style.mod_fontOrient, fAnimate)
+ : org.mod_fontOrient;
+ }
+#endif
else if(cmd == L"frx")
{
style.fontAngleX = !p.IsEmpty()
@@ -1718,8 +2124,20 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& }
else if(cmd == L"fsc")
{
+#ifdef _VSMOD // patch f004. \fsc(%f) is working
+ double dst = wcstod(p, NULL);
+ double nx = CalcAnimation(dst, style.fontScaleX, fAnimate);
+ style.fontScaleX = !p.IsEmpty()
+ ? (nx < 0 ? 0 : nx)
+ : org.fontScaleX;
+ double ny = CalcAnimation(dst, style.fontScaleY, fAnimate);
+ style.fontScaleY = !p.IsEmpty()
+ ? (ny < 0 ? 0 : ny)
+ : org.fontScaleY;
+#else
style.fontScaleX = org.fontScaleX;
style.fontScaleY = org.fontScaleY;
+#endif
}
else if(cmd == L"fsp")
{
@@ -1727,6 +2145,14 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? CalcAnimation(wcstod(p, NULL), style.fontSpacing, fAnimate)
: org.fontSpacing;
}
+#ifdef _VSMOD // patch m001. Vertical fontspacing
+ else if(cmd == L"fsvp")
+ {
+ double dst = wcstod(p, NULL)*8;
+ double nx = CalcAnimation(dst, style.mod_verticalSpace, fAnimate);
+ style.mod_verticalSpace = !p.IsEmpty() ? nx : org.mod_verticalSpace;
+ }
+#endif
else if(cmd == L"fs")
{
if(!p.IsEmpty())
@@ -1754,6 +2180,35 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? (n == 0 ? false : n == 1 ? true : org.fItalic)
: org.fItalic;
}
+#ifdef _VSMOD // patch m011. jitter
+ else if(cmd == L"jitter") // {\jitter(left,right,up,down,period,[seed])}
+ {
+ if((params.GetCount() >= 4))
+ {
+ int left = (int)abs(wcstol(params[0], NULL,10))*8;
+ int right = (int)abs(wcstol(params[1], NULL,10))*8;
+ int up = (int)abs(wcstol(params[2], NULL,10))*8;
+ int down = (int)abs(wcstol(params[3], NULL,10))*8;
+ style.mod_jitter.offset.top = CalcAnimation(up, style.mod_jitter.offset.top, fAnimate);
+ style.mod_jitter.offset.bottom = CalcAnimation(down, style.mod_jitter.offset.bottom, fAnimate);
+ style.mod_jitter.offset.left = CalcAnimation(left, style.mod_jitter.offset.left, fAnimate);
+ style.mod_jitter.offset.right = CalcAnimation(right, style.mod_jitter.offset.right, fAnimate);
+ style.mod_jitter.enabled = true;
+
+ if(params.GetCount() >= 5)
+ {
+ int period = wcstol(params[4], NULL, 10) * 10000;
+ style.mod_jitter.period = CalcAnimation(period, style.mod_jitter.period, fAnimate);
+ if(params.GetCount() >= 6)
+ {
+ style.mod_jitter.seed = wcstol(params[5], NULL, 10);
+ }
+ }
+ // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+ }
+ }
+#endif
else if(cmd == L"kt")
{
m_kstart = !p.IsEmpty()
@@ -1768,6 +2223,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& m_kend += !p.IsEmpty()
? wcstol(p, NULL, 10)*10
: 1000;
+//#ifdef _VSMOD // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+//#endif
}
else if(cmd == L"ko")
{
@@ -1776,6 +2234,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& m_kend += !p.IsEmpty()
? wcstol(p, NULL, 10)*10
: 1000;
+//#ifdef _VSMOD // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+//#endif
}
else if(cmd == L"k")
{
@@ -1785,31 +2246,177 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? wcstol(p, NULL, 10)*10
: 1000;
}
+#ifdef _VSMOD // patch m005. add some move types
+ else if(cmd == L"mover") // {\mover(x1,x2,x2,y2,alp1,alp2,r1,r2,t1,t2)}
+ {
+ if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE])
+ {
+ if(Effect* e = new Effect)
+ {
+ e->param[0] = 1; // ðàäèàëüíûé ìîâ
+ e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
+ e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
+ e->param[3] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8); // x2
+ e->param[4] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8); // y2
+ e->param[5] = (int)(wcstod(params[4], NULL)*10000); // alp1
+ e->param[6] = (int)(wcstod(params[5], NULL)*10000); // alp2
+ e->param[7] = (int)(sub->m_scalex*wcstod(params[6], NULL)*8); // r1
+ e->param[8] = (int)(sub->m_scaley*wcstod(params[7], NULL)*8); // r2
+
+ e->t[0] = e->t[1] = -1;
+
+ if(params.GetCount() == 10)
+ {
+ for(int i = 0; i < 2; i++)
+ e->t[i] = wcstol(params[8+i], NULL, 10);
+ }
+ sub->m_effects[EF_MOVE] = e;
+ }
+ // patch f005. don't cache animated
+// sub->m_fAnimated = true;
+ }
+ }
+ else if(cmd == L"moves3") // {\moves3(x1,x2,x2,y2,x3,y3[,t1,t2])}
+ {
+ if((params.GetCount() == 6 || params.GetCount() == 8) && !sub->m_effects[EF_MOVE])
+ {
+ if(Effect* e = new Effect)
+ {
+ e->param[0] = 2; // square spline
+ e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
+ e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
+ e->param[3] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8); // x2
+ e->param[4] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8); // y2
+ e->param[5] = (int)(sub->m_scalex*wcstod(params[4], NULL)*8); // x3
+ e->param[6] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8); // y3
+ e->t[0] = e->t[1] = -1;
+
+ if(params.GetCount() == 8)
+ {
+ for(int i = 0; i < 2; i++)
+ e->t[i] = wcstol(params[6+i], NULL, 10);
+ }
+ sub->m_effects[EF_MOVE] = e;
+ }
+ // patch f005. don't cache animated
+// sub->m_fAnimated = true;
+ }
+ }
+ else if(cmd == L"moves4") // {\moves4(x1,x2,x2,y2,x3,y3,x4,y4[,t1,t2])}
+ {
+ if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE])
+ {
+ if(Effect* e = new Effect)
+ {
+ e->param[0] = 3; // cubic spline
+ e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
+ e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
+ e->param[3] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8); // x2
+ e->param[4] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8); // y2
+ e->param[5] = (int)(sub->m_scalex*wcstod(params[4], NULL)*8); // x3
+ e->param[6] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8); // y3
+ e->param[7] = (int)(sub->m_scalex*wcstod(params[6], NULL)*8); // x4
+ e->param[8] = (int)(sub->m_scaley*wcstod(params[7], NULL)*8); // y4
+ e->t[0] = e->t[1] = -1;
+
+ if(params.GetCount() == 10)
+ {
+ for(int i = 0; i < 2; i++)
+ e->t[i] = wcstol(params[8+i], NULL, 10);
+ }
+ sub->m_effects[EF_MOVE] = e;
+ }
+ // patch f005. don't cache animated
+// sub->m_fAnimated = true;
+ }
+ }
+#endif
+#ifdef _VSMOD // patch m006. moveable vector clip
+ else if(cmd == L"movevc")
+ {
+ if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_VECTCLP])
+ {
+ if(Effect* e = new Effect)
+ {
+ e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL));
+ e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL));
+ e->t[0] = e->t[1] = -1;
+
+ if(params.GetCount() >= 4)
+ {
+ e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL));
+ e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL));
+ }
+ if(params.GetCount() == 6)
+ {
+ e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL));
+ e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL));
+ }
+ sub->m_effects[EF_VECTCLP] = e;
+ }
+ // patch f005. don't cache animated
+ sub->m_fAnimated = true;
+ }
+ }
+#endif
else if(cmd == L"move") // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3][, t1=t[0], t2=t[1]])}
{
if((params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_MOVE])
{
if(Effect* e = DNew Effect)
{
+#ifdef _VSMOD // patch m005. add some move types
+ e->param[0] = 0; // îáû÷íûé ìîâ
+ e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
+ e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
+ e->param[3] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8);
+ e->param[4] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8);
+#else
e->param[0] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
e->param[1] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8);
e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8);
-
+#endif
e->t[0] = e->t[1] = -1;
if(params.GetCount() == 6)
{
- for(int i = 0; i < 2; i++)
+ for(ptrdiff_t i = 0; i < 2; i++)
e->t[i] = wcstol(params[4+i], NULL, 10);
}
sub->m_effects[EF_MOVE] = e;
}
+//#ifdef _VSMOD // patch f005. don't cache animated
+// sub->m_fAnimated = true;
+//#endif
}
}
else if(cmd == L"org") // {\org(x=param[0], y=param[1])}
{
+#ifdef _VSMOD // patch f003. moving \org for some karaoke effects. part 1
+ if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_ORG])
+ {
+ if(Effect* e = new Effect)
+ {
+ e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
+ e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
+ e->t[0] = e->t[1] = -1;
+
+ if(params.GetCount() >= 4)
+ {
+ e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8);
+ e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8);
+ }
+ if(params.GetCount() == 6)
+ {
+ e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL)*8);
+ e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8);
+ }
+ sub->m_effects[EF_ORG] = e;
+ }
+ }
+#else
if(params.GetCount() == 2 && !sub->m_effects[EF_ORG])
{
if(Effect* e = DNew Effect)
@@ -1820,6 +2427,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& sub->m_effects[EF_ORG] = e;
}
}
+#endif
}
else if(cmd == L"pbo")
{
@@ -1831,13 +2439,33 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& {
if(Effect* e = DNew Effect)
{
+#ifdef _VSMOD // patch m005. add some move types
+ e->param[0] = 0; // usual move
+ e->param[1] = e->param[3] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
+ e->param[2] = e->param[4] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
+#else
+ e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
+ e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
+#endif
+ e->t[0] = e->t[1] = 0;
+
+ sub->m_effects[EF_MOVE] = e;
+ }
+ }
+#ifdef _VSMOD // patch m002. Z-coord
+ else if(params.GetCount() == 3 && !sub->m_effects[EF_MOVE])
+ {
+ if(Effect* e = DNew Effect)
+ {
e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8);
e->t[0] = e->t[1] = 0;
sub->m_effects[EF_MOVE] = e;
+ style.mod_z = wcstod(params[2], NULL)*80;
}
}
+#endif
}
else if(cmd == L"p")
{
@@ -1851,6 +2479,39 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? n
: m_defaultWrapStyle;
}
+#ifdef _VSMOD // patch m003. random text points
+ else if(cmd == L"rnds")
+ {
+ double dst = wcstol(p, NULL, 16);
+ double nx = CalcAnimation(dst, style.mod_rand.Seed, fAnimate);
+ style.mod_rand.Seed = !p.IsEmpty() ? nx : org.mod_rand.Seed;
+ }
+ else if(cmd == L"rndx")
+ {
+ double dst = wcstod(p, NULL)*8;
+ double nx = CalcAnimation(dst, style.mod_rand.X, fAnimate);
+ style.mod_rand.X = !p.IsEmpty() ? nx : org.mod_rand.X;
+ }
+ else if(cmd == L"rndy")
+ {
+ double dst = wcstod(p, NULL)*8;
+ double nx = CalcAnimation(dst, style.mod_rand.Y, fAnimate);
+ style.mod_rand.Y = !p.IsEmpty() ? nx : org.mod_rand.Y;
+ }
+ else if(cmd == L"rndz")
+ {
+ double dst = wcstod(p, NULL)*8;
+ double nx = CalcAnimation(dst, style.mod_rand.Z, fAnimate);
+ style.mod_rand.Z = !p.IsEmpty() ? nx : org.mod_rand.Z;
+ }
+ else if(cmd == L"rnd")
+ {
+ double dst = wcstod(p, NULL)*8;
+ style.mod_rand.X = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.X, fAnimate) : org.mod_rand.X;
+ style.mod_rand.Y = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Y, fAnimate) : org.mod_rand.Y;
+ style.mod_rand.Z = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Z, fAnimate) : org.mod_rand.Z;
+ }
+#endif
else if(cmd == L"r")
{
STSStyle* val;
@@ -1948,6 +2609,14 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& ? ny
: org.shadowDepthY;
}
+#ifdef _VSMOD // patch m002. Z-coord
+ else if(cmd == L"z")
+ {
+ double dst = wcstod(p, NULL)*80;
+ double nx = CalcAnimation(dst, style.mod_z, fAnimate);
+ style.mod_z = !p.IsEmpty() ? nx : org.mod_z;
+ }
+#endif
}
// return(nUnrecognizedTags < nTags);
@@ -2111,7 +2780,6 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) // find the appropriate embedded style
GetStyle(entry, stss);
}
-
if (m_ePARCompensationType == EPCTUpscale)
{
if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0)
@@ -2147,7 +2815,6 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) sub->m_wrapStyle = m_defaultWrapStyle;
sub->m_fAnimated = false;
sub->m_relativeTo = stss.relativeTo;
-
// this whole conditional is a work-around for what happens in STS.cpp:
// in CSimpleTextSubtitle::Open, we have m_dstScreenSize = CSize(384, 288)
// now, files containing embedded subtitles (and with styles) set m_dstScreenSize to a correct value
@@ -2164,7 +2831,6 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) sub->m_scaley = m_dstScreenSize.cy > 0 ? 1.0 * (stss.relativeTo == 1 ? m_vidrect.Height() : m_size.cy) / (m_dstScreenSize.cy*8) : 1.0;
}
-
m_animStart = m_animEnd = 0;
m_animAccel = 1;
m_ktype = m_kstart = m_kend = 0;
@@ -2203,8 +2869,9 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) i++;
}
- STSStyle tmp = stss;
+ STSStyle tmp;
+ tmp = stss;
tmp.fontSize = sub->m_scaley*tmp.fontSize*64;
tmp.fontSpacing = sub->m_scalex*tmp.fontSpacing*64;
@@ -2252,10 +2919,8 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry) sub->CreateClippers(m_size);
-
sub->MakeLines(m_size, marginRect);
-
m_subtitleCache[entry] = sub;
return(sub);
@@ -2310,7 +2975,6 @@ STDMETHODIMP_(REFERENCE_TIME) CRenderedTextSubtitle::GetStop(POSITION pos, doubl STDMETHODIMP_(bool) CRenderedTextSubtitle::IsAnimated(POSITION pos)
{
- // TODO
return(true);
}
@@ -2359,7 +3023,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d CAtlArray<LSub> subs;
- for(int i = 0, j = stss->subs.GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++)
{
LSub ls;
ls.idx = stss->subs[i];
@@ -2370,7 +3034,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
- for(int i = 0, j = subs.GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++)
{
int entry = subs[i].idx;
@@ -2397,6 +3061,15 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d CPoint org2;
+ BYTE* pAlphaMask = s->m_pClipper?s->m_pClipper->m_pAlphaMask:NULL;
+
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc;
+ mod_vc.spd = CSize(spd.w,spd.h);
+ //mod_vc.alphamask = pAlphaMask;
+ mod_vc.size = s->m_pClipper?s->m_pClipper->m_size : CSize(0,0);
+#endif
+
for(int k = 0; k < EF_NUMBEROFEFFECTS; k++)
{
if(!s->m_effects[k]) continue;
@@ -2406,40 +3079,147 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d case EF_MOVE: // {\move(x1=param[0], y1=param[1], x2=param[2], y2=param[3], t1=t[0], t2=t[1])}
{
CPoint p;
- CPoint p1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
- CPoint p2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
- int t1 = s->m_effects[k]->t[0];
- int t2 = s->m_effects[k]->t[1];
-
- if(t2 < t1) {int t = t1; t1 = t2; t2 = t;}
-
- if(t1 <= 0 && t2 <= 0) {t1 = 0; t2 = m_delay;}
-
- if(m_time <= t1) p = p1;
- else if (p1 == p2) p = p1;
- else if(t1 < m_time && m_time < t2)
+#ifdef _VSMOD // patch m005. add some move types
+ if (s->m_effects[k]->param[0]==0)
{
- double t = 1.0*(m_time-t1)/(t2-t1);
- p.x = (int)((1-t)*p1.x + t*p2.x);
- p.y = (int)((1-t)*p1.y + t*p2.y);
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+#else
+ CPoint p1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint p2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+#endif
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ if(t2 < t1) {int t = t1; t1 = t2; t2 = t;}
+
+ if(t1 <= 0 && t2 <= 0) {t1 = 0; t2 = m_delay;}
+
+ if(m_time <= t1) p = p1;
+ else if (p1 == p2) p = p1;
+ else if(t1 < m_time && m_time < t2)
+ {
+ double t = 1.0*(m_time-t1)/(t2-t1);
+ p.x = (int)((1-t)*p1.x + t*p2.x);
+ p.y = (int)((1-t)*p1.y + t*p2.y);
+ }
+ else p = p2;
+#ifdef _VSMOD // patch m005. add some move types
}
- else p = p2;
-
+ else if (s->m_effects[k]->param[0]==1) // radial move
+ {
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]); // p0
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]); // p1
+ CPoint r0(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
+ double alp1 = s->m_effects[k]->param[5]*PI/1800000; // alp1
+ double alp2 = s->m_effects[k]->param[6]*PI/1800000; // alp2
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ CPoint pr1 = (p1.x + cos(alp1)*r0.x, p1.y + sin(alp1)*r0.x);
+ CPoint pr2 = (p2.x + cos(alp2)*r0.y, p2.y + sin(alp2)*r0.y);
+
+ if(t2 < t1) {int t = t1; t1 = t2; t2 = t;}
+
+ if(t1 <= 0 && t2 <= 0) {t1 = 0; t2 = m_delay;}
+
+ if(m_time <= t1) p = pr1;
+ //else if (p1 == p2) p = pr1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if((t1 < m_time) && (m_time < t2))
+ {
+ double t = (double)(m_time-t1)/(t2-t1);
+ double alp = ((1-t)*alp1 + t*alp2);
+ double rt = ((1-t)*r0.x + t*r0.y);
+
+ p.x = (int)((1-t)*p1.x + t*p2.x); // origin point
+ p.y = (int)((1-t)*p1.y + t*p2.y);
+ p.x += (int)(cos(alp)*rt);
+ p.y -= (int)(sin(alp)*rt);
+ }
+ else p = pr2;
+ }
+ else if (s->m_effects[k]->param[0]==2) // square spline
+ {
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+ CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
+
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ if(t2 < t1) {int t = t1; t1 = t2; t2 = t;}
+
+ if(t1 <= 0 && t2 <= 0) {t1 = 0; t2 = m_delay;}
+
+ if(m_time <= t1) p = p1;
+ else if (p1 == p2) p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if(t1 < m_time && m_time < t2)
+ {
+ double t = (double)(m_time-t1)/(t2-t1);
+ p.x = (int)((1-t)*(1-t)*p1.x + 2*t*(1-t)*p2.x + t*t*p3.x);
+ p.y = (int)((1-t)*(1-t)*p1.y + 2*t*(1-t)*p2.y + t*t*p3.y);
+ }
+ else p = p3;
+ }
+ else if (s->m_effects[k]->param[0]==3) // cubic spline
+ {
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+ CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
+ CPoint p4(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
+
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ if(t2 < t1) {int t = t1; t1 = t2; t2 = t;}
+
+ if(t1 <= 0 && t2 <= 0) {t1 = 0; t2 = m_delay;}
+
+ if(m_time <= t1) p = p1;
+ else if (p1 == p2) p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if(t1 < m_time && m_time < t2)
+ {
+ double t = (double)(m_time-t1)/(t2-t1);
+ p.x = (int)((1-t)*(1-t)*(1-t)*p1.x + 3*t*(1-t)*(1-t)*p2.x + 3*t*t*(1-t)*p3.x + t*t*t*p4.x);
+ p.y = (int)((1-t)*(1-t)*(1-t)*p1.y + 3*t*(1-t)*(1-t)*p2.y + 3*t*t*(1-t)*p3.y + t*t*t*p4.y);
+ }
+ else p = p4;
+ }
+#endif
r = CRect(
CPoint((s->m_scrAlignment%3) == 1 ? p.x : (s->m_scrAlignment%3) == 0 ? p.x - spaceNeeded.cx : p.x - (spaceNeeded.cx+1)/2,
s->m_scrAlignment <= 3 ? p.y - spaceNeeded.cy : s->m_scrAlignment <= 6 ? p.y - (spaceNeeded.cy+1)/2 : p.y),
spaceNeeded);
if(s->m_relativeTo == 1)
- r.OffsetRect(m_vidrect.TopLeft());
-
+ r.OffsetRect(m_vidrect.TopLeft());
fPosOverride = true;
}
break;
case EF_ORG: // {\org(x=param[0], y=param[1])}
{
+#ifdef _VSMOD // patch f003. moving \org for some karaoke effects
+ CPoint orgA(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint orgB(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+ int to1 = s->m_effects[k]->t[0];
+ int to2 = s->m_effects[k]->t[1];
+
+ if(to2 < to1) {int to = to1; to1 = to2; to2 = to;}
+
+ if(to1 <= 0 && to2 <= 0) {to1 = 0; to2 = m_delay;}
+
+ if(m_time <= to1) org2 = orgA;
+ else if (to1 == to2) org2 = orgA; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if(to1 < m_time && m_time < to2)
+ {
+ double t = 1.0*(m_time-to1)/(to2-to1);
+ org2.x = (int)((1-t)*orgA.x + t*orgB.x);
+ org2.y = (int)((1-t)*orgA.y + t*orgB.y);
+ }
+ else org2 = orgB;
+#else
org2 = CPoint(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
-
+#endif
fOrgOverride = true;
}
break;
@@ -2503,6 +3283,30 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d fPosOverride = true;
}
+#ifdef _VSMOD // patch m006. moveable vector clip
+ case EF_VECTCLP:
+ {
+ CPoint vcpos1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint vcpos2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+ int to1 = s->m_effects[k]->t[0];
+ int to2 = s->m_effects[k]->t[1];
+
+ if(to2 < to1) {int to = to1; to1 = to2; to2 = to;}
+
+ if(to1 <= 0 && to2 <= 0) {to1 = 0; to2 = m_delay;}
+
+ if(m_time <= to1) mod_vc.pos = vcpos1;
+ else if (to1 == to2) mod_vc.pos = vcpos1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if(to1 < m_time && m_time < to2)
+ {
+ double t = 1.0*(m_time-to1)/(to2-to1);
+ mod_vc.pos.x = (int)((1-t)*vcpos1.x + t*vcpos2.x);
+ mod_vc.pos.y = (int)((1-t)*vcpos1.y + t*vcpos2.y);
+ }
+ else mod_vc.pos = vcpos2;
+ mod_vc.enable = true;
+ }
+#endif
break;
default:
break;
@@ -2518,8 +3322,6 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d if(!fOrgOverride) org2 = org;
- BYTE* pAlphaMask = s->m_pClipper?s->m_pClipper->m_pAlphaMask:NULL;
-
CPoint p, p2(0, r.top);
POSITION pos;
@@ -2542,6 +3344,19 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
: org.x - (l->m_width/2);
+#ifdef _VSMOD // patch m006. moveable vector clip
+ if (s->m_clipInverse)
+ {
+ bbox2 |= l->PaintShadow(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintShadow(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintShadow(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintShadow(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+ else
+ {
+ bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+#else
if (s->m_clipInverse)
{
bbox2 |= l->PaintShadow(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
@@ -2553,7 +3368,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d {
bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
-
+#endif
p.y += l->m_ascent + l->m_descent;
}
@@ -2568,6 +3383,19 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
: org.x - (l->m_width/2);
+#ifdef _VSMOD // patch m006. moveable vector clip
+ if (s->m_clipInverse)
+ {
+ bbox2 |= l->PaintOutline(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintOutline(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintOutline(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintOutline(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+ else
+ {
+ bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+#else
if (s->m_clipInverse)
{
bbox2 |= l->PaintOutline(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
@@ -2579,7 +3407,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d {
bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
-
+#endif
p.y += l->m_ascent + l->m_descent;
}
@@ -2594,6 +3422,19 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d : (s->m_scrAlignment%3) == 0 ? org.x - l->m_width
: org.x - (l->m_width/2);
+#ifdef _VSMOD // patch m006. moveable vector clip
+ if (s->m_clipInverse)
+ {
+ bbox2 |= l->PaintBody(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintBody(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintBody(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ bbox2 |= l->PaintBody(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+ else
+ {
+ bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
+ }
+#else
if (s->m_clipInverse)
{
bbox2 |= l->PaintBody(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha);
@@ -2605,7 +3446,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d {
bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
-
+#endif
p.y += l->m_ascent + l->m_descent;
}
}
@@ -2667,4 +3508,4 @@ STDMETHODIMP CRenderedTextSubtitle::Reload() CFileStatus s;
if(!CFile::GetStatus(m_path, s)) return E_FAIL;
return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET) ? S_OK : E_FAIL;
-}
+}
\ No newline at end of file diff --git a/src/subtitles/RTS.h b/src/subtitles/RTS.h index 6b48f4cf8..9f9afcae7 100644 --- a/src/subtitles/RTS.h +++ b/src/subtitles/RTS.h @@ -128,9 +128,15 @@ public: void Compact();
+#ifdef _VSMOD // patch m006. moveable vector clip
+ CRect PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt);
+ CRect PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt);
+ CRect PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha, MOD_MOVEVC& mod_vc, REFERENCE_TIME rt);
+#else
CRect PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
CRect PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
CRect PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoint p, CPoint org, int time, int alpha);
+#endif
};
enum eftype
@@ -140,9 +146,16 @@ enum eftype EF_FADE, // {\fade(a1=param[0], a2=param[1], a3=param[2], t1=t[0], t2=t[1], t3=t[2], t4=t[3])} or {\fad(t1=t[1], t2=t[2])
EF_BANNER, // Banner;delay=param[0][;lefttoright=param[1];fadeawaywidth=param[2]]
EF_SCROLL, // Scroll up/down=param[3];top=param[0];bottom=param[1];delay=param[2][;fadeawayheight=param[4]]
+#ifdef _VSMOD // patch m006. moveable vector clip
+ EF_VECTCLP
+#endif
};
-#define EF_NUMBEROFEFFECTS 5
+#ifdef _VSMOD // patch m006. moveable vector clip
+ #define EF_NUMBEROFEFFECTS 6
+#else
+ #define EF_NUMBEROFEFFECTS 5
+#endif
class Effect
{
@@ -224,7 +237,6 @@ class CRenderedTextSubtitle : public CSimpleTextSubtitle, public ISubPicProvider STSStyle *m_pStyleOverride; // the app can decide to use this style instead of a built-in one
bool m_doOverrideStyle;
-
void ParseEffect(CSubtitle* sub, CString str);
void ParseString(CSubtitle* sub, CStringW str, STSStyle& style);
void ParsePolygon(CSubtitle* sub, CStringW str, STSStyle& style);
@@ -244,6 +256,7 @@ public: virtual void Copy(CSimpleTextSubtitle& sts);
virtual void Empty();
+
// call to signal this RTS to ignore any of the styles and apply the given override style
void SetOverride(bool doOverride = true, STSStyle *styleOverride = NULL) { m_doOverrideStyle = doOverride; if(styleOverride != NULL) m_pStyleOverride = styleOverride; }
diff --git a/src/subtitles/Rasterizer.cpp b/src/subtitles/Rasterizer.cpp index b04e7e79a..7e0c7a0e4 100644 --- a/src/subtitles/Rasterizer.cpp +++ b/src/subtitles/Rasterizer.cpp @@ -37,6 +37,11 @@ #define _IMPL_MIN _MIN
#endif
+int Rasterizer::getOverlayWidth()
+{
+ return mOverlayWidth*8;
+}
+
Rasterizer::Rasterizer() : mpPathTypes(NULL), mpPathPoints(NULL), mPathPoints(0), mpOverlayBuffer(NULL)
{
mOverlayWidth = mOverlayHeight = 0;
@@ -321,7 +326,7 @@ bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy) if(pNewTypes && pNewPoints && nPoints == GetPath(hdc, pPoints, pTypes, nPoints))
{
- for(int i = 0; i < nPoints; ++i)
+ for(ptrdiff_t i = 0; i < nPoints; ++i)
{
mpPathPoints[mPathPoints + i].x = pPoints[i].x + dx;
mpPathPoints[mPathPoints + i].y = pPoints[i].y + dy;
@@ -348,8 +353,8 @@ bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy) bool Rasterizer::ScanConvert()
{
- int lastmoveto = -1;
- int i;
+ size_t lastmoveto = -1;
+ size_t i;
// Drop any outlines we may have.
@@ -366,15 +371,15 @@ bool Rasterizer::ScanConvert() return 0;
}
- int minx = INT_MAX;
- int miny = INT_MAX;
- int maxx = INT_MIN;
- int maxy = INT_MIN;
+ ptrdiff_t minx = INT_MAX;
+ ptrdiff_t miny = INT_MAX;
+ ptrdiff_t maxx = INT_MIN;
+ ptrdiff_t maxy = INT_MIN;
for(i=0; i<mPathPoints; ++i)
{
- int ix = mpPathPoints[i].x;
- int iy = mpPathPoints[i].y;
+ ptrdiff_t ix = mpPathPoints[i].x;
+ ptrdiff_t iy = mpPathPoints[i].y;
if(ix < minx) minx = ix;
if(ix > maxx) maxx = ix;
@@ -415,8 +420,8 @@ bool Rasterizer::ScanConvert() // Initialize scanline list.
- mpScanBuffer = DNew unsigned int[mHeight];
- memset(mpScanBuffer, 0, mHeight*sizeof(unsigned int));
+ mpScanBuffer = DNew size_t[mHeight];
+ memset(mpScanBuffer, 0, mHeight*sizeof(size_t));
// Scan convert the outline. Yuck, Bezier curves....
@@ -485,7 +490,7 @@ bool Rasterizer::ScanConvert() // Detangle scanline into edge heap.
- for(unsigned ptr = (unsigned)(mpScanBuffer[y]&0xffffffff); ptr; ptr = mpEdgeBuffer[ptr].next)
+ for(size_t ptr = (mpScanBuffer[y]&size_t(-1)); ptr; ptr = mpEdgeBuffer[ptr].next)
{
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -502,11 +507,11 @@ bool Rasterizer::ScanConvert() std::vector<int>::iterator itX1 = heap.begin();
std::vector<int>::iterator itX2 = heap.end(); // begin() + heap.size();
- int x1, x2;
+ size_t x1, x2;
for(; itX1 != itX2; ++itX1)
{
- int x = *itX1;
+ size_t x = *itX1;
if(!count)
x1 = (x>>1);
@@ -661,7 +666,7 @@ bool Rasterizer::CreateWidenedRegion(int rx, int ry) {
// Do a half circle.
// _OverlapRegion mirrors this so both halves are done.
- for(int y = -ry; y <= ry; ++y)
+ for(ptrdiff_t y = -ry; y <= ry; ++y)
{
int x = (int)(0.5 + sqrt(float(ry*ry - y*y)) * float(rx)/float(ry));
@@ -698,7 +703,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) ysub &= 7;
int width = mWidth + xsub;
- int height = mHeight + ysub;
+ int height = mHeight;// + ysub
mOffsetX = mPathOffsetX - xsub;
mOffsetY = mPathOffsetY - ysub;
@@ -727,7 +732,8 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) }
mOverlayWidth = ((width+7)>>3) + 1;
- mOverlayHeight = ((height+7)>>3) + 1;
+ // fixed image height
+ mOverlayHeight=((height+14)>>3) + 1;
mpOverlayBuffer = DNew byte[2 * mOverlayWidth * mOverlayHeight];
memset(mpOverlayBuffer, 0, 2 * mOverlayWidth * mOverlayHeight);
@@ -736,21 +742,21 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) tSpanBuffer* pOutline[2] = {&mOutline, &mWideOutline};
- for(int i = countof(pOutline)-1; i >= 0; i--)
+ for(ptrdiff_t i = countof(pOutline)-1; i >= 0; i--)
{
tSpanBuffer::iterator it = pOutline[i]->begin();
tSpanBuffer::iterator itEnd = pOutline[i]->end();
for(; it!=itEnd; ++it)
{
- int y = (int)(((*it).first >> 32) - 0x40000000 + ysub);
- int x1 = (int)(((*it).first & 0xffffffff) - 0x40000000 + xsub);
- int x2 = (int)(((*it).second & 0xffffffff) - 0x40000000 + xsub);
+ size_t y = ((((*it).first >> 32) - 0x40000000) + ysub);
+ size_t x1 = (((*it).first & 0xffffffff) - 0x40000000 + xsub);
+ size_t x2 = (((*it).second & 0xffffffff) - 0x40000000 + xsub);
if(x2 > x1)
{
- int first = x1>>3;
- int last = (x2-1)>>3;
+ size_t first = x1>>3;
+ size_t last = (x2-1)>>3;
byte* dst = mpOverlayBuffer + 2*(mOverlayWidth*(y>>3) + first) + i;
if(first == last)
@@ -778,7 +784,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) GaussianKernel filter(fGaussianBlur);
if (mOverlayWidth >= filter.width && mOverlayHeight >= filter.width)
{
- int pitch = mOverlayWidth*2;
+ size_t pitch = mOverlayWidth*2;
byte *tmp = DNew byte[pitch*mOverlayHeight];
if(!tmp) return(false);
@@ -810,12 +816,12 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) int border = !mWideOutline.empty() ? 1 : 0;
// This could be done in a separated way and win some speed
- for(int j = 1; j < mOverlayHeight-1; j++)
+ for(ptrdiff_t j = 1; j < mOverlayHeight-1; j++)
{
byte* src = tmp + pitch*j + 2 + border;
byte* dst = mpOverlayBuffer + pitch*j + 2 + border;
- for(int i = 1; i < mOverlayWidth-1; i++, src+=2, dst+=2)
+ for(ptrdiff_t i = 1; i < mOverlayWidth-1; i++, src+=2, dst+=2)
{
*dst = (src[-2-pitch] + (src[-pitch]<<1) + src[+2-pitch]
+ (src[-2]<<1) + (src[0]<<2) + (src[+2]<<1)
@@ -834,20 +840,20 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur) static __forceinline void pixmix(DWORD *dst, DWORD color, DWORD alpha)
{
- int a = (((alpha)*(color>>24))>>6)&0xff;
- // Make sure both a and ia are in range 1..256 for the >>8 operations below to be correct
- int ia = 256-a;
+ DWORD a = (((alpha)*(color>>24))>>6)&0xff;
+ DWORD ia = 256-a;
a+=1;
+ DWORD tmp = (((((*dst>>8)&0x00ff0000)*ia)&0xff000000)>>24)&0xFF;
*dst = ((((*dst&0x00ff00ff)*ia + (color&0x00ff00ff)*a)&0xff00ff00)>>8)
- | ((((*dst&0x0000ff00)*ia + (color&0x0000ff00)*a)&0x00ff0000)>>8)
- | ((((*dst>>8)&0x00ff0000)*ia)&0xff000000);
+ | ((((*dst&0x0000ff00)*ia + (color&0x0000ff00)*a)&0x00ff0000)>>8)
+ | ((((*dst>>8)&0x00ff0000)*ia)&0xff000000);
}
static __forceinline void pixmix2(DWORD *dst, DWORD color, DWORD shapealpha, DWORD clipalpha)
{
- int a = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
- int ia = 256-a;
+ DWORD a = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
+ DWORD ia = 256-a;
a+=1;
*dst = ((((*dst&0x00ff00ff)*ia + (color&0x00ff00ff)*a)&0xff00ff00)>>8)
@@ -879,7 +885,7 @@ static __forceinline void pixmix_sse2(DWORD* dst, DWORD color, DWORD alpha) static __forceinline void pixmix2_sse2(DWORD* dst, DWORD color, DWORD shapealpha, DWORD clipalpha)
{
- int alpha = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
+ DWORD alpha = (((shapealpha)*(clipalpha)*(color>>24))>>12)&0xff;
color &= 0xffffff;
__m128i zero = _mm_setzero_si128();
@@ -901,35 +907,813 @@ static __forceinline void pixmix2_sse2(DWORD* dst, DWORD color, DWORD shapealpha // Calculate a - b clamping to 0 instead of underflowing
static __forceinline DWORD safe_subtract(DWORD a, DWORD b)
{
- // Microsoft's compiler only supports MMX intrinsics in 32 bit mode
-#ifdef _M_IX86
+#ifndef _WIN64
__m64 ap = _mm_cvtsi32_si64(a);
__m64 bp = _mm_cvtsi32_si64(b);
__m64 rp = _mm_subs_pu16(ap, bp);
DWORD r = (DWORD)_mm_cvtsi64_si32(rp);
-
_mm_empty();
-
return r;
#else
+ // For whatever reason Microsoft's x64 compiler doesn't support MMX intrinsics
return (b > a) ? 0 : a - b;
#endif
}
-static __forceinline DWORD safe_subtract_sse2(DWORD a, DWORD b)
+// For CPUID usage in Rasterizer::Draw
+#include "../dsutil/vd.h"
+
+static const __int64 _00ff00ff00ff00ff = 0x00ff00ff00ff00ffi64;
+
+// some helper procedures (Draw is so big)
+void Rasterizer::Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // The <<6 is due to pixmix expecting the alpha parameter to be
+ // the multiplication of two 6-bit unsigned numbers but we
+ // only have one here. (No alpha mask.)
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+ pixmix(&dst[wt], color, s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo)
{
- __m128i ap = _mm_cvtsi32_si128(a);
- __m128i bp = _mm_cvtsi32_si128(b);
- __m128i rp = _mm_subs_epu16(ap, bp);
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ // src contains two different bitmaps, interlaced per pixel.
+ // The first stored is the fill, the second is the widened
+ // fill region created by CreateWidenedRegion().
+ // Since we're drawing only the border, we must otain that
+ // by subtracting the fill from the widened region. The
+ // subtraction must be saturating since the widened region
+ // pixel value can be smaller than the fill value.
+ // This happens when blur edges is used.
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+ pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
- return (DWORD)_mm_cvtsi128_si32(rp);
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
}
-// For CPUID usage in Rasterizer::Draw
-#include "../dsutil/vd.h"
+void Rasterizer::Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // xo is the offset (usually negative) we have moved into the image
+ // So if we have passed the switchpoint (?) switch to another colour
+ // (So switchpts stores both colours *and* coordinates?)
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix(&dst[wt], color, s[wt*2]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix(&dst[wt], color2, s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
-static const __int64 _00ff00ff00ff00ff = 0x00ff00ff00ff00ffi64;
+void Rasterizer::Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+void Rasterizer::Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // Both s and am contain 6-bit bitmaps of two different
+ // alpha masks; s is the subtitle shape and am is the
+ // clipping mask.
+ // Multiplying them together yields a 12-bit number.
+ // I think some imprecision is introduced here??
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+#ifdef _VSMOD // patch m006. moveable vector clip
+ pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+#else
+ pixmix2(&dst[wt], color, s[wt*2], am[wt]);
+ am += rnfo.spdw;
+#endif
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+#ifdef _VSMOD // patch m006. moveable vector clip
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+#else
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ am += rnfo.spdw;
+#endif
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+ {
+#ifdef _VSMOD // patch m006. moveable vector clip
+ pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
+#else
+ pixmix2(&dst[wt], color, s[wt*2], am[wt]);
+ }
+ am += rnfo.spdw;
+#endif
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+#ifdef _VSMOD // patch m006. moveable vector clip
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+#else
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ am += rnfo.spdw;
+#endif
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}//Draw_Alpha_sp_noBody_0(w,h,xo,spd.w,color,spd.pitch,dst,src,sw,am);
+
+// == SSE2 func ==
+void Rasterizer::Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ const DWORD* sw = rnfo.sw;
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // The <<6 is due to pixmix expecting the alpha parameter to be
+ // the multiplication of two 6-bit unsigned numbers but we
+ // only have one here. (No alpha mask.)
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+ pixmix_sse2(&dst[wt], color, s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}//Draw_noAlpha_spFF_Body_sse2(w,h,color,spd.pitch,dst,s);
+
+void Rasterizer::Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ const DWORD* sw = rnfo.sw;
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ // src contains two different bitmaps, interlaced per pixel.
+ // The first stored is the fill, the second is the widened
+ // fill region created by CreateWidenedRegion().
+ // Since we're drawing only the border, we must otain that
+ // by subtracting the fill from the widened region. The
+ // subtraction must be saturating since the widened region
+ // pixel value can be smaller than the fill value.
+ // This happens when blur edges is used.
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+ pixmix_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}//Draw_noAlpha_spFF_noBody_sse2(w,h,color,spd.pitch,dst,src);
+
+void Rasterizer::Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // xo is the offset (usually negative) we have moved into the image
+ // So if we have passed the switchpoint (?) switch to another colour
+ // (So switchpts stores both colours *and* coordinates?)
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix_sse2(&dst[wt], color, s[wt*2]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix_sse2(&dst[wt], color2, s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo)
+{
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix_sse2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ // Both s and am contain 6-bit bitmaps of two different
+ // alpha masks; s is the subtitle shape and am is the
+ // clipping mask.
+ // Multiplying them together yields a 12-bit number.
+ // I think some imprecision is introduced here??
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+#ifdef _VSMOD // patch m006. moveable vector clip
+ pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+#else
+ pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
+ am += rnfo.spdw;
+#endif
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ while(h--)
+ {
+ for(int wt=0; wt<rnfo.w; ++wt)
+#ifdef _VSMOD // patch m006. moveable vector clip
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+#else
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ am += rnfo.spdw;
+#endif
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+ int color = rnfo.color;
+
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+#ifdef _VSMOD // patch m006. moveable vector clip
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2_sse2(&dst[wt], color2, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+#else
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2_sse2(&dst[wt], color2, s[wt*2], am[wt]);
+ am += rnfo.spdw;
+#endif
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
+{
+#ifdef _VSMOD // patch m006. moveable vector clip
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+#else
+ byte* am = rnfo.am;
+#endif
+ int h = rnfo.h;
+
+ DWORD color = rnfo.color;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ int color2 = rnfo.sw[2];
+ while(h--)
+ {
+#ifdef _VSMOD // patch m006. moveable vector clip
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+#else
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ for(int wt=gran; wt<rnfo.w; ++wt)
+ pixmix2_sse2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
+ am += rnfo.spdw;
+#endif
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+#ifdef _VSMOD // patch m004. gradient colors
+void Rasterizer::Draw_Grad_noAlpha_spFF_Body_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}//Draw_noAlpha_spFF_Body_0(w,h,color,spd.pitch,dst,s);
+
+void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_noAlpha_sp_Body_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+
+ int gran = max(rnfo.sw[3]+1-rnfo.xo,0);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
+ for(int wt=gran; wt<w; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_noAlpha_sp_noBody_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_spFF_Body_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_spFF_noBody_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_sp_Body_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_sp_noBody_0(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+// == SSE2 func ==
+void Rasterizer::Draw_Grad_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ int typ = rnfo.typ;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ int typ = rnfo.typ;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
+ for(int wt=gran; wt<w; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo)
+//(int w, int h, int overlayp, int typ, MOD_GRADIENT& mod_grad, int pitch, DWORD* dst, const byte* s, MOD_MOVEVC& mod_vc)
+{
+ double hfull = (double)rnfo.h;
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
+//(int w, int h, int overlayp, int typ, MOD_GRADIENT& mod_grad, int pitch, DWORD* dst, const byte* src, MOD_MOVEVC& mod_vc)
+{
+ double hfull = (double)rnfo.h;
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ int typ = rnfo.typ;
+ int h = rnfo.h;
+ int w = rnfo.w;
+ while(h--)
+ {
+ for(int wt=0; wt<w; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_sp_Body_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ byte* s = rnfo.s;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ s += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+
+void Rasterizer::Draw_Grad_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
+{
+ double hfull = (double)rnfo.h;
+ MOD_GRADIENT mod_grad = rnfo.mod_grad;
+ MOD_MOVEVC mod_vc = rnfo.mod_vc;
+
+ byte* src = rnfo.src;
+ DWORD* dst = rnfo.dst;
+
+ int h = rnfo.h;
+ int w = rnfo.w;
+ int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
+ while(h--)
+ {
+ for(int wt=0; wt<gran; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ for(int wt=gran; wt<w; ++wt)
+ pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ src += 2*rnfo.overlayp;
+ dst = (DWORD*)((char *)dst + rnfo.pitch);
+ }
+}
+#endif
// Render a subpicture onto a surface.
// spd is the surface to render on.
// clipRect is a rectangular clip region to render inside.
@@ -939,14 +1723,18 @@ static const __int64 _00ff00ff00ff00ff = 0x00ff00ff00ff00ffi64; // switchpts[i*2] contains a colour and switchpts[i*2+1] contains the coordinate to use that colour from
// fBody tells whether to render the body of the subs.
// fBorder tells whether to render the border of the subs.
-CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const long* switchpts, bool fBody, bool fBorder)
+#ifdef _VSMOD // patch m004. gradient colors
+CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub,
+ const DWORD* switchpts, bool fBody, bool fBorder, int typ, MOD_GRADIENT& mod_grad, MOD_MOVEVC& mod_vc)
+#else
+CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub,
+ const DWORD* switchpts, bool fBody, bool fBorder)
+#endif
{
CRect bbox(0, 0, 0, 0);
if(!switchpts || !fBody && !fBorder) return(bbox);
- // clip
-
// Limit drawn area to intersection of rendering surface and rectangular clip area
CRect r(0, 0, spd.w, spd.h);
r &= clipRect;
@@ -972,201 +1760,240 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x bbox.SetRect(x, y, x+w, y+h);
bbox &= CRect(0, 0, spd.w, spd.h);
- // draw
+ // CPUID from VDub
+ bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
+
+#ifdef _VSMOD // patch m006. moveable vector clip
+ mod_vc.hfull = h;
+ mod_vc.curpos = CPoint(x,y);
+ mod_vc.alphamask = pAlphaMask + spd.w * y + x;
+#endif
+ // fill rasterize info
+ RasterizerNfo rnfo;
+ // Grab the first colour
+ rnfo.color = switchpts[0];
+ // How would this differ from src?
+ rnfo.dst = (DWORD*)((char *)spd.bits + (spd.pitch * y)) + x;
+ rnfo.sw = switchpts;
+
+ rnfo.w = w;
+ rnfo.h = h;
+ rnfo.xo = xo;
+ rnfo.yo = yo;
+ rnfo.overlayp = mOverlayWidth;
+ rnfo.pitch = spd.pitch;
+ rnfo.spdw = spd.w;
// The alpha bitmap of the subtitles?
- const byte* src = mpOverlayBuffer + 2*(mOverlayWidth * yo + xo);
+ rnfo.src = mpOverlayBuffer + 2*(mOverlayWidth * yo + xo);
// s points to what the "body" to use is
// If we're rendering body fill and border, src+1 points to the array of
// widened regions which contain both border and fill in one.
- const byte* s = fBorder ? (src+1) : src;
+ rnfo.s = fBorder ? (rnfo.src+1) : rnfo.src;
+#ifdef _VSMOD // patch m006. moveable vector clip
+ rnfo.mod_vc = mod_vc;
+ rnfo.mod_grad = mod_grad;
+ rnfo.mod_grad.width = mOverlayWidth;
+ rnfo.mod_grad.height = h;
+ rnfo.mod_grad.xoffset = xo;
+ rnfo.mod_grad.yoffset = yo;
+ rnfo.typ = typ;
+#else
// The complex "vector clip mask" I think.
- const byte* am = pAlphaMask + spd.w * y + x;
- // How would this differ from src?
- unsigned long* dst = (unsigned long *)((char *)spd.bits + spd.pitch * y) + x;
-
- // Grab the first colour
- unsigned long color = switchpts[0];
-
- // CPUID from VDub
- bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
-
+ rnfo.am = pAlphaMask + spd.w * y + x;
+#endif
// Every remaining line in the bitmap to be rendered...
- while(h--)
+ // Basic case of no complex clipping mask
+#ifdef _VSMOD // patch m004. gradient colors
+if(((typ==0)&&((mod_grad.mode[0]==0)&&(mod_grad.mode[1]==0)))||(mod_grad.mode[typ]==0))
+// No gradient
+#endif
+ if(!pAlphaMask)
{
- // Basic case of no complex clipping mask
- if(!pAlphaMask)
+ // If the first colour switching coordinate is at "infinite" we're
+ // never switching and can use some simpler code.
+ // ??? Is this optimisation really worth the extra readability issues it adds?
+ if(switchpts[1] == 0xFFFFFFFF)
{
- // If the first colour switching coordinate is at "infinite" we're
- // never switching and can use some simpler code.
- // ??? Is this optimisation really worth the extra readability issues it adds?
- if(switchpts[1] == 0xffffffff)
+ // fBody is true if we're rendering a fill or a shadow.
+ if(fBody)
{
- // fBody is true if we're rendering a fill or a shadow.
- if(fBody)
- {
- // Run over every pixel, overlaying the subtitles with the fill colour
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- // The <<6 is due to pixmix expecting the alpha parameter to be
- // the multiplication of two 6-bit unsigned numbers but we
- // only have one here. (No alpha mask.)
- pixmix_sse2(&dst[wt], color, s[wt*2]);
- else
- for(int wt=0; wt<w; ++wt)
- pixmix(&dst[wt], color, s[wt*2]);
- }
- // Not painting body, ie. painting border without fill in it
+ if(fSSE2)
+ { Draw_noAlpha_spFF_Body_sse2(rnfo); }
else
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- // src contains two different bitmaps, interlaced per pixel.
- // The first stored is the fill, the second is the widened
- // fill region created by CreateWidenedRegion().
- // Since we're drawing only the border, we must otain that
- // by subtracting the fill from the widened region. The
- // subtraction must be saturating since the widened region
- // pixel value can be smaller than the fill value.
- // This happens when blur edges is used.
- pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- else
- for(int wt=0; wt<w; ++wt)
- pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
- }
+ { Draw_noAlpha_spFF_Body_0(rnfo); }
}
- // not (switchpts[1] == 0xffffffff)
+ // Not painting body, ie. painting border without fill in it
else
{
- // switchpts plays an important role here
- const long *sw = switchpts;
+ if(fSSE2)
+ { Draw_noAlpha_spFF_noBody_sse2(rnfo); }
+ else
+ { Draw_noAlpha_spFF_noBody_0(rnfo); }
+ }
+ }
+ // not (switchpts[1] == 0xFFFFFFFF)
+ else
+ {
+ // switchpts plays an important rule here
+ //const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- {
- // xo is the offset (usually negative) we have moved into the image
- // So if we have passed the switchpoint (?) switch to another colour
- // (So switchpts stores both colours *and* coordinates?)
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix_sse2(&dst[wt], color, s[wt*2]);
- }
- else
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix(&dst[wt], color, s[wt*2]);
- }
- }
- // Not body
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_noAlpha_sp_Body_sse2(rnfo); }
else
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- }
- else
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]));
- }
- }
+ { Draw_noAlpha_sp_Body_0(rnfo); }
+ }
+ // Not body
+ else
+ {
+ if(fSSE2)
+ { Draw_noAlpha_sp_noBody_sse2(rnfo); }
+ else
+ { Draw_noAlpha_sp_noBody_0(rnfo); }
+ }
+ }
+ }
+ // Here we *do* have an alpha mask
+ else
+ {
+ if(switchpts[1] == 0xFFFFFFFF)
+ {
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_Alpha_spFF_Body_sse2(rnfo); }
+ else
+ { Draw_Alpha_spFF_Body_0(rnfo); }
+ }
+ else
+ {
+ if(fSSE2)
+ { Draw_Alpha_spFF_noBody_sse2(rnfo); }
+ else
+ { Draw_Alpha_spFF_noBody_0(rnfo); }
}
}
- // Here we *do* have an alpha mask
else
{
- if(switchpts[1] == 0xffffffff)
+ //const long *sw = switchpts;
+
+ if(fBody)
{
- if(fBody)
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- // Both s and am contain 6-bit bitmaps of two different
- // alpha masks; s is the subtitle shape and am is the
- // clipping mask.
- // Multiplying them together yields a 12-bit number.
- // I think some imprecision is introduced here??
- pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
- else
- for(int wt=0; wt<w; ++wt)
- pixmix2(&dst[wt], color, s[wt*2], am[wt]);
- }
+ if(fSSE2)
+ { Draw_Alpha_sp_Body_sse2(rnfo); }
else
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
- else
- for(int wt=0; wt<w; ++wt)
- pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
+ { Draw_Alpha_sp_Body_0(rnfo); }
+ }
+ else
+ {
+ if(fSSE2)
+ { Draw_Alpha_sp_noBody_sse2(rnfo); }
+ else
+ { Draw_Alpha_sp_noBody_0(rnfo); }
}
+ }
+ }
+#ifdef _VSMOD // patch m004. gradient colors
+else
+{
+ if(!pAlphaMask)
+ {
+ // If the first colour switching coordinate is at "infinite" we're
+ // never switching and can use some simpler code.
+ // ??? Is this optimisation really worth the extra readability issues it adds?
+ if(switchpts[1] == 0xFFFFFFFF)
+ {
+ // fBody is true if we're rendering a fill or a shadow.
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_Grad_noAlpha_spFF_Body_sse2(rnfo); }
+ else
+ { Draw_Grad_noAlpha_spFF_Body_0(rnfo); }
+ }
+ // Not painting body, ie. painting border without fill in it
else
{
- const long *sw = switchpts;
+ if(fSSE2)
+ { Draw_Grad_noAlpha_spFF_noBody_sse2(rnfo); }
+ else
+ { Draw_Grad_noAlpha_spFF_noBody_0(rnfo); }
+ }
+ }
+ // not (switchpts[1] == 0xFFFFFFFF)
+ else
+ {
+ // switchpts plays an important rule here
+ //const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1])
- sw += 2; color = sw[-2];
- }
- pixmix2_sse2(&dst[wt], color, s[wt*2], am[wt]);
- }
- else
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1])
- sw += 2; color = sw[-2];
- }
- pixmix2(&dst[wt], color, s[wt*2], am[wt]);
- }
- }
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_Grad_noAlpha_sp_Body_sse2(rnfo); }
else
- {
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1])
- sw += 2; color = sw[-2];
- }
- pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), am[wt]);
- }
- else
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {
- while(wt+xo >= sw[1])
- sw += 2; color = sw[-2];
- }
- pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), am[wt]);
- }
- }
+ { Draw_Grad_noAlpha_sp_Body_0(rnfo); }
+ }
+ // Not body
+ else
+ {
+ if(fSSE2)
+ { Draw_Grad_noAlpha_sp_noBody_sse2(rnfo); }
+ else
+ { Draw_Grad_noAlpha_sp_noBody_0(rnfo); }
}
}
+ }
+ // Here we *do* have an alpha mask
+ else
+ {
+ if(switchpts[1] == 0xFFFFFFFF)
+ {
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_Grad_Alpha_spFF_Body_sse2(rnfo); }
+ else
+ { Draw_Grad_Alpha_spFF_Body_0(rnfo); }
+ }
+ else
+ {
+ if(fSSE2)
+ { Draw_Grad_Alpha_spFF_noBody_sse2(rnfo); }
+ else
+ { Draw_Grad_Alpha_spFF_noBody_0(rnfo); }
+ }
+ }
+ else
+ {
+ //const long *sw = switchpts;
- // Step to next scanline
- src += 2*mOverlayWidth;
- s += 2*mOverlayWidth;
- am += spd.w;
- dst = (unsigned long *)((char *)dst + spd.pitch);
+ if(fBody)
+ {
+ if(fSSE2)
+ { Draw_Grad_Alpha_sp_Body_sse2(rnfo); }
+ else
+ { Draw_Grad_Alpha_sp_Body_0(rnfo); }
+ }
+ else
+ {
+ if(fSSE2)
+ { Draw_Grad_Alpha_sp_noBody_sse2(rnfo); }
+ else
+ { Draw_Grad_Alpha_sp_noBody_0(rnfo); }
+ }
+ }
}
+}
+// patch m010. png background
+//if(typ==0) rnfo.mod_grad.b_images[1].freeImage();
+//rnfo.mod_grad.b_images[typ].freeImage();
+#endif
// Remember to EMMS!
// Rendering fails in funny ways if we don't do this.
-#ifndef _M_X64
_mm_empty();
-#endif
return bbox;
}
@@ -1202,4 +2029,67 @@ void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nH pixmix(&dst[wt], lColor, 0x40);
}
}
-#endif
\ No newline at end of file +#endif
+
+#ifdef _VSMOD // patch m006. moveable vector clip
+MOD_MOVEVC::MOD_MOVEVC()
+{
+ clear();
+}
+
+void MOD_MOVEVC::clear()
+{
+ enable = false;
+ size = CSize(0,0);
+ pos = CPoint(0,0);
+// canvas = CSize(0,0);
+ spd = CSize(0,0);
+ curpos = CPoint(0,0);
+ hfull = 0;
+ alphamask = NULL;
+}
+
+byte MOD_MOVEVC::GetAlphaValue(int wx,int wy)
+{
+ byte alpham;
+ if(!enable)
+ {
+// return 0xFF;
+ return alphamask[wx+((hfull-wy)*spd.cx)];
+ }
+ if ((wx-pos.x)<-curpos.x+1) alpham=0;
+ else if ((wx-pos.x)>spd.cx-1) alpham=0;//canvas.cx
+ else if ((hfull-wy-pos.y)<-curpos.y+1) alpham=0;
+ else if ((hfull-wy-pos.y)>spd.cy-1) alpham=0;
+ else alpham=alphamask[wx-pos.x - pos.y*spd.cx+((hfull-wy)*spd.cx)];
+
+ return alpham;
+}
+#endif
+
+RasterizerNfo::RasterizerNfo()
+{
+ /*
+ w = 0;
+ h = 0;
+ spdw = 0;
+ overlayp = 0;
+ typ = 0;
+ pitch = 0;
+ color = 0;
+
+ xo = 0;
+
+ sw = NULL;
+ s = NULL;
+ src = NULL;
+ dst = NULL;
+
+#ifdef _VSMOD
+ mod_grad.clear();
+ mod_vc.clear();
+#else
+ am = NULL;
+#endif
+ */
+}
\ No newline at end of file diff --git a/src/subtitles/Rasterizer.h b/src/subtitles/Rasterizer.h index a7211dc70..6a261fbb6 100644 --- a/src/subtitles/Rasterizer.h +++ b/src/subtitles/Rasterizer.h @@ -23,11 +23,65 @@ #include <vector>
#include "../SubPic/ISubPic.h"
+#ifdef _VSMOD // patch m004. gradient colors
+#include "STS.h"
+#endif
+
+#ifdef _VSMOD // patch m006. moveable vector clip
+class MOD_MOVEVC
+{
+public:
+ // movevc
+ bool enable;
+ CSize size;
+ CPoint pos;
+
+ //CSize canvas; // canvas size
+ CSize spd; // output canvas size
+ CPoint curpos; // output origin point
+ int hfull; // full height
+ byte* alphamask;
+
+ MOD_MOVEVC();
+
+ byte GetAlphaValue(int wx,int wy);
+ void clear();
+};
+#endif
#define PT_MOVETONC 0xfe
#define PT_BSPLINETO 0xfc
#define PT_BSPLINEPATCHTO 0xfa
+class RasterizerNfo
+{
+public:
+ int w;
+ int h;
+ int spdw;
+ int overlayp;
+ int pitch;
+ DWORD color;
+
+ int xo;
+ int yo;
+
+ const DWORD* sw;
+ byte* s;
+ byte* src;
+ DWORD* dst;
+
+#ifdef _VSMOD
+ int typ;
+ MOD_GRADIENT mod_grad;
+ MOD_MOVEVC mod_vc;
+#else
+ byte* am;
+#endif
+
+ RasterizerNfo();
+};
+
class Rasterizer
{
bool fFirstSet;
@@ -36,7 +90,7 @@ class Rasterizer protected:
BYTE* mpPathTypes;
POINT* mpPathPoints;
- int mPathPoints;
+ size_t mPathPoints;
private:
int mWidth, mHeight;
@@ -52,18 +106,18 @@ private: int next;
int posandflag;
} *mpEdgeBuffer;
- unsigned mEdgeHeapSize;
- unsigned mEdgeNext;
+ size_t mEdgeHeapSize;
+ size_t mEdgeNext;
- unsigned int* mpScanBuffer;
+ size_t* mpScanBuffer;
typedef unsigned char byte;
protected:
- byte *mpOverlayBuffer;
- int mOverlayWidth, mOverlayHeight;
int mPathOffsetX, mPathOffsetY;
int mOffsetX, mOffsetY;
+ int mOverlayWidth, mOverlayHeight;
+ byte *mpOverlayBuffer;
private:
void _TrashPath();
@@ -73,7 +127,42 @@ private: void _EvaluateLine(int pt1idx, int pt2idx);
void _EvaluateLine(int x0, int y0, int x1, int y1);
static void _OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int dy);
-
+ // helpers
+ void Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+
+#ifdef _VSMOD // patch m004. gradient colors
+ void Draw_Grad_noAlpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_spFF_Body_0(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_spFF_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_sp_Body_0(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_sp_noBody_0(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_sp_Body_sse2(RasterizerNfo& rnfo);
+ void Draw_Grad_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo);
+#endif
public:
Rasterizer();
virtual ~Rasterizer();
@@ -86,7 +175,12 @@ public: bool CreateWidenedRegion(int borderX, int borderY);
void DeleteOutlines();
bool Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur);
- CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const long* switchpts, bool fBody, bool fBorder);
+ int getOverlayWidth();
+#ifdef _VSMOD // patch m004. gradient colors
+ CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const DWORD* switchpts, bool fBody, bool fBorder, int typ, MOD_GRADIENT& mod_grad, MOD_MOVEVC& mod_vc);
+#else
+ CRect Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int xsub, int ysub, const DWORD* switchpts, bool fBody, bool fBorder);
+#endif
void FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nHeight, DWORD lColor);
};
diff --git a/src/subtitles/STS.cpp b/src/subtitles/STS.cpp index 7032a5623..a35999083 100644 --- a/src/subtitles/STS.cpp +++ b/src/subtitles/STS.cpp @@ -178,7 +178,7 @@ struct htmlcolor {TCHAR* name; DWORD color;} hmtlcolors[] = CHtmlColorMap::CHtmlColorMap()
{
- for(int i = 0; i < countof(hmtlcolors); i++)
+ for(ptrdiff_t i = 0; i < countof(hmtlcolors); i++)
SetAt(hmtlcolors[i].name, hmtlcolors[i].color);
}
@@ -254,7 +254,7 @@ int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet) DWORD cp = CharSetToCodePage(CharSet);
int OrgCharSet = CharSet;
- for(int i = 0, j = str.GetLength(), k; i < j; i++)
+ for(size_t i = 0, j = str.GetLength(), k; i < j; i++)
{
WCHAR c2 = str[i];
@@ -295,7 +295,7 @@ static CStringW ToMBCS(CStringW str, DWORD CharSet) DWORD cp = CharSetToCodePage(CharSet);
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++)
{
WCHAR wc = str.GetAt(i);
char c[8];
@@ -303,7 +303,7 @@ static CStringW ToMBCS(CStringW str, DWORD CharSet) int len;
if((len = WideCharToMultiByte(cp, 0, &wc, 1, c, 8, NULL, NULL)) > 0)
{
- for(int k = 0; k < len; k++)
+ for(ptrdiff_t k = 0; k < len; k++)
ret += (WCHAR)(BYTE)c[k];
}
else
@@ -321,7 +321,7 @@ static CStringW UnicodeSSAToMBCS(CStringW str, DWORD CharSet) int OrgCharSet = CharSet;
- for(int j = 0; j < str.GetLength(); )
+ for(ptrdiff_t j = 0; j < str.GetLength(); )
{
j = str.Find('{', j);
if(j >= 0)
@@ -369,7 +369,7 @@ static CStringW ToUnicode(CStringW str, DWORD CharSet) DWORD cp = CharSetToCodePage(CharSet);
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++)
{
WCHAR wc = str.GetAt(i);
char c = wc&0xff;
@@ -404,7 +404,7 @@ static CStringW MBCSSSAToUnicode(CStringW str, int CharSet) int OrgCharSet = CharSet;
- for(int j = 0; j < str.GetLength(); )
+ for(ptrdiff_t j = 0; j < str.GetLength(); )
{
j = FindChar(str, '{', 0, false, CharSet);
@@ -453,7 +453,7 @@ CStringW RemoveSSATags(CStringW str, bool fUnicode, int CharSet) str.Replace (L"{\\i1}", L"<i>");
str.Replace (L"{\\i}", L"</i>");
- for(int i = 0, j; i < str.GetLength(); )
+ for(ptrdiff_t i = 0, j; i < str.GetLength(); )
{
if((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) break;
if((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) break;
@@ -546,7 +546,7 @@ static bool OpenOldSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int Char buff.Trim();
if(buff.IsEmpty()) continue;
- for(int i = 0; i < buff.GetLength(); i++)
+ for(ptrdiff_t i = 0; i < buff.GetLength(); i++)
{
if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) break;
buff.SetAt(i, '\n');
@@ -586,7 +586,7 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet if(buff[0] == '[')
{
- for(int i = 0; i < buff.GetLength() && buff[i]== '['; )
+ for(size_t i = 0; i < buff.GetLength() && buff[i]== '['; )
{
int j = buff.Find(']', ++i);
if(j < i) break;
@@ -671,7 +671,7 @@ static STSStyle* GetMicroDVDStyle(CString str, int CharSet) STSStyle* ret = DNew STSStyle();
if(!ret) return(NULL);
- for(int i = 0, len = str.GetLength(); i < len; i++)
+ for(ptrdiff_t i = 0, len = str.GetLength(); i < len; i++)
{
int j = str.Find('{', i);
if(j < 0) j = len;
@@ -732,7 +732,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) int fRestoreLen = 8;
memset(fRestore, 0, sizeof(bool)*fRestoreLen);
- for(int pos = 0, eol; pos < str.GetLength(); pos++)
+ for(ptrdiff_t pos = 0, eol; pos < str.GetLength(); pos++)
{
if((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) eol = str.GetLength();
@@ -740,7 +740,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) pos = eol;
- for(int i = 0, j, k, len = line.GetLength(); i < len; i++)
+ for(ptrdiff_t i = 0, j, k, len = line.GetLength(); i < len; i++)
{
if((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) j = str.GetLength();
@@ -821,7 +821,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet) if(pos >= str.GetLength()) break;
- for(int i = 0; i < fRestoreLen; i++)
+ for(ptrdiff_t i = 0; i < fRestoreLen; i++)
{
if(fRestore[i])
{
@@ -947,7 +947,7 @@ static CStringW SMI2SSA(CStringW str, int CharSet) // maven@maven.de
// now parse line
- for(int i = 0, j = str.GetLength(); i < j; )
+ for(ptrdiff_t i = 0, j = str.GetLength(); i < j; )
{
int k;
if((k = lstr.Find('<', i)) < 0) break;
@@ -1141,7 +1141,7 @@ static bool OpenVPlayer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) buff.Trim();
if(buff.IsEmpty()) continue;
- for(int i = 0; i < buff.GetLength(); i++)
+ for(ptrdiff_t i = 0; i < buff.GetLength(); i++)
{
if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) break;
buff.SetAt(i, '\n');
@@ -1226,7 +1226,7 @@ static bool LoadFont(CString& font) const TCHAR* e = s + len;
for(BYTE* p = pData; s < e; s++, p++) *p = *s - 33;
- for(int i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3)
+ for(ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3)
{
pData[j+0] = ((pData[i+0]&63)<<2)|((pData[i+1]>>4)& 3);
pData[j+1] = ((pData[i+1]&15)<<4)|((pData[i+2]>>2)&15);
@@ -1265,7 +1265,7 @@ static bool LoadFont(CString& font) GetTempPath(MAX_PATH, path);
DWORD chksum = 0;
- for(int i = 0, j = datalen>>2; i < j; i++)
+ for(ptrdiff_t i = 0, j = datalen>>2; i < j; i++)
chksum += ((DWORD*)(BYTE*)pData)[i];
CString fn;
@@ -1294,7 +1294,16 @@ static bool LoadUUEFont(CTextFile* file) while(file->ReadString(s))
{
s.Trim();
- if(s.IsEmpty() || s[0] == '[') break;
+ if(s.IsEmpty()) break;
+ if(s[0] == '[') // check for some standatr blocks
+ {
+ if(s.Find(_T("[Script Info]")) == 0) break;
+ if(s.Find(_T("[V4+ Styles]")) == 0) break;
+ if(s.Find(_T("[V4 Styles]")) == 0) break;
+ if(s.Find(_T("[Events]")) == 0) break;
+ if(s.Find(_T("[Fonts]")) == 0) break;
+ if(s.Find(_T("[Graphics]")) == 0) break;
+ }
if(s.Find(_T("fontname:")) == 0) {LoadFont(font); font.Empty(); continue;}
font += s;
@@ -1306,6 +1315,83 @@ static bool LoadUUEFont(CTextFile* file) return(true);
}
+#ifdef _VSMOD
+bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn)
+{
+ int len = img.GetLength();
+
+ CAutoVectorPtr<BYTE> pData;
+ if(len == 0 || (len&3) == 1 || !pData.Allocate(len))
+ return(false);
+
+ const TCHAR* s = img;
+ const TCHAR* e = s + len;
+ for(BYTE* p = pData; s < e; s++, p++) *p = *s - 33;
+
+ for(ptrdiff_t i = 0, j = 0, k = len&~3; i < k; i+=4, j+=3)
+ {
+ pData[j+0] = ((pData[i+0]&63)<<2)|((pData[i+1]>>4)& 3);
+ pData[j+1] = ((pData[i+1]&15)<<4)|((pData[i+2]>>2)&15);
+ pData[j+2] = ((pData[i+2]& 3)<<6)|((pData[i+3]>>0)&63);
+ }
+
+ int datalen = (len&~3)*3/4;
+
+ if((len&3) == 2)
+ {
+ pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
+ }
+ else if((len&3) == 3)
+ {
+ pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)& 3);
+ pData[datalen++] = ((pData[(len&~3)+1]&15)<<4)|((pData[(len&~3)+2]>>2)&15);
+ }
+
+ // load png image
+ MOD_PNGIMAGE t_temp;
+ if(t_temp.initImage(pData.m_p,m_fn)) // save path
+ {
+ mod_images.Add(t_temp);
+ }
+ return(true);
+}
+
+
+bool CSimpleTextSubtitle::LoadUUEFile(CTextFile* file, CString m_fn)
+{
+ CString s, img;
+ while(file->ReadString(s))
+ {
+ s.Trim();
+ if(s.IsEmpty()) break;
+ if(s[0] == '[') // check for some standatr blocks
+ {
+ if(s.Find(_T("[Script Info]")) == 0) break;
+ if(s.Find(_T("[V4+ Styles]")) == 0) break;
+ if(s.Find(_T("[V4 Styles]")) == 0) break;
+ if(s.Find(_T("[Events]")) == 0) break;
+ if(s.Find(_T("[Fonts]")) == 0) break;
+ if(s.Find(_T("[Graphics]")) == 0) break;
+ }
+ // next file
+ if(s.Find(_T("filename:")) == 0)
+ {
+ LoadEfile(img, m_fn);
+ m_fn = s.Mid(10);
+ img.Empty();
+ continue;
+ }
+
+ img += s;
+ }
+
+ if(!img.IsEmpty())
+ LoadEfile(img, m_fn);
+
+ return(true);
+}
+#endif
+
static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
bool fRet = false;
@@ -1406,7 +1492,7 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C StyleName = WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(int i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
+ for(ptrdiff_t i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
style->fontWeight = !!GetInt(buff) ? FW_BOLD : FW_NORMAL;
style->fItalic = !!GetInt(buff);
if(sver >= 5) style->fUnderline = !!GetInt(buff);
@@ -1429,11 +1515,13 @@ if(sver >= 6) style->relativeTo = GetInt(buff); if(sver <= 4) style->colors[2] = style->colors[3]; // style->colors[2] is used for drawing the outline
if(sver <= 4) alpha = max(min(alpha, 0xff), 0);
-if(sver <= 4) {for(int i = 0; i < 3; i++) style->alpha[i] = alpha; style->alpha[3] = 0x80;}
-if(sver >= 5) for(int i = 0; i < 4; i++) {style->alpha[i] = (BYTE)(style->colors[i]>>24); style->colors[i] &= 0xffffff;}
+if(sver <= 4) {for(ptrdiff_t i = 0; i < 3; i++) style->alpha[i] = alpha; style->alpha[3] = 0x80;}
+if(sver >= 5) for(ptrdiff_t i = 0; i < 4; i++) {style->alpha[i] = (BYTE)(style->colors[i]>>24); style->colors[i] &= 0xffffff;}
if(sver >= 5) style->fontScaleX = max(style->fontScaleX, 0);
if(sver >= 5) style->fontScaleY = max(style->fontScaleY, 0);
+#ifndef _VSMOD // patch f002. negative fontspacing at style
if(sver >= 5) style->fontSpacing = max(style->fontSpacing, 0);
+#endif
style->fontAngleX = style->fontAngleY = 0;
style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
style->outlineWidthX = max(style->outlineWidthX, 0);
@@ -1507,6 +1595,12 @@ if(version >= 6)marginRect.bottom = GetInt(buff); {
LoadUUEFont(file);
}
+#ifdef _VSMOD // load png graphic from text resources
+ else if(entry == L"filename")
+ {
+ ret.LoadUUEFile(file,GetStr(buff));
+ }
+#endif
}
return(fRet);
@@ -1573,8 +1667,8 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet StyleName = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(int i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
- for(int i = 0; i < 4; i++) style->alpha[i] = GetInt(buff);
+ for(ptrdiff_t i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
+ for(ptrdiff_t i = 0; i < 4; i++) style->alpha[i] = GetInt(buff);
style->fontWeight = !!GetInt(buff) ? FW_BOLD : FW_NORMAL;
style->fItalic = !!GetInt(buff);
style->fUnderline = !!GetInt(buff);
@@ -1658,6 +1752,12 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet {
LoadUUEFont(file);
}
+#ifdef _VSMOD // load png graphic from text resources
+ else if(entry == L"filename")
+ {
+ ret.LoadUUEFile(file,GetStr(buff));
+ }
+#endif
}
return(ret.GetCount() > 0);
@@ -1819,7 +1919,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff) timeoff = GetCount() > 0 ? GetAt(GetCount()-1).end : 0;
}
- for(int i = 0, j = GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
{
if(GetAt(i).start > timeoff)
{
@@ -1830,7 +1930,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff) CopyStyles(sts.m_styles, true);
- for(int i = 0, j = sts.GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = sts.GetCount(); i < j; i++)
{
STSEntry stse = sts.GetAt(i);
stse.start += timeoff;
@@ -1906,6 +2006,9 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C sub.start = start;
sub.end = end;
sub.readorder = readorder < 0 ? GetCount() : readorder;
+#ifdef _VSMOD // patch m009. png graphics
+ sub.mod_scripttype = 0;
+#endif
int n = __super::Add(sub);
int len = m_segments.GetCount();
@@ -1938,7 +2041,7 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C m_segments.InsertAt(0, stss);
}
- for(int i = 0; i < m_segments.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_segments.GetCount(); i++)
{
STSSegment& s = m_segments[i];
@@ -1959,7 +2062,7 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C if(start <= s.start && s.end <= end)
{
- for(int j = 0, k = s.subs.GetCount(); j <= k; j++)
+ for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++)
{
if(j == k || sub.readorder < GetAt(s.subs[j]).readorder)
s.subs.InsertAt(j, n);
@@ -1971,7 +2074,7 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C {
STSSegment stss(s.start, end);
stss.subs.Copy(s.subs);
- for(int j = 0, k = s.subs.GetCount(); j <= k; j++)
+ for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++)
{
if(j == k || sub.readorder < GetAt(stss.subs[j]).readorder)
stss.subs.InsertAt(j, n);
@@ -1996,7 +2099,7 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C if(style.IsEmpty()) style = _T("Default");
int j = m_segments.GetCount();
- for(int i = j-1; i >= 0; i--)
+ for(ptrdiff_t i = j-1; i >= 0; i--)
{
if(m_segments[i].end <= start)
{
@@ -2066,7 +2169,7 @@ void CSimpleTextSubtitle::ChangeUnknownStylesToDefault() CAtlMap<CString, STSStyle*, CStringElementTraits<CString> > unknown;
bool fReport = true;
- for(int i = 0; i < GetCount(); i++)
+ for(ptrdiff_t i = 0; i < GetCount(); i++)
{
STSEntry& stse = GetAt(i);
@@ -2162,7 +2265,7 @@ void CSimpleTextSubtitle::ConvertToTimeBased(double fps) {
if(m_mode == TIME) return;
- for(int i = 0, j = GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
{
STSEntry& stse = (*this)[i];
stse.start = int(1.0 * stse.start * 1000 / fps + 0.5);
@@ -2178,7 +2281,7 @@ void CSimpleTextSubtitle::ConvertToFrameBased(double fps) {
if(m_mode == FRAME) return;
- for(int i = 0, j = GetCount(); i < j; i++)
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
{
STSEntry& stse = (*this)[i];
stse.start = int(1.0 * stse.start * fps / 1000 + 0.5);
@@ -2522,7 +2625,7 @@ void CSimpleTextSubtitle::CreateSegments() TRACE(_T("%d - %d"), stss.start, stss.end);
- for(int k = 0, l = stss.subs.GetCount(); k < l; k++)
+ for(ptrdiff_t k = 0, l = stss.subs.GetCount(); k < l; k++)
{
TRACE(_T(", %d"), stss.subs[k]);
}
@@ -2565,7 +2668,7 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name) ULONGLONG pos = f->GetPosition();
- for(int i = 0; i < nOpenFuncts; i++)
+ for(ptrdiff_t i = 0; i < nOpenFuncts; i++)
{
if(!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/)
{
@@ -2771,7 +2874,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile:: L"";
// Sort(true);
- for(int i = 0, j = GetCount(), k = 0; i < j; i++)
+ for(ptrdiff_t i = 0, j = GetCount(), k = 0; i < j; i++)
{
STSEntry& stse = GetAt(i);
@@ -2892,6 +2995,14 @@ STSStyle::STSStyle() SetDefault();
}
+#ifdef _VSMOD
+STSStyle::STSStyle(STSStyle& s)
+{
+ SetDefault();
+ mod_CopyStyleFrom(s);
+}
+#endif
+
void STSStyle::SetDefault()
{
marginRect = CRect(20, 20, 20, 20);
@@ -2920,6 +3031,18 @@ void STSStyle::SetDefault() fGaussianBlur = 0;
fontShiftX = fontShiftY = fontAngleZ = fontAngleX = fontAngleY = 0;
relativeTo = 2;
+#ifdef _VSMOD
+ // patch m001. Vertical fontspacing
+ mod_verticalSpace = 0;
+ // patch m002. Z-coord
+ mod_z = 0;
+ // patch m003. random text points
+ mod_rand.clear();
+ // patch m004. gradient colors
+ mod_grad.clear();
+ // patch m007. symbol rotating
+ mod_fontOrient = 0;
+#endif
}
bool STSStyle::operator == (STSStyle& s)
@@ -2942,6 +3065,22 @@ bool STSStyle::operator == (STSStyle& s) && fBlur == s.fBlur
&& fGaussianBlur == s.fGaussianBlur
&& relativeTo == s.relativeTo
+#ifdef _VSMOD
+ // patch m001. Vertical fontspacing
+ && mod_verticalSpace == s.mod_verticalSpace
+ // patch m002. Z-coord
+ && mod_z == s.mod_z
+ // patch m003. random text points
+ && mod_rand == s.mod_rand
+ // patch m004. gradient colors
+ && mod_grad == s.mod_grad
+ // patch m007. symbol rotating
+ && mod_fontOrient == s.mod_fontOrient
+ // patch m008. distort
+ && mod_distort == s.mod_distort
+ // patch m011. jitter
+ && mod_jitter == s.mod_jitter
+#endif
&& IsFontStyleEqual(s));
}
@@ -2960,8 +3099,72 @@ bool STSStyle::IsFontStyleEqual(STSStyle& s) && fStrikeOut == s.fStrikeOut
&& fontAngleZ == s.fontAngleZ
&& fontAngleX == s.fontAngleX
- && fontAngleY == s.fontAngleY);
-}
+ && fontAngleY == s.fontAngleY
+ // patch f001. fax fay patch (many instances at line)
+ && fontShiftX == s.fontShiftX
+ && fontShiftY == s.fontShiftY);
+}
+
+#ifdef _VSMOD
+void STSStyle::mod_CopyStyleFrom(STSStyle& s)
+{
+ marginRect = s.marginRect;
+ scrAlignment = s.scrAlignment;
+ borderStyle = s.borderStyle;
+ outlineWidthX = s.outlineWidthX;
+ outlineWidthY = s.outlineWidthY;
+ shadowDepthX = s.shadowDepthX;
+ shadowDepthY = s.shadowDepthY;
+ *((int*)&colors[0]) = *((int*)&s.colors[0]);
+ *((int*)&colors[1]) = *((int*)&s.colors[1]);
+ *((int*)&colors[2]) = *((int*)&s.colors[2]);
+ *((int*)&colors[3]) = *((int*)&s.colors[3]);
+ alpha[0] = s.alpha[0];
+ alpha[1] = s.alpha[1];
+ alpha[2] = s.alpha[2];
+ alpha[3] = s.alpha[3];
+ fBlur = s.fBlur;
+ fGaussianBlur = s.fGaussianBlur;
+ relativeTo = s.relativeTo;
+
+ //patch m001. Vertical fontspacing
+ mod_verticalSpace = s.mod_verticalSpace;
+ //patch m002. Z-coord
+ mod_z = s.mod_z;
+ //patch m003. random text points
+ mod_rand = s.mod_rand;
+ //patch m004. gradient colors
+ mod_grad = s.mod_grad;
+ // patch m007. symbol rotating
+ mod_fontOrient = s.mod_fontOrient;
+ // patch m008. distort
+ mod_distort = s.mod_distort;
+ // patch m011. jitter
+ mod_jitter = s.mod_jitter;
+ // font
+ charSet = s.charSet;
+ fontName = s.fontName;
+ fontSize = s.fontSize;
+ fontScaleX = s.fontScaleX;
+ fontScaleY = s.fontScaleY;
+ fontSpacing = s.fontSpacing;
+ fontWeight = s.fontWeight;
+ fItalic = s.fItalic;
+ fUnderline = s.fUnderline;
+ fStrikeOut = s.fStrikeOut;
+ fontAngleZ = s.fontAngleZ;
+ fontAngleX = s.fontAngleX;
+ fontAngleY = s.fontAngleY;
+ // patch f001. fax fay patch (many instances at line)
+ fontShiftX = s.fontShiftX;
+ fontShiftY = s.fontShiftY;
+}
+
+void STSStyle::operator = (STSStyle& s)
+{
+ mod_CopyStyleFrom(s);
+}
+#endif
void STSStyle::operator = (LOGFONT& lf)
{
@@ -3036,8 +3239,8 @@ STSStyle& operator <<= (STSStyle& s, CString& style) s.marginRect.left = GetInt(str,';'); s.marginRect.right = GetInt(str,';'); s.marginRect.top = GetInt(str,';'); s.marginRect.bottom = GetInt(str,';');
s.scrAlignment = GetInt(str,';'); s.borderStyle = GetInt(str,';');
s.outlineWidthX = GetFloat(str,';'); s.outlineWidthY = GetFloat(str,';'); s.shadowDepthX = GetFloat(str,';'); s.shadowDepthY = GetFloat(str,';');
- for(int i = 0; i < 4; i++) s.colors[i] = (COLORREF)GetInt(str,';');
- for(int i = 0; i < 4; i++) s.alpha[i] = GetInt(str,';');
+ for(ptrdiff_t i = 0; i < 4; i++) s.colors[i] = (COLORREF)GetInt(str,';');
+ for(ptrdiff_t i = 0; i < 4; i++) s.alpha[i] = GetInt(str,';');
s.charSet = GetInt(str,';');
s.fontName = WToT(GetStr(str,';')); s.fontSize = GetFloat(str,';');
s.fontScaleX = GetFloat(str,';'); s.fontScaleY = GetFloat(str,';');
@@ -3090,3 +3293,374 @@ static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet) return(ret.GetCount() > 0);
}
+
+#ifdef _VSMOD // patch m003. random text points
+bool MOD_RANDOM::operator == (MOD_RANDOM& mr)
+{
+ return (X == mr.X
+ && Y == mr.Y
+ && Z == mr.X
+ && Seed == mr.Seed);
+}
+
+void MOD_RANDOM::clear()
+{
+ X = 0;
+ Y = 0;
+ Z = 0;
+ Seed = 0;
+}
+#endif
+
+#ifdef _VSMOD // patch m004. gradient colors
+#include <png.h> // patch m010. png background
+
+MOD_PNGIMAGE::MOD_PNGIMAGE()
+{
+ width = 0;
+ height = 0;
+
+ xoffset = 0;
+ yoffset = 0;
+
+ pointer = NULL;
+
+ // rasterizer
+ alpha = 0xFF;
+}
+
+void png_default_read_edata(png_structp png_ptr, png_bytep data, png_size_t length) +{ + png_size_t check; + + if (png_ptr->io_ptr == NULL) + return;
+
+ BYTE* eldata = (BYTE*)png_ptr->io_ptr; + + // read from memory + memcpy(data,eldata,length); + eldata += length; + png_ptr->io_ptr = (png_voidp)eldata; +}
+
+bool MOD_PNGIMAGE::operator == (MOD_PNGIMAGE& png)
+{
+ return(filename == png.filename
+ && xoffset == png.xoffset
+ && yoffset == png.yoffset);
+}
+
+bool MOD_PNGIMAGE::processData(png_structp png_ptr)
+{
+ png_uint_32 color_type;
+ png_uint_32 bit_depth;
+
+ png_infop info_ptr;
+ int number_of_passes;
+
+ /* initialize stuff */
+ info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) return false; // png_create_info_struct failed
+
+ if (setjmp(png_jmpbuf(png_ptr))) return false; // Error during init_io
+
+ png_set_sig_bytes(png_ptr, 8);
+
+ png_read_info(png_ptr, info_ptr);
+
+ width = info_ptr->width;
+ height = info_ptr->height;
+ color_type = info_ptr->color_type;
+ bit_depth = info_ptr->bit_depth;
+
+ // palette
+ if (color_type==PNG_COLOR_TYPE_PALETTE)
+ png_set_palette_to_rgb(png_ptr);
+
+ // expand to 8 bits
+ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
+ png_set_expand_gray_1_2_4_to_8(png_ptr);
+
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ png_set_tRNS_to_alpha(png_ptr);
+
+ // Strip 16 bit depth files to 8 bit depth
+ if (bit_depth == 16)
+ png_set_strip_16(png_ptr);
+
+ // ARGB -> RGBA
+// if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+// png_set_swap_alpha(png_ptr);
+
+ // grayscale -> RGB
+ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ png_set_gray_to_rgb(png_ptr);
+
+ number_of_passes = png_set_interlace_handling(png_ptr);
+ png_read_update_info(png_ptr, info_ptr);
+
+ /* read file */
+ if (setjmp(png_jmpbuf(png_ptr))) return false; // Error during read_image
+
+ bpp = info_ptr->rowbytes / width;
+ pointer = (png_bytep*) malloc(sizeof(png_bytep) * height);
+ for (int y=0; y<height; y++)
+ pointer[y] = (png_byte*) malloc(info_ptr->rowbytes);
+
+ png_read_image(png_ptr, pointer);
+ return true;
+}
+
+bool MOD_PNGIMAGE::initImage(CString m_fn)
+{
+ if((m_fn==filename)&&(pointer!=NULL)) return true; // already loaded
+
+ char header[8]; // 8 is the maximum size that can be check
+ png_structp png_ptr;
+
+ const wchar_t* wfn = m_fn.GetString();
+ int len = m_fn.GetLength();
+ char* fn = new char[len+1];
+ WideCharToMultiByte(CP_ACP,NULL,wfn,wcslen(wfn),fn,len,NULL,NULL);
+ fn[len]=0;
+ filename = m_fn;
+
+ FILE *fp = fopen(fn, "rb");
+ if (!fp) return false; // File could not be opened for reading
+ fread(header, 1, 8, fp);
+ if (png_sig_cmp((png_bytep)header, 0, 8)) return false; // File is not recognized as a PNG file
+
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) return false; // png_create_read_struct failed
+
+ png_init_io(png_ptr, fp);
+ return processData(png_ptr);
+ fclose(fp);
+}
+
+bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn)
+{
+ if((m_fn==filename)&&(pointer!=NULL)) return true; // already loaded
+ if(data == NULL) return false; // not loaded
+
+ char header[8]; // 8 is the maximum size that can be check
+ png_structp png_ptr;
+
+ filename = m_fn;
+
+ memcpy(header,data,8);
+ if (png_sig_cmp((png_bytep)header, 0, 8)) return false; // File is not recognized as a PNG file
+
+ data += 8; // don't forget modify pointer
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (!png_ptr) return false; // png_create_read_struct failed
+
+ png_set_read_fn(png_ptr, (png_voidp)data, &png_default_read_edata);
+ return processData(png_ptr);
+}
+
+void MOD_PNGIMAGE::freeImage()
+{
+ if(pointer!=NULL) delete [] pointer;
+}
+
+MOD_GRADIENT::MOD_GRADIENT()
+{
+ clear();
+}
+
+bool MOD_GRADIENT::operator == (MOD_GRADIENT& mg)
+{
+ return (color[0][0] == mg.color[0][0] // T.T
+ && color[1][0] == mg.color[1][0]
+ && color[2][0] == mg.color[2][0]
+ && color[3][0] == mg.color[3][0]
+ && color[0][1] == mg.color[0][1]
+ && color[1][1] == mg.color[1][1]
+ && color[2][1] == mg.color[2][1]
+ && color[3][1] == mg.color[3][1]
+ && color[0][2] == mg.color[0][2]
+ && color[1][2] == mg.color[1][2]
+ && color[2][2] == mg.color[2][2]
+ && color[3][2] == mg.color[3][2]
+ && color[0][3] == mg.color[0][3]
+ && color[1][3] == mg.color[1][3]
+ && color[2][3] == mg.color[2][3]
+ && color[3][3] == mg.color[3][3]
+ && alpha[0][0] == mg.alpha[0][0]
+ && alpha[1][0] == mg.alpha[1][0]
+ && alpha[2][0] == mg.alpha[2][0]
+ && alpha[3][0] == mg.alpha[3][0]
+ && alpha[0][1] == mg.alpha[0][1]
+ && alpha[1][1] == mg.alpha[1][1]
+ && alpha[2][1] == mg.alpha[2][1]
+ && alpha[3][1] == mg.alpha[3][1]
+ && alpha[0][2] == mg.alpha[0][2]
+ && alpha[1][2] == mg.alpha[1][2]
+ && alpha[2][2] == mg.alpha[2][2]
+ && alpha[3][2] == mg.alpha[3][2]
+ && alpha[0][3] == mg.alpha[0][3]
+ && alpha[1][3] == mg.alpha[1][3]
+ && alpha[2][3] == mg.alpha[2][3]
+ && alpha[3][3] == mg.alpha[3][3]
+ && mode[0] == mg.mode[0]
+ && mode[1] == mg.mode[1]
+ && mode[2] == mg.mode[2]
+ && mode[3] == mg.mode[3]
+ && b_images[0] == mg.b_images[0]
+ && b_images[1] == mg.b_images[1]
+ && b_images[2] == mg.b_images[2]
+ && b_images[3] == mg.b_images[3]);
+}
+
+void MOD_GRADIENT::clear()
+{
+ memset(&color,0,sizeof(color));
+ memset(&colors,0,sizeof(colors));
+ memset(&alpha,0,sizeof(alpha));
+ memset(&alphas,0,sizeof(alphas));
+ memset(&mode,0,sizeof(mode));
+ colors[0] = 0x00ffffff;
+ colors[1] = 0x0000ffff;
+ alphas[3] = 0x80;
+ width = 0;
+ height = 0;
+ xoffset = 0;
+ yoffset = 0;
+ subpixx = 0;
+ subpixy = 0;
+}
+
+DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T
+{
+ DWORD colorb = 0;
+ tx += xoffset;
+ ty += yoffset;
+ double x = (double)tx/(double)width;
+ double y = (double)ty/(double)height;
+ // gradient
+ if(mode[i]==1)
+ {
+ for(int j=0;j<3;j++)
+ {
+ colorb |= ((DWORD)(((color[i][0]>>(8*j))&0xff)*(1-x)*y +
+ ((color[i][1]>>(8*j))&0xff)*x*y+
+ ((color[i][2]>>(8*j))&0xff)*(1-y)*(1-x)+
+ ((color[i][3]>>(8*j))&0xff)*x*(1-y))&0xff)<<(8*j);
+ }
+ colorb |= (0xff - (DWORD)((alpha[i][0]*(1-x)*y) +
+ (alpha[i][1]*x*y)+
+ (alpha[i][2]*(1-y)*(1-x))+
+ (alpha[i][3]*x*(1-y)))&0xff)<<(24);
+ return colorb;
+ }
+ // png background
+ if(mode[i]==2)
+ {
+
+ tx += b_images[i].xoffset;
+ ty += b_images[i].yoffset;
+ while(tx>b_images[i].width-1) tx-=b_images[i].width;
+ while(ty>b_images[i].height-1) ty-=b_images[i].height;
+ // now tx and ty are valid array indexes
+ // rows are inverted last,...,n,...,1,0
+ bool nlastpixx = (tx>0);
+ bool nlastpixy = (ty<b_images[i].height-1);
+ BYTE* dst11 = b_images[i].pointer[b_images[i].height-1-ty]+tx*b_images[i].bpp;
+ BYTE* dst12 = (nlastpixx) ? b_images[i].pointer[b_images[i].height-1-ty]+(tx-1)*b_images[i].bpp : NULL;
+ BYTE* dst21 = (nlastpixy) ? b_images[i].pointer[b_images[i].height-ty-2]+tx*b_images[i].bpp : NULL;
+ BYTE* dst22 = (nlastpixx&&nlastpixy) ? b_images[i].pointer[b_images[i].height-ty-2]+(tx-1)*b_images[i].bpp : NULL;
+ BYTE r = dst11[0];
+ BYTE g = dst11[1];
+ BYTE b = dst11[2];
+ BYTE a = (b_images[i].bpp==4) ? dst11[3] : 0xFF;
+ // subpixel positioning
+ if(nlastpixx&&!nlastpixy) // last row
+ {
+ r = (r*(8-subpixx)+dst12[0]*subpixx)>>3;
+ g = (g*(8-subpixx)+dst12[1]*subpixx)>>3;
+ b = (b*(8-subpixx)+dst12[2]*subpixx)>>3;
+ a = (b_images[i].bpp==4) ? (a*(8-subpixx)+dst12[3]*subpixx)>>3 : 0xFF;
+ }
+ else if(nlastpixy&&!nlastpixx) // last col
+ {
+ r = (r*(subpixy)+dst21[0]*(8-subpixy))>>3;
+ g = (g*(subpixy)+dst21[1]*(8-subpixy))>>3;
+ b = (b*(subpixy)+dst21[2]*(8-subpixy))>>3;
+ a = (b_images[i].bpp==4) ? (a*(subpixy)+dst21[3]*(8-subpixy))>>3 : 0xFF;
+ }
+ else if(nlastpixy&&nlastpixx)
+ {// T.T
+ r = (((dst21[0]*(8-subpixx)+dst22[0]*subpixx)>>3)*(subpixy)+((r*(8-subpixx)+dst12[0]*subpixx)>>3)*(8-subpixy))>>3;
+ g = (((dst21[1]*(8-subpixx)+dst22[1]*subpixx)>>3)*(subpixy)+((g*(8-subpixx)+dst12[1]*subpixx)>>3)*(8-subpixy))>>3;
+ b = (((dst21[2]*(8-subpixx)+dst22[2]*subpixx)>>3)*(subpixy)+((b*(8-subpixx)+dst12[2]*subpixx)>>3)*(8-subpixy))>>3;
+ a = (b_images[i].bpp==4) ? (((dst21[3]*(8-subpixx)+dst22[3]*subpixx)>>3)*(subpixy)+((a*(8-subpixx)+dst12[3]*subpixx)>>3)*(8-subpixy))>>3 : 0xFF;
+ }
+ // alpha fix
+ a = (a*b_images[i].alpha)>>8;
+ colorb = a<<24 | r<<16 | g<<8 | b;
+
+ return colorb;
+ }
+ // usual color
+// if(mode[i]==0)
+ return (colors[i]|alphas[i]<<24);
+}
+#endif
+
+#ifdef _VSMOD // patch m008. distort
+MOD_DISTORT::MOD_DISTORT()
+{
+ enabled = false;
+ pointsx[0] = 1; pointsy[0] = 0;
+ pointsx[1] = 1; pointsy[1] = 1;
+ pointsx[2] = 0; pointsy[2] = 1;
+}
+
+bool MOD_DISTORT::operator == (MOD_DISTORT& md)
+{
+ return(enabled == md.enabled
+ && pointsx[0] == md.pointsx[0]
+ && pointsx[1] == md.pointsx[1]
+ && pointsx[2] == md.pointsx[2]
+ && pointsy[0] == md.pointsy[0]
+ && pointsy[1] == md.pointsy[1]
+ && pointsy[2] == md.pointsy[2]);
+}
+#endif
+
+#ifdef _VSMOD // patch m011. jitter
+MOD_JITTER::MOD_JITTER()
+{
+ seed = 0;
+ offset = CRect(0,0,0,0);
+ period = 1;
+ enabled = false;
+}
+
+bool MOD_JITTER::operator == (MOD_JITTER& mj)
+{
+ return(seed == mj.seed
+ && offset == mj.offset
+ && period == mj.period);
+}
+
+CPoint MOD_JITTER::getOffset(REFERENCE_TIME rt)
+{
+ if (!enabled) return CPoint(0,0);
+ if(period==0) period = 1;
+ int rseed = (seed + rt / period)*100;
+
+ srand(rseed);
+ rand();
+ int xoffset = rand();
+ xoffset = xoffset%(offset.left+offset.right) - offset.left;
+
+ //srand(rseed+1);
+ int yoffset = rand();
+ yoffset = yoffset%(offset.bottom+offset.top) - offset.top;
+
+ return CPoint((int)xoffset, (int)yoffset);
+}
+#endif
\ No newline at end of file diff --git a/src/subtitles/STS.h b/src/subtitles/STS.h index 9285f79bb..edde6f9b8 100644 --- a/src/subtitles/STS.h +++ b/src/subtitles/STS.h @@ -28,6 +28,117 @@ typedef enum {TIME, FRAME} tmode; // the meaning of STSEntry::start/end
+#ifdef _VSMOD // patch m003. random text points
+class MOD_RANDOM
+{
+public:
+ int X;
+ int Y;
+ int Z;
+ int Seed; // random seed
+
+ //MOD_RANDOM();
+ bool operator == (MOD_RANDOM& mr);
+
+ void clear();
+};
+#endif
+
+#ifdef _VSMOD // patch m010. png background
+#include <png.h>
+class MOD_PNGIMAGE
+{
+public:
+ CString filename;
+ int width;
+ int height;
+
+ int xoffset;
+ int yoffset;
+
+ int bpp;
+
+ BYTE alpha;
+
+ png_byte color_type;
+ png_byte bit_depth;
+
+ png_bytep* pointer;
+
+ MOD_PNGIMAGE();
+
+ bool operator == (MOD_PNGIMAGE& png);
+ /**/
+ bool processData(png_structp png_ptr);
+ bool initImage(CString m_fn);
+ bool initImage(BYTE* data, CString m_fn);
+ void freeImage();
+};
+#endif
+
+#ifdef _VSMOD // patch m004. gradient colors
+class MOD_GRADIENT
+{
+public:
+ COLORREF colors[4]; // c
+ COLORREF alphas[4]; // a
+ COLORREF color[4][4]; // vc
+ BYTE alpha[4][4]; // va
+ int mode[4];
+
+ // for renderer
+ int height;
+ int width;
+ int xoffset;
+ int yoffset;
+
+ BYTE subpixx;
+ BYTE subpixy;
+
+ BYTE img_alpha;
+
+ // for background image
+ MOD_PNGIMAGE b_images[4];
+
+ MOD_GRADIENT();
+ bool operator == (MOD_GRADIENT& mg);
+
+ void clear();
+ DWORD getmixcolor(int tx, int ty, int i);
+};
+#endif
+
+#ifdef _VSMOD // patch m008. distort
+class MOD_DISTORT
+{
+public:
+ double pointsx[3]; //P1-P3
+ double pointsy[3]; //P1-P3
+ bool enabled;
+
+ MOD_DISTORT();
+
+ bool operator == (MOD_DISTORT& md);
+};
+#endif
+
+#ifdef _VSMOD // patch m011. jitter
+class MOD_JITTER
+{
+public:
+ CRect offset; // left,top,right,left
+ int seed;
+ int period; // ms
+ bool enabled;
+
+ MOD_JITTER();
+
+ bool operator == (MOD_JITTER& mj);
+
+ CPoint getOffset(REFERENCE_TIME rt);
+};
+#endif
+
class STSStyle
{
public:
@@ -52,14 +163,37 @@ public: double fontAngleZ, fontAngleX, fontAngleY;
double fontShiftX, fontShiftY;
int relativeTo; // 0: window, 1: video, 2: undefined (~window)
+#ifdef _VSMOD
+ // patch m001. Vertical fontspacing
+ double mod_verticalSpace;
+ // patch m002. Z-coord
+ double mod_z;
+ // patch m003. random text points
+ MOD_RANDOM mod_rand;
+ // patch m004. gradient colors
+ MOD_GRADIENT mod_grad;
+ // patch m007. symbol rotating
+ int mod_fontOrient;
+ // patch m008. distort
+ MOD_DISTORT mod_distort;
+ // patch m011. jitter
+ MOD_JITTER mod_jitter;
+#endif
STSStyle();
+#ifdef _VSMOD
+ STSStyle(STSStyle& s);
+#endif
void SetDefault();
bool operator == (STSStyle& s);
bool IsFontStyleEqual(STSStyle& s);
+#ifdef _VSMOD
+ void mod_CopyStyleFrom(STSStyle& s);
+ void operator = (STSStyle& s);
+#endif
void operator = (LOGFONT& lf);
friend LOGFONTA& operator <<= (LOGFONTA& lfa, STSStyle& s);
@@ -86,6 +220,9 @@ typedef struct int layer;
int start, end;
int readorder;
+#ifdef _VSMOD // patch m009. png graphics
+ int mod_scripttype;
+#endif
} STSEntry;
class STSSegment
@@ -125,6 +262,10 @@ public: CSTSStyleMap m_styles;
+#ifdef _VSMOD
+ CAtlArray<MOD_PNGIMAGE> mod_images;
+#endif
+
enum EPARCompensationType
{
EPCTDisabled = 0,
@@ -153,8 +294,11 @@ public: bool Open(BYTE* data, int len, int CharSet, CString name);
bool SaveAs(CString fn, exttype et, double fps = -1, CTextFile::enc = CTextFile::ASCII);
+#ifdef _VSMOD // load embedded images
+ bool LoadUUEFile(CTextFile* file, CString m_fn);
+ bool LoadEfile(CString& img, CString m_fn);
+#endif
void Add(CStringW str, bool fUnicode, int start, int end, CString style = _T("Default"), CString actor = _T(""), CString effect = _T(""), CRect marginRect = CRect(0,0,0,0), int layer = 0, int readorder = -1);
-
STSStyle* CreateDefaultStyle(int CharSet);
void ChangeUnknownStylesToDefault();
void AddStyle(CString name, STSStyle* style); // style will be stored and freed in Empty() later
diff --git a/src/subtitles/TextFile.cpp b/src/subtitles/TextFile.cpp index d236e65d9..1f86a2aa0 100644 --- a/src/subtitles/TextFile.cpp +++ b/src/subtitles/TextFile.cpp @@ -203,7 +203,7 @@ void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/) else if(m_encoding == UTF8)
{
str.Replace(L"\n", L"\r\n");
- for(int i = 0; i < str.GetLength(); i++)
+ for(size_t i = 0; i < str.GetLength(); i++)
{
DWORD c = (WORD)str[i];
@@ -239,7 +239,7 @@ void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/) else if(m_encoding == BE16)
{
str.Replace(L"\n", L"\r\n");
- for(int i = 0; i < str.GetLength(); i++)
+ for(size_t i = 0; i < str.GetLength(); i++)
str.SetAt(i, ((str[i]>>8)&0x00ff)|((str[i]<<8)&0xff00));
Write((LPCWSTR)str, str.GetLength()*2);
}
@@ -483,7 +483,7 @@ void CWebTextFile::Close() CStringW AToW(CStringA str)
{
CStringW ret;
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (WCHAR)(BYTE)str[i];
return(ret);
}
@@ -491,7 +491,7 @@ CStringW AToW(CStringA str) CStringA WToA(CStringW str)
{
CStringA ret;
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (CHAR)(WORD)str[i];
return(ret);
}
@@ -499,7 +499,7 @@ CStringA WToA(CStringW str) CString AToT(CStringA str)
{
CString ret;
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (TCHAR)(BYTE)str[i];
return(ret);
}
@@ -507,7 +507,7 @@ CString AToT(CStringA str) CString WToT(CStringW str)
{
CString ret;
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (TCHAR)(WORD)str[i];
return(ret);
}
@@ -516,7 +516,7 @@ CStringA TToA(CString str) {
CStringA ret;
#ifdef UNICODE
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (CHAR)(BYTE)str[i];
#else
ret = str;
@@ -530,7 +530,7 @@ CStringW TToW(CString str) #ifdef UNICODE
ret = str;
#else
- for(int i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++)
ret += (WCHAR)(BYTE)str[i];
#endif
return(ret);
diff --git a/src/subtitles/USFSubtitles.cpp b/src/subtitles/USFSubtitles.cpp index 3d3de7fcf..e6dab2465 100644 --- a/src/subtitles/USFSubtitles.cpp +++ b/src/subtitles/USFSubtitles.cpp @@ -62,7 +62,7 @@ static CStringW GetXML(CComPtr<IXMLDOMNode> pNode) CStringW str(bstr);
str.Remove('\r');
str.Replace('\n', ' ');
- for(int i = 0; (i = str.Find(L" ", i)) >= 0; )
+ for(size_t i = 0; (i = str.Find(L" ", i)) >= 0; )
{
for(++i; i < str.GetLength() && (str[i] == '\n' || str[i] == ' ');)
str.Delete(i);
@@ -290,7 +290,7 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) if(!s->fontstyle.outline.IsEmpty()) stss->outlineWidthX = stss->outlineWidthY = wcstol(s->fontstyle.outline, NULL, 10);
if(!s->fontstyle.shadow.IsEmpty()) stss->shadowDepthX = stss->shadowDepthY = wcstol(s->fontstyle.shadow, NULL, 10);
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
DWORD color = ColorToDWORD(s->fontstyle.color[i]);
int alpha = (BYTE)wcstol(s->fontstyle.alpha, NULL, 10);
@@ -342,7 +342,7 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts) marginRect.top = marginRect.bottom = TranslateMargin(t->pal.vertical_margin, sts.m_dstScreenSize.cy);
WCHAR rtags[3][8] = {L"{\\rz%d}", L"{\\rx%d}", L"{\\ry%d}"};
- for(int i = 0; i < 3; i++)
+ for(ptrdiff_t i = 0; i < 3; i++)
{
if(int angle = wcstol(t->pal.rotate[i], NULL, 10))
{
@@ -725,7 +725,7 @@ void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str) if(!fs.outline.IsEmpty()) {prefix += L"{\\bord" + fs.outline + L"}"; postfix += L"{\\bord}";}
if(!fs.shadow.IsEmpty()) {prefix += L"{\\shad" + fs.shadow + L"}"; postfix += L"{\\shad}";}
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
{
if(!fs.color[i].IsEmpty())
{
diff --git a/src/subtitles/VobSubFile.cpp b/src/subtitles/VobSubFile.cpp index d73c468a2..e584ce64f 100644 --- a/src/subtitles/VobSubFile.cpp +++ b/src/subtitles/VobSubFile.cpp @@ -215,14 +215,14 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) {
Close();
- *static_cast<CVobSubSettings*>(this) = *static_cast<CVobSubSettings*>(&vsf);
+ *(CVobSubSettings*)this = *(CVobSubSettings*)&vsf;
m_title = vsf.m_title;
m_iLang = vsf.m_iLang;
m_sub.SetLength(vsf.m_sub.GetLength());
m_sub.SeekToBegin();
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
SubLang& src = vsf.m_langs[i];
SubLang& dst = m_langs[i];
@@ -231,7 +231,7 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) dst.name = src.name;
dst.alt = src.alt;
- for(int j = 0; j < src.subpos.GetCount(); j++)
+ for(ptrdiff_t j = 0; j < src.subpos.GetCount(); j++)
{
SubPos& sp = src.subpos[j];
if(!sp.fValid) continue;
@@ -247,7 +247,7 @@ bool CVobSubFile::Copy(CVobSubFile& vsf) WORD packetsize = (buff[buff[0x16]+0x18]<<8) | buff[buff[0x16]+0x19];
- for(int k = 0, size, sizeleft = packetsize - 4;
+ for(ptrdiff_t k = 0, size, sizeleft = packetsize - 4;
k < packetsize - 4;
k += size, sizeleft -= size)
{
@@ -308,11 +308,11 @@ bool CVobSubFile::Open(CString fn) m_title = fn;
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
CAtlArray<SubPos>& sp = m_langs[i].subpos;
- for(int j = 0; j < sp.GetCount(); j++)
+ for(ptrdiff_t j = 0; j < sp.GetCount(); j++)
{
sp[j].stop = sp[j].start;
sp[j].fForced = false;
@@ -371,7 +371,7 @@ void CVobSubFile::Close() m_sub.SetLength(0);
m_img.Invalidate();
m_iLang = -1;
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
m_langs[i].id = 0;
m_langs[i].name.Empty();
@@ -394,7 +394,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver) __int64 celltimestamp = 0;
CString str;
- for(int line = 0; !fError && f.ReadString(str); line++)
+ for(ptrdiff_t line = 0; !fError && f.ReadString(str); line++)
{
str.Trim();
@@ -811,7 +811,7 @@ bool CVobSubFile::ReadIfo(CString fn) f.Seek(pos*0x800 + offset + 0xa4, CFile::begin);
- for(int i = 0; i < 16; i++)
+ for(ptrdiff_t i = 0; i < 16; i++)
{
BYTE y, u, v, tmp;
@@ -941,7 +941,7 @@ bool CVobSubFile::WriteIdx(CString fn) // Subs
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
SubLang& sl = m_langs[i];
@@ -964,7 +964,7 @@ bool CVobSubFile::WriteIdx(CString fn) char vobid = -1, cellid = -1;
- for(int j = 0; j < sp.GetCount(); j++)
+ for(ptrdiff_t j = 0; j < sp.GetCount(); j++)
{
if(!sp[j].fValid) continue;
@@ -1050,7 +1050,7 @@ BYTE* CVobSubFile::GetPacket(int idx, int& packetsize, int& datasize, int iLang) if(!ret) break;
int i = 0, sizeleft = packetsize;
- for(int size;
+ for(ptrdiff_t size;
i < packetsize;
i += size, sizeleft -= size)
{
@@ -1226,14 +1226,14 @@ STDMETHODIMP CVobSubFile::GetClassID(CLSID* pClassID) STDMETHODIMP_(int) CVobSubFile::GetStreamCount()
{
int iStreamCount = 0;
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
if(m_langs[i].subpos.GetCount()) iStreamCount++;
return(iStreamCount);
}
STDMETHODIMP CVobSubFile::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
SubLang& sl = m_langs[i];
@@ -1263,7 +1263,7 @@ STDMETHODIMP_(int) CVobSubFile::GetStream() {
int iStream = 0;
- for(int i = 0; i < m_iLang; i++)
+ for(ptrdiff_t i = 0; i < m_iLang; i++)
if(!m_langs[i].subpos.IsEmpty()) iStream++;
return(iStream);
@@ -1271,7 +1271,7 @@ STDMETHODIMP_(int) CVobSubFile::GetStream() STDMETHODIMP CVobSubFile::SetStream(int iStream)
{
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
CAtlArray<SubPos>& sp = m_langs[i].subpos;
@@ -1356,12 +1356,12 @@ static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src) dw = dstrect.Width();
dh = dstrect.Height();
- for(int y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1))
+ for(ptrdiff_t y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1))
{
RGBQUAD* ptr = (RGBQUAD*)&((BYTE*)spd.bits)[y*spd.pitch] + dstrect.left;
RGBQUAD* endptr = ptr + dw;
- for(int sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++)
+ for(ptrdiff_t sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++)
{
// PixelAtBiLinear(*ptr, sx, srcy, src);
////
@@ -1418,7 +1418,7 @@ void CVobSubSettings::SetCustomPal(RGBQUAD* cuspal, int tridx) {
memcpy(m_cuspal, cuspal, sizeof(RGBQUAD)*4);
m_tridx = tridx & 0xf;
- for(int i = 0; i < 4; i++) m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
+ for(ptrdiff_t i = 0; i < 4; i++) m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
m_img.Invalidate();
}
@@ -1551,13 +1551,13 @@ bool CVobSubFile::SaveWinSubMux(CString fn) return(false);
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(int i = 0; i < sp.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < sp.GetCount(); i++)
{
if(!GetFrame(i)) continue;
int pal[4] = {0, 1, 2, 3};
- for(int j = 0; j < 5; j++)
+ for(ptrdiff_t j = 0; j < 5; j++)
{
if(j == 4 || !m_img.pal[j].tr)
{
@@ -1599,11 +1599,11 @@ bool CVobSubFile::SaveWinSubMux(CString fn) int h = m_img.rect.Height()-2;
int pitch = (((w+1)>>1) + 3) & ~3;
- for(int y = 0; y < h; y++)
+ for(ptrdiff_t y = 0; y < h; y++)
{
DWORD* p = (DWORD*)&m_img.lpPixels[(y+1)*(w+2)+1];
- for(int x = 0; x < w; x++, p++)
+ for(ptrdiff_t x = 0; x < w; x++, p++)
{
BYTE c = 0;
@@ -1770,11 +1770,11 @@ bool CVobSubFile::SaveScenarist(CString fn) BYTE colormap[16];
- for(int i = 0; i < 16; i++)
+ for(ptrdiff_t i = 0; i < 16; i++)
{
int idx = 0, maxdif = 255*255*3+1;
- for(int j = 0; j < 16 && maxdif; j++)
+ for(ptrdiff_t j = 0; j < 16 && maxdif; j++)
{
int rdif = pal[j].rgbRed - m_orgpal[i].rgbRed;
int gdif = pal[j].rgbGreen - m_orgpal[i].rgbGreen;
@@ -1790,11 +1790,11 @@ bool CVobSubFile::SaveScenarist(CString fn) int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(int i = 0, k = 0; i < sp.GetCount(); i++)
+ for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++)
{
if(!GetFrame(i)) continue;
- for(int j = 0; j < 5; j++)
+ for(ptrdiff_t j = 0; j < 5; j++)
{
if(j == 4 || !m_img.pal[j].tr)
{
@@ -1804,14 +1804,14 @@ bool CVobSubFile::SaveScenarist(CString fn) }
}
- for(int y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++)
+ for(ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++)
{
ASSERT(m_size.cy-y-1 >= 0);
if(m_size.cy-y-1 < 0) break;
DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
- for(int x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++)
+ for(ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++)
{
DWORD rgb = *p&0xffffff;
BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
@@ -1999,13 +1999,13 @@ bool CVobSubFile::SaveMaestro(CString fn) return(false);
BYTE colormap[16];
- for(int i = 0; i < 16; i++)
+ for(ptrdiff_t i = 0; i < 16; i++)
colormap[i] = i;
CFile spf;
if(spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary))
{
- for(int i = 0; i < 16; i++)
+ for(ptrdiff_t i = 0; i < 16; i++)
{
COLORREF c = (m_orgpal[i].rgbBlue<<16) | (m_orgpal[i].rgbGreen<<8) | m_orgpal[i].rgbRed;
spf.Write(&c, sizeof(COLORREF));
@@ -2017,11 +2017,11 @@ bool CVobSubFile::SaveMaestro(CString fn) int pc[4] = {1,1,1,1}, pa[4] = {15,15,15,0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(int i = 0, k = 0; i < sp.GetCount(); i++)
+ for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++)
{
if(!GetFrame(i)) continue;
- for(int j = 0; j < 5; j++)
+ for(ptrdiff_t j = 0; j < 5; j++)
{
if(j == 4 || !m_img.pal[j].tr)
{
@@ -2031,14 +2031,14 @@ bool CVobSubFile::SaveMaestro(CString fn) }
}
- for(int y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++)
+ for(ptrdiff_t y = max(m_img.rect.top+1, 2); y < m_img.rect.bottom-1; y++)
{
ASSERT(m_size.cy-y-1 >= 0);
if(m_size.cy-y-1 < 0) break;
DWORD* p = (DWORD*)&m_img.lpPixels[(y-m_img.rect.top)*m_img.rect.Width()+1];
- for(int x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++)
+ for(ptrdiff_t x = m_img.rect.left+1; x < m_img.rect.right-1; x++, p++)
{
DWORD rgb = *p&0xffffff;
BYTE c = rgb == 0x0000ff ? 0 : rgb == 0xff0000 ? 1 : rgb == 0x000000 ? 2 : 3;
@@ -2193,7 +2193,7 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len) else if(key == _T("palette"))
{
Explode(value, sl, ',', 16);
- for(int i = 0; i < 16 && sl.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < 16 && sl.GetCount(); i++)
*(DWORD*)&m_orgpal[i] = _tcstol(sl.RemoveHead(), NULL, 16);
}
else if(key == _T("custom colors"))
@@ -2208,14 +2208,14 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len) {
TCHAR tr[4];
_stscanf(tridx.RemoveHead(), _T("%c%c%c%c"), &tr[0], &tr[1], &tr[2], &tr[3]);
- for(int i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++)
m_tridx |= ((tr[i]=='1')?1:0)<<i;
}
Explode(sl.RemoveHead(), colors, ':', 2);
if(colors.RemoveHead() == _T("colors"))
{
Explode(colors.RemoveHead(), colors, ',', 4);
- for(int i = 0; i < 4 && colors.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < 4 && colors.GetCount(); i++)
*(DWORD*)&m_cuspal[i] = _tcstol(colors.RemoveHead(), NULL, 16);
}
}
diff --git a/src/subtitles/VobSubFileRipper.cpp b/src/subtitles/VobSubFileRipper.cpp index 5ed8c2b0c..cf793d09a 100644 --- a/src/subtitles/VobSubFileRipper.cpp +++ b/src/subtitles/VobSubFileRipper.cpp @@ -145,7 +145,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) int len = 0;
ReadBEw(len);
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
f.Seek(2, CFile::current); // 01 00 ?
ReadBEw(ids[i]);
@@ -187,7 +187,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) m_rd.pgcs.RemoveAll();
m_rd.pgcs.SetCount(nPGC);
- for(int i = 0; i < nPGC; i++)
+ for(ptrdiff_t i = 0; i < nPGC; i++)
{
PGC& pgc = m_rd.pgcs[i];
@@ -210,7 +210,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) f.Seek(offset + 0x1c, CFile::begin);
f.Read(splinfo, 32*4);
- for(int j = 0; j < 32; j++)
+ for(ptrdiff_t j = 0; j < 32; j++)
{
if(splinfo[j].id1 || splinfo[i].id2)
{
@@ -233,7 +233,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) f.Seek(offset + 0xa4, CFile::begin);
- for(int j = 0; j < 16; j++)
+ for(ptrdiff_t j = 0; j < 16; j++)
{
BYTE y, u, v, tmp;
@@ -274,7 +274,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) //
f.Seek(offset + vobcelloff, CFile::begin);
- for(int j = 0; j < nCells; j++)
+ for(ptrdiff_t j = 0; j < nCells; j++)
{
ReadBEw(pgc.angles[0][j].vob);
ReadBEw(pgc.angles[0][j].cell);
@@ -289,7 +289,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) pgc.nAngles = 0;
f.Seek(offset + celladdroff, CFile::begin);
- for(int j = 0; j < nCells; j++)
+ for(ptrdiff_t j = 0; j < nCells; j++)
{
BYTE b;
ReadBEb(b);
@@ -338,7 +338,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn) {
tOffset = tTotal = 0;
- for(int j = 0, k = 0; j < nCells; j++)
+ for(ptrdiff_t j = 0, k = 0; j < nCells; j++)
{
if(pgc.angles[0][j].iAngle != 0
&& pgc.angles[0][j].iAngle != iAngle)
@@ -372,7 +372,7 @@ bool CVobSubFileRipper::LoadVob(CString fn) fn = fn.Left(fn.ReverseFind('.')+1);
fn.TrimRight(_T(".0123456789"));
- for(int i = 0; i < 100; i++)
+ for(ptrdiff_t i = 0; i < 100; i++)
{
CString vob;
vob.Format(_T("%s%d.vob"), fn, i);
@@ -555,7 +555,7 @@ bool CVobSubFileRipper::Create() if(m_rd.fResetTime)
{
- for(int i = 0; i < angle.GetCount() && ((angle[i].vob<<16)|angle[i].cell) != m_rd.selvcs[0]; i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount() && ((angle[i].vob<<16)|angle[i].cell) != m_rd.selvcs[0]; i++)
tStart += angle[i].tTime;
Log(LOG_INFO, _T("Counting timestamps from %I64dms (v%02dc%02d)"),
@@ -564,7 +564,7 @@ bool CVobSubFileRipper::Create() CAtlMap<DWORD, int> selvcmap;
selvcmap.RemoveAll();
- for(int i = 0; i < m_rd.selvcs.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_rd.selvcs.GetCount(); i++)
selvcmap[m_rd.selvcs[i]] = 90000;
CAtlArray<vcchunk> chunks, foundchunks, loadedchunks;
@@ -573,7 +573,7 @@ bool CVobSubFileRipper::Create() {
Log(LOG_INFO, _T("Indexing mode: DVD"));
- for(int i = 0; i < angle.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
{
DWORD vc = (angle[i].vob<<16)|angle[i].cell;
if(!selvcmap.Lookup(vc))
@@ -590,7 +590,7 @@ bool CVobSubFileRipper::Create() {
Log(LOG_INFO, _T("Indexing mode: File"));
- for(int i = 0; i < loadedchunks.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < loadedchunks.GetCount(); i++)
{
DWORD vcid = loadedchunks[i].vc;
if(!selvcmap.Lookup(vcid))
@@ -611,10 +611,10 @@ bool CVobSubFileRipper::Create() }
__int64 sizedone = 0, sizetotal = 0;
- for(int i = 0; i < chunks.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < chunks.GetCount(); i++)
sizetotal += chunks[i].end - chunks[i].start;
- for(int i = 0; !m_fBreakThread && i < chunks.GetCount(); i++)
+ for(ptrdiff_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++)
{
__int64 curpos = chunks[i].start, endpos = chunks[i].end;
@@ -719,7 +719,7 @@ bool CVobSubFileRipper::Create() tOffset = tTotal = 0;
- for(int i = 0; i < angle.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
{
if(angle[i].vob == vob && angle[i].cell == cell)
{
@@ -830,7 +830,7 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Indexing finished"));
Progress(1);
- for(int i = 0; i < 32; i++)
+ for(ptrdiff_t i = 0; i < 32; i++)
{
if(m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) m_iLang = i;
m_langs[i].id = pgc.ids[i];
@@ -844,7 +844,7 @@ bool CVobSubFileRipper::Create() Log(LOG_INFO, _T("Searching for forced subs..."));
Progress(0);
- for(int j = 0, len = sp.GetCount(); j < len; j++)
+ for(ptrdiff_t j = 0, len = sp.GetCount(); j < len; j++)
{
Progress(1.0 * j / len);
@@ -1033,7 +1033,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) s++;
if(vob != 0 && cell == 0)
{
- for(int i = 0; i < angle.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
{
if(angle[i].vob == vob)
m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
@@ -1048,7 +1048,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) s++;
cell = _tcstol(s, &s, 10);
- for(int i = 0; i < angle.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
{
if(angle[i].vob == vob && angle[i].cell == cell)
{
@@ -1065,7 +1065,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) }
else
{
- for(int i = 0; i < angle.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
m_rd.selvcs.Add((angle[i].vob<<16)|angle[i].cell);
}
@@ -1075,7 +1075,7 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn) {
if(!line.CompareNoCase(_T("ALL")))
{
- for(int i = 0; i < 32; i++) m_rd.selids[i] = true;
+ for(ptrdiff_t i = 0; i < 32; i++) m_rd.selids[i] = true;
m_rd.fClosedCaption = true;
phase = P_OPTIONS;
}
@@ -1226,12 +1226,12 @@ void VSFRipperData::Copy(VSFRipperData& rd) if(int len = rd.pgcs.GetCount())
{
pgcs.SetCount(len);
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
PGC& src = rd.pgcs[i];
PGC& dst = pgcs[i];
dst.nAngles = src.nAngles;
- for(int i = 0; i < countof(dst.angles); i++)
+ for(ptrdiff_t i = 0; i < countof(dst.angles); i++)
dst.angles[i].Copy(src.angles[i]);
dst.iSelAngle = src.iSelAngle;
memcpy(dst.pal, src.pal, sizeof(src.pal));
diff --git a/src/subtitles/VobSubImage.cpp b/src/subtitles/VobSubImage.cpp index add35a0c9..b1ddea6ba 100644 --- a/src/subtitles/VobSubImage.cpp +++ b/src/subtitles/VobSubImage.cpp @@ -268,9 +268,9 @@ void CVobSubImage::TrimSubImage() RGBQUAD* ptr = lpTemp1;
- for(int j = 0, y = rect.Height(); j < y; j++)
+ for(ptrdiff_t j = 0, y = rect.Height(); j < y; j++)
{
- for(int i = 0, x = rect.Width(); i < x; i++, ptr++)
+ for(ptrdiff_t i = 0, x = rect.Width(); i < x; i++, ptr++)
{
if(ptr->rgbReserved)
{
@@ -299,7 +299,7 @@ void CVobSubImage::TrimSubImage() memset(lpTemp2, 0, (1 + w + 1)*sizeof(RGBQUAD));
- for(int height = h; height; height--, src += rect.Width())
+ for(ptrdiff_t height = h; height; height--, src += rect.Width())
{
*dst++ = 0;
memcpy(dst, src, w*sizeof(RGBQUAD)); dst += w;
@@ -334,7 +334,7 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft) BYTE* cp = p;
RGBQUAD* rgbp = (RGBQUAD*)lpPixels;
- for(int i = 0; i < len; i++, cp++, rgbp++)
+ for(ptrdiff_t i = 0; i < len; i++, cp++, rgbp++)
*cp = !!rgbp->rgbReserved;
enum {UP, RIGHT, DOWN, LEFT};
@@ -544,7 +544,7 @@ static int CalcPossibleCurveDegree(COutline& o) CUIntArray la;
- for(int i = 0, j = 0; j < len2; j++)
+ for(ptrdiff_t i = 0, j = 0; j < len2; j++)
{
if(j == len2-1 || o.da[j])
{
@@ -563,10 +563,10 @@ static int CalcPossibleCurveDegree(COutline& o) int penalty = 0;
int ma[2] = {0, 0};
- for(int i = 0; i < len; i++) ma[i&1] += la[i];
+ for(ptrdiff_t i = 0; i < len; i++) ma[i&1] += la[i];
int ca[2] = {ma[0], ma[1]};
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
ca[i&1] -= la[i];
@@ -585,7 +585,7 @@ static int CalcPossibleCurveDegree(COutline& o) la[0] <<= 1;
la[len-1] <<= 1;
- for(int i = 0; i < len; i+=2)
+ for(ptrdiff_t i = 0; i < len; i+=2)
{
if(la[i] > 1) {ret++; i--;} // prependicular to the last chosen section and bigger then 1 -> add a degree and continue with the other dir
}
@@ -616,7 +616,7 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really CPoint p = pa[len-1] - pa[0];
double l = vectlen(p);
- for(int i = 2; i < len-2; i++) // skip the endpoints, they aren't accurate
+ for(ptrdiff_t i = 2; i < len-2; i++) // skip the endpoints, they aren't accurate
{
CPoint p1 = pa[0] - pa[i], p2 = pa[len-1] - pa[i];
double l1 = vectlen(p1), l2 = vectlen(p2);
@@ -758,7 +758,7 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret) int cur = (start)%len, first = -1, last = -1;
int curDir = 0, lastDir = 0;
- for(int i = 0; i < len; i++)
+ for(ptrdiff_t i = 0; i < len; i++)
{
cur = (cur+1)%len;
@@ -942,7 +942,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(o.pa[2]);
- for(int i = 3; i <= start; i++)
+ for(ptrdiff_t i = 3; i <= start; i++)
{
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
@@ -1013,7 +1013,7 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat while(pos)
{
CAtlArray<CPoint>& pa = ol->GetNext(pos)->pa;
- for(int i = 0; i < pa.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < pa.GetCount(); i++)
{
pa[i].x = (pa[i].x-topleft.x)<<scale;
pa[i].y = (pa[i].y-topleft.y)<<scale;
@@ -1048,7 +1048,7 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat else
{
/*
- for(int i = 1, len = o.pa.GetSize(); i < len; i++)
+ for(ptrdiff_t i = 1, len = o.pa.GetSize(); i < len; i++)
{
if(int dir = o.da[i-1])
{
@@ -1069,7 +1069,7 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat pathTypes.Add(PT_MOVETO);
pathPoints.Add(o.pa[0]);
- for(int i = 1, len = int(o.pa.GetCount()); i < len; i++)
+ for(ptrdiff_t i = 1, len = int(o.pa.GetCount()); i < len; i++)
{
pathTypes.Add(PT_LINETO);
pathPoints.Add(o.pa[i]);
@@ -1095,7 +1095,7 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale) int nPoints = int(pathTypes.GetCount());
- for(int i = 0; i < nPoints; i++)
+ for(ptrdiff_t i = 0; i < nPoints; i++)
{
CStringW s;
@@ -1152,9 +1152,9 @@ void CVobSubImage::Scale2x() DWORD* src = (DWORD*)lpPixels;
DWORD* dst = DNew DWORD[w*h];
- for(int y = 0; y < h; y++)
+ for(ptrdiff_t y = 0; y < h; y++)
{
- for(int x = 0; x < w; x++, src++, dst++)
+ for(ptrdiff_t x = 0; x < w; x++, src++, dst++)
{
DWORD E = *src;
@@ -1162,8 +1162,8 @@ void CVobSubImage::Scale2x() DWORD B = y > 0 ? src[-w] : E;
DWORD C = x < w-1 && y > 0 ? src[-w+1] : E;
- DWORD D = x > 0 ? src[-1] : E;
- DWORD F = x < w-1 ? src[+1] : E;
+ DWORD D = x > 0 ? src[-1] : E;;
+ DWORD F = x < w-1 ? src[+1] : E;;
DWORD G = x > 0 && y < h-1 ? src[+w-1] : E;
DWORD H = y < h-1 ? src[+w] : E;
|