Projects
Multimedia
nordlicht
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 16
View file
nordlicht.spec
Changed
@@ -1,7 +1,7 @@ %define soname 0 Name: nordlicht -Version: 0.4.2 +Version: 0.4.4 Release: 0 License: GPL-2.0+ Summary: Creates colorful barcodes from video files
View file
_service:download_files:v0.4.4.tar.gz/CHANGELOG.md
Added
@@ -0,0 +1,103 @@ +# Change Log + +All notable changes to this project will be documented in this file. +*nordlicht* uses [Semantic Versioning](http://semver.org/). + +## 0.4.4 - 2016-01-24 + +- introduce the convention that the nordlicht is always written to `VIDEOFILE.nordlicht.png` +- increase default size to 1920x192, to get nice results on 1080p displays +- introduce `nordlicht_set_style`, which only accepts one style +- rename old `nordlicht_set_style` to `nordlicht_set_styles` +- fixes to the build system: don't over-/underlink (thanks, Roland!), set library `VERSION` only export symbols of the public API +- make pkg-config file more specific (thanks, Roland!) + +- mpv: check whether this file exists before generating a new one +- mpv: press *N* to re-generate nordlicht +- mpv: show nordlicht for 1 second when navigating in "off" mode (thanks, Roland!) + +## 0.4.3 - 2016-01-17 + +- add LICENSE.md and CHANGELOG.md +- add export specifier to API functions (thanks, Peter!) +- improve documentation at various places +- mpv plugin: Seek when clicking into the nordlicht + +## 0.4.2 - 2016-01-02 + +- report the correct version number when using `--version`. Oops. + +## 0.4.1 - 2015-12-11 + +Minor fix for better packaging: + +- don't test for unused FFmpeg libraries in CMake. Thanks, Olaf! + +## 0.4.0 "LED Throwie" - 2015-10-05 + +- introduce multiple new styles, including slitscan, middlecolumn and spectrogram +- allow specification of multiple styles at once, using `-s style1+style2` +- introduce options 'start' end 'end' in API and tool +- introduce `nordlicht_error()`, which returns a description of the last error +- add a `--quiet` switch to the tool, that suppresses progress output +- use FFmpeg to write PNGs, drop libpng dependency +- various bug fixes for older FFmpeg versions + +## 0.3.5 - 2014-03-20 + +- add a test suite for library and tool, fix a few bugs along the way +- add examples for the C API +- introduce `nordlicht_set_style()` to replace the "live" switch + +## 0.3.4 - 2014-03-15 + +This is a bug fix release: + +- fix a bug in upscaling the barcode's height +- don't `exit()` in library calls + +## 0.3.3 - 2014-03-03 + +Quick release to enable better packeting: + +- Replace FreeImage by libpng. + +## 0.3.2 - 2014-03-02 + +- generate a Makefile from `--help` using help2man +- do proper SOVERSION-ing +- introduce an experimental `--live` mode, which generates a BGRA file for mpv +- the mpv integration is really coming along + +## 0.3.1 - 2014-02-23 + +- Automatically decide whether exact seeking is necessary, remove the manual switch +- Significant quality improvements by better vertical and horizontal compression +- Fix time shift by correctly flushing FFmpeg's buffers +- Improve mpv-nordlicht to automatically display the barcode and go fullscreen + +## 0.3.0 "Blaze" - 2014-02-16 + +- New CLI API with proper GNU-style arguments +- Option to do "vertical" compression: `--style=vertical` +- Experimental "frame exakt" seeking with `--exact` switch +- Hacked together an mpv-nordlicht script that generates a barcode and displays it in mpv +- Fixed some memory leaks, added a lot of security checks + +## 0.2.0 "Spark" - 2014-02-11 + +Features a complete rewrite, removing the strong dependency on FFmpeg. Additional improvements: + +- Hand written downsampling, making generation much faster +- New, simpler API +- Command line tool now checks it's arguments + +## 0.1.1 - 2013-08-04 + +A minor release, mainly patching the code for older FFmpeg versions. + +## 0.1.0 "Fiat Lux" - 2013-08-02 + +After a few prototypes in shell script (look at the history if you're curious), +this is the first "stable" version of nordlicht. It comes with a command line +tool which uses the shared library.
View file
_service:download_files:v0.4.2.tar.gz/CMakeLists.txt -> _service:download_files:v0.4.4.tar.gz/CMakeLists.txt
Changed
@@ -1,46 +1,71 @@ -cmake_minimum_required(VERSION 2.6) +cmake_minimum_required(VERSION 2.8) project(nordlicht C) -set(NORDLICHT_VERSION 0.4.2) +set(MAJOR_VERSION 0) +set(MINOR_VERSION 4) +set(PATCH_VERSION 4) +set(NORDLICHT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") + +option (BUILD_SHARED_LIBS "Build shared libraries." ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -set(LIB_SUFFIX "" CACHE STRING "Suffix of library directory name (for example '32' or '64')") -set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Directory where library will be installed") + +include(GNUInstallDirs) + +if (BUILD_SHARED_LIBS) + add_definitions(-DNORDLICHT_BUILD_SHARED) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") +else() + add_definitions(-DNORDLICHT_BUILD_STATIC) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static") +endif() find_package(Threads REQUIRED) find_package(FFmpeg COMPONENTS AVUTIL AVFORMAT AVCODEC SWSCALE REQUIRED) find_package(Popt REQUIRED) -find_program(HELP2MAN help2man) -if (NOT HELP2MAN) - message(FATAL_ERROR "help2man not found, aborting.") +if (NOT WIN32) + find_program(HELP2MAN help2man) + if (NOT HELP2MAN) + message(FATAL_ERROR "help2man not found, aborting.") + endif() endif() include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${FFMPEG_INCLUDE_DIRS} ${POPT_INCLUDES}) -add_library(libnordlicht SHARED error.c image.c nordlicht.c source.c) +add_library(libnordlicht error.c image.c nordlicht.c source.c) set_target_properties(libnordlicht PROPERTIES OUTPUT_NAME nordlicht) -set_target_properties(libnordlicht PROPERTIES SOVERSION 0) -target_link_libraries(libnordlicht ${FFMPEG_LIBRARIES}) +set_target_properties(libnordlicht PROPERTIES SOVERSION ${MAJOR_VERSION} VERSION ${NORDLICHT_VERSION}) +set_target_properties(libnordlicht PROPERTIES C_VISIBILITY_PRESET hidden) +target_link_libraries(libnordlicht m ${FFMPEG_LIBRARIES}) add_executable(nordlicht main.c) target_link_libraries(nordlicht libnordlicht ${POPT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) +if (WIN32) + target_link_libraries(nordlicht mman) +endif() add_executable(testsuite testsuite.c) target_link_libraries(testsuite libnordlicht) -configure_file(cmake/nordlicht.pc.in nordlicht.pc @ONLY) configure_file(version.h.in version.h @ONLY) -add_custom_command(TARGET nordlicht POST_BUILD - COMMAND help2man ${CMAKE_BINARY_DIR}/nordlicht -N -n "creates colorful barcodes from video files" - -o ${CMAKE_BINARY_DIR}/nordlicht.1 -) -install(TARGETS libnordlicht DESTINATION ${LIB_INSTALL_DIR}) +if (NOT WIN32) + configure_file(cmake/nordlicht.pc.in nordlicht.pc @ONLY) + add_custom_command(TARGET nordlicht POST_BUILD + COMMAND help2man ${CMAKE_BINARY_DIR}/nordlicht -N -n "creates colorful barcodes from video files" + -o ${CMAKE_BINARY_DIR}/nordlicht.1 + ) +endif() + +install(TARGETS libnordlicht DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS nordlicht DESTINATION bin) install(FILES nordlicht.h DESTINATION include) -install(FILES ${CMAKE_BINARY_DIR}/nordlicht.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -install(FILES ${CMAKE_BINARY_DIR}/nordlicht.1 DESTINATION share/man/man1) + +if (NOT WIN32) + install(FILES ${CMAKE_BINARY_DIR}/nordlicht.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + install(FILES ${CMAKE_BINARY_DIR}/nordlicht.1 DESTINATION share/man/man1) +endif() add_custom_target(check testsuite) add_custom_target(download_testfile ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/download_testfile.cmake)
View file
_service:download_files:v0.4.4.tar.gz/LICENSE.md
Added
@@ -0,0 +1,48 @@ +## nordlicht: GPLv2+ + +Copyright (c) 2013, Sebastian Morr <sebastian@morr.cc> and contributors. + +*nordlicht* is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + +*nordlicht* is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You can get a copy of the GNU General Public License at <http://www.gnu.org/licenses/>. + +## cheat.h: BSD 2-clause + +Copyright (c) 2012, Guillermo "Tordek" Freschi +Copyright (c) 2013, Sampsa "Tuplanolla" Kiiskinen +All rights reserved. + +## cmake/FindPopt.cmake: BSD 2-clause + +Copyright (c) 2012, Lars Baehren <lbaehren@gmail.com> +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +## cmake/FindFFmpeg.cmake: BSD + +Copyright (c) 2006, Matthias Kretz <kretz@kde.org> +Copyright (c) 2008, Alexander Neundorf <neundorf@kde.org> +Copyright (c) 2011, Michael Jansen <kde@michael-jansen.biz> + +Redistribution and use is allowed according to the terms of the BSD license.
View file
_service:download_files:v0.4.2.tar.gz/README.md -> _service:download_files:v0.4.4.tar.gz/README.md
Changed
@@ -2,20 +2,23 @@ **nordlicht** is a C library that creates moodbars from video files. For a general introduction, installation and usage instructions, please visit <http://nordlicht.github.io/>. -## Contributing +## Building from source -Development of *nordlicht* happens on GitHub. Please report any bugs or ideas to the [issue tracker](https://github.com/blinry/nordlicht/issues). To contribute code, fork the repository and submit a pull request. +Get CMake, FFmpeg/libav, [popt](http://freecode.com/projects/popt), and [help2man](https://www.gnu.org/software/help2man/), and issue the following commands to create the `nordlicht` binary: -You can also help by packaging the software for your favorite operating system, or writing an integration for your favorite video player. Even rough prototypes are highly appreciated! + $ mkdir build + $ cd build + $ cmake .. + $ make -*nordlicht* uses [semantic versioning](http://semver.org/). +To run the test suite, run `make check`. Note that the test suite will download a ~20 MB test video from Wikimedia Commons. -## License: GPLv2+ +## Contributing -Copyright (C) 2014, Sebastian Morr and contributors. +Development of *nordlicht* happens on GitHub. Please report any bugs or ideas to the [issue tracker](https://github.com/nordlicht/nordlicht/issues). To contribute code, fork the repository and submit a pull request. -*nordlicht* is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +You can also help by packaging the software for your favorite operating system, or writing an integration for your favorite video player. Even rough prototypes are highly appreciated! -*nordlicht* is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +## License: GPLv2+ -You can get a copy of the GNU General Public License at <http://www.gnu.org/licenses/>. +See [LICENSE.md] for details.
View file
_service:download_files:v0.4.2.tar.gz/cheat.h -> _service:download_files:v0.4.4.tar.gz/cheat.h
Changed
@@ -1,15 +1,15 @@ /* -Copyright (c) 2012, Guillermo "Tordek" Freschi -Copyright (c) 2013, Sampsa "Tuplanolla" Kiiskinen -All rights reserved. +Copyright (c) 2012 Guillermo "Tordek" Freschi +Copyright (c) 2013 Sampsa "Tuplanolla" Kiiskinen -The full license can be found in the LICENSE file. +This is free software, and you are welcome to redistribute it +under certain conditions; see the LICENSE file for details. */ /* Identifiers starting with CHEAT_ and cheat_ are reserved for internal use and - identifiers starting with cheat_test_, cheat_wrapped_ or cheat_unwrapped_ for - external use. +identifiers starting with cheat_test_, cheat_wrapped_ or cheat_unwrapped_ for +external use. */ #ifndef CHEAT_H @@ -61,8 +61,8 @@ /* These headers are also - available externally even though - they do not need to be. +available externally even though +they do not need to be. */ #include <ctype.h> @@ -98,9 +98,9 @@ All nested conditions use #else #if - instead of +instead of #elif - since some compilers choke on the shorter form. +since some compilers choke on the shorter form. */ #ifdef CHEAT_POSIXLY #include <sys/types.h> /* pid_t, ssize_t */ @@ -184,7 +184,7 @@ /* These are ISO/IEC 6429 escape sequences for - communicating text attributes to terminal emulators. +communicating text attributes to terminal emulators. */ #define CHEAT_RESET "\033[0m" /* Some compilers do not understand '\x1b'. */ #define CHEAT_BOLD "\033[1m" @@ -244,19 +244,19 @@ /* Test outcomes are reported through exit codes, but - some of them are reserved for the operating system, so - this is needed to move them out of the way. +some of them are reserved for the operating system, so +this is needed to move them out of the way. For example POSIX allows 0 ... 255 - and in that range Windows allows +and in that range Windows allows 35, 37, 40 ... 49, 73 ... 79, 81, 90 ... 99, 115 ... 116, 163, 165 ... 166, 168 ... 169, 171 ... 172, 175 ... 179, 181, 184 ... 185, 204, 211, 213, 217 ... 229, 235 ... 239 and 241 ... 253 - of which long enough are +of which long enough are 40 ... 49 (9), 90 ... 99 (9), 217 ... 229 (12) and 241 ... 253 (12). Therefore an #ifdef - maze is not necessary. +maze is not necessary. */ #ifndef CHEAT_OFFSET /* This can be set externally. */ #define CHEAT_OFFSET ((int )40) @@ -287,12 +287,12 @@ */ #define CHEAT_INTEGER_LENGTH(type) \ (CHAR_BIT * sizeof type / 3 + 1) /* This is derived from - the base 2 logarithm of 10. */ + the base 2 logarithm of 10. */ /* This prints an error message and terminates the program. The error number is context sensitive and - might only contain the least significant bytes of the actual error code. +might only contain the least significant bytes of the actual error code. */ #define cheat_death(message, number) \ CHEAT_BEGIN \ @@ -301,12 +301,12 @@ __FILE__, __LINE__, message, (unsigned int )number); \ exit(EXIT_FAILURE); \ CHEAT_END /* Using cheat_print(), cheat_exit() and - cheat_suite is intentionally avoided here. */ + cheat_suite is intentionally avoided here. */ /* These could be defined as function types instead of function pointer types, but - that would be inconsistent with the standard library and - confuse some compilers. +that would be inconsistent with the standard library and +confuse some compilers. */ typedef void (* cheat_procedure)(void); /* A test or a utility procedure. */ typedef void (* cheat_handler)(int); /* A recovery procedure. */ @@ -316,7 +316,7 @@ /* It would not hurt to have __attribute__ ((__reorder__)) - on any of these structures since they are only for internal use. +on any of these structures since they are only for internal use. */ struct cheat_unit { @@ -328,10 +328,10 @@ /* This naming convention used here follows the notion that - lists have items, - arrays have elements, - arrays of structures have counts and - arrays of primitive types have sizes. +lists have items, +arrays have elements, +arrays of structures have counts and +arrays of primitive types have sizes. */ struct cheat_string_array { @@ -432,23 +432,24 @@ /* Procedures are ordered from more pure and general to - more effectful and domain specific. +more effectful and domain specific. */ /* Calculates the arithmetic mean of two sizes and returns it. */ __attribute__ ((__const__, __warn_unused_result__)) -static size_t cheat_mean(size_t const size, size_t const another_size) { +static size_t cheat_mean(size_t const size, + size_t const another_size) { if (another_size < size) - return cheat_mean(another_size, size); + return another_size + (size - another_size) / 2; return size + (another_size - size) / 2; } /* Returns a size that is incremented so that reallocation costs are minimized or - returns the old size unchanged in case it is maximal. +returns the old size unchanged in case it is maximal. */ __attribute__ ((__const__, __warn_unused_result__)) static size_t cheat_expand(size_t const size) { @@ -466,7 +467,8 @@ Letter case is ignored and only single byte characters are guaranteed to work. */ __attribute__ ((__nonnull__, __pure__, __warn_unused_result__)) -static bool cheat_compare(char const* const first, char const* const second) { +static bool cheat_compare(char const* const first, + char const* const second) { size_t index; if (second == first) @@ -504,7 +506,7 @@ /* Safely allocates memory for a block and returns a pointer to it or - returns NULL and sets errno in case of a failure. +returns NULL and sets errno in case of a failure. */ __attribute__ ((__malloc__, __warn_unused_result__)) static void* cheat_allocate_total(size_t const count, ...) { @@ -532,11 +534,12 @@ /* Safely reallocates memory for an array and returns a pointer to it or - returns NULL and sets errno in case of a failure. +returns NULL and sets errno in case of a failure. */ __attribute__ ((__warn_unused_result__)) static void* cheat_reallocate_array(void* const pointer, - size_t const count, size_t const size) { + size_t const count, + size_t const size) { if (count > SIZE_MAX / size) return NULL; @@ -545,11 +548,12 @@ /* Allocates a truncated string with a marker at its end if it is long enough or - returns NULL and sets errno in case of a failure. +returns NULL and sets errno in case of a failure. */ __attribute__ ((__malloc__, __nonnull__, __warn_unused_result__)) static char* cheat_allocate_truncated(char const* const literal, - size_t const length, char const* const marker) { + size_t const length, + char const* const marker) { size_t literal_length; char* result; @@ -582,7 +586,7 @@ /* Strips out ISO/IEC 6429 escape sequences from a string and - returns its new length. +returns its new length. */ __attribute__ ((__nonnull__)) static size_t cheat_strip(char* const variable) { @@ -625,11 +629,12 @@ /* Builds a formatted string or - fails safely in case the amount of conversion specifiers in - the format string does not match the expected count. +fails safely in case the amount of conversion specifiers in +the format string does not match the expected count. */ __attribute__ ((__format__ (__printf__, 1, 4), __nonnull__ (1))) -static int cheat_print_string(char* const destination, char const* const format, +static int cheat_print_string(char* const destination, + char const* const format, size_t const count, ...) { va_list list; int result; @@ -645,11 +650,12 @@ /* Prints a formatted string or - fails safely in case the amount of conversion specifiers in - the format string does not match the expected count. +fails safely in case the amount of conversion specifiers in +the format string does not match the expected count. */ __attribute__ ((__format__ (__printf__, 2, 4), __io__, __nonnull__ (1))) -static int cheat_print(FILE* const stream, char const* const format, +static int cheat_print(FILE* const stream, + char const* const format, size_t const count, ...) { va_list list; int result; @@ -666,7 +672,7 @@ /* This procedure does not have __attribute__ ((__io__)) - even though it uses cheat_death(), because it is reserved for failures. +even though it uses cheat_death(), because it is reserved for failures. */ /* Converts an outcome into an exit status. @@ -719,7 +725,7 @@ /* Finds a test or a utility procedure by its name and returns a pointer to it or - returns NULL in case of a failure. +returns NULL in case of a failure. */ __attribute__ ((__nonnull__, __pure__, __warn_unused_result__)) static struct cheat_unit const* cheat_find(struct cheat_unit const* const units, @@ -743,8 +749,7 @@ Initializes an undefined array of strings. */ __attribute__ ((__nonnull__)) -static void cheat_initialize_string_array( - struct cheat_string_array* const array) { +static void cheat_initialize_string_array(struct cheat_string_array* const array) { array->count = 0; array->elements = NULL; } @@ -763,8 +768,7 @@ Initializes an undefined list of character arrays. */ __attribute__ ((__nonnull__)) -static void cheat_initialize_list( - struct cheat_character_array_list* const list) { +static void cheat_initialize_list(struct cheat_character_array_list* const list) { list->count = 0; list->capacity = 0; list->items = NULL; @@ -774,8 +778,7 @@ Initializes undefined statistics. */ __attribute__ ((__nonnull__)) -static void cheat_initialize_statistics( - struct cheat_statistics* const statistics) { +static void cheat_initialize_statistics(struct cheat_statistics* const statistics) { statistics->run = 0; statistics->successful = 0; statistics->failed = 0; @@ -853,7 +856,7 @@ /* Adds a string to the end of a list or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__ (1))) static void cheat_append_string_list(struct cheat_string_list* const list, @@ -887,11 +890,12 @@ /* Copies a message form a character array to the end of a list or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__ (1))) static void cheat_append_list(struct cheat_character_array_list* const list, - char const* const buffer, size_t const size) { + char const* const buffer, + size_t const size) { size_t count; char* elements; @@ -910,8 +914,7 @@ if (capacity == list->capacity) cheat_death("item capacity exceeded", list->capacity); - items = CHEAT_CAST(struct cheat_character_array*, - cheat_reallocate_array(list->items, + items = CHEAT_CAST(struct cheat_character_array*, cheat_reallocate_array(list->items, capacity, sizeof *list->items)); if (items == NULL) cheat_death("failed to allocate more memory", errno); @@ -941,7 +944,7 @@ /* Checks whether a stream should be hidden or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__ (1), __unused__, __warn_unused_result__)) static bool cheat_hide(struct cheat_suite const* const suite, @@ -958,8 +961,16 @@ } /* +Here goes: + +cheat_limit_output(size_t) +cheat_purge_output(void) +cheat_scan_output(bool (*)(char const*, size_t)) +*/ + +/* Adds the outcome of a single test to a test suite or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__)) static void cheat_handle_outcome(struct cheat_suite* const suite) { @@ -986,7 +997,7 @@ /* Registers a signal handler or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__)) static void cheat_register_handler(cheat_handler const handler) { @@ -1004,7 +1015,7 @@ /* Stops a test or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__nonnull__)) static void cheat_exit(struct cheat_suite* const suite, @@ -1024,23 +1035,21 @@ /* Prints the contents of a list or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) -static void cheat_print_list( - struct cheat_character_array_list const* const list) { +static void cheat_print_list(struct cheat_character_array_list const* const list) { size_t index; for (index = 0; index < list->count; ++index) - (void )fwrite(list->items[index].elements, - 1, list->items[index].size, stdout); + (void )fwrite(list->items[index].elements, 1, list->items[index].size, stdout); } /* Prints a summary of the usage or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_usage(struct cheat_suite const* const suite) { @@ -1128,7 +1137,8 @@ if (print_labels) (void )fputs("Usage: ", stdout); - (void )cheat_print(stdout, usage_format, 1, suite->program); + (void )cheat_print(stdout, usage_format, 1, + suite->program); (void )fputc('\n', stdout); } @@ -1155,7 +1165,7 @@ /* Prints a list of the tests or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_tests(struct cheat_suite const* const suite) { @@ -1197,7 +1207,8 @@ } else (void )fputs(" ", stdout); } - (void )cheat_print(stdout, name_format, 1, suite->units[index].name); + (void )cheat_print(stdout, name_format, 1, + suite->units[index].name); if (print_subtypes) switch (suite->units[index].subtype) { case CHEAT_IGNORED_TEST: @@ -1216,17 +1227,17 @@ /* Prints the version number string or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__)) static void cheat_print_version(void) { - (void )fputs("CHEAT 1.0.0", stdout); /* This is always boring. */ + (void )fputs("CHEAT 1.0.3", stdout); /* This is always boring. */ (void )fputc('\n', stdout); } /* Prints the outcome of a single test or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_outcome(struct cheat_suite const* const suite) { @@ -1297,7 +1308,7 @@ /* Prints a separator or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_separator(struct cheat_suite const* const suite) { @@ -1334,7 +1345,7 @@ /* Prints a summary of tests or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_summary(struct cheat_suite const* const suite) { @@ -1447,8 +1458,8 @@ if (strip) cheat_strip(successful_format); - (void )cheat_print(stdout, successful_format, - 1, (CHEAT_SIZE_TYPE )suite->tests.successful); + (void )cheat_print(stdout, successful_format, 1, + (CHEAT_SIZE_TYPE )suite->tests.successful); } if (regular || (any_successes && any_failures)) { if (strip) @@ -1460,8 +1471,8 @@ if (strip) cheat_strip(failed_format); - (void )cheat_print(stdout, failed_format, - 1, (CHEAT_SIZE_TYPE )suite->tests.failed); + (void )cheat_print(stdout, failed_format, 1, + (CHEAT_SIZE_TYPE )suite->tests.failed); } if (regular || (any_successes || any_failures)) { if (strip) @@ -1472,8 +1483,8 @@ if (strip) cheat_strip(run_format); - (void )cheat_print(stdout, run_format, - 1, (CHEAT_SIZE_TYPE )suite->tests.run); + (void )cheat_print(stdout, run_format, 1, + (CHEAT_SIZE_TYPE )suite->tests.run); (void )fputc('\n', stdout); } if (print_conclusion) { @@ -1494,12 +1505,13 @@ /* Prints an error message or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_print_failure(struct cheat_suite* const suite, char const* const expression, - char const* const file, size_t const line) { + char const* const file, + size_t const line) { bool strip = false; bool print_assertion = false; char assertion_format[] = CHEAT_BOLD "%s:" @@ -1543,8 +1555,8 @@ if (buffer == NULL) cheat_death("failed to allocate memory", errno); - if (cheat_print_string(buffer, assertion_format, - 4, file, (CHEAT_SIZE_TYPE )line, + if (cheat_print_string(buffer, assertion_format, 4, + file, (CHEAT_SIZE_TYPE )line, suite->test_name, truncation) < 0) cheat_death("failed to build a string", errno); cheat_append_list(&suite->messages, buffer, strlen(buffer)); @@ -1552,8 +1564,9 @@ free(buffer); break; case CHEAT_SAFE: - (void )cheat_print(suite->message_stream, assertion_format, - 4, file, line, suite->test_name, truncation); + (void )cheat_print(suite->message_stream, assertion_format, 4, + file, line, + suite->test_name, truncation); (void )fflush(suite->message_stream); /* This prevents crashing from absorbing messages. */ break; @@ -1567,7 +1580,7 @@ /* Figures out whether further checks should be carried out or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__warn_unused_result__)) static bool cheat_further(enum cheat_outcome const outcome) { @@ -1588,12 +1601,14 @@ /* Checks a single assertion and prints an error message if it fails or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_check(struct cheat_suite* const suite, - bool const result, char const* const expression, - char const* const file, size_t const line) { + bool const result, + char const* const expression, + char const* const file, + size_t const line) { if (cheat_further(suite->outcome) && !result) { suite->outcome = CHEAT_FAILED; @@ -1603,7 +1618,7 @@ /* Runs all utility procedures of a certain type or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__)) static void cheat_run_utilities(struct cheat_suite* const suite, @@ -1620,7 +1635,7 @@ /* Runs a test procedure or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_test(struct cheat_unit const* const unit) { @@ -1632,7 +1647,7 @@ /* Runs a test from a test suite or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_coupled_test(struct cheat_suite* const suite, @@ -1652,7 +1667,7 @@ /* Creates a subprocess and runs a test in it or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_isolate_test(struct cheat_suite* const suite, @@ -1706,9 +1721,20 @@ cheat_run_coupled_test(suite, test); - fflush(suite->message_stream); /* This is very important, because - streams opened from file descriptors are not flushed when - the file descriptors are closed. */ + /* + These are very important, because + streams opened from file descriptors are not flushed when + the file descriptors are closed. + */ + + if (fflush(suite->message_stream) == EOF) + cheat_death("failed to flush the message stream", errno); + + if (fflush(stdout) == EOF) + cheat_death("failed to flush the standard output stream", errno); + + if (fflush(stderr) == EOF) + cheat_death("failed to flush the standard error stream", errno); for (index = 0; index < channel_count; @@ -1748,7 +1774,7 @@ struct timeval time; time.tv_sec = CHEAT_TIME / 1000; - time.tv_usec = CHEAT_TIME % 1000; + time.tv_usec = (CHEAT_TIME % 1000) * 1000; result = select(maximum + 1, &set, NULL, NULL, &time); } else @@ -1791,7 +1817,7 @@ /* Both kill() and waitpid() can fail if - the child process exits or crashes after select() has returned. + the child process exits or crashes after select() has returned. */ if (due) { if (kill(pid, SIGKILL) == -1) @@ -1830,7 +1856,7 @@ /* The memory of these structures is zeroed to - avoid compatibility issues if their fields change. + avoid compatibility issues if their fields change. */ ZeroMemory(&security, sizeof security); ZeroMemory(&startup, sizeof startup); @@ -1864,7 +1890,8 @@ name_length = strlen(test->name); command = cheat_allocate_total(4, - command_length, option_length, name_length, (size_t )3); + command_length, option_length, + name_length, (size_t )3); if (command == NULL) cheat_death("failed to allocate memory", errno); @@ -1886,13 +1913,14 @@ free(command); /* - name = CHEAT_CAST(LPTSTR, cheat_allocate_total(3, strlen(CHEAT_PIPE), - CHEAT_INTEGER_LENGTH(process.dwProcessId), (size_t )1)); + name = CHEAT_CAST(LPTSTR, cheat_allocate_total(3, + strlen(CHEAT_PIPE), CHEAT_INTEGER_LENGTH(process.dwProcessId), + (size_t )1)); if (name == NULL) cheat_death("failed to allocate memory", errno); - if (cheat_print_string(name, "%s%d", - 2, CHEAT_PIPE, process.dwProcessId) < 0) + if (cheat_print_string(name, "%s%d", 2, + CHEAT_PIPE, process.dwProcessId) < 0) cheat_death("failed to build a string", errno); message_pipe = CreateNamedPipe(name, @@ -1975,7 +2003,7 @@ /* Runs a single test and exits or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_hidden(struct cheat_suite* const suite, @@ -1992,11 +2020,13 @@ pid = GetCurrentProcessId(); pipe = CHEAT_CAST(LPTSTR, cheat_allocate_total(3, - strlen(CHEAT_PIPE), CHEAT_INTEGER_LENGTH(pid), (size_t )1)); + strlen(CHEAT_PIPE), CHEAT_INTEGER_LENGTH(pid), + (size_t )1)); if (pipe == NULL) cheat_death("failed to allocate memory", errno); - if (cheat_print_string(pipe, "%s%d", 2, CHEAT_PIPE, pid) < 0) + if (cheat_print_string(pipe, "%s%d", 2, + CHEAT_PIPE, pid) < 0) cheat_death("failed to build a string", errno); if (!WaitNamedPipe(pipe, CHEAT_TIME)) @@ -2017,7 +2047,7 @@ /* Runs a single test from a test suite and prints its outcome or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_specific(struct cheat_suite* const suite, @@ -2029,6 +2059,10 @@ cheat_isolate_test(suite, unit); break; case CHEAT_DANGEROUS: + if (suite->harness == CHEAT_DANGEROUS) + cheat_register_handler(suite->handler); /* This is here, because + signal handlers may be cleared after each use. */ + status = setjmp(suite->environment); if (status == 0) cheat_run_coupled_test(suite, unit); @@ -2049,7 +2083,7 @@ /* Runs every test from a test suite and prints their outcomes or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_all(struct cheat_suite* const suite) { @@ -2064,7 +2098,7 @@ /* Runs some tests from a test suite and prints their outcomes or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_some(struct cheat_suite* const suite, @@ -2086,14 +2120,11 @@ /* Runs a test suite and prints a summary or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_run_suite(struct cheat_suite* const suite, struct cheat_string_list const* const names) { - if (suite->harness == CHEAT_DANGEROUS) - cheat_register_handler(suite->handler); - suite->force = names->count != 0; if (suite->force) @@ -2106,7 +2137,7 @@ /* Parses the arguments of a test suite and delegates work or - terminates the program in case of a failure. +terminates the program in case of a failure. */ __attribute__ ((__io__, __nonnull__)) static void cheat_parse(struct cheat_suite* const suite) { @@ -2260,7 +2291,7 @@ /* Prepares the environment for running tests or - terminates the program in case of a failure. +terminates the program in case of a failure. */ static void cheat_prepare(void) { @@ -2270,8 +2301,8 @@ /* This ridiculous shuffling prevents - the executable "has encountered a problem and needs to close" dialog from - popping up and making the test suite wait for user interaction. + the executable "has encountered a problem and needs to close" dialog from + popping up and making the test suite wait for user interaction. */ mode = SetErrorMode(SEM_NOGPFAULTERRORBOX); SetErrorMode(mode | SEM_NOGPFAULTERRORBOX); @@ -2281,8 +2312,8 @@ /* Interruptions are unnecessary since - processes wait for each other and - the return values read() and write() are always checked. + processes wait for each other and + the return values read() and write() are always checked. */ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) cheat_death("failed to add a handler for SIGPIPE", errno); @@ -2294,8 +2325,8 @@ /* This global test suite contains a pointer to the test units instead of - encompassing the units themselves, because - their size is not known when the type of the suite defined. +encompassing the units themselves, because +their size is not known when the type of the suite defined. */ static struct cheat_suite cheat_suite; @@ -2330,9 +2361,9 @@ #endif /* -These are automatically generated with the command - tcc -run meta.c 127 - or equivalent. +These are automatically generated with +$ tcc -run meta.c 127 +or equivalent. */ #define CHEAT_COMMAS_1(x1, x2) x1, x2 #define CHEAT_COMMAS_2(x1, x2, x3) x1, x2, x3 @@ -2478,7 +2509,7 @@ (CHEAT_GET(name)()) /* -This pass declare the prototypes of test and utility procedures. +This pass declares the prototypes of test and utility procedures. */ #define CHEAT_PASS 1 /* This is informational. */ @@ -2710,7 +2741,7 @@ #define CHEAT_REPEAT(name, ...) \ static void CHEAT_GET(name)(void) { \ size_t cheat_index; \ -\ + \ cheat_suite.test_name = #name; \ cheat_suite.outcome = CHEAT_SUCCESSFUL; \ for (cheat_index = 0; \ @@ -2769,7 +2800,7 @@ #define CHEAT_REPEAT(name, body) \ static void CHEAT_GET(name)(void) { \ size_t cheat_index; \ -\ + \ cheat_suite.test_name = #name; \ cheat_suite.outcome = CHEAT_SUCCESSFUL; \ for (cheat_index = 0; \ @@ -2797,12 +2828,12 @@ /* The third pass continues past the end of this file, but - the definitions for it end here. +the definitions for it end here. */ /* Suppresses a signal and - returns to a recovery point. +returns to a recovery point. */ __attribute__ ((__noreturn__)) static void cheat_handle_signal(int const number) { @@ -2818,10 +2849,11 @@ /* Runs tests from the main test suite and - returns EXIT_SUCCESS in case all tests passed or - EXIT_FAILURE in case of a failure. +returns EXIT_SUCCESS in case all tests passed or +EXIT_FAILURE in case of a failure. */ -int main(int const count, char** const arguments) { +int main(int const count, + char** const arguments) { cheat_prepare(); cheat_initialize(&cheat_suite); @@ -2855,9 +2887,9 @@ /* These are a "best effort" attempt to manage process termination - and stream capturing without process isolation. +and stream capturing without process isolation. Some libraries and system calls can still exit or print things, but - that is a problem for the user to solve. +that is a problem for the user to solve. */ #ifndef CHEAT_NO_WRAP @@ -2921,7 +2953,8 @@ #ifdef CHEAT_MODERN __attribute__ ((__unused__)) -static size_t cheat_printed_length(char const* const format, va_list list) { +static size_t cheat_printed_length(char const* const format, + va_list list) { va_list another_list; va_copy(another_list, list); /* This is a big compatibility bottleneck. */ @@ -2933,13 +2966,15 @@ __attribute__ ((__unused__)) static int CHEAT_UNWRAP(vfprintf)(FILE* const stream, - char const* const format, va_list list) { + char const* const format, + va_list list) { return vfprintf(stream, format, list); } __attribute__ ((__unused__)) static int CHEAT_WRAP(vfprintf)(FILE* const stream, - char const* const format, va_list list) { + char const* const format, + va_list list) { if (cheat_hide(&cheat_suite, stream)) { #ifdef CHEAT_MODERN @@ -2980,12 +3015,14 @@ #define vfprintf CHEAT_WRAP(vfprintf) __attribute__ ((__unused__)) -static int CHEAT_UNWRAP(vprintf)(char const* const format, va_list list) { +static int CHEAT_UNWRAP(vprintf)(char const* const format, + va_list list) { return vprintf(format, list); } __attribute__ ((__unused__)) -static int CHEAT_WRAP(vprintf)(char const* const format, va_list list) { +static int CHEAT_WRAP(vprintf)(char const* const format, + va_list list) { return CHEAT_WRAP(vfprintf)(stdout, format, list); } @@ -3042,12 +3079,14 @@ #define printf CHEAT_WRAP(printf) __attribute__ ((__unused__)) -static int CHEAT_UNWRAP(fputs)(char const* const message, FILE* const stream) { +static int CHEAT_UNWRAP(fputs)(char const* const message, + FILE* const stream) { return fputs(message, stream); } __attribute__ ((__unused__)) -static int CHEAT_WRAP(fputs)(char const* const message, FILE* const stream) { +static int CHEAT_WRAP(fputs)(char const* const message, + FILE* const stream) { int result; result = CHEAT_WRAP(fprintf)(stream, "%s", message); @@ -3061,12 +3100,14 @@ #define fputs CHEAT_WRAP(fputs) __attribute__ ((__unused__)) -static int CHEAT_UNWRAP(fputc)(int const character, FILE* const stream) { +static int CHEAT_UNWRAP(fputc)(int const character, + FILE* const stream) { return fputc(character, stream); } __attribute__ ((__unused__)) -static int CHEAT_WRAP(fputc)(int const character, FILE* const stream) { +static int CHEAT_WRAP(fputc)(int const character, + FILE* const stream) { int result; result = CHEAT_WRAP(fprintf)(stream, "%c", character); @@ -3087,12 +3128,14 @@ #endif __attribute__ ((__unused__)) -static int CHEAT_UNWRAP(putc)(int const character, FILE* const stream) { +static int CHEAT_UNWRAP(putc)(int const character, + FILE* const stream) { return putc(character, stream); } __attribute__ ((__unused__)) -static int CHEAT_WRAP(putc)(int const character, FILE* const stream) { +static int CHEAT_WRAP(putc)(int const character, + FILE* const stream) { return CHEAT_WRAP(fputc)(character, stream); } @@ -3132,13 +3175,17 @@ __attribute__ ((__unused__)) static size_t CHEAT_UNWRAP(fwrite)(void const* const buffer, - size_t const size, size_t const count, FILE* const stream) { + size_t const size, + size_t const count, + FILE* const stream) { return fwrite(buffer, size, count, stream); } __attribute__ ((__unused__)) static size_t CHEAT_WRAP(fwrite)(void const* const buffer, - size_t const size, size_t const count, FILE* const stream) { + size_t const size, + size_t const count, + FILE* const stream) { if (cheat_hide(&cheat_suite, stream)) { #ifdef CHEAT_MODERN @@ -3210,13 +3257,15 @@ __attribute__ ((__unused__)) static ssize_t CHEAT_UNWRAP(write)(int const fd, - void const* const buffer, size_t const size) { + void const* const buffer, + size_t const size) { return write(fd, buffer, size); } __attribute__ ((__unused__)) static ssize_t CHEAT_WRAP(write)(int const fd, - void const* const buffer, size_t const size) { + void const* const buffer, + size_t const size) { FILE* stream; stream = fdopen(fd, "w");
View file
_service:download_files:v0.4.2.tar.gz/cmake/nordlicht.pc.in -> _service:download_files:v0.4.4.tar.gz/cmake/nordlicht.pc.in
Changed
@@ -2,7 +2,10 @@ includedir=@CMAKE_INSTALL_PREFIX@/include Name: nordlicht +Version: @NORDLICHT_VERSION@ Description: A library that creates video barcodes Requires: +Requires.private: libavutil libavformat libavcodec libswscale Libs: -L${libdir} -lnordlicht +Libs.private: -lm Cflags: -I${includedir}
View file
_service:download_files:v0.4.2.tar.gz/main.c -> _service:download_files:v0.4.4.tar.gz/main.c
Changed
@@ -8,6 +8,25 @@ #include "nordlicht.h" #include "version.h" +#ifdef _WIN32 +// from http://stackoverflow.com/a/8514474/248734 +char* strsep(char** stringp, const char* delim) { + char* start = *stringp; + char* p; + + p = (start != NULL) ? strpbrk(start, delim) : NULL; + + if (p == NULL) { + *stringp = NULL; + } else { + *p = '\0'; + *stringp = p + 1; + } + + return start; +} +#endif + typedef struct { const char *name; const char *description; @@ -20,7 +39,7 @@ {"slitscan", "take single columns while constantly moving to the right (and wrapping back to the left)", NORDLICHT_STYLE_SLITSCAN}, {"middlecolumn", "take the middlemost column of each frame", NORDLICHT_STYLE_MIDDLECOLUMN}, {"thumbnails", "display small thumbnails at regular intervals", NORDLICHT_STYLE_THUMBNAILS}, - {"spectrogram", "calculate a spectrogram of the first audio track", NORDLICHT_STYLE_SPECTROGRAM}, + {"spectrogram", "spectrogram of the first audio track (not all sample formats are supported yet)", NORDLICHT_STYLE_SPECTROGRAM}, {NULL, NULL, NORDLICHT_STYLE_LAST} }; @@ -33,11 +52,6 @@ fprintf(stderr, "\n"); } -const char *gnu_basename(const char *path) { - const char *base = strrchr(path, '/'); - return base ? base+1 : path; -} - const char *filename_ext(const char *path) { const char *dot = strrchr(path, '.'); if (!dot || dot == path) return ""; @@ -77,9 +91,9 @@ int version = 0; const struct poptOption optionsTable[] = { - {"width", 'w', POPT_ARG_INT, &width, 0, "set the barcode's width; by default it's \"height*10\", or 1000 pixels, if both are undefined", NULL}, + {"width", 'w', POPT_ARG_INT, &width, 0, "set the barcode's width; by default it's \"height*10\", or 1920 pixels, if both are undefined", NULL}, {"height", 'h', POPT_ARG_INT, &height, 0, "set the barcode's height; by default it's \"width/10\"", NULL}, - {"output", 'o', POPT_ARG_STRING, &output_file, 0, "set output filename, the default is $(basename VIDEOFILE).png; when you specify an *.bgra file, you'll get a raw 32-bit BGRA file that is updated as the barcode is generated", "FILENAME"}, + {"output", 'o', POPT_ARG_STRING, &output_file, 0, "set output filename, the default is VIDEOFILE.png; when you specify an *.bgra file, you'll get a raw 32-bit BGRA file that is updated as the barcode is generated", "FILENAME"}, {"style", 's', POPT_ARG_STRING, &styles_string, 0, "default is 'horizontal', see \"Styles\" section below. You can specify more than one style, separated by '+', to get multiple tracks", "STYLE"}, {"start", '\0', POPT_ARG_FLOAT, &start, 0, "specify where to start the barcode (in percent between 0 and 1)", NULL}, {"end", '\0', POPT_ARG_FLOAT, &end, 0, "specify where to end the barcode (in percent between 0 and 1)", NULL}, @@ -124,8 +138,9 @@ } if (output_file == NULL) { - output_file = (char *) malloc(snprintf(NULL, 0, "%s.png", gnu_basename(filename)) + 1); - sprintf(output_file, "%s.png", gnu_basename(filename)); + size_t len = snprintf(NULL, 0, "%s.nordlicht.png", filename) + 1; + output_file = (char *) malloc(len); + snprintf(output_file, len, "%s.nordlicht.png", filename); free_output_file = 1; } @@ -139,8 +154,8 @@ } } if (height == -1 && width == -1) { - width = 1000; - height = 100; + width = 1920; + height = 192; } if (styles_string == NULL) { @@ -196,7 +211,7 @@ nordlicht_set_start(n, start); nordlicht_set_end(n, end); - nordlicht_set_style(n, styles, num_tracks); + nordlicht_set_styles(n, styles, num_tracks); nordlicht_set_strategy(n, strategy); if (nordlicht_error() != NULL) { @@ -236,7 +251,7 @@ fflush(stdout); while (progress == 0) { progress = nordlicht_progress(n); - usleep(100000); + nanosleep((const struct timespec[]){{0, 100000000L}}, NULL); } printf("done.\n"); @@ -244,7 +259,7 @@ progress = nordlicht_progress(n); printf("\rnordlicht: %02.0f%%", progress*100); fflush(stdout); - usleep(100000); + nanosleep((const struct timespec[]){{0, 100000000L}}, NULL); } }
View file
_service:download_files:v0.4.2.tar.gz/nordlicht.c -> _service:download_files:v0.4.4.tar.gz/nordlicht.c
Changed
@@ -26,11 +26,11 @@ source *source; }; -size_t nordlicht_buffer_size(const nordlicht *n) { +NORDLICHT_API size_t nordlicht_buffer_size(const nordlicht *n) { return n->width * n->height * 4; } -nordlicht* nordlicht_init(const char *filename, const int width, const int height) { +NORDLICHT_API nordlicht* nordlicht_init(const char *filename, const int width, const int height) { if (width < 1 || height < 1) { error("Dimensions must be positive (got %dx%d)", width, height); return NULL; @@ -69,7 +69,7 @@ return n; } -void nordlicht_free(nordlicht *n) { +NORDLICHT_API void nordlicht_free(nordlicht *n) { if (n->owns_data) { free(n->data); } @@ -78,11 +78,11 @@ free(n); } -const char *nordlicht_error() { +NORDLICHT_API const char *nordlicht_error() { return get_error(); } -int nordlicht_set_start(nordlicht *n, const float start) { +NORDLICHT_API int nordlicht_set_start(nordlicht *n, const float start) { if (! n->modifiable) { return -1; } @@ -101,7 +101,7 @@ return 0; } -int nordlicht_set_end(nordlicht *n, const float end) { +NORDLICHT_API int nordlicht_set_end(nordlicht *n, const float end) { if (! n->modifiable) { return -1; } @@ -120,7 +120,16 @@ return 0; } -int nordlicht_set_style(nordlicht *n, const nordlicht_style *styles, const int num_tracks) { +NORDLICHT_API int nordlicht_set_style(nordlicht *n, const nordlicht_style style) { + if (! n->modifiable) { + return -1; + } + + nordlicht_style styles[1] = {style}; + return nordlicht_set_styles(n, styles, 1); +} + +NORDLICHT_API int nordlicht_set_styles(nordlicht *n, const nordlicht_style *styles, const int num_tracks) { if (! n->modifiable) { return -1; } @@ -151,7 +160,7 @@ return 0; } -int nordlicht_set_strategy(nordlicht *n, const nordlicht_strategy s) { +NORDLICHT_API int nordlicht_set_strategy(nordlicht *n, const nordlicht_strategy s) { if (! n->modifiable) { return -1; } @@ -162,7 +171,7 @@ return 0; } -int nordlicht_generate(nordlicht *n) { +NORDLICHT_API int nordlicht_generate(nordlicht *n) { n->modifiable = 0; source_build_keyframe_index(n->source, n->width); @@ -254,7 +263,7 @@ return 0; } -int nordlicht_write(const nordlicht *n, const char *filename) { +NORDLICHT_API int nordlicht_write(const nordlicht *n, const char *filename) { int code = 0; if (filename == NULL) { @@ -296,15 +305,15 @@ return code; } -float nordlicht_progress(const nordlicht *n) { +NORDLICHT_API float nordlicht_progress(const nordlicht *n) { return n->progress; } -const unsigned char* nordlicht_buffer(const nordlicht *n) { +NORDLICHT_API const unsigned char* nordlicht_buffer(const nordlicht *n) { return n->data; } -int nordlicht_set_buffer(nordlicht *n, unsigned char *data) { +NORDLICHT_API int nordlicht_set_buffer(nordlicht *n, unsigned char *data) { if (! n->modifiable) { return -1; }
View file
_service:download_files:v0.4.2.tar.gz/nordlicht.h -> _service:download_files:v0.4.4.tar.gz/nordlicht.h
Changed
@@ -2,6 +2,29 @@ #define INCLUDE_nordlicht_h__ #include <stdlib.h> // for size_t + +#ifndef NORDLICHT_API +# ifdef _WIN32 +# if defined(NORDLICHT_BUILD_SHARED) /* build dll */ +# define NORDLICHT_API __declspec(dllexport) +# elif !defined(NORDLICHT_BUILD_STATIC) /* use dll */ +# define NORDLICHT_API __declspec(dllimport) +# else /* static library */ +# define NORDLICHT_API +# endif +# else +# if __GNUC__ >= 4 +# define NORDLICHT_API __attribute__((visibility("default"))) +# else +# define NORDLICHT_API +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + typedef struct nordlicht nordlicht; typedef enum nordlicht_style { @@ -10,7 +33,7 @@ NORDLICHT_STYLE_VERTICAL, // compress frames to rows, "move downwards" NORDLICHT_STYLE_SLITSCAN, // take single columns, while moving to the right (and wrapping to the left) NORDLICHT_STYLE_MIDDLECOLUMN, // take the frames' middlemost column - NORDLICHT_STYLE_SPECTROGRAM, + NORDLICHT_STYLE_SPECTROGRAM, // spectrogram of the first audio track (not all sample formats are supported yet) NORDLICHT_STYLE_LAST } nordlicht_style; @@ -20,50 +43,59 @@ } nordlicht_strategy; // Returns a description of the last error, or NULL if the was no error. -const char *nordlicht_error(); +NORDLICHT_API const char *nordlicht_error(); // Allocate a new nordlicht of specific width and height, for a given video // file. When `live` is true, give a fast approximation before starting the // slow, exact generation. Use `nordlicht_free` to free the nordlicht again. // Returns NULL on errors. -nordlicht* nordlicht_init(const char *filename, const int width, const int height); +NORDLICHT_API nordlicht* nordlicht_init(const char *filename, const int width, const int height); // Free a nordlicht. -void nordlicht_free(nordlicht *n); +NORDLICHT_API void nordlicht_free(nordlicht *n); // Specify where to start the nordlicht, in percent between 0 and 1. -int nordlicht_set_start(nordlicht *n, const float start); +NORDLICHT_API int nordlicht_set_start(nordlicht *n, const float start); // Specify where to end the nordlicht, in percent between 0 and 1. -int nordlicht_set_end(nordlicht *n, const float end); +NORDLICHT_API int nordlicht_set_end(nordlicht *n, const float end); // Set the output style of the nordlicht. Default is NORDLICHT_STYLE_HORIZONTAL. +// Returns 0 on success. To set multiple styles at once, use `nordlicht_set_styles`. +NORDLICHT_API int nordlicht_set_style(nordlicht *n, const nordlicht_style style); + +// Set multiple output styles, which will be displayed on top of each other. +// Expects a pointer to an array of nordlicht_style-s of length `num_styles`. // Returns 0 on success. -int nordlicht_set_style(nordlicht *n, const nordlicht_style *s, const int num_styles); +NORDLICHT_API int nordlicht_set_styles(nordlicht *n, const nordlicht_style *styles, const int num_styles); // Set the generation strategy of the nordlicht. Default is NORDLICHT_STRATEGY_FAST. // Returns 0 on success. This function will be removed in the future. -int nordlicht_set_strategy(nordlicht *n, const nordlicht_strategy s); +NORDLICHT_API int nordlicht_set_strategy(nordlicht *n, const nordlicht_strategy strategy); // Returns a pointer to the nordlicht's internal buffer. You can use it to draw // the barcode while it is generated. The pixel format is 32-bit BGRA. -const unsigned char* nordlicht_buffer(const nordlicht *n); +NORDLICHT_API const unsigned char* nordlicht_buffer(const nordlicht *n); // Replace the internal nordlicht's internal buffer. The data pointer is owned // by the caller and must be freed after `nordlicht_free`. Returns 0 on success. -int nordlicht_set_buffer(nordlicht *n, unsigned char *data); +NORDLICHT_API int nordlicht_set_buffer(nordlicht *n, unsigned char *data); // Returns the size of this nordlicht's buffer in bytes. -size_t nordlicht_buffer_size(const nordlicht *n); +NORDLICHT_API size_t nordlicht_buffer_size(const nordlicht *n); // Generate the nordlicht. Calling this will freeze the nordlicht: // "set" functions will fail. Returns 0 on success. -int nordlicht_generate(nordlicht *n); +NORDLICHT_API int nordlicht_generate(nordlicht *n); // Returns a value between 0 and 1 indicating how much of the nordlicht is done. -float nordlicht_progress(const nordlicht *n); +NORDLICHT_API float nordlicht_progress(const nordlicht *n); // Write the nordlicht to a PNG file. Returns 0 on success. -int nordlicht_write(const nordlicht *n, const char *filename); +NORDLICHT_API int nordlicht_write(const nordlicht *n, const char *filename); + +#ifdef __cplusplus +} +#endif #endif
View file
_service:download_files:v0.4.2.tar.gz/source.c -> _service:download_files:v0.4.4.tar.gz/source.c
Changed
@@ -76,6 +76,11 @@ } if (got_frame) { + if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { + if (st->frame->data[0] == 0) { + return 1; + } + } pts = packet_pts(st, &s->packet); valid = 1; } @@ -93,10 +98,10 @@ return 0; } -void seek_keyframe(source *s, stream *st, const long frame) { +int seek_keyframe(source *s, stream *st, const long frame) { av_seek_frame(s->format, st->stream, frame/st->fps/st->time_base, AVSEEK_FLAG_BACKWARD); avcodec_flush_buffers(st->codec); - grab_next_frame(s, st); + return grab_next_frame(s, st) != 0; } int total_number_of_frames(const source *s, stream *st) { @@ -282,7 +287,9 @@ long keyframe = preceding_keyframe(s, max_frame_nr); if (keyframe > st->current_frame) { - seek_keyframe(s, st, keyframe); + if (seek_keyframe(s, st, keyframe) != 0) { + return 1; + } } while (st->current_frame < min_frame_nr) { @@ -294,7 +301,9 @@ } } } else { - seek_keyframe(s, st, (min_frame_nr+max_frame_nr)/2); + if (seek_keyframe(s, st, (min_frame_nr+max_frame_nr)/2) != 0) { + return 1; + } } return 0; } @@ -362,13 +371,12 @@ data = (float *) malloc(sizeof(float)*SAMPLES_PER_FRAME); for (i = 0; i < SAMPLES_PER_FRAME; i++) { float val = ((int16_t *) s->audio->frame->data[0])[i]/100000.0; - //printf("%f\n", val); data[i] = val; } break; default: - error("Unsupported audio format (%d)", st->codec->sample_fmt); + error("Unsupported sample format (%d), see https://github.com/nordlicht/nordlicht/issues/26", st->codec->sample_fmt); return NULL; }
View file
_service:download_files:v0.4.2.tar.gz/testsuite.c -> _service:download_files:v0.4.4.tar.gz/testsuite.c
Changed
@@ -1,6 +1,12 @@ #include "cheat.h" #include "nordlicht.h" +#ifdef _WIN32 +#include <io.h> +#define F_OK 0 +#define access _access +#endif + #define cheat_null(x) cheat_assert(NULL == (x)) #define cheat_not_null(x) cheat_assert(NULL != (x)) #define cheat_fail(x) cheat_assert(0 != (x)) @@ -36,7 +42,7 @@ cheat_null(nordlicht_init("\0", 100, 100)); cheat_null(nordlicht_init(".", 100, 100)); cheat_null(nordlicht_init("..", 100, 100)); - cheat_null(nordlicht_init("nonexistant_file.123", 100, 100)); + cheat_null(nordlicht_init("nonexistent_file.123", 100, 100)); ) CHEAT_TEST(invalid_size, @@ -70,12 +76,22 @@ CHEAT_TEST(style, n = nordlicht_init("video.mp4", 1, 100); cheat_not_null(n); - nordlicht_style styles[1] = {NORDLICHT_STYLE_HORIZONTAL}; - cheat_ok(nordlicht_set_style(n, styles, 1)); - styles[0] = NORDLICHT_STYLE_VERTICAL; - cheat_ok(nordlicht_set_style(n, styles, 1)); + cheat_ok(nordlicht_set_style(n, NORDLICHT_STYLE_HORIZONTAL)); + cheat_ok(nordlicht_set_style(n, NORDLICHT_STYLE_VERTICAL)); + cheat_fail(nordlicht_set_style(n, 10000000)); +) + +CHEAT_TEST(styles, + n = nordlicht_init("video.mp4", 1, 100); + cheat_not_null(n); + nordlicht_style styles[2]; + styles[0] = NORDLICHT_STYLE_HORIZONTAL; + styles[1] = NORDLICHT_STYLE_VERTICAL; + cheat_ok(nordlicht_set_styles(n, styles, 2)); + styles[0] = NORDLICHT_STYLE_THUMBNAILS; + cheat_ok(nordlicht_set_styles(n, styles, 2)); styles[0] = 10000000; - cheat_fail(nordlicht_set_style(n, styles, 1)); + cheat_fail(nordlicht_set_styles(n, styles, 2)); ) CHEAT_TEST(strategy, @@ -144,6 +160,8 @@ ) CHEAT_TEST(tool_output, + cheat_ok(tool("video.mp4 -w 1")); + cheat_assert(-1 != access("video.mp4.nordlicht.png", F_OK)); cheat_ok(tool("video.mp4 -w 1 -o ünîç⌀də.png")); cheat_assert(-1 != access("ünîç⌀də.png", F_OK)); cheat_fail(tool("video.mp4 -o video.mp4"));
View file
_service:download_files:v0.4.2.tar.gz/utils/mpv-nordlicht.lua -> _service:download_files:v0.4.4.tar.gz/utils/mpv-nordlicht.lua
Changed
@@ -1,36 +1,25 @@ -- nordlicht integration for mpv. You need mpv >= 0.3.6 to correctly support -- lua scripting. -function init() - is_on = false - mode = 1 -- 1: single, 2: double - -- size of the display: - screen_width = mp.get_property("osd-width") - - -- size of the barcode: - width = mp.get_property("osd-width") - height = math.floor(width/20) - width2 = width*5 - height2 = math.floor(width2/50) +utils = require "mp.utils" - -- size of the progress marker: - mh = math.floor(height/15)*2+1 - mw = mh*2-1 - - -- styles: +function init() styles = os.getenv("NORDLICHT_STYLE") or "horizontal" - mp.register_event("start-file", new_file) + mp.register_event("file-loaded", new_file) mp.register_event("shutdown", shutdown) + mp.register_event("seek", seek) mp.add_key_binding("n", "nordlicht-toggle", toggle) + mp.add_key_binding("N", "nordlicht-regenerate", regenerate) + mp.add_key_binding("mouse_btn0", "jump", jump) - -- yeah, I know. But it's flexible :-P - os.execute("convert -depth 8 -size "..mw.."x"..mh.." xc:none -fill white -stroke black -strokewidth 0.5 +antialias -draw \"path 'M "..((mw-1)/2)..",0 L "..(mw-1)..","..(mh-1).." L 0,"..(mh-1).." Z'\" bgra:/tmp/arrow_up.bgra") - os.execute("convert -depth 8 -size "..mw.."x"..mh.." bgra:/tmp/arrow_up.bgra -flip bgra:/tmp/arrow_down.bgra") + -- size of the progress marker + mh = 10 + mw = mh*2-1 - new_file() - -- wait for the convert commands to finish - mp.add_timeout(0.5, on) + -- yeah, I know. But it's flexible :-P + utils.subprocess({args={"convert", "-depth", "8", "-size", mw.."x"..mh, "xc:none", "-fill", "white", "-stroke", "black", "-strokewidth", "0.5", "+antialias", "-draw", "path 'M"..((mw-1)/2)..",0L"..(mw-1)..","..(mh-1).."L0,"..(mh-1).."Z'", "bgra:/tmp/arrow_up.bgra"}}) + utils.subprocess({args={"convert", "-depth", "8", "-size", mw.."x"..mh, "bgra:/tmp/arrow_up.bgra", "-flip", "bgra:/tmp/arrow_down.bgra"}}) end function shutdown() @@ -44,44 +33,46 @@ function new_file() local was_on = is_on - if was_on then - off() - end + shutdown() - kill() + -- size of the barcode + width = mp.get_property("osd-width") + height = math.floor(width/20) - local nordlicht_cmd = "nordlicht -s "..styles - local nordlicht_cmd2 = "nordlicht -s "..styles - local path = mp.get_property("path") - local cmd = "nice "..nordlicht_cmd.." \""..path.."\" -o /tmp/nordlicht.bgra -w "..width.." -h "..height.." &" - os.execute(cmd) - local cmd2 = "nice "..nordlicht_cmd2.." \""..path.."\" -o /tmp/nordlicht2.bgra -w "..width2.." -h "..height2.." &" - os.execute(cmd2) + video = mp.get_property("path") + nordlicht = video..".nordlicht.png" + buffer = "/tmp/nordlicht.bgra" - if was_on then - -- wait for the file to be opened and truncated - mp.add_timeout(0.5, on) + local f = io.open(nordlicht, "r") + if f ~= nil then + -- a suitable nordlicht already exists, use that + io.close(f) + local cmd = {"convert", nordlicht, "-depth", "8", "-resize", width.."x"..height.."!", buffer} + utils.subprocess({args=cmd}) + + if was_on then + on() + end + else + -- no nordlicht exists, generate one + regenerate() + + if was_on then + -- wait for the buffer to be opened and truncated + mp.add_timeout(0.5, on) + end end + end function update() local pos = mp.get_property("percent-pos") if pos ~= nil then - mp.command("overlay_add 0 0 "..mh.." /tmp/nordlicht.bgra 0 bgra "..width.." "..height.." "..width*4) + mp.command("overlay_add 0 0 "..mh.." "..buffer.." 0 bgra "..width.." "..height.." "..width*4) mp.command("overlay_add 1 "..(math.floor(pos/100*width)-(mw-1)/2).." "..(0).." /tmp/arrow_down.bgra 0 bgra "..mw.." "..mh.." "..mw*4) mp.command("overlay_add 2 "..(math.floor(pos/100*width)-(mw-1)/2).." "..(height+mh).." /tmp/arrow_up.bgra 0 bgra "..mw.." "..mh.." "..mw*4) end - - if mode == 2 then - local offset = height+3*mh - - if pos ~= nil then - mp.command("overlay_add 3 "..math.floor(screen_width/2-width2*pos/100).." "..(mh+offset).." /tmp/nordlicht2.bgra 0 bgra "..width2.." "..height2.." "..width2*4) - mp.command("overlay_add 4 "..(math.floor(screen_width/2)-(mw-1)/2).." "..(offset).." /tmp/arrow_down.bgra 0 bgra "..mw.." "..mh.." "..mw*4) - mp.command("overlay_add 5 "..(math.floor(screen_width/2)-(mw-1)/2).." "..(height2+mh+offset).." /tmp/arrow_up.bgra 0 bgra "..mw.." "..mh.." "..mw*4) - end - end end function on() @@ -97,9 +88,6 @@ mp.command("overlay_remove 0") mp.command("overlay_remove 1") mp.command("overlay_remove 2") - mp.command("overlay_remove 3") - mp.command("overlay_remove 4") - mp.command("overlay_remove 5") is_on = false end end @@ -107,20 +95,51 @@ function toggle() if is_on then off() - if mode == 1 then - mode = 2 - on() - end else - mode = 1 on() end end -function fullscreen() - mp.set_property("fullscreen", "yes") +function seek() + if not is_on then + on() + + if seek_off_timer then + seek_off_timer:kill() + end + seek_off_timer = mp.add_timeout(1, off) + end +end + +function regenerate() + local was_on = is_on + off() + local cmd = "(nice nordlicht -s "..styles.." \""..video.."\" -o "..buffer.." -w "..width.." -h "..height.." && convert -depth 8 -size "..width.."x"..height.." "..buffer.." \""..nordlicht.."\") &" + os.execute(cmd) + if was_on then + on() + end +end + +function jump(e) + local mouseX, mouseY = mp.get_mouse_pos() + local osdX, osdY = mp.get_osd_resolution() + mouseX = 100.0*mouseX/osdX + + mp.commandv("seek", mouseX, "absolute-percent", "exact") +end + +-- wait until the osd-width is > 0, then init +function maybeinit() + if tonumber(mp.get_property("osd-width")) > 0 then + init() + is_on = false + new_file() + on() + else + mp.add_timeout(0.1, maybeinit) + end end --- not an optimal solution, but it seems to work: -mp.add_timeout(0.5, fullscreen) -mp.add_timeout(2, init) +mp.set_property("fullscreen", "yes") +maybeinit()
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.