├── .gitattributes ├── .github └── workflows │ └── CI.yml ├── .gitignore ├── AviSynth ├── LICENSE ├── LSMASHSourceVCX.sln ├── LSMASHSourceVCX.vcxproj ├── LSMASHSourceVCX.vcxproj.filters ├── README ├── audio_output.cpp ├── audio_output.h ├── exlibs.cpp ├── libavsmash_source.cpp ├── libavsmash_source.h ├── lsmashsource.cpp ├── lsmashsource.h ├── lwlibav_source.cpp ├── lwlibav_source.h ├── meson.build ├── vcxcompat.props ├── video_output.cpp └── video_output.h ├── AviUtl ├── GNUmakefile ├── LICENSE ├── README ├── README.ja ├── audio_output.c ├── audio_output.h ├── avs_input.c ├── color.h ├── colorspace.c ├── colorspace.h ├── colorspace_simd.c ├── colorspace_simd.h ├── configure ├── dummy_input.c ├── filter.h ├── input.h ├── libavsmash_input.c ├── lwcolor.c ├── lwcolor.h ├── lwcolor_simd.c ├── lwcolor_simd.h ├── lwdumper.c ├── lwinput.c ├── lwinput.h ├── lwinput.rc ├── lwlibav_input.c ├── lwmuxer.c ├── lwmuxer.rc ├── progress_dlg.c ├── progress_dlg.h ├── resource.h ├── video_output.c ├── video_output.h └── vpy_input.c ├── VapourSynth ├── LICENSE ├── README ├── libavsmash_source.c ├── lsmashsource.c ├── lsmashsource.h ├── lwlibav_source.c ├── meson.build ├── meson_options.txt ├── version.h.in ├── video_output.c └── video_output.h ├── common ├── audio_output.c ├── audio_output.h ├── cpp_compat.h ├── decode.c ├── decode.h ├── libavsmash.c ├── libavsmash.h ├── libavsmash_audio.c ├── libavsmash_audio.h ├── libavsmash_audio_internal.h ├── libavsmash_video.c ├── libavsmash_video.h ├── libavsmash_video_internal.h ├── lwindex.c ├── lwindex.h ├── lwindex_version.h ├── lwlibav_audio.c ├── lwlibav_audio.h ├── lwlibav_audio_internal.h ├── lwlibav_dec.c ├── lwlibav_dec.h ├── lwlibav_video.c ├── lwlibav_video.h ├── lwlibav_video_internal.h ├── lwsimd.c ├── lwsimd.h ├── osdep.c ├── osdep.h ├── progress.h ├── qsv.c ├── qsv.h ├── resample.c ├── resample.h ├── utils.c ├── utils.h ├── video_output.c ├── video_output.h ├── xxh3.h ├── xxhash.c └── xxhash.h └── include ├── VSHelper.h ├── VapourSynth.h ├── avisynth.h ├── avisynth_c.h ├── avs ├── alignment.h ├── capi.h ├── config.h ├── cpuid.h ├── filesystem.h ├── minmax.h ├── posix.h ├── types.h └── win.h └── input.h /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ${{ matrix.os }} 8 | 9 | strategy: 10 | matrix: 11 | os: [ubuntu-latest, macos-latest] 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v3 16 | 17 | - name: Install automake 18 | if: ${{ matrix.os == 'macos-latest' }} 19 | run: | 20 | brew update 21 | brew install automake 22 | 23 | - name: Setup Python 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: 3.x # Version range or exact version of a Python version to use, using SemVer's version range syntax 27 | 28 | - name: Install meson 29 | run: | 30 | python -m pip install --upgrade pip 31 | pip install meson ninja 32 | 33 | - name: Install FFmpeg 34 | run: | 35 | git clone https://github.com/AkarinVS/FFmpeg --branch lsmas --depth 1 36 | pushd FFmpeg 37 | # If you want to build lsmas for encoding, the recommended configure 38 | # arguments are as follows: 39 | # --enable-gpl --enable-version3 --enable-static --disable-shared \ 40 | # --enable-avcodec --enable-avformat --enable-swresample --enable-swscale \ 41 | # --disable-programs --disable-avdevice --disable-postproc --disable-avfilter \ 42 | # --disable-encoders --disable-muxers --disable-doc --disable-debug \ 43 | # --enable-libdav1d --enable-zlib \ 44 | # --enable-cuvid --enable-ffnvcodec --enable-libmfx 45 | # Remove the last line if you don't need hardware accelerated decoding. 46 | ./configure --enable-gpl --enable-version3 --disable-static --enable-shared --disable-all --disable-autodetect --enable-avcodec --enable-avformat --enable-swresample --enable-swscale --disable-asm --disable-debug 47 | make -j2 48 | sudo make install -j2 49 | popd 50 | rm -rf FFmpeg 51 | 52 | - name: Install l-smash 53 | run: | 54 | git clone https://github.com/l-smash/l-smash --depth 1 55 | pushd l-smash 56 | mv configure configure.old 57 | sed 's/-Wl,--version-script,liblsmash.ver//g' configure.old >configure 58 | chmod +x configure 59 | ./configure --disable-static 60 | make lib -j2 61 | sudo make install-lib -j2 62 | popd 63 | rm -rf l-smash 64 | 65 | - name: Install AviSynth 66 | run: | 67 | git clone https://github.com/AviSynth/AviSynthPlus --branch 3.7 --depth 1 avisynth-build 68 | pushd avisynth-build 69 | cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DENABLE_PLUGINS=OFF -DENABLE_INTEL_SIMD=OFF 70 | cmake --build build -j 2 71 | sudo cmake --install build 72 | popd 73 | rm -rf avisynth-build 74 | 75 | - name: Build AviSynth plugin 76 | run: | 77 | pushd AviSynth 78 | meson build 79 | ninja -C build 80 | popd 81 | 82 | - name: Install zimg 83 | run: | 84 | git clone https://github.com/sekrit-twc/zimg --branch v3.0 --depth 1 85 | pushd zimg 86 | ./autogen.sh 87 | ./configure --disable-static --disable-simd 88 | make -j2 89 | sudo make install -j2 90 | popd 91 | rm -rf zimg 92 | 93 | - name: Install VapourSynth 94 | run: | 95 | git clone https://github.com/vapoursynth/vapoursynth --branch api3 --depth 1 vapoursynth-build 96 | pushd vapoursynth-build 97 | ./autogen.sh 98 | ./configure --disable-static --disable-x86-asm --disable-vsscript --disable-vspipe --disable-python-module --disable-plugins 99 | make -j2 100 | sudo make install -j2 101 | popd 102 | rm -rf vapoursynth-build 103 | 104 | - name: Build VapourSynth plugin 105 | run: | 106 | pushd VapourSynth 107 | meson build 108 | ninja -C build 109 | popd 110 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # User-specific files 35 | *.rsuser 36 | *.suo 37 | *.user 38 | *.userosscache 39 | *.sln.docstates 40 | 41 | # Visual Studio 2015/2017 cache/options directory 42 | .vs/ 43 | 44 | # Files built by Visual Studio 45 | *_i.c 46 | *_p.c 47 | *_h.h 48 | *.ilk 49 | *.meta 50 | *.obj 51 | *.iobj 52 | *.pch 53 | *.pdb 54 | *.ipdb 55 | *.pgc 56 | *.pgd 57 | *.rsp 58 | *.sbr 59 | *.tlb 60 | *.tli 61 | *.tlh 62 | *.tmp 63 | *.tmp_proj 64 | *_wpftmp.csproj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Visual C++ cache files 74 | ipch/ 75 | *.aps 76 | *.ncb 77 | *.opendb 78 | *.opensdf 79 | *.sdf 80 | *.cachefile 81 | *.VC.db 82 | *.VC.VC.opendb 83 | 84 | # Visual Studio profiler 85 | *.psess 86 | *.vsp 87 | *.vspx 88 | *.sap 89 | 90 | # Windows thumbnail cache files 91 | Thumbs.db 92 | Thumbs.db:encryptable 93 | ehthumbs.db 94 | ehthumbs_vista.db 95 | 96 | # Dump file 97 | *.stackdump 98 | 99 | # Folder config file 100 | [Dd]esktop.ini 101 | 102 | # Recycle Bin used on file shares 103 | $RECYCLE.BIN/ 104 | 105 | # Windows Installer files 106 | *.cab 107 | *.msi 108 | *.msix 109 | *.msm 110 | *.msp 111 | 112 | # Windows shortcuts 113 | *.lnk 114 | -------------------------------------------------------------------------------- /AviSynth/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012-2015 L-SMASH Works project 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | ----------------------------------------------------------------------------- 16 | 17 | Avisynth v2.5. Copyright 2002 Ben Rudiak-Gould et al. 18 | http://www.avisynth.org 19 | 20 | This program is free software; you can redistribute it and/or modify 21 | it under the terms of the GNU General Public License as published by 22 | the Free Software Foundation; either version 2 of the License, or 23 | (at your option) any later version. 24 | 25 | This program is distributed in the hope that it will be useful, 26 | but WITHOUT ANY WARRANTY; without even the implied warranty of 27 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 28 | GNU General Public License for more details. 29 | 30 | You should have received a copy of the GNU General Public License 31 | along with this program; if not, write to the Free Software 32 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 33 | http:www.gnu.org/copyleft/gpl.html . 34 | 35 | Linking Avisynth statically or dynamically with other modules is making a 36 | combined work based on Avisynth. Thus, the terms and conditions of the GNU 37 | General Public License cover the whole combination. 38 | 39 | As a special exception, the copyright holders of Avisynth give you 40 | permission to link Avisynth with independent modules that communicate with 41 | Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 42 | terms of these independent modules, and to copy and distribute the 43 | resulting combined work under terms of your choice, provided that 44 | every copy of the combined work is accompanied by a complete copy of 45 | the source code of Avisynth (the version of Avisynth used to produce the 46 | combined work), being distributed under the terms of the GNU General 47 | Public License plus this exception. An independent module is a module 48 | which is not derived from or based on Avisynth, such as 3rd-party filters, 49 | import and export plugins, or graphical user interfaces. 50 | -------------------------------------------------------------------------------- /AviSynth/LSMASHSourceVCX.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2002 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LSMASHSource", "LSMASHSourceVCX.vcxproj", "{55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Debug|x64.ActiveCfg = Debug|x64 17 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Debug|x64.Build.0 = Debug|x64 18 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Debug|x86.ActiveCfg = Debug|Win32 19 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Debug|x86.Build.0 = Debug|Win32 20 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Release|x64.ActiveCfg = Release|x64 21 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Release|x64.Build.0 = Release|x64 22 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Release|x86.ActiveCfg = Release|Win32 23 | {55BD76C7-954C-45CE-BC11-C1BA6D5D14B1}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {BDCE47AD-8943-421C-90ED-549570C3AF76} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /AviSynth/LSMASHSourceVCX.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | Source Files 44 | 45 | 46 | Source Files 47 | 48 | 49 | Source Files 50 | 51 | 52 | Source Files 53 | 54 | 55 | Source Files 56 | 57 | 58 | Source Files 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Source Files 68 | 69 | 70 | Source Files 71 | 72 | 73 | Source Files 74 | 75 | 76 | Source Files 77 | 78 | 79 | Source Files 80 | 81 | 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | Header Files 97 | 98 | 99 | Header Files 100 | 101 | 102 | Header Files 103 | 104 | 105 | Header Files 106 | 107 | 108 | Header Files 109 | 110 | 111 | Header Files 112 | 113 | 114 | Header Files 115 | 116 | 117 | Header Files 118 | 119 | 120 | Header Files 121 | 122 | 123 | Header Files 124 | 125 | 126 | Header Files 127 | 128 | 129 | Header Files 130 | 131 | 132 | Header Files 133 | 134 | 135 | Header Files 136 | 137 | 138 | Header Files 139 | 140 | 141 | Header Files 142 | 143 | 144 | -------------------------------------------------------------------------------- /AviSynth/audio_output.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * audio_output.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include "lsmashsource.h" 25 | 26 | extern "C" 27 | { 28 | #include 29 | #include 30 | #include 31 | } 32 | 33 | #include "audio_output.h" 34 | 35 | static inline enum AVSampleFormat as_decide_audio_output_sample_format( enum AVSampleFormat input_sample_format ) 36 | { 37 | /* Avisynth doesn't support IEEE double precision floating point format. */ 38 | switch( input_sample_format ) 39 | { 40 | case AV_SAMPLE_FMT_U8 : 41 | case AV_SAMPLE_FMT_U8P : 42 | return AV_SAMPLE_FMT_U8; 43 | case AV_SAMPLE_FMT_S16 : 44 | case AV_SAMPLE_FMT_S16P : 45 | return AV_SAMPLE_FMT_S16; 46 | case AV_SAMPLE_FMT_S32 : 47 | case AV_SAMPLE_FMT_S32P : 48 | return AV_SAMPLE_FMT_S32; 49 | default : 50 | return AV_SAMPLE_FMT_FLT; 51 | } 52 | } 53 | 54 | void as_setup_audio_rendering 55 | ( 56 | lw_audio_output_handler_t *aohp, 57 | AVCodecContext *ctx, 58 | VideoInfo *vi, 59 | IScriptEnvironment *env, 60 | const char *filter_name, 61 | uint64_t channel_layout, 62 | int sample_rate 63 | ) 64 | { 65 | /* Channel layout. */ 66 | if( ctx->channel_layout == 0 ) 67 | ctx->channel_layout = av_get_default_channel_layout( ctx->channels ); 68 | if( channel_layout != 0 ) 69 | aohp->output_channel_layout = channel_layout; 70 | /* Sample rate. */ 71 | if( sample_rate > 0 ) 72 | aohp->output_sample_rate = sample_rate; 73 | /* Decide output Bits Per Sample. */ 74 | aohp->output_sample_format = as_decide_audio_output_sample_format( aohp->output_sample_format ); 75 | if( aohp->output_sample_format == AV_SAMPLE_FMT_S32 76 | && (aohp->output_bits_per_sample == 0 || aohp->output_bits_per_sample == 24) ) 77 | { 78 | /* 24bit signed integer output */ 79 | aohp->s24_output = 1; 80 | aohp->output_bits_per_sample = 24; 81 | } 82 | else 83 | aohp->output_bits_per_sample = av_get_bytes_per_sample( aohp->output_sample_format ) * 8; 84 | /* Set up the number of planes and the block alignment of decoded and output data. */ 85 | int input_channels = av_get_channel_layout_nb_channels( ctx->channel_layout ); 86 | if( av_sample_fmt_is_planar( ctx->sample_fmt ) ) 87 | { 88 | aohp->input_planes = input_channels; 89 | aohp->input_block_align = av_get_bytes_per_sample( ctx->sample_fmt ); 90 | } 91 | else 92 | { 93 | aohp->input_planes = 1; 94 | aohp->input_block_align = av_get_bytes_per_sample( ctx->sample_fmt ) * input_channels; 95 | } 96 | int output_channels = av_get_channel_layout_nb_channels( aohp->output_channel_layout ); 97 | aohp->output_block_align = (output_channels * aohp->output_bits_per_sample) / 8; 98 | /* Set up resampler. */ 99 | SwrContext *swr_ctx = aohp->swr_ctx; 100 | swr_ctx = swr_alloc(); 101 | if( !swr_ctx ) 102 | env->ThrowError( "%s: failed to swr_alloc.", filter_name ); 103 | aohp->swr_ctx = swr_ctx; 104 | av_opt_set_int( swr_ctx, "in_channel_layout", ctx->channel_layout, 0 ); 105 | av_opt_set_int( swr_ctx, "in_sample_fmt", ctx->sample_fmt, 0 ); 106 | av_opt_set_int( swr_ctx, "in_sample_rate", ctx->sample_rate, 0 ); 107 | av_opt_set_int( swr_ctx, "out_channel_layout", aohp->output_channel_layout, 0 ); 108 | av_opt_set_int( swr_ctx, "out_sample_fmt", aohp->output_sample_format, 0 ); 109 | av_opt_set_int( swr_ctx, "out_sample_rate", aohp->output_sample_rate, 0 ); 110 | av_opt_set_int( swr_ctx, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0 ); 111 | if( swr_init( swr_ctx ) < 0 ) 112 | env->ThrowError( "%s: failed to open resampler.", filter_name ); 113 | /* Set up AviSynth output format. */ 114 | vi->nchannels = output_channels; 115 | vi->audio_samples_per_second = aohp->output_sample_rate; 116 | switch ( aohp->output_sample_format ) 117 | { 118 | case AV_SAMPLE_FMT_U8 : 119 | case AV_SAMPLE_FMT_U8P : 120 | vi->sample_type = SAMPLE_INT8; 121 | break; 122 | case AV_SAMPLE_FMT_S16 : 123 | case AV_SAMPLE_FMT_S16P : 124 | vi->sample_type = SAMPLE_INT16; 125 | break; 126 | case AV_SAMPLE_FMT_S32 : 127 | case AV_SAMPLE_FMT_S32P : 128 | vi->sample_type = aohp->s24_output ? SAMPLE_INT24 : SAMPLE_INT32; 129 | break; 130 | case AV_SAMPLE_FMT_FLT : 131 | case AV_SAMPLE_FMT_FLTP : 132 | vi->sample_type = SAMPLE_FLOAT; 133 | break; 134 | default : 135 | env->ThrowError( "%s: %s is not supported.", filter_name, av_get_sample_fmt_name( ctx->sample_fmt ) ); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /AviSynth/audio_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * audio_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include "../common/audio_output.h" 25 | 26 | void as_setup_audio_rendering 27 | ( 28 | lw_audio_output_handler_t *aohp, 29 | AVCodecContext *ctx, 30 | VideoInfo *vi, 31 | IScriptEnvironment *env, 32 | const char *filter_name, 33 | uint64_t channel_layout, 34 | int sample_rate 35 | ); 36 | -------------------------------------------------------------------------------- /AviSynth/exlibs.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * exlibs.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #pragma comment( lib, "Ws2_32.lib" ) 25 | #pragma comment( lib, "liblsmash.lib" ) 26 | #pragma comment( lib, "libavutil.a" ) 27 | #pragma comment( lib, "libavcodec.a" ) 28 | #pragma comment( lib, "libavformat.a" ) 29 | #pragma comment( lib, "libswscale.a" ) 30 | #pragma comment( lib, "libavresample.a" ) 31 | #pragma comment( lib, "libswresample.a" ) 32 | #pragma comment( lib, "zlib.lib" ) 33 | #pragma comment( lib, "mfx.lib" ) 34 | 35 | /* Add more external libraries user-self if needed. */ 36 | -------------------------------------------------------------------------------- /AviSynth/libavsmash_source.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libavsmash_source.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include "../common/libavsmash.h" 25 | #include "../common/libavsmash_video.h" 26 | #include "../common/libavsmash_audio.h" 27 | 28 | class LibavSMASHSource : public LSMASHSource 29 | { 30 | private: 31 | void (*free_format_ctx)( AVFormatContext *p ) 32 | = []( AVFormatContext *p ){ avformat_close_input( &p ); }; 33 | protected: 34 | lsmash_file_parameters_t file_param; 35 | std::unique_ptr< AVFormatContext, decltype( free_format_ctx ) > format_ctx; 36 | LibavSMASHSource() : file_param{}, format_ctx{ nullptr, free_format_ctx } {} 37 | ~LibavSMASHSource() = default; 38 | LibavSMASHSource( const LibavSMASHSource & ) = delete; 39 | LibavSMASHSource & operator= ( const LibavSMASHSource & ) = delete; 40 | }; 41 | 42 | class LSMASHVideoSource : public LibavSMASHSource 43 | { 44 | private: 45 | std::unique_ptr< libavsmash_video_decode_handler_t, decltype( &libavsmash_video_free_decode_handler ) > vdhp; 46 | std::unique_ptr< libavsmash_video_output_handler_t, decltype( &libavsmash_video_free_output_handler ) > vohp; 47 | LSMASHVideoSource() 48 | : LibavSMASHSource{}, 49 | vdhp{ libavsmash_video_alloc_decode_handler(), libavsmash_video_free_decode_handler }, 50 | vohp{ libavsmash_video_alloc_output_handler(), libavsmash_video_free_output_handler } {} 51 | uint32_t open_file 52 | ( 53 | const char *source, 54 | IScriptEnvironment *env 55 | ); 56 | void get_video_track 57 | ( 58 | const char *source, 59 | uint32_t track_number, 60 | IScriptEnvironment *env 61 | ); 62 | bool has_at_least_v8; 63 | AVFrame* av_frame; 64 | public: 65 | LSMASHVideoSource 66 | ( 67 | const char *source, 68 | uint32_t track_number, 69 | int threads, 70 | int seek_mode, 71 | uint32_t forward_seek_threshold, 72 | int direct_rendering, 73 | int fps_num, 74 | int fps_den, 75 | enum AVPixelFormat pixel_format, 76 | const char *preferred_decoder_names, 77 | int prefer_hw_decoder, 78 | IScriptEnvironment *env 79 | ); 80 | ~LSMASHVideoSource(); 81 | PVideoFrame __stdcall GetFrame( int n, IScriptEnvironment *env ); 82 | bool __stdcall GetParity( int n ) { return false; } 83 | void __stdcall GetAudio( void *buf, int64_t start, int64_t count, IScriptEnvironment *env ) {} 84 | }; 85 | 86 | class LSMASHAudioSource : public LibavSMASHSource 87 | { 88 | private: 89 | std::unique_ptr< libavsmash_audio_decode_handler_t, decltype( &libavsmash_audio_free_decode_handler ) > adhp; 90 | std::unique_ptr< libavsmash_audio_output_handler_t, decltype( &libavsmash_audio_free_output_handler ) > aohp; 91 | LSMASHAudioSource() 92 | : LibavSMASHSource{}, 93 | adhp{ libavsmash_audio_alloc_decode_handler(), libavsmash_audio_free_decode_handler }, 94 | aohp{ libavsmash_audio_alloc_output_handler(), libavsmash_audio_free_output_handler } {} 95 | uint32_t open_file 96 | ( 97 | const char *source, 98 | IScriptEnvironment *env 99 | ); 100 | void get_audio_track 101 | ( 102 | const char *source, 103 | uint32_t track_number, 104 | IScriptEnvironment *env 105 | ); 106 | public: 107 | LSMASHAudioSource 108 | ( 109 | const char *source, 110 | uint32_t track_number, 111 | bool skip_priming, 112 | uint64_t channel_layout, 113 | int sample_rate, 114 | const char *preferred_decoder_names, 115 | IScriptEnvironment *env 116 | ); 117 | ~LSMASHAudioSource(); 118 | PVideoFrame __stdcall GetFrame( int n, IScriptEnvironment *env ) { return nullptr; } 119 | bool __stdcall GetParity( int n ) { return false; } 120 | void __stdcall GetAudio( void *buf, int64_t start, int64_t wanted_length, IScriptEnvironment *env ); 121 | }; 122 | -------------------------------------------------------------------------------- /AviSynth/lsmashsource.cpp: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lsmashsource.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include 25 | 26 | #include "lsmashsource.h" 27 | 28 | #if defined(_WIN32) 29 | # define AVS_EXPORT __declspec(dllexport) 30 | #elif defined(__GNUC__) && __GNUC__ >= 4 31 | # define AVS_EXPORT __attribute__((visibility("default"))) 32 | #else 33 | # define AVS_EXPORT 34 | #endif 35 | 36 | void throw_error 37 | ( 38 | lw_log_handler_t *lhp, 39 | lw_log_level level, 40 | const char *message 41 | ) 42 | { 43 | IScriptEnvironment *env = (IScriptEnvironment *)lhp->priv; 44 | env->ThrowError( message ); 45 | } 46 | 47 | extern AVSValue __cdecl CreateLSMASHVideoSource( AVSValue args, void *user_data, IScriptEnvironment *env ); 48 | extern AVSValue __cdecl CreateLSMASHAudioSource( AVSValue args, void *user_data, IScriptEnvironment *env ); 49 | extern AVSValue __cdecl CreateLWLibavVideoSource( AVSValue args, void *user_data, IScriptEnvironment *env ); 50 | extern AVSValue __cdecl CreateLWLibavAudioSource( AVSValue args, void *user_data, IScriptEnvironment *env ); 51 | 52 | const AVS_Linkage* AVS_linkage = 0; 53 | 54 | extern "C" AVS_EXPORT const char* __stdcall AvisynthPluginInit3( IScriptEnvironment* env, const AVS_Linkage* const vectors ) 55 | { 56 | AVS_linkage = vectors; 57 | 58 | /* LSMASHVideoSource */ 59 | env->AddFunction 60 | ( 61 | "LSMASHVideoSource", 62 | "[source]s[track]i[threads]i[seek_mode]i[seek_threshold]i[dr]b[fpsnum]i[fpsden]i[format]s[decoder]s[prefer_hw]i[ff_loglevel]i", 63 | CreateLSMASHVideoSource, 64 | 0 65 | ); 66 | /* LSMASHAudioSource */ 67 | env->AddFunction 68 | ( 69 | "LSMASHAudioSource", 70 | "[source]s[track]i[skip_priming]b[layout]s[rate]i[decoder]s[ff_loglevel]i", 71 | CreateLSMASHAudioSource, 72 | 0 73 | ); 74 | /* LWLibavVideoSource */ 75 | env->AddFunction 76 | ( 77 | "LWLibavVideoSource", 78 | "[source]s[stream_index]i[threads]i[cache]b[cachefile]s[seek_mode]i[seek_threshold]i[dr]b[fpsnum]i[fpsden]i[repeat]b[dominance]i[format]s[decoder]s[prefer_hw]i[ff_loglevel]i[cachedir]s", 79 | CreateLWLibavVideoSource, 80 | 0 81 | ); 82 | /* LWLibavAudioSource */ 83 | env->AddFunction 84 | ( 85 | "LWLibavAudioSource", 86 | "[source]s[stream_index]i[cache]b[cachefile]s[av_sync]b[layout]s[rate]i[decoder]s[ff_loglevel]i[cachedir]s", 87 | CreateLWLibavAudioSource, 88 | 0 89 | ); 90 | return "LSMASHSource"; 91 | } 92 | -------------------------------------------------------------------------------- /AviSynth/lsmashsource.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lsmashsource.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include 25 | #include 26 | 27 | #include "../common/cpp_compat.h" 28 | #include "../common/utils.h" 29 | 30 | #include 31 | 32 | class LSMASHSource : public IClip 33 | { 34 | protected: 35 | VideoInfo vi; 36 | char preferred_decoder_names_buf[512]; 37 | inline void set_preferred_decoder_names 38 | ( 39 | const char *preferred_decoder_names 40 | ) 41 | { 42 | memset( preferred_decoder_names_buf, 0, sizeof(preferred_decoder_names_buf) ); 43 | if( preferred_decoder_names ) 44 | memcpy( preferred_decoder_names_buf, 45 | preferred_decoder_names, 46 | MIN( sizeof(preferred_decoder_names_buf) - 1, strlen(preferred_decoder_names) ) ); 47 | } 48 | inline const char **tokenize_preferred_decoder_names( void ) 49 | { 50 | return lw_tokenize_string( preferred_decoder_names_buf, ',', nullptr ); 51 | } 52 | int __stdcall SetCacheHints( int cachehints, int frame_range ) { return cachehints == CACHE_GET_MTMODE ? MT_SERIALIZED : 0; } 53 | const VideoInfo& __stdcall GetVideoInfo() { return vi; } 54 | }; 55 | 56 | void throw_error 57 | ( 58 | lw_log_handler_t *lhp, 59 | lw_log_level level, 60 | const char *message 61 | ); 62 | -------------------------------------------------------------------------------- /AviSynth/lwlibav_source.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwlibav_source.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #define NO_PROGRESS_HANDLER 25 | 26 | #include "../common/progress.h" 27 | #include "../common/lwlibav_dec.h" 28 | #include "../common/lwlibav_video.h" 29 | #include "../common/lwlibav_audio.h" 30 | #include "../common/lwindex.h" 31 | 32 | class LWLibavSource : public LSMASHSource 33 | { 34 | protected: 35 | lwlibav_file_handler_t lwh; 36 | std::unique_ptr< lwlibav_video_decode_handler_t, decltype( &lwlibav_video_free_decode_handler ) > vdhp; 37 | std::unique_ptr< lwlibav_video_output_handler_t, decltype( &lwlibav_video_free_output_handler ) > vohp; 38 | std::unique_ptr< lwlibav_audio_decode_handler_t, decltype( &lwlibav_audio_free_decode_handler ) > adhp; 39 | std::unique_ptr< lwlibav_audio_output_handler_t, decltype( &lwlibav_audio_free_output_handler ) > aohp; 40 | inline void free_video_decode_handler( void ) { vdhp.reset( nullptr ); } 41 | inline void free_video_output_handler( void ) { vohp.reset( nullptr ); } 42 | inline void free_audio_decode_handler( void ) { adhp.reset( nullptr ); } 43 | inline void free_audio_output_handler( void ) { aohp.reset( nullptr ); } 44 | LWLibavSource() 45 | : vdhp{ lwlibav_video_alloc_decode_handler(), lwlibav_video_free_decode_handler }, 46 | vohp{ lwlibav_video_alloc_output_handler(), lwlibav_video_free_output_handler }, 47 | adhp{ lwlibav_audio_alloc_decode_handler(), lwlibav_audio_free_decode_handler }, 48 | aohp{ lwlibav_audio_alloc_output_handler(), lwlibav_audio_free_output_handler } {}; 49 | ~LWLibavSource() = default; 50 | LWLibavSource( const LWLibavSource & ) = delete; 51 | LWLibavSource & operator= ( const LWLibavSource & ) = delete; 52 | }; 53 | 54 | class LWLibavVideoSource : public LWLibavSource 55 | { 56 | private: 57 | LWLibavVideoSource() = default; 58 | bool has_at_least_v8; 59 | AVFrame* av_frame; 60 | public: 61 | LWLibavVideoSource 62 | ( 63 | lwlibav_option_t *opt, 64 | int seek_mode, 65 | uint32_t forward_seek_threshold, 66 | int direct_rendering, 67 | enum AVPixelFormat pixel_format, 68 | const char *preferred_decoder_names, 69 | int prefer_hw_decoder, 70 | IScriptEnvironment *env 71 | ); 72 | ~LWLibavVideoSource(); 73 | PVideoFrame __stdcall GetFrame( int n, IScriptEnvironment *env ); 74 | bool __stdcall GetParity( int n ); 75 | void __stdcall GetAudio( void *buf, int64_t start, int64_t count, IScriptEnvironment *env ) {} 76 | }; 77 | 78 | class LWLibavAudioSource : public LWLibavSource 79 | { 80 | private: 81 | LWLibavAudioSource() = default; 82 | int delay_audio( int64_t *start, int64_t wanted_length ); 83 | public: 84 | LWLibavAudioSource 85 | ( 86 | lwlibav_option_t *opt, 87 | uint64_t channel_layout, 88 | int sample_rate, 89 | const char *preferred_decoder_names, 90 | IScriptEnvironment *env 91 | ); 92 | ~LWLibavAudioSource(); 93 | PVideoFrame __stdcall GetFrame( int n, IScriptEnvironment *env ) { return NULL; } 94 | bool __stdcall GetParity( int n ) { return false; } 95 | void __stdcall GetAudio( void *buf, int64_t start, int64_t wanted_length, IScriptEnvironment *env ); 96 | }; 97 | -------------------------------------------------------------------------------- /AviSynth/meson.build: -------------------------------------------------------------------------------- 1 | project('L-SMASH-Works', 'c', 'cpp', 2 | default_options: ['buildtype=release', 'b_ndebug=if-release', 'c_std=c99', 'cpp_std=c++14'], 3 | meson_version: '>=0.48.0' 4 | ) 5 | 6 | add_project_arguments('-Wno-sign-compare', '-DXXH_INLINE_ALL', '-D_FILE_OFFSET_BITS=64', language: ['c', 'cpp']) 7 | 8 | sources = [ 9 | 'audio_output.cpp', 10 | 'audio_output.h', 11 | 'libavsmash_source.cpp', 12 | 'libavsmash_source.h', 13 | 'lsmashsource.cpp', 14 | 'lsmashsource.h', 15 | 'lwlibav_source.cpp', 16 | 'lwlibav_source.h', 17 | 'video_output.cpp', 18 | 'video_output.h', 19 | '../common/audio_output.c', 20 | '../common/audio_output.h', 21 | '../common/cpp_compat.h', 22 | '../common/decode.c', 23 | '../common/decode.h', 24 | '../common/libavsmash.c', 25 | '../common/libavsmash.h', 26 | '../common/libavsmash_audio.c', 27 | '../common/libavsmash_audio.h', 28 | '../common/libavsmash_audio_internal.h', 29 | '../common/libavsmash_video.c', 30 | '../common/libavsmash_video.h', 31 | '../common/libavsmash_video_internal.h', 32 | '../common/lwindex.c', 33 | '../common/lwindex.h', 34 | '../common/lwlibav_audio.c', 35 | '../common/lwlibav_audio.h', 36 | '../common/lwlibav_audio_internal.h', 37 | '../common/lwlibav_dec.c', 38 | '../common/lwlibav_dec.h', 39 | '../common/lwlibav_video.c', 40 | '../common/lwlibav_video.h', 41 | '../common/lwlibav_video_internal.h', 42 | '../common/lwsimd.c', 43 | '../common/lwsimd.h', 44 | '../common/osdep.c', 45 | '../common/osdep.h', 46 | '../common/progress.h', 47 | '../common/qsv.c', 48 | '../common/qsv.h', 49 | '../common/resample.c', 50 | '../common/resample.h', 51 | '../common/utils.c', 52 | '../common/utils.h', 53 | '../common/video_output.c', 54 | '../common/video_output.h' 55 | ] 56 | 57 | avisynth_dep = dependency('avisynth').partial_dependency(compile_args: true, includes: true) 58 | 59 | deps = [ 60 | avisynth_dep, 61 | dependency('liblsmash'), 62 | dependency('libavcodec', version: '>=58.91.0'), 63 | dependency('libavformat', version: '>=58.45.0'), 64 | dependency('libavutil', version: '>=56.51.0'), 65 | dependency('libswresample', version: '>=3.7.0'), 66 | dependency('libswscale', version: '>=5.7.0') 67 | ] 68 | 69 | if host_machine.cpu_family().startswith('x86') 70 | add_project_arguments('-mfpmath=sse', '-msse2', language: ['c', 'cpp']) 71 | endif 72 | 73 | if host_machine.system() == 'windows' 74 | add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: ['c', 'cpp']) 75 | endif 76 | 77 | shared_module('lsmashsource', sources, 78 | dependencies: deps, 79 | install: true, 80 | install_dir: join_paths(avisynth_dep.get_pkgconfig_variable('libdir'), 'avisynth'), 81 | gnu_symbol_visibility: 'hidden' 82 | ) 83 | -------------------------------------------------------------------------------- /AviSynth/vcxcompat.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | v120 5 | 6 | 7 | v140 8 | 9 | 10 | v141 11 | 12 | 13 | v142 14 | 15 | 16 | -------------------------------------------------------------------------------- /AviSynth/video_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include "../common/video_output.h" 25 | 26 | typedef struct 27 | { 28 | uint8_t *data [4]; 29 | int linesize[4]; 30 | } as_picture_t; 31 | 32 | typedef void func_make_black_background 33 | ( 34 | PVideoFrame &frame, 35 | int bitdepth_minus_8 36 | ); 37 | 38 | typedef int func_make_frame 39 | ( 40 | lw_video_output_handler_t *vohp, 41 | int height, 42 | AVFrame *av_frame, 43 | PVideoFrame &as_frame 44 | ); 45 | 46 | typedef struct 47 | { 48 | func_make_black_background *make_black_background; 49 | func_make_frame *make_frame; 50 | IScriptEnvironment *env; 51 | VideoInfo *vi; 52 | int bitdepth_minus_8; 53 | int sub_width; 54 | int sub_height; 55 | as_picture_t scaled; 56 | } as_video_output_handler_t; 57 | 58 | typedef struct 59 | { 60 | PVideoFrame as_frame_buffer; 61 | } as_video_buffer_handler_t; 62 | 63 | enum AVPixelFormat get_av_output_pixel_format 64 | ( 65 | const char *format_name 66 | ); 67 | 68 | int make_frame 69 | ( 70 | lw_video_output_handler_t *vohp, 71 | AVFrame *av_frame, 72 | PVideoFrame &as_frame, 73 | IScriptEnvironment *env 74 | ); 75 | 76 | void as_free_video_output_handler 77 | ( 78 | void *private_handler 79 | ); 80 | 81 | void as_setup_video_rendering 82 | ( 83 | lw_video_output_handler_t *vohp, 84 | AVCodecContext *ctx, 85 | const char *filter_name, 86 | int direct_rendering, 87 | enum AVPixelFormat output_pixel_format, 88 | int output_width, 89 | int output_height 90 | ); 91 | 92 | void avs_set_frame_properties 93 | ( 94 | AVFrame* av_frame, 95 | AVStream* stream, 96 | int64_t duration_num, 97 | int64_t duration_den, 98 | bool rgb, 99 | PVideoFrame& avs_frame, 100 | int top, 101 | int bottom, 102 | IScriptEnvironment* env 103 | ); 104 | -------------------------------------------------------------------------------- /AviUtl/GNUmakefile: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------------------------- 2 | # Makefile for AviUtl plugins 3 | #---------------------------------------------------------------------------------------------- 4 | 5 | include config.mak 6 | 7 | vpath %.c $(SRCDIR) 8 | vpath %.h $(SRCDIR) 9 | vpath %.rc $(SRCDIR) 10 | 11 | OBJ_INPUT = $(SRC_INPUT:%.c=%.o) lwinput.res 12 | OBJ_MUXER = $(SRC_MUXER:%.c=%.o) lwmuxer.res 13 | OBJ_DUMPER = $(SRC_DUMPER:%.c=%.o) 14 | OBJ_COLOR = $(SRC_COLOR:%.c=%.o) 15 | 16 | SRC_ALL = $(SRC_INPUT) $(SRC_MUXER) $(SRC_DUMPER) $(SRC_COLOR) 17 | 18 | RCFLAGS = -J rc -O coff 19 | 20 | ifneq ($(STRIP),) 21 | LDFLAGS += -Wl,-s 22 | endif 23 | 24 | .PHONY: all input muxer dumper color clean distclean dep 25 | 26 | all: input muxer dumper color 27 | 28 | input: lwinput.aui 29 | 30 | muxer: lwmuxer.auf 31 | 32 | dumper: lwdumper.auf 33 | 34 | color: lwcolor.auc 35 | 36 | lwinput.aui: $(OBJ_INPUT) 37 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) 38 | 39 | lwmuxer.auf: $(OBJ_MUXER) 40 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) 41 | 42 | lwdumper.auf: $(OBJ_DUMPER) 43 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) 44 | 45 | lwcolor.auc: $(OBJ_COLOR) 46 | $(LD) $(LDFLAGS) -o $@ $^ $(LIBS) 47 | 48 | %.o: %.c .depend 49 | $(CC) $(CFLAGS) -c $< -o $@ 50 | 51 | %.res: %.rc resource.h 52 | $(RC) $(RCFLAGS) $< -o $@ 53 | 54 | clean: 55 | $(RM) *.auf *.aui *.auc *.o *.res .depend 56 | 57 | distclean: clean 58 | $(RM) config.* 59 | 60 | dep: .depend 61 | 62 | ifneq ($(wildcard .depend),) 63 | include .depend 64 | endif 65 | 66 | .depend: config.mak 67 | @$(RM) .depend 68 | @$(foreach SRC, $(SRC_ALL:%=$(SRCDIR)/%), $(CC) $(SRC) $(CFLAGS) -msse4.1 -g0 -MT $(SRC:$(SRCDIR)/%.c=%.o) -MM >> .depend;) 69 | 70 | config.mak: 71 | configure 72 | -------------------------------------------------------------------------------- /AviUtl/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011-2015 L-SMASH Works project 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | ----------------------------------------------------------------------------- 16 | 17 | Copyright (C) 2011-2015 L-SMASH Works project 18 | Copyright (C) 1999-2012 Kenkun 19 | 20 | Permission is hereby granted, free of charge, to any person obtaining a copy 21 | of this software and associated documentation files (the "Software"), to deal 22 | in the Software without restriction, including without limitation the rights 23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 24 | copies of the Software, and to permit persons to whom the Software is 25 | furnished to do so, subject to the following conditions: 26 | 27 | The above copyright notice and this permission notice shall be included in 28 | all copies or substantial portions of the Software. 29 | 30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 36 | THE SOFTWARE. 37 | -------------------------------------------------------------------------------- /AviUtl/audio_output.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * audio_output.c 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #define _USE_MATH_DEFINES 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "lwinput.h" 34 | #include "audio_output.h" 35 | 36 | static inline enum AVSampleFormat au_decide_audio_output_sample_format 37 | ( 38 | enum AVSampleFormat input_sample_format, 39 | int input_bits_per_sample 40 | ) 41 | { 42 | /* AviUtl doesn't support IEEE floating point format. */ 43 | switch ( input_sample_format ) 44 | { 45 | case AV_SAMPLE_FMT_U8 : 46 | case AV_SAMPLE_FMT_U8P : 47 | return AV_SAMPLE_FMT_U8; 48 | case AV_SAMPLE_FMT_S16 : 49 | case AV_SAMPLE_FMT_S16P : 50 | return AV_SAMPLE_FMT_S16; 51 | case AV_SAMPLE_FMT_S32 : 52 | case AV_SAMPLE_FMT_S32P : 53 | return AV_SAMPLE_FMT_S32; 54 | default : 55 | if( input_bits_per_sample == 0 ) 56 | return AV_SAMPLE_FMT_S32; 57 | else if( input_bits_per_sample <= 8 ) 58 | return AV_SAMPLE_FMT_U8; 59 | else if( input_bits_per_sample <= 16 ) 60 | return AV_SAMPLE_FMT_S16; 61 | else 62 | return AV_SAMPLE_FMT_S32; 63 | } 64 | } 65 | 66 | static inline void au_opt_set_mix_level 67 | ( 68 | SwrContext *swr_ctx, 69 | const char *opt, 70 | int value 71 | ) 72 | { 73 | av_opt_set_double( swr_ctx, opt, value == 71 ? M_SQRT1_2 : (value / 100.0), 0 ); 74 | } 75 | 76 | int au_setup_audio_rendering 77 | ( 78 | lw_audio_output_handler_t *aohp, 79 | AVCodecContext *ctx, 80 | audio_option_t *opt, 81 | WAVEFORMATEX *format 82 | ) 83 | { 84 | /* Channel layout. */ 85 | if( ctx->channel_layout == 0 ) 86 | ctx->channel_layout = av_get_default_channel_layout( ctx->channels ); 87 | if( opt->channel_layout != 0 ) 88 | aohp->output_channel_layout = opt->channel_layout; 89 | /* Sample rate. */ 90 | if( opt->sample_rate > 0 ) 91 | aohp->output_sample_rate = opt->sample_rate; 92 | /* Decide output sample format. */ 93 | aohp->output_sample_format = au_decide_audio_output_sample_format( aohp->output_sample_format, aohp->output_bits_per_sample ); 94 | if( aohp->output_sample_format == AV_SAMPLE_FMT_S32 95 | && (aohp->output_bits_per_sample == 0 || aohp->output_bits_per_sample == 24) ) 96 | { 97 | /* 24bit signed integer output */ 98 | aohp->s24_output = 1; 99 | aohp->output_bits_per_sample = 24; 100 | } 101 | else 102 | aohp->output_bits_per_sample = av_get_bytes_per_sample( aohp->output_sample_format ) * 8; 103 | /* Set up the number of planes and the block alignment of decoded and output data. */ 104 | int input_channels = av_get_channel_layout_nb_channels( ctx->channel_layout ); 105 | if( av_sample_fmt_is_planar( ctx->sample_fmt ) ) 106 | { 107 | aohp->input_planes = input_channels; 108 | aohp->input_block_align = av_get_bytes_per_sample( ctx->sample_fmt ); 109 | } 110 | else 111 | { 112 | aohp->input_planes = 1; 113 | aohp->input_block_align = av_get_bytes_per_sample( ctx->sample_fmt ) * input_channels; 114 | } 115 | int output_channels = av_get_channel_layout_nb_channels( aohp->output_channel_layout ); 116 | aohp->output_block_align = (output_channels * aohp->output_bits_per_sample) / 8; 117 | /* Set up resampler. */ 118 | SwrContext *swr_ctx = aohp->swr_ctx; 119 | swr_ctx = swr_alloc(); 120 | if( !swr_ctx ) 121 | { 122 | DEBUG_AUDIO_MESSAGE_BOX_DESKTOP( MB_ICONERROR | MB_OK, "Failed to swr_alloc." ); 123 | return -1; 124 | } 125 | aohp->swr_ctx = swr_ctx; 126 | av_opt_set_int( swr_ctx, "in_channel_layout", ctx->channel_layout, 0 ); 127 | av_opt_set_int( swr_ctx, "in_sample_fmt", ctx->sample_fmt, 0 ); 128 | av_opt_set_int( swr_ctx, "in_sample_rate", ctx->sample_rate, 0 ); 129 | av_opt_set_int( swr_ctx, "out_channel_layout", aohp->output_channel_layout, 0 ); 130 | av_opt_set_int( swr_ctx, "out_sample_fmt", aohp->output_sample_format, 0 ); 131 | av_opt_set_int( swr_ctx, "out_sample_rate", aohp->output_sample_rate, 0 ); 132 | av_opt_set_int( swr_ctx, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0 ); 133 | au_opt_set_mix_level( swr_ctx, "center_mix_level", opt->mix_level[MIX_LEVEL_INDEX_CENTER ] ); 134 | au_opt_set_mix_level( swr_ctx, "surround_mix_level", opt->mix_level[MIX_LEVEL_INDEX_SURROUND] ); 135 | au_opt_set_mix_level( swr_ctx, "lfe_mix_level", opt->mix_level[MIX_LEVEL_INDEX_LFE ] ); 136 | if( swr_init( swr_ctx ) < 0 ) 137 | { 138 | DEBUG_AUDIO_MESSAGE_BOX_DESKTOP( MB_ICONERROR | MB_OK, "Failed to open resampler." ); 139 | return -1; 140 | } 141 | /* Support of WAVEFORMATEXTENSIBLE is much restrictive on AviUtl, so we always use WAVEFORMATEX instead. */ 142 | format->nChannels = output_channels; 143 | format->nSamplesPerSec = aohp->output_sample_rate; 144 | format->wBitsPerSample = aohp->output_bits_per_sample; 145 | format->nBlockAlign = aohp->output_block_align; 146 | format->nAvgBytesPerSec = format->nSamplesPerSec * format->nBlockAlign; 147 | format->wFormatTag = WAVE_FORMAT_PCM; 148 | format->cbSize = 0; 149 | return 0; 150 | } 151 | -------------------------------------------------------------------------------- /AviUtl/audio_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * audio_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #include "../common/audio_output.h" 26 | 27 | int au_setup_audio_rendering 28 | ( 29 | lw_audio_output_handler_t *aohp, 30 | AVCodecContext *ctx, 31 | audio_option_t *opt, 32 | WAVEFORMATEX *format 33 | ); 34 | -------------------------------------------------------------------------------- /AviUtl/color.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * color.h: 色変換プラグイン ヘッダーファイル for AviUtl version 0.99h 以降 3 | ******************************************************************************** 4 | * Copyright (c) 1999-2012 Kenkun 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | *******************************************************************************/ 24 | 25 | // YC構造体 26 | #ifndef PIXEL_YC 27 | typedef struct { 28 | short y; // 画素(輝度 )データ ( 0 ~ 4096 ) 29 | short cb; // 画素(色差(青))データ ( -2048 ~ 2048 ) 30 | short cr; // 画素(色差(赤))データ ( -2048 ~ 2048 ) 31 | // 画素データは範囲外に出ていることがあります 32 | // また範囲内に収めなくてもかまいません 33 | } PIXEL_YC; 34 | #endif 35 | 36 | // マルチスレッド関数用の定義 37 | typedef void (*MULTI_THREAD_FUNC)( int thread_id,int thread_num,void *param1,void *param2 ); 38 | // thread_id : スレッド番号 ( 0 ~ thread_num-1 ) 39 | // thread_num : スレッド数 ( 1 ~ ) 40 | // param1 : 汎用パラメータ 41 | // param2 : 汎用パラメータ 42 | 43 | // 色変換の処理情報構造体 44 | typedef struct { 45 | int flag; // フラグ 46 | // COLOR_PROC_INFO_FLAG_INVERT_HEIGHT : pixelpの縦方向を上下逆に処理する 47 | // COLOR_PROC_INFO_FLAG_USE_SSE : SSE使用 48 | // COLOR_PROC_INFO_FLAG_USE_SSE2 : SSE2使用 49 | PIXEL_YC *ycp; // PIXEL_YC構造体へのポインタ 50 | void *pixelp; // DIB形式データへのポインタ 51 | DWORD format; // DIB形式データのフォーマット( NULL = RGB24bit / 'Y''U''Y''2' = YUY2 / 'Y''C''4''8' = PIXEL_YC ) 52 | int w,h; // 画像データの縦横サイズ 53 | int line_size; // PIXEL_YC構造体の横幅のバイトサイズ 54 | int yc_size; // PIXEL_YC構造体の画素のバイトサイズ 55 | BOOL (*exec_multi_thread_func)( MULTI_THREAD_FUNC func,void *param1,void *param2 ); 56 | // 指定した関数をシステムの設定値に応じたスレッド数で呼び出します 57 | // 呼び出された関数内からWin32APIや外部関数を使用しないでください 58 | // func : マルチスレッドで呼び出す関数 59 | // param1 : 呼び出す関数に渡す汎用パラメータ 60 | // param2 : 呼び出す関数に渡す汎用パラメータ 61 | // 戻り値 : TRUEなら成功 62 | int reserve[16]; 63 | } COLOR_PROC_INFO; 64 | 65 | #define COLOR_PROC_INFO_FLAG_INVERT_HEIGHT 1 66 | #define COLOR_PROC_INFO_FLAG_USE_SSE 256 67 | #define COLOR_PROC_INFO_FLAG_USE_SSE2 512 68 | 69 | // 色変換プラグイン構造体 70 | typedef struct { 71 | int flag; // フラグ 72 | LPSTR name; // プラグインの名前 73 | LPSTR information; // プラグインの情報 74 | BOOL (*func_init)( void ); 75 | // DLL開始時に呼ばれる関数へのポインタ (NULLなら呼ばれません) 76 | BOOL (*func_exit)( void ); 77 | // DLL終了時に呼ばれる関数へのポインタ (NULLなら呼ばれません) 78 | BOOL (*func_pixel2yc)( COLOR_PROC_INFO *cpip ); 79 | // DIB形式の画像からからPIXEL_YC形式の画像に変換します (NULLなら呼ばれません) 80 | // 戻り値 : TRUEなら成功 81 | // : FALSEならAviUtl側でデフォルト変換されます 82 | BOOL (*func_yc2pixel)( COLOR_PROC_INFO *cpip ); 83 | // PIXEL_YC形式の画像からからDIB形式の画像に変換します (NULLなら呼ばれません) 84 | // 戻り値 : TRUEなら成功 85 | // : FALSEならAviUtl側でデフォルト変換されます 86 | int reserve[16]; 87 | } COLOR_PLUGIN_TABLE; 88 | 89 | BOOL func_init( void ); 90 | BOOL func_exit( void ); 91 | BOOL func_pixel2yc( COLOR_PROC_INFO *cpip ); 92 | BOOL func_yc2pixel( COLOR_PROC_INFO *cpip ); 93 | 94 | 95 | -------------------------------------------------------------------------------- /AviUtl/colorspace.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * colorspace.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | typedef int func_convert_colorspace 26 | ( 27 | lw_video_output_handler_t *vohp, 28 | AVFrame *picture, 29 | uint8_t *buf 30 | ); 31 | 32 | func_convert_colorspace to_yuv16le_to_lw48; 33 | func_convert_colorspace to_yuv16le_to_yc48; 34 | func_convert_colorspace to_rgba; 35 | func_convert_colorspace to_rgb24; 36 | func_convert_colorspace to_yuy2; 37 | -------------------------------------------------------------------------------- /AviUtl/colorspace_simd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * colorspace_simd.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | void convert_yuv16le_to_yc48_sse2 26 | ( 27 | uint8_t *buf, 28 | int buf_linesize, 29 | uint8_t **dst_data, 30 | int *dst_linesize, 31 | int output_rowsize, 32 | int output_height, 33 | int full_range 34 | ); 35 | void convert_yuv16le_to_yc48_sse4_1 36 | ( 37 | uint8_t *buf, 38 | int buf_linesize, 39 | uint8_t **dst_data, 40 | int *dst_linesize, 41 | int output_rowsize, 42 | int output_height, 43 | int full_range 44 | ); 45 | void convert_yv12i_to_yuy2_ssse3 46 | ( 47 | uint8_t *buf, 48 | int buf_linesize, 49 | uint8_t **pic_data, 50 | int *pic_linesize, 51 | int output_rowsize, 52 | int height 53 | ); 54 | 55 | typedef void func_convert_yuv420ple_i_to_yuv444p16le 56 | ( 57 | uint8_t **dst, 58 | const int *dst_linesize, 59 | uint8_t **pic_data, 60 | int *pic_linesize, 61 | int output_rowsize, 62 | int height 63 | ); 64 | 65 | func_convert_yuv420ple_i_to_yuv444p16le convert_yuv420p9le_i_to_yuv444p16le_sse41; 66 | func_convert_yuv420ple_i_to_yuv444p16le convert_yuv420p10le_i_to_yuv444p16le_sse41; 67 | func_convert_yuv420ple_i_to_yuv444p16le convert_yuv420p16le_i_to_yuv444p16le_sse41; 68 | -------------------------------------------------------------------------------- /AviUtl/dummy_input.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dummy_input.c 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #include "lwinput.h" 26 | 27 | typedef struct 28 | { 29 | uint8_t *dummy_data; 30 | int dummy_size; 31 | } dummy_handler_t; 32 | 33 | static void *open_file( char *file_name, reader_option_t *opt ) 34 | { 35 | return lw_malloc_zero( sizeof(dummy_handler_t) ); 36 | } 37 | 38 | static int get_first_video_track( lsmash_handler_t *h, video_option_t *opt ) 39 | { 40 | if( h->audio_pcm_sample_count == 0 || h->audio_format.Format.nSamplesPerSec == 0 ) 41 | return -1; /* Only available if audio stream is present. */ 42 | if( opt->dummy.framerate_den == 0 ) 43 | return -1; 44 | h->framerate_num = opt->dummy.framerate_num; 45 | h->framerate_den = opt->dummy.framerate_den; 46 | h->video_sample_count = ((uint64_t)h->framerate_num * h->audio_pcm_sample_count - 1) 47 | / ((uint64_t)h->framerate_den * h->audio_format.Format.nSamplesPerSec) + 1; 48 | static const struct 49 | { 50 | int pixel_size; 51 | output_colorspace_tag compression; 52 | } colorspace_table[3] = 53 | { 54 | { YUY2_SIZE, OUTPUT_TAG_YUY2 }, 55 | { RGB24_SIZE, OUTPUT_TAG_RGB }, 56 | { YC48_SIZE, OUTPUT_TAG_YC48 } 57 | }; 58 | int linesize = MAKE_AVIUTL_PITCH( opt->dummy.width * (colorspace_table[ opt->dummy.colorspace ].pixel_size << 3) ); 59 | dummy_handler_t *hp = (dummy_handler_t *)h->video_private; 60 | hp->dummy_size = linesize * opt->dummy.height; 61 | if( hp->dummy_size <= 0 ) 62 | return -1; 63 | hp->dummy_data = lw_malloc_zero( hp->dummy_size ); 64 | if( !hp->dummy_data ) 65 | return -1; 66 | uint8_t *pic = hp->dummy_data; 67 | switch( colorspace_table[ opt->dummy.colorspace ].compression ) 68 | { 69 | case OUTPUT_TAG_YC48 : 70 | case OUTPUT_TAG_RGB : 71 | break; 72 | case OUTPUT_TAG_YUY2 : 73 | for( int i = 0; i < opt->dummy.height; i++ ) 74 | { 75 | for( int j = 0; j < linesize; j += 2 ) 76 | { 77 | pic[j ] = 0; 78 | pic[j + 1] = 128; 79 | } 80 | pic += linesize; 81 | } 82 | break; 83 | default : 84 | lw_freep( &hp->dummy_data ); 85 | return -1; 86 | } 87 | /* BITMAPINFOHEADER */ 88 | h->video_format.biSize = sizeof( BITMAPINFOHEADER ); 89 | h->video_format.biWidth = opt->dummy.width; 90 | h->video_format.biHeight = opt->dummy.height; 91 | h->video_format.biBitCount = colorspace_table[ opt->dummy.colorspace ].pixel_size << 3; 92 | h->video_format.biCompression = colorspace_table[ opt->dummy.colorspace ].compression; 93 | return 0; 94 | } 95 | 96 | static int read_video( lsmash_handler_t *h, int sample_number, void *buf ) 97 | { 98 | /* Generate a black video frame. */ 99 | dummy_handler_t *hp = (dummy_handler_t *)h->video_private; 100 | memcpy( buf, hp->dummy_data, hp->dummy_size ); 101 | return hp->dummy_size; 102 | } 103 | 104 | static void close_file( void *private_stuff ) 105 | { 106 | dummy_handler_t *hp = (dummy_handler_t *)private_stuff; 107 | if( !hp ) 108 | return; 109 | lw_free( hp->dummy_data ); 110 | lw_free( hp ); 111 | } 112 | 113 | lsmash_reader_t dummy_reader = 114 | { 115 | DUMMY_READER, 116 | open_file, 117 | get_first_video_track, 118 | NULL, 119 | NULL, 120 | read_video, 121 | NULL, 122 | NULL, 123 | NULL, 124 | NULL, 125 | NULL, 126 | close_file 127 | }; 128 | -------------------------------------------------------------------------------- /AviUtl/input.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * input.h: 入力プラグイン ヘッダーファイル for AviUtl version 0.99k 以降 3 | ******************************************************************************** 4 | * Copyright (c) 1999-2012 Kenkun 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | *******************************************************************************/ 24 | 25 | // 入力ファイル情報構造体 26 | typedef struct { 27 | int flag; // フラグ 28 | // INPUT_INFO_FLAG_VIDEO : 画像データあり 29 | // INPUT_INFO_FLAG_AUDIO : 音声データあり 30 | // INPUT_INFO_FLAG_VIDEO_RANDOM_ACCESS : キーフレームを気にせずにfunc_read_video()を呼び出します 31 | // ※標準ではキーフレームからシーケンシャルにfunc_read_video()が呼ばれるように制御されます 32 | int rate,scale; // フレームレート 33 | int n; // フレーム数 34 | BITMAPINFOHEADER *format; // 画像フォーマットへのポインタ(次に関数が呼ばれるまで内容を有効にしておく) 35 | int format_size; // 画像フォーマットのサイズ 36 | int audio_n; // 音声サンプル数 37 | WAVEFORMATEX *audio_format; // 音声フォーマットへのポインタ(次に関数が呼ばれるまで内容を有効にしておく) 38 | int audio_format_size; // 音声フォーマットのサイズ 39 | DWORD handler; // 画像codecハンドラ 40 | int reserve[7]; 41 | } INPUT_INFO; 42 | #define INPUT_INFO_FLAG_VIDEO 1 43 | #define INPUT_INFO_FLAG_AUDIO 2 44 | #define INPUT_INFO_FLAG_VIDEO_RANDOM_ACCESS 8 45 | // ※画像フォーマットにはRGB,YUY2とインストールされているcodecのものが使えます。 46 | // また、'Y''C''4''8'(biBitCountは48)でPIXEL_YC形式フォーマットで扱えます。(YUY2フィルタモードでは使用出来ません) 47 | // 音声フォーマットにはPCMとインストールされているcodecのものが使えます。 48 | 49 | // 入力ファイルハンドル 50 | typedef void* INPUT_HANDLE; 51 | 52 | // 入力プラグイン構造体 53 | typedef struct { 54 | int flag; // フラグ 55 | // INPUT_PLUGIN_FLAG_VIDEO : 画像をサポートする 56 | // INPUT_PLUGIN_FLAG_AUDIO : 音声をサポートする 57 | LPSTR name; // プラグインの名前 58 | LPSTR filefilter; // 入力ファイルフィルタ 59 | LPSTR information; // プラグインの情報 60 | BOOL (*func_init)( void ); 61 | // DLL開始時に呼ばれる関数へのポインタ (NULLなら呼ばれません) 62 | BOOL (*func_exit)( void ); 63 | // DLL終了時に呼ばれる関数へのポインタ (NULLなら呼ばれません) 64 | INPUT_HANDLE (*func_open)( LPSTR file ); 65 | // 入力ファイルをオープンする関数へのポインタ 66 | // file : ファイル名 67 | // 戻り値 : TRUEなら入力ファイルハンドル 68 | BOOL (*func_close)( INPUT_HANDLE ih ); 69 | // 入力ファイルをクローズする関数へのポインタ 70 | // ih : 入力ファイルハンドル 71 | // 戻り値 : TRUEなら成功 72 | BOOL (*func_info_get)( INPUT_HANDLE ih,INPUT_INFO *iip ); 73 | // 入力ファイルの情報を取得する関数へのポインタ 74 | // ih : 入力ファイルハンドル 75 | // iip : 入力ファイル情報構造体へのポインタ 76 | // 戻り値 : TRUEなら成功 77 | int (*func_read_video)( INPUT_HANDLE ih,int frame,void *buf ); 78 | // 画像データを読み込む関数へのポインタ 79 | // ih : 入力ファイルハンドル 80 | // frame : 読み込むフレーム番号 81 | // buf : データを読み込むバッファへのポインタ 82 | // 戻り値 : 読み込んだデータサイズ 83 | int (*func_read_audio)( INPUT_HANDLE ih,int start,int length,void *buf ); 84 | // 音声データを読み込む関数へのポインタ 85 | // ih : 入力ファイルハンドル 86 | // start : 読み込み開始サンプル番号 87 | // length : 読み込むサンプル数 88 | // buf : データを読み込むバッファへのポインタ 89 | // 戻り値 : 読み込んだサンプル数 90 | BOOL (*func_is_keyframe)( INPUT_HANDLE ih,int frame ); 91 | // キーフレームか調べる関数へのポインタ (NULLなら全てキーフレーム) 92 | // ih : 入力ファイルハンドル 93 | // frame : フレーム番号 94 | // 戻り値 : キーフレームなら成功 95 | BOOL (*func_config)( HWND hwnd,HINSTANCE dll_hinst ); 96 | // 入力設定のダイアログを要求された時に呼ばれる関数へのポインタ (NULLなら呼ばれません) 97 | // hwnd : ウィンドウハンドル 98 | // dll_hinst : インスタンスハンドル 99 | // 戻り値 : TRUEなら成功 100 | int reserve[16]; 101 | } INPUT_PLUGIN_TABLE; 102 | #define INPUT_PLUGIN_FLAG_VIDEO 1 103 | #define INPUT_PLUGIN_FLAG_AUDIO 2 104 | 105 | BOOL func_init( void ); 106 | BOOL func_exit( void ); 107 | INPUT_HANDLE func_open( LPSTR file ); 108 | BOOL func_close( INPUT_HANDLE ih ); 109 | BOOL func_info_get( INPUT_HANDLE ih,INPUT_INFO *iip ); 110 | int func_read_video( INPUT_HANDLE ih,int frame,void *buf ); 111 | int func_read_audio( INPUT_HANDLE ih,int start,int length,void *buf ); 112 | BOOL func_is_keyframe( INPUT_HANDLE ih,int frame ); 113 | BOOL func_config( HWND hwnd,HINSTANCE dll_hinst ); 114 | 115 | 116 | -------------------------------------------------------------------------------- /AviUtl/lwcolor.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwcolor.h 3 | ***************************************************************************** 4 | * Copyright (C) 2011-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #define YUY2_SIZE 2 24 | #define RGB24_SIZE 3 25 | #define RGBA_SIZE 4 26 | #define YC48_SIZE 6 27 | #define LW48_SIZE 6 28 | 29 | /* LW48 pixel format / LW48 color space. 30 | * As a pixel format, a LW48 pixel consists of packed YUV 16:16:16, 48bpp 16Y 16Cb 16Cr, and 31 | * the 2-byte value for each Y/Cb/Cr component is stored as little-endian. 32 | * As a color space, the derivation of luminance and color-difference signals refers to Rec. ITU-R BT.601. 33 | * - Luminance signal 34 | * The black level corresponding to 4096 and the peak white level corresponding to 60160. 35 | * - Color-difference signal 36 | * The achromatic level corresponding to 32768 and the peak levels corresponding to 4096 and 61440. */ 37 | typedef struct 38 | { 39 | unsigned short y; 40 | unsigned short cb; 41 | unsigned short cr; 42 | } PIXEL_LW48; 43 | 44 | typedef enum 45 | { 46 | OUTPUT_YUY2 = 0, 47 | OUTPUT_RGB24 = 1, 48 | OUTPUT_RGBA = 2, 49 | OUTPUT_YC48 = 3, 50 | OUTPUT_LW48 = 4, 51 | } output_colorspace_index; 52 | 53 | typedef enum 54 | { 55 | OUTPUT_TAG_YUY2 = MAKEFOURCC( 'Y', 'U', 'Y', '2' ), 56 | OUTPUT_TAG_RGB = 0x00000000, 57 | OUTPUT_TAG_RGBA = 0x00000000, 58 | OUTPUT_TAG_YC48 = MAKEFOURCC( 'Y', 'C', '4', '8' ), 59 | OUTPUT_TAG_LW48 = MAKEFOURCC( 'L', 'W', '4', '8' ), 60 | } output_colorspace_tag; 61 | -------------------------------------------------------------------------------- /AviUtl/lwcolor_simd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwcolor_simd.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | void convert_lw48_to_yuy2_sse41( int thread_id, int thread_num, void *param1, void *param2 ); 24 | void convert_lw48_to_rgb24_sse41( int thread_id, int thread_num, void *param1, void *param2 ); 25 | -------------------------------------------------------------------------------- /AviUtl/lwmuxer.rc: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lsmashmuxer.rc 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #include 26 | #include 27 | #include "resource.h" 28 | 29 | /* Dialog resources */ 30 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 31 | IDD_PROGRESS_ABORTABLE DIALOG DISCARDABLE 0, 0, 186, 84 32 | STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP 33 | CAPTION "lsmashmuxer" 34 | FONT 9, "Tahoma" 35 | { 36 | PUSHBUTTON "Cancel", IDCANCEL, 61, 57, 62, 20 37 | CONTROL "", IDC_PROGRESS, PROGRESS_CLASS, PBS_SMOOTH, 17, 34, 152, 17 38 | LTEXT "progress", IDC_PERCENT_TEXT, 19, 13, 150, 14, SS_LEFT 39 | } 40 | 41 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 42 | IDD_PROGRESS_UNABORTABLE DIALOG DISCARDABLE 0, 0, 186, 84 43 | STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP 44 | CAPTION "lsmashmuxer" 45 | FONT 9, "Tahoma" 46 | { 47 | CONTROL "", IDC_PROGRESS, PROGRESS_CLASS, PBS_SMOOTH, 17, 34, 152, 17 48 | LTEXT "progress", IDC_PERCENT_TEXT, 19, 13, 150, 14, SS_LEFT 49 | } 50 | 51 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 52 | IDD_MUXER_OPTIONS DIALOG DISCARDABLE 0, 0, 186, 76 53 | STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP 54 | CAPTION "lsmashmuxer" 55 | FONT 9, "Tahoma" 56 | { 57 | PUSHBUTTON "Mux", IDOK, 42, 50, 40, 18 58 | PUSHBUTTON "Default", IDC_BUTTON_OPTION_DEFAULT, 100, 50, 40, 18 59 | LTEXT "Chapter", IDC_STATIC, 11, 12, 26, 8, SS_LEFT 60 | EDITTEXT IDC_EDIT_CHAPTER_PATH, 38, 10, 94, 14, ES_AUTOHSCROLL 61 | PUSHBUTTON "Browse...", IDC_BUTTON_CHAPTER_BROWSE, 134, 10, 40, 14 62 | AUTOCHECKBOX "Optimize for Progressive Download", IDC_CHECK_OPTIMIZE_PD, 33, 33, 124, 8 63 | } 64 | -------------------------------------------------------------------------------- /AviUtl/progress_dlg.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * progress_dlg.c 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "progress_dlg.h" 30 | #include "resource.h" 31 | 32 | static BOOL CALLBACK dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) 33 | { 34 | switch( msg ) 35 | { 36 | case WM_INITDIALOG : 37 | SetWindowLongPtr( hwnd, GWLP_USERDATA, lparam ); 38 | break; 39 | case WM_COMMAND : 40 | if( wparam == IDCANCEL ) 41 | { 42 | progress_dlg_t *dlg = (progress_dlg_t *)GetWindowLongPtr( hwnd, GWLP_USERDATA ); 43 | dlg->abort = TRUE; 44 | } 45 | break; 46 | default: 47 | break; 48 | } 49 | 50 | return FALSE; 51 | } 52 | 53 | void init_progress_dlg( progress_dlg_t *dlg, const char *module_name, int template_id ) 54 | { 55 | dlg->hnd = NULL; 56 | dlg->progress_percent = -1; 57 | dlg->abort = FALSE; 58 | dlg->hnd = CreateDialogParam( GetModuleHandle( module_name ), 59 | MAKEINTRESOURCE( template_id ), 60 | NULL, dialog_proc, (LPARAM)dlg ); 61 | } 62 | 63 | void close_progress_dlg(progress_dlg_t *dlg) 64 | { 65 | if( dlg->hnd ) 66 | DestroyWindow( dlg->hnd ); 67 | dlg->hnd = NULL; 68 | dlg->progress_percent = -1; 69 | dlg->abort = FALSE; 70 | } 71 | 72 | int update_progress_dlg( progress_dlg_t *dlg, const char *mes, int progress_percent ) 73 | { 74 | if( dlg->abort == FALSE ) 75 | { 76 | for( MSG message; PeekMessage( &message, NULL, 0, 0, PM_REMOVE ); ) 77 | { 78 | TranslateMessage( &message ); 79 | DispatchMessage ( &message ); 80 | } 81 | if( dlg->progress_percent < progress_percent ) 82 | { 83 | dlg->progress_percent = progress_percent; 84 | progress_percent = min( progress_percent, 100 ); 85 | char window_mes[256]; 86 | sprintf( window_mes, "%s... %d %%", mes, progress_percent ); 87 | if( !IsWindowVisible( dlg->hnd ) ) 88 | ShowWindow( dlg->hnd, SW_SHOW ); 89 | HWND window_text = GetDlgItem( dlg->hnd, IDC_PERCENT_TEXT ); 90 | SetWindowText( window_text, window_mes ); 91 | HWND window_prg = GetDlgItem( dlg->hnd, IDC_PROGRESS ); 92 | PostMessage( window_prg, PBM_SETPOS, progress_percent, 0 ); 93 | } 94 | } 95 | return dlg->abort; 96 | } 97 | -------------------------------------------------------------------------------- /AviUtl/progress_dlg.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * progress_dlg.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #ifndef _PROGRESS_DLG_H_ 26 | #define _PROGRESS_DLG_H_ 27 | 28 | typedef struct 29 | { 30 | HWND hnd; 31 | int progress_percent; 32 | int abort; 33 | } progress_dlg_t; 34 | 35 | void init_progress_dlg( progress_dlg_t *dlg, const char *module_name, int template_id ); 36 | void close_progress_dlg( progress_dlg_t *dlg ); 37 | int update_progress_dlg( progress_dlg_t *dlg, const char *mes, int progress_percent ); 38 | 39 | #endif /* _PROGRESS_DLG_H_ */ 40 | -------------------------------------------------------------------------------- /AviUtl/resource.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * resource.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #ifndef IDC_STATIC 26 | #define IDC_STATIC (-1) 27 | #endif 28 | 29 | /* Progress dialog */ 30 | #define IDD_PROGRESS_ABORTABLE 101 31 | #define IDD_PROGRESS_UNABORTABLE 102 32 | #define IDC_PERCENT_TEXT 1000 33 | #define IDC_PROGRESS 1001 34 | 35 | /* Reader dialog */ 36 | #define IDC_CHECK_LIBAVSMASH_INPUT 1100 37 | #define IDC_CHECK_AVS_INPUT 1101 38 | #define IDC_CHECK_VPY_INPUT 1102 39 | #define IDC_CHECK_LIBAV_INPUT 1103 40 | #define IDC_EDIT_THREADS 1110 41 | #define IDC_SPIN_THREADS 1111 42 | #define IDC_EDIT_FORWARD_THRESHOLD 1120 43 | #define IDC_SPIN_FORWARD_THRESHOLD 1121 44 | #define IDC_COMBOBOX_SEEK_MODE 1122 45 | #define IDC_CHECK_APPLY_REPEAT_FLAG 1130 46 | #define IDC_COMBOBOX_FIELD_DOMINANCE 1131 47 | #define IDC_COMBOBOX_SCALER 1132 48 | #define IDC_CHECK_VFR_TO_CFR 1133 49 | #define IDC_EDIT_CONST_FRAMERATE_NUM 1134 50 | #define IDC_EDIT_CONST_FRAMERATE_DEN 1135 51 | #define IDC_EDIT_AUDIO_DELAY 1140 52 | #define IDC_EDIT_SAMPLE_RATE 1141 53 | #define IDC_EDIT_CHANNEL_LAYOUT 1142 54 | #define IDC_SLIDER_MIX_LEVEL_CENTER 1143 55 | #define IDC_SLIDER_MIX_LEVEL_SURROUND 1144 56 | #define IDC_SLIDER_MIX_LEVEL_LFE 1145 57 | #define IDC_TEXT_MIX_LEVEL_CENTER 1146 58 | #define IDC_TEXT_MIX_LEVEL_SURROUND 1147 59 | #define IDC_TEXT_MIX_LEVEL_LFE 1148 60 | #define IDC_CHECK_AV_SYNC 1149 61 | #define IDC_CHECK_CREATE_INDEX_FILE 1150 62 | #define IDC_CHECK_FORCE_VIDEO 1151 63 | #define IDC_EDIT_FORCE_VIDEO_INDEX 1152 64 | #define IDC_CHECK_FORCE_AUDIO 1153 65 | #define IDC_EDIT_FORCE_AUDIO_INDEX 1154 66 | #define IDC_EDIT_DUMMY_WIDTH 1160 67 | #define IDC_EDIT_DUMMY_HEIGHT 1161 68 | #define IDC_EDIT_DUMMY_FRAMERATE_NUM 1162 69 | #define IDC_EDIT_DUMMY_FRAMERATE_DEN 1163 70 | #define IDC_COMBOBOX_DUMMY_COLORSPACE 1164 71 | #define IDC_CHECK_LW48_OUTPUT 1170 72 | #define IDC_COMBOBOX_AVS_BITDEPTH 1171 73 | #define IDC_EDIT_PREFERRED_DECODERS 1180 74 | #define IDC_TEXT_LIBRARY_INFO 1190 75 | 76 | /* Muxer dialog */ 77 | #define IDD_MUXER_OPTIONS 103 78 | #define IDC_BUTTON_OPTION_DEFAULT 1200 79 | #define IDC_BUTTON_CHAPTER_BROWSE 1201 80 | #define IDC_EDIT_CHAPTER_PATH 1202 81 | #define IDC_CHECK_OPTIMIZE_PD 1203 82 | -------------------------------------------------------------------------------- /AviUtl/video_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. 23 | * Don't distribute it if its license is GPL. */ 24 | 25 | #include "../common/video_output.h" 26 | #include "colorspace.h" 27 | 28 | typedef struct 29 | { 30 | int output_linesize; 31 | uint32_t output_frame_size; 32 | uint8_t *back_ground; 33 | uint8_t *another_chroma; 34 | uint32_t another_chroma_size; 35 | AVFrame *yuv444p16; 36 | func_convert_colorspace *convert_colorspace; 37 | } au_video_output_handler_t; 38 | 39 | int au_setup_video_rendering 40 | ( 41 | lw_video_output_handler_t *vohp, 42 | video_option_t *opt, 43 | BITMAPINFOHEADER *format, 44 | int output_width, 45 | int output_height, 46 | enum AVPixelFormat input_pixel_format 47 | ); 48 | 49 | int convert_colorspace 50 | ( 51 | lw_video_output_handler_t *vohp, 52 | AVFrame *picture, 53 | uint8_t *buf 54 | ); 55 | -------------------------------------------------------------------------------- /VapourSynth/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2011-2015 L-SMASH Works project 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any 4 | purpose with or without fee is hereby granted, provided that the above 5 | copyright notice and this permission notice appear in all copies. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | ----------------------------------------------------------------------------- 16 | 17 | Copyright (c) 2012 Fredrik Mellbin 18 | 19 | This file is part of VapourSynth. 20 | 21 | VapourSynth is free software; you can redistribute it and/or 22 | modify it under the terms of the GNU Lesser General Public 23 | License as published by the Free Software Foundation; either 24 | version 2.1 of the License, or (at your option) any later version. 25 | 26 | VapourSynth is distributed in the hope that it will be useful, 27 | but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | Lesser General Public License for more details. 30 | 31 | You should have received a copy of the GNU Lesser General Public 32 | License along with VapourSynth; if not, write to the Free Software 33 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 34 | -------------------------------------------------------------------------------- /VapourSynth/lsmashsource.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lsmashsource.c 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include "../common/cpp_compat.h" 25 | #include "../common/lwindex_version.h" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include "lsmashsource.h" 32 | 33 | #include "libavutil/ffversion.h" 34 | #include "libavcodec/version.h" 35 | #include "libavformat/version.h" 36 | #include "libavutil/version.h" 37 | #include "libswscale/version.h" 38 | #include "version.h" 39 | 40 | void set_error 41 | ( 42 | lw_log_handler_t *lhp, 43 | lw_log_level level, 44 | const char *message 45 | ) 46 | { 47 | vs_basic_handler_t *eh = (vs_basic_handler_t *)lhp->priv; 48 | if( !eh || !eh->vsapi ) 49 | return; 50 | if( eh->out ) 51 | eh->vsapi->setError( eh->out, message ); 52 | else if( eh->frame_ctx ) 53 | eh->vsapi->setFilterError( message, eh->frame_ctx ); 54 | } 55 | 56 | void set_error_on_init 57 | ( 58 | VSMap *out, 59 | const VSAPI *vsapi, 60 | const char *format, 61 | ... 62 | ) 63 | { 64 | char message[4096]; 65 | va_list args; 66 | va_start( args, format ); 67 | vsnprintf( message, sizeof message, format, args ); 68 | va_end( args ); 69 | vsapi->setError( out, message ); 70 | } 71 | 72 | extern void VS_CC vs_libavsmashsource_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ); 73 | extern void VS_CC vs_lwlibavsource_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ); 74 | 75 | void VS_CC vs_version_create( const VSMap *in, VSMap *out, void *user_data, VSCore *core, const VSAPI *vsapi ) 76 | { 77 | vsapi->propSetData(out, "version", VERSION, -1, paAppend); 78 | vsapi->propSetData(out, "config", config_opts, -1, paAppend); 79 | vsapi->propSetData(out, "ffmpeg_version", FFMPEG_VERSION, -1, paAppend); 80 | vsapi->propSetData(out, "ffmpeg_version", LIBAVCODEC_IDENT, -1, paAppend); 81 | vsapi->propSetData(out, "ffmpeg_version", LIBAVFORMAT_IDENT, -1, paAppend); 82 | vsapi->propSetData(out, "ffmpeg_version", LIBAVUTIL_IDENT, -1, paAppend); 83 | vsapi->propSetData(out, "ffmpeg_version", LIBSWSCALE_IDENT, -1, paAppend); 84 | vsapi->propSetData(out, "lwindex_version", lwindex_version_header(), -1, paAppend); 85 | } 86 | 87 | VS_EXTERNAL_API(void) VapourSynthPluginInit( VSConfigPlugin config_func, VSRegisterFunction register_func, VSPlugin *plugin ) 88 | { 89 | config_func 90 | ( 91 | "systems.innocent.lsmas", 92 | "lsmas", 93 | "LSMASHSource for VapourSynth", 94 | VAPOURSYNTH_API_VERSION, 95 | 1, 96 | plugin 97 | ); 98 | #define COMMON_OPTS "threads:int:opt;seek_mode:int:opt;seek_threshold:int:opt;dr:int:opt;fpsnum:int:opt;fpsden:int:opt;variable:int:opt;format:data:opt;decoder:data:opt;prefer_hw:int:opt;" 99 | register_func 100 | ( 101 | "LibavSMASHSource", 102 | "source:data;track:int:opt;" COMMON_OPTS "ff_loglevel:int:opt;", 103 | vs_libavsmashsource_create, 104 | NULL, 105 | plugin 106 | ); 107 | register_func 108 | ( 109 | "LWLibavSource", 110 | "source:data;stream_index:int:opt;cache:int:opt;cachefile:data:opt;" COMMON_OPTS "repeat:int:opt;dominance:int:opt;ff_loglevel:int:opt;cachedir:data:opt;soft_reset:int:opt;framelist:int:opt;", 111 | vs_lwlibavsource_create, 112 | NULL, 113 | plugin 114 | ); 115 | register_func 116 | ( 117 | "Version", 118 | "", 119 | vs_version_create, 120 | NULL, 121 | plugin 122 | ); 123 | #undef COMMON_OPTS 124 | } 125 | -------------------------------------------------------------------------------- /VapourSynth/lsmashsource.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lsmashsource.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. 22 | * However, when distributing its binary file, it will be under LGPL or GPL. */ 23 | 24 | #include 25 | 26 | #include "../common/utils.h" 27 | 28 | #define PREFERRED_DECODER_NAMES_BUFSIZE 512 29 | 30 | typedef struct 31 | { 32 | VSMap *out; 33 | VSFrameContext *frame_ctx; 34 | const VSAPI *vsapi; 35 | } vs_basic_handler_t; 36 | 37 | void set_error 38 | ( 39 | lw_log_handler_t *lhp, 40 | lw_log_level level, 41 | const char *message 42 | ); 43 | 44 | void set_error_on_init 45 | ( 46 | VSMap *out, 47 | const VSAPI *vsapi, 48 | const char *format, 49 | ... 50 | ); 51 | 52 | static inline void set_option_int64 53 | ( 54 | int64_t *opt, 55 | int64_t default_value, 56 | const char *arg, 57 | const VSMap *in, 58 | const VSAPI *vsapi 59 | ) 60 | { 61 | int e; 62 | *opt = vsapi->propGetInt( in, arg, 0, &e ); 63 | if( e ) 64 | *opt = default_value; 65 | } 66 | 67 | static inline void set_option_string 68 | ( 69 | const char **opt, 70 | const char *default_value, 71 | const char *arg, 72 | const VSMap *in, 73 | const VSAPI *vsapi 74 | ) 75 | { 76 | int e; 77 | *opt = vsapi->propGetData( in, arg, 0, &e ); 78 | if( e ) 79 | *opt = default_value; 80 | } 81 | 82 | static inline void set_preferred_decoder_names_on_buf 83 | ( 84 | char *preferred_decoder_names_buf, 85 | const char *preferred_decoder_names 86 | ) 87 | { 88 | memset( preferred_decoder_names_buf, 0, PREFERRED_DECODER_NAMES_BUFSIZE ); 89 | if( preferred_decoder_names ) 90 | memcpy( preferred_decoder_names_buf, 91 | preferred_decoder_names, 92 | MIN( PREFERRED_DECODER_NAMES_BUFSIZE - 1, strlen(preferred_decoder_names) ) ); 93 | } 94 | 95 | static inline const char **tokenize_preferred_decoder_names 96 | ( 97 | char *preferred_decoder_names_buf 98 | ) 99 | { 100 | return lw_tokenize_string( preferred_decoder_names_buf, ',', NULL ); 101 | } 102 | -------------------------------------------------------------------------------- /VapourSynth/meson.build: -------------------------------------------------------------------------------- 1 | project('L-SMASH-Works', 'c', 2 | default_options: ['buildtype=release', 'b_ndebug=if-release', 'c_std=c99'], 3 | meson_version: '>=0.48.0' 4 | ) 5 | 6 | version_h = declare_dependency( 7 | sources: vcs_tag( 8 | command: ['git', 'describe', '--tags', '--long'], 9 | input: 'version.h.in', 10 | output: 'version.h' 11 | ) 12 | ) 13 | 14 | add_project_arguments('-DXXH_INLINE_ALL', '-D_FILE_OFFSET_BITS=64', '-DDEFAULT_CACHEDIR=' + get_option('cachedir'), language: 'c') 15 | 16 | sources = [ 17 | 'libavsmash_source.c', 18 | 'lsmashsource.c', 19 | 'lsmashsource.h', 20 | 'lwlibav_source.c', 21 | 'video_output.c', 22 | 'video_output.h', 23 | '../common/decode.c', 24 | '../common/decode.h', 25 | '../common/libavsmash.c', 26 | '../common/libavsmash.h', 27 | '../common/libavsmash_video.c', 28 | '../common/libavsmash_video.h', 29 | '../common/lwindex.c', 30 | '../common/lwindex.h', 31 | '../common/lwlibav_audio.c', 32 | '../common/lwlibav_audio.h', 33 | '../common/lwlibav_dec.c', 34 | '../common/lwlibav_dec.h', 35 | '../common/lwlibav_video.c', 36 | '../common/lwlibav_video.h', 37 | '../common/osdep.c', 38 | '../common/osdep.h', 39 | '../common/qsv.c', 40 | '../common/qsv.h', 41 | '../common/utils.c', 42 | '../common/utils.h', 43 | '../common/video_output.c', 44 | '../common/video_output.h' 45 | ] 46 | 47 | vapoursynth_dep = dependency('vapoursynth').partial_dependency(compile_args: true, includes: true) 48 | 49 | deps = [ 50 | vapoursynth_dep, 51 | dependency('liblsmash'), 52 | dependency('libavcodec', version: '>=58.91.0'), 53 | dependency('libavformat', version: '>=58.45.0'), 54 | dependency('libavutil', version: '>=56.51.0'), 55 | dependency('libswscale', version: '>=5.7.0'), 56 | version_h 57 | ] 58 | 59 | if host_machine.cpu_family().startswith('x86') 60 | add_project_arguments('-mfpmath=sse', '-msse2', language: 'c') 61 | endif 62 | 63 | if host_machine.system() == 'windows' 64 | add_project_arguments('-D__USE_MINGW_ANSI_STDIO', language: 'c') 65 | if host_machine.cpu_family() == 'x86' 66 | add_project_arguments('-static-libgcc', language: 'c') 67 | add_global_link_arguments('-static-libgcc', language: 'c') 68 | add_global_link_arguments('-Wl,--add-stdcall-alias', language: 'c') 69 | endif 70 | endif 71 | 72 | shared_module('vslsmashsource', sources, 73 | dependencies: deps, 74 | install: true, 75 | install_dir: join_paths(vapoursynth_dep.get_pkgconfig_variable('libdir'), 'vapoursynth'), 76 | gnu_symbol_visibility: 'hidden' 77 | ) 78 | -------------------------------------------------------------------------------- /VapourSynth/meson_options.txt: -------------------------------------------------------------------------------- 1 | # -Dcachedir=val set the default value for the cachedir option. Examples: 2 | # (1) "": store *.lwi along side the source video file (the previous behavior) 3 | # (2) ".": store *.lwi at the current directory 4 | # (3) "/tmp": store *.lwi at /tmp 5 | # (4) getenv("TMPDIR") [Unix] or getenv("TEMP") [Windows]: store *.lwi at system temporary directory. 6 | # If unspecified, the default value is "". 7 | option('cachedir', type: 'string', value: '""', description: 'Default value for cachedir parameter, e.g. "" to store along side the source video file; "." to store at current working directory and getenv("TMPDIR") to use temporary directory') 8 | -------------------------------------------------------------------------------- /VapourSynth/version.h.in: -------------------------------------------------------------------------------- 1 | #define VERSION "@VCS_TAG@" 2 | 3 | #define STRINGIFY_(x) #x 4 | #define STRINGIFY(x) STRINGIFY_(x) 5 | static const char *config_opts = "-Dcachedir=\"" STRINGIFY(DEFAULT_CACHEDIR) "\""; 6 | -------------------------------------------------------------------------------- /VapourSynth/video_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include "../common/video_output.h" 24 | 25 | typedef int component_reorder_t; 26 | enum { component_reorder_bigendian = 0x80 }; 27 | #define component_reorder_get_order(order) ((order) & ~component_reorder_bigendian) 28 | #define component_reorder_is_bigendian(order) (!!((order) & component_reorder_bigendian)) 29 | 30 | typedef void func_make_black_background 31 | ( 32 | VSFrameRef *vs_frame, 33 | const VSAPI *vsapi 34 | ); 35 | 36 | typedef void func_make_frame 37 | ( 38 | lw_video_scaler_handler_t *vshp, 39 | AVFrame *av_picture, 40 | const component_reorder_t *component_reorder, 41 | VSFrameRef *vs_frame, 42 | VSFrameContext *frame_ctx, 43 | const VSAPI *vsapi 44 | ); 45 | 46 | typedef struct 47 | { 48 | int variable_info; 49 | int direct_rendering; 50 | const component_reorder_t *component_reorder[2]; 51 | VSPresetFormat vs_output_pixel_format; 52 | VSFrameRef *background_frame[2]; 53 | func_make_black_background *make_black_background[2]; 54 | func_make_frame *make_frame[2]; 55 | VSFrameContext *frame_ctx; 56 | VSCore *core; 57 | const VSAPI *vsapi; 58 | } vs_video_output_handler_t; 59 | 60 | VSPresetFormat get_vs_output_pixel_format( const char *format_name ); 61 | 62 | VSFrameRef *make_frame 63 | ( 64 | lw_video_output_handler_t *vohp, 65 | AVFrame *av_frame, 66 | int output_index 67 | ); 68 | 69 | int vs_setup_video_rendering 70 | ( 71 | lw_video_output_handler_t *lw_vohp, 72 | AVCodecContext *ctx, 73 | VSVideoInfo *vi, 74 | VSMap *out, 75 | int width, 76 | int height 77 | ); 78 | 79 | vs_video_output_handler_t *vs_allocate_video_output_handler 80 | ( 81 | lw_video_output_handler_t *vohp 82 | ); 83 | 84 | void vs_set_frame_properties 85 | ( 86 | int n, 87 | AVFrame *av_frame, 88 | AVStream *stream, 89 | int64_t duration_num, 90 | int64_t duration_den, 91 | VSFrameRef *vs_frame, 92 | int top, 93 | int bottom, 94 | const VSAPI *vsapi 95 | ); 96 | -------------------------------------------------------------------------------- /common/audio_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * audio_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include "cpp_compat.h" 24 | 25 | typedef struct 26 | { 27 | SwrContext *swr_ctx; 28 | uint8_t *resampled_buffer; 29 | int resampled_buffer_size; 30 | int input_planes; 31 | uint64_t input_channel_layout; 32 | enum AVSampleFormat input_sample_format; 33 | int input_sample_rate; 34 | int input_block_align; 35 | uint64_t output_channel_layout; 36 | enum AVSampleFormat output_sample_format; 37 | int output_sample_rate; 38 | int output_block_align; 39 | int output_bits_per_sample; 40 | int s24_output; 41 | uint64_t request_length; 42 | uint64_t skip_decoded_samples; /* Upsampling by the decoder is considered. */ 43 | uint64_t output_sample_offset; 44 | } lw_audio_output_handler_t; 45 | 46 | enum audio_output_flag 47 | { 48 | AUDIO_OUTPUT_NO_FLAGS = 0, 49 | AUDIO_OUTPUT_ENOUGH = 1 << 0, 50 | AUDIO_DECODER_DELAY = 1 << 1, 51 | AUDIO_DECODER_ERROR = 1 << 2, 52 | AUDIO_RECONFIG_FAILURE = 1 << 3, 53 | AUDIO_DECODER_RECEIVED_PACKET = 1 << 4, 54 | }; 55 | CPP_DEFINE_OR_SUBSTITUTE_OPERATOR( enum audio_output_flag ) 56 | 57 | uint64_t output_pcm_samples_from_buffer 58 | ( 59 | lw_audio_output_handler_t *aohp, 60 | AVFrame *frame_buffer, 61 | uint8_t **output_buffer, 62 | enum audio_output_flag *output_flags 63 | ); 64 | 65 | uint64_t output_pcm_samples_from_packet 66 | ( 67 | lw_audio_output_handler_t *aohp, 68 | AVCodecContext *ctx, 69 | AVPacket *pkt, 70 | AVFrame *frame_buffer, 71 | uint8_t **output_buffer, 72 | enum audio_output_flag *output_flags 73 | ); 74 | 75 | void lw_cleanup_audio_output_handler 76 | ( 77 | lw_audio_output_handler_t *aohp 78 | ); 79 | -------------------------------------------------------------------------------- /common/cpp_compat.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cpp_compat.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #ifndef LW_CPP_COMPAT_H 24 | #define LW_CPP_COMPAT_H 25 | 26 | #ifdef _MSC_VER 27 | #define _CRT_SECURE_NO_WARNINGS 28 | #pragma warning( disable:4996 ) 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | # ifndef __STDC_CONSTANT_MACROS 33 | # define __STDC_CONSTANT_MACROS 34 | # endif 35 | # ifndef __STDC_LIMIT_MACROS 36 | # define __STDC_LIMIT_MACROS 37 | # endif 38 | # ifndef __STDC_FORMAT_MACROS 39 | # define __STDC_FORMAT_MACROS 40 | # endif 41 | #endif /* __cplusplus */ 42 | 43 | #ifdef __cplusplus 44 | #define CPP_DEFINE_OR_SUBSTITUTE_OPERATOR( ENUM ) \ 45 | inline ENUM operator |= ( ENUM &x, const ENUM y ) \ 46 | { \ 47 | x = (ENUM)(((unsigned int)x)|((unsigned int)y)); \ 48 | return x; \ 49 | } 50 | #else 51 | #define CPP_DEFINE_OR_SUBSTITUTE_OPERATOR( ENUM ) 52 | #endif /* __cplusplus */ 53 | 54 | #endif /* LW_CPP_COMPAT_H */ 55 | -------------------------------------------------------------------------------- /common/decode.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * decode.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2016 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | static inline uint32_t get_decoder_delay 24 | ( 25 | AVCodecContext *ctx 26 | ) 27 | { 28 | return ctx->has_b_frames + ((ctx->active_thread_type & FF_THREAD_FRAME) ? ctx->thread_count - 1 : 0); 29 | } 30 | 31 | const AVCodec *find_decoder 32 | ( 33 | enum AVCodecID codec_id, 34 | const AVCodecParameters *codecpar, 35 | const char **preferred_decoder_names, 36 | const int prefer_hw_decoder 37 | ); 38 | 39 | int open_decoder 40 | ( 41 | AVCodecContext **ctx, 42 | const AVCodecParameters *codecpar, 43 | const AVCodec *codec, 44 | const int thread_count 45 | ); 46 | 47 | int find_and_open_decoder 48 | ( 49 | AVCodecContext **ctx, 50 | const AVCodecParameters *codecpar, 51 | const char **preferred_decoder_names, 52 | const int prefer_hw_decoder, 53 | const int thread_count 54 | ); 55 | 56 | int decode_video_packet 57 | ( 58 | AVCodecContext *ctx, 59 | AVFrame *av_frame, 60 | int *got_frame, 61 | AVPacket *pkt 62 | ); 63 | 64 | int decode_audio_packet 65 | ( 66 | AVCodecContext *ctx, 67 | AVFrame *av_frame, 68 | int *got_frame, 69 | AVPacket *pkt 70 | ); 71 | -------------------------------------------------------------------------------- /common/libavsmash.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libavsmash.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | typedef struct 24 | { 25 | int width; /* the maximum visual presentation width */ 26 | int height; /* the maximum visual presentation height */ 27 | uint64_t channel_layout; 28 | enum AVSampleFormat sample_format; 29 | int sample_rate; 30 | int bits_per_sample; 31 | int frame_length; 32 | } extended_summary_t; 33 | 34 | typedef struct 35 | { 36 | lsmash_summary_t *summary; 37 | extended_summary_t extended; 38 | } libavsmash_summary_t; 39 | 40 | typedef struct 41 | { 42 | int error; 43 | int update_pending; 44 | int dequeue_packet; 45 | uint32_t count; 46 | uint32_t index; /* index of the current decoder configuration */ 47 | uint32_t delay_count; 48 | uint8_t *input_buffer; 49 | AVCodecContext *ctx; 50 | const char **preferred_decoder_names; 51 | int prefer_hw_decoder; 52 | libavsmash_summary_t *entries; 53 | extended_summary_t prefer; 54 | lw_log_handler_t lh; 55 | int (*get_buffer)( struct AVCodecContext *, AVFrame *, int ); 56 | struct 57 | { 58 | uint32_t index; /* index of the queued decoder configuration */ 59 | uint32_t delay_count; 60 | uint32_t sample_number; 61 | AVPacket packet; 62 | enum AVCodecID codec_id; 63 | uint8_t *extradata; 64 | int extradata_size; 65 | /* Parameters stored in audio summary doesn't always tell appropriate info. 66 | * The followings are imported from CODEC specific extensions. */ 67 | int sample_rate; 68 | int bits_per_sample; 69 | int channels; 70 | } queue; 71 | } codec_configuration_t; 72 | 73 | #ifdef __cplusplus 74 | extern "C" 75 | { 76 | #endif /* __cplusplus */ 77 | 78 | lsmash_root_t *libavsmash_open_file 79 | ( 80 | AVFormatContext **p_format_ctx, 81 | const char *file_name, 82 | lsmash_file_parameters_t *file_param, 83 | lsmash_movie_parameters_t *movie_param, 84 | lw_log_handler_t *lhp 85 | ); 86 | 87 | uint32_t libavsmash_get_track_by_media_type 88 | ( 89 | lsmash_root_t *root, 90 | uint32_t type, 91 | uint32_t track_number, 92 | lw_log_handler_t *lhp 93 | ); 94 | 95 | int get_summaries 96 | ( 97 | lsmash_root_t *root, 98 | uint32_t track_ID, 99 | codec_configuration_t *config 100 | ); 101 | 102 | int libavsmash_find_and_open_decoder 103 | ( 104 | codec_configuration_t *config, 105 | const AVCodecParameters *codecpar, 106 | const int thread_count 107 | ); 108 | 109 | int initialize_decoder_configuration 110 | ( 111 | lsmash_root_t *root, 112 | uint32_t track_ID, 113 | codec_configuration_t *config 114 | ); 115 | 116 | int get_sample 117 | ( 118 | lsmash_root_t *root, 119 | uint32_t track_ID, 120 | uint32_t sample_number, 121 | codec_configuration_t *config, 122 | AVPacket *pkt 123 | ); 124 | 125 | void update_configuration 126 | ( 127 | lsmash_root_t *root, 128 | uint32_t track_ID, 129 | codec_configuration_t *config 130 | ); 131 | 132 | void libavsmash_flush_buffers 133 | ( 134 | codec_configuration_t *config 135 | ); 136 | 137 | void cleanup_configuration 138 | ( 139 | codec_configuration_t *config 140 | ); 141 | 142 | #ifdef __cplusplus 143 | } 144 | #endif /* __cplusplus */ 145 | -------------------------------------------------------------------------------- /common/libavsmash_audio_internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libavsmash_audio_internal.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | struct libavsmash_audio_decode_handler_tag 24 | { 25 | lsmash_root_t *root; 26 | uint32_t track_id; 27 | codec_configuration_t config; 28 | AVFrame *frame_buffer; 29 | AVPacket packet; 30 | uint64_t pcm_sample_count; 31 | uint64_t next_pcm_sample_number; 32 | uint32_t last_frame_number; 33 | uint32_t frame_count; 34 | int implicit_preroll; 35 | uint32_t media_timescale; 36 | uint64_t media_duration; /* unused */ 37 | uint64_t min_cts; 38 | }; 39 | -------------------------------------------------------------------------------- /common/libavsmash_video_internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libavsmash_video_internal.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #define SEEK_MODE_NORMAL 0 24 | #define SEEK_MODE_UNSAFE 1 25 | #define SEEK_MODE_AGGRESSIVE 2 26 | 27 | typedef struct 28 | { 29 | uint32_t composition_to_decoding; 30 | } order_converter_t; 31 | 32 | struct libavsmash_video_decode_handler_tag 33 | { 34 | lsmash_root_t *root; 35 | uint32_t track_id; 36 | codec_configuration_t config; 37 | AVFrame *frame_buffer; 38 | uint32_t forward_seek_threshold; 39 | int seek_mode; 40 | order_converter_t *order_converter; 41 | uint8_t *keyframe_list; 42 | uint32_t sample_count; 43 | uint32_t last_sample_number; 44 | uint32_t last_rap_number; 45 | uint32_t first_valid_frame_number; 46 | AVFrame *first_valid_frame; 47 | uint32_t media_timescale; 48 | uint64_t media_duration; 49 | uint64_t min_cts; 50 | }; 51 | -------------------------------------------------------------------------------- /common/lwindex.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwindex.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | typedef struct 24 | { 25 | const char *file_path; 26 | const char *cache_dir; 27 | int threads; 28 | int av_sync; 29 | int no_create_index; 30 | const char *index_file_path; 31 | int force_video; 32 | int force_video_index; 33 | int force_audio; 34 | int force_audio_index; 35 | int apply_repeat_flag; 36 | int field_dominance; 37 | struct 38 | { 39 | int active; 40 | uint32_t fps_num; 41 | uint32_t fps_den; 42 | } vfr2cfr; 43 | } lwlibav_option_t; 44 | 45 | #ifdef __cplusplus 46 | extern "C" 47 | { 48 | #endif /* __cplusplus */ 49 | 50 | int lwlibav_construct_index 51 | ( 52 | lwlibav_file_handler_t *lwhp, 53 | lwlibav_video_decode_handler_t *vdhp, 54 | lwlibav_video_output_handler_t *vohp, 55 | lwlibav_audio_decode_handler_t *adhp, 56 | lwlibav_audio_output_handler_t *aohp, 57 | lw_log_handler_t *lhp, 58 | lwlibav_option_t *opt, 59 | progress_indicator_t *indicator, 60 | progress_handler_t *php 61 | ); 62 | 63 | int lwlibav_import_av_index_entry 64 | ( 65 | lwlibav_decode_handler_t *dhp 66 | ); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif /* __cplusplus */ 71 | -------------------------------------------------------------------------------- /common/lwindex_version.h: -------------------------------------------------------------------------------- 1 | #ifndef LWINDEX_VERSION_H 2 | #define LWINDEX_VERSION_H 3 | 4 | #include 5 | 6 | /* lwindex version 7 | * Major.Minor.Micro.Build */ 8 | #define LWINDEX_VERSION ((0 << 24) | (0 << 16) | (3 << 8) | 1) 9 | 10 | /* index file version 11 | * This version is bumped when its structure changed so that the lwindex invokes 12 | * reindexing opened file immediately. */ 13 | #define LWINDEX_INDEX_FILE_VERSION 16 14 | 15 | const char *lwindex_version_header(); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /common/lwlibav_audio.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwlibav_audio.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | /***************************************************************************** 24 | * Opaque Handlers 25 | *****************************************************************************/ 26 | typedef lw_audio_output_handler_t lwlibav_audio_output_handler_t; 27 | 28 | typedef struct lwlibav_audio_decode_handler_tag lwlibav_audio_decode_handler_t; 29 | 30 | #ifdef __cplusplus 31 | extern "C" 32 | { 33 | #endif /* __cplusplus */ 34 | 35 | /***************************************************************************** 36 | * Allocators / Deallocators 37 | *****************************************************************************/ 38 | lwlibav_audio_decode_handler_t *lwlibav_audio_alloc_decode_handler 39 | ( 40 | void 41 | ); 42 | 43 | lwlibav_audio_output_handler_t *lwlibav_audio_alloc_output_handler 44 | ( 45 | void 46 | ); 47 | 48 | void lwlibav_audio_free_decode_handler 49 | ( 50 | lwlibav_audio_decode_handler_t *adhp 51 | ); 52 | 53 | void lwlibav_audio_free_output_handler 54 | ( 55 | lwlibav_audio_output_handler_t *aohp 56 | ); 57 | 58 | void lwlibav_audio_free_decode_handler_ptr 59 | ( 60 | lwlibav_audio_decode_handler_t **adhpp 61 | ); 62 | 63 | void lwlibav_audio_free_output_handler_ptr 64 | ( 65 | lwlibav_audio_output_handler_t **aohpp 66 | ); 67 | 68 | /***************************************************************************** 69 | * Setters 70 | *****************************************************************************/ 71 | void lwlibav_audio_set_preferred_decoder_names 72 | ( 73 | lwlibav_audio_decode_handler_t *adhp, 74 | const char **preferred_decoder_names 75 | ); 76 | 77 | void lwlibav_audio_set_codec_context 78 | ( 79 | lwlibav_audio_decode_handler_t *adhp, 80 | AVCodecContext *ctx 81 | ); 82 | 83 | /***************************************************************************** 84 | * Getters 85 | *****************************************************************************/ 86 | const char **lwlibav_audio_get_preferred_decoder_names 87 | ( 88 | lwlibav_audio_decode_handler_t *adhp 89 | ); 90 | 91 | lw_log_handler_t *lwlibav_audio_get_log_handler 92 | ( 93 | lwlibav_audio_decode_handler_t *adhp 94 | ); 95 | 96 | AVCodecContext *lwlibav_audio_get_codec_context 97 | ( 98 | lwlibav_audio_decode_handler_t *adhp 99 | ); 100 | 101 | /***************************************************************************** 102 | * Others 103 | *****************************************************************************/ 104 | void lwlibav_audio_force_seek 105 | ( 106 | lwlibav_audio_decode_handler_t *adhp 107 | ); 108 | 109 | int lwlibav_audio_get_desired_track 110 | ( 111 | const char *file_path, 112 | lwlibav_audio_decode_handler_t *adhp, 113 | int threads 114 | ); 115 | 116 | uint64_t lwlibav_audio_count_overall_pcm_samples 117 | ( 118 | lwlibav_audio_decode_handler_t *adhp, 119 | int output_sample_rate 120 | ); 121 | 122 | uint64_t lwlibav_audio_get_pcm_samples 123 | ( 124 | lwlibav_audio_decode_handler_t *adhp, 125 | lwlibav_audio_output_handler_t *aohp, 126 | void *buf, 127 | int64_t start, 128 | int64_t wanted_length 129 | ); 130 | 131 | #ifdef __cplusplus 132 | } 133 | #endif /* __cplusplus */ 134 | -------------------------------------------------------------------------------- /common/lwlibav_audio_internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwlibav_audio_internal.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | typedef struct 24 | { 25 | int64_t pts; 26 | int64_t dts; 27 | int64_t file_offset; 28 | uint32_t sample_number; 29 | int extradata_index; 30 | uint8_t keyframe; 31 | int length; 32 | int sample_rate; 33 | } audio_frame_info_t; 34 | 35 | struct lwlibav_audio_decode_handler_tag 36 | { 37 | /* common */ 38 | AVFormatContext *format; 39 | int stream_index; 40 | int error; 41 | lw_log_handler_t lh; 42 | lwlibav_extradata_handler_t exh; 43 | AVCodecContext *ctx; 44 | AVIndexEntry *index_entries; 45 | int index_entries_count; 46 | int lw_seek_flags; 47 | int av_seek_flags; /* unused */ 48 | int dv_in_avi; /* 1 = 'DV in AVI Type-1', 0 = otherwise */ 49 | enum AVCodecID codec_id; 50 | const char **preferred_decoder_names; 51 | int prefer_hw_decoder; 52 | AVRational time_base; 53 | uint32_t frame_count; 54 | AVFrame *frame_buffer; 55 | audio_frame_info_t *frame_list; 56 | int soft_reset; 57 | /* */ 58 | AVPacket packet; /* for getting and freeing */ 59 | AVPacket alter_packet; /* for consumed by the decoder instead of 'packet'. */ 60 | uint32_t frame_length; 61 | uint32_t last_frame_number; 62 | uint64_t pcm_sample_count; 63 | uint64_t next_pcm_sample_number; 64 | }; 65 | -------------------------------------------------------------------------------- /common/lwlibav_video_internal.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwlibav_video_internal.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #define LW_VFRAME_FLAG_KEY 0x1 24 | #define LW_VFRAME_FLAG_LEADING 0x2 25 | #define LW_VFRAME_FLAG_CORRUPT 0x4 26 | #define LW_VFRAME_FLAG_INVISIBLE 0x8 27 | #define LW_VFRAME_FLAG_COUNTERPART_MISSING 0x10 28 | 29 | typedef struct 30 | { 31 | int64_t pts; /* presentation timestamp */ 32 | int64_t dts; /* decoding timestamp */ 33 | int64_t file_offset; /* offset from the beginning of file */ 34 | uint32_t sample_number; /* unique value in decoding order */ 35 | int extradata_index; /* index of extradata to decode this frame */ 36 | int flags; /* a combination of LW_VFRAME_FLAG_*s */ 37 | int pict_type; /* may be stored as enum AVPictureType */ 38 | int poc; /* Picture Order Count */ 39 | int repeat_pict; 40 | lw_field_info_t field_info; 41 | } video_frame_info_t; 42 | 43 | typedef struct 44 | { 45 | uint32_t decoding_to_presentation; 46 | } order_converter_t; 47 | 48 | struct lwlibav_video_decode_handler_tag 49 | { 50 | /* common */ 51 | AVFormatContext *format; 52 | int stream_index; 53 | int error; 54 | lw_log_handler_t lh; 55 | lwlibav_extradata_handler_t exh; 56 | AVCodecContext *ctx; 57 | AVIndexEntry *index_entries; 58 | int index_entries_count; 59 | int lw_seek_flags; 60 | int av_seek_flags; 61 | int dv_in_avi; /* unused */ 62 | enum AVCodecID codec_id; 63 | const char **preferred_decoder_names; 64 | int prefer_hw_decoder; 65 | AVRational time_base; 66 | uint32_t frame_count; 67 | AVFrame *frame_buffer; 68 | video_frame_info_t *frame_list; /* stored in presentation order */ 69 | int soft_reset; /* if false: close and re-open codecs when seeking (default); 70 | if true: just calling avcodec_flush_buffers */ 71 | /* */ 72 | uint32_t forward_seek_threshold; 73 | int seek_mode; 74 | int max_width; 75 | int max_height; 76 | int initial_width; 77 | int initial_height; 78 | enum AVPixelFormat initial_pix_fmt; 79 | enum AVColorSpace initial_colorspace; 80 | AVPacket packet; 81 | order_converter_t *order_converter; /* maps of decoding to presentation stored in decoding order */ 82 | uint8_t *keyframe_list; /* keyframe list stored in decoding order */ 83 | uint32_t last_half_frame; /* The last frame consists of complementary field coded picture pair 84 | * if set to non-zero, otherwise single frame coded picture. */ 85 | uint32_t last_frame_number; /* the number of the last requested frame */ 86 | uint32_t last_rap_number; /* the number of the last random accessible picture */ 87 | uint32_t last_fed_picture_number; /* the number of the last picture fed to the decoder 88 | * This number could be larger than frame_count to handle flush. */ 89 | uint32_t first_valid_frame_number; 90 | AVFrame *first_valid_frame; /* the frame buffer 91 | * where the first valid frame data is stored */ 92 | AVFrame *last_req_frame; /* the pointer to the frame buffer 93 | * where the last requested frame data is stored */ 94 | AVFrame *last_dec_frame; /* the pointer to the frame buffer 95 | * where the last output frame data from the decoder is stored */ 96 | AVFrame *movable_frame_buffer; /* the frame buffer 97 | * where the decoder outputs temporally stored frame data */ 98 | int64_t stream_duration; 99 | int64_t min_ts; 100 | uint32_t last_ts_frame_number; 101 | AVRational actual_time_base; 102 | int strict_cfr; 103 | }; 104 | -------------------------------------------------------------------------------- /common/lwsimd.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwsimd.c 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include 24 | 25 | #ifdef __GNUC__ 26 | static void __cpuid(int CPUInfo[4], int prm) 27 | { 28 | __asm volatile ( "cpuid" :"=a"(CPUInfo[0]), "=b"(CPUInfo[1]), "=c"(CPUInfo[2]), "=d"(CPUInfo[3]) :"a"(prm) ); 29 | return; 30 | } 31 | #else 32 | #include 33 | #endif /* __GNUC__ */ 34 | 35 | static int check_xgetbv( void ) 36 | { 37 | #if defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK) 38 | uint64_t eax = _xgetbv( _XCR_XFEATURE_ENABLED_MASK ); 39 | #elif defined(__GNUC__) 40 | uint32_t eax; 41 | uint32_t edx; 42 | __asm volatile ( ".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(0) ); 43 | #else 44 | uint32_t eax = 0; 45 | #endif 46 | return (eax & 0x6) == 0x6; 47 | } 48 | 49 | int lw_check_sse2() 50 | { 51 | int CPUInfo[4]; 52 | __cpuid( CPUInfo, 1 ); 53 | return (CPUInfo[3] & 0x04000000) != 0; 54 | } 55 | 56 | int lw_check_ssse3() 57 | { 58 | int CPUInfo[4]; 59 | __cpuid( CPUInfo, 1 ); 60 | return (CPUInfo[2] & 0x00000200) != 0; 61 | } 62 | 63 | int lw_check_sse41() 64 | { 65 | int CPUInfo[4]; 66 | __cpuid( CPUInfo, 1 ); 67 | return (CPUInfo[2] & 0x00080000) != 0; 68 | } 69 | 70 | int lw_check_avx2() 71 | { 72 | int CPUInfo[4]; 73 | __cpuid( CPUInfo, 1 ); 74 | if( (CPUInfo[2] & 0x18000000) == 0x18000000 && check_xgetbv() ) 75 | { 76 | __cpuid( CPUInfo, 7 ); 77 | return (CPUInfo[1] & 0x00000020) != 0; 78 | } 79 | return 0; 80 | } 81 | -------------------------------------------------------------------------------- /common/lwsimd.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * lwsimd.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: rigaya 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #ifdef __GNUC__ 24 | #define LW_ALIGN(x) __attribute__((aligned(x))) 25 | #define LW_FUNC_ALIGN __attribute__((force_align_arg_pointer)) 26 | #define LW_FORCEINLINE inline __attribute__((always_inline)) 27 | #else 28 | #define LW_ALIGN(x) __declspec(align(x)) 29 | #define LW_FUNC_ALIGN 30 | #define LW_FORCEINLINE __forceinline 31 | #endif 32 | 33 | #ifdef __cplusplus 34 | extern "C" 35 | { 36 | #endif /* __cplusplus */ 37 | 38 | int lw_check_sse2(); 39 | int lw_check_ssse3(); 40 | int lw_check_sse41(); 41 | int lw_check_avx2(); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif /* __cplusplus */ 46 | -------------------------------------------------------------------------------- /common/osdep.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * osdep.c / osdep.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2014 L-SMASH project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #ifdef _WIN32 24 | #define _CRT_SECURE_NO_WARNINGS 25 | 26 | #include "osdep.h" 27 | #include "utils.h" 28 | #include 29 | #include 30 | 31 | #define WIN32_LEAN_AND_MEAN 32 | #include 33 | 34 | int lw_string_to_wchar( int cp, const char *from, wchar_t **to ) 35 | { 36 | int nc = MultiByteToWideChar( cp, MB_ERR_INVALID_CHARS, from, -1, 0, 0 ); 37 | if( nc == 0 ) 38 | return 0; 39 | *to = (wchar_t *)lw_malloc_zero( nc * sizeof(wchar_t) ); 40 | MultiByteToWideChar( cp, 0, from, -1, *to, nc ); 41 | return nc; 42 | } 43 | 44 | int lw_string_from_wchar( int cp, const wchar_t *from, char **to ) 45 | { 46 | int nc = WideCharToMultiByte( cp, 0, from, -1, 0, 0, 0, 0 ); 47 | if( nc == 0 ) 48 | return 0; 49 | *to = (char *)lw_malloc_zero( nc * sizeof(char) ); 50 | WideCharToMultiByte( cp, 0, from, -1, *to, nc, 0, 0 ); 51 | return nc; 52 | } 53 | 54 | FILE *lw_win32_fopen( const char *name, const char *mode ) 55 | { 56 | wchar_t *wname = 0, *wmode = 0; 57 | FILE *fp = 0; 58 | if( lw_string_to_wchar( CP_UTF8, name, &wname ) && 59 | lw_string_to_wchar( CP_UTF8, mode, &wmode ) ) 60 | fp = _wfopen( wname, wmode ); 61 | if( !fp ) 62 | fp = fopen( name, mode ); 63 | lw_freep( &wname ); 64 | lw_freep( &wmode ); 65 | return fp; 66 | } 67 | 68 | char *lw_realpath( const char *path, char *resolved ) 69 | { 70 | wchar_t *wpath = 0, *wresolved = 0; 71 | char *ret = 0; 72 | if( lw_string_to_wchar( CP_UTF8, path, &wpath ) ) { 73 | wresolved = _wfullpath(0, wpath, _MAX_PATH); 74 | lw_string_from_wchar( CP_UTF8, wresolved, &ret); 75 | } else 76 | ret = _fullpath(0, path, _MAX_PATH); 77 | lw_freep( &wpath ); 78 | lw_freep( &wresolved ); 79 | if (resolved) { 80 | strcpy(resolved, ret); 81 | free(ret); 82 | return resolved; 83 | } 84 | return ret; 85 | } 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /common/osdep.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * osdep.h: 3 | ***************************************************************************** 4 | * Copyright (C) 2014 L-SMASH project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #ifndef OSDEP_H 24 | #define OSDEP_H 25 | 26 | #ifdef _WIN32 27 | # include 28 | FILE *lw_win32_fopen( const char *name, const char *mode ); 29 | # define lw_fopen lw_win32_fopen 30 | char *lw_realpath( const char *path, char *resolved ); 31 | #else 32 | # define lw_fopen fopen 33 | # define lw_realpath realpath 34 | #endif 35 | 36 | #ifdef _WIN32 37 | # include 38 | int lw_string_to_wchar( int cp, const char *from, wchar_t **to ); 39 | int lw_string_from_wchar( int cp, const wchar_t *from, char **to ); 40 | #endif 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /common/progress.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * progress.h 3 | ***************************************************************************** 4 | * Copyright (C) 2013-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #ifdef NO_PROGRESS_HANDLER 24 | struct progress_handler_tag 25 | { 26 | int dummy; 27 | }; 28 | #endif 29 | 30 | typedef struct progress_handler_tag progress_handler_t; 31 | 32 | typedef struct 33 | { 34 | void (*open) ( progress_handler_t *hp ); 35 | int (*update)( progress_handler_t *hp, const char *message, int percent ); 36 | void (*close )( progress_handler_t *hp ); 37 | } progress_indicator_t; 38 | -------------------------------------------------------------------------------- /common/qsv.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * qsv.c / qsv.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include "cpp_compat.h" 24 | 25 | #include 26 | 27 | #ifdef __cplusplus 28 | extern "C" 29 | { 30 | #endif /* __cplusplus */ 31 | #include 32 | #include 33 | #include 34 | #ifdef __cplusplus 35 | } 36 | #endif /* __cplusplus */ 37 | 38 | #include "decode.h" 39 | 40 | int is_qsv_decoder 41 | ( 42 | const AVCodec *codec 43 | ) 44 | { 45 | if( codec && codec->pix_fmts ) 46 | for( const enum AVPixelFormat *pix_fmt = codec->pix_fmts; *pix_fmt != AV_PIX_FMT_NONE; pix_fmt++ ) 47 | if( *pix_fmt == AV_PIX_FMT_QSV ) 48 | return 1; 49 | return 0; 50 | } 51 | 52 | /* Workarounds for Intel QuickSync Video Decoder through libavcodec */ 53 | int do_qsv_decoder_workaround 54 | ( 55 | AVCodecContext *ctx 56 | ) 57 | { 58 | ctx->has_b_frames = 16; /* the maximum decoder latency for AVC and HEVC frame */ 59 | if( ctx->codec_id != AV_CODEC_ID_H264 ) 60 | return 0; 61 | /* Feed an initializer packet to the decoder since libavcodec does not append parameter sets to access units 62 | * containing no IDR NAL units. Here we append parameter sets before the fake IDR NAL unit. Without this, 63 | * MFXVideoDECODE_DecodeHeader will return MFX_ERR_MORE_DATA. */ 64 | static const uint8_t fake_idr[] = { 0x00, 0x00, 0x00, 0x01, 0x65 }; /* valid for both start-code and size-field prefixes */ 65 | int ret = -1; 66 | AVPacket initializer = { 0 }; 67 | if( ctx->extradata[0] == 1 ) 68 | { 69 | /* Set up the bitstream filter. */ 70 | AVBSFContext *bsf_ctx = NULL; 71 | const AVBitStreamFilter *bsf = av_bsf_get_by_name( "h264_mp4toannexb" ); 72 | if( !bsf || (ret = av_bsf_alloc( bsf, &bsf_ctx )) < 0 ) 73 | goto bsf_fail; 74 | AVCodecParameters *codecpar = bsf_ctx->par_in; 75 | if( (ret = avcodec_parameters_from_context( codecpar, ctx )) < 0 ) 76 | goto bsf_fail; 77 | codecpar->extradata[4] |= 0x03; /* Force 4 byte length size fields. */ 78 | if( (ret = av_bsf_init( bsf_ctx )) < 0 ) 79 | goto bsf_fail; 80 | /* Convert into AnnexB Byte Stream Format. */ 81 | uint8_t data[sizeof(fake_idr)]; 82 | memcpy( data, fake_idr, sizeof(fake_idr) ); 83 | initializer.data = data; 84 | initializer.size = sizeof(fake_idr); 85 | AVPacket *in_pkt = &initializer; 86 | while( 1 ) 87 | { 88 | if( (ret = av_bsf_send_packet( bsf_ctx, in_pkt )) < 0 ) 89 | goto bsf_fail; 90 | ret = av_bsf_receive_packet( bsf_ctx, &initializer ); 91 | if( ret == AVERROR( EAGAIN ) || (in_pkt && ret == AVERROR_EOF) ) 92 | in_pkt = NULL; /* Send a null packet. */ 93 | else if( ret < 0 ) 94 | goto bsf_fail; 95 | else if( ret == 0 ) 96 | break; 97 | } 98 | bsf_fail: 99 | /* Tear down the bistream filter. */ 100 | av_bsf_free( &bsf_ctx ); 101 | if( ret < 0 ) 102 | goto fail; 103 | } 104 | else 105 | { 106 | if( (ret = av_new_packet( &initializer, ctx->extradata_size + sizeof(fake_idr) )) < 0 ) 107 | return ret; 108 | memcpy( initializer.data, ctx->extradata, ctx->extradata_size ); 109 | memcpy( initializer.data + ctx->extradata_size, fake_idr, sizeof(fake_idr) ); 110 | } 111 | /* Initialize the decoder. */ 112 | AVFrame *picture = av_frame_alloc(); 113 | if( picture ) 114 | { 115 | int got_picture; /* unused */ 116 | ret = decode_video_packet( ctx, picture, &got_picture, &initializer ); 117 | av_frame_free( &picture ); 118 | } 119 | fail: 120 | av_packet_unref( &initializer ); 121 | return ret; 122 | } 123 | -------------------------------------------------------------------------------- /common/qsv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * qsv.h 3 | ***************************************************************************** 4 | * Copyright (C) 2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | int is_qsv_decoder 24 | ( 25 | const AVCodec *codec 26 | ); 27 | 28 | /* Workarounds for Intel QuickSync Video Decoder through libavcodec */ 29 | int do_qsv_decoder_workaround 30 | ( 31 | AVCodecContext *ctx 32 | ); 33 | -------------------------------------------------------------------------------- /common/resample.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * resample.c / resample.cpp 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include "cpp_compat.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" 27 | { 28 | #endif /* __cplusplus */ 29 | #include 30 | #include 31 | #include 32 | #include 33 | #ifdef __cplusplus 34 | } 35 | #endif /* __cplusplus */ 36 | 37 | #include "resample.h" 38 | 39 | int resample_s32_to_s24( uint8_t **out_data, uint8_t *in_data, int data_size ) 40 | { 41 | /* Assume little endianess here. 42 | * in[0] in[1] in[2] in[3] in[4] in[5] in[6] in[7] ... 43 | * X out[0] out[1] out[2] X out[3] out[4] out[5] ... */ 44 | data_size &= ~3; 45 | int resampled_size = 0; 46 | for( int i = 0; i < data_size; i += 4 ) 47 | { 48 | *((*out_data) + resampled_size ) = in_data[i + 1]; 49 | *((*out_data) + resampled_size + 1) = in_data[i + 2]; 50 | *((*out_data) + resampled_size + 2) = in_data[i + 3]; 51 | resampled_size += 3; 52 | } 53 | *out_data += resampled_size; 54 | return resampled_size; 55 | } 56 | 57 | int flush_resampler_buffers(SwrContext *swr ) 58 | { 59 | swr_close( swr ); 60 | return swr_init( swr ) < 0 ? -1 : 0; 61 | } 62 | 63 | int update_resampler_configuration(SwrContext *swr, 64 | uint64_t out_channel_layout, int out_sample_rate, enum AVSampleFormat out_sample_fmt, 65 | uint64_t in_channel_layout, int in_sample_rate, enum AVSampleFormat in_sample_fmt, 66 | int *input_planes, int *input_block_align ) 67 | { 68 | /* Reopen the resampler. */ 69 | swr_close( swr ); 70 | av_opt_set_int( swr, "in_channel_layout", in_channel_layout, 0 ); 71 | av_opt_set_int( swr, "in_sample_fmt", in_sample_fmt, 0 ); 72 | av_opt_set_int( swr, "in_sample_rate", in_sample_rate, 0 ); 73 | av_opt_set_int( swr, "out_channel_layout", out_channel_layout, 0 ); 74 | av_opt_set_int( swr, "out_sample_fmt", out_sample_fmt, 0 ); 75 | av_opt_set_int( swr, "out_sample_rate", out_sample_rate, 0 ); 76 | av_opt_set_int( swr, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0 ); 77 | if( swr_init( swr ) < 0 ) 78 | return -1; 79 | /* Set up the number of planes and the block alignment of input audio frame. */ 80 | int input_channels = av_get_channel_layout_nb_channels( in_channel_layout ); 81 | if( av_sample_fmt_is_planar( in_sample_fmt ) ) 82 | { 83 | *input_planes = input_channels; 84 | *input_block_align = av_get_bytes_per_sample( in_sample_fmt ); 85 | } 86 | else 87 | { 88 | *input_planes = 1; 89 | *input_block_align = av_get_bytes_per_sample( in_sample_fmt ) * input_channels; 90 | } 91 | return 0; 92 | } 93 | 94 | int resample_audio(SwrContext *swr, audio_samples_t *out, audio_samples_t *in ) 95 | { 96 | /* Don't call this function over different block aligns. */ 97 | uint8_t *out_orig = *out->data; 98 | int out_channels = get_channel_layout_nb_channels( out->channel_layout ); 99 | int block_align = av_get_bytes_per_sample( out->sample_format ) * out_channels; 100 | int request_sample_count = out->sample_count; 101 | if( swr_get_delay( swr, request_sample_count) > 0 ) 102 | { 103 | int resampled_count = swr_convert( swr, out->data, request_sample_count, NULL, 0 ); 104 | if( resampled_count < 0 ) 105 | return 0; 106 | request_sample_count -= resampled_count; 107 | *out->data += resampled_count * block_align; 108 | } 109 | uint8_t **in_data = in->sample_count > 0 ? in->data : NULL; 110 | const uint8_t **indata = (const uint8_t**)in_data; 111 | int resampled_count = swr_convert( swr, out->data, request_sample_count, 112 | indata, in->sample_count ); 113 | if( resampled_count < 0 ) 114 | return 0; 115 | *out->data += resampled_count * block_align; 116 | return *out->data - out_orig; 117 | } 118 | -------------------------------------------------------------------------------- /common/resample.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * resample.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include 24 | 25 | typedef struct 26 | { 27 | uint64_t channel_layout; 28 | int sample_count; 29 | enum AVSampleFormat sample_format; 30 | uint8_t **data; 31 | } audio_samples_t; 32 | 33 | static inline void put_silence_audio_samples( int silence_data_size, int is_u8, uint8_t **out_data ) 34 | { 35 | memset( *out_data, is_u8 ? 0x80 : 0x00, silence_data_size ); 36 | *out_data += silence_data_size; 37 | } 38 | 39 | static inline int get_channel_layout_nb_channels( uint64_t channel_layout ) 40 | { 41 | int channels = av_get_channel_layout_nb_channels( channel_layout ); 42 | return channels > 0 ? channels : 1; 43 | } 44 | 45 | static inline int get_linesize( int channel_count, int sample_count, enum AVSampleFormat sample_format ) 46 | { 47 | int linesize; 48 | av_samples_get_buffer_size( &linesize, channel_count, sample_count, sample_format, 0 ); 49 | return linesize; 50 | } 51 | 52 | int resample_s32_to_s24( uint8_t **out_data, uint8_t *in_data, int data_size ); 53 | int flush_resampler_buffers( SwrContext *swr ); 54 | int update_resampler_configuration( SwrContext *swr, 55 | uint64_t out_channel_layout, int out_sample_rate, enum AVSampleFormat out_sample_fmt, 56 | uint64_t in_channel_layout, int in_sample_rate, enum AVSampleFormat in_sample_fmt, 57 | int *input_planes, int *input_block_align ); 58 | int resample_audio( SwrContext *swr, audio_samples_t *out, audio_samples_t *in ); 59 | -------------------------------------------------------------------------------- /common/utils.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * utils.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #define MIN( a, b ) ((a) < (b) ? (a) : (b)) 28 | #define MAX( a, b ) ((a) > (b) ? (a) : (b)) 29 | #define CLIP_VALUE( value, min, max ) ((value) > (max) ? (max) : (value) < (min) ? (min) : (value)) 30 | 31 | #ifndef _countof 32 | #define _countof( _Array ) ( sizeof(_Array) / sizeof(_Array[0]) ) 33 | #endif 34 | 35 | #define LW_STRINGFY( s ) #s 36 | 37 | typedef enum 38 | { 39 | LW_LOG_INFO = 0, 40 | LW_LOG_WARNING, 41 | LW_LOG_ERROR, 42 | LW_LOG_FATAL, 43 | LW_LOG_QUIET, 44 | } lw_log_level; 45 | 46 | typedef struct lw_log_handler_tag lw_log_handler_t; 47 | 48 | struct lw_log_handler_tag 49 | { 50 | const char *name; 51 | lw_log_level level; 52 | void *priv; 53 | void (*show_log)( lw_log_handler_t *, lw_log_level, const char *message ); 54 | }; 55 | 56 | #ifdef __cplusplus 57 | extern "C" 58 | { 59 | #endif /* __cplusplus */ 60 | 61 | void *lw_malloc_zero 62 | ( 63 | size_t size 64 | ); 65 | 66 | void lw_free 67 | ( 68 | void *pointer 69 | ); 70 | 71 | void lw_freep 72 | ( 73 | void *pointer 74 | ); 75 | 76 | void *lw_memdup 77 | ( 78 | void *src, 79 | size_t size 80 | ); 81 | 82 | const char **lw_tokenize_string 83 | ( 84 | char *str, /* null-terminated string: separator charactors will be replaced with '\0'. */ 85 | char separator, /* separator */ 86 | char **bufs /* If NULL, allocate memory block internally, which can be deallocated by lw_freep(). */ 87 | ); 88 | 89 | /***************************************************************************** 90 | * Non-public functions 91 | *****************************************************************************/ 92 | void lw_log_show 93 | ( 94 | lw_log_handler_t *lhp, 95 | lw_log_level level, 96 | const char *format, 97 | ... 98 | ); 99 | 100 | static inline uint64_t get_gcd 101 | ( 102 | uint64_t a, 103 | uint64_t b 104 | ) 105 | { 106 | if( !b ) 107 | return a; 108 | while( 1 ) 109 | { 110 | uint64_t c = a % b; 111 | if( !c ) 112 | return b; 113 | a = b; 114 | b = c; 115 | } 116 | } 117 | 118 | static inline uint64_t reduce_fraction 119 | ( 120 | uint64_t *a, 121 | uint64_t *b 122 | ) 123 | { 124 | uint64_t reduce = get_gcd( *a, *b ); 125 | *a /= reduce; 126 | *b /= reduce; 127 | return reduce; 128 | } 129 | 130 | int lw_check_file_extension 131 | ( 132 | const char *file_name, 133 | const char *extension 134 | ); 135 | 136 | int lw_try_rational_framerate 137 | ( 138 | double framerate, 139 | int64_t *framerate_num, 140 | int64_t *framerate_den, 141 | uint64_t timebase 142 | ); 143 | 144 | #ifdef __cplusplus 145 | } 146 | #endif /* __cplusplus */ 147 | -------------------------------------------------------------------------------- /common/video_output.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * video_output.h 3 | ***************************************************************************** 4 | * Copyright (C) 2012-2015 L-SMASH Works project 5 | * 6 | * Authors: Yusuke Nakamura 7 | * 8 | * Permission to use, copy, modify, and/or distribute this software for any 9 | * purpose with or without fee is hereby granted, provided that the above 10 | * copyright notice and this permission notice appear in all copies. 11 | * 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 | *****************************************************************************/ 20 | 21 | /* This file is available under an ISC license. */ 22 | 23 | #define REPEAT_CONTROL_CACHE_NUM 2 24 | 25 | #define LW_FRAME_PROP_CHANGE_FLAG_WIDTH (1<<0) 26 | #define LW_FRAME_PROP_CHANGE_FLAG_HEIGHT (1<<1) 27 | #define LW_FRAME_PROP_CHANGE_FLAG_PIXEL_FORMAT (1<<2) 28 | #define LW_FRAME_PROP_CHANGE_FLAG_COLORSPACE (1<<3) 29 | #define LW_FRAME_PROP_CHANGE_FLAG_YUV_RANGE (1<<4) 30 | 31 | typedef struct 32 | { 33 | int scaler_flags; 34 | int frame_prop_change_flags; 35 | int input_width; 36 | int input_height; 37 | enum AVPixelFormat input_pixel_format; 38 | enum AVPixelFormat output_pixel_format; 39 | enum AVColorSpace input_colorspace; 40 | int input_yuv_range; 41 | struct SwsContext *sws_ctx; 42 | } lw_video_scaler_handler_t; 43 | 44 | typedef struct 45 | { 46 | uint32_t top; 47 | uint32_t bottom; 48 | } lw_video_frame_order_t; 49 | 50 | typedef struct 51 | { 52 | lw_video_scaler_handler_t scaler; 53 | int output_width; 54 | int output_height; 55 | /* VFR->CFR conversion */ 56 | int vfr2cfr; 57 | uint32_t cfr_num; 58 | uint32_t cfr_den; 59 | /* Repeat control */ 60 | int repeat_control; 61 | int repeat_requested; 62 | int64_t repeat_correction_ts; 63 | uint32_t frame_count; 64 | uint32_t frame_order_count; 65 | lw_video_frame_order_t *frame_order_list; 66 | AVFrame *frame_cache_buffers[REPEAT_CONTROL_CACHE_NUM]; 67 | uint32_t frame_cache_numbers[REPEAT_CONTROL_CACHE_NUM]; 68 | /* Application private extension */ 69 | void *private_handler; 70 | void (*free_private_handler)( void *private_handler ); 71 | } lw_video_output_handler_t; 72 | 73 | #ifdef __cplusplus 74 | extern "C" 75 | { 76 | #endif /* __cplusplus */ 77 | 78 | int avoid_yuv_scale_conversion( enum AVPixelFormat *pixel_format ); 79 | 80 | void setup_video_rendering 81 | ( 82 | lw_video_output_handler_t *vohp, 83 | int scaler_flags, 84 | int width, 85 | int height, 86 | enum AVPixelFormat output_pixel_format, 87 | struct AVCodecContext *ctx, 88 | int (*dr_get_buffer)( struct AVCodecContext *, AVFrame *, int ) 89 | ); 90 | 91 | /* Return 0 if no update. 92 | * Return 1 if any update. 93 | * Retunr a negative value otherwise. */ 94 | int update_scaler_configuration_if_needed 95 | ( 96 | lw_video_scaler_handler_t *vshp, 97 | lw_log_handler_t *lhp, 98 | const AVFrame *av_frame 99 | ); 100 | 101 | void lw_cleanup_video_output_handler 102 | ( 103 | lw_video_output_handler_t *vohp 104 | ); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif /* __cplusplus */ 109 | -------------------------------------------------------------------------------- /common/xxh3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * xxHash - Extremely Fast Hash algorithm 3 | * Development source file for `xxh3` 4 | * Copyright (C) 2019-2020 Yann Collet 5 | * 6 | * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are 10 | * met: 11 | * 12 | * * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * * Redistributions in binary form must reproduce the above 15 | * copyright notice, this list of conditions and the following disclaimer 16 | * in the documentation and/or other materials provided with the 17 | * distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | * 31 | * You can contact the author at: 32 | * - xxHash homepage: https://www.xxhash.com 33 | * - xxHash source repository: https://github.com/Cyan4973/xxHash 34 | */ 35 | 36 | /* 37 | * Note: This file used to host the source code of XXH3_* variants. 38 | * during the development period. 39 | * The source code is now properly integrated within xxhash.h. 40 | * 41 | * xxh3.h is no longer useful, 42 | * but it is still provided for compatibility with source code 43 | * which used to include it directly. 44 | * 45 | * Programs are now highly discourage to include xxh3.h. 46 | * Include `xxhash.h` instead, which is the officially supported interface. 47 | * 48 | * In the future, xxh3.h will start to generate warnings, then errors, 49 | * then it will be removed from source package and from include directory. 50 | */ 51 | 52 | /* Simulate the same impact as including the old xxh3.h source file */ 53 | 54 | #define XXH_INLINE_ALL 55 | #include "xxhash.h" 56 | -------------------------------------------------------------------------------- /common/xxhash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * xxHash - Extremely Fast Hash algorithm 3 | * Copyright (C) 2012-2020 Yann Collet 4 | * 5 | * BSD 2-Clause License (https://www.opensource.org/licenses/bsd-license.php) 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions are 9 | * met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following disclaimer 15 | * in the documentation and/or other materials provided with the 16 | * distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | * 30 | * You can contact the author at: 31 | * - xxHash homepage: https://www.xxhash.com 32 | * - xxHash source repository: https://github.com/Cyan4973/xxHash 33 | */ 34 | 35 | 36 | /* 37 | * xxhash.c instantiates functions defined in xxhash.h 38 | */ 39 | 40 | #define XXH_STATIC_LINKING_ONLY /* access advanced declarations */ 41 | #define XXH_IMPLEMENTATION /* access definitions */ 42 | 43 | #include "xxhash.h" 44 | -------------------------------------------------------------------------------- /include/VSHelper.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (c) 2012-2015 Fredrik Mellbin 3 | * --- Legal stuff --- 4 | * This program is free software. It comes without any warranty, to 5 | * the extent permitted by applicable law. You can redistribute it 6 | * and/or modify it under the terms of the Do What The Fuck You Want 7 | * To Public License, Version 2, as published by Sam Hocevar. See 8 | * http://sam.zoy.org/wtfpl/COPYING for more details. 9 | *****************************************************************************/ 10 | 11 | #ifndef VSHELPER_H 12 | #define VSHELPER_H 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #ifdef _WIN32 21 | #include 22 | #endif 23 | #include "VapourSynth.h" 24 | 25 | /* Visual Studio doesn't recognize inline in c mode */ 26 | #if defined(_MSC_VER) && !defined(__cplusplus) 27 | #define inline _inline 28 | #endif 29 | 30 | /* A kinda portable definition of the C99 restrict keyword (or its inofficial C++ equivalent) */ 31 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* Available in C99 */ 32 | #define VS_RESTRICT restrict 33 | #elif defined(__cplusplus) || defined(_MSC_VER) /* Almost all relevant C++ compilers support it so just assume it works */ 34 | #define VS_RESTRICT __restrict 35 | #else /* Not supported */ 36 | #define VS_RESTRICT 37 | #endif 38 | 39 | #ifdef _WIN32 40 | #define VS_ALIGNED_MALLOC(pptr, size, alignment) do { *(pptr) = _aligned_malloc((size), (alignment)); } while (0) 41 | #define VS_ALIGNED_FREE(ptr) do { _aligned_free((ptr)); } while (0) 42 | #else 43 | #define VS_ALIGNED_MALLOC(pptr, size, alignment) do { if(posix_memalign((void**)(pptr), (alignment), (size))) *((void**)pptr) = NULL; } while (0) 44 | #define VS_ALIGNED_FREE(ptr) do { free((ptr)); } while (0) 45 | #endif 46 | 47 | #define VSMAX(a,b) ((a) > (b) ? (a) : (b)) 48 | #define VSMIN(a,b) ((a) > (b) ? (b) : (a)) 49 | 50 | #ifdef __cplusplus 51 | /* A nicer templated malloc for all the C++ users out there */ 52 | #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900) 53 | template 54 | #else 55 | template 56 | #endif 57 | static inline T* vs_aligned_malloc(size_t size, size_t alignment) { 58 | #ifdef _WIN32 59 | return (T*)_aligned_malloc(size, alignment); 60 | #else 61 | void *tmp = NULL; 62 | if (posix_memalign(&tmp, alignment, size)) 63 | tmp = 0; 64 | return (T*)tmp; 65 | #endif 66 | } 67 | 68 | static inline void vs_aligned_free(void *ptr) { 69 | VS_ALIGNED_FREE(ptr); 70 | } 71 | #endif /* __cplusplus */ 72 | 73 | /* convenience function for checking if the format never changes between frames */ 74 | static inline int isConstantFormat(const VSVideoInfo *vi) { 75 | return vi->height > 0 && vi->width > 0 && vi->format; 76 | } 77 | 78 | /* convenience function to check for if two clips have the same format (unknown/changeable will be considered the same too) */ 79 | static inline int isSameFormat(const VSVideoInfo *v1, const VSVideoInfo *v2) { 80 | return v1->height == v2->height && v1->width == v2->width && v1->format == v2->format; 81 | } 82 | 83 | /* multiplies and divides a rational number, such as a frame duration, in place and reduces the result */ 84 | static inline void muldivRational(int64_t *num, int64_t *den, int64_t mul, int64_t div) { 85 | /* do nothing if the rational number is invalid */ 86 | if (!*den) 87 | return; 88 | 89 | /* nobody wants to accidentally divide by zero */ 90 | assert(div); 91 | 92 | int64_t a, b; 93 | *num *= mul; 94 | *den *= div; 95 | a = *num; 96 | b = *den; 97 | while (b != 0) { 98 | int64_t t = a; 99 | a = b; 100 | b = t % b; 101 | } 102 | if (a < 0) 103 | a = -a; 104 | *num /= a; 105 | *den /= a; 106 | } 107 | 108 | /* reduces a rational number */ 109 | static inline void vs_normalizeRational(int64_t *num, int64_t *den) { 110 | muldivRational(num, den, 1, 1); 111 | } 112 | 113 | /* add two rational numbers and reduces the result */ 114 | static inline void vs_addRational(int64_t *num, int64_t *den, int64_t addnum, int64_t addden) { 115 | /* do nothing if the rational number is invalid */ 116 | if (!*den) 117 | return; 118 | 119 | /* nobody wants to accidentally add an invalid rational number */ 120 | assert(addden); 121 | 122 | if (*den == addden) { 123 | *num += addnum; 124 | } else { 125 | int64_t temp = addden; 126 | addnum *= *den; 127 | addden *= *den; 128 | *num *= temp; 129 | *den *= temp; 130 | 131 | *num += addnum; 132 | 133 | vs_normalizeRational(num, den); 134 | } 135 | } 136 | 137 | /* converts an int64 to int with saturation, useful to silence warnings when reading int properties among other things */ 138 | static inline int int64ToIntS(int64_t i) { 139 | if (i > INT_MAX) 140 | return INT_MAX; 141 | else if (i < INT_MIN) 142 | return INT_MIN; 143 | else return (int)i; 144 | } 145 | 146 | static inline void vs_bitblt(void *dstp, int dst_stride, const void *srcp, int src_stride, size_t row_size, size_t height) { 147 | if (height) { 148 | if (src_stride == dst_stride && src_stride == (int)row_size) { 149 | memcpy(dstp, srcp, row_size * height); 150 | } else { 151 | const uint8_t *srcp8 = (const uint8_t *)srcp; 152 | uint8_t *dstp8 = (uint8_t *)dstp; 153 | size_t i; 154 | for (i = 0; i < height; i++) { 155 | memcpy(dstp8, srcp8, row_size); 156 | srcp8 += src_stride; 157 | dstp8 += dst_stride; 158 | } 159 | } 160 | } 161 | } 162 | 163 | /* check if the frame dimensions are valid for a given format */ 164 | /* returns non-zero for valid width and height */ 165 | static inline int areValidDimensions(const VSFormat *fi, int width, int height) { 166 | return !(width % (1 << fi->subSamplingW) || height % (1 << fi->subSamplingH)); 167 | } 168 | 169 | /* Visual Studio doesn't recognize inline in c mode */ 170 | #if defined(_MSC_VER) && !defined(__cplusplus) 171 | #undef inline 172 | #endif 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /include/avs/alignment.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_ALIGNMENT_H 34 | #define AVS_ALIGNMENT_H 35 | 36 | // Functions and macros to help work with alignment requirements. 37 | 38 | // Tells if a number is a power of two. 39 | #define IS_POWER2(n) ((n) && !((n) & ((n) - 1))) 40 | 41 | // Tells if the pointer "ptr" is aligned to "align" bytes. 42 | #define IS_PTR_ALIGNED(ptr, align) (((uintptr_t)ptr & ((uintptr_t)(align-1))) == 0) 43 | 44 | // Rounds up the number "n" to the next greater multiple of "align" 45 | #define ALIGN_NUMBER(n, align) (((n) + (align)-1) & (~((align)-1))) 46 | 47 | // Rounds up the pointer address "ptr" to the next greater multiple of "align" 48 | #define ALIGN_POINTER(ptr, align) (((uintptr_t)(ptr) + (align)-1) & (~(uintptr_t)((align)-1))) 49 | 50 | #ifdef __cplusplus 51 | 52 | #include 53 | #include 54 | #include 55 | #include "config.h" 56 | 57 | #if defined(MSVC) && _MSC_VER<1400 58 | // needed for VS2013, otherwise C++11 'alignas' works 59 | #define avs_alignas(x) __declspec(align(x)) 60 | #else 61 | // assumes C++11 support 62 | #define avs_alignas(x) alignas(x) 63 | #endif 64 | 65 | template 66 | static bool IsPtrAligned(T* ptr, size_t align) 67 | { 68 | assert(IS_POWER2(align)); 69 | return (bool)IS_PTR_ALIGNED(ptr, align); 70 | } 71 | 72 | template 73 | static T AlignNumber(T n, T align) 74 | { 75 | assert(IS_POWER2(align)); 76 | return ALIGN_NUMBER(n, align); 77 | } 78 | 79 | template 80 | static T* AlignPointer(T* ptr, size_t align) 81 | { 82 | assert(IS_POWER2(align)); 83 | return (T*)ALIGN_POINTER(ptr, align); 84 | } 85 | 86 | extern "C" 87 | { 88 | #else 89 | #include 90 | #endif // __cplusplus 91 | 92 | // Returns a new buffer that is at least the size "nbytes". 93 | // The buffer will be aligned to "align" bytes. 94 | // Returns NULL on error. On successful allocation, 95 | // the returned buffer must be freed using "avs_free". 96 | inline void* avs_malloc(size_t nbytes, size_t align) 97 | { 98 | if (!IS_POWER2(align)) 99 | return NULL; 100 | 101 | size_t offset = sizeof(void*) + align - 1; 102 | 103 | void *orig = malloc(nbytes + offset); 104 | if (orig == NULL) 105 | return NULL; 106 | 107 | void **aligned = (void**)(((uintptr_t)orig + (uintptr_t)offset) & (~(uintptr_t)(align-1))); 108 | aligned[-1] = orig; 109 | return aligned; 110 | } 111 | 112 | // Buffers allocated using "avs_malloc" must be freed 113 | // using "avs_free" instead of "free". 114 | inline void avs_free(void *ptr) 115 | { 116 | // Mirroring free()'s semantic requires us to accept NULLs 117 | if (ptr == NULL) 118 | return; 119 | 120 | free(((void**)ptr)[-1]); 121 | } 122 | 123 | #ifdef __cplusplus 124 | } // extern "C" 125 | 126 | // The point of these undef's is to force using the template functions 127 | // if we are in C++ mode. For C, the user can rely only on the macros. 128 | #undef IS_PTR_ALIGNED 129 | #undef ALIGN_NUMBER 130 | #undef ALIGN_POINTER 131 | 132 | #endif // __cplusplus 133 | 134 | #endif //AVS_ALIGNMENT_H 135 | -------------------------------------------------------------------------------- /include/avs/capi.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CAPI_H 34 | #define AVS_CAPI_H 35 | 36 | #include "config.h" 37 | 38 | #ifdef AVS_POSIX 39 | // this is also defined in avs/posix.h 40 | #define __declspec(x) 41 | #endif 42 | 43 | #ifdef __cplusplus 44 | # define EXTERN_C extern "C" 45 | #else 46 | # define EXTERN_C 47 | #endif 48 | 49 | #ifdef AVS_WINDOWS 50 | #ifdef BUILDING_AVSCORE 51 | # if defined(GCC) && defined(X86_32) 52 | # define AVSC_CC 53 | # else // MSVC builds and 64-bit GCC 54 | # ifndef AVSC_USE_STDCALL 55 | # define AVSC_CC __cdecl 56 | # else 57 | # define AVSC_CC __stdcall 58 | # endif 59 | # endif 60 | #else // needed for programs that talk to AviSynth+ 61 | # ifndef AVSC_WIN32_GCC32 // see comment below 62 | # ifndef AVSC_USE_STDCALL 63 | # define AVSC_CC __cdecl 64 | # else 65 | # define AVSC_CC __stdcall 66 | # endif 67 | # else 68 | # define AVSC_CC 69 | # endif 70 | #endif 71 | # else 72 | # define AVSC_CC 73 | #endif 74 | 75 | // On 64-bit Windows, there's only one calling convention, 76 | // so there is no difference between MSVC and GCC. On 32-bit, 77 | // this isn't true. The convention that GCC needs to use to 78 | // even build AviSynth+ as 32-bit makes anything that uses 79 | // it incompatible with 32-bit MSVC builds of AviSynth+. 80 | // The AVSC_WIN32_GCC32 define is meant to provide a user 81 | // switchable way to make builds of FFmpeg to test 32-bit 82 | // GCC builds of AviSynth+ without having to screw around 83 | // with alternate headers, while still default to the usual 84 | // situation of using 32-bit MSVC builds of AviSynth+. 85 | 86 | // Hopefully, this situation will eventually be resolved 87 | // and a broadly compatible solution will arise so the 88 | // same 32-bit FFmpeg build can handle either MSVC or GCC 89 | // builds of AviSynth+. 90 | 91 | #define AVSC_INLINE static __inline 92 | 93 | #ifdef BUILDING_AVSCORE 94 | #ifdef AVS_WINDOWS 95 | # define AVSC_EXPORT __declspec(dllexport) 96 | # define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name 97 | #else 98 | # define AVSC_EXPORT EXTERN_C 99 | # define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name 100 | #endif 101 | #else 102 | # define AVSC_EXPORT EXTERN_C __declspec(dllexport) 103 | # ifndef AVSC_NO_DECLSPEC 104 | # define AVSC_API(ret, name) EXTERN_C __declspec(dllimport) ret AVSC_CC name 105 | # else 106 | # define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func) 107 | # endif 108 | #endif 109 | 110 | #endif //AVS_CAPI_H 111 | -------------------------------------------------------------------------------- /include/avs/config.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_CONFIG_H 34 | #define AVS_CONFIG_H 35 | 36 | // Undefine this to get cdecl calling convention 37 | #define AVSC_USE_STDCALL 1 38 | 39 | // NOTE TO PLUGIN AUTHORS: 40 | // Because FRAME_ALIGN can be substantially higher than the alignment 41 | // a plugin actually needs, plugins should not use FRAME_ALIGN to check for 42 | // alignment. They should always request the exact alignment value they need. 43 | // This is to make sure that plugins work over the widest range of AviSynth 44 | // builds possible. 45 | #define FRAME_ALIGN 64 46 | 47 | #if defined(_M_AMD64) || defined(__x86_64) 48 | # define X86_64 49 | #elif defined(_M_IX86) || defined(__i386__) 50 | # define X86_32 51 | // VS2017 introduced _M_ARM64 52 | #elif defined(_M_ARM64) || defined(__aarch64__) 53 | # define ARM64 54 | #elif defined(_M_ARM) || defined(__arm__) 55 | # define ARM32 56 | #else 57 | # error Unsupported CPU architecture. 58 | #endif 59 | 60 | // VC++ LLVM-Clang-cl MinGW-Gnu 61 | // MSVC x x 62 | // MSVC_PURE x 63 | // CLANG x 64 | // GCC x 65 | 66 | #if defined(__clang__) 67 | // Check clang first. clang-cl also defines __MSC_VER 68 | // We set MSVC because they are mostly compatible 69 | # define CLANG 70 | #if defined(_MSC_VER) 71 | # define MSVC 72 | # define AVS_FORCEINLINE __attribute__((always_inline)) 73 | #else 74 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 75 | #endif 76 | #elif defined(_MSC_VER) 77 | # define MSVC 78 | # define MSVC_PURE 79 | # define AVS_FORCEINLINE __forceinline 80 | #elif defined(__GNUC__) 81 | # define GCC 82 | # define AVS_FORCEINLINE __attribute__((always_inline)) inline 83 | #else 84 | # error Unsupported compiler. 85 | # define AVS_FORCEINLINE inline 86 | # undef __forceinline 87 | # define __forceinline inline 88 | #endif 89 | 90 | #if defined(_WIN32) 91 | # define AVS_WINDOWS 92 | #elif defined(__linux__) 93 | # define AVS_LINUX 94 | # define AVS_POSIX 95 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 96 | # define AVS_BSD 97 | # define AVS_POSIX 98 | #elif defined(__APPLE__) 99 | # define AVS_MACOS 100 | # define AVS_POSIX 101 | #else 102 | # error Operating system unsupported. 103 | #endif 104 | 105 | // useful warnings disabler macros for supported compilers 106 | 107 | #if defined(_MSC_VER) 108 | #define DISABLE_WARNING_PUSH __pragma(warning( push )) 109 | #define DISABLE_WARNING_POP __pragma(warning( pop )) 110 | #define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber )) 111 | 112 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(4101) 113 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(4505) 114 | // other warnings you want to deactivate... 115 | 116 | #elif defined(__GNUC__) || defined(__clang__) 117 | #define DO_PRAGMA(X) _Pragma(#X) 118 | #define DISABLE_WARNING_PUSH DO_PRAGMA(GCC diagnostic push) 119 | #define DISABLE_WARNING_POP DO_PRAGMA(GCC diagnostic pop) 120 | #define DISABLE_WARNING(warningName) DO_PRAGMA(GCC diagnostic ignored #warningName) 121 | 122 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE DISABLE_WARNING(-Wunused-variable) 123 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION DISABLE_WARNING(-Wunused-function) 124 | // other warnings you want to deactivate... 125 | 126 | #else 127 | #define DISABLE_WARNING_PUSH 128 | #define DISABLE_WARNING_POP 129 | #define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE 130 | #define DISABLE_WARNING_UNREFERENCED_FUNCTION 131 | // other warnings you want to deactivate... 132 | 133 | #endif 134 | 135 | #if defined(AVS_POSIX) 136 | #define NEW_AVSVALUE 137 | #else 138 | #define NEW_AVSVALUE 139 | #endif 140 | 141 | #if defined(AVS_WINDOWS) 142 | // Windows XP does not have proper initialization for 143 | // thread local variables. 144 | // Use workaround instead __declspec(thread) 145 | #define XP_TLS 146 | #endif 147 | 148 | #endif //AVS_CONFIG_H 149 | -------------------------------------------------------------------------------- /include/avs/cpuid.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_CPUID_H 33 | #define AVSCORE_CPUID_H 34 | 35 | // For GetCPUFlags. These are backwards-compatible with those in VirtualDub. 36 | // ending with SSE4_2 37 | // For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator 38 | enum { 39 | /* oldest CPU to support extension */ 40 | CPUF_FORCE = 0x01, // N/A 41 | CPUF_FPU = 0x02, // 386/486DX 42 | CPUF_MMX = 0x04, // P55C, K6, PII 43 | CPUF_INTEGER_SSE = 0x08, // PIII, Athlon 44 | CPUF_SSE = 0x10, // PIII, Athlon XP/MP 45 | CPUF_SSE2 = 0x20, // PIV, K8 46 | CPUF_3DNOW = 0x40, // K6-2 47 | CPUF_3DNOW_EXT = 0x80, // Athlon 48 | CPUF_X86_64 = 0xA0, // Hammer (note: equiv. to 3DNow + SSE2, which 49 | // only Hammer will have anyway) 50 | CPUF_SSE3 = 0x100, // PIV+, K8 Venice 51 | CPUF_SSSE3 = 0x200, // Core 2 52 | CPUF_SSE4 = 0x400, 53 | CPUF_SSE4_1 = 0x400, // Penryn, Wolfdale, Yorkfield 54 | CPUF_AVX = 0x800, // Sandy Bridge, Bulldozer 55 | CPUF_SSE4_2 = 0x1000, // Nehalem 56 | // AVS+ 57 | CPUF_AVX2 = 0x2000, // Haswell 58 | CPUF_FMA3 = 0x4000, 59 | CPUF_F16C = 0x8000, 60 | CPUF_MOVBE = 0x10000, // Big Endian move 61 | CPUF_POPCNT = 0x20000, 62 | CPUF_AES = 0x40000, 63 | CPUF_FMA4 = 0x80000, 64 | 65 | CPUF_AVX512F = 0x100000, // AVX-512 Foundation. 66 | CPUF_AVX512DQ = 0x200000, // AVX-512 DQ (Double/Quad granular) Instructions 67 | CPUF_AVX512PF = 0x400000, // AVX-512 Prefetch 68 | CPUF_AVX512ER = 0x800000, // AVX-512 Exponential and Reciprocal 69 | CPUF_AVX512CD = 0x1000000, // AVX-512 Conflict Detection 70 | CPUF_AVX512BW = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions 71 | CPUF_AVX512VL = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions 72 | CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit 73 | CPUF_AVX512VBMI = 0x10000000,// AVX-512 VBMI 74 | }; 75 | 76 | #ifdef BUILDING_AVSCORE 77 | int GetCPUFlags(); 78 | void SetMaxCPU(int new_flags); 79 | #endif 80 | 81 | #endif // AVSCORE_CPUID_H 82 | -------------------------------------------------------------------------------- /include/avs/filesystem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Snippet copied from filesystem/README.md 4 | 5 | #if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) 6 | #if __has_include() 7 | #define GHC_USE_STD_FS 8 | #include 9 | namespace fs = std::filesystem; 10 | #endif 11 | #endif 12 | #ifndef GHC_USE_STD_FS 13 | #include 14 | namespace fs = ghc::filesystem; 15 | #endif 16 | -------------------------------------------------------------------------------- /include/avs/minmax.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_MINMAX_H 33 | #define AVSCORE_MINMAX_H 34 | 35 | template 36 | T min(T v1, T v2) 37 | { 38 | return v1 < v2 ? v1 : v2; 39 | } 40 | 41 | template 42 | T max(T v1, T v2) 43 | { 44 | return v1 > v2 ? v1 : v2; 45 | } 46 | 47 | template 48 | T clamp(T n, T min, T max) 49 | { 50 | n = n > max ? max : n; 51 | return n < min ? min : n; 52 | } 53 | 54 | #endif // AVSCORE_MINMAX_H 55 | -------------------------------------------------------------------------------- /include/avs/posix.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifdef AVS_POSIX 33 | #ifndef AVSCORE_POSIX_H 34 | #define AVSCORE_POSIX_H 35 | 36 | #ifdef __cplusplus 37 | #include 38 | #endif 39 | #include 40 | #include 41 | 42 | // Define these MSVC-extension used in Avisynth 43 | #define __single_inheritance 44 | 45 | // These things don't exist in Linux 46 | #define __declspec(x) 47 | #define lstrlen strlen 48 | #define lstrcmp strcmp 49 | #define lstrcmpi strcasecmp 50 | #define _stricmp strcasecmp 51 | #define _strnicmp strncasecmp 52 | #define _strdup strdup 53 | #define SetCurrentDirectory(x) chdir(x) 54 | #define SetCurrentDirectoryW(x) chdir(x) 55 | #define GetCurrentDirectoryW(x) getcwd(x) 56 | #define _putenv putenv 57 | #define _alloca alloca 58 | 59 | // Borrowing some compatibility macros from AvxSynth, slightly modified 60 | #define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b)))) 61 | #define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b))) 62 | #define Int32x32To64(a, b) ((int64_t)(((int64_t)((long)(a))) * ((long)(b)))) 63 | 64 | #define InterlockedIncrement(x) __sync_add_and_fetch((x), 1) 65 | #define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1) 66 | #define MulDiv(nNumber, nNumerator, nDenominator) (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator)) 67 | 68 | #ifndef TRUE 69 | #define TRUE true 70 | #endif 71 | 72 | #ifndef FALSE 73 | #define FALSE false 74 | #endif 75 | 76 | #define S_FALSE (0x00000001) 77 | #define E_FAIL (0x80004005) 78 | #define FAILED(hr) ((hr) & 0x80000000) 79 | #define SUCCEEDED(hr) (!FAILED(hr)) 80 | 81 | // Statuses copied from comments in exception.cpp 82 | #define STATUS_GUARD_PAGE_VIOLATION 0x80000001 83 | #define STATUS_DATATYPE_MISALIGNMENT 0x80000002 84 | #define STATUS_BREAKPOINT 0x80000003 85 | #define STATUS_SINGLE_STEP 0x80000004 86 | #define STATUS_ACCESS_VIOLATION 0xc0000005 87 | #define STATUS_IN_PAGE_ERROR 0xc0000006 88 | #define STATUS_INVALID_HANDLE 0xc0000008 89 | #define STATUS_NO_MEMORY 0xc0000017 90 | #define STATUS_ILLEGAL_INSTRUCTION 0xc000001d 91 | #define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025 92 | #define STATUS_INVALID_DISPOSITION 0xc0000026 93 | #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c 94 | #define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d 95 | #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e 96 | #define STATUS_FLOAT_INEXACT_RESULT 0xc000008f 97 | #define STATUS_FLOAT_INVALID_OPERATION 0xc0000090 98 | #define STATUS_FLOAT_OVERFLOW 0xc0000091 99 | #define STATUS_FLOAT_STACK_CHECK 0xc0000092 100 | #define STATUS_FLOAT_UNDERFLOW 0xc0000093 101 | #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094 102 | #define STATUS_INTEGER_OVERFLOW 0xc0000095 103 | #define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096 104 | #define STATUS_STACK_OVERFLOW 0xc00000fd 105 | 106 | // Calling convension 107 | #define __stdcall 108 | #define __cdecl 109 | 110 | #endif // AVSCORE_POSIX_H 111 | #endif // AVS_POSIX 112 | -------------------------------------------------------------------------------- /include/avs/types.h: -------------------------------------------------------------------------------- 1 | // Avisynth C Interface Version 0.20 2 | // Copyright 2003 Kevin Atkinson 3 | 4 | // This program is free software; you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation; either version 2 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program; if not, write to the Free Software 16 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 17 | // http://www.gnu.org/copyleft/gpl.html . 18 | // 19 | // As a special exception, I give you permission to link to the 20 | // Avisynth C interface with independent modules that communicate with 21 | // the Avisynth C interface solely through the interfaces defined in 22 | // avisynth_c.h, regardless of the license terms of these independent 23 | // modules, and to copy and distribute the resulting combined work 24 | // under terms of your choice, provided that every copy of the 25 | // combined work is accompanied by a complete copy of the source code 26 | // of the Avisynth C interface and Avisynth itself (with the version 27 | // used to produce the combined work), being distributed under the 28 | // terms of the GNU General Public License plus this exception. An 29 | // independent module is a module which is not derived from or based 30 | // on Avisynth C Interface, such as 3rd-party filters, import and 31 | // export plugins, or graphical user interfaces. 32 | 33 | #ifndef AVS_TYPES_H 34 | #define AVS_TYPES_H 35 | 36 | // Define all types necessary for interfacing with avisynth.dll 37 | #include 38 | #include 39 | #ifdef __cplusplus 40 | #include 41 | #include 42 | #else 43 | #include 44 | #include 45 | #endif 46 | 47 | // Raster types used by VirtualDub & Avisynth 48 | typedef uint32_t Pixel32; 49 | typedef uint8_t BYTE; 50 | 51 | // Audio Sample information 52 | typedef float SFLOAT; 53 | 54 | #endif //AVS_TYPES_H 55 | -------------------------------------------------------------------------------- /include/avs/win.h: -------------------------------------------------------------------------------- 1 | // This program is free software; you can redistribute it and/or modify 2 | // it under the terms of the GNU General Public License as published by 3 | // the Free Software Foundation; either version 2 of the License, or 4 | // (at your option) any later version. 5 | // 6 | // This program is distributed in the hope that it will be useful, 7 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 8 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9 | // GNU General Public License for more details. 10 | // 11 | // You should have received a copy of the GNU General Public License 12 | // along with this program; if not, write to the Free Software 13 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit 14 | // http://www.gnu.org/copyleft/gpl.html . 15 | // 16 | // Linking Avisynth statically or dynamically with other modules is making a 17 | // combined work based on Avisynth. Thus, the terms and conditions of the GNU 18 | // General Public License cover the whole combination. 19 | // 20 | // As a special exception, the copyright holders of Avisynth give you 21 | // permission to link Avisynth with independent modules that communicate with 22 | // Avisynth solely through the interfaces defined in avisynth.h, regardless of the license 23 | // terms of these independent modules, and to copy and distribute the 24 | // resulting combined work under terms of your choice, provided that 25 | // every copy of the combined work is accompanied by a complete copy of 26 | // the source code of Avisynth (the version of Avisynth used to produce the 27 | // combined work), being distributed under the terms of the GNU General 28 | // Public License plus this exception. An independent module is a module 29 | // which is not derived from or based on Avisynth, such as 3rd-party filters, 30 | // import and export plugins, or graphical user interfaces. 31 | 32 | #ifndef AVSCORE_WIN_H 33 | #define AVSCORE_WIN_H 34 | 35 | // Whenever you need windows headers, start by including this file, then the rest. 36 | 37 | // WWUUT? We require XP now? 38 | #if !defined(NTDDI_VERSION) && !defined(_WIN32_WINNT) 39 | #define NTDDI_VERSION 0x05020000 40 | #define _WIN32_WINNT 0x0502 41 | #endif 42 | 43 | #define WIN32_LEAN_AND_MEAN 44 | #define STRICT 45 | #if !defined(NOMINMAX) 46 | #define NOMINMAX 47 | #endif 48 | 49 | #include 50 | 51 | // Provision for UTF-8 max 4 bytes per code point 52 | #define AVS_MAX_PATH MAX_PATH*4 53 | 54 | #endif // AVSCORE_WIN_H 55 | -------------------------------------------------------------------------------- /include/input.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AkarinVS/L-SMASH-Works/024ac718bca701e9175f663cbfd6589fc0c27fdb/include/input.h --------------------------------------------------------------------------------