Projects
Multimedia
nordlicht
Sign Up
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
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 @@ /*
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
.