Repository: Herschel/Swivel Branch: master Commit: 8032fdf3a46c Files: 150 Total size: 62.4 MB Directory structure: gitextract__150jprk/ ├── .appveyor.yml ├── .gitignore ├── .gitmodules ├── .travis.yml ├── LICENSE.md ├── Makefile ├── PackageApp.bat ├── README.md ├── Run.bat ├── Swivel.hxml ├── Swivel.hxproj ├── SwivelHuey.xml ├── application.xml ├── assets/ │ ├── SwivelFonts.fla │ ├── SwivelFonts.swf │ └── inject_swfs/ │ ├── AS2Basics.fla │ ├── AS2Basics.swf │ ├── AS2SoundLogger.fla │ ├── AS2SoundLogger.swf │ ├── AS3Basics.swc │ ├── AS3Core.fla │ ├── AS3Core.swf │ ├── __Swivel.as │ ├── __SwivelSound.as │ └── __SwivelSoundChannel.as ├── bat/ │ ├── CreateCertificate.bat │ ├── Packager.bat │ ├── SetupApplication.bat │ ├── SetupSDK.bat │ └── Swivel.p12 ├── ffmpeg/ │ ├── licenses/ │ │ ├── bzip2.txt │ │ ├── ffmpeg.txt │ │ ├── fontconfig.txt │ │ ├── freetype.txt │ │ ├── frei0r.txt │ │ ├── gnutls.txt │ │ ├── lame.txt │ │ ├── libass.txt │ │ ├── libbluray.txt │ │ ├── libcaca.txt │ │ ├── libgsm.txt │ │ ├── libtheora.txt │ │ ├── libvorbis.txt │ │ ├── libvpx.txt │ │ ├── opencore-amr.txt │ │ ├── openjpeg.txt │ │ ├── opus.txt │ │ ├── rtmpdump.txt │ │ ├── schroedinger.txt │ │ ├── speex.txt │ │ ├── twolame.txt │ │ ├── vo-aacenc.txt │ │ ├── vo-amrwbenc.txt │ │ ├── x264.txt │ │ ├── xavs.txt │ │ ├── xvid.txt │ │ └── zlib.txt │ └── mac64/ │ └── ffmpeg ├── huey/ │ ├── src/ │ │ └── com/ │ │ └── huey/ │ │ ├── Main.hx │ │ ├── assets/ │ │ │ ├── Asset.hx │ │ │ ├── AssetManager.hx │ │ │ └── AssetSource.hx │ │ ├── binding/ │ │ │ ├── BindableArray.hx │ │ │ └── Binding.hx │ │ ├── core/ │ │ │ ├── Application.hx │ │ │ └── ApplicationMacros.hx │ │ ├── events/ │ │ │ └── Dispatcher.hx │ │ ├── macros/ │ │ │ ├── ClassBuilder.hx │ │ │ ├── FieldInfo.hx │ │ │ ├── MacroTools.hx │ │ │ └── Macros.hx │ │ ├── tests/ │ │ │ ├── AsyncTestCase.hx │ │ │ ├── AsyncTestVisitor.hx │ │ │ ├── ITest.hx │ │ │ ├── ITestVisitor.hx │ │ │ ├── TestBuilder.hx │ │ │ ├── TestCase.hx │ │ │ ├── TestRunner.hx │ │ │ ├── TestStatus.hx │ │ │ └── TestSuite.hx │ │ ├── ui/ │ │ │ ├── Button.hx │ │ │ ├── CheckBox.hx │ │ │ ├── Component.hx │ │ │ ├── Container.hx │ │ │ ├── Image.hx │ │ │ ├── Label.hx │ │ │ ├── ListBox.hx │ │ │ ├── NumericStepper.hx │ │ │ ├── ProgressBar.hx │ │ │ ├── RadioButton.hx │ │ │ ├── RadioGroup.hx │ │ │ ├── Rectangle.hx │ │ │ ├── ScaledImage.hx │ │ │ ├── SelectBox.hx │ │ │ ├── Slider.hx │ │ │ ├── StateContainer.hx │ │ │ ├── TextAlign.hx │ │ │ ├── TextBox.hx │ │ │ ├── UIEvent.hx │ │ │ └── UIMacros.hx │ │ └── utils/ │ │ ├── Assert.hx │ │ ├── Logger.hx │ │ ├── Thread.hx │ │ └── WeakRef.hx │ └── test/ │ └── com/ │ └── huey/ │ ├── assets/ │ │ └── AssetTests.hx │ ├── binding/ │ │ └── BindingTests.hx │ ├── core/ │ │ └── ApplicationTests.hx │ ├── events/ │ │ └── EventTests.hx │ ├── macros/ │ │ └── MacroTests.hx │ ├── ui/ │ │ └── UITests.hx │ └── utils/ │ ├── AssertTests.hx │ └── WeakRefTest.hx ├── mac-installer.json ├── redirecter/ │ ├── redirecter/ │ │ ├── main.cpp │ │ ├── redirecter.vcxproj │ │ └── redirecter.vcxproj.filters │ └── redirecter.sln ├── src/ │ └── com/ │ └── newgrounds/ │ └── swivel/ │ ├── PreviewGenerator.hx │ ├── SplashScreen.hx │ ├── Swivel.hx │ ├── SwivelController.hx │ ├── SwivelJob.hx │ ├── audio/ │ │ ├── ActionScriptSoundInstance.hx │ │ ├── AudioTracker.hx │ │ ├── Decoder.hx │ │ ├── EventSoundInstance.hx │ │ ├── SoundClip.hx │ │ ├── SoundInstance.hx │ │ └── SoundSample.hx │ ├── ffmpeg/ │ │ ├── AudioCodec.hx │ │ ├── FfmpegProcess.hx │ │ └── VideoPreset.hx │ └── swf/ │ ├── AS3SoundConnectionMutator.hx │ ├── AS3SwivelConnection.hx │ ├── AbcUtils.hx │ ├── BitmapSmoothingMutator.hx │ ├── ISWFMutator.hx │ ├── RenderQuality.hx │ ├── SWFRecorder.hx │ ├── ScaleFilterMutator.hx │ ├── SilenceSoundMutator.hx │ ├── SoundConnectionMutator.hx │ ├── SwfUtils.hx │ ├── SwivelAbcContext.hx │ ├── SwivelConnection.hx │ ├── SwivelMutator.hx │ ├── SwivelSwf.hx │ ├── SwivelSwfReader.hx │ └── Watermark.hx └── win-installer.nsi ================================================ FILE CONTENTS ================================================ ================================================ FILE: .appveyor.yml ================================================ version: "{build}" environment: global: HAXELIB_ROOT: C:\projects\haxelib cache: - c:\projects\air init: - set AIR_SDK=c:\projects\air install: # Chocolatey was failing trying to install some Windows updates..!? # This fixes it somehow. - ps: Set-Service wuauserv -StartupType Manual - cinst -y php # Appveyor doesn't get submodules by default. - git submodule update --init --recursive # Install the haxe chocolatey package (https://chocolatey.org/packages/haxe) - cinst haxe --version 3.4.7 -y # Install NSIS for installer generation. - cinst nsis --version 3.02 -y - RefreshEnv # Setup haxelib - mkdir "%HAXELIB_ROOT%" - haxelib setup "%HAXELIB_ROOT%" # Install project dependencies # `> log.txt || type log.txt` is for muting the output unless there is an error - haxelib install air3 > log.txt || type log.txt && cmd /C exit 1 - haxelib list # Download and unzip Adobe AIR SDK if not cached. - if not exist %AIR_SDK% ( curl -fsS -O https://airdownload.adobe.com/air/win/download/latest/AIRSDK_Compiler.zip && mkdir %AIR_SDK% && 7z x -o%AIR_SDK% AIRSDK_Compiler.zip) # We don't use the build section, but do both build and # test in `test_script:`. # It is just because it is more similar to the TravisCI config, # thus it would be easier to update both of them. build: off test_script: # Build Swivel.swf. - haxe Swivel.hxml # Package AIR runtime. - PackageApp.bat # Build NSIS installer. - set PATH="C:\Program Files (x86)\NSIS";%PATH% - makensis win-installer.nsi artifacts: - path: swivel-win32.exe ================================================ FILE: .gitignore ================================================ /bin /obj /redirecter/ipch /redirecter/Debug /redirecter/Release /redirecter/redirecter/Debug /redirecter/redirecter/Release RECOVER_*.fla swivel*.exe Swivel.exe *.mp4 *.opensdf *.sdf *.suo *.vcxproj.user Thumbs.db ================================================ FILE: .gitmodules ================================================ [submodule "lib/format"] path = lib/format url = https://github.com/Herschel/format ================================================ FILE: .travis.yml ================================================ language: haxe os: osx env: - AIR_SDK=air_sdk HAXELIB_ROOT=haxelib cache: directiories: - air_sdk - haxelib install: # Setup haxelib and install libraries. - mkdir $HAXELIB_ROOT - haxelib setup $HAXELIB_ROOT - yes | haxelib install Swivel.hxml # Download and unzip the Adobe AIR SDK if not cached. - test -f $AIR_SDK || ( curl -fsS -O https://airdownload.adobe.com/air/mac/download/latest/AIRSDK_Compiler.dmg && mkdir $AIR_SDK && hdiutil attach -noverify -mountpoint /Volumes/air AIRSDK_Compiler.dmg && cp -R /Volumes/air/* $AIR_SDK && hdiutil detach /Volumes/air) - export PATH=$PATH:$AIR_SDK/bin # Install appdmg node package. - npm install -g appdmg@0.5.2 script: # Run make to build package. - make all haxe: - "3.4.4" - development matrix: allow_failures: - haxe: development deploy: provider: releases api_key: - secure: "i0Fm7EmabkefgOfe/G6tUKwtnWonGugKMsyZognTlBJbqGkrsJMt34fSlqk7HnoG7B3P6FXbJDwGwunQWQx/AUDB2jyTec4Oawd6WJ8LhWs9KAPW5GiDWXJvJTLGdvCS1aFj62cs80XH6ipmCUpIx1nxvN+Vh24zxltjQyHShiAvjYOaxiQ5vfFYKaSTJB6MwfC/p4B5JXgcn9eioe2FZj4xR726Ug3YR7zQm7jc/f9NZL5c6Q34iAyBbKzNe6lMiypMaPtZQekQ/NrVqaVtTNeJnnbLRET09DLnSVPFiqKuBi2RiBYy2vJRXucaCCjlHx6FzgdR+m0l+9ExkQvmcaZn2SxamSfru6Kqd5jrbYZpMB1JlkI6xTnEih5PPuTZom5eOfsu4TsWTw4s7fXJccIYSZ3Lstym5XDpFAe2KmLf08RiLbqQ0QDQZPBvxGTJ9R0yORH6V8yft1N1OhZIFRvw+P24aJyh8+zJBQvqAKEZo4t/eJ5ftNp026lwNsBg1xKy+X39aOCQ+vTNnd8enJES/5yLmNN4howIfuD7eZdrpVKx/aXWapoceArRFJMO7KnSdw5/LmRF/UAzzgAWcInCOIQL9EK3gVd0pH5Nj3wLZgYu/tX9qFLNlgatCStoPX9axSbB6Znp6JDgGG3EqZcc1VGCozMWCEoTWw5jdUk=" file: "bin/Swivel.dmg" skip_cleanup: true on: tags: true ================================================ FILE: LICENSE.md ================================================ GNU General Public License ========================== _Version 3, 29 June 2007_ _Copyright © 2007 Free Software Foundation, Inc. <>_ Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. ## Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: **(1)** assert copyright on the software, and **(2)** offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. ## TERMS AND CONDITIONS ### 0. Definitions “This License” refers to version 3 of the GNU General Public License. “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. “The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. A “covered work” means either the unmodified Program or a work based on the Program. To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that **(1)** displays an appropriate copyright notice, and **(2)** tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. ### 1. Source Code The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The “System Libraries” of an executable work include anything, other than the work as a whole, that **(a)** is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and **(b)** serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. ### 2. Basic Permissions All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. ### 4. Conveying Verbatim Copies You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. ### 5. Conveying Modified Source Versions You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: * **a)** The work must carry prominent notices stating that you modified it, and giving a relevant date. * **b)** The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. * **c)** You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. * **d)** If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. ### 6. Conveying Non-Source Forms You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: * **a)** Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. * **b)** Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either **(1)** a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or **(2)** access to copy the Corresponding Source from a network server at no charge. * **c)** Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. * **d)** Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. * **e)** Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A “User Product” is either **(1)** a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or **(2)** anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. “Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. ### 7. Additional Terms “Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: * **a)** Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or * **b)** Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or * **c)** Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or * **d)** Limiting the use for publicity purposes of names of licensors or authors of the material; or * **e)** Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or * **f)** Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. ### 8. Termination You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated **(a)** provisionally, unless and until the copyright holder explicitly and finally terminates your license, and **(b)** permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. ### 9. Acceptance Not Required for Having Copies You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. ### 10. Automatic Licensing of Downstream Recipients Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. ### 11. Patents A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either **(1)** cause the Corresponding Source to be so available, or **(2)** arrange to deprive yourself of the benefit of the patent license for this particular work, or **(3)** arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license **(a)** in connection with copies of the covered work conveyed by you (or copies made from those copies), or **(b)** primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. ### 12. No Surrender of Others' Freedom If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. ### 13. Use with the GNU Affero General Public License Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. ### 14. Revised Versions of this License The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. ### 15. Disclaimer of Warranty 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. ### 16. Limitation of Liability IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. ### 17. Interpretation of Sections 15 and 16 If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. _END OF TERMS AND CONDITIONS_ ## 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 state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an “about box”. You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <>. The GNU 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 Lesser General Public License instead of this License. But first, please read <>. ================================================ FILE: Makefile ================================================ HAXE=haxe ADL=adl ADT=adt SWF=bin/Swivel.swf CERT_PASS=ngswivel!430 PACKAGE_FILES=application.xml $(SWF) ffmpeg/mac64 ffmpeg/licenses assets/icons README.md LICENSE.md ADTFLAGS=-package -storetype pkcs12 -keystore bat/Swivel.p12 -storepass $(CERT_PASS) -target bundle bin/Swivel HXML_FILE=Swivel.hxml APP_PATH=bin/Swivel.app DMG_PATH=bin/Swivel.dmg .PHONY: clean package debug run all: package run: $(SWF) $(ADL) application.xml . debug: # Force rebuild with debug parameters. $(HAXE) $(HXML_FILE) -debug -D fdb $(ADL) application.xml . package: $(DMG_PATH) clean: rm -rf bin $(SWF): $(HXML_FILE) $(HAXE) $(HXML_FILE) $(HXML_FLAGS) $(DMG_PATH): $(APP_PATH) mac-installer.json # Use appdmg to build the DMG image. rm -rf $(DMG_PATH) appdmg mac-installer.json $(DMG_PATH) $(APP_PATH): $(SWF) $(PACKAGE_FILES) # Package app using ADT. $(ADT) $(ADTFLAGS) $(PACKAGE_FILES) # Create debug file to force AIR app into Debug mode. # This is necessary to use the System.pause methods in AS3. touch bin/Swivel.app/Contents/Resources/META-INF/debug ================================================ FILE: PackageApp.bat ================================================ @echo off set PAUSE_ERRORS=1 call bat\SetupSDK.bat call bat\SetupApplication.bat set AIR_TARGET= set OPTIONS= call bat\Packager.bat echo. 2>bin\Swivel\META-INF\AIR\debug ================================================ FILE: README.md ================================================ # ![Swivel](https://www.newgrounds.com/imgs/swivel/logo.png) [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/Herschel/Swivel)](https://ci.appveyor.com/project/Herschel/swivel) [![Travis Build Status](https://travis-ci.org/Herschel/Swivel.svg?branch=master)](https://travis-ci.org/Herschel/Swivel) Converts Adobe Flash SWF files to video. ## Binaries The latest stable release of Swivel can be found at . ## Building from source Swivel is built using the [Haxe](http://www.haxe.org) programming language. Run `haxe Swivel.hxml` to build, then run `PackageApp.bat` to package the app. The current source will have regressions from the binary release on Newgrounds; I'm trying to get everything working again! ## License Swivel is licensed under the GNU GPLv3. See [LICENSE.md](LICENSE.md) for the full license. Swivel runs using the [Adobe AIR](https://get.adobe.com/air/) runtime. AIR is owned by Adobe Systems, Inc. Swivel uses software from the [FFmpeg](https://www.ffmpeg.org) project along with supporting libraries, licensed under their corresponding licenses. These libraries include: bzip2, fontconfig, FreeType, frei0r, gnutls, LAME, libass, libbluray, libcaca, libgsm, libtheora, libvorbis, libvpx, opencore-amr, openjpeg, opus, rtmpdump, schroedinger, speez, twolame, vo-aacenc, vo-amrwbenc, libx264, xavs, xvid, zlib The full licenses for FFmpeg and each library can be found in the [FFmpeg/licenses](FFmpeg/licenses) folder. These licenses are compatible with the GPLv3. FFmpeg and the these libraries are property of their respective owners. The FFmpeg build bundled in this software was compiled by Kyle Schwarz and downloaded from . ================================================ FILE: Run.bat ================================================ @echo off set PAUSE_ERRORS=1 call bat\SetupSDK.bat call bat\SetupApplication.bat echo. echo Starting AIR Debug Launcher... echo. adl "%APP_XML%" . if errorlevel 1 goto error goto end :error pause :end ================================================ FILE: Swivel.hxml ================================================ com.newgrounds.swivel.Swivel -cp src -cp huey/src -cp huey/test -cp lib/format -lib air3 -main com.newgrounds.swivel.Swivel -swf bin/Swivel.swf -swf-header 930:590:30 -swf-version 27 -swf-lib assets/SwivelFonts.swf -D air --flash-strict ================================================ FILE: Swivel.hxproj ================================================  ================================================ FILE: SwivelHuey.xml ================================================ ================================================ FILE: application.xml ================================================ com.newgrounds.swivel.Swivel 1.12 Swivel Swivel SWF-to-video converter 2013 Newgrounds.com, Inc. extendedDesktop desktop assets/icons/SWV_PNG-16.png assets/icons/SWV_PNG-32.png assets/icons/SWV_PNG-128.png assets/icons/SWV_PNG-512.png Swivel bin/Swivel.swf none true true true false false ================================================ FILE: assets/inject_swfs/__Swivel.as ================================================ package { import flash.events.Event; import flash.events.IEventDispatcher; import flash.net.LocalConnection; import flash.net.SharedObject; import flash.display.MovieClip; import flash.display.Stage; import flash.utils.getDefinitionByName; import flash.display.Shape; import flash.display.DisplayObject; public class __Swivel { private static var __swivelSharedObj : SharedObject; private static var _swivelCon : Object; private static var _frame : int = 0; private static var _root : MovieClip; private static var _s : __SwivelSound; private static var _mask : Shape; private static var _startFrame : int; public static function __swivel(...args) : void { //args.unshift("__swivel"); //__swivelCon.send.apply(__swivelCon, args); //trace("swivel: " + args); _swivelCon.receiveMessage(args); } public static function get frame() : uint { return _frame - 1; } public static function setMask(clip : DisplayObject, margin : Number) : void { if(margin < 10) margin = 10; var m : Shape = new Shape(); m.graphics.beginFill(0); m.graphics.drawRect(-margin, -margin, stage.stageWidth+margin*2, stage.stageHeight+margin*2); m.graphics.endFill(); // TODO: Dangerous... does this allow GC safely? stage.addChild(m); m.visible = false; clip.mask = m; } public static function get stage() : Stage { try { var ow : Array = getDefinitionByName("flash.desktop.NativeApplication").nativeApplication.openedWindows; return ow[ow.length-1].stage; } catch(error:*) { } return null; } public static function registerDocument(root : MovieClip, startFrame : int) : void { _startFrame = startFrame; _root = root; _root.addEventListener(Event.ENTER_FRAME, __onEnterFrame, false, 999, true) _root.addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 999, true); __onEnterFrame(null); _swivelCon = stage.loaderInfo.applicationDomain.getDefinition("com.newgrounds.swivel.swf.AS3SwivelConnection"); } private static function addedToStage(e:Event) : void { _root.removeEventListener(Event.ADDED_TO_STAGE, addedToStage); if(_startFrame > 1) _root.gotoAndPlay(_startFrame); } private static function __onEnterFrame(e:Event) : void { if(!__swivelSharedObj) { __swivelSharedObj = SharedObject.getLocal("__swivel"); __swivelSharedObj.clear(); } var rootFrame : uint = _root.currentFrame; for(var i:int=0; _root.scenes[i].name != _root.currentScene.name && i<_root.scenes.length; i++) { rootFrame += _root.scenes[i].numFrames; } __swivelSharedObj.data.frame = rootFrame; __swivelSharedObj.flush(); _frame++; } } } ================================================ FILE: assets/inject_swfs/__SwivelSound.as ================================================ package { import flash.events.Event; import flash.events.EventDispatcher; import flash.media.Sound; import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.utils.getQualifiedClassName; import flash.utils.ByteArray; import flash.net.URLRequest; import flash.media.SoundLoaderContext; import flash.media.ID3Info; public class __SwivelSound extends EventDispatcher { private static var _numInstances : uint = 1; public function get bytesLoaded() : uint { return 1; } public function get bytesTotal() : uint { return 1; } public function get id3() : ID3Info { return null; } public function get isBuffering() : Boolean { return false; } public function get isURLInaccessible() : Boolean { return false; } public function get length() : Number { return 1; } public function get url() : String { return null; } public function __SwivelSound() { super(); _instanceNum = _numInstances++; _name = getQualifiedClassName(this); } public function close():void {} public function extract(target : ByteArray, length : Number, startPosition : Number = -1) : void {} public function load(stream : URLRequest, context : SoundLoaderContext = null) : void {} public function loadCompressedDataFromByteArray(bytes : ByteArray, bytesLength : uint) : void {} public function loadPCMFromByteArray(bytes : ByteArray, samples : uint, format : String = "float", stereo : Boolean = true, sampleRate : Number = 44100.0) : void {} public function play(startTime : Number = 0, loops : int = 0, soundTransform : SoundTransform = null) : __SwivelSoundChannel { __Swivel.__swivel("asStart", __Swivel.frame, _instanceNum, _name, startTime, loops) return new __SwivelSoundChannel(_instanceNum); } private var _instanceNum : uint; private var _name : String; } } ================================================ FILE: assets/inject_swfs/__SwivelSoundChannel.as ================================================ package { import flash.media.SoundChannel; import flash.media.SoundTransform; import flash.events.EventDispatcher; public class __SwivelSoundChannel extends EventDispatcher { public function get leftPeak() : Number { return 0; } public function get rightPeak() : Number { return 0; } public function get position() : Number { return 0; } public function get soundTransform() : SoundTransform { return _transform; } // TODO: defensive copy? public function set soundTransform(v : SoundTransform) : void { _transform = v; __Swivel.__swivel("asSetVolume", __Swivel.frame, _instanceNum, _transform.volume); if(_transform.rightToLeft > 0 || _transform.leftToRight > 0) __Swivel.__swivel("asSetTransform", __Swivel.frame, _instanceNum, _transform.leftToLeft, _transform.rightToLeft, _transform.leftToRight, _transform.rightToRight); else __Swivel.__swivel("asSetPan", __Swivel.frame, _instanceNum, _transform.pan); } public function __SwivelSoundChannel(instanceNum : uint, soundTransform : SoundTransform = null) { super(); _instanceNum = instanceNum; if(soundTransform == null) this.soundTransform = new SoundTransform(); else this.soundTransform = soundTransform; } public function stop() : void { __Swivel.__swivel("asStop",__Swivel.frame, _instanceNum); } private var _instanceNum : uint; private var _transform : SoundTransform; } } ================================================ FILE: bat/CreateCertificate.bat ================================================ @echo off cd.. set PAUSE_ERRORS=1 call bat\SetupSDK.bat call bat\SetupApplication.bat :: Generate echo. echo Generating a self-signed certificate... call adt -certificate -cn %CERT_NAME% -ou Developer -o "Newgrounds.com, Inc." -c US -validityPeriod 20 2048-RSA %CERT_FILE% %CERT_PASS% if errorlevel 1 goto failed :succeed echo. echo Certificate created: %CERT_FILE% with password "%CERT_PASS%" echo. if "%CERT_PASS%" == "fd" echo (note: you did not change the default password) echo. echo HINTS: echo - you only need to generate this certificate once, echo - wait a minute before using this certificate to package your AIR application. echo. goto end :failed echo. echo Certificate creation FAILED. echo. :end pause ================================================ FILE: bat/Packager.bat ================================================ @echo off if not exist %CERT_FILE% goto certificate :: AIR output if not exist %AIR_PATH% md %AIR_PATH% set OUTPUT=%AIR_PATH%\%AIR_NAME%%AIR_TARGET%.air :: Package echo. echo Packaging %AIR_NAME%%AIR_TARGET%.air using certificate %CERT_FILE%... call adt -package -storetype pkcs12 -keystore bat/Swivel.p12 -storepass %CERT_PASS% -target bundle bin/Swivel application.xml bin/Swivel.swf ffmpeg/win32 ffmpeg/licenses assets/icons README.md LICENSE.md if errorlevel 1 goto failed goto end :certificate echo. echo Certificate not found: %CERT_FILE% echo. echo Troubleshooting: echo - generate a default certificate using 'bat\CreateCertificate.bat' echo. if %PAUSE_ERRORS%==1 pause exit :failed echo AIR setup creation FAILED. echo. echo Troubleshooting: echo - did you build your project in FlashDevelop? echo - verify AIR SDK target version in %APP_XML% echo. if %PAUSE_ERRORS%==1 pause exit :end echo. ================================================ FILE: bat/SetupApplication.bat ================================================ :user_configuration :: About AIR application packaging :: http://livedocs.adobe.com/flex/3/html/help.html?content=CommandLineTools_5.html#1035959 :: http://livedocs.adobe.com/flex/3/html/distributing_apps_4.html#1037515 :: NOTICE: all paths are relative to project root :: Your certificate information set CERT_NAME="Swivel" set CERT_PASS=ngswivel!430 set CERT_FILE="bat\Swivel.p12" set SIGNING_OPTIONS=-storetype pkcs12 -keystore %CERT_FILE% -storepass %CERT_PASS% :: Application descriptor set APP_XML=application.xml :: Files to package set APP_DIR=bin set FILE_OR_DIR=-C %APP_DIR% . :: Your application ID (must match of Application descriptor) set APP_ID=com.newgrounds.swivel.Swivel :: Output set AIR_PATH=air set AIR_NAME=Swivel :validation %SystemRoot%\System32\find /C "%APP_ID%" "%APP_XML%" > NUL if errorlevel 1 goto badid goto end :badid echo. echo ERROR: echo Application ID in 'bat\SetupApplication.bat' (APP_ID) echo does NOT match Application descriptor '%APP_XML%' (id) echo. if %PAUSE_ERRORS%==1 pause exit :end ================================================ FILE: bat/SetupSDK.bat ================================================ :user_configuration :: Default path to AIR SDK if installed using HaxeDevelop. if not defined AIR_SDK (set AIR_SDK=%HOMEDRIVE%%HOMEPATH%\AppData\Local\HaxeDevelop\Apps\ascsdk\27.0.0) :validation if not exist "%AIR_SDK%\bin" goto flexsdk goto succeed :flexsdk echo. echo ERROR: Path to Air SDK not set. echo Please set the AIR_SDK environment variable, or install the echo AIR SDK + ASC 2.0 Compiler in HaxeDevelop -> Tools -> Install Software. echo. if %PAUSE_ERRORS%==1 pause exit :succeed set PATH=%PATH%;%AIR_SDK%\bin ================================================ FILE: ffmpeg/licenses/bzip2.txt ================================================ -------------------------------------------------------------------------- This program, "bzip2", the associated library "libbzip2", and all documentation, are copyright (C) 1996-2010 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. 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. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, jseward@bzip.org bzip2/libbzip2 version 1.0.6 of 6 September 2010 -------------------------------------------------------------------------- ================================================ FILE: ffmpeg/licenses/ffmpeg.txt ================================================ This is a FFmpeg Win32 static build by Kyle Schwarz. Zeranoe's FFmpeg Builds Home Page: This build was compiled on: Jan 20 2013, at: 23:05:28 FFmpeg version: 1.1.1 libavutil 52. 13.100 / 52. 13.100 libavcodec 54. 86.100 / 54. 86.100 libavformat 54. 59.106 / 54. 59.106 libavdevice 54. 3.102 / 54. 3.102 libavfilter 3. 32.100 / 3. 32.100 libswscale 2. 1.103 / 2. 1.103 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 This FFmpeg build was configured with: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib This build was compiled with the following external libraries: bzip2 1.0.6 Fontconfig 2.10.91 Frei0r 20121203-git-f4bac51 GnuTLS 3.1.6 libass 0.10.1 libbluray 0.2.3 libcaca 0.99.beta18 FreeType 2.4.10 GSM 1.0.13-4 LAME 3.99.5 OpenCORE AMR 0.1.3 OpenJPEG 1.5.1 Opus 1.0.2 RTMPDump 20121209-git-3a1e20c Schroedinger 1.0.11 Speex 1.2rc1 Theora 1.1.1 TwoLAME 0.3.13 VisualOn AAC 0.1.2 VisualOn AMR-WB 0.1.2 Vorbis 1.3.3 vpx 1.2.0 x264 20130108-git-bc13772 XAVS svn-r55 Xvid 1.3.2 zlib 1.2.7 The source code for this FFmpeg build can be found at: This build was compiled on Debian 6.0.6 (64-bit): GCC 4.7.2 was used to compile this FFmpeg build: This build was compiled using the MinGW-w64 toolchain: Licenses for each library can be found in the 'licenses' folder. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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 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. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) year 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. , 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 Lesser General Public License instead of this License. ================================================ FILE: ffmpeg/licenses/fontconfig.txt ================================================ fontconfig/COPYING Copyright © 2000,2001,2002,2003,2004,2006,2007 Keith Packard Copyright © 2005 Patrick Lam Copyright © 2009 Roozbeh Pournader Copyright © 2008,2009 Red Hat, Inc. Copyright © 2008 Danilo Šegan Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of the author(s) not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. The authors make no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ================================================ FILE: ffmpeg/licenses/freetype.txt ================================================ The FreeType Project LICENSE ---------------------------- 2006-Jan-27 Copyright 1996-2002, 2006 by David Turner, Robert Wilhelm, and Werner Lemberg Introduction ============ The FreeType Project is distributed in several archive packages; some of them may contain, in addition to the FreeType font engine, various tools and contributions which rely on, or relate to, the FreeType Project. This license applies to all files found in such packages, and which do not fall under their own explicit license. The license affects thus the FreeType font engine, the test programs, documentation and makefiles, at the very least. This license was inspired by the BSD, Artistic, and IJG (Independent JPEG Group) licenses, which all encourage inclusion and use of free software in commercial and freeware products alike. As a consequence, its main points are that: o We don't promise that this software works. However, we will be interested in any kind of bug reports. (`as is' distribution) o You can use this software for whatever you want, in parts or full form, without having to pay us. (`royalty-free' usage) o You may not pretend that you wrote this software. If you use it, or only parts of it, in a program, you must acknowledge somewhere in your documentation that you have used the FreeType code. (`credits') We specifically permit and encourage the inclusion of this software, with or without modifications, in commercial products. We disclaim all warranties covering The FreeType Project and assume no liability related to The FreeType Project. Finally, many people asked us for a preferred form for a credit/disclaimer to use in compliance with this license. We thus encourage you to use the following text: """ Portions of this software are copyright The FreeType Project (www.freetype.org). All rights reserved. """ Please replace with the value from the FreeType version you actually use. Legal Terms =========== 0. Definitions -------------- Throughout this license, the terms `package', `FreeType Project', and `FreeType archive' refer to the set of files originally distributed by the authors (David Turner, Robert Wilhelm, and Werner Lemberg) as the `FreeType Project', be they named as alpha, beta or final release. `You' refers to the licensee, or person using the project, where `using' is a generic term including compiling the project's source code as well as linking it to form a `program' or `executable'. This program is referred to as `a program using the FreeType engine'. This license applies to all files distributed in the original FreeType Project, including all source code, binaries and documentation, unless otherwise stated in the file in its original, unmodified form as distributed in the original archive. If you are unsure whether or not a particular file is covered by this license, you must contact us to verify this. The FreeType Project is copyright (C) 1996-2000 by David Turner, Robert Wilhelm, and Werner Lemberg. All rights reserved except as specified below. 1. No Warranty -------------- THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO USE, OF THE FREETYPE PROJECT. 2. Redistribution ----------------- This license grants a worldwide, royalty-free, perpetual and irrevocable right and license to use, execute, perform, compile, display, copy, create derivative works of, distribute and sublicense the FreeType Project (in both source and object code forms) and derivative works thereof for any purpose; and to authorize others to exercise some or all of the rights granted herein, subject to the following conditions: o Redistribution of source code must retain this license file (`FTL.TXT') unaltered; any additions, deletions or changes to the original files must be clearly indicated in accompanying documentation. The copyright notices of the unaltered, original files must be preserved in all copies of source files. o Redistribution in binary form must provide a disclaimer that states that the software is based in part of the work of the FreeType Team, in the distribution documentation. We also encourage you to put an URL to the FreeType web page in your documentation, though this isn't mandatory. These conditions apply to any software derived from or based on the FreeType Project, not just the unmodified files. If you use our work, you must acknowledge us. However, no fee need be paid to us. 3. Advertising -------------- Neither the FreeType authors and contributors nor you shall use the name of the other for commercial, advertising, or promotional purposes without specific prior written permission. We suggest, but do not require, that you use one or more of the following phrases to refer to this software in your documentation or advertising materials: `FreeType Project', `FreeType Engine', `FreeType library', or `FreeType Distribution'. As you have not signed this license, you are not required to accept it. However, as the FreeType Project is copyrighted material, only this license, or another one contracted with the authors, grants you the right to use, distribute, and modify it. Therefore, by using, distributing, or modifying the FreeType Project, you indicate that you understand and accept all the terms of this license. 4. Contacts ----------- There are two mailing lists related to FreeType: o freetype@nongnu.org Discusses general use and applications of FreeType, as well as future and wanted additions to the library and distribution. If you are looking for support, start in this list if you haven't found anything to help you in the documentation. o freetype-devel@nongnu.org Discusses bugs, as well as engine internals, design issues, specific licenses, porting, etc. Our home page can be found at http://www.freetype.org --- end of FTL.TXT --- ================================================ FILE: ffmpeg/licenses/frei0r.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 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. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) year 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. , 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. ================================================ FILE: ffmpeg/licenses/gnutls.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . ================================================ FILE: ffmpeg/licenses/lame.txt ================================================ GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, 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 library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, 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 companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Library 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ================================================ FILE: ffmpeg/licenses/libass.txt ================================================ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ================================================ FILE: ffmpeg/licenses/libbluray.txt ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ================================================ FILE: ffmpeg/licenses/libcaca.txt ================================================ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar 14 rue de Plaisance, 75014 Paris, France Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. ================================================ FILE: ffmpeg/licenses/libgsm.txt ================================================ Copyright 1992, 1993, 1994 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin Any use of this software is permitted provided that this notice is not removed and that neither the authors nor the Technische Universitaet Berlin are deemed to have made any representations as to the suitability of this software for any purpose nor are held responsible for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. As a matter of courtesy, the authors request to be informed about uses this software has found, about bugs in this software, and about any improvements that may be of general interest. Berlin, 28.11.1994 Jutta Degener Carsten Bormann oOo Since the original terms of 15 years ago maybe do not make our intentions completely clear given today's refined usage of the legal terms, we append this additional permission: Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that this notice is not removed and that neither the authors nor the Technische Universitaet Berlin are deemed to have made any representations as to the suitability of this software for any purpose nor are held responsible for any defects of this software. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE. Berkeley/Bremen, 05.04.2009 Jutta Degener Carsten Bormann ================================================ FILE: ffmpeg/licenses/libtheora.txt ================================================ Copyright (C) 2002-2009 Xiph.org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: ffmpeg/licenses/libvorbis.txt ================================================ Copyright (c) 2002-2008 Xiph.org Foundation Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: ffmpeg/licenses/libvpx.txt ================================================ Copyright (c) 2010, The WebM Project authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google, nor the WebM Project, nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: ffmpeg/licenses/opencore-amr.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and 2. You must cause any modified files to carry prominent notices stating that You changed the files; and 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: ffmpeg/licenses/openjpeg.txt ================================================ /* * Copyright (c) 2002-2012, Communications and Remote Sensing Laboratory, Universite catholique de Louvain (UCL), Belgium * Copyright (c) 2002-2012, Professor Benoit Macq * Copyright (c) 2003-2012, Antonin Descampe * Copyright (c) 2003-2009, Francois-Olivier Devaux * Copyright (c) 2005, Herve Drolon, FreeImage Team * Copyright (c) 2002-2003, Yannick Verschueren * Copyright (c) 2001-2003, David Janssens * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France * Copyright (c) 2012, CS Systemes d'Information, France * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ ================================================ FILE: ffmpeg/licenses/opus.txt ================================================ Copyright 2001-2011 Xiph.Org, Skype Limited, Octasic, Jean-Marc Valin, Timothy B. Terriberry, CSIRO, Gregory Maxwell, Mark Borgerding, Erik de Castro Lopo Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of Internet Society, IETF or IETF Trust, nor the names of specific contributors, may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Opus is subject to the royalty-free patent licenses which are specified at: Xiph.Org Foundation: https://datatracker.ietf.org/ipr/1524/ Microsoft Corporation: https://datatracker.ietf.org/ipr/1914/ Broadcom Corporation: https://datatracker.ietf.org/ipr/1526/ ================================================ FILE: ffmpeg/licenses/rtmpdump.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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 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. Copyright (C) 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) year 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. , 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 Lesser General Public License instead of this License. ================================================ FILE: ffmpeg/licenses/schroedinger.txt ================================================ GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 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. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, 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 library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, 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 companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Library 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ================================================ FILE: ffmpeg/licenses/speex.txt ================================================ Copyright 2002-2008 Xiph.org Foundation Copyright 2002-2008 Jean-Marc Valin Copyright 2005-2007 Analog Devices Inc. Copyright 2005-2008 Commonwealth Scientific and Industrial Research Organisation (CSIRO) Copyright 1993, 2002, 2006 David Rowe Copyright 2003 EpicGames Copyright 1992-1994 Jutta Degener, Carsten Bormann Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Xiph.org Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: ffmpeg/licenses/twolame.txt ================================================ GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ================================================ FILE: ffmpeg/licenses/vo-aacenc.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and 2. You must cause any modified files to carry prominent notices stating that You changed the files; and 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: ffmpeg/licenses/vo-amrwbenc.txt ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and 2. You must cause any modified files to carry prominent notices stating that You changed the files; and 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: ffmpeg/licenses/x264.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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. , 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. ================================================ FILE: ffmpeg/licenses/xavs.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. 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. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey 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; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If 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 convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU 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 that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. 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. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS 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 state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 3 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, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program 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, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU 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 Lesser General Public License instead of this License. But first, please read . ================================================ FILE: ffmpeg/licenses/xvid.txt ================================================ GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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. Copyright (C) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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. , 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. ================================================ FILE: ffmpeg/licenses/zlib.txt ================================================ /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.2.7, May 2nd, 2012 Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler 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. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu */ ================================================ FILE: ffmpeg/mac64/ffmpeg ================================================ [File too large to display: 61.7 MB] ================================================ FILE: huey/src/com/huey/Main.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey; import com.huey.assets.Asset; import com.huey.assets.AssetManager; import com.huey.assets.AssetSource; import com.huey.assets.AssetTests; import com.huey.binding.BindingTests; import com.huey.core.Application; import com.huey.core.ApplicationTests; import com.huey.ui.Image; import com.huey.ui.Label; import com.huey.utils.AssertTests; import com.huey.events.EventTests; import com.huey.tests.TestRunner; import com.huey.tests.TestSuite; import com.huey.ui.UITests; import com.huey.macros.MacroTests; import com.huey.utils.WeakRefTest; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.Lib; class Main { static function main() { var stage = Lib.current.stage; stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; // entry point var test : TestSuite = new TestSuite(); test.add(new AssertTests()); test.add(new EventTests()); test.add(new WeakRefTest()); test.add(new MacroTests()); test.add(new BindingTests()); test.add(new UITests()); test.add(new ApplicationTests()); test.add(new AssetTests()); var testRunner : TestRunner = new TestRunner(); testRunner.run(test); //_app = new TestApplication(); } private static var _app : Application; } class TestApplication extends Application { public function new() { super(); assetManager.registerAsset( new Asset("shadow", External("h:/Swivel/assets/SHADOW.PNG")) ); assetManager.onAssetsLoaded.add(onAssetsLoaded); assetManager.preloadAssets(); } public function onAssetsLoaded(e) : Void { var label : Label = uiFactory.createLabel(); label.text = "Foo"; ui.add(label); label.x = 100; label.onClick.add(function(e) { trace("FOO"); } ); var image : Image = uiFactory.createImage(); image.source = assetManager.getAsset("shadow"); ui.add(image); } } ================================================ FILE: huey/src/com/huey/assets/Asset.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.assets; import com.huey.events.Dispatcher; import com.huey.events.Dispatcher; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLRequest; class Asset { public var name(default, null) : String; public var source(default, null) : AssetSource; public var data(default, null) : Dynamic; public var onLoaded(default, null) : Dispatcher; private var _loader : Loader; public function new(name : String, source : AssetSource) { this.name = name; this.source = source; onLoaded = new Dispatcher(); } public function load() : Void { _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); switch(source) { case Internal(id): _loader.loadBytes(haxe.Resource.getBytes(id).getData()); case External(url): _loader.load(new URLRequest(url)); } } private function onLoadComplete(event : Event): Void { data = cast(_loader.content, Bitmap).bitmapData; _loader = null; onLoaded.dispatch(); } private function ioErrorHandler(_) { } } ================================================ FILE: huey/src/com/huey/assets/AssetManager.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.assets; import com.huey.events.Dispatcher; import haxe.ds.StringMap; class AssetManager { private static var _instance : AssetManager; public static var instance(get, null) : AssetManager; inline private static function get_instance() : AssetManager { if (_instance == null) _instance = new AssetManager(); return _instance; } public var onAssetsLoaded : Dispatcher; private var _assets : StringMap; private var _loaderIterator : Iterator; public function new() { _assets = new StringMap(); onAssetsLoaded = new Dispatcher(); } public function preloadAssets() : Void { _loaderIterator = _assets.iterator(); loadNextAsset(); } public function registerAsset(asset : Asset) : Void { _assets.set(asset.name, asset); } public function getAsset(name : String) : Asset { return _assets.get(name); } private function loadNextAsset() : Void { if (_loaderIterator.hasNext()) { var asset = _loaderIterator.next(); asset.onLoaded.add( onAssetLoaded ); asset.load(); } else { _loaderIterator = null; onAssetsLoaded.dispatch(); } } private function onAssetLoaded(e) : Void { loadNextAsset(); } } ================================================ FILE: huey/src/com/huey/assets/AssetSource.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.assets; enum AssetSource { Internal(id : String); External(url : String); } ================================================ FILE: huey/src/com/huey/binding/BindableArray.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.binding; class BindableArray extends Binding.Bindable { private var _array : Array; public static function fromArray(a : Array) : BindableArray { var ba = new BindableArray(); ba._array = a; ba.dispatchBindings(); return ba; } public function new() { super(); _array = []; dispatchBinding("length"); dispatchBinding("_array"); } public var length(get_length, null) : Int; private function get_length() : Int { return _array.length; } public var array(get_array, never) : Array; public function get_array() : Array { return _array; } public function concat(a : Array) : Array { return _array.concat(a); } public function copy() : Array { return _array.copy(); } public function insert(pos : Int, x : T) : Void { _array.insert(pos, x); dispatchBindings(); } public function iterator() : Iterator { return _array.iterator(); } public function join(sep : String) : String { return _array.join(sep); } public function pop() : Null { var ret = _array.pop(); dispatchBindings(); return ret; } public function push(x : T) : Int { var ret = _array.push(x); dispatchBindings(); return ret; } public function remove(x : T) : Bool { var ret = _array.remove(x); dispatchBindings(); return ret; } public function reverse() : Void { _array.reverse(); dispatchBindings(); } public function shift() : Null { var ret = _array.shift(); dispatchBindings(); return ret; } public function sort(f : T->T->Int) : Void { _array.sort(f); dispatchBindings(); } public function splice(pos : Int, len : Int) : Array { var ret = _array.splice(pos, len); dispatchBindings(); return ret; } public function toString() : String { return _array.toString(); } public function unshift(x : T) : Void { _array.unshift(x); dispatchBindings(); } private function dispatchBindings() : Void { dispatchBinding("length"); dispatchBinding("_array"); } } ================================================ FILE: huey/src/com/huey/binding/Binding.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.binding; import com.huey.events.Dispatcher; import com.huey.macros.ClassBuilder; import com.huey.macros.FieldInfo; import com.huey.macros.MacroTools; import haxe.ds.StringMap; import haxe.macro.Context; import haxe.macro.Expr; using Lambda; typedef BindingInstance = Void -> Void; typedef BindingsList = List; // RUN-TIME BINDING MANAGEMENT @:autoBuild(com.huey.binding.Binding.bindable()) class Bindable { private var __bindings : StringMap; private var __distpatching : Bool; public function new() { __bindings = new StringMap(); __distpatching = false; } public function addBinding(field : String, binding : BindingInstance) : Void { var bindingsList = __bindings.get(field); if (bindingsList == null) { bindingsList = new List(); __bindings.set(field, bindingsList); } bindingsList.add(binding); } public function removeBinding(field : String, binding : BindingInstance) : Void { var bindingsList = __bindings.get(field); if (bindingsList != null) bindingsList.remove(binding); } public function removeBindings(field : String) : Void { __bindings.set(field, null); } private function dispatchBinding(field : String) : Void { if (__distpatching) return; __distpatching = true; var bindingsList : List = __bindings.get(field); //var isFieldBindable : Bool = Std.is(value, Bindable); if(bindingsList != null) { for (binding in bindingsList) { try { binding(); } catch(e:Dynamic) { } } } __distpatching = false; } } /** * Binding provides utilities for data binding. * @author Newgrounds.com, Inc. */ class Binding { #if macro private static var _cl : ClassBuilder; macro public static function bindable() : Array { _cl = ClassBuilder.createFromContext(); for(field in _cl.getFieldsWithMeta("bindable")) makeFieldBindable(field); return _cl.fields(); } /** Adds binding dispatches to fields, so that the field can be bound to. */ private static function makeFieldBindable(field : FieldInfo) : Void { var pos = Context.currentPos(); // add event dispatcher var setterField : FieldInfo; var fieldNameString = {expr:EConst(CString(field.name)), pos: Context.currentPos()}; var fieldNameIdent = {expr:EConst(CIdent(field.name)), pos: Context.currentPos()}; switch(field.kind) { case FVar(t, e): setterField = new FieldInfo("set_" + field.name); setterField.access = [APrivate]; setterField.kind = FFun({ ret: t, params: [], expr: macro { $fieldNameIdent = v; dispatchBinding($fieldNameString); return v; }, args: [{name: "v", value: null, type: t, opt: false}] }); _cl.addField(setterField); field.kind = FProp("default", setterField.name, t, e); case FProp(get, set, t, e): if(set == "default") { setterField = new FieldInfo("set_" + field.name); setterField.access = [APrivate]; setterField.kind = FFun({ ret: t, params: [], expr: macro { $fieldNameIdent = v; dispatchBinding($fieldNameString); return v; }, args: [{name: "v", value: null, type: t, opt: false}] }); _cl.addField(setterField); field.kind = FProp(get, setterField.name, t, e); } else { function injectNotify(e : ExprDef) : ExprDef { var retExpr : Expr; return switch(e) { case EReturn(e): (macro { var ret = $e; dispatchBinding($fieldNameString); return ret; }).expr; default: return null; } } var setter = _cl.getField('set_${field.name}'); // MIKNEW switch(setter.kind) { case FFun(f): com.huey.macros.MacroTools.mapExpr(f.expr, injectNotify); default: Context.error("Unexpected error", pos); } } default: Context.error('${field.kind} can not be bindable', pos); } } private static function isBindable(obj : Expr) : Bool { switch(Context.typeof(obj)) { case TInst(t, params): var cl = t.get(); while (cl.superClass != null) { cl = cl.superClass.t.get(); if (cl.name == "Bindable") return true; } return false; default: return false; } } private static function isBindableArray(obj : Expr) : Bool { switch(Context.typeof(obj)) { case TInst(t, params): var cl = t.get(); return cl.name == "BindableArray"; default: return false; } } #end /** COMPILE-TIME BINDING GENERATION */ #if !macro macro #end public static function bind(dst : ExprOf, src : ExprOf) : ExprOf { // determine binding dependencies var dependencies = []; var localVars = []; function traverseExpr(e : ExprDef) : ExprDef { switch(e) { case EConst(c): switch(c) { case CIdent(s): if(Lambda.indexOf(localVars, s) == -1) if (isBindable( { expr: EConst(CIdent("this")), pos: Context.currentPos() } )) { dependencies.push( { obj: null, field: s } ); } default: } case EField(obj, field): if (isBindable( obj )) { dependencies.push( { obj: obj, field: field } ); } var expr = { expr:e, pos: Context.currentPos() }; if (isBindableArray(expr)) dependencies.push( { obj: expr, field: "_array" } ); case EVars(vars): for(v in vars) localVars.push(v.name); default: } return null; } MacroTools.mapExpr(src, traverseExpr); /* // var oldObj = $obj; // function handler() { // // for each dependent // if($obj != oldObj) { // oldObj.removeBinding($field, handler); // $obj.addBinding($field, handler); // oldObj = $obj; // } // $dst = $src; // } */ var i : Int = 0; var vars = []; var ifExprs : Array = []; var initExprs : Array = []; for(dep in dependencies) { var obj; var isThis; if (dep.obj != null) { obj = dep.obj; isThis = false; } else { obj = { expr: EConst(CIdent("this")), pos: Context.currentPos() }; isThis = true; } var field = { expr: EConst(CString(dep.field)), pos: Context.currentPos() }; var oldObj = { expr: EConst(CIdent("old" + i)), pos: Context.currentPos() }; var initBinding = macro if($obj != null) $obj.addBinding($field, handler); if(!isThis) { vars.push( {name: "old" + i, type: null, expr: obj} ); ifExprs.push( macro if($oldObj != $obj) { if($oldObj != null) $oldObj.removeBinding($field, handler); $initBinding; $oldObj = $obj; } ); } initExprs.push( macro $initBinding ); i++; } var varsExpr = {expr: EVars(vars), pos: Context.currentPos()}; var ifExpr = {expr: EBlock(ifExprs), pos: Context.currentPos()}; var initExpr = {expr: EBlock(initExprs), pos: Context.currentPos()}; var bindingExpr = macro { try { $dst = $src; } catch (e:Dynamic) { } }; return macro { $varsExpr; function handler() { $ifExpr; $bindingExpr; } $initExpr; handler(); }; } macro public static function bindTwoWay(dst : ExprOf, src : ExprOf) : ExprOf { return { expr: EBlock([Binding.bind(dst, src), Binding.bind(src, dst)]), pos: Context.currentPos() }; } } ================================================ FILE: huey/src/com/huey/core/Application.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.core; import com.huey.assets.*; import com.huey.ui.*; import com.huey.utils.Assert; import com.huey.binding.Binding; import com.huey.utils.Thread; @:autoBuild(com.huey.core.ApplicationMacros.buildApplication()) class Application extends Binding.Bindable { private var _thread : Thread; public var ui(default, null) : StateContainer; public var assetManager(default, null) : AssetManager; private var _appXml : haxe.xml.Fast; private function new() { super(); flash.Lib.current.loaderInfo.uncaughtErrorEvents.addEventListener(flash.events.UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler); #if !debug haxe.Log.trace = function(_, ?_){} #end assetManager = AssetManager.instance; ui = new StateContainer(); #if flash9 // TODO untyped { flash.Lib.current.addChild(ui._implComponent); } #end // XML resource name gets set by macro // TODO: pass thru constructor? var applicationData = haxe.Resource.getString("applicationData"); if(applicationData != null) { _appXml = new haxe.xml.Fast( Xml.parse(applicationData).firstElement() ); } registerAssets(); assetManager.onAssetsLoaded.add(assetsLoadedHandler); assetManager.preloadAssets(); } private function registerAssets() : Void { } private function assetsLoadedHandler(e) : Void { for(uiData in _appXml.node.ui.elements) { var component = readComponent(uiData); if (component != null) ui.add( component ); else { if (uiData.name == "state") { var stateComps = readUIList(uiData); for(comp in stateComps) ui.addToState(comp, uiData.att.name); } } } #if air var win = flash.desktop.NativeApplication.nativeApplication.openedWindows[0]; if(win != null) { win.x = (win.stage.fullScreenWidth - win.width) / 2; win.y = (win.stage.fullScreenHeight - win.height) / 2; win.addEventListener(flash.events.Event.CLOSE, function(_) exit()); } #end init(); } private function readUIList(data : haxe.xml.Fast) : Array { var comps : Array = []; for(uiData in data.elements) { var component = readComponent(uiData); if(component != null) comps.push( component ); } return comps; } private function readStateContainer(data : haxe.xml.Fast) : Component { var container = new StateContainer(); for(uiData in data.elements) { var component = readComponent(uiData); if (component != null) container.add( component ); else { if (uiData.name == "state") { var stateComps = readUIList(uiData); for(comp in stateComps) container.addToState(comp, uiData.att.name); } } } return container; } private function readComponent(uiData : haxe.xml.Fast) : Component { if(uiData == null) return null; var comp : Component; switch(uiData.name) { case "radioGroup": var radioGroup = new RadioGroup(); Reflect.setProperty(this, uiData.att.name, radioGroup); return null; case "container": comp = readStateContainer(uiData); case "image": var source = if(uiData.has.source) assetManager.getAsset(uiData.att.source) else null; var image = new Image(source); comp = image; case "scaledImage": var source = if(uiData.has.source) assetManager.getAsset(uiData.att.source) else null; var image = new ScaledImage(source); comp = image; case "label": var label = new Label(); if(uiData.has.text) label.text = StringTools.replace(uiData.att.text, "\\n", "\n"); if(uiData.has.wordWrap) label.wordWrap = uiData.att.wordWrap != "false"; label.font = uiData.att.font; if(uiData.has.size) label.size = Std.parseFloat(uiData.att.size); if(uiData.has.editable) label.editable = uiData.att.editable != "false"; label.bold = uiData.has.bold && uiData.att.bold == "true"; label.color = Std.parseInt(uiData.att.color); if(uiData.has.width) label.autoSize = false; if(uiData.has.letterSpacing) label.letterSpacing = Std.parseFloat(uiData.att.letterSpacing); if(uiData.has.align) label.align = switch(uiData.att.align) { case "left": left; case "right": right; case "center": center; case "justify": justify; default: left; } comp = label; case "button": var button = new Button(); button.upState = if(uiData.hasNode.upState) readComponent(uiData.node.upState.elements.next()) else null; button.downState = if(uiData.hasNode.downState) readComponent(uiData.node.downState.elements.next()) else null; button.overState = if(uiData.hasNode.overState) readComponent(uiData.node.overState.elements.next()) else null; if(uiData.has.onClick) button.onClick.add(Reflect.field(this, uiData.att.onClick)); if(uiData.has.onMouseDown) button.onMouseDown.add(Reflect.field(this, uiData.att.onMouseDown)); comp = button; case "checkBox": var checkBox = new CheckBox(); checkBox.upState = if(uiData.hasNode.upState) readComponent(uiData.node.upState.elements.next()) else null; checkBox.downState = if(uiData.hasNode.downState) readComponent(uiData.node.downState.elements.next()) else null; checkBox.overState = if (uiData.hasNode.overState) readComponent(uiData.node.overState.elements.next()) else null; checkBox.selectedUpState = if(uiData.hasNode.selectedUpState) readComponent(uiData.node.selectedUpState.elements.next()) else null; checkBox.selectedDownState = if(uiData.hasNode.selectedDownState) readComponent(uiData.node.selectedDownState.elements.next()) else null; checkBox.selectedOverState = if(uiData.hasNode.selectedOverState) readComponent(uiData.node.selectedOverState.elements.next()) else null; if(uiData.has.onClick) checkBox.onClick.add(Reflect.field(this, uiData.att.onClick)); if(uiData.has.onMouseDown) checkBox.onMouseDown.add(Reflect.field(this, uiData.att.onMouseDown)); if(uiData.has.selected) checkBox.selected = uiData.att.selected != "false"; comp = checkBox; case "radioButton": var radioButton = new RadioButton(); radioButton.upState = if(uiData.hasNode.upState) readComponent(uiData.node.upState.elements.next()) else null; radioButton.downState = if(uiData.hasNode.downState) readComponent(uiData.node.downState.elements.next()) else null; radioButton.overState = if (uiData.hasNode.overState) readComponent(uiData.node.overState.elements.next()) else null; radioButton.selectedUpState = if(uiData.hasNode.selectedUpState) readComponent(uiData.node.selectedUpState.elements.next()) else null; radioButton.selectedDownState = if(uiData.hasNode.selectedDownState) readComponent(uiData.node.selectedDownState.elements.next()) else null; radioButton.selectedOverState = if(uiData.hasNode.selectedOverState) readComponent(uiData.node.selectedOverState.elements.next()) else null; if(uiData.has.onClick) radioButton.onClick.add(Reflect.field(this, uiData.att.onClick)); if(uiData.has.onMouseDown) radioButton.onMouseDown.add(Reflect.field(this, uiData.att.onMouseDown)); if(uiData.has.selected) radioButton.selected = uiData.att.selected != "false"; if(uiData.has.group) { radioButton.group = Reflect.getProperty(this, uiData.att.group); radioButton.group.items.push(radioButton); if(radioButton.selected) radioButton.group.selectedItem = radioButton; } comp = radioButton; case "listBox": var listBox = new ListBox(); comp = listBox; case "selectBox": var selectBox = new SelectBox(); comp = selectBox; case "textBox": var textBox = new TextBox(); var comps = readUIList(uiData); for (comp in comps) textBox.add(comp); if (uiData.has.textX) textBox.textX = Std.parseFloat(uiData.att.textX); if (uiData.has.textY) textBox.textY = Std.parseFloat(uiData.att.textY); textBox.font = uiData.att.font; textBox.size = Std.parseFloat(uiData.att.size); textBox.color = Std.parseInt(uiData.att.color); comp = textBox; case "slider": var slider = new Slider(); var comps = readUIList(uiData); for (comp in comps) slider.add(comp); if (uiData.hasNode.nub) { slider.nub = readComponent(uiData.node.nub.elements.next()); slider.add( slider.nub ); } if (uiData.has.labelX) slider.label.x = Std.parseFloat(uiData.att.labelX); if (uiData.has.labelY) slider.label.y = Std.parseFloat(uiData.att.labelY); if (uiData.has.bold) slider.bold = uiData.att.bold != "false"; if (uiData.has.step) slider.step = Std.parseFloat(uiData.att.step); if (uiData.has.minimum) slider.minimum = Std.parseFloat(uiData.att.minimum); if (uiData.has.maximum) slider.maximum = Std.parseFloat(uiData.att.maximum); if (uiData.has.labelFunc) slider.labelFunc = Reflect.getProperty(this, uiData.att.labelFunc); if(uiData.has.value) slider.value = Std.parseFloat(uiData.att.value); if(uiData.has.font) slider.font = uiData.att.font; if(uiData.has.size) slider.size = Std.parseFloat(uiData.att.size); if(uiData.has.color) slider.color = Std.parseInt(uiData.att.color); comp = slider; case "progressBar": var slider = new ProgressBar(); var comps = readUIList(uiData); for (comp in comps) slider.add(comp); if (uiData.hasNode.nub) { slider.nub = readComponent(uiData.node.nub.elements.next()); slider.add( slider.nub ); } if (uiData.has.labelX) slider.label.x = Std.parseFloat(uiData.att.labelX); if (uiData.has.labelY) slider.label.y = Std.parseFloat(uiData.att.labelY); if (uiData.has.bold) slider.bold = uiData.att.bold != "false"; if (uiData.has.step) slider.step = Std.parseFloat(uiData.att.step); if (uiData.has.minimum) slider.minimum = Std.parseFloat(uiData.att.minimum); if (uiData.has.maximum) slider.maximum = Std.parseFloat(uiData.att.maximum); if (uiData.has.labelFunc) slider.labelFunc = Reflect.getProperty(this, uiData.att.labelFunc); if(uiData.has.value) slider.value = Std.parseFloat(uiData.att.value); if(uiData.has.font) slider.font = uiData.att.font; if(uiData.has.size) slider.size = Std.parseFloat(uiData.att.size); if(uiData.has.color) slider.color = Std.parseInt(uiData.att.color); comp = slider; case "numericStepper": var numericStepper = new NumericStepper(); var comps = readUIList(uiData); for (comp in comps) { numericStepper.add(comp); if(Std.is(comp,TextBox)) numericStepper._textBox = cast(comp); } if(uiData.hasNode.incButton) numericStepper.incButton = cast(readComponent(uiData.node.incButton.elements.next())); if(uiData.hasNode.decButton) numericStepper.decButton = cast(readComponent(uiData.node.decButton.elements.next())); if(uiData.has.minimum) numericStepper.minimum = Std.parseFloat(uiData.att.minimum); if(uiData.has.maximum) numericStepper.maximum = Std.parseFloat(uiData.att.maximum); if(uiData.has.value) numericStepper.value = Std.parseFloat(uiData.att.value); if(uiData.has.step) numericStepper.step = Std.parseFloat(uiData.att.step); comp = numericStepper; case "rectangle": var rectangle = new Rectangle(Std.parseInt(uiData.att.color), Std.parseFloat(uiData.att.width), Std.parseFloat(uiData.att.height)); comp = rectangle; default: return null; } comp.x = if(uiData.has.x) Std.parseFloat(uiData.att.x) else 0; comp.y = if (uiData.has.y) Std.parseFloat(uiData.att.y) else 0; if(uiData.has.alpha) comp.alpha = Std.parseFloat(uiData.att.alpha); if(uiData.has.depth) comp.depth = Std.parseFloat(uiData.att.depth); if(uiData.name != "rectangle") { if(uiData.has.width) comp.width = Std.parseFloat(uiData.att.width); if(uiData.has.height) comp.height = Std.parseFloat(uiData.att.height); } if (uiData.has.enabled) comp.enabled = uiData.att.enabled != "false"; if(uiData.has.visible) comp.visible = uiData.att.visible != "false"; if(uiData.hasNode.hitArea) { var hitArea = uiData.node.hitArea; if(hitArea.hasNode.rectangle) { comp.hitArea = Rectangle( Std.parseFloat(hitArea.node.rectangle.att.x), Std.parseFloat(hitArea.node.rectangle.att.y), Std.parseFloat(hitArea.node.rectangle.att.width), Std.parseFloat(hitArea.node.rectangle.att.height) ); } } if (uiData.has.name) Reflect.setProperty(this, uiData.att.name, comp); return comp; } private function init() : Void { } public function exit() : Void { #if air flash.desktop.NativeApplication.nativeApplication.exit(); #end } public function minimize() : Void { #if air flash.desktop.NativeApplication.nativeApplication.activeWindow.minimize(); #end } public function orderToFront() { #if air var win = flash.desktop.NativeApplication.nativeApplication.openedWindows[0]; if(win != null) win.orderToFront(); #end } private function uncaughtErrorHandler(_) { } } ================================================ FILE: huey/src/com/huey/core/ApplicationMacros.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.core; import com.huey.macros.*; import haxe.macro.Type; import haxe.macro.Context; import haxe.macro.Expr; using com.huey.macros.MacroTools; class ApplicationMacros { @:macro public static function buildApplication() : Array { var cl : ClassBuilder = ClassBuilder.createFromContext(); var xml; if(cl.getMeta(":xml") != null) { var xmlPath : String = cl.getMeta(":xml").params[0].extractString(); if(xmlPath != null) { xml = new haxe.xml.Fast( Xml.parse(sys.io.File.getContent(xmlPath)).firstElement() ); Context.addResource("applicationData", sys.io.File.getBytes(xmlPath)); } } var appClass = {pack: [], name: cl.name}; // MIKE: Why doesn't fullClassPath work here? var field = new FieldInfo("main"); field.pos = Context.currentPos(); field.access = [AStatic, APublic]; field.kind = FFun({ params: [], ret: null, args: [], expr: macro { // If this is a worker thread, run its entry point // TODO: Should this probably be in Thread class? var worker = flash.system.Worker.current; if(!worker.isPrimordial) { var entryPoint : String = worker.getSharedProperty("entryPoint"); var i = entryPoint.lastIndexOf("."); var className = entryPoint.substr(0, i); var methodName = entryPoint.substr(i+1); Reflect.field(Type.resolveClass(className), methodName)(); return; } else { // else run main application _app = new $appClass(); } } }); cl.addField(field); var time = Date.now().getTime(); field = new FieldInfo("BUILD_TIME"); field.pos = Context.currentPos(); field.access = [AStatic, APublic]; field.kind = FVar(null, macro Date.fromTime($v{time})); cl.addField(field); if(cl.getMeta(":version") != null) { field = new FieldInfo("VERSION"); field.pos = Context.currentPos(); field.access = [AStatic, APublic, AInline]; var version : String = cl.getMeta(":version").params[0].extractString(); field.kind = FVar(null, {expr: EConst(CString(version)), pos: Context.currentPos()}); cl.addField(field); } var es : Array = []; for(assetData in xml.node.assets.nodes.asset) { var assetName = {expr:EConst(CString(assetData.att.name)), pos: Context.currentPos()}; es.push(macro assetManager.registerAsset( new Asset($assetName, Internal($assetName)) )); Context.addResource(assetData.att.name, sys.io.File.getBytes(assetData.att.source)); } field = new FieldInfo("registerAssets"); field.pos = Context.currentPos(); field.access = [APrivate, AOverride]; field.kind = FFun({ params: [], ret: null, args: [], expr: {expr: EBlock(es), pos: Context.currentPos()}, }); cl.addField(field); field = new FieldInfo("_app"); field.pos = Context.currentPos(); field.access = [AStatic, APrivate]; field.kind = FVar(null); cl.addField(field); /*field = new FieldInfo("buildUI"); field.access = [APrivate, AOverride]; field.kind = FMethod( { } ); cl.addField(field);*/ return cl.fields(); } } ================================================ FILE: huey/src/com/huey/events/Dispatcher.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.events; /** * The Dispatcher class allows observers to listen for events. */ class Dispatcher { private var _listeners : List Void>; public var numListeners(get, null) : Int; private function get_numListeners() : Int { return _listeners.length; } /** * Creates a new Dispatcher. */ public function new() { _listeners = new List(); } /** * Attaches a listener method to this dispatcher. * The listener will be called when the event is dispatched * @param listener */ public function add(listener : T -> Void) : Void { if(!Lambda.has(_listeners, listener)) _listeners.add(listener); } /** * Dispatches the event and calls all registered listeners. */ public function dispatch(?event : T) : Void { for (listener in _listeners) listener(event); } /** * Unregisters a listener from this dispatcher. */ public function remove(listener : T -> Void) : Void { _listeners.remove(listener); } /** * Unregisters all listener from this dispatcher. */ public function removeAll() : Void { _listeners.clear(); } /** * Returns whether a listener is registered to this dispatcher. */ public function has(listener : T -> Void) : Bool { return Lambda.has(_listeners, listener); } } ================================================ FILE: huey/src/com/huey/macros/ClassBuilder.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.macros; import haxe.ds.StringMap; import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; class ClassBuilder { public static function createFromContext() : ClassBuilder { var builder : ClassBuilder = new ClassBuilder(); #if macro var clazz = Context.getLocalClass().get(); builder.name = clazz.name; builder.fullClassPath = clazz.module; builder.meta = clazz.meta.get(); for (field in Context.getBuildFields()) builder._fields.set(field.name, FieldInfo.fromField(field)); #end return builder; } public var _fields : StringMap; public var name(default, null) : String; public var fullClassPath(default, null) : String; public var meta : Metadata; public function new() { // TODO: name etc. _fields = new StringMap(); meta = []; } inline public function getField(name : String) : Null { return _fields.get(name); } public function addField(field : FieldInfo) : Void { _fields.set(field.name, field); } public function getFieldsWithMeta(metadata : String) : Array { var results : Array = []; for (f in _fields) { var meta = f.getMeta(metadata); if (meta != null) results.push(f); } return results; } public function getMeta(metadata : String) { for(m in meta) if(m.name == metadata) return m; return null; } public function fields() : Array { var fields : Array = []; for (f in _fields) fields.push(f.toField()); return fields; } } ================================================ FILE: huey/src/com/huey/macros/FieldInfo.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.macros; import haxe.macro.Expr; import haxe.macro.Context; class FieldInfo { public static function fromField(field : Field) : FieldInfo { var f : FieldInfo = new FieldInfo(field.name); f.pos = field.pos; f.meta = field.meta; f.kind = field.kind; f.access = field.access; return f; } public var name : String; public var pos : Position; public var meta(default, null) : Metadata; public var kind : FieldType; public var access : Array; public function new(name : String) : Void { this.name = name; meta = []; access = [APublic]; #if macro pos = Context.currentPos(); #end } public function toField() : Field { return { name: name, pos: pos, meta: meta, kind: kind, access: access }; } public function getMeta(name : String) { for (m in meta) if (m.name == name) return m; return null; } public function addMeta(name : String, ?params : Array) : Void { } } ================================================ FILE: huey/src/com/huey/macros/MacroTools.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.macros; import haxe.macro.Context; import haxe.macro.Expr; class MacroTools { public static function extractString(expr : Expr) : String { switch(expr.expr) { case EConst(c): switch(c) { case CString(s): return s; default: } default: } return null; } inline public static function extractIdentifier(expr : Expr) : String { switch(expr.expr) { case EConst(c): switch(c) { case CIdent(s): return s; default: } default: } throw "Expression is not an identifier."; return null; } inline public static function getVar(fields : Array, name : String) { for (field in fields) { if (field.name == name) { switch(field.kind) { case FVar(_, _): return field.kind; default: } } } return null; } inline public static function hasVar(fields : Array, name : String) : Bool { for (field in fields) { if (field.name == name) { switch(field.kind) { case FVar(_, _): return true; default: } } } return false; } inline public static function getMeta(field : Field, name : String) : Array { var ret = null; for (m in field.meta) { if (m.name == name) ret = m.params; } return ret; } inline public static function hasMeta(field : Field, name : String) : Bool { return getMeta(field, name) != null; } public static function cocnatExpr(e1 : Expr, e2 : Expr) : Expr { return {expr: EBlock([e1, e2]), pos: e1.pos}; } public static function mapExpr(expr : Expr, f : ExprDef->ExprDef) : Void { if (expr == null) return; var replaceExpr : ExprDef = f(expr.expr); if(replaceExpr == null) { switch(expr.expr) { case EArray(e1, e2): mapExpr(e1, f); mapExpr(e2, f); case EArrayDecl(values): for (e in values) mapExpr(e, f); case EBinop(op, e1, e2): mapExpr(e1, f); mapExpr(e2, f); case EBlock(es): for (e in es) mapExpr(e, f); case EBreak: case ECall(e, params): mapExpr(e, f); for (e in params) mapExpr(e, f); case ECast(e, t): mapExpr(e, f); case ECheckType(e, t): mapExpr(e, f); case EConst(c): case EContinue: case EDisplay(e, isCall): mapExpr(e, f); case EDisplayNew(t): case EField(e, field): mapExpr(e, f); case EFor(it, e): mapExpr(it, f); mapExpr(e, f); case EFunction(name, func): mapExpr(func.expr, f); case EIf(econd, eif, eelse): mapExpr(econd, f); mapExpr(eif, f); mapExpr(eelse, f); // Fix for dev build: in Haxe 4, EIn changed to OpIn. #if (haxe_ver < "4") case EIn(e1, e2): mapExpr(e1, f); mapExpr(e2, f); #end case ENew(t, params): for (e in params) mapExpr(e, f); case EObjectDecl(fields): for (field in fields) mapExpr(field.expr, f); case EParenthesis(e): mapExpr(e, f); case EReturn(e): if (e != null) mapExpr(e, f); case ESwitch(e, cases, edef): mapExpr(e, f); for (c in cases) mapExpr(c.expr, f); if (edef != null) mapExpr(edef, f); case ETernary(econd, eif, eelse): mapExpr(econd, f); mapExpr(eif, f); mapExpr(eelse, f); case EThrow(e): mapExpr(e, f); case ETry(e, catches): mapExpr(e, f); for (c in catches) mapExpr(c.expr, f); case EUnop(op, postFix, e): mapExpr(e, f); case EUntyped(e): mapExpr(e, f); case EVars(vars): for (v in vars) if (v.expr != null) mapExpr(v.expr, f); case EWhile(econd, e, normalWhile): mapExpr(econd, f); mapExpr(e, f); default: } } else { expr.expr = replaceExpr; } } public static function concatExpr(e1 : Expr, e2 : Expr) : Expr { var out = switch(e1.expr) { case EBlock(es): es; default: [e1]; } out.concat( switch(e2.expr) { case EBlock(es): es; default: [e2]; } ); // TODO: smarter position? return {expr: EBlock(out), pos: e1.pos}; } } ================================================ FILE: huey/src/com/huey/macros/Macros.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.macros; import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; using com.huey.macros.MacroTools; class Macros { @:macro public static function build() : Array { var cl : ClassBuilder = ClassBuilder.createFromContext(); for (field in cl.getFieldsWithMeta("forward")) { var meta = field.getMeta("forward"); if (meta.params.length < 1) Context.error("@forward requires a parameter.", meta.pos); var fieldExpr : Expr = meta.params[0]; switch(fieldExpr.expr) { case EConst(c): switch(c) { case CIdent(i): fieldExpr.expr = EField({expr: fieldExpr.expr, pos: fieldExpr.pos}, field.name); default: } default: } var type; switch(field.kind) { case FVar(t, _): type = t; default: Context.error("@forward destination field must be a variable, not be a property or function.", fieldExpr.pos); } // transform into property var getterName = "get_" + field.name; var setterName = if (meta.params.length < 2) "set_" + field.name else null; field.kind = FProp("get", if( setterName != null ) setterName else "null", type); meta.params = []; var getter = new FieldInfo(getterName); getter.pos = meta.pos; getter.access = [APrivate, AInline]; getter.kind = FFun( { params: [], args: [], ret: null, expr: macro return $fieldExpr } ); cl.addField(getter); if(setterName != null) { var setter = new FieldInfo(setterName); setter.pos = meta.pos; setter.access = [APrivate, AInline]; setter.kind = FFun( { params: [], args: [ { name: "v", opt: false, type: null, value: null } ], ret: null, expr: macro return $fieldExpr = v } ); cl.addField(setter); } } return cl.fields(); } } ================================================ FILE: huey/src/com/huey/tests/AsyncTestCase.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import com.huey.events.Dispatcher; import haxe.Stack; class AsyncTestCase implements ITest { public var onTestComplete(default, null) : Dispatcher; public var name(default, null) : String; private var _testMethod : AsyncTestCase -> Void; private var _timer : haxe.Timer; public function new(name : String, testMethod : AsyncTestCase -> Void, ?timeout : Int = 1000) { this.name = name; _testMethod = testMethod; onTestComplete = new Dispatcher(); _timer = new haxe.Timer(timeout); } public function accept(visitor : ITestVisitor) : Void { visitor.visitAsyncTestCase(this); } public function run() : TestStatus { _timer.run = timeout; try { _testMethod(this); } catch (error : Dynamic) { _timer.stop(); if (error != TestStatus.passed) onTestComplete.dispatch(TestStatus.failed(error, Stack.exceptionStack())); else onTestComplete.dispatch(TestStatus.passed); } return null; } public function wrapAsync(f : Void -> Void) : Void -> Void { return function() { try { f(); } catch (error : Dynamic) { _timer.stop(); if (error != TestStatus.passed) onTestComplete.dispatch(TestStatus.failed(error, Stack.exceptionStack())); else onTestComplete.dispatch(TestStatus.passed); } } } private function timeout() : Void { onTestComplete.dispatch(TestStatus.failed("Timed out", Stack.callStack())); _timer.stop(); } } ================================================ FILE: huey/src/com/huey/tests/AsyncTestVisitor.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; class AsyncTestVisitor implements ITestVisitor { private var _visitor : ITestVisitor; private var _visits : List Void>; public function new(visitor : ITestVisitor) { _visitor = visitor; _visits = new List(); } public function preVisitTestSuite(suite : TestSuite) : Void { _visits.add( function() _visitor.preVisitTestSuite(suite) ); } public function postVisitTestSuite(suite : TestSuite) : Void { _visits.add( function() _visitor.postVisitTestSuite(suite) ); } public function visitTestCase(test : TestCase) : Void { _visits.add( function() _visitor.visitTestCase(test) ); } public function visitAsyncTestCase(test : AsyncTestCase) : Void { _visits.add( function() _visitor.visitAsyncTestCase(test) ); } public function hasNext() : Bool { return !_visits.isEmpty(); } public function visitNext() : Void { var f = _visits.pop(); f(); } } ================================================ FILE: huey/src/com/huey/tests/ITest.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; interface ITest { var name(default, null) : String; function accept(visitor : ITestVisitor) : Void; } ================================================ FILE: huey/src/com/huey/tests/ITestVisitor.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; interface ITestVisitor { function preVisitTestSuite(suite : TestSuite) : Void; function postVisitTestSuite(suite : TestSuite) : Void; function visitTestCase(test : TestCase) : Void; function visitAsyncTestCase(test : AsyncTestCase) : Void; } ================================================ FILE: huey/src/com/huey/tests/TestBuilder.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import com.huey.macros.MacroTools; import haxe.macro.Context; import haxe.macro.Expr; @:macro class TestBuilder { public static function buildTestSuite() : Array { var cl = Context.getLocalClass().get(); var fields : Array = Context.getBuildFields(); var pos = Context.currentPos(); var testMethods : List = new List(); var asyncTestMethods : List = new List(); var newExprs : Array; function wrapAsync(expr) { switch(expr) { /*case ECall(e, args): switch(Context.typeof(e)) { case TFun(_, _): return ECall( {pos: pos, expr: EField( {pos: pos, expr: EConst(CIdent("async")) }, "wrapAsync") }, [ e ]); default: }*/ case EFunction(name, _): if (name == null) return ECall( {pos: pos, expr: EField( {pos: pos, expr: EConst(CIdent("async")) }, "wrapAsync") }, [{expr: expr, pos: pos}]); default: } return null; } for (field in fields) { switch(field.kind) { case FFun(f): if (field.name == "new") { switch(f.expr.expr) { case EBlock(e): newExprs = e; default: Context.error("Expected EBlock for constructor", pos); } } else { for (meta in field.meta) { if (meta.name == "test") testMethods.add(field.name); else if (meta.name == "asyncTest") { f.args.push( { name: "async", opt: false, type: null, value: null } ); asyncTestMethods.add(field.name); MacroTools.mapExpr(f.expr, wrapAsync); } } } default: } } if (newExprs == null) { newExprs = [ Context.parse("super()", pos) ]; fields.push( { pos: pos, name: "new", meta: [], access: [APublic], doc: null, kind: FFun( { ret: null, params: [], args: [], expr: { expr: EBlock(newExprs), pos: pos } } ) } ); } for(method in testMethods) newExprs.push( Context.parse(Std.format('_tests.add(new com.huey.tests.TestCase("$method", $method))'), pos) ); for(method in asyncTestMethods) newExprs.push( Context.parse(Std.format('_tests.add(new com.huey.tests.AsyncTestCase("$method", $method))'), pos) ); /*for (meta in cl.meta) { if (meta.name == "childSuites") { for (child in meta.params) { } break; } }*/ return fields; } } ================================================ FILE: huey/src/com/huey/tests/TestCase.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import haxe.Stack; class TestCase implements ITest { public var name(default, null) : String; private var _testMethod : Void -> Void; public function new(name : String, testMethod : Void -> Void) { this.name = name; _testMethod = testMethod; } public function accept(visitor : ITestVisitor) : Void { visitor.visitTestCase(this); } public function run() : TestStatus { try { _testMethod(); } catch (error : Dynamic) { if (error != TestStatus.passed) return TestStatus.failed(error, Stack.exceptionStack()); } return TestStatus.passed; } } ================================================ FILE: huey/src/com/huey/tests/TestRunner.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import haxe.Stack; class TestRunner implements ITestVisitor { public var numTestsRun(default, null) : Int; public var numTestsPassed(default, null) : Int; public var numTestsFailed(default, null) : Int; public var numSuitesRun(default, null) : Int; private var _asyncAdapter : AsyncTestVisitor; private var _waiting : Bool; public function new() { numTestsRun = numTestsPassed = numTestsFailed = numSuitesRun = 0; _asyncAdapter = new AsyncTestVisitor(this); _waiting = false; } public function run(test : ITest) : Void { test.accept(_asyncAdapter); runLoop(); } private function runLoop() : Void { _waiting = false; while (_asyncAdapter.hasNext()) { if (_waiting) return; _asyncAdapter.visitNext(); } complete(); } public function preVisitTestSuite(suite : TestSuite) : Void { log(Std.format("Running test suite ${suite.name}...")); numSuitesRun++; suite.setUp(); } public function postVisitTestSuite(suite : TestSuite) : Void { suite.tearDown(); log(Std.format("Finished test suite ${suite.name}.")); } public function visitTestCase(test : TestCase) : Void { log(Std.format("Running test ${test.name}...")); numTestsRun++; switch(test.run()) { case passed: log("Passed!"); numTestsPassed++; case failed(message, stack): log(Std.format("Failed! $message\n$stack")); //_failedTests.add(test); numTestsFailed++; default: } } public function visitAsyncTestCase(test : AsyncTestCase) : Void { log(Std.format("Running test ${test.name}...")); numTestsRun++; test.onTestComplete.add(onAsyncTestCompleted); test.run(); _waiting = true; } private function onAsyncTestCompleted(status : TestStatus) : Void { switch(status) { case passed: log("Passed!"); numTestsPassed++; case failed(message, stack): log(Std.format("Failed! $message\n$stack")); //_failedTests.add(test); numTestsFailed++; default: } runLoop(); } private function complete() : Void { log("Testing complete."); log(Std.format("$numTestsPassed / $numTestsRun tests passed.")); log(Std.format("$numTestsFailed / $numTestsRun tests failed.")); } public dynamic function log(message : String) : Void { trace(message); } } ================================================ FILE: huey/src/com/huey/tests/TestStatus.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import haxe.Stack; enum TestStatus { passed; failed(message : String, stackTrace : Array); } ================================================ FILE: huey/src/com/huey/tests/TestSuite.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.tests; import com.huey.events.Dispatcher; import com.huey.utils.Assert; import haxe.macro.Expr; import haxe.Stack; /** * TestSuite groups test cases together. */ @:autoBuild(com.huey.tests.TestBuilder.buildTestSuite()) class TestSuite implements ITest { public var name(default, null) : String; private var _tests : List; public function new() { name = Type.getClassName( Type.getClass(this) ); _tests = new List(); } public function add(test : ITest) : Void { _tests.add(test); } public function accept(visitor : ITestVisitor) : Void { visitor.preVisitTestSuite(this); for (test in _tests) test.accept(visitor); visitor.postVisitTestSuite(this); } public function iterator() : Iterator { return _tests.iterator(); } public function setUp() : Void { } public function tearDown() : Void { } inline private function assertNull(v : T, ?message : String) : Void { Assert.assertNull(v, message); } inline private function assertNotNull(v : T, ?message : String) : Void { Assert.assertNotNull(v, message); } inline private function assertTrue(b : Bool, ?message : String) : Void { Assert.assertTrue(b, message); } inline private function assertFalse(b : Bool, ?message : String) : Void { Assert.assertFalse(b, message); } inline private function assertEqual(expected : T, actual : T, ?message : String) : Void { Assert.assertEqual(expected, actual, message); } inline private function assertNotEqual(unexpected : T, actual : T, ?message : String = "") : Void { Assert.assertNotEqual(unexpected, actual, message); } private function pass() : Void { throw TestStatus.passed; } private function fail(error : Dynamic) : Void { throw error; } } ================================================ FILE: huey/src/com/huey/ui/Button.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class Button extends StateContainer { public var label : String; public var upState(default, set) : Component; public var overState(default, set) : Component; public var downState(default, set) : Component; private var _isOver : Bool; inline private function set_upState(v : Component) : Component { _states.set("up", []); if(v != null) addToState(v, "up"); return upState = v; } inline private function set_overState(v : Component) : Component { if(v != null) { _states.set("over", []); addToState(v, "over"); } return overState = v; } inline private function set_downState(v : Component) : Component { if(v != null) { _states.set("down", []); addToState(v, "down"); } return downState = v; } public function new() { super(); _implContainer.buttonMode = true; _isOver = false; state = "up"; onMouseOver.add(mouseOverHandler); onMouseDown.add(mouseDownHandler); onMouseUp.add(mouseUpHandler); onMouseOut.add(mouseOutHandler); } private function mouseOverHandler(e) : Void { if (state != "down") { if(_states.exists("over")) state = "over"; } _isOver = true; } private function mouseOutHandler(e) : Void { if(state != "down") { state = "up"; } _isOver = false; } private function mouseDownHandler(e) : Void { if(_states.exists("down")) state = "down"; } private function mouseUpHandler(e) : Void { if (_isOver && _states.exists("over")) state = "over"; else state = "up"; } } ================================================ FILE: huey/src/com/huey/ui/CheckBox.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class CheckBox extends Button { @bindable public var selected(default, set) : Bool; private function set_selected(v : Bool) : Bool { selected = v; updateState(); return selected; } public var selectedUpState(default, set) : Component; public var selectedOverState(default, set) : Component; public var selectedDownState(default, set) : Component; inline private function set_selectedUpState(v : Component) : Component { if(v != null) _states.set("selectedUp", [v]); return v; } inline private function set_selectedOverState(v : Component) : Component { if(v != null) _states.set("selectedOver", [v]); return v; } inline private function set_selectedDownState(v : Component) : Component { if(v != null) _states.set("selectedDown", [v]); return v; } public function new() { super(); onClick.add(clickHandler); } override private function mouseOverHandler(e) : Void { if (state != "down" && state != "selectedDown") { if(selected) { if (_states.exists("selectedOver")) state = "selectedOver"; } else { if (_states.exists("over")) state = "over"; } } _isOver = true; } override private function mouseOutHandler(e) : Void { if(state != "down" && state != "selectedDown") { state = if(selected) "selectedUp" else "up"; } _isOver = false; } override private function mouseDownHandler(e) : Void { if(selected) { if (_states.exists("selectedDown")) state = "selectedDown"; } else { if (_states.exists("down")) state = "down"; } } override private function mouseUpHandler(e) : Void { if (_isOver) { if (!selected) { if (_states.exists("over")) state = "over"; } else { if (_states.exists("selectedOver")) state = "selectedOver"; } } else { state = if (selected) "selectedUp" else "up"; } } private function updateState() : Void { if (_isOver) { if (!selected) { if (_states.exists("over")) state = "over"; } else { if (_states.exists("selectedOver")) state = "selectedOver"; else state = "selectedUp"; } } else { state = if (selected) "selectedUp" else "up"; } } private function clickHandler(e) : Void { selected = !selected; } } ================================================ FILE: huey/src/com/huey/ui/Component.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; import com.huey.binding.Binding; @:autoBuild(com.huey.macros.Macros.build()) interface UIBase { } class Component extends Binding.Bindable implements UIBase { public var parent(default, null) : Container; public var root(get_root, null) : Container; private function get_root() { var c = this; while (c.parent != null) c = c.parent; return c.root; } @bindable public var enabled(default, set_enabled) : Bool; private function set_enabled(v) { if (Std.is(_implComponent, flash.display.InteractiveObject)) { untyped _implComponent.mouseEnabled = v; untyped _implComponent.tabEnabled = v; untyped _implComponent.mouseChildren = v; } _implComponent.alpha = if (v) 1.0 else 0.5; return enabled = v; } @forward(_implComponent) public var visible : Bool; @forward(_implComponent) public var x : Float; @forward(_implComponent) public var y : Float; @forward(_implComponent) public var alpha : Float; public var depth(default, set_depth) : Float; private function set_depth(v) { depth = v; //if(parent != null) parent.needDepthSort(); return depth; } public var hitArea(default, set_hitArea) : HitArea; public function set_hitArea(v) { hitArea = v; if(Std.is(_implComponent, flash.display.Sprite)) { untyped { _implComponent.graphics.clear(); } switch(hitArea) { case Self: untyped{ _implComponent.hitArea = null; } case Rectangle(x, y, width, height): untyped { _implComponent.graphics.beginFill(0, 0); _implComponent.graphics.drawRect(x, y, width, height); _implComponent.graphics.endFill(); } } } return hitArea; } public var width(get_width, set_width) : Float; private function get_width() return _implComponent.width; private function set_width(v) return _implComponent.width = v; public var height(get_height, set_height) : Float; private function get_height() return _implComponent.height; private function set_height(v) return _implComponent.height = v; // ===== EVENTS ===== public var onClick : Dispatcher; public var onMouseOver : Dispatcher; public var onMouseOut : Dispatcher; public var onMouseDown(default, null) : Dispatcher; public var onMouseUp(default, null) : Dispatcher; public function new(implComponent : flash.display.DisplayObject) { super(); _implComponent = implComponent; visible = true; x = 0.0; y = 0.0; depth = 0.0; hitArea = Self; onClick = new Dispatcher(); _implComponent.addEventListener(flash.events.MouseEvent.CLICK, function(_) onClick.dispatch( { source: this } ) ); onMouseOver = new Dispatcher(); _implComponent.addEventListener(flash.events.MouseEvent.ROLL_OVER, function(e) { onMouseOver.dispatch( { source: this } ); e.updateAfterEvent(); } ); onMouseOut = new Dispatcher(); _implComponent.addEventListener(flash.events.MouseEvent.ROLL_OUT, function(e) { onMouseOut.dispatch( { source: this } ); e.updateAfterEvent(); } ); onMouseDown = new Dispatcher(); _implComponent.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, mouseDownInternalHandler ); onMouseUp = new Dispatcher(); } private var _implComponent : flash.display.DisplayObject; private function mouseDownInternalHandler(e) { flash.Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, mouseUpInternalHandler, false, 0, true); onMouseDown.dispatch({source: this}); // e.updateAfterEvent(); } private function mouseUpInternalHandler(e) { flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.MOUSE_UP, mouseUpInternalHandler); onMouseUp.dispatch({source: this}); //e.updateAfterEvent(); } } enum HitArea { Self; Rectangle(x : Float, y : Float, width : Float, height : Float); } ================================================ FILE: huey/src/com/huey/ui/Container.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class Container extends Component { public var numChildren(get, never) : Int; private var _children : List; private var _implContainer : flash.display.Sprite; private var _needsDepthSorting : Bool; public function new() { _implContainer = new flash.display.Sprite(); super(_implContainer); _children = new List(); } public function add(child : Component) : Void { _children.add(child); child.parent = this; _implContainer.addChild(child._implComponent); } public function remove(child : Component) : Bool { var removed : Bool = _children.remove(child); _implContainer.removeChild(child._implComponent); child.parent = null; return removed; } public function removeAll() : Void { for(child in _children) { _implContainer.removeChild(child._implComponent); child.parent = null; } _children.clear(); } private function get_numChildren() : Int { return _children.length; } public function needDepthSort() : Void { _needsDepthSorting = true; flash.Lib.current.stage.addEventListener(flash.events.Event.EXIT_FRAME, depthSort, false, 0, true); } private function depthSort(_) { // TODO: merge sort linked list if(_needsDepthSorting) { flash.Lib.current.stage.removeEventListener(flash.events.Event.EXIT_FRAME, depthSort); var a = []; for (child in _children) a.push(child); a.sort( function(a, b) { return if (a.depth < b.depth) -1 else if(a.depth > b.depth) 1 else 0; } ); var i = 0; for (child in a) _implContainer.setChildIndex(child._implComponent, i++); _needsDepthSorting = false; } } } ================================================ FILE: huey/src/com/huey/ui/Image.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.assets.Asset; class Image extends Component { public function new(source : Asset) { _implImage = if(source != null) source.data else null; super(new flash.display.Bitmap(_implImage, flash.display.PixelSnapping.AUTO, true)); } private var _implImage : flash.display.BitmapData; } ================================================ FILE: huey/src/com/huey/ui/Label.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; import flash.text.TextFormat; class Label extends Component { public var text(default, set_text) : String; private function set_text(v : String) : String { if (v == null) v = ""; text = _implText.text = v; return v; } @forward(_implText) public var wordWrap : Bool; public var color(get_color, set_color) : Int; private function get_color() return _textFormat.color; private function set_color(v) { _textFormat.color = v; updateTextFormat(); return v; } public var font(get_font, set_font) : String; private function get_font() return _textFormat.font; private function set_font(v) { _textFormat.font = v; updateTextFormat(); return v; } public var size(get_size, set_size) : Float; private function get_size() return _textFormat.size; private function set_size(v) { _textFormat.size = v; updateTextFormat(); return v; } public var bold(get_bold, set_bold) : Bool; private function get_bold() return _textFormat.bold; private function set_bold(v) { _textFormat.bold = v; updateTextFormat(); return v; } public var editable(get_editable, set_editable) : Bool; private function get_editable() return _implText.type == flash.text.TextFieldType.INPUT; private function set_editable(v) { _implText.selectable = v; _implText.type = v ? flash.text.TextFieldType.INPUT : flash.text.TextFieldType.DYNAMIC; return v; } public var autoSize(get_autoSize, set_autoSize) : Bool; private function get_autoSize() return _implText.autoSize != flash.text.TextFieldAutoSize.NONE; private function set_autoSize(v) { _implText.autoSize = if(v) flash.text.TextFieldAutoSize.LEFT else flash.text.TextFieldAutoSize.NONE; if(v == false) { _implText.width = 100; _implText.height = 20; } return v; } public var align(get_align, set_align) : TextAlign; private function get_align() { return switch(_textFormat.align) { case flash.text.TextFormatAlign.LEFT: TextAlign.left; case flash.text.TextFormatAlign.CENTER: TextAlign.center; case flash.text.TextFormatAlign.RIGHT: TextAlign.right; case flash.text.TextFormatAlign.JUSTIFY: TextAlign.justify; default: TextAlign.left; } } private function set_align(v) { _textFormat.align = switch(v) { case TextAlign.left: flash.text.TextFormatAlign.LEFT; case TextAlign.center: flash.text.TextFormatAlign.CENTER; case TextAlign.right: flash.text.TextFormatAlign.RIGHT; case TextAlign.justify: flash.text.TextFormatAlign.JUSTIFY; } updateTextFormat(); return v; } public var letterSpacing(get_letterSpacing, set_letterSpacing) : Float; private function get_letterSpacing() return _textFormat.letterSpacing; private function set_letterSpacing(v) { _textFormat.letterSpacing = v; updateTextFormat(); return v; } @forward(_implText.restrict) public var allowedCharacters : String; public var onUserEdited(default, null) : Dispatcher; public function new(?text = "") { onUserEdited = new Dispatcher(); _implText = new flash.text.TextField(); _implText.width = 100; _implText.height = 20; _implText.addEventListener(flash.events.Event.CHANGE, textChangeHandler); _implText.addEventListener(flash.events.FocusEvent.FOCUS_OUT, function(_) dispatchChange()); autoSize = true; _implText.embedFonts = true; _implText.selectable = false; _textFormat = new TextFormat("Arial", 12, 0x000000, false, false, false); updateTextFormat(); super(_implText); this.text = text; } private var _implText : flash.text.TextField; private var _textFormat : flash.text.TextFormat; private var _changeTimer : haxe.Timer; private inline function updateTextFormat() { _implText.defaultTextFormat = _textFormat; _implText.setTextFormat(_textFormat); } private function textChangeHandler(_) { if(_changeTimer != null) { _changeTimer.stop(); } _changeTimer = new haxe.Timer(750); _changeTimer.run = dispatchChange; } private function dispatchChange() { if(this.text != _implText.text) { this.text = _implText.text; onUserEdited.dispatch({source: this}); } if(_changeTimer != null) { _changeTimer.stop(); _changeTimer = null; } } } ================================================ FILE: huey/src/com/huey/ui/ListBox.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; class ListBox extends Container { @bindable public var selectedItem(get_selectedItem, set_selectedItem) : Dynamic; private function get_selectedItem() : Dynamic { return if(selectedIndex >= 0) _items[selectedIndex].data else null; } private function set_selectedItem(v : Dynamic) : Dynamic { var i = 0; for (item in _items) { if ( item.data == v ) { set_selectedIndex(i); break; } i++; } return selectedItem; } public var onChange(default, null) : Dispatcher; @bindable public var selectedIndex(default, set_selectedIndex) : Int = -1; private function set_selectedIndex(v : Int) : Int { _selectedRect.visible = false; selectedIndex = v; if (selectedIndex < 0) selectedIndex = -1; if (selectedIndex > _items.length - 1) selectedIndex = _items.length - 1; if (selectedIndex >= 0) { _selectedRect.visible = true; _selectedRect.y = _items[selectedIndex].view.y + 4; } dispatchBinding("selectedItem"); onChange.dispatch({source: this}); return selectedIndex; } public function new() { onChange = new Dispatcher(); super(); _items = new Array(); _scrollRect = new flash.geom.Rectangle(0, 0, 290, 70); _itemContainer = new Container(); _itemContainer.x = 9; _itemContainer.y = 2; _itemContainer._implComponent.scrollRect = _scrollRect; add(_itemContainer); _selectedRect = new Rectangle(0xccf3e728, 287, 15); _itemContainer.add(_selectedRect); _selectedRect.x = -2; _selectedRect.visible = false; _scrollButton = new Button(); _scrollButton.add(new Image(com.huey.assets.AssetManager.instance.getAsset("btnDragger"))); _scrollButton.x = 295; _scrollButton.y = 5; _scrollButton.visible = false; _scrollButton.onMouseDown.add(function(_) { flash.Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, mouseMoveHandler, false, 0, true); mouseMoveHandler(null); }); _scrollButton.onMouseUp.add(function(_) { flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.MOUSE_MOVE, mouseMoveHandler); }); _implComponent.addEventListener(flash.events.MouseEvent.MOUSE_WHEEL, mouseWheelHandler); add(_scrollButton); } private function mouseWheelHandler(e) { if(_items.length <= 4) return; _scrollButton.y -= e.delta; updateScrollRect(); e.updateAfterEvent(); } private function mouseMoveHandler(e) { _scrollButton.y = _implComponent.mouseY; updateScrollRect(); if(e != null) e.updateAfterEvent(); } private function updateScrollRect() { if(_scrollButton.y < 5) _scrollButton.y = 5; if(_scrollButton.y > 55) _scrollButton.y = 55; _scrollRect.y = 16 * (_items.length - 4) * (_scrollButton.y - 4) / 50; _itemContainer._implComponent.scrollRect = _scrollRect; } private function updateScroll() { _scrollButton.visible = _items.length > 4; _scrollButton.y = 5 + (_scrollRect.y * 50) / (16 * (_items.length - 4)); if(_scrollButton.y < 5) _scrollButton.y = 5; if(_scrollButton.y > 55) { _scrollButton.y = 55; updateScrollRect(); } } public function addItem(item : Dynamic, ?label : String) : Void { var comp = new Container(); var labelComp = new Label(); labelComp.text = if(Reflect.hasField(item, "label")) Reflect.getProperty(item, "label") else Std.string(item); comp.x = 0; comp.y = _items.length * 14; // TODO labelComp.x = 15; labelComp.font = "AdvoCut_10pt_st"; labelComp.size = 10; labelComp.color = 0x425137; labelComp.autoSize = false; labelComp.width = 266; comp.add(labelComp); untyped comp._implComponent.buttonMode = true; untyped comp._implComponent.mouseChildren = false; comp.onClick.add( function(i) {return function(e) selectedIndex = i;}(_items.length) ); var str = Std.string(_items.length + 1); if(str.length < 2) str = "0" + str; labelComp = new Label(str); labelComp.font = "AdvoCut_10pt_st"; labelComp.size = 10; labelComp.color = 0xD16436; labelComp.width = 20; labelComp.x = 0; comp.add(labelComp); _itemContainer.add(comp); _items.push( { data : item, label: comp, view: comp, number: labelComp} ); updateScroll(); } public function removeItemAt(i : Int) : Void { var item = _items[i]; if(item != null) { _itemContainer.remove(item.label); _items.splice(i, 1); items.splice(i, 1); for(j in i..._items.length) { var str = Std.string(j + 1); if(str.length < 2) str = "0" + str; _items[j].view.y = j * 14; _items[j].number.text = str; } if(i == selectedIndex) { if(i > _items.length - 1) i = _items.length - 1; selectedIndex = i; } updateScroll(); } } public var items(default, set) : Array; private function set_items( v : Array ) : Array { for (item in _items) _itemContainer.remove(item.label); _items = []; for (item in v) addItem(item); if (selectedIndex >= _items.length) { selectedIndex = _items.length - 1; } return items = v; } private var _items : Array; private var _selectedRect : Rectangle; private var _itemContainer : Container; private var _scrollRect : flash.geom.Rectangle; private var _scrollButton : Button; } typedef ListItem = { label : Container, data : Dynamic, view : Container, number : Label }; ================================================ FILE: huey/src/com/huey/ui/NumericStepper.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; class NumericStepper extends Container { @forward(_textBox) public var font : String; @forward(_textBox) public var size : Float; @forward(_textBox) public var color : Int; public var minimum : Float; public var maximum : Float; public var step : Float = 1; public var onChange(default, null) : Dispatcher; public var onUserChange(default, null) : Dispatcher; @bindable public var value(default, set) : Float; private function set_value(v : Float) : Float { value = v; if(Math.isNaN(value)) value = 0; if(value < minimum) value = minimum; else if(value > maximum) value = maximum; if(_textBox != null) _textBox.text = Std.string(value); onChange.dispatch({source: this}); return value; } public function new() { super(); onChange = new Dispatcher(); onUserChange = new Dispatcher(); value = 0; minimum = Math.NEGATIVE_INFINITY; maximum = Math.POSITIVE_INFINITY; } public var textX(default, set) : Float; private function set_textX(v : Float) : Float { return _textBox.x = v; } public var textY(default, set) : Float; private function set_textY(v : Float) : Float { return _textBox.y = v; } public var _textBox(default, set) : TextBox; private function set__textBox(v) { _textBox = v; _textBox.onUserEdited.add(function(_) { value = Std.parseFloat(_textBox.text); onUserChange.dispatch({source: this});}); value = value; _textBox.allowedCharacters = "0123456789"; return _textBox; } public var incButton(default, set) : Button; private function set_incButton(v : Button) : Button { add(v); v.onClick.add(function(_) {value+=step; onUserChange.dispatch({source: this});} ); return incButton = v; } public var decButton(default, set) : Button; private function set_decButton(v : Button) : Button { add(v); v.onClick.add(function(_) {value-=step; onUserChange.dispatch({source: this});} ); return decButton = v; } } ================================================ FILE: huey/src/com/huey/ui/ProgressBar.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class ProgressBar extends Slider { public function new() { super(); minimum = 0; maximum = 100; untyped _implComponent.mouseEnabled = _implComponent.tabEnabled = false; } override private function updateNub() : Void { untyped { _implComponent.scrollRect = new flash.geom.Rectangle(0, 0, 567 * (value - minimum) / (maximum - minimum), 13); } } } ================================================ FILE: huey/src/com/huey/ui/RadioButton.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class RadioButton extends CheckBox { public var group : RadioGroup; public function new() { super(); } private override function clickHandler(e) : Void { if(group != null && group.selectedItem != null) group.selectedItem.selected = false; selected = true; if(group != null) group.selectedItem = this; updateState(); } } ================================================ FILE: huey/src/com/huey/ui/RadioGroup.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; class RadioGroup extends com.huey.binding.Binding.Bindable { public function new() { onChange = new Dispatcher(); super(); items = new Array(); } public var onChange : Dispatcher; public var items : Array; @bindable public var selectedItem(default, set_selectedItem) : Null = null; private inline function set_selectedItem(v) { selectedItem = v; onChange.dispatch(null); return v; } } ================================================ FILE: huey/src/com/huey/ui/Rectangle.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class Rectangle extends Component { public function new(color : Int, width : Float, height : Float) { var shape = new flash.display.Shape(); shape.graphics.beginFill(color, (color >>> 24) / 255.0); shape.graphics.drawRect(0, 0, width, height); shape.graphics.endFill(); super(shape); } } ================================================ FILE: huey/src/com/huey/ui/ScaledImage.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class ScaledImage extends Container { public var scaleMode(default, set_scaleMode) : ScaleMode; private function set_scaleMode(v) { scaleMode = v; updateSize(); return v; } private var _width : Int; private var _height : Int; private function updateSize() { if((untyped _image._implImage) == null) return; _implComponent.scrollRect = new flash.geom.Rectangle(0, 0, _width, _height); var desiredAspect = _width / _height; var actualAspect = untyped _image._implImage.width / _image._implImage.height; switch(scaleMode) { case crop: if(actualAspect > desiredAspect) { _image.height = _height; _image.width = _height * actualAspect; _image.x = (_height * actualAspect - _width)/2; _image.y = 0; } else { _image.width = _width; _image.height = _implComponent.width / actualAspect; _image.x = 0; _image.y = (_width / actualAspect - _height)/2; } case letterbox: if(actualAspect > desiredAspect) { _image.width = _width; _image.height = _width / actualAspect; _image.x = 0; _image.y = (_height - _width / actualAspect)/2; } else { _image.height = _height; _image.width = _height * actualAspect; _image.x = (_width - _height * actualAspect)/2; _image.y = 0; } case stretch: _image.width = _width; _image.height = _height; _image.x = _image.y = 0; } } private var _width : Float; private var _height : Float; override private function set_width(v) { _width = v; updateSize(); return v; } override private function set_height(v) { _height = v; updateSize(); return v; } public function new(source : com.huey.assets.Asset) { super(); _image = new Image(source); add(_image); scaleMode = letterbox; } private var _image : Image; } enum ScaleMode { crop; letterbox; stretch; } ================================================ FILE: huey/src/com/huey/ui/SelectBox.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.assets.AssetManager; import com.huey.events.Dispatcher; import com.huey.events.Dispatcher; import com.huey.ui.Image; class SelectBox extends Container { @forward(_listBox) public var items : Array; @forward(_listBox) public var selectedItem : Dynamic; @forward(_listBox) public var selectedIndex : Dynamic; public var onChange(default, null) : Dispatcher; public function new() { super(); var assetManager = AssetManager.instance; _listBoxBg = new Image(assetManager.getAsset("listBoxBigBG")); _listBoxBg.visible = false; _listBoxBg.y = 22; add(_listBoxBg); _listBox = new ListBox(); _listBox.visible = false; _listBox.y = 22; _listBox.onChange.add(listBoxChangeHandler); add(_listBox); _textBoxBg = new Image(assetManager.getAsset("textFieldBig")); add(_textBoxBg); _textBox = new Label(); _textBox.width = 312; _textBox.x = 8; _textBox.y = 1; _textBox.font = "AdvoCut_10pt_st"; _textBox.size = 10; _textBox.bold = true; _textBox.color = 0x425137; add(_textBox); _showButton = new Button(); _showButton.upState = new Image(assetManager.getAsset("btnDecUp")); _showButton.overState = new Image(assetManager.getAsset("btnDecOver")); _showButton.downState = new Image(assetManager.getAsset("btnDecDown")); _showButton.x = 309; _showButton.hitArea = Rectangle(-309, 0, 329, 25); _textBoxBg.onClick.add(showButtonClickHandler); _showButton.onClick.add(showButtonClickHandler); add(_showButton); onChange = new Dispatcher(); _listBox.onChange.add(function(_) onChange.dispatch({source: this})); } private var _textBoxBg : Image; private var _textBox : Label; private var _listBoxBg : Image; private var _listBox : ListBox; private var _showButton : Button; private function showButtonClickHandler(_) { _listBox.visible = !_listBox.visible; _listBoxBg.visible = _listBox.visible; if(_listBox.visible) { flash.Lib.current.stage.addEventListener(flash.events.MouseEvent.CLICK, stageClickHandler, false, 0, false); } else { flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.CLICK, stageClickHandler); } } private function listBoxChangeHandler(_) { _listBox.visible = _listBoxBg.visible = false; _textBox.text = Std.string(_listBox.selectedItem.label); flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.CLICK, stageClickHandler); } private function stageClickHandler(_) { var c = flash.Lib.current.stage.focus; while(c != null) { if(c == _implComponent) return; c = c.parent; } _listBox.visible = _listBoxBg.visible = false; flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.CLICK, stageClickHandler); } } ================================================ FILE: huey/src/com/huey/ui/Slider.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; class Slider extends Container { @bindable public var value(default, set) : Float; private function set_value(v : Float) : Float { if (step != 0) v = Math.round(v / step) * step; if (v < minimum) v = minimum; if (v > maximum) v = maximum; value = v; label.text = if(labelFunc != null) labelFunc(value) else Std.string(value); updateNub(); return value; } public var minimum(default, set) : Float; private inline function set_minimum(v : Float) : Float { minimum = v; set_value( value ); return minimum; } public var maximum(default, set) : Float; private inline function set_maximum(v : Float) : Float { maximum = v; set_value( value ); return maximum; } public var step(default, set) : Float; private inline function set_step(v : Float) : Float { if (v < 0 || Math.isNaN(v)) v = 0; step = v; set_value( value ); return step; } @forward(label) public var font : String; @forward(label) public var size : Float; @forward(label) public var color : Int; @forward(label) public var bold : Bool; public var nubMinimum : Float = 5.0; public var nubMaximum : Float = 200.0; public var nub : Component; public var label : Label; public var labelFunc(default, set) : Float -> String; private function set_labelFunc(v) { labelFunc = v; label.text = if (labelFunc != null) labelFunc(value) else Std.string(value); return labelFunc; } public function new() { super(); label = new Label(); add(label); value = minimum = 0.0; maximum = 1.0; step = 0; onMouseDown.add(mouseDownHandler); onMouseUp.add(mouseUpHandler); untyped _implComponent.buttonMode = true; } private function updateNub() : Void { if(nub != null) nub.x = (nubMaximum - nubMinimum) * (value - minimum) / (maximum - minimum) + nubMinimum - nub.width / 2; } private function mouseDownHandler(_) : Void { flash.Lib.current.stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, mouseMoveHandler, false, 0, true); mouseMoveHandler(null); } private function mouseUpHandler(_) : Void { flash.Lib.current.stage.removeEventListener(flash.events.MouseEvent.MOUSE_MOVE, mouseMoveHandler, false); } private function mouseMoveHandler(e) : Void { value = untyped { minimum + (maximum - minimum) * (_implComponent.mouseX - nubMinimum) / (nubMaximum-nubMinimum); }; if(e != null) e.updateAfterEvent(); } } ================================================ FILE: huey/src/com/huey/ui/StateContainer.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import haxe.ds.StringMap; class StateContainer extends Container { public var state(default, set) : String; private function set_state(v : String) : String { var oldState = _states.get(state); if (oldState != null) { for(child in oldState) remove(child); } var newState = _states.get(v); if (newState != null) { for (comp in newState) add(comp); } return state = v; } private var _states : StringMap; public function addToState(component : Component, state : String) : Void { if (!_states.exists(state)) _states.set(state, new UIState()); _states.get(state).push(component); if (this.state == null) this.state = state; else if (state == this.state) add(component); } public function new() { super(); _states = new StringMap(); } } typedef UIState = Array; ================================================ FILE: huey/src/com/huey/ui/TextAlign.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; enum TextAlign { left; center; right; justify; } ================================================ FILE: huey/src/com/huey/ui/TextBox.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.events.Dispatcher; class TextBox extends Container { @forward(_text) public var text : String; @forward(_text) public var font : String; @forward(_text) public var size : Float; @forward(_text) public var color : Int; @forward(_text) public var allowedCharacters : String; public var textX(default, set_textX) : Float; private function set_textX(v : Float) : Float { return textX = _text.x = v; } public var textY(default, set_textY) : Float; private function set_textY(v : Float) : Float { return textY = _text.y = v; } override private function set_width(v : Float) { _text.width = v - textX*2; return v; } override private function set_height(v : Float) { _text.height = v - textY*2; return v; } public var onUserEdited(default, null) : Dispatcher; public function new() { onUserEdited = new Dispatcher(); super(); _text = new Label(); _text.autoSize = false; _text.editable = true; add(_text); _text.onUserEdited.add(function(_) onUserEdited.dispatch()); } private var _text : Label; } ================================================ FILE: huey/src/com/huey/ui/UIEvent.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; typedef UIEvent = { var source : Component; }; ================================================ FILE: huey/src/com/huey/ui/UIMacros.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import haxe.macro.Context; import haxe.macro.Expr; import haxe.macro.Type; @:macro class UIMacros { public static function buildComponent() : Array { var cl : ClassType = Context.getLocalClass(); var fields : Array = Context.getBuildFields(); } } ================================================ FILE: huey/src/com/huey/utils/Assert.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; class Assert { inline public static function assertNull(v : T, ?message : String) : Void { if (v != null) { throw 'assertNull failed!\n$message'; } } inline public static function assertNotNull(v : T, ?message : String) : Void { if (v == null) { throw 'assertNotNull failed!\n$message'; } } inline public static function assertTrue(b : Bool, ?message : String) : Void { if (!b) { throw 'assertTrue failed! $message'; } } inline public static function assertFalse(b : Bool, ?message : String) : Void { if (b) { throw 'assertFalse failed! $message'; } } inline public static function assertEqual(expected : T, actual : T, ?message : String) : Void { if (expected != actual) { throw 'assertEqual failed! $expected != $actual\n$message'; } } inline public static function assertNotEqual(expected : T, actual : T, ?message : String) : Void { if (expected == actual) { throw 'assertNotEqual failed! $expected == $actual\n$message'; } } } ================================================ FILE: huey/src/com/huey/utils/Logger.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import haxe.ds.StringMap; import haxe.macro.Expr; class Logger { inline public static function log(name : String, msg : String) { Logger.getInstance(name).logMessage(msg); } inline public static function getLog(name : String) : String { return Logger.getInstance(name).get(); } private static var loggers : StringMap = new StringMap(); inline public static function getInstance(name : String) { var logger = loggers.get(name); if(logger == null) { logger = new Logger(name, File.applicationStorageDirectory.resolvePath('$name.txt').nativePath); loggers.set(name, logger); } return logger; } private var name : String; private var logFile : File; private var outputStream : FileStream; private function new(name : String, outputFile : String) { this.name = name; logFile = new File(outputFile); try { if(logFile.exists) logFile.deleteFile(); outputStream = new FileStream(); outputStream.open(logFile, FileMode.UPDATE); } catch(_ : Dynamic) { outputStream = null; } } public function logMessage(msg : String) { #if debug trace('$msg'); #end if(outputStream != null) { try outputStream.writeUTFBytes(msg) catch(_ : Dynamic) {} } } public function get() : String { //var inputStream = new FileStream(); try { //inputStream.open(logFile, FileMode.READ); outputStream.position = 0; var data = outputStream.readUTFBytes(outputStream.bytesAvailable); //inputStream.close(); return data; } catch(_ : Dynamic) return ""; } } ================================================ FILE: huey/src/com/huey/utils/Thread.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; import flash.events.Event; import flash.system.Worker; import flash.system.WorkerDomain; import flash.system.WorkerState; #if flash9 class Thread { public var state(default, null) : ThreadState; private var _worker : Worker; // MIKE: swf width and height for flash only public static function spawn(entryPoint : String) : Thread { var thread = new Thread(WorkerDomain.current.createWorker(flash.Lib.current.loaderInfo.bytes, true)); thread.setProperty("entryPoint", entryPoint); return thread; } public static var current(get, null) : Thread; private static function get_current() : Thread { if(current == null) { current = new Thread(Worker.current); } return current; } private function new(worker : flash.system.Worker) { _worker = worker; workerStateHandler(null); _worker.addEventListener(Event.WORKER_STATE, workerStateHandler); } public function start() : Void { _worker.start(); } public function getProperty(key : String) : Dynamic { return _worker.getSharedProperty(key); } public function setProperty(key : String, value : Dynamic) : Void { _worker.setSharedProperty(key, value); } private function workerStateHandler(e : Event) : Void { state = switch(_worker.state) { case NEW: stopped; case RUNNING: running; case TERMINATED: terminated; } } } #else #error Threads not implemented on this platform #end enum ThreadState { stopped; running; terminated; } ================================================ FILE: huey/src/com/huey/utils/WeakRef.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; #if flash9 class WeakRef { private var _dictionary : flash.utils.TypedDictionary; public function new(object : T) { _dictionary = new flash.utils.TypedDictionary(true); if (object != null) _dictionary.set(object, 1); } public function get() : Null { for (key in _dictionary.keys()) if (key != null) return key; return null; } } #else class WeakRef { private var _object : T; public function new(object : T) { _object = t; } inline public function get() : Null { return _object; } } #end ================================================ FILE: huey/test/com/huey/assets/AssetTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.assets; import com.huey.tests.TestSuite; class AssetTests extends TestSuite { @test public function testAsset() : Void { var asset : Asset = new Asset("myAsset", Internal("Foo")); } @test public function testAssetManager() : Void { var assetManager : AssetManager = new AssetManager(); assetManager.registerAsset( new Asset("myAsset", Internal("Foo")) ); } /** Tests AssetSource. */ @test public function testInternalAssetSource() { var asset : AssetSource; asset = Internal("Foo"); } @test public function testExternalAssetSource() { var asset : AssetSource; asset = External("Foo"); } } ================================================ FILE: huey/test/com/huey/binding/BindingTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.binding; import com.huey.tests.TestSuite; import com.huey.binding.Binding; /** * Tests the data binding framework. * @author Newgrounds.com, Inc. */ class BindingTests extends TestSuite { /** Tests binding to a member variable. */ @test public function testBindingVariable() { var a = new BindObject(); var b = new BindObject(); Binding.bind(b.foo, a.foo); a.foo = 10; assertEqual(10, b.foo, "Variable change did not propogate."); } /** Tests binding to a property. */ @test public function testBindingProperty() { var a = new BindObject(); var b = new BindObject(); Binding.bind(b.bar, a.bar); a.bar = "blah"; assertEqual("blah", b.bar, "Property change did not propogate."); } /** Tests binding to a property with a setter. */ @test public function testBindingPropertySetter() { var a = new BindObject(); var b = new BindObject(); Binding.bind(b.baz, a.baz); a.baz = 2.1; assertEqual(2.1, b.baz, "Property change with setter did not propogate."); assertTrue(b.setterCalled, "Setter was not called on property change."); } /** * Tests two-way binding to a variable. * Watch out for infinite recursions here. */ @test public function testTwoWayBindingVariable() { var a = new BindObject(); var b = new BindObject(); Binding.bindTwoWay(b.foo, a.foo); a.foo = 10; assertEqual(10, b.foo, "Variable change did not propogate."); b.foo = 20; assertEqual(20, a.foo, "Variable change did not propogate."); } @test public function textExpressionBinding() { var a = new BindObject(); var b = new BindObject(); Binding.bind(b.foo, a.foo * 2); a.foo = 2; assertEqual(4, b.foo, "Variable change did not propogate"); } /** Test deep binding. */ @test public function testDeepBinding() { var a = new BindObject(); var b = new BindObject(); Binding.bindTwoWay(b.baz, a.child.x); a.child.x = -1.0; a.child = new BindObject2(); assertEqual(0.0, b.baz, "Subcomponent variable change did not propogate."); a.child.x = 1.0; assertEqual(1.0, b.baz, "Subcomponent variable change did not propogate."); } /** Test bindable arrays. */ @test public function testBindableArray() { var a = new BindObject(); var b = new BindObject2(); Binding.bind(b.array, a.array); a.array = BindableArray.fromArray([1, 2]); assertEqual(1, b.array.array[0]); assertEqual(2, b.array.array[1]); assertEqual(2, b.array.length); assertEqual(3, b.sum); a.array.push(3); assertEqual(3, b.array.array[2]); assertEqual(3, b.array.length); assertEqual(6, b.sum); } } private class BindObject extends Binding.Bindable { @bindable public var foo : Int; @bindable public var bar(default, default) : String; @bindable public var baz(getBaz, setBaz) : Float; @bindable public var child : BindObject2; @bindable public var array : BindableArray; public var setterCalled : Bool; public function new() { super(); child = new BindObject2(); setterCalled = false; } private function getBaz() { return baz; } private function setBaz(x) { setterCalled = true; return baz = x; } } private class BindObject2 extends Binding.Bindable { public var array(default, set_array) : BindableArray; private function set_array(v) { array = v; sum = 0; if (array != null) for (i in array) sum += i; return array; } public function new() { super(); x = 0.0; } @bindable public var x : Float; public var sum : Int; } ================================================ FILE: huey/test/com/huey/core/ApplicationTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.core; import com.huey.tests.TestSuite; import com.huey.core.Application; class ApplicationTests extends TestSuite { @test private function testApplication() : Void { var app : Application = new SimpleApplication(); assertNotNull(app.buildTime); assertNotNull(app.ui, "UI should be initialized."); } } @layout("layout.xml") private class SimpleApplication extends Application { public function new() { super(); } } ================================================ FILE: huey/test/com/huey/events/EventTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.events; import com.huey.tests.TestSuite; import com.huey.events.Dispatcher; /** * Tests the event handling system. */ class EventTests extends TestSuite { /** Tests dispatch instantiation and default values. */ @test public function testDispatcher() { var dispatcher = new Dispatcher(); assertEqual(0, dispatcher.numListeners, "A dispatcher should start with 0 listeners."); } /** * Tests listener registration and dispatch. * Verifies that the listener is called when an event is dispatched. */ @test public function testDispatch() { var dispatcher = new Dispatcher(); var called = false; var eventArg = { x: 3 }; function listener(e) { called = true; assertEqual(eventArg, e, "Event parameter was not dispatched"); } dispatcher.add(listener); dispatcher.dispatch(eventArg); assertTrue(called, "Listener was not called after dispatch()."); } /** Tests removal of a listener */ @test public function testRemove() { var dispatcher = new Dispatcher(); var calls = 0; function listener(e) { throw "Listener remains after remove()."; } dispatcher.add(listener); dispatcher.remove(listener); dispatcher.dispatch(); assertEqual(calls, 0); } /** Test numListeners count */ @test public function testNumListeners() { var dispatcher = new Dispatcher(); function listener(e) { } assertEqual(0, dispatcher.numListeners); dispatcher.add(listener); assertEqual(1, dispatcher.numListeners); dispatcher.remove(listener); assertEqual(0, dispatcher.numListeners); dispatcher.add(listener); dispatcher.add(function (event) { } ); assertEqual(2, dispatcher.numListeners); } /** * Tests that a listener may only be added once * Subsequent adds fail silently */ @test public function testAddOnlyOnce() { var dispatcher = new Dispatcher(); var calls = 0; function listener(e) { calls++; } dispatcher.add(listener); dispatcher.add(listener); dispatcher.dispatch(); assertEqual(1, calls, "A listener should not be added to a dispatcher twice."); } /** Tests dispatcher.removeAll(). */ @test public function testRemoveAll() { function listener1(e) { throw "Listener remains after removeAll()."; } function listener2(e) { throw "Listener remains after removeAll()."; } var dispatcher = new Dispatcher(); dispatcher.add(listener1); dispatcher.add(listener2); dispatcher.removeAll(); dispatcher.dispatch(); } /** Tests dispathcer.has(). */ @test public function testHas() { function listener(e) { } var dispatcher = new Dispatcher(); assertFalse( dispatcher.has(listener) ); dispatcher.add( listener ); assertTrue( dispatcher.has(listener) ); } } ================================================ FILE: huey/test/com/huey/macros/MacroTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.macros; import com.huey.tests.TestSuite; import haxe.macro.Expr; class MacroTests extends TestSuite { private var _builder : ClassBuilder; override public function setUp() { _builder = new ClassBuilder(); var pos : Position = { min: 0, max: 1, file: "Test.hx" }; var field = new FieldInfo("field1"); field.addMeta("meta1"); _builder.addField( field ); } @test private function testMetaHelpers() : Void { assertNotNull( _builder.getField("foo") ); var fields = _builder.getFieldsWithMeta("meta1"); assertEqual(1, fields.length); assertEqual(fields[0].name, "foo"); } @test private function testForward() : Void { var obj = new BuildTest(); assertEqual(obj.x, 1, "Property forwarding getter failed."); obj.x = 2; assertEqual(obj.sub.x, 2, "Property forwarding setter failed."); assertEqual(obj.y, 1, "Property forwarding getter failed."); obj.y = 2; assertEqual(obj.sub.x, 2, "Property forwarding setter failed."); } /*@test private function testInjectMethod() : Void { var test = new BuildTest2(); assertEqual(1, test.x, "Method injection failed."); test.foo(); assertEqual(2, test.x, "Method injection failed."); }*/ } @:build(com.huey.macros.Macros.build()) private class BuildTest { public var sub : Subcomponent; public var sub2 : Subcomponent; @forward(sub) public var x : Int; @forward(sub2.x) public var y : Int; public function new() { sub = new Subcomponent(); sub2 = new Subcomponent(); } } private class Subcomponent { public var x : Int = 1; public function new() { } } ================================================ FILE: huey/test/com/huey/ui/UITests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.ui; import com.huey.tests.TestSuite; import com.huey.ui.Component; import com.huey.ui.UIContainer; import com.huey.ui.UIFactory; class UITests extends TestSuite { private var _factory : UIFactory; override public function setUp() { _factory = new UIFactory(); } /** Tests Component instantiation and interface. */ public function testComponentDefaults(component : Component) { assertNull(component.parent, "Parent should be null on instantiation."); assertTrue(component.visible, "Component should default to visible."); assertEqual(0.0, component.x, "Position should default to (0, 0)."); assertEqual(0.0, component.y, "Position should default to (0, 0)."); assertEqual(0.0, component.depth, "Depth should default to 0."); } /** Tests UIContainer instantiation and add/remove children. */ @test public function testUIContainer() { var parent : UIContainer = _factory.createContainer(); testComponentDefaults(parent); var child : Component = _factory.createContainer(); testComponentDefaults(child); assertEqual(0, parent.numChildren, "Parent should start with no children."); parent.add(child); assertEqual(1, parent.numChildren, "numChildren did not update after add."); assertEqual(parent, child.parent, "Child's parent was not updated after add."); var removed = parent.remove(child); assertTrue(removed, "Child was not successfully removed."); assertEqual(0, parent.numChildren, "numChildren did not update after remove."); } /** Tests Label control instantiation and properties. */ @test public function testLabel() { var label = _factory.createLabel(); assertEqual("", label.text, "Label text should default to ''."); } /** Tests Image control instantiation and properties. */ @test public function testImage() { var button = _factory.createImage(); } } ================================================ FILE: huey/test/com/huey/utils/AssertTests.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; import com.huey.tests.TestSuite; class AssertTests extends TestSuite { #if debug @test public function testAssertNull() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertNull(null) catch (_ : Dynamic) threw = true; if (threw) throw "assertNull threw for null."; threw = false; try Assert.assertNull(true) catch (_ : Dynamic) threw = true; if (!threw) throw "assertNull didn't throw for non-null."; threw = false; try Assert.assertNull(0) catch (_ : Dynamic) threw = true; if (!threw) throw "assertNull didn't throw for 0."; threw = false; try Assert.assertNull(false, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertNull didn't throw with the supplied message."; } if (!threw) throw "assertNull didn't throw for false."; } @test public function testAssertNotNull() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertNotNull(null, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertNotNull didn't throw with the supplied message."; } if (!threw) throw "assertNotNull didn't throw for null."; threw = false; try Assert.assertNotNull(true) catch (_ : Dynamic) threw = true; if (threw) throw "assertNotNull threw for non-null."; threw = false; try Assert.assertNotNull(0) catch (_ : Dynamic) threw = true; if (threw) throw "assertNotNull threw for 0."; threw = false; try Assert.assertNotNull(false, msg) catch (_ : Dynamic) threw = true; if (threw) throw "assertNotNull threw for false."; } @test public function testAssertTrue() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertTrue(false, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertTrue didn't throw with the supplied message."; } if (!threw) throw "assertTrue didn't throw for false."; threw = false; try Assert.assertTrue(true) catch (_ : Dynamic) threw = true; if (threw) throw "assertTrue threw for true."; } @test public function testAssertFalse() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertFalse(false) catch (_ : Dynamic) threw = true; if (threw) throw "assertFalse threw for true."; threw = false; try Assert.assertFalse(true, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertFalse didn't throw with the supplied message."; } if (!threw) throw "assertFalse didn't throw for false."; } @test public function testAssertEqual() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertEqual(0, 0) catch (_ : Dynamic) threw = true; if (threw) throw "assertEqual threw with equal ints."; threw = false; try Assert.assertEqual(0, 1) catch (_ : Dynamic) threw = true; if (!threw) throw "assertEqual didn't throw with non-equal ints."; var a = {x: 1}; threw = false; try Assert.assertEqual(a, a) catch (_ : Dynamic) threw = true; if (threw) throw "assertEqual threw with equal objects."; threw = false; try Assert.assertEqual(a, {x: 1}, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertEqual didn't throw with the supplied message."; } if (!threw) throw "assertEqual didn't throw with different objects."; } @test public function testAssertNotEqual() : Void { var threw : Bool; var msg : String = "msg"; threw = false; try Assert.assertNotEqual(0, 0) catch (_ : Dynamic) threw = true; if (!threw) throw "assertNotEqual didn't throw with equal ints."; threw = false; try Assert.assertNotEqual(0, 1) catch (_ : Dynamic) threw = true; if (threw) throw "assertNotEqual threw with non-equal ints."; var a = {x: 1}; threw = false; try Assert.assertNotEqual(a, a, msg) catch (error : Dynamic) { threw = true; if (Std.string(error).indexOf(msg) == -1) throw "assertNotEqual didn't throw with the supplied message."; } if (!threw) throw "assertNotEqual did not throw with equal objects."; threw = false; try Assert.assertNotEqual(a, {x: 1}, msg) catch (_ : Dynamic) threw = true; if (threw) throw "assertNotEqual threw with different objects."; } #end } ================================================ FILE: huey/test/com/huey/utils/WeakRefTest.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.huey.utils; import com.huey.tests.TestSuite; import com.huey.utils.WeakRef; class WeakRefTest extends TestSuite { @test public function testWeakRef() { var ref = new WeakRef( {foo: 1, bar: 2} ); assertEqual(1, ref.get().foo); } #if flash9 @asyncTest public function testWeakRefGC() { var ref = new WeakRef( {foo: 1, bar: 2} ); flash.system.System.gc(); haxe.Timer.delay( function() { assertNull(ref.get(), "Weak reference was not garbage collected."); pass(); }, 100 ); } #end } ================================================ FILE: mac-installer.json ================================================ { "title": "Swivel", "icon": "bin/Swivel.app/Contents/Resources/Icon.icns", "background": "assets/bgMAC.jpg", "icon-size": 128, "contents": [ { "x": 200, "y": 210, "type": "file", "path": "bin/Swivel.app" }, { "x": 500, "y": 210, "type": "link", "path": "/Applications" } ] } ================================================ FILE: redirecter/redirecter/main.cpp ================================================ #include #include #include #include #include #define BUFSIZE 1920*1080*4*4 HANDLE g_hProcess = NULL; HANDLE g_hChildStd_IN_Rd = NULL; HANDLE g_hChildStd_IN_Wr = NULL; HANDLE g_hChildStd_ERR_Rd = NULL; HANDLE g_hChildStd_ERR_Wr = NULL; DWORD g_dwExitCode = NULL; HANDLE hStderrThread = NULL; typedef struct { HANDLE parentStdErr; HANDLE childStdErr; HANDLE childStdIn; } StderrThreadData; StderrThreadData stderrThreadData; void CreateChildProcess(void); void StartStderrThread(void); DWORD WINAPI StderrThreadMain( LPVOID lpParam ); void WriteToPipe(void); void ReadFromPipe(void); void ErrorExit(PTSTR); int _tmain(int argc, TCHAR *argv[]) { SECURITY_ATTRIBUTES saAttr; // Set the bInheritHandle flag so pipe handles are inherited. saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; // Create a pipe for the child process's STDOUT. if ( ! CreatePipe(&g_hChildStd_ERR_Rd, &g_hChildStd_ERR_Wr, &saAttr, 0) ) ErrorExit(TEXT("StdoutRd CreatePipe")); // Ensure the read handle to the pipe for STDOUT is not inherited. if ( ! SetHandleInformation(g_hChildStd_ERR_Rd, HANDLE_FLAG_INHERIT, 0) ) ErrorExit(TEXT("Stdout SetHandleInformation")); // Create a pipe for the child process's STDIN. if (! CreatePipe(&g_hChildStd_IN_Rd, &g_hChildStd_IN_Wr, &saAttr, 0)) ErrorExit(TEXT("Stdin CreatePipe")); // Ensure the write handle to the pipe for STDIN is not inherited. if ( ! SetHandleInformation(g_hChildStd_IN_Wr, HANDLE_FLAG_INHERIT, 0) ) ErrorExit(TEXT("Stdin SetHandleInformation")); // Create the child process. CreateChildProcess(); // Get a handle to an input file for the parent. // This example assumes a plain text file and uses string output to verify data flow. // Write to the pipe that is the standard input for a child process. // Data is written to the pipe's buffers, so it is not necessary to wait // until the child process is running before writing data. //WriteToPipe(); StartStderrThread(); // Read from pipe that is the standard output for child process. ReadFromPipe(); CloseHandle(hStderrThread); // The remaining open handles are cleaned up when this process terminates. // To avoid resource leaks in a larger application, close handles explicitly. return (int)g_dwExitCode; } void StartStderrThread() { stderrThreadData.parentStdErr = GetStdHandle(STD_ERROR_HANDLE); stderrThreadData.childStdErr = g_hChildStd_ERR_Rd; stderrThreadData.childStdIn = g_hChildStd_IN_Wr; hStderrThread = CreateThread(NULL, 0, StderrThreadMain, &stderrThreadData, 0, NULL); } DWORD WINAPI StderrThreadMain( LPVOID lpParam ) { StderrThreadData data = *(StderrThreadData*)lpParam; const int STDERR_BUF_SIZE = 4096; char stderrBuf[4096]; DWORD dwRead, dwWritten; BOOL bSuccess; for(;;) { // read output from stderr bSuccess = ReadFile( data.childStdErr, stderrBuf, STDERR_BUF_SIZE, &dwRead, NULL); if( ! bSuccess || dwRead == 0 ) break; //printf("stderr: %i", dwRead); // fflush(stdout); bSuccess = WriteFile(data.parentStdErr, stderrBuf, dwRead, &dwWritten, NULL); FlushFileBuffers(data.parentStdErr); if (! bSuccess ) break; } CloseHandle(data.childStdIn); ExitThread(0); } void ArgvQuote ( const std::wstring& Argument, std::wstring& CommandLine, bool Force ) /*++ Routine Description: This routine appends the given argument to a command line such that CommandLineToArgvW will return the argument string unchanged. Arguments in a command line should be separated by spaces; this function does not add these spaces. Arguments: Argument - Supplies the argument to encode. CommandLine - Supplies the command line to which we append the encoded argument string. Force - Supplies an indication of whether we should quote the argument even if it does not contain any characters that would ordinarily require quoting. Return Value: None. Environment: Arbitrary. --*/ { // // Unless we're told otherwise, don't quote unless we actually // need to do so --- hopefully avoid problems if programs won't // parse quotes properly // if (Force == false && Argument.empty () == false && Argument.find_first_of (L" \t\n\v\"") == Argument.npos) { CommandLine.append (Argument); } else { CommandLine.push_back (L'"'); for (auto It = Argument.begin () ; ; ++It) { unsigned NumberBackslashes = 0; while (It != Argument.end () && *It == L'\\') { ++It; ++NumberBackslashes; } if (It == Argument.end ()) { // // Escape all backslashes, but let the terminating // double quotation mark we add below be interpreted // as a metacharacter. // CommandLine.append (NumberBackslashes * 2, L'\\'); break; } else if (*It == L'"') { // // Escape all backslashes and the following // double quotation mark. // CommandLine.append (NumberBackslashes * 2 + 1, L'\\'); CommandLine.push_back (*It); } else { // // Backslashes aren't special here. // CommandLine.append (NumberBackslashes, L'\\'); CommandLine.push_back (*It); } } CommandLine.push_back (L'"'); } CommandLine.push_back (L' '); } void CreateChildProcess() // Create a child process that uses the previously created pipes for STDIN and STDOUT. { //TCHAR zaName[]=TEXT("ffmpeg.exe"); int nArgs; LPWSTR* cmdLineArgs = CommandLineToArgvW(GetCommandLine(), &nArgs); std::wstring cmdLine; ArgvQuote(L"ffmpeg.exe", cmdLine, false); for(int i=1; i 0) { bSuccess = WriteFile(g_hChildStd_IN_Wr, buf, dwRead, &dwWritten, NULL); if ( ! bSuccess ) break; } printf("!"); fflush(stdout); } free(buf); CloseHandle(g_hChildStd_IN_Wr); CloseHandle(g_hChildStd_ERR_Rd); WaitForSingleObject(g_hProcess, INFINITE); GetExitCodeProcess(g_hProcess, &g_dwExitCode); } void ErrorExit(PTSTR lpszFunction) // Format a readable error message, display a message box, // and exit from the application. { LPVOID lpMsgBuf; LPVOID lpDisplayBuf; DWORD dw = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); lpDisplayBuf = (LPVOID)LocalAlloc(LMEM_ZEROINIT, (lstrlen((LPCTSTR)lpMsgBuf)+lstrlen((LPCTSTR)lpszFunction)+40)*sizeof(TCHAR)); StringCchPrintf((LPTSTR)lpDisplayBuf, LocalSize(lpDisplayBuf) / sizeof(TCHAR), TEXT("%s failed with error %d: %s"), lpszFunction, dw, lpMsgBuf); MessageBox(NULL, (LPCTSTR)lpDisplayBuf, TEXT("Error"), MB_OK); LocalFree(lpMsgBuf); LocalFree(lpDisplayBuf); ExitProcess(1); } ================================================ FILE: redirecter/redirecter/redirecter.vcxproj ================================================  Debug Win32 Release Win32 {6F30F38B-35CD-4F18-A8B4-C88E42077C00} Win32Proj redirecter Application true Unicode Application false true Unicode true false Level3 Disabled WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreadedDLL Console true Level3 MaxSpeed true true WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) MultiThreaded Console true true true ================================================ FILE: redirecter/redirecter/redirecter.vcxproj.filters ================================================  {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms Source Files ================================================ FILE: redirecter/redirecter.sln ================================================  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C++ Express 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "redirecter", "redirecter\redirecter.vcxproj", "{6F30F38B-35CD-4F18-A8B4-C88E42077C00}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6F30F38B-35CD-4F18-A8B4-C88E42077C00}.Debug|Win32.ActiveCfg = Debug|Win32 {6F30F38B-35CD-4F18-A8B4-C88E42077C00}.Debug|Win32.Build.0 = Debug|Win32 {6F30F38B-35CD-4F18-A8B4-C88E42077C00}.Release|Win32.ActiveCfg = Release|Win32 {6F30F38B-35CD-4F18-A8B4-C88E42077C00}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal ================================================ FILE: src/com/newgrounds/swivel/PreviewGenerator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel; import com.huey.events.Dispatcher; import com.newgrounds.swivel.swf.SWFRecorder; import com.newgrounds.swivel.swf.SwfUtils; import com.newgrounds.swivel.swf.SwivelSwf; import format.abc.Context; using com.newgrounds.swivel.swf.AbcUtils; class PreviewGenerator { public var onPreviewReady(default, null) : Dispatcher; public function new() { onPreviewReady = new Dispatcher(); _recorder = new SWFRecorder(); _recorder.outputWidth = 133; _recorder.outputHeight = 75; _recorder.renderQuality = High; _recorder.scaleMode = letterbox; _recorder.onFrameCaptured.add( frameCapturedHandler ); } public function getPreview(swf : SwivelSwf, frame : Int) { stop(); var previewSwf = swf.clone(); previewSwf.compression = SCUncompressed; swf.prepend(SwfUtils.getAs2Tag("AS2Basics", {width: swf.width, height: swf.height, frameRate: swf.frameRate})); if(swf.version < 5) swf.version = 5; previewSwf.avmVersion = AVM1; // TODO: allow AS3 support switch(previewSwf.avmVersion) { case AVM1: previewSwf.prepend( TDoActions( SwivelSwf.getAvm1Bytes( [ APush( [PString("__swivelInit")] ), AEval, ACondJump(5), AGotoFrame(frame+1), AStop, AStopSounds, APush( [PString("__swivelInit"), PInt(1)] ), ASet, ] ) ) ); previewSwf.prepend( TShowFrame ); previewSwf.prepend( TShowFrame ); case AVM2: var context = new Context(); var cl = context.beginClass("__SwivelPreview"); cl.isSealed = false; cl.superclass = context.type("flash.display.MovieClip"); var f = context.beginConstructor([]); f.maxStack = f.maxScope = 4; context.ops([ OThis, OConstructSuper(0), OThis, OInt(frame), OCallPropVoid( context.type("gotoAndPlay"), 1), ORetVoid, ]); context.finalize(); var o = new haxe.io.BytesOutput(); new format.abc.Writer(o).write(context.getData()); previewSwf.prepend(TActionScript3(o.getBytes(), null)); previewSwf.prepend(TSymbolClass([{className: "__SwivelPreview", cid: 0}] )); } flash.media.SoundMixer.soundTransform = new flash.media.SoundTransform(0); _recorder.startPlayback(previewSwf); _recorder.startRecording(); } public function stop() { _recorder.stop(); } private var _recorder : SWFRecorder; private function frameCapturedHandler(frame : flash.display.BitmapData) { onPreviewReady.dispatch(frame); flash.media.SoundMixer.soundTransform = new flash.media.SoundTransform(1.0); stop(); } } ================================================ FILE: src/com/newgrounds/swivel/SplashScreen.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel; import com.huey.ui.Component; import flash.display.MovieClip; import flash.events.MouseEvent; import flash.Lib; import flash.net.URLRequest; class SplashScreen extends Component { public function new() { _anim = new SplashAnim(); _anim.addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler); _anim.addEventListener(flash.events.Event.ADDED_TO_STAGE, addedToStageHandler, true); super(_anim); } private var _anim : MovieClip; private function enterFrameHandler(e) { if (_anim.currentFrame == _anim.totalFrames) { _anim.stop(); _anim.removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler); if (parent != null) parent.remove(this); } } private function addedToStageHandler(e) { var url = switch(e.target.name) { case "swivelButton": "http://www.newgrounds.com/swivel"; case "ngButton": "http://www.newgrounds.com"; case "haxeButton": "http://www.haxe.org"; case "ffmpegButton": "http://www.ffmpeg.org"; default: null; } if (url != null) { e.target.addEventListener(MouseEvent.CLICK, function(e) Lib.getURL(new URLRequest(url)) ); } } } ================================================ FILE: src/com/newgrounds/swivel/Swivel.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel; import com.newgrounds.swivel.ffmpeg.AudioCodec; import com.newgrounds.swivel.ffmpeg.VideoPreset; import com.newgrounds.swivel.swf.Watermark; import com.newgrounds.swivel.SwivelController.SwivelTask; import com.newgrounds.swivel.SwivelController.SwivelProgressEvent; import com.newgrounds.swivel.SwivelJob.RecordingDuration; import com.huey.assets.Asset; import com.huey.assets.AssetSource; import com.huey.core.Application; import com.huey.binding.Binding; import com.huey.binding.BindableArray; import com.huey.utils.Thread; import com.huey.ui.Component.HitArea; import com.huey.ui.*; import com.newgrounds.swivel.SwivelController.AudioSource; import com.newgrounds.swivel.swf.SwivelSwf; import com.newgrounds.swivel.swf.RenderQuality; import com.newgrounds.swivel.swf.SWFRecorder.ScaleMode; import com.newgrounds.swivel.swf.Watermark.WatermarkAlign; import flash.desktop.NativeApplication; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.Event; import flash.events.InvokeEvent; import flash.events.MouseEvent; import flash.filesystem.File; import flash.Lib; import flash.net.FileFilter; import flash.system.Capabilities; import flash.system.System; import flash.text.TextField; import format.swf.Reader; import format.swf.Data; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.Input; @:xml("SwivelHuey.xml") @:version("1.11") class Swivel extends Application { @bindable private var _controller : SwivelController; private var _browseFile : File; private var _fileListBox : ListBox; private var _settingsContainer : StateContainer; private var _previewImage : ScaledImage; public var busySpinner : Component; public var sourceButton : Button; public var videoButton : Button; public var audioButton : Button; public var overlayButton : Button; public var outputFileBox : TextBox; public var removeButton : Button; public var convertButton : Button; public var cancelButton : Button; public var qualitySlider : Slider; public var widthStepper : NumericStepper; public var heightStepper : NumericStepper; private var _aspectRatio : Null = 16.0 / 9.0; public var lockAspectCheckBox : CheckBox; public var frameStepperImage : Image; public var startFrameStepper : NumericStepper; public var endFrameStepper : NumericStepper; private var _previewGenerator : PreviewGenerator; public var setupGroup : RadioGroup; @bindable public var durationGroup : RadioGroup; public var scaleModeGroup : RadioGroup; public var cropButton : RadioButton; public var letterboxButton : RadioButton; public var exactFitButton : RadioButton; public var transparentBgCheckBox : CheckBox; public var codecSelectBox : SelectBox; public var videoBitrateSlider : Slider; @bindable public var audioGroup : RadioGroup; public var frameRangeButton : RadioButton; public var manualButton : RadioButton; public var noAudioButton : RadioButton; public var swfAudioButton : RadioButton; public var externalAudioButton : RadioButton; public var externalAudioFileBox : TextBox; public var externalAudioContainer : Component; public var externalAudioFile : File; public var audioChannelGroup : RadioGroup; public var monoRadioButton : RadioButton; public var audioCodecSelectBox : SelectBox; public var audioBitrateSlider : Slider; private var _watermark : Watermark; private var _watermarkFile : File; public var watermarkEnabledCheckBox : CheckBox; public var watermarkFileBox : TextBox; public var watermarkAlphaSlider : Slider; public var watermarkSizeSlider : Slider; public var watermarkSettingsContainer : Component; @bindable private var bitmapSmoothingCheckBox : CheckBox; private var progressText : Label; private var timeText : Label; private var videoNameText : Label; private var videoNameButton : Button; private var fileSizeText : Label; private var aboutBox : Container; public var versionText : Label; public var creditsText : Label; private var swfSetupContainer : Container; private var frameContainer : Container; private var mainContainer : StateContainer; public var progressBar : Slider; public var alignmentGroup : RadioGroup; public var watermarkPreview : Component; public var recordingButton : CheckBox; public var errorText : Label; private var cmdLineArguments : Array; public function new() : Void { super(); _controller = new SwivelController(); _watermarkFile = new File(); _watermark = {image : null, alpha: 1.0, scale: 1.0, align: bottomLeft}; NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, function(e : InvokeEvent) { if(!_isCmdLine && e.arguments != null && e.arguments.length > 0) { _isCmdLine = true; cmdLineArguments = e.arguments; _cmdLineDirectory = e.currentDirectory; } }); /*_isCmdLine = true; cmdLineArguments = (["dealer-warranty.swf","-s","640x480","-o","cmd.mp4","-ab","64k","-vb","1.5M"]); _cmdLineDirectory = new File("d:\\Swiveltest");*/ } private var _isCmdLine : Bool; private var _cmdLineFile : File; private var _cmdLineParams : Dynamic; private var _cmdLineDirectory : File; private function handleCommandLineArguments(args : Array) { if(args.length == 0) return; while(args.length > 0) parseNextArgument(args); if(_cmdLineFile == null) throw("No input file specified"); if(!_cmdLineFile.exists) throw('${_cmdLineFile.nativePath} does not exist'); if(_controller.outputFile == null) { _controller.outputFile = _cmdLineFile.parent.resolvePath( _cmdLineFile.name.split(".")[0] + ".mp4" ); } _cmdLineFile.addEventListener(Event.COMPLETE, function(_) { var job = new SwivelJob(_cmdLineFile, new SwivelSwf(Bytes.ofData(_cmdLineFile.data)) ); job.parameters = _cmdLineParams; _controller.jobs.push( job ); convertClickHandler(null); } ); _cmdLineFile.load(); } private function parseNextArgument(args : Array) { var arg = StringTools.trim(args.shift()); if(arg.charAt(0) == "-") { var sw = arg.substr(1); switch(sw) { case "s": var parts = args.shift().split("x"); _controller.outputWidth = Std.parseInt(parts[0]); _controller.outputHeight = Std.parseInt(parts[1]); case "vb": var arg = StringTools.trim(args.shift()); var bitRate : Null = switch( arg.charAt(arg.length-1).toLowerCase() ) { case "k": 1024 * Std.parseFloat( arg.substr(0,arg.length-1) ); case "m": 1024 * 1024 * Std.parseFloat( arg.substr(0,arg.length-1) ); default: Std.parseFloat( arg.substr(0,arg.length-1) ); } if(bitRate != null && bitRate > 0) _controller.videoBitRate = Std.int(bitRate); case "ab": var arg = StringTools.trim(args.shift()); var bitRate : Null = switch( arg.charAt(arg.length-1).toLowerCase() ) { case "k": 1024 * Std.parseFloat( arg.substr(0,arg.length-1) ); case "m": 1024 * 1024 * Std.parseFloat( arg.substr(0,arg.length-1) ); default: Std.parseFloat( arg ); } if(bitRate != null && bitRate > 0) _controller.audioBitRate = Std.int(bitRate); case "sm": switch(args.shift()) { case "letterbox": _controller.scaleMode = letterbox; case "crop": _controller.scaleMode = crop; case "stretch": _controller.scaleMode = stretchToFit; default: throw("Invalid scale mode"); } case "a": var arg = StringTools.trim(args.shift()); switch(arg) { case "none": _controller.audioSource = none; case "swf": _controller.audioSource = swf; default: var audioFile = _cmdLineDirectory.resolvePath(arg); if(!audioFile.exists) throw("Audio file ${audioFile.nativePath} does not exist"); _controller.audioSource = external( audioFile ); } case "t": _controller.transparentBackground = true; case "o": _controller.outputFile = _cmdLineDirectory.resolvePath( StringTools.trim(args.shift()) ); default: throw('Invalid switch $sw'); } } else { if(_cmdLineFile != null) { throw("Only one input file may be specified"); } var fileParts = arg.split("?"); if(fileParts.length > 1) { _cmdLineParams = {}; for(param in StringTools.urlDecode(fileParts[1]).split("&")) { var paramParts = param.split("="); Reflect.setField(_cmdLineParams, paramParts[0], paramParts[1]); } } _cmdLineFile = _cmdLineDirectory.resolvePath(fileParts[0]); } } private override function init() : Void { #if !debug if(!_isCmdLine) ui.add(new SplashScreen()); #end _previewGenerator = new PreviewGenerator(); _previewGenerator.onPreviewReady.add(previewReadyHandler); // SOURCE Binding.bind( removeButton.enabled, _controller.jobs.length > 0 ); Binding.bind( convertButton.enabled, _controller.jobs.length > 0 && _controller.outputFile != null); Binding.bind( swfSetupContainer.enabled, _fileListBox.selectedItem != null ); Binding.bind( _fileListBox.items, _controller.jobs.array ); Binding.bind( qualitySlider.value, _fileListBox.selectedItem.renderQuality.getIndex()); untyped qualitySlider._implComponent.addEventListener(MouseEvent.MOUSE_DOWN, qualitySecretHandler ); Binding.bind( _fileListBox.selectedItem.renderQuality, Type.createEnumIndex(RenderQuality, Std.int(qualitySlider.value)) ); Binding.bind( outputFileBox.text, _controller.outputFile.nativePath ); outputFileBox.onUserEdited.add(outputFileEditHandler); Binding.bind( frameContainer.enabled, !swfSetupContainer.enabled || durationGroup.selectedItem == frameRangeButton ); Binding.bindTwoWay( bitmapSmoothingCheckBox.selected, _fileListBox.selectedItem.forceBitmapSmoothing ); _fileListBox.onChange.add(fileChangedHandler); Binding.bind( startFrameStepper.maximum, _fileListBox.selectedItem.swf.numFrames ); Binding.bind( endFrameStepper.maximum, _fileListBox.selectedItem.swf.numFrames ); startFrameStepper.onUserChange.add(showPreview); endFrameStepper.onUserChange.add(showPreview); startFrameStepper.onChange.add(function(_) changeDuration(false)); endFrameStepper.onChange.add(function(_) changeDuration(true)); durationGroup.onChange.add(function(_) changeDuration(false)); codecSelectBox.items = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.PRESETS; codecSelectBox.selectedIndex = 0; codecSelectBox.onChange.add(codecChangeHandler); // VIDEO Binding.bind( widthStepper.value, _controller.outputWidth ); Binding.bind( heightStepper.value, _controller.outputHeight ); Binding.bind( widthStepper.step, if(lockAspectCheckBox.selected) Std.int(Math.max(Math.round(widthStepper.value/heightStepper.value)*2,2)) else 2 ); Binding.bind( heightStepper.step, if(lockAspectCheckBox.selected) Std.int(Math.max(Math.round(heightStepper.value/widthStepper.value)*2,2)) else 2 ); widthStepper.onUserChange.add(function(_) updateOutputSize(Std.int(widthStepper.value), null)); heightStepper.onUserChange.add(function(_) updateOutputSize(null, Std.int(heightStepper.value))); lockAspectCheckBox.onClick.add(function(_) { _aspectRatio = if(lockAspectCheckBox.selected) widthStepper.value / heightStepper.value else null; updateOutputSize(null, null); }); Binding.bind( _controller.scaleMode, { if(lockAspectCheckBox.selected || scaleModeGroup.selectedItem == cropButton) crop; else if(scaleModeGroup.selectedItem == letterboxButton) letterbox; else stretchToFit; } ); Binding.bindTwoWay( _controller.transparentBackground, transparentBgCheckBox.selected ); transparentBgCheckBox.onClick.add( function(_) { if(transparentBgCheckBox.selected) { codecSelectBox.items = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.TRANSPARENT_PRESETS; codecSelectBox.selectedIndex = 0; } else { codecSelectBox.items = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.PRESETS; codecSelectBox.selectedIndex = 1; } } ); // AUDIO Binding.bind( _controller.audioSource, { if(audioGroup.selectedItem == noAudioButton) none; else if(audioGroup.selectedItem == swfAudioButton) swf; else external(externalAudioFile); } ); Binding.bind( externalAudioContainer.enabled, externalAudioButton.selected ); audioCodecSelectBox.items = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.AUDIO_CODECS; audioCodecSelectBox.selectedIndex = 0; audioCodecSelectBox.onChange.add(audioCodecChangeHandler); Binding.bind( _controller.stereoAudio, {!monoRadioButton.selected;} ); codecChangeHandler(null); // WATERMARK watermarkFileBox.onUserEdited.add(watermarkFileEditHandler); Binding.bind( _controller.watermark, if(watermarkEnabledCheckBox.selected) _watermark else null ); Binding.bind( _watermark.alpha, {drawWatermarkPreview(); watermarkAlphaSlider.value;} ); Binding.bind( _watermark.scale, {drawWatermarkPreview(); watermarkSizeSlider.value;} ); Binding.bind( watermarkSettingsContainer.enabled, watermarkEnabledCheckBox.selected ); Binding.bind( _watermark.align, { drawWatermarkPreview(); if(alignmentGroup.selectedItem.y == 299) { if(alignmentGroup.selectedItem.x == 438) topLeft; else if(alignmentGroup.selectedItem.x == 468) topCenter; else topRight; } else if(alignmentGroup.selectedItem.y == 321) { if(alignmentGroup.selectedItem.x == 438) middleLeft; else if(alignmentGroup.selectedItem.x == 468) center; else middleRight; } else { if(alignmentGroup.selectedItem.x == 438) bottomLeft; else if(alignmentGroup.selectedItem.x == 468) bottomCenter; else bottomRight; } } ); versionText.text = 'v$VERSION - $BUILD_TIME'; if(!flash.system.Capabilities.isDebugger) { mainContainer.state = "error"; errorText.text = 'Please restart your computer before using Swivel for the first time.\n\nIf this error persists, please e-mail mike@newgrounds.com.'; } else if(_isCmdLine) handleCommandLineArguments(cmdLineArguments); } private function dragWindowHandler(e) NativeApplication.nativeApplication.activeWindow.startMove(); private function closeClickHandler(e) if(aboutBox.visible) aboutCloseHandler(null) else exit(); private function minClickHandler(e) minimize(); private function aboutClickHandler(_) { aboutBox.visible = true; untyped creditsText._implComponent.scrollRect = new flash.geom.Rectangle(0, -230, 300, 225); flash.Lib.current.stage.frameRate = 25; flash.Lib.current.addEventListener(flash.events.Event.ENTER_FRAME, aboutFrameHandler); } private function aboutFrameHandler(_) { untyped creditsText._implComponent.scrollRect = new flash.geom.Rectangle(0, creditsText._implComponent.scrollRect.y+1, 300, 225); } private function helpClickHandler(_) flash.Lib.getURL(new flash.net.URLRequest("http://www.newgrounds.com/swivel")); private function ngUpsellClickHandler(_) flash.Lib.getURL(new flash.net.URLRequest("http://www.newgrounds.com/projects/movies/submit")); private function addClickHandler(e) : Void { // TODO: create File class _browseFile = new File(); _browseFile.addEventListener(flash.events.Event.SELECT, fileSelectHandler); _browseFile.browseForOpen("Import SWF", [new FileFilter("SWF Files (*.swf)", "*.swf")]); } private function removeClickHandler(e) : Void { _controller.jobs.splice(_fileListBox.selectedIndex, 1); } private function spinBusyIcon() untyped busySpinner._implComponent.rotation -= 40; private function fileSelectHandler(e) { busySpinner.visible = true; flash.Lib.current.mouseChildren = flash.Lib.current.tabEnabled = false; var spinTimer = new haxe.Timer(33); spinTimer.run = spinBusyIcon; _browseFile.addEventListener(flash.events.Event.COMPLETE, function(e) { try { var swf = new SwivelSwf(Bytes.ofData(_browseFile.data)); var job = new SwivelJob( _browseFile, swf ); _controller.jobs.push(job); if(_controller.jobs.length == 1) { _controller.outputFile = _browseFile.parent.resolvePath( _browseFile.name.split(".")[0] + ".mp4" ); _fileListBox.selectedIndex = 0; var swfAspectRatio = swf.width / swf.height; if(_aspectRatio != null) _aspectRatio = swfAspectRatio; var w : Float = 1920.0; var h : Float = 1080.0; if(swfAspectRatio > w/h) h = swf.height * (w/swf.width); else w = swf.width * (h/swf.height); updateOutputSize(Std.int(w), Std.int(h)); } } catch(error : Dynamic) {} busySpinner.visible = false; flash.Lib.current.mouseChildren = flash.Lib.current.tabEnabled = true; spinTimer.stop(); spinTimer = null; }); _browseFile.load(); } private function fileChangedHandler(_) { var job : SwivelJob = _fileListBox.selectedItem; if(job != null) { switch(job.duration) { case frameRange(s,e): startFrameStepper.value = s; endFrameStepper.value = e; manualButton.selected = false; frameRangeButton.selected = true; durationGroup.selectedItem = frameRangeButton; case manual: startFrameStepper.value = 1; endFrameStepper.value = _fileListBox.selectedItem.swf.numFrames; manualButton.selected = true; frameRangeButton.selected = false; durationGroup.selectedItem = manualButton; } } showPreview(); } private function changeDuration(isEndFrame : Bool) : Void { if(startFrameStepper.value > endFrameStepper.value) if(isEndFrame) startFrameStepper.value = endFrameStepper.value; else endFrameStepper.value = startFrameStepper.value; _fileListBox.selectedItem.duration = if(durationGroup.selectedItem == frameRangeButton) frameRange(Std.int(startFrameStepper.value), Std.int(endFrameStepper.value)); else manual; } private function showPreview(?e : UIEvent) { if(_fileListBox.selectedItem != null) { var swf : SwivelSwf = _fileListBox.selectedItem.swf; if(swf != null) { var frame = if(e != null) untyped(e.source).value else Std.int(startFrameStepper.value); _previewGenerator.getPreview(swf, frame); } } } private function previewReadyHandler(frame) { frameStepperImage.visible = true; untyped frameStepperImage._implComponent.smoothing = true; untyped frameStepperImage._implComponent.bitmapData = frame; untyped frameStepperImage._implImage = frame; } private function convertClickHandler(e) : Void { mainContainer.state = "converting"; if(e != null) { var videoCodec : VideoPreset = codecSelectBox.selectedItem; if(videoCodec.supportsBitRate && videoBitrateSlider.value != videoBitrateSlider.maximum) { _controller.videoBitRate = Std.int(videoBitrateSlider.value); } else { _controller.videoBitRate = null; } var audioCodec : AudioCodec = audioCodecSelectBox.selectedItem; _controller.audioBitRate = if(audioCodec.supportsBitRate) Std.int(audioBitrateSlider.value) else null; } _recording = false; recordingButton.selected = false; recordingButton.visible = false; _controller.onProgress.add(convertProgressHandler); _controller.onComplete.add(convertCompleteHandler); _controller.start(); cancelButton.visible = false; haxe.Timer.delay( function() cancelButton.visible = true, 2000); } // VIDEO tab private function outputBrowseClickHandler(e) : Void { var outputFile = new File(); outputFile.addEventListener(flash.events.Event.SELECT, function(_) _controller.outputFile = outputFile ); outputFile.browseForSave("Set Output Video File"); } private function outputFileEditHandler(_) { try _controller.outputFile = new File(outputFileBox.text) catch(error:Dynamic) _controller.outputFile = null; } private function updateOutputSize(w : Null, h : Null) : Void { var _w : Float = if(w != null) w else _controller.outputWidth; var _h : Float = if(h != null) h else _controller.outputHeight; if(_aspectRatio != null) { if(w == null) _w = _h * _aspectRatio; else if(h == null) _h = _w / _aspectRatio; } var forceEven = true; if(forceEven) { _w = Std.int(_w/2)*2; _h = Std.int(_h/2)*2; } if(_w < 2) _w = 2; if(_h < 2) _h = 2; _controller.outputWidth = Std.int(_w); _controller.outputHeight = Std.int(_h); } private function codecChangeHandler(_) { var preset : VideoPreset = codecSelectBox.selectedItem; if(_controller.outputFile != null) { var nameParts = _controller.outputFile.name.split("."); nameParts.pop(); nameParts.push( preset.fileFormat ); _controller.outputFile = _controller.outputFile.parent.resolvePath( nameParts.join(".") ); } _controller.videoPreset = preset; if(preset.supportsBitRate) { videoBitrateSlider.enabled = true; } else { videoBitrateSlider.enabled = false; videoBitrateSlider.value = videoBitrateSlider.maximum; } audioCodecSelectBox.items = if(preset.supportedAudioCodecs != null) preset.supportedAudioCodecs else com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.AUDIO_CODECS; audioCodecSelectBox.selectedIndex = 0; } private function videoBitrateLabelFunc(v : Float) { if(codecSelectBox != null && codecSelectBox.selectedItem != null && v == videoBitrateSlider.maximum) return "Lossless"; if(v < 1024*1024) return Math.round(v/1024*10)/10 + " kbps"; else return Math.round(v/1024/1024*10)/10 + " Mbps"; } private function audioBitrateLabelFunc(v : Float) { if(v < 1024*1024) return Math.round(v/1024*10)/10 + " kbps"; else return Math.round(v/1024/1024*10)/10 + " Mbps"; } // === AUDIO === private function audioBrowseClickHandler(e) : Void { externalAudioFile = new File(); externalAudioFile.addEventListener(flash.events.Event.SELECT, function(_) { _controller.audioSource = external(externalAudioFile); externalAudioFileBox.text = externalAudioFile.nativePath; } ); externalAudioFile.browseForOpen("Set Audio Track", [new FileFilter("Audio Files (*.mp3, *.wav, *.ogg, *.aac)", "*.mp3;*.wav;*.ogg;*.aac")]); } private var _bitmap : flash.display.Bitmap; private var _recording : Bool; private function convertProgressHandler(progress : SwivelProgressEvent) { // TODO progressBar.value = progress.progress; var text; text = switch(progress.task) { case StartEncoder(_, _): "Starting video encoder..."; case ParseSwf(job): 'Parsing SWF... (${job.file.name})'; case MutateSwf(job): 'Tweaking SWF... (${job.file.name})'; case EncodeSwf(job): recordingButton.visible = Type.enumEq(progress.job.duration,manual); 'Encoding SWF to video... (${job.file.name})'; case DecodeAudio: 'Decoding audio clips...'; case MixAudio: 'Mixing audio track...'; case StopEncoder: 'Finishing video encode...'; case EncodeAudio: 'Encoding audio track...'; case DeleteTempFiles: 'Cleaning up temporary files...'; } progressText.text = text; if(progress.frame != null) { untyped { _previewImage._image._implComponent.bitmapData = progress.frame; _previewImage._image._implImage = progress.frame; //_previewImage._implComponent.width = 702; //_previewImage._implComponent.height = 395; if(_previewImage.visible == false) { _previewImage.visible = true; _previewImage.updateSize(); } } } else _previewImage.visible = false; } private function audioCodecChangeHandler(_) { var codec : AudioCodec = audioCodecSelectBox.selectedItem; _controller.audioCodec = codec; if(codec.supportsBitRate) { audioBitrateSlider.enabled = true; } else { audioBitrateSlider.enabled = false; audioBitrateSlider.value = audioBitrateSlider.maximum; } } private function toggleRecordingHandler(_) { if(!_recording) { _controller.startRecording(); _recording = true; } else { _controller.stopRecording(); _recording = false; recordingButton.visible = false; } } // === OVERLAY TAB === private function alphaSliderFunc(v : Float) return Std.string(Std.int(v * 100)) + "%"; private function overlayBrowseClickHandler(e) : Void { _watermarkFile = new File(); _watermarkFile.addEventListener(flash.events.Event.SELECT, watermarkSelectHandler ); _watermarkFile.browseForOpen("Choose Watermark", [new FileFilter("Image Files (*.png, *.jpg, *.jpeg, *.gif)", "*.png;*.jpg;*.jpeg;*.gif")]); } private function watermarkFileEditHandler(_) { _watermark.image = null; try { _watermarkFile = new File(watermarkFileBox.text); watermarkSelectHandler(null); } catch(error:Dynamic) _watermarkFile = null; } private function watermarkSelectHandler(_) { _watermark.image = null; drawWatermarkPreview(); watermarkFileBox.text = _watermarkFile.nativePath; var asset = new com.huey.assets.Asset("watermark", External(_watermarkFile.nativePath)); asset.onLoaded.add(function(_) { _watermark.image = asset.data; asset.onLoaded.removeAll(); drawWatermarkPreview(); asset = null; } ); asset.load(); } private function drawWatermarkPreview() { if(_settingsContainer.state != "overlay") return; var g : flash.display.Graphics = untyped watermarkPreview._implComponent.graphics; g.clear(); var w : Float = 108.0; var h : Float = 61.0; var scale : Float; var aspect = _controller.outputWidth / _controller.outputHeight; if(aspect > w/h){ scale = w/_controller.outputWidth; h = w / aspect; } else { scale = h/_controller.outputHeight; w = h * aspect; } g.lineStyle(); g.beginFill(0x425137, .35); g.drawRect(-2, -2, w+2, h+2); g.endFill(); g.beginFill(0x425137); g.drawRect(0, 0, w, h); g.endFill(); g.lineStyle(1, 0, 0.5); g.moveTo(0, 0); g.lineTo(w, h); g.moveTo(w, 0); g.lineTo(0, h); g.lineStyle(); if(_watermark.image == null) return; var iw : Float = _watermark.image.width * _watermark.scale * scale; var ih : Float = _watermark.image.height * _watermark.scale * scale; var m = 2.0 * scale; g.beginFill(0xe98a4b, _watermark.alpha); switch(_watermark.align) { case topLeft: g.drawRect(m, m, iw, ih); case topCenter: g.drawRect((w-iw)/2, m, iw, ih); case topRight: g.drawRect(w-iw-m, m, iw, ih); case middleLeft: g.drawRect(m, (h-ih)/2, iw, ih); case center: g.drawRect((w-iw)/2, (h-ih)/2, iw, ih); case middleRight: g.drawRect(w-iw-m, (h-ih)/2, iw, ih); case bottomLeft: g.drawRect(m, h-ih-m, iw, ih); case bottomCenter: g.drawRect((w-iw)/2, h-ih-m, iw, ih); case bottomRight: g.drawRect(w-iw-m, h-ih-m, iw, ih); } g.endFill(); untyped watermarkPreview._implComponent.scrollRect = new flash.geom.Rectangle(0, 0, w, h); } // === ABOUT BOX === private function aboutCloseHandler(_) { aboutBox.visible = false; flash.Lib.current.removeEventListener(flash.events.Event.ENTER_FRAME, aboutFrameHandler); flash.Lib.current.stage.frameRate = 30; } private function contactClickHandler(_) flash.Lib.getURL(new flash.net.URLRequest("mailto:mike@newgrounds.com")); private function licenseClickHandler(_) File.applicationDirectory.resolvePath("license.txt").openWithDefaultApplication(); // === ENCODING === private function convertCompleteHandler(e) : Void { _controller.onProgress.removeAll(); // TODO: add once _controller.onComplete.removeAll(); if(!_isCmdLine) { mainContainer.state = "complete"; var time : Int = Std.int(e.time); var secs = Std.string(time % 60); time = Std.int(time/60); var mins = Std.string(time % 60); time = Std.int(time/60); var hours = Std.string(time); if(hours.length < 2) hours = "0" + hours; if(mins.length < 2) mins = "0" + mins; if(secs.length < 2) secs = "0" + secs; timeText.text = hours + ":" + mins + ":" + secs; fileSizeText.text = (Std.int(e.fileSize / (1024*1024) * 10)/ 10) + " MB"; videoNameText.text = e.outputFile.name; new CompleteSound().play(); orderToFront(); } else { NativeApplication.nativeApplication.exit(0); } } private function navClickHandler(e) : Void { if(e.source==sourceButton) _settingsContainer.state = "source"; else if(e.source==videoButton) _settingsContainer.state = "video"; else if(e.source==audioButton) _settingsContainer.state = "audio"; else if(e.source==overlayButton) { _settingsContainer.state = "overlay"; drawWatermarkPreview(); } } private function qualitySecretHandler(e) { if(e.controlKey) qualitySlider.maximum = 4; untyped qualitySlider.mouseMoveHandler(null); } private function qualitySliderFunc(v : Float) return ["Low", "Medium", "High", "Higher", "Highest"][Std.int(v)]; private function cancelClickHandler(e) : Void { if(Type.enumConstructor(_controller.currentTask) == "EncodeSwf") { _controller.stopRecording(); _recording = false; recordingButton.visible = false; } else { _controller.stop(); mainContainer.state = "setup"; convertButton.visible = false; haxe.Timer.delay( function() convertButton.visible = true, 2000); if(_isCmdLine) NativeApplication.nativeApplication.exit(-1); } } // === ENCODING COMPLETE === private function videoNameClickHandler(_) _controller.outputFile.openWithDefaultApplication(); private function backClickHandler(_) mainContainer.state = "setup"; override private function uncaughtErrorHandler(e) { e.preventDefault(); if(!_isCmdLine ) { mainContainer.state = "error"; errorText.text = 'Whoa! Something bad happened, and the program blew up. Sorry about that!\nPlease copy and paste this junk and send it to mike@newgrounds.com along with the SWF you were converting:\n\n${Std.string(e.error)}\n${haxe.CallStack.exceptionStack().join("\n")}'; } else { NativeApplication.nativeApplication.exit(-1); } } } ================================================ FILE: src/com/newgrounds/swivel/SwivelController.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel; import com.huey.binding.BindableArray; import com.huey.events.Dispatcher; import com.huey.utils.Logger; import com.newgrounds.swivel.audio.AudioTracker; import com.newgrounds.swivel.ffmpeg.FfmpegProcess; import com.newgrounds.swivel.ffmpeg.VideoPreset; import com.newgrounds.swivel.ffmpeg.AudioCodec; import com.newgrounds.swivel.swf.*; import com.newgrounds.swivel.swf.SWFRecorder.ScaleMode; import flash.display.BitmapData; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import format.swf.Reader; import haxe.io.Bytes; import haxe.io.BytesInput; import com.newgrounds.swivel.swf.SwivelConnection.ISwivelConnection; @:autoBuild(com.huey.macros.Macros.build()) interface ControllerBase { } class SwivelController extends com.huey.binding.Binding.Bindable implements ControllerBase { public var onProgress(default, null) : Dispatcher; public var onStateChange(default, null) : Dispatcher; public var onComplete(default, null) : Dispatcher; @bindable public var jobs : BindableArray; // TODO private var _recorder : SWFRecorder; @bindable @forward(_recorder) public var outputWidth : Int; @bindable @forward(_recorder) public var outputHeight : Int; @bindable @forward(_recorder) public var scaleMode : ScaleMode; @bindable @forward(_recorder) public var transparentBackground : Bool; public var stereoAudio : Bool = true; public var audioSource : AudioSource; @forward(_recorder) public var watermark : Null; private var _videoFile : File; private var _audioFile : File; private var _audioOutput : FileStream; @bindable public var outputFile : File; @bindable public var videoPreset : VideoPreset; public var videoBitRate : Null; @bindable public var audioCodec : AudioCodec; public var audioBitRate : Null; private var _parsedSwf : SwivelSwf; private var _ffmpeg : FfmpegProcess; private var _connection : ISwivelConnection; private var _recordingStartFrame : Int; private var _recordingNumFrames : Int; private var _totalNumFrames : Int; private var _audioTracker : AudioTracker; private var _startTime : Float; private var _taskList : List; public var currentTask(default, null) : SwivelTask; private var _currentJob : SwivelJob; public function new() { super(); jobs = new BindableArray(); onProgress = new Dispatcher(); onStateChange = new Dispatcher(); onComplete = new Dispatcher(); _recorder = new SWFRecorder(); _recorder.onFrameCaptured.add(onFrameCaptured); audioSource = swf; videoPreset = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.PRESETS[0]; audioCodec = com.newgrounds.swivel.ffmpeg.FfmpegProcess.FfmpegEncoder.AUDIO_CODECS[0]; } public function start() : Void { _startTime = haxe.Timer.stamp(); _progress = 0; _totalNumFrames = 0; flash.Lib.current.addEventListener(flash.events.Event.ENTER_FRAME, dispatchProgress); if(outputFile.name.split(".").length < 2) outputFile = outputFile.resolvePath('../${outputFile.name}.mp4'); var usesSwfAudio = switch(audioSource) { case swf: _audioFile = File.applicationStorageDirectory.resolvePath("temp_audio.raw"); if(_audioFile.exists) try _audioFile.deleteFile() catch(e:Dynamic) {} true; case external(source): _audioFile = source; false; default: _audioFile = null; false; } _videoFile = if(usesSwfAudio) { var nameParts = outputFile.name.split("."); var name = if(nameParts.length > 1) "temp_video." + nameParts[nameParts.length-1] else "temp_video.mp4"; File.applicationStorageDirectory.resolvePath(name); } else { outputFile; } _taskList = new List(); _taskList.add( StartEncoder(_videoFile, if(!usesSwfAudio) _audioFile else null) ); for(job in jobs) { _taskList.add( ParseSwf(job) ); _taskList.add( MutateSwf(job) ); if(usesSwfAudio) { _taskList.add( EncodeSwf(job) ); _taskList.add( DecodeAudio ); _taskList.add( MixAudio ); } else { _taskList.add( EncodeSwf(job) ); } } _taskList.add( StopEncoder ); if(usesSwfAudio) { _taskList.add( EncodeAudio ); } _taskList.add( DeleteTempFiles ); runNextTask(); } private function runNextTask() { currentTask = _taskList.pop(); if(currentTask == null) { finish(); return; } flash.ui.Mouse.show(); _frame = null; _waitCount = 0; flash.Lib.current.addEventListener(flash.events.Event.ENTER_FRAME, runTaskDelay); } private function runTaskDelay(_) { _waitCount++; if(_waitCount >= 2) { flash.Lib.current.removeEventListener(flash.events.Event.ENTER_FRAME, runTaskDelay); runTask(currentTask); } } private function runTask(task : SwivelTask) { _currentJob = null; switch(task) { case StartEncoder(outputFile, inputAudioFile): var ffmpeg = new FfmpegEncoder(videoPreset, videoBitRate, outputFile, _recorder.outputWidth, _recorder.outputHeight, jobs.array[0].swf.frameRate, if(inputAudioFile != null) inputAudioFile.nativePath else null, audioCodec, audioBitRate, if(stereoAudio) 2 else 1); ffmpeg.onComplete.add(onEncodingComplete); _ffmpeg = ffmpeg; runNextTask(); case ParseSwf(job): _currentJob = job; job.swf.parseSwf(); _parsedSwf = job.swf; runNextTask(); case MutateSwf(job): _currentJob = job; _swfMutators = new List(); var startFrame = switch( job.duration ) { case frameRange(start,_): start - 1; default: 0; } _swfMutators.add( new SwivelMutator(startFrame) ); if(job.forceBitmapSmoothing) _swfMutators.add( new BitmapSmoothingMutator() ); if(job.swf.version >= 8) _swfMutators.add( new ScaleFilterMutator(_recorder.outputWidth / job.swf.width) ); if(Type.enumEq(audioSource, swf)) { // TODO _audioTracker = new AudioTracker(); switch(_parsedSwf.avmVersion) { case AVM1: _swfMutators.add( new SoundConnectionMutator("__swivel", _audioTracker) ); case AVM2: _swfMutators.add( new AS3SoundConnectionMutator("__swivel", _audioTracker) ); } } _swfMutators.add( new SilenceSoundMutator() ); for (mutator in _swfMutators) mutator.mutate(job.swf); runNextTask(); case EncodeSwf(job): _currentJob = job; if(_connection != null) _connection.close(); if(Type.enumEq(audioSource, swf)) { if(Type.enumEq(_currentJob.swf.avmVersion, AVM1)) { _connection = new SwivelConnection(); } else _connection = new AS3SwivelConnection(); } _recordingStartFrame = 0; _recordingNumFrames = 0; _recorder.showWindow = Type.enumEq(job.duration, manual); _recorder.renderQuality = _currentJob.renderQuality; _recorder.startPlayback(_parsedSwf, _currentJob.parameters); if(!_recorder.showWindow) startRecording(); _parsedSwf.disposeTags(); flash.system.System.gc(); case DecodeAudio: _audioTracker.onSoundsDecoded.add( function(_) runNextTask() ); _audioTracker.decodeSounds(); case MixAudio: _audioOutput = new FileStream(); _audioOutput.endian = flash.utils.Endian.LITTLE_ENDIAN; _audioOutput.open(_audioFile, FileMode.APPEND); _audioTracker.onMixingComplete.add(audioMixCompleteHandler); _audioTracker.mixTrack(_audioOutput, _parsedSwf.frameRate, _recordingStartFrame, _recordingNumFrames); case StopEncoder: if(_ffmpeg != null) { _ffmpeg.close(); } if(_connection != null) _connection.close(); case EncodeAudio: var params = [ "-y", "-i", _videoFile.nativePath, "-c:a", "pcm_s16le", "-f", "s16le", "-ar", "44100", "-ac", "2", "-i", _audioFile.nativePath, "-c:v", "copy", "-c:a", audioCodec.codec, "-strict", "-2", "-ar", "44100", "-ac", if(stereoAudio) "2" else "1", ]; if(audioBitRate != null) { params.push("-b:a"); params.push(Std.string(audioBitRate)); } params.push( outputFile.nativePath ); _ffmpeg = new FfmpegProcess(params); _ffmpeg.onComplete.add(onEncodingComplete); case DeleteTempFiles: var dirList = File.applicationStorageDirectory.getDirectoryListing(); for(f in dirList) { if(StringTools.startsWith(f.name, "temp_")) { try f.deleteFile() catch(e:Dynamic) {} } } runNextTask(); } } public function startRecording() { _recordingStartFrame = _recorder.currentFrame; _recorder.startRecording(); if(_audioTracker != null) _audioTracker.listen(_connection); } public function stopRecording() { _recorder.stop(); runNextTask(); } private var _waitCount : Int = 0; private var _swfMutators : List; public function audioMixCompleteHandler(_) { _audioOutput.close(); runNextTask(); } public function stop() : Void { if(_ffmpeg != null) { _ffmpeg.onComplete.removeAll(); _ffmpeg.close(true); _ffmpeg = null; } if(_connection != null) { _connection.close(); _connection = null; } if(_recorder != null) { _recorder.stop(); } if(_audioTracker != null) { _audioTracker.onSoundsDecoded.removeAll(); _audioTracker.onMixingComplete.removeAll(); _audioTracker.stop(); _audioTracker = null; } try _audioOutput.close() catch(error:Dynamic) {} _taskList = null; flash.Lib.current.removeEventListener(flash.events.Event.ENTER_FRAME, dispatchProgress); flash.Lib.current.removeEventListener(flash.events.Event.ENTER_FRAME, runTaskDelay); } private function onEncodingComplete(exitCode) : Void { if(exitCode != 0) { var log = Logger.getLog("FfmpegLog"); if(~/Permission denied/.match(log)) { throw('The output file ${outputFile.nativePath} cannot be accessed.\n\nIf it is open in another program, please close the program before converting.\n\nIf the problem persists, reboot your computer and try saving the output video in a different folder.'); } else { throw('FFmpeg exited with exit code $exitCode\n\n$log'); } } runNextTask(); } private var _progress : Float; private var _frame : flash.display.BitmapData; private function onFrameCaptured(frame : flash.display.BitmapData) { if(_ffmpeg != null) _ffmpeg.send( frame.getPixels(frame.rect) ); _recordingNumFrames++; _totalNumFrames++; _frame = frame; _progress = 0; switch(_currentJob.duration) { case frameRange(startFrame, endFrame): var currentFrame = try Std.int(flash.net.SharedObject.getLocal("__swivel").data.frame) catch(e:Dynamic) 0; _progress = (currentFrame - startFrame) / (endFrame - startFrame + 1); if (currentFrame == endFrame) { _recorder.stop(); runNextTask(); } case manual: default: } } private function dispatchProgress(_) { onProgress.dispatch({ frame: _frame, progress: if(Type.enumEq(currentTask, MixAudio)) _audioTracker.sample / _audioTracker.numSamples else _progress, task: currentTask, job: _currentJob, }); } private function finish() { var time = haxe.Timer.stamp() - _startTime; stop(); onComplete.dispatch( { time: time, outputFile: outputFile, fileSize: outputFile.size, } ); } } typedef SwivelProgressEvent = { var frame : Null; var progress : Float; var task : SwivelTask; var job : SwivelJob; }; typedef FileData = { var file : File; var swf : SwivelSwf; } enum SwivelTask { StartEncoder(outputVideo : File, ?inputAudio : File); ParseSwf(job : SwivelJob); MutateSwf(swf : SwivelJob); EncodeSwf(swf : SwivelJob); DecodeAudio; MixAudio; EncodeAudio; StopEncoder; DeleteTempFiles; } enum AudioSource { none; swf; external(source : File); } ================================================ FILE: src/com/newgrounds/swivel/SwivelJob.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel; import com.huey.binding.Binding; import com.newgrounds.swivel.swf.SwivelSwf; import com.newgrounds.swivel.swf.RenderQuality; import flash.filesystem.File; class SwivelJob extends Binding.Bindable { @bindable public var swf : SwivelSwf; public var file : File; @bindable public var duration : RecordingDuration; @bindable public var renderQuality : RenderQuality; @bindable public var forceBitmapSmoothing : Bool; public var parameters : Dynamic; public function new(file : File, swf : SwivelSwf) { super(); renderQuality = High; forceBitmapSmoothing = true; this.file = file; this.swf = swf; duration = frameRange(1,swf.numFrames); } public function toString() : String { return file.nativePath; } } enum RecordingDuration { frameRange(startFrame : Int, endFrame : Int); manual; } ================================================ FILE: src/com/newgrounds/swivel/audio/ActionScriptSoundInstance.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; class ActionScriptSoundInstance extends SoundInstance { public function new(sound : SoundClip, instance : Int, inPoint : Int, loops : Int) : Void { super(sound, inPoint, null, loops); this.instance = instance; } public var instance(default, null) : Int; public var volume : Float = 1.0; public var leftToLeft : Float = 1.0; public var leftToRight : Float = 0.0; public var rightToLeft : Float = 0.0; public var rightToRight : Float = 1.0; override private function applyTransforms(sample : SoundSample) { var l : Float = sample.left; var r : Float = sample.right; sample.left = volume * (leftToLeft * l + rightToLeft * r); sample.right = volume * (leftToRight * l + rightToRight * r); } } ================================================ FILE: src/com/newgrounds/swivel/audio/AudioTracker.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; import com.huey.events.Dispatcher; import com.huey.utils.Logger; import flash.filesystem.FileStream; import haxe.Int32; import haxe.ds.IntMap; import haxe.ds.StringMap; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.BytesOutput; import com.newgrounds.swivel.swf.SwivelConnection.ISwivelConnection; import haxe.io.Eof; import format.swf.Data; import com.newgrounds.swivel.audio.SoundClip.SoundClipId; class AudioTracker { public var onSoundsDecoded : Dispatcher; public var onMixingComplete : Dispatcher; private var _sounds : List; private var _eventSounds : IntMap; private var _streamSounds : IntMap; private var _asSounds : StringMap; private var _decodeIterator : Iterator; private var _soundLog : Array; private var _activeStreams : IntMap; private var _soundInstances : List; private var _asSoundInstances : List; private var _as2Transforms : IntMap; private var _globalTransform : SoundTransform; public function new() { _sounds = new List(); _eventSounds = new IntMap(); _streamSounds = new IntMap(); _asSounds = new StringMap(); _soundLog = new Array(); _activeStreams = new IntMap(); _soundInstances = new List(); _asSoundInstances = new List(); _as2Transforms = new IntMap(); _globalTransform = { volume: 1.0, leftToLeft: 1.0, leftToRight: 0.0, rightToLeft: 0.0, rightToRight: 1.0, }; onSoundsDecoded = new Dispatcher(); onMixingComplete = new Dispatcher(); _sample = {left: 0, right: 0}; } public function listen(connection : ISwivelConnection) : Void { connection.client = { startSound: startSoundHandler, streamSound: streamSoundHandler, asStart: asStartHandler, asStop: asStopHandler, asSetVolume: asSetVolumeHandler, asSetPan: asSetPanHandler, asSetTransform: asSetTransformHandler, }; } public function registerSound(clip : SoundClip) : Void { _sounds.push(clip); switch(clip.id) { case SoundClipId.event(id): _eventSounds.set(id, clip); case SoundClipId.stream(id): _streamSounds.set(id, clip); case SoundClipId.actionScript(name): _asSounds.set(name, clip); } } public function decodeSounds() { _decodeIterator = _sounds.iterator(); decodeNextSound(); } function decodeNextSound() { if (_decodeIterator.hasNext()) { var clip = _decodeIterator.next(); var decoder = new Decoder(clip); switch(clip.id) { //case SoundClipId.actionScript(_): // decodeNextSound(); default: decoder.onComplete.add( function(e) decodeNextSound() ); decoder.start(); } } else { _decodeIterator = null; onSoundsDecoded.dispatch(); } } private function startSoundHandler(frame : Int, soundId : Int, sync : Int, ?startPos : Int32, ?endPos: Int32, ?numLoops : Int, ?envelopeData : Array) : Void { Logger.log("AudioTrackLog", '$frame: StartSound id: $soundId\n'); var envelope = null; if (envelopeData != null && envelopeData.length > 0) { envelope = []; var i = 0; while (i < envelopeData.length) { envelope.push( { pos: envelopeData[i], leftVolume: envelopeData[i + 1], rightVolume: envelopeData[i+2] } ); i += 3; } } _soundLog.push( { soundId: event(soundId), frame: frame, type: event({ stop: sync == 2, noMultiple: sync == 1, envelope: envelope, numLoops: numLoops, startPos: startPos, endPos: endPos, }), } ); } private function streamSoundHandler(movieFrame : Int, streamId : Int, streamFrame : Int) : Void { Logger.log("AudioTrackLog", '$movieFrame: StreamSound id: $streamId streamFrame: $streamFrame\n'); var streamLog = _activeStreams.get(streamId); if (streamLog != null) { switch(streamLog.type) { case stream(frames): if (frames.endFrame == streamFrame - 1 && streamLog.frame + (frames.endFrame - frames.startFrame) == movieFrame - 1) frames.endFrame = streamFrame; else streamLog = null; default: throw("Event sound in activeStreams"); } } if (streamLog == null) { streamLog = { soundId: stream(streamId), frame: movieFrame, type: stream({startFrame: streamFrame, endFrame: streamFrame}) } _activeStreams.set(streamId, streamLog); _soundLog.push(streamLog); } } private function asStartHandler(movieFrame : Int, instanceNum : Int, soundName : String, offsetSeconds : Null, loops : Null) { var soundId = SoundClipId.actionScript(soundName); var sound = getSound(soundId); _soundLog.push( { soundId: soundId, frame: movieFrame, type: asStart(instanceNum, if(offsetSeconds != null) Std.int(offsetSeconds*SAMPLE_RATE) else null, if(loops != null) loops else 1), } ); } private function asStopHandler(movieFrame : Int, instanceNum : Int) { _soundLog.push( { soundId: null, frame: movieFrame, type: asStop(instanceNum), } ); } private function asSetVolumeHandler(movieFrame : Int, instanceNum : Int, volume : Float) { _soundLog.push( { soundId: null, frame: movieFrame, type: asSetVolume(instanceNum, volume), } ); } private function asSetPanHandler(movieFrame : Int, instanceNum : Int, pan : Float) { _soundLog.push( { soundId: null, frame: movieFrame, type: asSetPan(instanceNum, pan), } ); } private function asSetTransformHandler(movieFrame : Int, instanceNum : Int, ll : Float, lr : Float, rr : Float, rl : Float) { _soundLog.push( { soundId: null, frame: movieFrame, type: asSetTransform(instanceNum, ll, lr, rl, rr), } ); } public function getSound(id : SoundClipId) : SoundClip { if(id == null) return null; return switch(id) { case SoundClipId.event(soundId): _eventSounds.get(soundId); case SoundClipId.stream(clipId): _streamSounds.get(clipId); case SoundClipId.actionScript(name): _asSounds.get(name); } } private static inline var TIME_SLICE : Float = 0.25; public var sample : Int; private var _audioOutput : FileStream; private var frameRate : Float; private var startFrame : Int; public var numFrames : Int; public var numSamples : Int; private var _sample : SoundSample; private static inline var BYTES_PER_SAMPLE = 4; private static inline var SAMPLE_RATE = 44100; public function mixTrack(output : FileStream, frameRate : Float, startFrame : Int, numFrames : Int) { sample = 0; this.startFrame = startFrame; this.numFrames = numFrames; this.frameRate = frameRate; numSamples = Std.int(numFrames * SAMPLE_RATE / frameRate); _audioOutput = output; flash.Lib.current.addEventListener(flash.events.Event.ENTER_FRAME, mixTrackWork); } private function mixTrackWork(_) { var samplesPerFrame : Int = Std.int(frameRate * BYTES_PER_SAMPLE); var length : Int32;// = 1;// Int32.ofInt(numFrames).mul(samplesPerFrame); var startTime = haxe.Timer.stamp(); while(sample < numSamples && haxe.Timer.stamp() - startTime < TIME_SLICE) { var frame = sample * frameRate / SAMPLE_RATE + startFrame; // check if any new sound logs occurred this frame while (_soundLog.length > 0 && _soundLog[0].frame <= frame) { var e = _soundLog.shift(); var soundClip : SoundClip = getSound(e.soundId); switch(e.type) { case event(info): if (soundClip == null) continue; // Sync: "event" var play = true; if ( info.stop ) { // Sync: "stop" // Stop any active instances of this sound. for(sound in _soundInstances) { if (Type.enumEq(sound.id, e.soundId)) _soundInstances.remove(sound); } play = false; } else if ( info.noMultiple ) { // Sync: "start" // Only play if there are no instances of this sound already playing. var found = false; for (sound in _soundInstances) { if (Type.enumEq(sound.id, e.soundId)) { found = true; break; } } play = !found; } if (play) { _soundInstances.add( new EventSoundInstance(soundClip, info) ); } case stream(frames): if(soundClip == null) continue; _soundInstances.add( new SoundInstance(soundClip, Std.int(frames.startFrame * SAMPLE_RATE / frameRate), Std.int(frames.endFrame * SAMPLE_RATE / frameRate), 0) ); case asStart(i, secs, loops): if(soundClip == null) continue; var soundInst = new ActionScriptSoundInstance(soundClip, i, secs * SAMPLE_RATE, loops); var transform = _as2Transforms.get(i); if(transform == null) { transform = {volume: _globalTransform.volume, leftToLeft: _globalTransform.leftToLeft, leftToRight: _globalTransform.leftToRight, rightToLeft: _globalTransform.rightToLeft, rightToRight: _globalTransform.rightToRight}; _as2Transforms.set(i, transform); } soundInst.volume = transform.volume; soundInst.leftToLeft = transform.leftToLeft; soundInst.leftToRight = transform.leftToRight; soundInst.rightToRight = transform.rightToRight; soundInst.rightToLeft = transform.rightToLeft; _asSoundInstances.add(soundInst); case asStop(i): for (sound in _asSoundInstances) if(sound.instance == i) _asSoundInstances.remove(sound); case asSetVolume(i, v): var transform; if(i==-1) { transform = _globalTransform; _as2Transforms = new IntMap(); } else { transform = _as2Transforms.get(i); if(transform == null) { transform = {volume: _globalTransform.volume, leftToLeft: _globalTransform.leftToLeft, leftToRight: _globalTransform.leftToRight, rightToLeft: _globalTransform.rightToLeft, rightToRight: _globalTransform.rightToRight}; _as2Transforms.set(i, transform); } } transform.volume = v; for (sound in _asSoundInstances) if(i == -1 || sound.instance == i) sound.volume = v; case asSetPan(i, p): var transform; if(i==-1) { transform = _globalTransform; _as2Transforms = new IntMap(); } else { transform = _as2Transforms.get(i); if(transform == null) { transform = {volume: _globalTransform.volume, leftToLeft: _globalTransform.leftToLeft, leftToRight: _globalTransform.leftToRight, rightToLeft: _globalTransform.rightToLeft, rightToRight: _globalTransform.rightToRight}; _as2Transforms.set(i, transform); } } transform.leftToRight = 0; transform.rightToLeft = 0; transform.leftToLeft = 1.0 - p; transform.rightToRight = 1.0 + p; if(transform.leftToLeft > 1.0) transform.leftToLeft = 1.0; if(transform.rightToRight > 1.0) transform.rightToRight = 1.0; for (sound in _asSoundInstances) if(i==-1 || sound.instance == i) { sound.leftToRight = 0; sound.rightToLeft = 0; sound.leftToLeft = transform.leftToLeft; sound.rightToRight = transform.rightToRight; }; case asSetTransform(i, ll, lr, rr, rl): var transform; if(i==-1) { transform = _globalTransform; _as2Transforms = new IntMap(); } else { transform = _as2Transforms.get(i); if(transform == null) { transform = {volume: _globalTransform.volume, leftToLeft: _globalTransform.leftToLeft, leftToRight: _globalTransform.leftToRight, rightToLeft: _globalTransform.rightToLeft, rightToRight: _globalTransform.rightToRight}; _as2Transforms.set(i, transform); } } transform.leftToRight = rl; transform.rightToRight = rr; transform.leftToLeft = ll; transform.rightToLeft = lr; for (sound in _asSoundInstances) if(i==-1 || sound.instance == i) { sound.leftToLeft = ll; sound.rightToLeft = lr; sound.leftToRight = rl; sound.rightToRight = rr; } } } // mix all active sounds together _sample.left = 0; _sample.right = 0; for (sound in _soundInstances) { if( sound.step(_sample) ) { _soundInstances.remove(sound); } } for (sound in _asSoundInstances) { if( sound.step(_sample) ) { _soundInstances.remove(sound); } } // clamp result if (_sample.left > 32767) _sample.left = 32767; if (_sample.left < -32768) _sample.left = -32768; if (_sample.right > 32767) _sample.right = 32767; if (_sample.right < -32768) _sample.right = -32768; // output _audioOutput.writeShort(Std.int(_sample.left)); _audioOutput.writeShort(Std.int(_sample.right)); sample++; } if(sample >= numSamples) { stop(); onMixingComplete.dispatch(); } } public function stop() { flash.Lib.current.removeEventListener(flash.events.Event.ENTER_FRAME, mixTrackWork); } } // TODO: this nomenclature is getting confusing... enum SoundLogType { event(info : StartSoundInfo); stream(frames : {startFrame : Int, endFrame : Int}); asStart(instance : Int, offsetSeconds : Null, loops : Int); asSetVolume(instance : Int, volume : Float); asSetPan(instance : Int, pan : Float); asSetTransform(instance : Int, ll : Float, lr : Float, rl : Float, rr : Float); asStop(instance : Int); } typedef SoundLogEntry = { var frame : Int; var soundId : SoundClipId; var type : SoundLogType; } typedef SoundTransform = { var volume : Float; var leftToLeft : Float; var leftToRight : Float; var rightToLeft : Float; var rightToRight : Float; } ================================================ FILE: src/com/newgrounds/swivel/audio/Decoder.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; import com.huey.events.Dispatcher; import com.newgrounds.swivel.ffmpeg.FfmpegProcess; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.utils.ByteArray; import haxe.io.Bytes; import haxe.io.BytesOutput; class Decoder { public var onComplete(default, null) : Dispatcher; private var _clip : SoundClip; private var _ffmpeg : FfmpegProcess; private var _outFile : File; public function new(clip : SoundClip) { onComplete = new Dispatcher(); _clip = clip; } public function start() : Void { // TODO: sometiems we are getting 0 length streams if(_clip.data[0].length == 0) { onComplete.dispatch(); return; } var inFile : File = File.applicationStorageDirectory.resolvePath("temp_clipIn"); _outFile = File.applicationStorageDirectory.resolvePath("temp_clipOut"); var fileStream : FileStream = new FileStream(); var useFlv = false; var args = ["-y", "-f"]; args.push( switch(_clip.format) { case SFNativeEndianUncompressed,SFLittleEndianUncompressed: if (_clip.is16bit) "s16le" else "u8"; case SFNellymoser,SFNellymoser16k,SFNellymoser8k,SFADPCM,SFSpeex: useFlv = true; "flv"; case SFMP3: "mp3"; } ); switch(_clip.format) { case SFNativeEndianUncompressed,SFLittleEndianUncompressed: args = args.concat([ "-ac", _clip.isStereo ? "2" : "1", "-ar", switch(_clip.sampleRate) { case SR5k: "5512"; case SR11k: "11025"; case SR22k: "22050"; case SR44k: "44100"; } ]); default: } args = args.concat(["-i", inFile.nativePath]); args = args.concat( [ "-f", "s16le", "-ac", "2", "-ar", "44100", _outFile.nativePath ] ); fileStream.open( inFile, FileMode.WRITE ); if (useFlv) writeFlvData(_clip, fileStream); else writeAudioData(_clip, fileStream); fileStream.close(); trace(args); _ffmpeg = new FfmpegProcess(args); _ffmpeg.onComplete.add(onDecodeComplete); } private function writeAudioData(sound : SoundClip, out : FileStream) : Void { out.writeBytes(sound.data[0].getData()); } private function writeFlvData(sound : SoundClip, out : FileStream) : Void { out.endian = flash.utils.Endian.BIG_ENDIAN; out.writeUTFBytes("FLV"); out.writeByte(1); out.writeByte(0x4); // audio only out.writeUnsignedInt(0x9); // header size // tag size out.writeUnsignedInt(0); for(packet in sound.data) { var pos = out.position; out.writeByte(0x8); // audio // data size var dataSize: Int = packet.length + 1; out.writeByte((dataSize >> 16) & 0xff); out.writeByte((dataSize >> 8) & 0xff); out.writeByte(dataSize & 0xff); out.writeByte(0); // timestamp TODO: write an actual value here? seems to work ok regardless out.writeShort(0); out.writeByte(0); // timestamp ext. out.writeByte(0); // stream id out.writeShort(0); // audio tag header var tagHeader : Int = 0x2; tagHeader |= switch(sound.format) { case SFADPCM: 0x10; case SFNellymoser16k: 0x40; case SFNellymoser8k: 0x50; case SFNellymoser: 0x60; case SFSpeex: 0xb0; default: throw("FlvDecoder does not support codec " + sound.format); } tagHeader |= switch(sound.sampleRate) { case SR5k: 0; case SR11k: 0x4; case SR22k: 0x8; case SR44k: 0xc; } if (sound.isStereo) tagHeader |= 0x1; out.writeByte(tagHeader); out.writeBytes(packet.getData()); out.writeUnsignedInt( Std.int(out.position - pos) ); } } private function onDecodeComplete(exitCode) : Void { try { if(exitCode == 0) { var fileStream : FileStream = new FileStream(); fileStream.open( _outFile, FileMode.READ ); var byteArray : ByteArray = new ByteArray(); var skipCount = _clip.latencySeek * 4; var scale = switch(_clip.sampleRate) { case SR5k: 8; case SR11k: 4; case SR22k: 2; case SR44k: 1; } fileStream.position += skipCount * scale; var len = if(_clip.numSamples != null) _clip.numSamples * 4 * scale else fileStream.bytesAvailable; if(len > Std.int(fileStream.bytesAvailable)) len = Std.int(fileStream.bytesAvailable); fileStream.readBytes(byteArray, 0, len); fileStream.close(); _clip.data = [Bytes.ofData(byteArray)]; } else { _clip.data = [Bytes.alloc(0)]; } } catch(_ : Dynamic) { _clip.data = [Bytes.alloc(0)]; } onComplete.dispatch(); } } ================================================ FILE: src/com/newgrounds/swivel/audio/EventSoundInstance.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; import format.swf.Data.SoundEnvelopePoint; import format.swf.Data.StartSoundInfo; import haxe.Int32; class EventSoundInstance extends SoundInstance { private static inline var MAX_VOLUME : Int = 32768; public function new(sound : SoundClip, info : StartSoundInfo) { super( sound, if (info.startPos != null) info.startPos else null, if (info.endPos != null) info.endPos else null, if (info.numLoops != null) info.numLoops else 1 ); _envelope = if(info.envelope != null) info.envelope else new Array(); } override private function applyTransforms(sample : SoundSample) { if(_envelopeIndex < _envelope.length) { _volumeLeft += _dVolumeLeft; _volumeRight += _dVolumeRight; var point : SoundEnvelopePoint = _envelope[_envelopeIndex]; if(_sampleCount >= point.pos) { _volumeLeft = point.leftVolume / MAX_VOLUME; _volumeRight = point.rightVolume / MAX_VOLUME; _envelopeIndex++; if(_envelopeIndex < _envelope.length) { point = _envelope[_envelopeIndex]; var dp : Int = point.pos - _sampleCount; _dVolumeLeft = (point.leftVolume / MAX_VOLUME - _volumeLeft) / dp; _dVolumeRight = (point.rightVolume / MAX_VOLUME - _volumeRight) / dp; } } } sample.left *= _volumeLeft; sample.right *= _volumeRight; } private var _dVolumeLeft : Float = 0.0; private var _dVolumeRight : Float = 0.0; private var _volumeLeft : Float = 1.0; private var _volumeRight : Float = 1.0; private var _envelope : Array; private var _envelopeIndex : Int; } ================================================ FILE: src/com/newgrounds/swivel/audio/SoundClip.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; import haxe.io.Bytes; import format.swf.Data; typedef SoundClip = { var id : SoundClipId; var format : SoundFormat; var isStereo : Bool; var is16bit : Bool; var sampleRate : SoundRate; var latencySeek : Int; var numSamples : Null; var data : Array; }; enum SoundClipId { event(soundId : Int); stream(clipId : Int); actionScript(soundName : String); } ================================================ FILE: src/com/newgrounds/swivel/audio/SoundInstance.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; import com.newgrounds.swivel.audio.AudioTracker; import format.swf.Data; import haxe.Int32; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.Eof; import com.newgrounds.swivel.audio.SoundClip.SoundClipId; class SoundInstance { private static var _workSample : SoundSample = {left: 0, right: 0}; public var id(default, null) : SoundClipId; public function new(sound : SoundClip, inPoint : Null, outPoint : Null, loops : Int) { _bytes = sound.data[0]; id = sound.id; _input = new BytesInput(_bytes); _inPosition = if(inPoint != null) inPoint*4 else 0; _outPosition = if(outPoint != null) outPoint*4 else _bytes.length; _loops = loops; _dataPosition = _inPosition; _sampleCount = 0; } inline public function step(sample : SoundSample) : Bool { var done = false; try { _bytes.getData().position = _dataPosition; _workSample.left = _input.readInt16(); _workSample.right = _input.readInt16(); applyTransforms(_workSample); sample.left += _workSample.left; sample.right += _workSample.right; _dataPosition += 4; _sampleCount++; if(_dataPosition >= _outPosition) { _loops--; if(_loops > 0) _dataPosition = _inPosition; else done = true; } } catch(e : Eof) { done = true; } return done; } private var _bytes : Bytes; private var _input : BytesInput; private var _dataPosition : Int; private var _sampleCount : Int; private var _inPosition : Int; private var _outPosition : Int; private var _loops : Int; private function applyTransforms(sample : SoundSample) { } } ================================================ FILE: src/com/newgrounds/swivel/audio/SoundSample.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.audio; typedef SoundSample = { var left : Float; var right : Float; } ================================================ FILE: src/com/newgrounds/swivel/ffmpeg/AudioCodec.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.ffmpeg; typedef AudioCodec = { var label : String; var codec : String; var supportsBitRate : Bool; } ================================================ FILE: src/com/newgrounds/swivel/ffmpeg/FfmpegProcess.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.ffmpeg; import com.huey.events.Dispatcher; import com.huey.events.Dispatcher; import com.huey.utils.Logger; import flash.desktop.NativeProcess; import flash.desktop.NativeProcessStartupInfo; import flash.events.IOErrorEvent; import flash.events.NativeProcessExitEvent; import flash.events.ProgressEvent; import flash.filesystem.File; import flash.Lib; import flash.utils.ByteArray; class FfmpegProcess { public var onComplete(default, null) : Dispatcher; private static var _ffmpegFolder : File; private var _closed : Bool; private var _ffmpeg : NativeProcess; public function new(args : Array) { onComplete = new Dispatcher(); if (_ffmpegFolder == null) { try { var xmlData = flash.desktop.NativeApplication.nativeApplication.applicationDescriptor.toString(); xmlData = StringTools.replace(xmlData, "xmlns", "x"); var xml = Xml.parse(xmlData).firstElement(); var fast = new haxe.xml.Fast( xml ); _ffmpegFolder = File.applicationDirectory.resolvePath( fast.node.ffmpegPath.innerData ); } catch (e:Dynamic) { _ffmpegFolder = File.applicationDirectory.resolvePath("ffmpeg/win32"); } } _closed = false; var ffmpegFile : File = getFfmpegExecutable(); var startupInfo = new NativeProcessStartupInfo(); startupInfo.executable = ffmpegFile; startupInfo.workingDirectory = ffmpegFile.parent; startupInfo.arguments = flash.Vector.ofArray(args); Logger.log("FfmpegLog", Std.string(args) + "\n"); _ffmpeg = new NativeProcess(); _ffmpeg.addEventListener(ProgressEvent.STANDARD_INPUT_PROGRESS, onStdinProgress); _ffmpeg.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, onStdinError); _ffmpeg.addEventListener(ProgressEvent.STANDARD_ERROR_DATA, onStderr); _ffmpeg.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdOutData); _ffmpeg.addEventListener(NativeProcessExitEvent.EXIT, onFfmpegExit); _ffmpeg.start(startupInfo); } private function getFfmpegExecutable() : File { var ffmpegFile = _ffmpegFolder; switch( flash.system.Capabilities.os.split(" ")[0] ) { case "Windows": #if win32 ffmpegFile = ffmpegFile.resolvePath("ffmpeg.exe"); #else ffmpegFile = ffmpegFile.resolvePath("ffmpeg.exe"); #end case "Mac": #if mac32 ffmpegFile = ffmpegFile.resolvePath("ffmpeg"); #else ffmpegFile = ffmpegFile.resolvePath("ffmpeg"); #end default: throw "Unsupported OS"; } return ffmpegFile; } public function send(data) : Void { _ffmpeg.standardInput.writeBytes( data ); } public function close(?force : Bool = false) : Void { _closed = true; _ffmpeg.closeInput(); if(force) _ffmpeg.exit(true); } private function onStdinProgress(_) : Void { } private function onStdinError(event) : Void { Logger.log("FfmpegLog", Std.string(event)); event.preventDefault(); } private function onStdOutData(_) : Void { Logger.log("FfmpegLog", _ffmpeg.standardOutput.readUTFBytes(_ffmpeg.standardOutput.bytesAvailable) ); } private function onStderr(_) : Void { var output : String = _ffmpeg.standardError.readUTFBytes(_ffmpeg.standardError.bytesAvailable); Logger.log("FfmpegLog", output); } private function onFfmpegExit(e) : Void { flash.system.System.resume(); onComplete.dispatch(e.exitCode); } } class FfmpegEncoder extends FfmpegProcess { public static var AUDIO_CODECS : Array = [ {label: "AAC", codec: "aac", supportsBitRate: true}, {label: "Raw PCM 16-bit", codec: "pcm_s16le", supportsBitRate: false}, {label: "MP3", codec: "mp3", supportsBitRate: true}, {label: "Vorbis", codec: "libvorbis", supportsBitRate: true}, {label: "Windows Media Audio", codec: "wmav2", supportsBitRate: true}, ]; public static var PRESETS : Array = [ {label: "H.264 High", fileFormat: "mp4", codec: "libx264", supportsBitRate: true, extraParameters: ["-preset","slow","-pix_fmt","yuv420p"], supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[2]]}, {label: "H.264 Main", fileFormat: "mp4", codec: "libx264", supportsBitRate: true, extraParameters: ["-preset","slow","-profile:v","main","-pix_fmt","yuv420p"], supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[2]]}, {label: "H.264 Baseline", fileFormat: "mp4", codec: "libx264", supportsBitRate: true, extraParameters: ["-preset","slow","-profile:v","baseline","-pix_fmt","yuv420p"], supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[2]]}, {label: "MPEG-2 Video", fileFormat: "mpg", codec: "mpeg2video", supportsBitRate: true, extraParameters: ["-preset","slow"], supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[2]]}, {label: "Theora", fileFormat: "ogg", codec: "theora", supportsBitRate: true, extraParameters: ["-preset","slow"], supportedAudioCodecs: [AUDIO_CODECS[3]]}, {label: "QuickTime Animation", fileFormat: "mov", codec: "qtrle", supportsBitRate: false, extraParameters: null,supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[1], AUDIO_CODECS[2]]}, {label: "Uncompressed AVI", fileFormat: "avi", codec: "rawvideo", supportsBitRate: false, extraParameters: ["-pix_fmt","bgr24"], supportedAudioCodecs: [AUDIO_CODECS[1], AUDIO_CODECS[2]]}, {label: "VP8", fileFormat: "webm", codec: "vp8", supportsBitRate: true, extraParameters: ["-preset","slow"], supportedAudioCodecs: [AUDIO_CODECS[3]]}, {label: "Windows Media Video", fileFormat: "wmv", codec: "wmv2", supportsBitRate: true, extraParameters: ["-preset","slow"], supportedAudioCodecs: [AUDIO_CODECS[4]]}, {label: "Xvid (MPEG-4 part 2)", fileFormat: "mp4", codec: "mpeg4", supportsBitRate: true, extraParameters: ["-preset","slow"], supportedAudioCodecs: [AUDIO_CODECS[0], AUDIO_CODECS[2]]}, ]; public static var TRANSPARENT_PRESETS : Array = [ PRESETS[3], ]; //private var _proc : FfmpegProcess; private var _framesSent : Int; private var _framesReceived : Int; private var _framesEncoded : Int; private var _isWindows : Bool; private var _frameQueue : Array; inline private static var FRAME_QUEUE_SIZE : Int = 2; public var onFrameReceived(default, null) : Dispatcher; public function new(preset : VideoPreset, videoBitRate : Null, outputFile : File, width : UInt, height : UInt, frameRate : Float, ?audioFile : String, ?audioCodec : AudioCodec, ?audioBitRate : Null, ?numChannels : Int) { _framesSent = _framesReceived = _framesEncoded = 0; _frameQueue = new Array(); onFrameReceived = new Dispatcher(); var params = [ "-threads", "0", // multithreading "-y", // overwrite output silently // read video from stdin "-f", "rawvideo", "-pix_fmt", "argb", "-s", width + "x" + height, "-r", Std.string(frameRate), "-i", "-", ]; if(audioFile == null) params.push("-an"); else { params.push("-i"); params.push(audioFile); params.push("-c:a"); if(audioCodec == null) { params.push("copy"); } else { params.push(audioCodec.codec); if(audioBitRate != null) { params.push("-b:a"); params.push(Std.string(audioBitRate)); } params.push("-ac"); params.push(Std.string(numChannels)); } } params.push("-c:v"); params.push(preset.codec); if(videoBitRate != null) { params.push("-b:v"); params.push(Std.string(videoBitRate)); } else if(preset.supportsBitRate) { params.push("-q"); params.push("0"); } if(preset.extraParameters != null) { for(p in preset.extraParameters) params.push(p); } params.push("-aspect"); params.push(width + ":" + height); params.push("-strict"); params.push("-2"); params.push(outputFile.nativePath); super( params ); } private override function getFfmpegExecutable() : File { var ffmpegFile = FfmpegProcess._ffmpegFolder; switch( flash.system.Capabilities.os.split(" ")[0] ) { case "Windows": _isWindows = true; #if win32 ffmpegFile = ffmpegFile.resolvePath("redirecter.exe"); #else ffmpegFile = ffmpegFile.resolvePath("redirecter.exe"); #end case "Mac": _isWindows = false; #if mac32 ffmpegFile = ffmpegFile.resolvePath("ffmpeg"); #else ffmpegFile = ffmpegFile.resolvePath("ffmpeg"); #end default: throw "Unsupported OS"; } return ffmpegFile; } public override function send(frame : ByteArray) { //if(_closed) return; _frameQueue.push(frame); _framesSent++; if(_frameQueue.length == 1) sendNextFrame(); if(_frameQueue.length >= FRAME_QUEUE_SIZE) flash.system.System.pause(); } private function sendNextFrame() { if(_frameQueue.length > 0) { super.send(_frameQueue[0]); } if(_frameQueue.length < FRAME_QUEUE_SIZE) flash.system.System.resume(); } public override function close(?force : Bool = false) : Void { _closed = true; if (_framesReceived >= _framesSent) _ffmpeg.closeInput(); if(force) _ffmpeg.exit(true); } private override function onStderr(_) : Void { var output : String = _ffmpeg.standardError.readUTFBytes(_ffmpeg.standardError.bytesAvailable); Logger.log("FfmpegLog", output); var frameRegex : EReg = ~/frame=\s*(\d+).*/; if ( frameRegex.match(output) ) { _framesEncoded = Std.parseInt( frameRegex.matched(1) ); } } private override function onStdinError(event) : Void { Logger.log("FfmpegLog", Std.string(event)); event.preventDefault(); _framesReceived++; //trace("Ercvd: " + _framesReceived); if (_closed && _framesReceived >= _framesSent) _ffmpeg.closeInput(); if(!_isWindows) { _frameQueue.shift(); sendNextFrame(); } } private override function onStdinProgress(_) : Void { _framesReceived++; //trace("Prcvd: " + _framesReceived); if (_closed && _framesReceived >= _framesSent) _ffmpeg.closeInput(); if(!_isWindows) { _frameQueue.shift(); sendNextFrame(); } } private override function onStdOutData(_) : Void { if(_isWindows) { _frameQueue.shift(); sendNextFrame(); } } } ================================================ FILE: src/com/newgrounds/swivel/ffmpeg/VideoPreset.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.ffmpeg; typedef VideoPreset = { var label : String; var fileFormat : String; var codec : String; var supportsBitRate : Bool; var extraParameters : Null>; var supportedAudioCodecs : Null>; } ================================================ FILE: src/com/newgrounds/swivel/swf/AS3SoundConnectionMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ /** * ... * @author Newgrounds.com, Inc. * Tracks sound events over LocalConnection */ package com.newgrounds.swivel.swf; import com.newgrounds.swivel.audio.AudioTracker; import com.newgrounds.swivel.audio.SoundClip; import com.newgrounds.swivel.swf.SwivelSwf.ABCStuff; import format.abc.Context; import format.abc.Data; import format.abc.OpReader; import format.as1.Data; import format.swf.Data; import haxe.Int32; import haxe.ds.IntMap; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.BytesOutput; using com.newgrounds.swivel.swf.AbcUtils; typedef ClipFrameSounds = IntMap< Array >; class AS3SoundConnectionMutator extends SoundConnectionMutator { public function new(connectionName : String, audioTracker : AudioTracker) { super(connectionName, audioTracker); _clipsWithSound = new IntMap(); } override public function mutate(swf : SwivelSwf) : Void { for(i in 0...swf.tags.length) { var tag = swf.tags[i]; switch(tag) { case TActionScript3(data, c): var abc = new format.abc.Reader(new BytesInput(data)).read(); var altered = false; for(j in 0...abc.names.length) { var clName = abc.getNamePath(Idx(j+1)); if(clName == "flash.media.Sound") { abc.names[j] = NName( abc.string("__SwivelSound"), abc.namespace(NPublic(abc.string(""))) ); altered = true; } else if(clName == "flash.media.SoundChannel") { abc.names[j] = NName( abc.string("Object"), abc.namespace(NPublic(abc.string(""))) ); altered = true; } } if(altered) { var o = new BytesOutput(); new format.abc.Writer(o).write(abc); swf.tags[i] = TActionScript3(o.getBytes(), c); } default: } } super.mutate(swf); } private var _clipsWithSound : IntMap; override private function handleStartSound(clipId : Int, frame : Int, soundId : Int, infos : StartSoundInfo) : SWFTag { var sounds = getClip(clipId, frame); sounds.push({ frame: frame, soundId: event(soundId), type: event(infos), }); return null; } override private function handleStreamFrame(clipId : Int, clipFrame : Int, streamId : Int, streamFrame : Int) : SWFTag { var sounds = getClip(clipId, clipFrame); sounds.push({ frame: clipFrame, soundId: SoundClipId.stream(streamId), type: SoundLogType.stream({startFrame: streamFrame, endFrame: streamFrame}), }); return null; } private function getClip(id : Int, frame : Int) : Array { var sounds = _clipsWithSound.get(id); if(sounds == null) { sounds = new IntMap(); _clipsWithSound.set(id, sounds); } var frameSounds = sounds.get(frame); if(frameSounds == null) { frameSounds = new Array(); sounds.set(frame, frameSounds); } return frameSounds; } inline private function name(ctx : Context, name : String) { return ctx.name( NName(ctx.string(name), ctx.nsPublic) ); } private var _currentSounds : ClipFrameSounds; override private function finalize(swf : SwivelSwf) { for(clipId in _clipsWithSound.keys()) { _currentSounds = _clipsWithSound.get(clipId); swf.hoistClip(clipId, injectSoundMethods); } } function injectSoundMethods(abcStuff : ABCStuff) { var abc = abcStuff.abc; var cl = abcStuff.cl; var addFrameScriptName = abc.publicName( "addFrameScript" ); var publicNs = abc.namespace( NPublic(abc.string("")) ); var voidName = abc.publicName("void"); var swivelClName = abc.publicName("__Swivel"); var startSoundStr = abc.string("startSound"); var frameName = abc.publicName("frame"); var streamSoundStr = abc.string("streamSound"); var swivelName = abc.publicName("__swivel"); //var traceName = abc.publicName("trace"); var oldFrameScripts = new IntMap(); for(f in cl.fields) { var name = abc.getName(f.name); switch(name) { case NName(n,_): var name = abc.getString(n); if(name.substr(0,5) == "frame") { var oldMethod = switch(f.kind) { case FMethod(t,_,_,_): abc.getFunction(t); default: throw("Unexpected frame method"); }; var frameNum = Std.parseInt(name.substr(5)); if(frameNum != null) oldFrameScripts.set( frameNum-1, oldMethod ); } default: } } var ctorOps = [ OThis, OScope, ]; var j = 0; for(frame in _currentSounds.keys()) { var methodName = abc.pushName( NName(abc.pushString('__snd$j'), publicNs) ); var oldMethod = oldFrameScripts.get(frame); if(oldMethod == null) { ctorOps = ctorOps.concat([ OFindPropStrict(addFrameScriptName), abc.opInt(frame), OThis, OGetProp(methodName), OCallPropVoid(addFrameScriptName, 2), ]); } else { if(oldMethod.maxStack < 2) oldMethod.maxStack = 2; oldMethod.prependOps([ OThis, OScope, OFindPropStrict(methodName), OCallPropVoid(methodName, 0), OPopScope, ]); } var methodOps = [ OThis, OScope, ]; for(e in _currentSounds.get(frame)) { var soundId : Int = switch(e.soundId) { case event(i): i; case stream(i): i; default: throw("Bad sound id"); -1; } switch(e.type) { case event(info): methodOps = methodOps.concat([ OGetLex( swivelClName ), OString( startSoundStr ), OGetLex( swivelClName ), OGetProp( frameName ), OInt(soundId), OInt(if(info.noMultiple) 1 else if(info.stop) 2 else 0), if(info.startPos!= null) abc.opInt(info.startPos) else ONull, if(info.endPos != null) abc.opInt(info.endPos) else ONull, if(info.numLoops != null) abc.opInt(info.numLoops) else ONull, ]); if(info.envelope != null) { for(p in info.envelope) { methodOps = methodOps.concat([ abc.opInt(p.pos), abc.opInt(p.leftVolume), abc.opInt(p.rightVolume), ]); } methodOps.push(OArray(info.envelope.length * 3)); } else methodOps.push( ONull ); methodOps.push( OCallPropVoid(swivelName, 8) ); case stream(frames): methodOps = methodOps.concat([ OGetLex( swivelClName ), OString( streamSoundStr ), OGetLex( swivelClName ), OGetProp( frameName ), // movie frame OInt(soundId), // stream id abc.opInt(frames.startFrame), // stream frame OCallPropVoid(swivelName, 4), ]); default: throw("Bad sound type in AS3SoundConnectionMutator"); } } methodOps.push(OPopScope); methodOps.push(ORetVoid); abc.quickMethod(cl, methodName, methodOps, KNormal, null, voidName); j++; } ctorOps.push(OPopScope); var ctor = abc.getFunction(cl.constructor); if(ctor.maxStack < 4) ctor.maxStack = 4; if(ctor.maxScope < 4) ctor.maxScope = 4; ctor.prependOps(ctorOps); } } ================================================ FILE: src/com/newgrounds/swivel/swf/AS3SwivelConnection.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import com.newgrounds.swivel.swf.SwivelConnection.ISwivelConnection; class AS3SwivelConnection implements ISwivelConnection { private static var _instance : AS3SwivelConnection; private var _client : Dynamic; public var client(get,set) : Dynamic; private function get_client() : Dynamic { return _client; } private function set_client(v : Dynamic ) : Dynamic { return _client = v; } public function new() { _instance = this; } public static function receiveMessage(args : Array) { try { if(_instance != null && _instance.client != null) { var methodName = args.shift(); var method : Dynamic = Reflect.getProperty(_instance.client, methodName); if(args.length == 0) method(); else if(args.length == 1) method(args[0]); else if(args.length == 2) method(args[0],args[1]); else if(args.length == 3) method(args[0],args[1],args[2]); else if(args.length == 4) method(args[0],args[1],args[2],args[3]); else if(args.length == 5) method(args[0],args[1],args[2],args[3],args[4]); else if(args.length == 6) method(args[0],args[1],args[2],args[3],args[4],args[5]); else if(args.length == 7) method(args[0],args[1],args[2],args[3],args[4],args[5],args[6]); //Reflect.callMethod(_instance.client, args.shift(), args); } } catch(e:Dynamic) { } } public function tick() { } public function close() { client = null; } } ================================================ FILE: src/com/newgrounds/swivel/swf/AbcUtils.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.abc.Data; import format.abc.OpWriter; import format.abc.Reader; import format.abc.Writer; import format.swf.Data; import haxe.io.BytesInput; import haxe.io.BytesOutput; class AbcUtils { private static function lookup( arr : Array, n : T ) : Index { for( i in 0...arr.length ) if( arr[i] == n ) return Idx(i + 1); arr.push(n); return Idx(arr.length); } private static function elookup( arr : Array, n : T ) : Index { for( i in 0...arr.length ) if( Type.enumEq(arr[i],n) ) return Idx(i + 1); arr.push(n); return Idx(arr.length); } inline public static function opInt(abc : ABCData, v) : OpCode { return if(v < 32768) OInt(v); else OIntRef( int(abc, v) ); } public static function int(abc : ABCData, v) return lookup(abc.ints, v); public static function uint(abc : ABCData, v) return lookup(abc.uints, v); public static function float(abc : ABCData, v : Float) return lookup(abc.floats, v); public static function string(abc : ABCData, v : String) return lookup(abc.strings, v); public static function pushString(abc : ABCData, v : String) : Index { abc.strings.push(v); return Idx(abc.strings.length); } public static function name(abc : ABCData, v : Name) return elookup(abc.names, v); inline public static function pushName(abc : ABCData, v : Name) : IName { abc.names.push(v); return Idx(abc.names.length); } public static function publicName(abc : ABCData, v : String) return elookup(abc.names, NName( string(abc, v), namespace(abc, NPublic(string(abc, ""))) ) ); public static function namespace(abc : ABCData, v : Namespace) return elookup(abc.namespaces, v); public static function namespaceSet(abc : ABCData, v : NamespaceSet) return elookup(abc.nssets, v); public static function methodType(abc : ABCData, v : MethodType) { abc.methodTypes.push(v); return Idx(abc.methodTypes.length - 1); } public static function type(abc : ABCData, path) : Null> { if( path == "*" ) return null; var path = path.split("."); var cname = path.pop(); var pid = string(abc,path.join(".")); var nameid = string(abc,cname); var pid = namespace(abc,NPublic(pid)); var tid = name(abc,NName(nameid,pid)); return tid; } public static function replaceName(abc : ABCData, i : IName, name : Name) { var _i = switch(i) { case Idx(i): i-1; }; abc.names[_i] = name; } public static function getInt(abc : ABCData, i) return abc.get(abc.ints, i); public static function getUInt(abc : ABCData, i) return abc.get(abc.uints, i); public static function getFloat(abc : ABCData, i : Index) return abc.get(abc.floats, i); public static function getString(abc : ABCData, i : Index) return abc.get(abc.strings, i); public static function getClass(abc : ABCData, i : Index) return abc.get(abc.classes, i); public static function getName(abc : ABCData, i : IName) return abc.get(abc.names, i); public static function getNamespace(abc : ABCData, i : Index) return abc.get(abc.namespaces, i); public static function getNamespaceSet(abc : ABCData, i : Index) return abc.get(abc.nssets, i); public static function getMethodType(abc : ABCData, i : Index) { return switch( i ) { case Idx(n): abc.methodTypes[n]; }; } public static function getFunction(abc : ABCData, i : Index) { for (f in abc.functions) if (Type.enumEq(f.type, i)) return f; return null; } public static function getNamespaceStr(abc : ABCData, i : Index) : String { switch(i) { case Idx(n): if(n==0) return null; } return switch( getNamespace(abc, i) ) { case NPublic(ns): getString(abc, ns); case NNamespace(ns): getString(abc, ns); case NPrivate(ns): getString(abc, ns); case NInternal(ns): getString(abc, ns); case NProtected(ns): getString(abc, ns); case NExplicit(ns): getString(abc, ns); case NStaticProtected(ns): getString(abc, ns); } } /*public static function quickClass(name : String) : ABCData { data = new ABCData(); data.ints = new Array(); data.uints = new Array(); data.floats = new Array(); data.strings = new Array(); data.namespaces = new Array(); data.nssets = new Array(); data.metadatas = new Array(); data.methodTypes = new Array(); data.names = new Array(); data.classes = new Array(); data.functions = new Array(); }*/ public static function dumpFunc(abc : ABCData, f : Function) : String { var ops = format.abc.OpReader.decode(new BytesInput(f.code)); var str = ""; for(op in ops) { str += switch(op) { case OGetLex(n): 'OGetLex(${getNamePath(abc,n)})'; case OFindProp(n): 'OFindProp(${getNamePath(abc,n)})'; case OFindPropStrict(n): 'OFindPropStrict(${getNamePath(abc,n)})'; case OGetProp(n): 'OGetProp(${getNamePath(abc,n)})'; case OInitProp(n): 'OInitProp(${getNamePath(abc,n)})'; case OString(s): 'OString(${getString(abc,s)})'; case OCallProperty(n,i): 'OCallProperty(${getNamePath(abc,n)},$i)'; case OCallPropVoid(n,i): 'OCallPropVoid(${getNamePath(abc,n)},$i)'; case OConstructProperty(n,i):'OConstructProperty(${getNamePath(abc,n)},$i)'; case OSetProp(n): 'OSetProp(${getNamePath(abc,n)})'; //case OClassDef(c): 'OClassDef(${getNamePath(abc,getClass(abc,c).name)})'; default: Std.string(op); } str += "\n"; } return str; } public static function dumpAbc(abc : ABCData) { var str = ""; /*var str = "init fields:"; for(init in abc.inits) { for(field in init.fields) str += " " + getNamePath(abc, field.name) + "\n"; } str += "\n";*/ for(f in abc.functions) { str += dumpFunc(abc, f); str += "-----------------\n\n"; } /* str += "\nclasses:\n"; for(cl in abc.classes) str += " " + getNamePath(abc, cl.name) + " extends " + getNamePath(abc, cl.superclass) + "\n"; str += "\n";*/ str += "\nstrings:\n"; for(i in 0...abc.strings.length) if(abc.strings[i].substr(0,5) != "frame") str += " " + (i+1) + ".\t" + abc.strings[i] + "\n"; /*str += "\nnames:\n"; for(i in 1...abc.names.length+1) str += " " + i + ".\t" + getNamePath(abc, Idx(i)) + "\n";*/ str += "\n"; return str; } /*inline private static function mergeMap(abc : ABCData, arr : Array>, i : Index ) : T { switch(i) { case Idx(j): return arr[j]; } } inline private static function nullMergeMap(abc : ABCData, arr : Array>, i : Null> ) : T { return if(i != null) mergeMap(abc,arr,i) else null; } public static function merge(dst : ABCData, src : ABCData) { var intMap = new Array(); var uintMap = new Array(); var floatMap = new Array(); var namespaceMap = new Array(); var nssetMap = new Array(); var nameMap = new Array(); var classMap = new Array(); for(i in 0...src.ints.length) intMap[i] = dst.int(src.ints[i]); for(i in 0...src.uints.length) uintMap[i] = dst.uint(src.uints[i]); for(i in 0...src.floats.length) floatMap[i] = dst.float(src.uints[i]); for(i in 0...src.strings.length) stringMap[i] = dst.string(src.strings[i]); for(i in 0...src.namespaces.length) { namespaceMap[i] = switch(src.namespaces[i]) { case NPrivate(ns): dst.namespace( NPrivate(mergeMap(dst,stringMap,ns)) ); case NNamespace(ns): dst.namespace( NNamespace(mergeMap(dst,stringMap,ns)) ); case NPublic(ns): dst.namespace( NPublic(mergeMap(dst,stringMap,ns)) ); case NInternal(ns): dst.namespace( NInternal(mergeMap(dst,stringMap,ns)) ); case NProtected(ns): dst.namespace( NProtected(mergeMap(dst,stringMap,ns)) ); case NExplicit(ns): dst.namespace( NExplicit(mergeMap(dst,stringMap,ns)) ); case NStaticProtected(ns): dst.namespace( NStaticProtected(mergeMap(dst,stringMap,ns)) ); } } for(i in 0...src.nssets.length) { var nsset = src.nssets[i]; var newNsset = new Array(); for(ns in nsset) newNsset.push( mergeMap(dst,namespaceMap,ns) ); nssetMap[i] = dst.namespaceSet( newNsset ); } for(i in 0...src.names.length) { nameMap[i] = switch(src.names[i]) { case NName(n,ns): dst.name( NName( mergeMap(dst,stringMap,n), mergeMap(dst,namespaceMap,ns) ) ); case NMulti(n,nsset): dst.name( NMulti( mergeMap(dst,stringMap,n), mergeMap(dst,nssetMap,nsset) ) ); case Runtime(n): dst.name( NRuntime( mergeMap(dst,stringMap,n) ) ); case NRuntimeLate: dst.name( NRuntimeLate ); case NMultiLate(nsset): dst.name( NMultiLate( mergeMap(dst,nssetMap,nsset) ) ); case NAttrib(n): dst.name( NAttrib(n) ); case NParams(n, params): throw("TODO???"); } } // TODO: method types??? // TODO this for(i in 0...src.metadatas.length) { var metadata = src.metadatas[i]; var newData = { n: if(metadata.n != null) mergeMap(dst,stringMap,metadata.n) else null, v: mergeMap(dst,stringMap,metadata.v) }; metadataMap[i] = dst.metadata( {name: mergeMap(dst,stringMap,metadata.name), data: newData} ); } for(i in 0...src.classes.length) { var cl = src.classes[i]; var newClass = { name: mergeMap(dst,stringMap,cl.name), superclass: nullMergeMap(dst,stringMap,cl.superclass), interfaces: new Array(), constructor: mergeMap(dst,methodTypeMap,cl.constructor), fields: new Array(), namespace: nullMergeMap(dst,namespaceMap,cl.namespace), isSealed: cl.isSealed, isFinal: cl.isFinal, isInterface: cl.isInterface, statics: mergeMap(dst,methodTypeMap,cl.statics), staticFields: new Array(), }; dst.classes.push(cl); classMap[i] = dst.classes.length; } for(i in 0...src.inits.length) { var init = src.inits[i]; var newInit = { method: mergeMap(dst,methodTypeMap,init.method), fields: new Array(), }; dst.inits.push(newInit); } for(i in 0...src.functions.length) { var f = src.functions[i]; var newF = { type: mergeMap(dst,methodTypeMap,f.type), maxStack: f.maxStack, nRegs: f.nRegs, initScope: f.initScope, maxScope: f.maxScope, maxStack: f.maxStack, code: null, trys: new Array(), locals: new Array(), } var ops = format.abc.OReader.decode(new BytesInput(f.code)); for(i in 0...ops.length) { ops[i] = switch(ops[i]) { case OGetSuper(n): OGetSuper( mergeMap(dst,nameMap,n) ); case OSetSuper(n): OSetSuper( mergeMap(dst,nameMap,n) ); case ODxNs(s): ODxNs( mergeMap(dst,stringMap,s) ); case OString(s): OString( mergeMap(dst,stringMap,s) ); case OIntRef(i): OIntRef( mergeMap(dst,intMap,i) ); case OUIntRef(i): OUIntRef( mergeMap(dst,uintMap,i) ); case OFloat(f): OFloat( mergeMap(dst,floatMap,f) ); case ONamespace(ns): ONamespace( mergeMap(dst,namespaceMap,ns) ); case OFunction(m): OFunction( mergeMap(dst,methodTypeMap,m) ); case OCallStatic(m,i): OCallStatic( mergeMap(dst,methodTypeMap,m), i); case OCallSuper(n,i): OCallSuper( mergeMap(dst,nameMap,n), i ); case OCallProperty(n,i): OCallProperty( mergeMap(dst,nameMap,n), i ); case OConstructProperty(n,i): OConstructProperty( mergeMap(dst,nameMap,n), i ); case OCallPropLex(n,i): OCallPropLex( mergeMap(dst,nameMap,n), i ); case OCallSuperVoid(n,i): OCallSuperVoid( mergeMap(dst,nameMap,n), i ); case OCallPropVoid(n,i): OCallPropVoid( mergeMap(dst,nameMap,n), i ); // OClassDef case OGetDescendants(n): OGetDescendants( mergeMap(dst,nameMap,n) ); case OFindPropStrict(n): OFindPropStrict( mergeMap(dst,nameMap,n) ); case OFindDefinition(n): OFindDefinition( mergeMap(dst,nameMap,n) ); case OGetLex(n): OGetLex( mergeMap(dst,nameMap,n) ); case OSetProp(n): OSetProp( mergeMap(dst,nameMap,n) ); case OGetProp(n): OGetProp( mergeMap(dst,nameMap,n) ); case OInitProp(n): OInitProp( mergeMap(dst,nameMap,n) ); case ODeleteProp(n): ODeleteProp( mergeMap(dst,nameMap,n) ); case OCast(n): OCast( mergeMap(dst,nameMap,n) ); case OAsType(n): OAsType( mergeMap(dst,nameMap,n) ); case OIsType(n): OIsType( mergeMap(dst,nameMap,n) ); case ODebugReg(s,r,l): ODebugReg( mergeMap(dst,stringMap,s), r, l ); case ODebugFile(s): ODebugFile( mergeMap(dst,stringMap,s) ); default: ops[i]; } } var o = new BytesOutput(); format.abc.OReader.encode(o, ops); newF.code = o.getBytes(); dst.functions.push(newF); } }*/ private static var _mergeI : Int = 0; public static function mergeClass(dst : ABCData, dstCl : ClassDef, src : ABCData, srcCl : ClassDef) { trace(dumpAbc(dst)); trace( dumpAbc(src) ); //trace( countSlots(src, srcCl) ); var slotOffset = countSlots(dst, dstCl); //trace( slotOffset ); var srcClassName : String = getNamePath(src, srcCl.name); var dstClassName : String = getNamePath(dst, dstCl.name); for(i in 0...src.strings.length) { if(src.strings[i] == srcClassName) { src.strings[i] = dstClassName; } } for(field in srcCl.fields) { dstCl.fields.push(mergeField(dst,src,field, slotOffset)); } var theName = null; for(field in srcCl.staticFields) { dstCl.staticFields.push(mergeField(dst,src,field, slotOffset)); var newField = dstCl.staticFields[dstCl.staticFields.length-1]; theName = newField.name; } var srcCtor = getFunction(src,srcCl.constructor); var ctorF = mergeFunction(dst,src,srcCtor); var consField = { name: publicName(dst, '__cons$_mergeI'), slot: 0, kind: FMethod( ctorF.type, KNormal, false, false ), metadatas: null, }; _mergeI++; dstCl.fields.push(consField); /*var sField = { name: publicName(dst, "__a"), slot: 1, kind: FVar( publicName(dst, "Object") ), metadatas: null, }; dstCl.staticFields.push(sField);*/ var dstCtor = getFunction(dst,dstCl.constructor); var o = new BytesOutput(); encodeOps(o, [ OThis, OCallPropVoid(consField.name, 0), /*OThis, OScope, OFindPropStrict(publicName(dst, "trace")), OString(string(dst, "InjectCtor")), OCallPropVoid(publicName(dst,"trace"),1), OPopScope,*/ ]); o.write(dstCtor.code); dstCtor.code = o.getBytes(); //trace("NEW"); //trace( dumpAbc(dst) ); } private static function countSlots(abc : ABCData, cl : ClassDef) { var maxSlot = 0; for(field in cl.staticFields) { if(field.slot > maxSlot) maxSlot = field.slot; } for(field in cl.fields) { if(field.slot > maxSlot) maxSlot = field.slot; } return maxSlot; } private static function mergeField(dst : ABCData, src : ABCData, srcField : Field, ?slotOffset : Int = 0) { var newKind = switch(srcField.kind) { case FVar(type, value, const): FVar( if(type != null) mergeName(dst,src,type) else null, if(value != null) mergeValue(dst,src,value) else null, const ); case FMethod(type, kind, isFinal, isOverride): var newF = mergeFunction(dst,src,getFunction(src,type)); FMethod( newF.type, kind, isFinal, isOverride ); case FClass(_): throw("TODO FClass"); case FFunction(_): throw("TODO FFunction"); } var newField = { name: mergeName(dst,src,srcField.name), slot: if(srcField.slot > 0) srcField.slot + slotOffset else 0, kind: newKind, metadatas: null, }; return newField; } private static function mergeValue(dst : ABCData, src : ABCData, v : Value ) : Value { return switch(v) { case VNull: VNull; case VBool(b): VBool(b); case VString(s): VString( mergeString(dst,src,s) ); case VInt(i): VInt( mergeInt(dst,src,i) ); case VUInt(i): VUInt( mergeUInt(dst,src,i) ); case VFloat(f): VFloat( mergeFloat(dst,src,f) ); case VNamespace(k,ns): VNamespace(k, mergeNamespace(dst,src,ns)); }; } private static function mergeInt(dst : ABCData, src : ABCData, i) { if(Type.enumEq(i,Idx(0))) return i; return int(dst, getInt(src, i)); } private static function mergeUInt(dst : ABCData, src : ABCData, i) { if(Type.enumEq(i,Idx(0))) return i; return uint(dst, getUInt(src, i)); } private static function mergeFloat(dst : ABCData, src : ABCData, i : Index) : Index { if(Type.enumEq(i,Idx(0))) return i; return float(dst, getFloat(src, i)); } private static function mergeFunction(dst : ABCData, src : ABCData, srcF : Function) : Function { var newLocals = new Array(); for(field in srcF.locals) { newLocals.push( mergeField(dst,src,field) ); } var newTrys = new Array(); for(i in 0...srcF.trys.length) { var t = srcF.trys[i]; newTrys.push({ start: t.start, end: t.end, handle: t.handle, type: if(t.type != null) mergeName(dst, src, t.type) else null, variable: if(t.variable != null) mergeName(dst, src, t.variable) else null, }); } var ops = format.abc.OpReader.decode(new BytesInput(srcF.code)); for(i in 0...ops.length) { ops[i] = switch(ops[i]) { case OGetSuper(n): OGetSuper( mergeName(dst,src,n) ); case OSetSuper(n): OSetSuper( mergeName(dst,src,n) ); case ODxNs(s): ODxNs( mergeString(dst,src,s) ); case OString(s): OString( mergeString(dst,src,s) ); case OIntRef(i): OIntRef( mergeInt(dst,src,i) ); case OUIntRef(i): OUIntRef( mergeUInt(dst,src,i) ); case OFloat(f): OFloat( mergeFloat(dst,src,f) ); case ONamespace(ns): ONamespace( mergeNamespace(dst,src,ns) ); case OFunction(m): OFunction( mergeMethodType(dst,src,m) ); case OCallStatic(m,i): OCallStatic( mergeMethodType(dst,src,m), i); case OCallSuper(n,i): OCallSuper( mergeName(dst,src,n), i ); case OCallProperty(n,i): OCallProperty( mergeName(dst,src,n), i ); case OConstructProperty(n,i): OConstructProperty( mergeName(dst,src,n), i ); case OCallPropLex(n,i): OCallPropLex( mergeName(dst,src,n), i ); case OCallSuperVoid(n,i): OCallSuperVoid( mergeName(dst,src,n), i ); case OCallPropVoid(n,i): OCallPropVoid( mergeName(dst,src,n), i ); case OClassDef(c): throw("TODO OClassDef"); null; case OGetDescendants(n): OGetDescendants( mergeName(dst,src,n) ); case OFindPropStrict(n): OFindPropStrict( mergeName(dst,src,n) ); case OFindProp(n): OFindProp( mergeName(dst,src,n) ); case OFindDefinition(n): OFindDefinition( mergeName(dst,src,n) ); case OGetLex(n): OGetLex( mergeName(dst,src,n) ); case OSetProp(n): OSetProp( mergeName(dst,src,n) ); case OGetProp(n): OGetProp( mergeName(dst,src,n) ); case OInitProp(n): OInitProp( mergeName(dst,src,n) ); case ODeleteProp(n): ODeleteProp( mergeName(dst,src,n) ); case OCast(n): OCast( mergeName(dst,src,n) ); case OAsType(n): OAsType( mergeName(dst,src,n) ); case OIsType(n): OIsType( mergeName(dst,src,n) ); case ODebugReg(s,r,l): ODebugReg( mergeString(dst,src,s), r, l ); case ODebugFile(s): ODebugFile( mergeString(dst,src,s) ); default: ops[i]; } } var o = new BytesOutput(); encodeOps(o, ops); var newF = { type: mergeMethodType(dst, src, srcF.type), maxStack: srcF.maxStack, nRegs: srcF.nRegs, initScope: srcF.initScope, maxScope: srcF.maxScope, code: o.getBytes(), locals: newLocals, trys: newTrys, } dst.functions.push(newF); return newF; } private static function mergeMethodType(dst : ABCData, src : ABCData, i : Index) : Index { var m = getMethodType(src,i); var newArgs = new Array(); for(arg in m.args) { newArgs.push( if(arg != null) mergeName(dst,src,arg) else null ); } var newExtra = null; if(m.extra != null) { var newDParams = null; if(m.extra.defaultParameters != null) { newDParams = new Array(); for(v in m.extra.defaultParameters) { newDParams.push( mergeValue(dst,src,v) ); } } var newParamNames = null; if(m.extra.paramNames != null) { newParamNames = new Array(); for(p in m.extra.paramNames) { newParamNames.push( if(p != null) mergeString(dst,src,p) else null ); } } newExtra = { native: m.extra.native, variableArgs: m.extra.variableArgs, argumentsDefined: m.extra.native, usesDXNS: m.extra.usesDXNS, newBlocK: m.extra.newBlock, unused: m.extra.unused, debugName: if(m.extra.debugName != null) mergeString(dst,src,m.extra.debugName) else null, defaultParameters: newDParams, paramNames: newParamNames, }; } return methodType(dst,{ args: newArgs, ret: if(m.ret != null) mergeName(dst,src,m.ret) else null, extra: null, }); } private static function mergeName(dst : ABCData, src : ABCData, i : IName) : IName { if(Type.enumEq(i,Idx(0))) return i; return switch(getName(src,i)) { case NName(n,ns): name( dst, NName( mergeString(dst,src,n), mergeNamespace(dst,src,ns) ) ); case NMulti(n,nsset): name( dst, NMulti( mergeString(dst,src,n), mergeNamespaceSet(dst,src,nsset) ) ); case NRuntime(n): name( dst, NRuntime( mergeString(dst,src,n) ) ); case NRuntimeLate: name( dst, NRuntimeLate ); case NMultiLate(nsset): name( dst, NMultiLate( mergeNamespaceSet(dst,src,nsset) ) ); case NAttrib(n): name( dst, NAttrib(n) ); throw("TODO"); case NParams(n, params): throw("TODO???"); } } private static function mergeNamespace(dst : ABCData, src : ABCData, i : Index) : Index { if(Type.enumEq(i,Idx(0))) return i; return switch(getNamespace(src,i)) { case NPrivate(ns): namespace( dst, NPrivate(mergeString(dst,src,ns)) ); case NNamespace(ns): namespace( dst, NNamespace(mergeString(dst,src,ns)) ); case NPublic(ns): namespace( dst, NPublic(mergeString(dst,src,ns)) ); case NInternal(ns): namespace( dst, NInternal(mergeString(dst,src,ns)) ); case NProtected(ns): namespace( dst, NProtected(mergeString(dst,src,ns)) ); case NExplicit(ns): namespace( dst, NExplicit(mergeString(dst,src,ns)) ); case NStaticProtected(ns): namespace( dst, NStaticProtected(mergeString(dst,src,ns)) ); } } private static function mergeNamespaceSet(dst : ABCData, src : ABCData, i : Index) : Index { if(Type.enumEq(i,Idx(0))) return i; var nsset = getNamespaceSet(src,i); var newNsset = new Array(); for(ns in nsset) newNsset.push( mergeNamespace(dst,src,ns) ); return namespaceSet( dst,newNsset ); } private static function mergeString(dst : ABCData, src : ABCData, s : Index) : Index { if(Type.enumEq(s,Idx(0))) return s; return string(dst, getString(src,s)); } public static function getNamePath(abc : ABCData, i : IName) : String { var multiname = getName(abc, i); return switch( multiname ) { case NName(n, ns): var p = getNamespaceStr(abc, ns); return (p != null && p != "" ? p + "." : "") + getString(abc, n); case NMulti(n, nsset): var nses = getNamespaceSet(abc, nsset); var str="NMulti: ["; for(ns in nses) { var p = getNamespaceStr(abc, ns); str+=p+","; } str += "]." + getString(abc, n); return str; default: //throw("Unexpected name"); return Std.string(multiname); } } public static function publicToInternalNs(abc : ABCData, i : IName) : Index { return switch( getName(abc, i) ) { case NName(_, ns): switch(getNamespace(abc, ns)) { case NPublic(ns): return namespace(abc, NInternal(ns)); default: throw("Unexpected namespace"); } default: throw("Unexpected name"); } } public static function prependOps(f : Function, ops : Array) { var oldLength = f.code.length; var o = new haxe.io.BytesOutput(); encodeOps(o, ops); o.write(f.code); f.code = o.getBytes(); var offset = f.code.length - oldLength; for(t in f.trys) { t.start += offset; t.end += offset; t.handle += offset; } } public static function appendOps(f : Function, ops : Array) { var o = new haxe.io.BytesOutput(); o.writeBytes(f.code, 0, f.code.length-1); encodeOps(o, ops); f.code = o.getBytes(); } public static function encodeOps( o : haxe.io.BytesOutput, ops : Array ) { var opWriter = new OpWriter(o); for( op in ops ) opWriter.write(op); } public static function getClassPath(abc : ABCData, classPath : String) { var pack = classPath.split("."); var className = pack.pop(); for (cl in abc.classes) { if (getNamePath(abc, cl.name) == classPath) return cl; } return null; } public static function quickMethod(abc : ABCData, cl : ClassDef, methodName : IName, ops : Array, ?kind : MethodKind, ?args : Null>, ?ret : Null, ?isOverride : Bool = false) : Function { var o = new haxe.io.BytesOutput(); // MIKE NEW: var opWriter = new OpWriter(o); for(op in ops) opWriter.write(op); var f = { type: methodType(abc, { args : args == null ? [] : args, ret : ret, extra : null }), nRegs: if(args != null) args.length + 1 else 1, initScope: 0, maxScope: 255, maxStack: 255, code: o.getBytes(), trys: [], locals: [] }; abc.functions.push(f); var field = { name: methodName, slot: 0, kind: FMethod(f.type, if(kind != null) kind else KNormal, false, isOverride), metadatas: null, }; cl.fields.push(field); return f; } } ================================================ FILE: src/com/newgrounds/swivel/swf/BitmapSmoothingMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.swf.Data; class BitmapSmoothingMutator implements ISWFMutator { public function new() { } public function mutate(swf : SwivelSwf) { swf.mapTags( forceBitmapSmoothing ); } private function setSmoothInStyles( fillStyles : Array ) { for(i in 0...fillStyles.length) { switch(fillStyles[i]) { case FSBitmap(id, matrix, smooth, repeat): if(smooth == false) fillStyles[i] = FSBitmap(id, matrix, true, repeat); default: } } } private function forceBitmapSmoothing( tag : SWFTag ) : SWFTag { switch(tag) { case TShape(id, SHDShape1(_, data)) | TShape(id, SHDShape2(_, data)) | TShape(id, SHDShape3(_, data)): setSmoothInStyles( data.fillStyles ); for(sr in data.shapeRecords) { switch(sr) { case SHRChange((change)): if((change).newStyles != null) setSmoothInStyles( change.newStyles.fillStyles ); default: } } case TShape(id, SHDShape4(data)): setSmoothInStyles( data.shapes.fillStyles ); for(sr in data.shapes.shapeRecords) { switch(sr) { case SHRChange(change): if(change.newStyles != null) setSmoothInStyles( change.newStyles.fillStyles ); default: } } default: } return tag; } } ================================================ FILE: src/com/newgrounds/swivel/swf/ISWFMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; interface ISWFMutator { function mutate(swf : SwivelSwf) : Void; } ================================================ FILE: src/com/newgrounds/swivel/swf/RenderQuality.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; enum RenderQuality { Low; Medium; High; Higher; Highest; } ================================================ FILE: src/com/newgrounds/swivel/swf/SWFRecorder.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import com.huey.events.Dispatcher; import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Loader; import flash.display.NativeWindow; import flash.display.NativeWindowInitOptions; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; import flash.events.Event; import flash.events.UncaughtErrorEvent; import flash.geom.ColorTransform; import flash.geom.Matrix; import flash.geom.Rectangle; import flash.system.LoaderContext; import flash.system.System; class SWFRecorder { private static inline var DEFAULT_WIDTH : Int = 1920; private static inline var DEFAULT_HEIGHT : Int = 1080; private static inline var WATERMARK_MARGIN : Int = 2; public var outputWidth : Int; public var outputHeight : Int; public var scaleMode : ScaleMode; public var transparentBackground : Bool; public var renderQuality : RenderQuality; public var watermark : Null; public var showWindow : Bool = false; public var currentFrame(default, null) : Int; public var onFrameCaptured : Dispatcher; public var recording(default, null) : Bool; public function new() { outputWidth = DEFAULT_WIDTH; outputHeight = DEFAULT_HEIGHT; scaleMode = crop; renderQuality = High; recording = false; transparentBackground = false; onFrameCaptured = new Dispatcher(); _maxFrameRate = switch( flash.system.Capabilities.os.split(" ")[0] ) { case "Windows": 1000; default: 30; } } private var _swf : SwivelSwf; private var _window : NativeWindow; private var _loader : Loader; private var _mask : Bitmap; private var _drawMatrix : Matrix; private var _watermarkMatrix: Matrix; private var _watermarkColorTransform : ColorTransform; private var _letterBoxRect0 : Rectangle; private var _letterBoxRect1 : Rectangle; private var _frame : BitmapData; // TODO: private var _maxFrameRate : Int; private function createWindow() { var opts = new NativeWindowInitOptions(); opts.maximizable = false; opts.resizable = false; _window = new NativeWindow(opts); _window.addEventListener(flash.events.Event.CLOSING, function(e) e.preventDefault()); _window.stage.align = StageAlign.TOP_LEFT; _window.stage.scaleMode = StageScaleMode.NO_SCALE; _window.title = "Swivel Interactive Window"; } public function startPlayback(swf : SwivelSwf, ?parameters : Dynamic) : Void { currentFrame = 0; createWindow(); _swf = swf; _window.width = _swf.width; _window.height = _swf.height; _window.stage.stageWidth = _swf.width; _window.stage.stageHeight = _swf.height; _window.stage.frameRate = if(showWindow) _swf.frameRate else _maxFrameRate; _frame = new BitmapData(outputWidth, outputHeight, transparentBackground); var scaleX = outputWidth / _swf.width; var scaleY = outputHeight / _swf.height; // create scaling matrix and letterboxes for drawing SWF _drawMatrix = new Matrix(); _letterBoxRect0 = _letterBoxRect1 = null; switch(scaleMode) { case stretchToFit: _drawMatrix.scale(scaleX, scaleY); case crop: if (scaleX > scaleY) { _drawMatrix.scale(scaleX, scaleX); _drawMatrix.translate(0, (outputHeight - scaleX * _swf.height) / 2); } else if (scaleY > scaleX) { _drawMatrix.scale(scaleY, scaleY); _drawMatrix.translate((outputWidth - scaleY * _swf.width) / 2, 0); } else _drawMatrix.scale(scaleX, scaleY); case letterbox: if (scaleX < scaleY) { _drawMatrix.scale(scaleX, scaleX); var letterBoxSize = (outputHeight - scaleX * _swf.height) / 2; _drawMatrix.translate(0, letterBoxSize); _letterBoxRect0 = new Rectangle(0, 0, outputWidth, letterBoxSize); _letterBoxRect1 = new Rectangle(0, outputHeight-letterBoxSize, outputWidth, letterBoxSize); } else if (scaleY < scaleX) { _drawMatrix.scale(scaleY, scaleY); var letterBoxSize = (outputWidth - scaleY * _swf.width) / 2; _drawMatrix.translate(letterBoxSize, 0); if(!transparentBackground) { _letterBoxRect0 = new Rectangle(0, 0, letterBoxSize, outputHeight); _letterBoxRect1 = new Rectangle(outputWidth-letterBoxSize, 0, letterBoxSize, outputHeight); } } else _drawMatrix.scale(scaleX, scaleY); } if(watermark != null && watermark.image != null) { _watermarkMatrix = new Matrix(); var watermarkW = watermark.scale * watermark.image.width; var watermarkH = watermark.scale * watermark.image.height; _watermarkMatrix.translate(-watermark.image.width/2, -watermark.image.height/2); _watermarkMatrix.scale(watermark.scale, watermark.scale); _watermarkMatrix.translate(watermarkW/2, watermarkH/2); switch(watermark.align) { case bottomLeft: _watermarkMatrix.translate(WATERMARK_MARGIN, outputHeight - watermarkH - WATERMARK_MARGIN); case bottomCenter: _watermarkMatrix.translate(outputWidth/2 - watermarkW/2, outputHeight - watermarkH - WATERMARK_MARGIN); case bottomRight: _watermarkMatrix.translate(outputWidth - watermarkW - WATERMARK_MARGIN, outputHeight - watermarkH - WATERMARK_MARGIN); case middleLeft: _watermarkMatrix.translate(WATERMARK_MARGIN, (outputHeight - watermarkH)/2); case center: _watermarkMatrix.translate((outputWidth - watermarkW)/2, (outputHeight - watermarkH)/2); case middleRight: _watermarkMatrix.translate(outputWidth - watermarkW - WATERMARK_MARGIN, (outputHeight - watermarkH)/2); case topLeft: _watermarkMatrix.translate(WATERMARK_MARGIN, WATERMARK_MARGIN); case topCenter: _watermarkMatrix.translate((outputWidth - watermarkW)/2, WATERMARK_MARGIN); case topRight: _watermarkMatrix.translate(outputWidth - watermarkW - WATERMARK_MARGIN, WATERMARK_MARGIN); } _watermarkColorTransform = new ColorTransform(1, 1, 1, watermark.alpha); } var loaderContext : LoaderContext = new LoaderContext(); loaderContext.allowCodeImport = true; if(parameters != null) loaderContext.parameters = parameters; _loader = new Loader(); // start recording after Event.INIT (first frame is loaded) _loader.contentLoaderInfo.addEventListener(Event.INIT, onSWFLoaded); _loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, function(e) { trace(e.error); e.preventDefault(); }); _loader.loadBytes(_swf.getBytes().getData(), loaderContext); _window.stage.addChild(_loader); // Flash would crash from exceptionally large frames/filters // Masking the loader to output dimensions seems to fix the problem _mask = new Bitmap( new BitmapData(_swf.width, _swf.height, false, 0) ); _window.stage.addChild(_mask); _window.x = (_window.stage.fullScreenWidth-_window.width)/2; _window.y = 0; if(showWindow) _window.activate(); } public function startRecording() { recording = true; } public function stop() : Void { recording = false; if (_loader != null) { _loader.content.mask = null; _loader.contentLoaderInfo.removeEventListener(flash.events.Event.INIT, onSWFLoaded); _loader.removeEventListener(flash.events.Event.RENDER, onSWFRender); _loader.removeEventListener(flash.events.Event.ENTER_FRAME, onSWFFrame); _loader.unloadAndStop(true); if (_loader.parent != null) _window.stage.removeChild(_loader); _loader = null; } if(_mask != null && _mask.parent != null) _mask.parent.removeChild(_mask); _mask = null; if(_window != null) { while(_window.stage.numChildren > 0) _window.stage.removeChildAt(0); if(showWindow) _window.close(); _window.stage.frameRate = 30; _window = null; } _frame = null; } private function onSWFLoaded(event : Dynamic) : Void { _loader.content.mask = _mask; _loader.contentLoaderInfo.removeEventListener(flash.events.Event.INIT, onSWFLoaded); _loader.addEventListener(flash.events.Event.ENTER_FRAME, onSWFFrame); _loader.addEventListener(flash.events.Event.RENDER, onSWFRender); // The first frame of the movie is already visible, and the events above won't fire // until next frame, so manually trigger a render immediately (#2). onSWFFrame(null); } function onSWFFrame(_) _window.stage.invalidate(); private function onSWFRender(_) : Void { _window.stage.align = StageAlign.TOP_LEFT; _window.stage.scaleMode = StageScaleMode.NO_SCALE; if(recording) { onFrameCaptured.dispatch( drawFrame() ); } currentFrame++; } private function drawFrame() : BitmapData { if (_loader == null) throw "F"; _frame.lock(); _frame.fillRect(_frame.rect, transparentBackground ? 0x00000000 : _swf.backgroundColor); // There are some weird bugs in Flash causing artifacts when drawing at high resolutions // Readding loader to stage seems to fix it (forces redraw???) _window.stage.addChild(_loader); // TODO: StageQuality.HIGH_8X8/16X16 and better seems to cause artifacts on some content. :( // If they fix this in the Flash Player, readd them to settings screen var quality = switch(renderQuality) { case Low: StageQuality.LOW; case Medium: StageQuality.MEDIUM; case High: StageQuality.BEST; case Higher: StageQuality.HIGH_8X8_LINEAR; case Highest: StageQuality.HIGH_16X16_LINEAR; } // this might need to draw loader instead of _window.stage _frame.drawWithQuality(_window.stage, _drawMatrix, null, null, null, true, quality); if (_letterBoxRect0 != null) _frame.fillRect(_letterBoxRect0, 0xff000000); if (_letterBoxRect1 != null) _frame.fillRect(_letterBoxRect1, 0xff000000); // draw watermark if(watermark != null && watermark.image != null) _frame.draw(watermark.image, _watermarkMatrix, _watermarkColorTransform, null, null, true); _frame.unlock(); return _frame; } } enum ScaleMode { crop; stretchToFit; letterbox; } ================================================ FILE: src/com/newgrounds/swivel/swf/ScaleFilterMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.swf.Data; import haxe.ds.IntMap; using com.newgrounds.swivel.swf.AbcUtils; /** * Scales all filters to match the output video size. */ class ScaleFilterMutator implements ISWFMutator { public function new(scale : Float) { this.scale = scale; } public var scale : Float; private var _filteredClips : IntMap; private var _maskClips : IntMap; private var _isAS3 : Bool; public function mutate(swf : SwivelSwf) { _isAS3 = switch(swf.avmVersion) { case AVM1: false; case AVM2: _filteredClips = new IntMap(); _maskClips = new IntMap(); true; } swf.mapClips( tweakFilters ); if(_isAS3) { for (id in _filteredClips.keys()) { if (_maskClips.get(id)) continue; swf.hoistClip(id, function(abcStuff) { var abc = abcStuff.abc; var cl = abcStuff.cl; var ctor = abc.getFunction(cl.constructor); if(ctor.maxStack < 4) ctor.maxStack = 4; if(ctor.maxScope < 4) ctor.maxScope = 4; ctor.prependOps([ OGetLex( abc.publicName("__Swivel") ), OThis, OFloat( abc.float( _filteredClips.get(id) ) ), OCallPropVoid( abc.publicName("setMask"), 2 ) ]); } ); } } } private function tweakFilters(id : Int, tags : Array) : Array { var curClips = new IntMap(); for(i in 0...tags.length) { var tag = tags[i]; switch(tag) { case TPlaceObject2(po): if (po.cid != null) curClips.set(po.depth, po.cid); if (po.clipDepth != null) _maskClips.set(po.cid, true); case TPlaceObject3(po): if (po.cid != null) curClips.set(po.depth, po.cid); if (po.clipDepth != null) _maskClips.set(po.cid, true); if (po.filters != null || po.bitmapCache != null) { var margin = 0.0; if(po.filters != null) { for (filter in po.filters) { switch (filter) { case FBlur(data): data.blurX = Std.int(data.blurX * scale); data.blurY = Std.int(data.blurY * scale); //data.passes = 3; margin = Math.max(margin, data.blurX/0x00010000+1); margin = Math.max(margin, data.blurY/0x00010000+1); case FGradientGlow(data), FGradientBevel(data): data.data.blurX = Std.int(data.data.blurX * scale); data.data.blurY = Std.int(data.data.blurY * scale); data.data.distance = Std.int(data.data.distance * scale); //data.data.flags.passes = 3; var dist = Math.abs(data.data.distance/0x00010000) + 1; margin = Math.max(margin, data.data.blurX + dist); margin = Math.max(margin, data.data.blurY + dist); case FDropShadow(data), FGlow(data), FBevel(data): data.blurX = Std.int(data.blurX * scale); data.blurY = Std.int(data.blurY * scale); data.distance = Std.int(data.distance * scale); //data.strength = Std.int(data.strength * scale); //data.flags.passes = 3; var dist = Math.abs(data.distance/0x00010000) + 1; margin = Math.max(margin, data.blurX/0x00010000 + dist); margin = Math.max(margin, data.blurY/0x00010000 + dist); default: } } } if(_isAS3) { _filteredClips.set(curClips.get(po.depth), margin); } else { if(po.events == null) po.events = new Array(); po.events.push( { eventsFlags: 1, data: com.newgrounds.swivel.swf.SwivelSwf.getAvm1Bytes([ APush( [PFloat(margin), PString("this")] ), AEval, APush( [PInt(2), PString("__createMask")] ), ACall, APop, ]), } ); } } default: } } return tags; } } ================================================ FILE: src/com/newgrounds/swivel/swf/SilenceSoundMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.swf.Data; class SilenceSoundMutator implements ISWFMutator { public function new() { } public function mutate(swf : SwivelSwf) : Void { swf.mapTags(removeSounds); } private function removeSounds(tag : SWFTag) : SWFTag { switch(tag) { case TStartSound(_,_), TSoundStream(_), TSoundStreamBlock(_): return null; default: return tag; } } } ================================================ FILE: src/com/newgrounds/swivel/swf/SoundConnectionMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import com.newgrounds.swivel.audio.AudioTracker; import format.as1.Data; import format.swf.Data; import haxe.Int32; import haxe.ds.IntMap; import haxe.io.Bytes; import haxe.io.BytesOutput; /** * Tracks sounds playing in an SWF using LocalConnection. */ class SoundConnectionMutator implements ISWFMutator { public var connectionName : String; private var _audioTracker : AudioTracker; private var _streamId : Int; private var _clipClasses : IntMap; public function new(connectionName : String, audioTracker : AudioTracker) { this.connectionName = connectionName; _audioTracker = audioTracker; _streamId = 0; _clipClasses = new IntMap(); } public function mutate(swf : SwivelSwf) : Void { swf.mapClips(injectSoundLogging); finalize(swf); } private function injectSoundLogging(id : Int, tags : Array) : Array { var stream : SoundStream = null; var streamFrame : Int = 0; var i : Int = 0; var streamData : Array = null; var currentStreamPacket : BytesOutput = null; var frame : Int = 0; var lastStreamData : Int = 0; function finalizeStream() { if(stream == null || streamData == null) return; if (currentStreamPacket != null) streamData.push(currentStreamPacket.getBytes()); // FIX for dolphinn.swf if(streamData[0].length > 0) { _audioTracker.registerSound({ id: com.newgrounds.swivel.audio.SoundClip.SoundClipId.stream(_streamId), format: stream.streamFormat, is16bit: stream.streamIs16bit, isStereo: stream.streamIsStereo, sampleRate: stream.streamRate, numSamples: null, // stream.samples, MIKE: stream sounds were getting truncated weirdly!? latencySeek: stream.seek, data: streamData }); } _streamId++; currentStreamPacket = null; streamData = null; streamFrame = 0; } while(i < tags.length) { var tag = tags[i]; switch(tag) { case TSound(sound): _audioTracker.registerSound( { id: event(sound.sid), format: sound.format, is16bit: sound.is16bit, isStereo: sound.isStereo, sampleRate: sound.rate, numSamples: sound.samples, latencySeek: switch(sound.data) { case SDMp3(seek, _): seek; default: 0; }, data: switch(sound.data) { case SDMp3(_, d): [d]; case SDRaw(d): [d]; case SDOther(d): [d]; }, }); case TStartSound(soundId, infos): var newTag = handleStartSound(id, frame, soundId, infos); if(newTag != null) tags[i] = newTag; case TSoundStream(streamInfo): stream = streamInfo; case TSymbolClass(links): for(link in links) { _clipClasses.set(link.cid, link.className); var sound = _audioTracker.getSound(event(link.cid)); if(sound != null) { _audioTracker.registerSound({ id: actionScript(link.className), format: sound.format, is16bit: sound.is16bit, isStereo: sound.isStereo, sampleRate: sound.sampleRate, latencySeek: sound.latencySeek, numSamples: sound.numSamples, data: sound.data, }); } } case TExport(exports): for(e in exports) { var sound = _audioTracker.getSound(event(e.cid)); if(sound != null) { _audioTracker.registerSound({ id: actionScript(e.name), format: sound.format, is16bit: sound.is16bit, isStereo: sound.isStereo, sampleRate: sound.sampleRate, latencySeek: sound.latencySeek, numSamples: sound.numSamples, data: sound.data, }); } } case TShowFrame: if(stream != null && streamData != null && lastStreamData >= frame-4) { var newTag = handleStreamFrame(id, frame, _streamId, streamFrame); if(newTag != null) { tags.insert(i, newTag); i++; } streamFrame++; } frame++; case TSoundStreamBlock(data): if(streamData == null || lastStreamData < frame-1) { finalizeStream(); streamData = []; } lastStreamData = frame; switch(stream.streamFormat) { case SFMP3: if (currentStreamPacket == null) currentStreamPacket = new BytesOutput(); if(data.length >= 4) currentStreamPacket.writeBytes(data, 4, data.length - 4); case SFADPCM: streamData.push(data); default: if (currentStreamPacket == null) currentStreamPacket = new BytesOutput(); currentStreamPacket.write(data); } default: }; i++; } finalizeStream(); return tags; } private function handleStartSound(clipId : Int, frame : Int, soundId : Int, infos : StartSoundInfo) : SWFTag { var envelope = []; var len = 0; if(infos.envelope != null) { for (point in infos.envelope) { envelope.push( PInt(point.pos) ); envelope.push( PInt(point.leftVolume) ); envelope.push( PInt(point.rightVolume) ); len += 3; } } envelope.reverse(); envelope.push( PInt( len ) ); var sync = if( infos.stop ) 2 else if( infos.noMultiple ) 1 else 0; return TDoActions( SwivelSwf.getAvm1Bytes([ APush( envelope ), AInitArray, APush([ PInt( infos.numLoops ), if( infos.endPos != null ) PInt( infos.endPos ) else PNull, if( infos.startPos != null ) PInt( infos.startPos ) else PNull, PInt( sync ), PInt( soundId ), PInt( 0 ), PString("__getFrame"), ]), ACall, APush( [PString("startSound"), PInt(8), PString("__swivel")] ), ACall, APop ]) ); } private function handleStreamFrame(clipId : Int, clipFrame : Int, streamId : Int, streamFrame : Int) : SWFTag { return TDoActions( SwivelSwf.getAvm1Bytes([ APush([ PInt( streamFrame ), PInt( streamId ), PInt( 0 ), PString("__getFrame"), ]), ACall, APush( [PString("streamSound"), PInt(4), PString("__swivel")] ), ACall, APop, ]) ); } private function finalize(swf : SwivelSwf) { swf.prepend(SwfUtils.getAs2Tag("AS2SoundLogger")); } } ================================================ FILE: src/com/newgrounds/swivel/swf/SwfUtils.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.abc.Data; import format.as1.Data; import format.swf.Data; import haxe.ds.IntMap; import haxe.io.BytesInput; import haxe.io.BytesOutput; import haxe.Resource; import haxe.macro.Expr; class SwfUtils { macro public static function getAs2Tag(resourceName, ?params) { var name = switch(resourceName.expr) { case EConst(c): switch(c) { case CString(s): s; default: null; } default: null; } haxe.macro.Context.addResource(name, sys.io.File.getBytes('assets/inject_swfs/$name.swf')); return macro com.newgrounds.swivel.swf.SwfUtils._getAs2Tag($resourceName, $params); } macro public static function getAs3Tag(resourceName, ?i) { var name = switch(resourceName.expr) { case EConst(c): switch(c) { case CString(s): s; default: null; } default: null; } haxe.macro.Context.addResource(name, sys.io.File.getBytes('assets/inject_swfs/$name.swf')); return macro com.newgrounds.swivel.swf.SwfUtils._getAs3Tag($resourceName, $i); } macro public static function getClip(resourceName, clipName) { var name = switch(resourceName.expr) { case EConst(c): switch(c) { case CString(s): s; default: null; } default: null; } haxe.macro.Context.addResource(name, sys.io.File.getBytes('assets/inject_swfs/$name.swf')); return macro com.newgrounds.swivel.swf.SwfUtils._getClip($resourceName, $clipName); } #if !macro private static function getSwf(resourceName : String) : SWF { var bytes = Resource.getBytes(resourceName); if(bytes == null) throw("Could not find resource " + resourceName); var i = new BytesInput(bytes); var swf = new format.swf.Reader(i).read(); return swf; } public static function _getAs2Tag(resourceName, ?params : Null) : SWFTag { var swf = getSwf(resourceName); for(tag in swf.tags) { switch(tag) { case TDoActions(data): if(params != null) { var i = new BytesInput(data); var as1 = new format.as1.Reader(i).read(); for(key in Reflect.fields(params)) { as1 = [ APush( [PString("_global")] ), AEval, APush( [PString("$"+key), PFloat( Reflect.field(params, key) )] ), AObjSet, ].concat(as1); } var o = new BytesOutput(); new format.as1.Writer(o).write(as1); return TDoActions(o.getBytes()); } else return tag; default: } } throw("AS2 Data not found in " + resourceName); } public static function _getClip(resourceName : String, clipName : String) : SWFTag { var swf = getSwf(resourceName); var clips = new IntMap(); for(tag in swf.tags) { switch(tag) { case TClip(id, frames, tags): clips.set(id, tag); case TExport(links): for(link in links) if(link.name == clipName) return clips.get(link.cid); default: } } return null; } public static function _getAs3Tag(resourceName : String, ?i : Int = 0) { var swf = getSwf(resourceName); for(tag in swf.tags) { switch(tag) { case TActionScript3(data, _): if(i > 0) { i--; continue; } var reader = new format.abc.Reader(new BytesInput(data)); return {tag: tag, abc: reader.read()}; default: } } throw("AS3 Data not found in " + resourceName); return null; } #end /*public function mutateAs3(tag : SWFTag, f : ABCData -> Void) : SWFTag { switch(tag) { case TActionScript3(data): var abc = new format.abc.Reader( new BytesInput(data) ).read(); f(abc); var o = new BytesOutput(); new format.abc.Writer(o).write(abc); return TActionScript3(o.getBytes()); default: throw("Not an AS3 tag"); } }*/ } ================================================ FILE: src/com/newgrounds/swivel/swf/SwivelAbcContext.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.abc.Context; /* class SwivelAbcContext extends Context { public static function fromData(d : ABCData) { var context = new SwivelAbcContext(); context.bytepos = new NullOutput(); contextopw = new OpWriter(bytepos); hstrings = new Hash(); data = new ABCData(); data.ints = new Array(); data.uints = new Array(); data.floats = new Array(); data.strings = new Array(); data.namespaces = new Array(); data.nssets = new Array(); data.metadatas = new Array(); data.methodTypes = new Array(); data.names = new Array(); data.classes = new Array(); data.functions = new Array(); emptyString = string(""); nsPublic = namespace(NPublic(emptyString)); arrayProp = name(NMultiLate(nsset([nsPublic]))); beginFunction([],null); ops([OThis,OScope]); init = curFunction; init.f.maxStack = 2; init.f.maxScope = 2; classes = new Array(); data.inits = [{ method : init.f.type, fields : classes }]; } public var replaceMode : ReplaceMode; public function new() { replaceMode = overwrite; super(); } public function beginStatics() { if (curClass.statics != null) replaceFunction( data.get(data.functions, cast(curClass.statics)) ); else { beginFunction([], null); curClass.statics = curFunction.f.type; } return curFunction.f; } override public function beginClass( path : String ) { endClass(); var tpath = this.type(path); for (cl in data.classes) { if (Type.enumEq(tpath, cl.name)) { curClass = cl; break; } } if (curClass != null) { fieldSlot = curClass.fields.length + curClass.staticFields.length + 1; } else { beginFunction([],null); var st = curFunction.f.type; op(ORetVoid); endFunction(); beginFunction([],null); var cst = curFunction.f.type; curFunction.f.maxStack = 1; op(OThis); op(OConstructSuper(0)); op(ORetVoid); endFunction(); fieldSlot = 1; curClass = { name : tpath, superclass : this.type("Object"), interfaces : [], isSealed : false, isInterface : false, isFinal : false, namespace : null, constructor : cst, statics : st, fields : [], staticFields : [], }; data.classes.push(curClass); classes.push({ name: tpath, slot: 0, kind: FClass(Idx(data.classes.length - 1)), metadatas: null, }); } curFunction = null; return curClass; } override public function endClass() { if( curClass == null ) return; endFunction(); curFunction = null; curClass = null; } public override function finalize() { endClass(); replaceMode = overwrite; if (init == null) beginFunction([], null); else replaceFunction( init.f ); init = curFunction; init.f.maxStack = 2; init.f.maxScope = 2; ops([OThis, OScope]); for (cl in data.classes) { ops([ OGetGlobalScope, OGetLex( curClass.superclass ), OScope, OGetLex( curClass.superclass ), OClassDef( Idx(data.classes.length - 1) ), OPopScope, OInitProp( curClass.name ), ]); } op(ORetVoid); endFunction(); curClass = null; } override public function beginConstructor(args) { if (curClass.constructor != null) replaceFunction( data.get(data.functions, cast(curClass.constructor)) ); else { beginFunction(args, null); curClass.constructor = curFunction.f.type; } return curFunction.f; } override public function beginMethod( mname : String, targs, tret, ?isStatic, ?isOverride, ?isFinal ) { var fl = if ( isStatic ) curClass.staticFields else curClass.fields; for (field in fl) { switch( data.get(data.names, field.name) ) { case NName(n, _): if (data.get(data.strings, n) == mname) { switch(field.kind) { case FMethod(type,_,_,_): replaceFunction( data.get(data.functions, cast(type)) ); return curFunction.f; default: throw("Unexpected field!"); } } default: throw("Unexpected field name!"); } } var m = beginFunction(targs,tret); fl.push({ name : property(mname), slot : 0, kind : FMethod(curFunction.f.type,KNormal,isFinal,isOverride), metadatas : null, }); return curFunction.f; } function replaceFunction(f) { endFunction(); curFunction = { f : f, ops : [] }; registers = new Array(); for( x in 0...f.nRegs ) registers.push(true); return f; } override function endFunction() { if( curFunction == null ) return; var old = opw.o; var bytes = new haxe.io.BytesOutput(); opw.o = bytes; for( op in curFunction.ops ) opw.write(op); switch(replaceMode) { case overwrite: curFunction.f.code = bytes.getBytes(); case prepend: if (curFunction.f.code != null) bytes.write(curFunction.f.code); curFunction.f.code = bytes.getBytes(); case append: var newBytes = new haxe.io.BytesOutput(); if (curFunction.f.code != null) newBytes.write(curFunction.f.code); newBytes.write(bytes.getBytes()); curFunction.f.code = newBytes.getBytes(); } opw.o = old; curFunction = null; } } enum ReplaceMode { overwrite; prepend; append; }*/ ================================================ FILE: src/com/newgrounds/swivel/swf/SwivelConnection.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import com.huey.events.Dispatcher; import com.newgrounds.swivel.audio.AudioTracker; import flash.net.LocalConnection; import flash.net.SharedObject; import haxe.Int32; interface ISwivelConnection { public var client(get, set) : Dynamic; public function tick() : Void; public function close() : Void; } class SwivelConnection implements ISwivelConnection { public static inline var CONNECTION_NAME : String = "__swivel"; private var _inConnection : LocalConnection; public var client(get, set) : Dynamic; private function get_client() : Dynamic { return _inConnection.client; } private function set_client(v : Dynamic) : Dynamic { return _inConnection.client = v; } public function new() { _inConnection = new LocalConnection(); // TODO: output better error msg here _inConnection.addEventListener(flash.events.AsyncErrorEvent.ASYNC_ERROR, function(e) {} ); _inConnection.connect(CONNECTION_NAME); } public function tick() : Void { } public function close() : Void { try { _inConnection.close(); } catch(_ : Dynamic) { } } } ================================================ FILE: src/com/newgrounds/swivel/swf/SwivelMutator.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.abc.Context; import format.abc.Data; import format.swf.Data; import format.as1.Data; import haxe.Int32; using com.newgrounds.swivel.swf.AbcUtils; class SwivelMutator implements ISWFMutator { public function new(?startFrame : Int = 0) { _startFrame = startFrame; } public function mutate(swf : SwivelSwf) : Void { swf.compression = SCUncompressed; // Set our SWF version is at least version 6 so that our various AS will work // (maybe this could break some things, since AS2 is case-sensitive, but AS1 isn't?) if (swf.version < 6) swf.version = 6; if(Type.enumEq(swf.avmVersion, AVM1)) { swf.prepend(SwfUtils.getAs2Tag("AS2Basics", {width: swf.width, height: swf.height, frameRate: swf.frameRate})); var clip = SwfUtils.getClip("AS2Basics", "__FrameCounter"); var clipDepth = 9999; switch(clip) { case TClip(_, frames, tags): clip = TClip(clipDepth, frames, tags); default: throw("Bad clip"); } swf.prepend(clip); var po = new PlaceObject(); po.cid = clipDepth; swf.prepend( TPlaceObject2(po) ); var i=0; //swf.prepend(TDoActions( SwivelSwf.getAvm1Bytes([AGotoFrame(_startFrame), APlay]))); var f = 0; while(i < swf.tags.length) { switch(swf.tags[i]) { case TUnknown(id, _): // get rid of debug tags... causing super weird problems in AS2 movies if(id == 63 || id == 64) { swf.tags.splice(i,1); i--; } case TShowFrame: if(_startFrame == 0) break; if(f==0) { swf.tags.insert(i, TDoActions( SwivelSwf.getAvm1Bytes([AGotoFrame(_startFrame), APlay])) ); i++; } else if(f==_startFrame) { swf.tags.insert(i, TDoActions( SwivelSwf.getAvm1Bytes([APlay])) ); break; } f++; default: } i++; } } else { for(i in 0...swf.tags.length) { var tag = swf.tags[i]; switch(tag) { case TActionScript3(data, c): var abc = new format.abc.Reader(new haxe.io.BytesInput(data)).read(); var altered = false; for(j in 0...abc.strings.length) { var str = abc.strings[j]; if(str == "exactFit" || str == "noBorder" || str == "showAll") { abc.strings[j] = "noScale"; altered = true; } else if(str == "EXACT_FIT" || str == "NO_BORDER" || str == "SHOW_ALL") { abc.strings[j] = "NO_SCALE"; altered = true; } } if(altered) { var o = new haxe.io.BytesOutput(); new format.abc.Writer(o).write(abc); swf.tags[i] = TActionScript3(o.getBytes(), c); } default: } } swf.prepend( SwfUtils.getAs3Tag("AS3Core", 0).tag ); swf.hoistClip(0, function(abcStuff) { var abc = abcStuff.abc; var cl = abcStuff.cl; var ctor = abc.getFunction(cl.constructor); if(ctor.maxStack < 4) ctor.maxStack = 4; if(ctor.maxScope < 4) ctor.maxScope = 4; /*if(_startFrame != 0) { ctor.appendOps([ OThis, OInt(_startFrame), OCallPropVoid( abc.publicName("gotoAndPlay"), 1), ORetVoid, ]); }*/ ctor.prependOps([ OGetLex( abc.publicName("__Swivel") ), OThis, OInt( _startFrame+1 ), OCallPropVoid( abc.publicName("registerDocument"), 2) ]); abc.quickMethod(cl, abc.publicName("stage"), [ OGetLex( abc.publicName("__Swivel") ), OGetProp( abc.publicName("stage") ), ORet, ], KGetter, null, abc.type("flash.display.Stage"), true); }); return; } } private var _startFrame : Int; } ================================================ FILE: src/com/newgrounds/swivel/swf/SwivelSwf.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.abc.Data; import format.as1.Data; import format.swf.Data; import format.swf.Reader; import format.swf.Writer; import haxe.io.Bytes; import haxe.io.BytesInput; import haxe.io.BytesOutput; using com.newgrounds.swivel.swf.AbcUtils; typedef ABCStuff = {abc : ABCData, cl : ClassDef, tagIndex : Int, extra : AS3Context}; class SwivelSwf { public static function getAvm1Bytes( actions : AS1 ) : Bytes { var o = new BytesOutput(); var writer = new format.as1.Writer(o); writer.write(actions); return o.getBytes(); } public var version(get_version, set_version) : Int; inline private function get_version() { return _header.version; } inline private function set_version(v) { return _header.version = v; } public var avmVersion(default, set_avmVersion) : AVM; private function set_avmVersion(v) { if(version < 8 || _fileAttributesIndex < 0) { return avmVersion = v; } if(version < 9 && Type.enumEq(v, AVM2)) throw("AVM2 requires SWF version 9 or higher"); // MIKNEW _headerTags[_fileAttributesIndex] = switch(_headerTags[_fileAttributesIndex]) { case TSandBox(useDirectBlit, useGpu, hasMeta, useAs3, useNetwork): TSandBox(useDirectBlit, useGpu, hasMeta, v == AVM2, useNetwork); default: throw("Unexpected tag"); } return avmVersion = v; } public var abcData(default, null) : ABCData; public var compression(get, set) : SWFCompression; inline private function get_compression() { return _header.compression; } inline private function set_compression(v) { return _header.compression = v; } public var width(get, set) : Int; inline private function get_width() { return _header.width; } inline private function set_width(v) { return _header.width = v; } public var height(get, set) : Int; inline private function get_height() { return _header.height; } inline private function set_height(v) { return _header.height = v; } public var frameRate(get, set) : Float; inline private function get_frameRate() { return _header.fps / 256.0; } inline private function set_frameRate(v : Float) { _header.fps = Std.int(v * 256.0); return v; } @:isVar public var backgroundColor(get, set) : Int; inline private function get_backgroundColor() { return backgroundColor; } inline private function set_backgroundColor(v) { return backgroundColor = v; } @bindable public var numFrames(default, set) : Int; inline private function set_numFrames(v) { return numFrames = _header.nframes = v; } private var _header : SWFHeader; private var _data: Bytes; private var _headerTags : Array; public var tags : Array; private var _parsed : Bool = false; private var _startIndex : Int; // index after SetBackground tag private var _fileAttributesIndex : Int = -1; public function new(data : Bytes) { var partialSwf = new SwivelSwfReader( new BytesInput(data) ).readPartial(); _header = partialSwf.header; numFrames = _header.nframes; _headerTags = partialSwf.tags; tags = []; _data = partialSwf.data; avmVersion = AVM1; var i = 0; for (t in _headerTags) { switch(t) { case TSandBox(_, _, _, useAs3, _): // MIKENEW _fileAttributesIndex = i; avmVersion = if(useAs3) AVM2 else AVM1; case TBackgroundColor(color): backgroundColor = color; default: } i++; } _startIndex = 0; } public function parseSwf() { var reader = new SwivelSwfReader( new BytesInput(_data) ); untyped reader.version = _header.version; var newTags = reader.readTagList(); _startIndex = _headerTags.length; tags = _headerTags.concat(newTags); _parsed = true; } private var _clipNum : Int = 0; public function hoistClip(clipId : Int, f : ABCStuff -> Void) { var clipIndex = 0; var i = 0; for(tag in tags) { switch(tag) { case TSymbolClass(links): for(link in links) { if(link.cid == clipId) { var clipStuff = getAbcWithClass(link.className); var clipAbc = clipStuff.abc; f(clipStuff); var o = new BytesOutput(); new format.abc.Writer(o).write(clipAbc); tags[clipStuff.tagIndex] = TActionScript3(o.getBytes(), clipStuff.extra); return; } } case TClip(id,_,_): if(clipId == id) clipIndex = i+1; default: } i++; } var ctx = new format.abc.Context(); var className = '__SwivelClip$_clipNum'; var cl = ctx.beginClass(className); cl.isSealed = false; cl.superclass = ctx.type("flash.display.MovieClip"); _clipNum++; ctx.endClass(); ctx.finalize(); var abc = ctx.getData(); f({abc:ctx.getData(), cl:abc.classes[0], tagIndex:0, extra:null}); var o = new BytesOutput(); new format.abc.Writer(o).write(abc); var tag = TActionScript3(o.getBytes(), null); // insert new AS3 tag in proper location //prepend(tag); if(clipId == 0) { clipIndex = _startIndex; _startIndex+=2; } else if(clipIndex == 0) return; //tags.insert(clipIndex, TSymbolClass([ {cid: clipId, className: className} ])); tags.insert(clipIndex, tag); tags.insert(clipIndex+1, TSymbolClass([ {cid: clipId, className: className} ])); } /*public function hoistClip2(clipId : Int, f : ABCStuff -> Void) { var newClassName = '__SwivelClip$_clipNum'; _clipNum++; var ctx = new format.abc.Context(); var cl = ctx.beginClass(className); cl.isSealed = false; cl.superclass = ctx.type("flash.display.MovieClip"); ctx.endClass(); ctx.finalize(); var abc = ctx.getData(); f({abc:ctx.getData(), cl:abc.classes[0], tagIndex:0, extra:null}); var clipIndex = 0; var i = 0; for(tag in tags) { switch(tag) { case TSymbolClass(links): for(link in links) { if(link.cid == clipId) { var clipStuff = getAbcWithClass(link.className); var clipAbc = clipStuff.abc; cl.superclass = ctx.type(clipStuff.cl.name); clipStuff.cl.name = clipAbc.publicName(newClassName); f(clipStuff); var o = new BytesOutput(); new format.abc.Writer(o).write(clipAbc); tags[clipStuff.tagIndex] = TActionScript3(o.getBytes(), clipStuff.extra); return; } } case TClip(id,_,_): if(clipId == id) clipIndex = i+1; default: } i++; } var o = new BytesOutput(); new format.abc.Writer(o).write(abc); var tag = TActionScript3(o.getBytes(), null); // insert new AS3 tag in proper location //prepend(tag); if(clipId == 0) { clipIndex = _startIndex; _startIndex+=2; } else if(clipIndex == 0) return; //tags.insert(clipIndex, TSymbolClass([ {cid: clipId, className: className} ])); tags.insert(clipIndex, tag); tags.insert(clipIndex+1, TSymbolClass([ {cid: clipId, className: className} ])); }*/ private function getAbcWithClass(className : String) : ABCStuff { var i = 0; for(tag in tags) { switch(tag) { case TActionScript3(data, extra): var abc = new format.abc.Reader(new BytesInput(data)).read(); for(cl in abc.classes) { if(abc.getNamePath(cl.name) == className) { return {abc: abc, cl: cl, tagIndex: i, extra: extra}; } } default: } i++; } return null; } public function prepend(tag : SWFTag) : Void { tags.insert(_startIndex++, tag); } public function mapTags(f : SWFTag -> SWFTag) : Void { tags = _mapTags(f, tags); } private function _mapTags(f : SWFTag -> SWFTag, tags : Array) : Array { var newTags = new Array(); for (tag in tags) { switch(tag) { case TClip(id, frames, tags): var t = f(tag); if (t != null) { if (Type.enumEq(t, tag)) newTags.push( TClip(id, frames, _mapTags(f, tags)) ); else newTags.push(t); } default: var t = f(tag); if (t != null) newTags.push(t); } } return newTags; } public function mapClips(f : Int -> Array -> Array) : Void { f(0, tags); for (tag in tags) { switch(tag) { case TClip(id, _, tags): f(id, tags); default: } } } public function getBytes() : Bytes { var o = new haxe.io.BytesOutput(); var writer = new Writer( o ); if(_parsed) writer.write( {header: _header, tags: tags} ); else { writer.writeHeader(_header); for(t in _headerTags) writer.writeTag(t); for(t in tags) writer.writeTag(t); untyped writer.o.write(_data); writer.writeEnd(); } return o.getBytes(); } public function disposeTags() { _parsed = false; tags = []; _startIndex = 0; } public function clone() : SwivelSwf { var swf = Type.createEmptyInstance(SwivelSwf); swf.tags = []; swf._headerTags = _headerTags.copy(); swf._header = { version: _header.version, compression: _header.compression, width: _header.width, height: _header.height, fps: _header.fps, nframes: _header.nframes, } swf.backgroundColor = backgroundColor; swf._data = _data; swf._parsed = false; swf._startIndex = _startIndex; swf._fileAttributesIndex = _fileAttributesIndex; return swf; } } enum AVM { AVM1; AVM2; } ================================================ FILE: src/com/newgrounds/swivel/swf/SwivelSwfReader.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; import format.swf.Constants; import format.swf.Data; import format.swf.Reader; import haxe.io.BytesInput; class SwivelSwfReader extends format.swf.Reader { public function new(i : BytesInput) { bits = new format.tools.BitsInput(i); super(i); } public function readPartial() { var header = readHeader(); var tags = new Array(); while(true) { var tag = readTag(); tags.push(tag); switch(tag) { case TSandBox(_): case TBackgroundColor(_): break; default: } } return {header: header, tags: tags, data: i.readAll() }; } // TODO: repeated from SWFReader, to not throw on some incorrect-ish SWF files // Is there a way we can avoid repeating this? /* MIKE TODO 2017: Reintegrate the below, or just change it directly in our format fork. override public function readHeader() : SWFHeader { var tag = i.readString(3); var compression; if( tag == "ZWS" ) compression = SCLZMA; else if( tag == "CWS" ) compression = SCDeflate; else if( tag == "FWS" ) compression = SCUncompressed; else throw error(); version = i.readByte(); var size = readInt(); switch( compression ) { case SCLZMA: throw "LZMA is unsupported"; case SCDeflate: var bytes = format.tools.Inflate.run(i.readAll()); if( bytes.length + 8 != size ) trace("Compressed data length is incorrect"); i = new haxe.io.BytesInput(bytes); case SCUncompressed: } bits = new format.tools.BitsInput(i); var r = readRect(); if( r.left != 0 || r.top != 0 ) throw error(); var fps = readFixed8(); var nframes = i.readUInt16(); return { version : version, compression : compression, width : Std.int(r.right/20), height : Std.int(r.bottom/20), fps : fps, nframes : nframes, }; } override private function readTagData(id,len) : SWFTag { var startPos = untyped i.b.position; var tag = super.readTagData(id, len); // Assert here var endPos = untyped i.b.position; if(len != endPos - startPos) { #if debug trace("Bad tag!"); #end untyped i.b.position = startPos + len; } return tag; } */ } ================================================ FILE: src/com/newgrounds/swivel/swf/Watermark.hx ================================================ /* * Swivel * Copyright (C) 2012-2017, Newgrounds.com, Inc. * https://github.com/Herschel/Swivel * * Swivel 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 3 of the License, or * (at your option) any later version. * * Swivel 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 Swivel. If not, see . */ package com.newgrounds.swivel.swf; typedef Watermark = { var image : flash.display.BitmapData; var align : WatermarkAlign; var alpha : Float; var scale : Float; } enum WatermarkAlign { topLeft; topCenter; topRight; middleLeft; center; middleRight; bottomLeft; bottomCenter; bottomRight; } ================================================ FILE: win-installer.nsi ================================================ ;NSIS Modern User Interface ;Welcome/Finish Page Example Script ;Written by Joost Verburg ;-------------------------------- ;Include Modern UI !include "MUI2.nsh" ;-------------------------------- ;General ;Name and file Name "Swivel" OutFile "swivel-win32.exe" ;Default installation folder InstallDir "$PROGRAMFILES\Swivel" ;Get installation folder from registry if available InstallDirRegKey HKCU "Software\Swivel" "" ;Request application privileges for Windows Vista RequestExecutionLevel admin SetCompressor /SOLID /FINAL lzma ;-------------------------------- ;Variables Var StartMenuFolder Function createDestkopIcon CreateShortcut "$DESKTOP\Swivel.lnk" "$INSTDIR\Swivel.exe" FunctionEnd ;-------------------------------- ;Interface Settings !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_BITMAP "assets\WinInstallerHeader.bmp" !define MUI_ABORTWARNING ;-------------------------------- ;Pages !insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_LICENSE "LICENSE.md" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Swivel" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder !insertmacro MUI_PAGE_INSTFILES !define MUI_FINISHPAGE_RUN "$INSTDIR\Swivel.exe" !define MUI_FINISHPAGE_SHOWREADME "" !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut" !define MUI_FINISHPAGE_SHOWREADME_FUNCTION createDestkopIcon !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_WELCOME !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_UNPAGE_FINISH ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Installer Sections Section "Swivel" SecSwivel SetOutPath "$INSTDIR" File /r bin\Swivel\* ;Store installation folder WriteRegStr HKCU "Software\Swivel" "" $INSTDIR ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application SetShellVarContext all ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Swivel.lnk" "$INSTDIR\Swivel.exe" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END ;Add/Remove Programs WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "DisplayName" "Swivel" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "DisplayIcon" "$\"$INSTDIR\Swivel.exe$\"" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "Publisher" "Newgrounds.com, Inc." WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "HelpLink" "http://www.newgrounds.com" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "DisplayVersion" "1.11" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "VersionMajor" "1" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "VersionMinor" "11" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "NoModify" "1" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "NoRepair" "1" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "EstimatedSize" "61440" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" \ "Comments" "SWF to video convertor" SectionEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_SecSwivel ${LANG_ENGLISH} "Swivel" ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SecSwivel} $(DESC_SecSwivel) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" ;ADD YOUR OWN FILES HERE... Delete "$INSTDIR\Uninstall.exe" RMDir /r "$INSTDIR" !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder SetShellVarContext all Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Swivel.lnk" RMDir /r "$SMPROGRAMS\$StartMenuFolder" DeleteRegKey /ifempty HKCU "Software\Swivel" DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Swivel" SectionEnd