├── .gitignore ├── CMakeLists.txt ├── Changelog ├── Makefile.old ├── README.md ├── avs2yuv.c ├── avs_internal.c ├── cmake_uninstall.cmake.in └── gpl.txt /.gitignore: -------------------------------------------------------------------------------- 1 | *.vcxproj* 2 | CMakeCache.txt 3 | CMakeFiles/* 4 | *.dir/* 5 | *.sln 6 | cmake_install.cmake 7 | cmake_uninstall.cmake 8 | x64/* 9 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | project(avs2yuv VERSION 0.30) 4 | 5 | set(CMAKE_C_STANDARD 99) 6 | set(CMAKE_C_STANDARD_REQUIRED True) 7 | 8 | if(MSVC) 9 | message(FATAL_ERROR "Windows builds must be compiled using MinGW-w64, not MSVC.") 10 | else() 11 | include(FindPkgConfig) 12 | if(MINGW) 13 | pkg_search_module(AVISYNTH avisynth>=3.5.0) 14 | if(AVISYNTH_FOUND) 15 | include_directories(${AVISYNTH_INCLUDE_DIRS}) 16 | else() 17 | # the path on Windows itself, outside of pkg-config 18 | include_directories($ENV{AVISYNTH_SDK_PATH}/include) 19 | endif() 20 | else() 21 | pkg_search_module(AVISYNTH REQUIRED avisynth>=3.5.0) 22 | include_directories(${AVISYNTH_INCLUDE_DIRS}) 23 | endif() 24 | endif() 25 | 26 | add_executable(avs2yuv avs2yuv.c) 27 | 28 | if(CMAKE_SYSTEM_NAME STREQUAL "Haiku") 29 | set(SYSLIB "root") 30 | else() 31 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 32 | set(SYSLIB "pthread" "dl") 33 | else() 34 | set(SYSLIB "pthread") 35 | endif() 36 | endif() 37 | 38 | if(NOT APPLE) 39 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed") 40 | endif() 41 | 42 | target_link_libraries(avs2yuv "${SYSLIB}") 43 | 44 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I. -Wall -O3 -ffast-math -fno-math-errno -fomit-frame-pointer") 45 | 46 | # This is needed because trying to detect OSX versions in C is a PITA. 47 | # The only occasion this option should be used is for OSX 10.6-10.11 on Intel. 48 | # PPC versions of OSX have this enabled by default, right in avs2yuv.c. 49 | # Most/all other OSes should already support clock_gettime. 50 | option(OLD_TIME_BEHAVIOR "Use ftime() instead of clock_gettime() for timing." OFF) 51 | if(${OLD_TIME_BEHAVIOR}) 52 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOLD_TIME_BEHAVIOR") 53 | endif() 54 | 55 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR 56 | CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR 57 | CMAKE_SYSTEM_PROCESSOR STREQUAL "x64" OR 58 | CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64") 59 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse") 60 | endif() 61 | 62 | include(GNUInstallDirs) 63 | install(TARGETS avs2yuv 64 | RUNTIME DESTINATION bin) 65 | 66 | # uninstall target 67 | configure_file( 68 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" 69 | "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" 70 | IMMEDIATE @ONLY) 71 | 72 | add_custom_target(uninstall 73 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) 74 | -------------------------------------------------------------------------------- /Changelog: -------------------------------------------------------------------------------- 1 | 0.29 DJATOM's mod 4 (2020-3-05) 2 | new: linux support, unify code to compile on both Windows and Linux OSes, drop headers from repo (now using system headers). 3 | 4 | 0.28 DJATOM's mod 3 (2016-8-16) 5 | removed: CSP-related conversion code. 6 | info: this program doesn't support classic avisynth anymore. The core features now depends on avs+ functions, so it's not possible to support obsolete versions. 7 | improvement: added support for all new HBD stuff. 8 | 9 | 0.27 DJATOM's mod 2 (2016-8-12) 10 | merged: new options from BM's mod 3 (depth, par, fps). Old 'wheels' removed. 11 | removed: -log option. Guess it useless now. 12 | removed: 'Distributor'-related code. Use Avs+, if you want multi-threaded Avisynth. 13 | new: implemented native HBD support. Only 16-bit and float for now. I'll add more stuff here once it will be merged in Avs+ from PR. 14 | new: -nstdr option. Silences all stderr output. Use it when piping to external encoder. 15 | improvement: now application prints progress console, so -log is not needed under Wine. The output schema was reworked and should be better. 16 | Also migrated to avisynth_c.h from Avs+, it makes me easy to support new avs+ stuff when it will come. 17 | GCC will complaints about avisynth_c.h, but I think it's not that critical. 18 | 19 | 0.26a DJATOM's mod (2014-8-26) 20 | fixed i420p10/i420p16 options bug (thx Isorkin for testing). 21 | now I use MSVC 2012 with Intel Composer XE 2013 inbstead of MinGW. 22 | 23 | 0.26 DJATOM's mod (2014-8-20) 24 | mod: added i420p10/i420p16 to -csp. 25 | removed huffyuv functionality 'cuz it useless now. 26 | 27 | 0.25 DJATOM's mod (2013-9-13) 28 | new option: -log for logging to file (useful on Wine). 29 | 30 | 0.24 DJATOM's mod (2013-2-12) 31 | modified verbose output: now avs2yuv print all usefull info about processing to CMD's caption (like x264). 32 | 33 | 0.24 BugMaster's mod 2 (2011-9-20) 34 | merge 2 changes by Oka Motofumi (aka Chikuzen): 35 | added 128 KB file buffering for speed up 36 | use ffmpeg for huffyuv encoding instead of mencoder 37 | added support for interlaced avs sources (it must be field-based instead of frame-based) 38 | new option: -csp i420/i422/i444 for support of I422/I444 colorspaces output (AviSynth 2.6+ is required) 39 | 40 | 0.24 BugMaster's mod (2011-7-7) 41 | replaced AviSynth C++ interface with C interface 42 | compiles with GCC instead of MSVS 43 | added call of 'Distributor' for multi-threaded scripts 44 | calls avs_delete_script_environment at the end of work 45 | 46 | 0.24 (2005-3-4) 47 | new option: -raw outputs raw I420 (omits yuv4mpeg headers) 48 | 49 | 0.23 (2005-1-26) 50 | new option: -slave takes a list of frames to decode 51 | 52 | 0.22 (2004-11-25) 53 | fixed a bug when -frames comes before -seek on the command line 54 | 55 | 0.21 (2004-11-22) 56 | write to multiple output streams 57 | huffyuv preset (doesn't work under wine) 58 | 59 | 0.20 (2004-11-22) 60 | prints avisynth error messages instead of crashing 61 | no longer requires avisynth_c.dll 62 | 63 | 0.13 (2004-11-10) 64 | binmode stdout again 65 | 66 | 0.12 (2004-11-9) 67 | reduced memory footprint 68 | no longer requires that avisynth be installed; merely having the dlls is enough 69 | fixed a possible crash on exit 70 | 71 | 0.11 (2004-10-31) 72 | binmode stdout (may or may not fix some piping problems) 73 | 74 | 0.1 (2004-10-4) 75 | initial release 76 | -------------------------------------------------------------------------------- /Makefile.old: -------------------------------------------------------------------------------- 1 | ifeq ($(PREFIX),) 2 | PREFIX := /usr/local 3 | endif 4 | 5 | OBJECTS := avs2yuv.o 6 | BIN := avs2yuv 7 | 8 | CCFLAGS := -I. -std=gnu99 -Wall -O3 -ffast-math -fno-math-errno -fomit-frame-pointer $(CFLAGS) 9 | UNAME_S := $(shell uname -s) 10 | ifneq ($(UNAME_S),Darwin) 11 | LDFLAGS := -Wl,--no-as-needed 12 | endif 13 | 14 | UNAME_M := $(shell uname -m) 15 | ifeq ($(UNAME_M),i686) 16 | CCFLAGS += -msse2 -mfpmath=sse 17 | endif 18 | ifeq ($(UNAME_M),x86_64) 19 | CCFLAGS += -msse2 -mfpmath=sse 20 | endif 21 | 22 | ifeq (${OS},Windows_NT) 23 | CCFLAGS += -I"${AVISYNTH_SDK_PATH}\include" 24 | else 25 | ifeq ($(UNAME_S),Haiku) 26 | LDFLAGS += -lroot 27 | else 28 | ifeq (${OS},MINGW) 29 | LDFLAGS += -pthread 30 | else 31 | LDFLAGS += -ldl -pthread 32 | endif 33 | endif 34 | CCFLAGS += $(shell pkg-config --cflags avisynth) 35 | endif 36 | all: $(BIN) 37 | 38 | %.o : %.c 39 | $(CC) $(CCFLAGS) -c $< -o $@ 40 | 41 | $(BIN) : $(OBJECTS) 42 | $(CC) $(LDFLAGS) $(OBJECTS) -s -o $(BIN) 43 | 44 | install: avs2yuv 45 | install -m 755 avs2yuv $(PREFIX)/bin/ 46 | 47 | clean : 48 | rm -f $(OBJECTS) $(BIN) 49 | 50 | avs2yuv.o: avs2yuv.c 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | avs2yuv 2 | ======= 3 | A simple tool that can execute avisynth scripts. 4 | This version is intended to be used with Avisynth+. 5 | 6 | Compiling and installing 7 | ======= 8 | ```bash 9 | git clone https://github.com/DJATOM/avs2yuv.git 10 | cd avs2yuv 11 | mkdir build 12 | cd build 13 | cmake .. 14 | make 15 | [sudo] make install 16 | ``` 17 | -------------------------------------------------------------------------------- /avs2yuv.c: -------------------------------------------------------------------------------- 1 | // Avs2YUV by Loren Merritt 2 | 3 | // Contributors: Anton Mitrofanov (aka BugMaster) 4 | // Oka Motofumi (aka Chikuzen) 5 | // Vladimir Kontserenko (aka DJATOM) 6 | 7 | // This program is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License as published by 9 | // the Free Software Foundation; either version 2 of the License, or 10 | // (at your option) any later version. 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include "avs_internal.c" 19 | 20 | #if defined(AVS_POSIX) 21 | #include 22 | #if defined(AVS_MACOS) 23 | #define AVS_LIBNAME "libavisynth.dylib" 24 | #else 25 | #define AVS_LIBNAME "libavisynth.so" 26 | #endif 27 | #else 28 | #include 29 | #define fileno _fileno 30 | #define dup _dup 31 | #define fdopen _fdopen 32 | #if defined(_MSC_VER) 33 | #define strcasecmp _stricmp 34 | #define strncasecmp _strnicmp 35 | #define snprintf _snprintf 36 | typedef signed __int64 int64_t; 37 | // MSVC specifically lacks clock_gettime. 38 | #define OLD_TIME_BEHAVIOR 39 | #endif 40 | #define AVS_LIBNAME "avisynth.dll" 41 | #endif 42 | 43 | #if defined(AVS_MACOS) 44 | #if defined(PPC32) 45 | // AviSynth+ can be built/run natively on OS X 10.4 and 10.5, 46 | // which are the last two versions that can be used on PPC. 47 | // clock_gettime() support was introduced for macOS in 10.12, 48 | // so we definitely need ftime if we're on a PPC version of OSX. 49 | // Intel users between 10.6 and 10.11 will have to force it 50 | // by passing CFLAGS during make. 51 | #define OLD_TIME_BEHAVIOR 52 | #endif 53 | #endif 54 | 55 | #ifdef OLD_TIME_BEHAVIOR 56 | #include 57 | #endif 58 | 59 | #if !defined(INT_MAX) 60 | #define INT_MAX 0x7fffffff 61 | #endif 62 | 63 | #define MY_VERSION "Avs2YUV 0.30" 64 | #define AUTHORS "Writen by Loren Merritt, modified by BugMaster, Chikuzen\nand currently maintained by DJATOM" 65 | 66 | #define MAX_FH 10 67 | #define AVS_BUFSIZE (128*1024) 68 | 69 | static volatile int b_ctrl_c = 0; 70 | 71 | void sigintHandler(int sig_num) 72 | { 73 | exit(0); 74 | b_ctrl_c = 1; 75 | } 76 | 77 | int64_t avs2yuv_mdate(void) 78 | { 79 | #ifdef OLD_TIME_BEHAVIOR 80 | struct timeb tb; 81 | ftime(&tb); 82 | return ((int64_t)tb.time * 1000 + (int64_t)tb.millitm) * 1000; 83 | #else 84 | struct timespec tb; 85 | clock_gettime(CLOCK_MONOTONIC, &tb); 86 | return ((int64_t)tb.tv_sec * 1000 + (int64_t)tb.tv_nsec / 1000000) * 1000; 87 | #endif 88 | } 89 | 90 | int main(int argc, const char* argv[]) 91 | { 92 | const char* infile = NULL; 93 | const char* outfile[MAX_FH] = {NULL}; 94 | int y4m_headers[MAX_FH] = {0}; 95 | FILE* out_fh[10] = {NULL}; 96 | int out_fhs = 0; 97 | int nostderr = 0; 98 | int usage = 0; 99 | int seek = 0; 100 | int end = 0; 101 | int slave = 0; 102 | int raw_output = 0; 103 | int interlaced = 0; 104 | int tff = 0; 105 | int input_depth = 8; 106 | int input_width; 107 | int input_height; 108 | unsigned fps_num = 0; 109 | unsigned fps_den = 0; 110 | unsigned par_width = 0; 111 | unsigned par_height = 0; 112 | int i_frame = 0; 113 | int64_t i_frame_total = 0; 114 | int64_t i_start = 0; 115 | #if defined(AVS_WINDOWS) 116 | SetConsoleTitle("avs2yuv: preparing frameserver"); 117 | #endif 118 | for(int i = 1; i < argc; i++) { 119 | if(argv[i][0] == '-' && argv[i][1] != 0) { 120 | if(!strcmp(argv[i], "-h")) 121 | usage = 1; 122 | else if(!strcmp(argv[i], "-nstdr")) 123 | nostderr = 1; 124 | else if(!strcmp(argv[i], "-o")) { 125 | if(i > argc-2) { 126 | fprintf(stderr, "Error: -o needs an argument.\n"); 127 | return 2; 128 | } 129 | i++; 130 | goto add_outfile; 131 | } else if(!strcmp(argv[i], "-seek")) { 132 | if(i > argc-2) { 133 | fprintf(stderr, "Error: -seek needs an argument.\n"); 134 | return 2; 135 | } 136 | seek = atoi(argv[++i]); 137 | if(seek < 0) usage = 1; 138 | } else if(!strcmp(argv[i], "-frames")) { 139 | if(i > argc-2) { 140 | fprintf(stderr, "Error: -frames needs an argument.\n"); 141 | return 2; 142 | } 143 | end = atoi(argv[++i]); 144 | } else if(!strcmp(argv[i], "-raw")) { 145 | raw_output = 1; 146 | if (!nostderr) { 147 | fprintf(stderr, "Warning: output will not contain any headers!\nYou will have to point resolution, framerate and format (and duration) manually to your reading software.\n"); 148 | } 149 | } else if(!strcmp(argv[i], "-slave")) { 150 | slave = 1; 151 | } else if(!strcmp(argv[i], "-depth")) { 152 | if(i > argc-2) { 153 | fprintf(stderr, "Error: -depth needs an argument.\n"); 154 | return 2; 155 | } 156 | input_depth = atoi(argv[++i]); 157 | if(input_depth < 8 || input_depth > 16) { 158 | fprintf(stderr, "Error: -depth \"%s\" is not supported.\n", argv[i]); 159 | return 2; 160 | } 161 | } else if(!strcmp(argv[i], "-fps")) { 162 | if(i > argc-2) { 163 | fprintf(stderr, "Error: -fps needs an argument.\n"); 164 | return 2; 165 | } 166 | const char *str = argv[++i]; 167 | if(sscanf(str, "%u/%u", &fps_num, &fps_den) != 2) { 168 | char *str_end; 169 | double fps = strtod(str, &str_end); 170 | if(str_end == str || *str_end != '\0' || fps <= 0 || fps > INT_MAX) 171 | fps_num = 0; 172 | else if(fps <= INT_MAX/1000) { 173 | fps_num = (unsigned)(fps * 1000 + .5); 174 | fps_den = 1000; 175 | } else { 176 | fps_num = (unsigned)(fps + .5); 177 | fps_den = 1; 178 | } 179 | } 180 | if(!fps_num || !fps_den) { 181 | fprintf(stderr, "Error: -fps \"%s\" is not supported.\n", str); 182 | return 2; 183 | } 184 | } else if(!strcmp(argv[i], "-par")) { 185 | if(i > argc-2) { 186 | fprintf(stderr, "Error: -par needs an argument.\n"); 187 | return 2; 188 | } 189 | const char *str = argv[++i]; 190 | if( (sscanf(str, "%u:%u", &par_width, &par_height) != 2) && 191 | (sscanf(str, "%u/%u", &par_width, &par_height) != 2) ) 192 | { 193 | fprintf(stderr, "Error: -par \"%s\" is not supported.\n", str); 194 | return 2; 195 | } 196 | } else { 197 | fprintf(stderr, "Error: no such option \"%s\".\n", argv[i]); 198 | return 2; 199 | } 200 | } else if(!infile) { 201 | infile = argv[i]; 202 | const char *dot = strrchr(infile, '.'); 203 | if(!dot || strcmp(".avs", dot)) 204 | fprintf(stderr, "Error: infile \"%s\" doesn't look like an avisynth script.\n", infile); 205 | } else { 206 | add_outfile: 207 | if(out_fhs > MAX_FH-1) { 208 | fprintf(stderr, "Error: too many output files.\n"); 209 | return 2; 210 | } 211 | outfile[out_fhs] = argv[i]; 212 | y4m_headers[out_fhs] = !raw_output; 213 | out_fhs++; 214 | } 215 | } 216 | if(usage || !infile || (!out_fhs && !nostderr)) { 217 | fprintf(stderr, MY_VERSION "\n"AUTHORS "\n" 218 | "Usage: avs2yuv [options] in.avs [-o out.y4m] [-o out2.y4m]\n" 219 | "-nstdr\tdo not print info to stderr\n" 220 | "-seek\tseek to the given frame number\n" 221 | "-frames\tstop after processing this many frames\n" 222 | "-slave\tinit script and do nothing\n\t(useful for piping from TCPDeliver to AvsNetPipe)\n" 223 | "-raw\toutput raw data\n" 224 | "-depth\tspecify input bit depth\n\t(default 8, trying to guess from the script)\n" 225 | "-fps\toverwrite input framerate\n" 226 | "-par\tspecify pixel aspect ratio\n" 227 | "The outfile may be \"-\", meaning stdout.\n" 228 | "Output format is yuv4mpeg, as used by MPlayer, FFmpeg, Libav, x264, mjpegtools.\n" 229 | ); 230 | return 2; 231 | } 232 | int retval = 1; 233 | avs_hnd_t avs_h = {0}; 234 | if(internal_avs_load_library(&avs_h) < 0) { 235 | fprintf(stderr, "Error: failed to load %s.\n", AVS_LIBNAME); 236 | goto fail; 237 | } 238 | avs_h.env = avs_h.func.avs_create_script_environment(AVISYNTH_INTERFACE_VERSION); 239 | if(avs_h.func.avs_get_error) { 240 | const char *error = avs_h.func.avs_get_error(avs_h.env); 241 | if(error) { 242 | fprintf(stderr, "Error: %s.\n", error); 243 | goto fail; 244 | } 245 | } 246 | AVS_Value arg = avs_new_value_string(infile); 247 | AVS_Value res = avs_h.func.avs_invoke(avs_h.env, "Import", arg, NULL); 248 | if(avs_is_error(res)) { 249 | fprintf(stderr, "Error: %s.\n", avs_as_string(res)); 250 | goto fail; 251 | } 252 | if(!avs_is_clip(res)) { 253 | fprintf(stderr, "Error: \"%s\" didn't return a video clip.\n", infile); 254 | goto fail; 255 | } 256 | avs_h.clip = avs_h.func.avs_take_clip(res, avs_h.env); 257 | const AVS_VideoInfo *inf = avs_h.func.avs_get_video_info(avs_h.clip); 258 | if(!avs_has_video(inf)) { 259 | fprintf(stderr, "Error: \"%s\" has no video data.\n", infile); 260 | goto fail; 261 | } 262 | if(!avs_h.func.avs_component_size(inf)) { 263 | fprintf(stderr, "Error: this program only works with Avisynth+.\n"); 264 | goto fail; 265 | } 266 | /* if the clip is made of fields instead of frames, call weave to make them frames */ 267 | if(avs_is_field_based(inf)) { 268 | fprintf(stderr, "Detected fieldbased (separated) input, weaving to frames.\n"); 269 | AVS_Value tmp = avs_h.func.avs_invoke(avs_h.env, "Weave", res, NULL); 270 | if(avs_is_error(tmp)) { 271 | fprintf(stderr, "Error: couldn't weave fields into frames.\n"); 272 | goto fail; 273 | } 274 | res = internal_avs_update_clip(&avs_h, &inf, tmp, res); 275 | interlaced = 1; 276 | tff = avs_is_tff(inf); 277 | } 278 | if(!nostderr) 279 | fprintf(stderr, "%s\n", MY_VERSION); 280 | input_width = inf->width; 281 | input_height = inf->height; 282 | if(input_depth > 8 && (avs_h.func.avs_is_yv12(inf) || avs_h.func.avs_is_yv16(inf) || avs_h.func.avs_is_yv24(inf))) { //ignore native hbd cs 283 | if(input_width & 3) { 284 | if(!nostderr) 285 | fprintf(stderr, "Error: avisynth %d-bit hack requires that width is at least mod4.\n", input_depth); 286 | goto fail; 287 | } 288 | if(!nostderr) 289 | fprintf(stderr, "Avisynth %d-bit hack enabled!\n", input_depth); 290 | if(avs_h.func.avs_component_size(inf) == 1) 291 | input_width >>= 1; 292 | } 293 | if(!fps_num || !fps_den) { 294 | fps_num = inf->fps_numerator; 295 | fps_den = inf->fps_denominator; 296 | } 297 | if(!nostderr) { 298 | fprintf(stderr, "Script file:\t%s\nResolution:\t%dx%d\n", infile, input_width, input_height); 299 | if(fps_den == 1) 300 | fprintf(stderr, "Frames per sec:\t%u\n", fps_num); 301 | else 302 | fprintf(stderr, "Frames per sec:\t%u/%u (%.3f)\n", fps_num, fps_den, (float) fps_num/fps_den); 303 | fprintf(stderr, "Total frames:\t%d\n", inf->num_frames); 304 | } 305 | signal(SIGINT, sigintHandler); 306 | //start processing 307 | i_start = avs2yuv_mdate(); 308 | time_t tm_s = time(0); 309 | i_frame_total = inf->num_frames; 310 | if(b_ctrl_c) 311 | goto close_files; 312 | avs_h.func.avs_release_value(res); 313 | for(int i = 0; i < out_fhs; i++) { 314 | if(!strcmp(outfile[i], "-")) { 315 | for(int j = 0; j < i; j++) 316 | if(out_fh[j] == stdout) { 317 | fprintf(stderr, "Error: can't write to stdout multiple times.\n"); 318 | goto fail; 319 | } 320 | int dupout = dup(fileno(stdout)); 321 | fclose(stdout); 322 | #if defined(AVS_WINDOWS) 323 | _setmode(dupout, _O_BINARY); 324 | #endif 325 | out_fh[i] = fdopen(dupout, "wb"); 326 | } else { 327 | out_fh[i] = fopen(outfile[i], "wb"); 328 | if(!out_fh[i]) { 329 | fprintf(stderr, "Error: failed to create/open \"%s\".\n", outfile[i]); 330 | goto fail; 331 | } 332 | } 333 | } 334 | char *interlace_type = interlaced ? tff ? "t" : "b" : "p"; 335 | char csp_type[200]; 336 | int chroma_h_shift = 0; 337 | int chroma_v_shift = 0; 338 | if(avs_h.func.avs_is_y(inf)) { 339 | if(input_depth == 16) 340 | sprintf(csp_type, "Cmono16 XYSCSS=Cmono16"); 341 | else if(avs_h.func.avs_bits_per_component(inf) == 16) 342 | sprintf(csp_type, "Cmono16 XYSCSS=Cmono16"); 343 | else if((avs_h.func.avs_bits_per_component(inf) > 8 && avs_h.func.avs_bits_per_component(inf) < 16) || (input_depth > 8 && input_depth < 16)) { 344 | fprintf(stderr, "Warning: output bit-depth is forced to 16 (was %d)!\n", avs_h.func.avs_bits_per_component(inf)); 345 | sprintf(csp_type, "Cmono16 XYSCSS=Cmono16"); 346 | } else 347 | sprintf(csp_type, "Cmono"); 348 | } else if(avs_h.func.avs_is_420(inf)) { 349 | chroma_h_shift = 1; 350 | chroma_v_shift = 1; 351 | if(input_depth > 8) 352 | sprintf(csp_type, "C420p%d XYSCSS=C420p%d", input_depth, input_depth); 353 | else if(avs_h.func.avs_bits_per_component(inf) > 8) 354 | sprintf(csp_type, "C420p%d XYSCSS=C420p%d", avs_h.func.avs_bits_per_component(inf), avs_h.func.avs_bits_per_component(inf)); 355 | else 356 | sprintf(csp_type, "C420mpeg2"); 357 | } else if(avs_h.func.avs_is_422(inf)) { 358 | chroma_h_shift = 1; 359 | if(input_depth > 8) 360 | sprintf(csp_type, "C422p%d XYSCSS=C422p%d", input_depth, input_depth); 361 | else if(avs_h.func.avs_bits_per_component(inf) > 8) 362 | sprintf(csp_type, "C422p%d XYSCSS=C422p%d", avs_h.func.avs_bits_per_component(inf), avs_h.func.avs_bits_per_component(inf)); 363 | else 364 | sprintf(csp_type, "C422"); 365 | } else if(avs_h.func.avs_is_444(inf)) { 366 | if(input_depth > 8) 367 | sprintf(csp_type, "C444p%d XYSCSS=C444p%d", input_depth, input_depth); 368 | else if(avs_h.func.avs_bits_per_component(inf) > 8) 369 | sprintf(csp_type, "C444p%d XYSCSS=C444p%d", avs_h.func.avs_bits_per_component(inf), avs_h.func.avs_bits_per_component(inf)); 370 | else 371 | sprintf(csp_type, "C444"); 372 | } else { 373 | if(!raw_output) { 374 | fprintf(stderr, "Error: unsupported colorspace.\nYou still can output any format in headerless mode. Use \"-raw\" option if you really need that.\n"); 375 | goto fail; 376 | } 377 | } 378 | for(int i = 0; i < out_fhs; i++) { 379 | if(setvbuf(out_fh[i], NULL, _IOFBF, AVS_BUFSIZE)) { 380 | fprintf(stderr, "Error: failed to create buffer for \"%s\".\n", outfile[i]); 381 | goto fail; 382 | } 383 | if(!y4m_headers[i]) 384 | continue; 385 | fprintf(out_fh[i], "YUV4MPEG2 W%d H%d F%u:%u I%s A%u:%u %s\n", input_width, input_height, fps_num, fps_den, interlace_type, par_width, par_height, csp_type); 386 | fflush(out_fh[i]); 387 | } 388 | int frame_size = (inf->width * avs_h.func.avs_component_size(inf)) * inf->height + (avs_h.func.avs_num_components(inf) - 1) * ((inf->width * avs_h.func.avs_component_size(inf)) >> chroma_h_shift) * (inf->height >> chroma_v_shift); 389 | int write_target = out_fhs * frame_size; // how many bytes per frame we expect to write 390 | if(slave) { 391 | seek = 0; 392 | end = INT_MAX; 393 | #if defined(AVS_WINDOWS) 394 | SetConsoleTitle("avs2yuv: slave process running"); 395 | #endif 396 | } else { 397 | end += seek; 398 | if(end <= seek || end > inf->num_frames) 399 | end = inf->num_frames; 400 | } 401 | for(int frm = seek; frm < end; ++frm) { 402 | if(slave) { 403 | char input[80]; 404 | frm = -1; 405 | do { 406 | if(!fgets(input, 80, stdin)) 407 | goto close_files; 408 | sscanf(input, "%d", &frm); 409 | } while(frm < 0); 410 | if(frm >= inf->num_frames) 411 | frm = inf->num_frames-1; 412 | } 413 | AVS_VideoFrame *f = avs_h.func.avs_get_frame(avs_h.clip, frm); 414 | const char *err = avs_h.func.avs_clip_get_error(avs_h.clip); 415 | if(err) { 416 | fprintf(stderr, "Error: %s occurred while reading frame %d.\n", err, frm); 417 | goto fail; 418 | } 419 | if(out_fhs) { 420 | static const int planes[] = {AVS_PLANAR_Y, AVS_PLANAR_U, AVS_PLANAR_V}; 421 | int wrote = 0; 422 | for(int i = 0; i < out_fhs; i++) 423 | if(y4m_headers[i]) 424 | fwrite("FRAME\n", 1, 6, out_fh[i]); 425 | for(int p = 0; p < avs_h.func.avs_num_components(inf); p++) { 426 | int w = (inf->width * avs_h.func.avs_component_size(inf)) >> (p ? chroma_h_shift : 0); 427 | int h = inf->height >> (p ? chroma_v_shift : 0); 428 | int pitch = avs_h.func.avs_get_pitch_p(f, planes[p]); 429 | const BYTE* data = avs_h.func.avs_get_read_ptr_p(f, planes[p]); 430 | for(int y = 0; y < h; y++) { 431 | for(int i = 0; i < out_fhs; i++) 432 | wrote += fwrite(data, 1, w, out_fh[i]); 433 | data += pitch; 434 | } 435 | } 436 | if(wrote != write_target) { 437 | fprintf(stderr, "Error: wrote only %d of %d bytes.\n", wrote, write_target); 438 | goto fail; 439 | } 440 | if(slave) { // assume timing doesn't matter in other modes 441 | for(int i = 0; i < out_fhs; i++) 442 | fflush(out_fh[i]); 443 | } 444 | } 445 | #if defined(AVS_WINDOWS) 446 | if(frm == 0) { 447 | SetConsoleTitle("avs2yuv: executing script"); 448 | } 449 | #endif 450 | if(!nostderr) { 451 | char buf[400]; 452 | int64_t i_time = avs2yuv_mdate(); 453 | int64_t i_elapsed = i_time - i_start; 454 | double fps = i_elapsed > 0 ? frm * 1000000. / i_elapsed : 0; 455 | i_frame = frm + 1; 456 | int secs = i_elapsed / 1000000; 457 | int eta = i_elapsed * (i_frame_total - i_frame) / ((int64_t)i_frame * 1000000); 458 | if(!nostderr) { 459 | #if defined(AVS_WINDOWS) 460 | sprintf(buf, "avs2yuv [%.1f%%], %d/%d frames, %.2f fps, eta %d:%02d:%02d", 100. * frm / i_frame_total, frm, (int)i_frame_total, fps, eta / 3600, (eta / 60) % 60, eta % 60); 461 | SetConsoleTitle(buf); 462 | #endif 463 | static int print_progress_header = 1; 464 | if(print_progress_header) { 465 | fprintf(stderr, "%6s %12s %7s %9s %9s\n", "Progress", "Frames", "FPS", "Elapsed", "Remain"); 466 | print_progress_header = 0; 467 | } 468 | sprintf(buf, "[%5.1f%%] %6d/%-6d %8.2f %3d:%02d:%02d %3d:%02d:%02d", 100. * frm / i_frame_total, frm, (int)i_frame_total, fps, secs / 3600, (secs / 60) % 60, secs % 60, eta / 3600, (eta / 60) % 60, eta % 60); 469 | fprintf(stderr, "%s \r", buf); 470 | } 471 | fflush(stderr); 472 | } 473 | avs_h.func.avs_release_video_frame(f); 474 | } 475 | for(int i = 0; i < out_fhs; i++) 476 | fflush(out_fh[i]); 477 | close_files: 478 | retval = 0; 479 | if(!nostderr) { 480 | time_t tm2 = time(NULL); 481 | fprintf(stderr, "\n"); 482 | fprintf(stderr, "Started:\t%s", ctime(&tm_s)); 483 | fprintf(stderr, "Finished:\t%s", ctime(&tm2)); 484 | tm2 = tm2 - tm_s; 485 | fprintf(stderr, "Elapsed:\t%d:%02d:%02d\n", (int)tm2 / 3600, (int)tm2 % 3600 / 60, (int)tm2 % 60); 486 | } 487 | fail: 488 | for(int i = 0; i < out_fhs; i++) 489 | if(out_fh[i]) 490 | fclose(out_fh[i]); 491 | if(avs_h.library) 492 | internal_avs_close_library(&avs_h); 493 | return retval; 494 | } 495 | -------------------------------------------------------------------------------- /avs_internal.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * avs.c: avisynth input 3 | ***************************************************************************** 4 | * Copyright (C) 2009-2011 x264 project 5 | * 6 | * Authors: Steven Walters 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 21 | * 22 | * This program is also available under a commercial proprietary license. 23 | * For more information, contact us at licensing@x264.com. 24 | *****************************************************************************/ 25 | 26 | #if defined(_WIN32) 27 | #include 28 | #define SYS_WINDOWS 1 29 | #endif 30 | 31 | #define AVSC_NO_DECLSPEC 32 | #undef EXTERN_C 33 | 34 | #include 35 | 36 | #if defined(AVS_POSIX) 37 | #include 38 | #if defined(AVS_MACOS) 39 | #define avs_open() dlopen( "libavisynth.dylib", RTLD_NOW ) 40 | #else 41 | #define avs_open() dlopen( "libavisynth.so", RTLD_NOW ) 42 | #endif 43 | #define avs_close dlclose 44 | #define avs_address dlsym 45 | #else 46 | #define avs_open() LoadLibraryW( L"avisynth" ) 47 | #define avs_close FreeLibrary 48 | #define avs_address GetProcAddress 49 | #endif 50 | 51 | #define AVSC_DECLARE_FUNC(name) name##_func name 52 | 53 | #define LOAD_AVS_FUNC(name, continue_on_fail)\ 54 | {\ 55 | h->func.name = (void*)avs_address(h->library, #name);\ 56 | if(!continue_on_fail && !h->func.name)\ 57 | goto fail;\ 58 | } 59 | 60 | typedef struct 61 | { 62 | AVS_Clip *clip; 63 | AVS_ScriptEnvironment *env; 64 | void *library; 65 | struct 66 | { 67 | AVSC_DECLARE_FUNC(avs_add_function); 68 | AVSC_DECLARE_FUNC(avs_at_exit); 69 | AVSC_DECLARE_FUNC(avs_bit_blt); 70 | AVSC_DECLARE_FUNC(avs_check_version); 71 | AVSC_DECLARE_FUNC(avs_clip_get_error); 72 | AVSC_DECLARE_FUNC(avs_copy_clip); 73 | AVSC_DECLARE_FUNC(avs_copy_value); 74 | AVSC_DECLARE_FUNC(avs_copy_video_frame); 75 | AVSC_DECLARE_FUNC(avs_create_script_environment); 76 | AVSC_DECLARE_FUNC(avs_delete_script_environment); 77 | AVSC_DECLARE_FUNC(avs_function_exists); 78 | AVSC_DECLARE_FUNC(avs_get_audio); 79 | AVSC_DECLARE_FUNC(avs_get_cpu_flags); 80 | AVSC_DECLARE_FUNC(avs_get_frame); 81 | AVSC_DECLARE_FUNC(avs_get_parity); 82 | AVSC_DECLARE_FUNC(avs_get_var); 83 | AVSC_DECLARE_FUNC(avs_get_version); 84 | AVSC_DECLARE_FUNC(avs_get_video_info); 85 | AVSC_DECLARE_FUNC(avs_invoke); 86 | AVSC_DECLARE_FUNC(avs_make_writable); 87 | AVSC_DECLARE_FUNC(avs_new_c_filter); 88 | AVSC_DECLARE_FUNC(avs_new_video_frame_a); 89 | AVSC_DECLARE_FUNC(avs_release_clip); 90 | AVSC_DECLARE_FUNC(avs_release_value); 91 | AVSC_DECLARE_FUNC(avs_release_video_frame); 92 | AVSC_DECLARE_FUNC(avs_save_string); 93 | AVSC_DECLARE_FUNC(avs_set_cache_hints); 94 | AVSC_DECLARE_FUNC(avs_set_global_var); 95 | AVSC_DECLARE_FUNC(avs_set_memory_max); 96 | AVSC_DECLARE_FUNC(avs_set_to_clip); 97 | AVSC_DECLARE_FUNC(avs_set_var); 98 | AVSC_DECLARE_FUNC(avs_set_working_dir); 99 | AVSC_DECLARE_FUNC(avs_sprintf); 100 | AVSC_DECLARE_FUNC(avs_subframe); 101 | AVSC_DECLARE_FUNC(avs_subframe_planar); 102 | AVSC_DECLARE_FUNC(avs_take_clip); 103 | AVSC_DECLARE_FUNC(avs_vsprintf); 104 | 105 | AVSC_DECLARE_FUNC(avs_get_error); 106 | AVSC_DECLARE_FUNC(avs_is_rgb48); 107 | AVSC_DECLARE_FUNC(avs_is_rgb64); 108 | AVSC_DECLARE_FUNC(avs_is_yv24); 109 | AVSC_DECLARE_FUNC(avs_is_yv16); 110 | AVSC_DECLARE_FUNC(avs_is_yv12); 111 | AVSC_DECLARE_FUNC(avs_is_yv411); 112 | AVSC_DECLARE_FUNC(avs_is_y8); 113 | AVSC_DECLARE_FUNC(avs_is_yuv444p16); 114 | AVSC_DECLARE_FUNC(avs_is_yuv422p16); 115 | AVSC_DECLARE_FUNC(avs_is_yuv420p16); 116 | AVSC_DECLARE_FUNC(avs_is_y16); 117 | AVSC_DECLARE_FUNC(avs_is_yuv444ps); 118 | AVSC_DECLARE_FUNC(avs_is_yuv422ps); 119 | AVSC_DECLARE_FUNC(avs_is_yuv420ps); 120 | AVSC_DECLARE_FUNC(avs_is_y32); 121 | AVSC_DECLARE_FUNC(avs_is_444); 122 | AVSC_DECLARE_FUNC(avs_is_422); 123 | AVSC_DECLARE_FUNC(avs_is_420); 124 | AVSC_DECLARE_FUNC(avs_is_y); 125 | AVSC_DECLARE_FUNC(avs_is_yuva); 126 | AVSC_DECLARE_FUNC(avs_is_planar_rgb); 127 | AVSC_DECLARE_FUNC(avs_is_planar_rgba); 128 | AVSC_DECLARE_FUNC(avs_is_color_space); 129 | 130 | AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling); 131 | AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling); 132 | AVSC_DECLARE_FUNC(avs_bits_per_pixel); 133 | AVSC_DECLARE_FUNC(avs_bytes_from_pixels); 134 | AVSC_DECLARE_FUNC(avs_row_size); 135 | AVSC_DECLARE_FUNC(avs_bmp_size); 136 | AVSC_DECLARE_FUNC(avs_get_pitch_p); 137 | AVSC_DECLARE_FUNC(avs_get_row_size_p); 138 | AVSC_DECLARE_FUNC(avs_get_height_p); 139 | AVSC_DECLARE_FUNC(avs_get_read_ptr_p); 140 | AVSC_DECLARE_FUNC(avs_is_writable); 141 | AVSC_DECLARE_FUNC(avs_get_write_ptr_p); 142 | 143 | AVSC_DECLARE_FUNC(avs_num_components); 144 | AVSC_DECLARE_FUNC(avs_component_size); 145 | AVSC_DECLARE_FUNC(avs_bits_per_component); 146 | } func; 147 | } avs_hnd_t; 148 | 149 | /* load the library and functions we require from it */ 150 | static int internal_avs_load_library(avs_hnd_t *h) 151 | { 152 | h->library = avs_open(); 153 | if(!h->library) 154 | return -1; 155 | LOAD_AVS_FUNC(avs_add_function, 0); 156 | LOAD_AVS_FUNC(avs_at_exit, 0); 157 | LOAD_AVS_FUNC(avs_bit_blt, 0); 158 | LOAD_AVS_FUNC(avs_check_version, 0); 159 | LOAD_AVS_FUNC(avs_clip_get_error, 0); 160 | LOAD_AVS_FUNC(avs_copy_clip, 0); 161 | LOAD_AVS_FUNC(avs_copy_value, 0); 162 | LOAD_AVS_FUNC(avs_copy_video_frame, 0); 163 | LOAD_AVS_FUNC(avs_create_script_environment, 0); 164 | LOAD_AVS_FUNC(avs_delete_script_environment, 1); 165 | LOAD_AVS_FUNC(avs_function_exists, 0); 166 | LOAD_AVS_FUNC(avs_get_audio, 0); 167 | LOAD_AVS_FUNC(avs_get_cpu_flags, 0); 168 | LOAD_AVS_FUNC(avs_get_frame, 0); 169 | LOAD_AVS_FUNC(avs_get_parity, 0); 170 | LOAD_AVS_FUNC(avs_get_var, 0); 171 | LOAD_AVS_FUNC(avs_get_version, 0); 172 | LOAD_AVS_FUNC(avs_get_video_info, 0); 173 | LOAD_AVS_FUNC(avs_invoke, 0); 174 | LOAD_AVS_FUNC(avs_make_writable, 0); 175 | LOAD_AVS_FUNC(avs_new_c_filter, 0); 176 | LOAD_AVS_FUNC(avs_new_video_frame_a, 0); 177 | LOAD_AVS_FUNC(avs_release_clip, 0); 178 | LOAD_AVS_FUNC(avs_release_value, 0); 179 | LOAD_AVS_FUNC(avs_release_video_frame, 0); 180 | LOAD_AVS_FUNC(avs_save_string, 0); 181 | LOAD_AVS_FUNC(avs_set_cache_hints, 0); 182 | LOAD_AVS_FUNC(avs_set_global_var, 0); 183 | LOAD_AVS_FUNC(avs_set_memory_max, 0); 184 | LOAD_AVS_FUNC(avs_set_to_clip, 0); 185 | LOAD_AVS_FUNC(avs_set_var, 0); 186 | LOAD_AVS_FUNC(avs_set_working_dir, 0); 187 | LOAD_AVS_FUNC(avs_sprintf, 0); 188 | LOAD_AVS_FUNC(avs_subframe, 0); 189 | LOAD_AVS_FUNC(avs_subframe_planar, 0); 190 | LOAD_AVS_FUNC(avs_take_clip, 0); 191 | LOAD_AVS_FUNC(avs_vsprintf, 0); 192 | 193 | LOAD_AVS_FUNC(avs_get_error, 1); 194 | LOAD_AVS_FUNC(avs_is_rgb48, 0); 195 | LOAD_AVS_FUNC(avs_is_rgb64, 0); 196 | LOAD_AVS_FUNC(avs_is_yv24, 0); 197 | LOAD_AVS_FUNC(avs_is_yv16, 0); 198 | LOAD_AVS_FUNC(avs_is_yv12, 0); 199 | LOAD_AVS_FUNC(avs_is_yv411, 0); 200 | LOAD_AVS_FUNC(avs_is_y8, 0); 201 | LOAD_AVS_FUNC(avs_is_yuv444p16, 0); 202 | LOAD_AVS_FUNC(avs_is_yuv422p16, 0); 203 | LOAD_AVS_FUNC(avs_is_yuv420p16, 0); 204 | LOAD_AVS_FUNC(avs_is_y16, 0); 205 | LOAD_AVS_FUNC(avs_is_yuv444ps, 0); 206 | LOAD_AVS_FUNC(avs_is_yuv422ps, 0); 207 | LOAD_AVS_FUNC(avs_is_yuv420ps, 0); 208 | LOAD_AVS_FUNC(avs_is_y32, 0); 209 | LOAD_AVS_FUNC(avs_is_444, 0); 210 | LOAD_AVS_FUNC(avs_is_422, 0); 211 | LOAD_AVS_FUNC(avs_is_420, 0); 212 | LOAD_AVS_FUNC(avs_is_y, 0); 213 | LOAD_AVS_FUNC(avs_is_yuva, 0); 214 | LOAD_AVS_FUNC(avs_is_planar_rgb, 0); 215 | LOAD_AVS_FUNC(avs_is_planar_rgba, 0); 216 | LOAD_AVS_FUNC(avs_is_color_space, 0); 217 | 218 | LOAD_AVS_FUNC(avs_get_plane_width_subsampling, 0); 219 | LOAD_AVS_FUNC(avs_get_plane_height_subsampling, 0); 220 | LOAD_AVS_FUNC(avs_bits_per_pixel, 0); 221 | LOAD_AVS_FUNC(avs_bytes_from_pixels, 0); 222 | LOAD_AVS_FUNC(avs_row_size, 0); 223 | LOAD_AVS_FUNC(avs_bmp_size, 0); 224 | LOAD_AVS_FUNC(avs_get_pitch_p, 0); 225 | LOAD_AVS_FUNC(avs_get_row_size_p, 0); 226 | LOAD_AVS_FUNC(avs_get_height_p, 0); 227 | LOAD_AVS_FUNC(avs_get_read_ptr_p, 0); 228 | LOAD_AVS_FUNC(avs_is_writable, 0); 229 | LOAD_AVS_FUNC(avs_get_write_ptr_p, 0); 230 | 231 | LOAD_AVS_FUNC(avs_num_components, 0); 232 | LOAD_AVS_FUNC(avs_component_size, 0); 233 | LOAD_AVS_FUNC(avs_bits_per_component, 0); 234 | return 0; 235 | fail: 236 | avs_close(h->library); 237 | h->library = NULL; 238 | return -1; 239 | } 240 | 241 | static AVS_Value internal_avs_update_clip(avs_hnd_t *h, const AVS_VideoInfo **vi, AVS_Value res, AVS_Value release) 242 | { 243 | h->func.avs_release_clip(h->clip); 244 | h->clip = h->func.avs_take_clip(res, h->env); 245 | h->func.avs_release_value(release); 246 | *vi = h->func.avs_get_video_info(h->clip); 247 | return res; 248 | } 249 | 250 | static int internal_avs_close_library(avs_hnd_t *h) 251 | { 252 | h->func.avs_release_clip(h->clip); 253 | if(h->func.avs_delete_script_environment) 254 | h->func.avs_delete_script_environment(h->env); 255 | avs_close(h->library); 256 | h->library = NULL; 257 | return 0; 258 | } 259 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /gpl.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 675 Mass Ave, Cambridge, MA 02139, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | Appendix: How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 19yy 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) 19yy name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Library General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------