(wrong string) ée

From: <git_AT_suckless.org>
Date: Wed, 31 May 2017 21:14:09 +0200 (CEST)

commit 91eae00bfa6abfb4b50833768d54ac48678c88f6
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Wed May 31 21:06:25 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Wed May 31 21:06:25 2017 +0200

    blind-stack: add -s
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/man/blind-stack.1 b/man/blind-stack.1
index ca9ed9b..5a0a31f 100644
--- a/man/blind-stack.1
+++ b/man/blind-stack.1
_AT_@ -3,7 +3,7 @@
 blind-stack - Overlay videos
 .SH SYNOPSIS
 .B blind-stack
-[-b]
+[-bs]
 .IR bottom-stream
 .RI "... " top-stream
 .SH DESCRIPTION
_AT_@ -30,6 +30,10 @@ Instead of drawing the videos on top of each
 other, for each pixel in each frame, print the
 average colour for each input stream's
 corresponding pixel and frame.
+.TP
+.B -s
+The output video will be as long as the shortest
+input video, rather than as the longest.
 .SH SEE ALSO
 .BR blind (7),
 .BR blind-dissolve (1),
diff --git a/src/blind-stack.c b/src/blind-stack.c
index b7dcc8e..bff2923 100644
--- a/src/blind-stack.c
+++ b/src/blind-stack.c
_AT_@ -1,7 +1,7 @@
 /* See LICENSE file for copyright and license details. */
 #include "common.h"
 
-USAGE("[-b] bottom-stream ... top-stream")
+USAGE("[-bs] bottom-stream ... top-stream")
 
 #define PROCESS(TYPE, BLEND)\
         do {\
_AT_@ -42,13 +42,16 @@ main(int argc, char *argv[])
 {
         struct stream *streams;
         size_t n_streams, i, frames = 0, tmp;
- int blend = 0;
+ int blend = 0, shortest = 0;
         void (*process)(struct stream *streams, size_t n_streams, size_t n);
 
         ARGBEGIN {
         case 'b':
                 blend = 1;
                 break;
+ case 's':
+ shortest = 1;
+ break;
         default:
                 usage();
         } ARGEND;
_AT_@ -61,7 +64,7 @@ main(int argc, char *argv[])
 
         for (i = 0; i < n_streams; i++) {
                 eopen_stream(streams + i, argv[i]);
- if (streams[i].frames > frames)
+ if (shortest ? (streams[i].frames && streams[i].frames) < frames : streams[i].frames > frames)
                         frames = streams[i].frames;
         }
 
_AT_@ -76,7 +79,7 @@ main(int argc, char *argv[])
         fprint_stream_head(stdout, streams);
         efflush(stdout, "<stdout>");
         streams->frames = tmp;
- process_multiple_streams(streams, n_streams, STDOUT_FILENO, "<stdout>", process);
+ process_multiple_streams(streams, n_streams, STDOUT_FILENO, "<stdout>", shortest, process);
 
         free(streams);
         return 0;
diff --git a/src/stream.c b/src/stream.c
index 30bce25..1f361a4 100644
--- a/src/stream.c
+++ b/src/stream.c
_AT_@ -398,7 +398,7 @@ nprocess_two_streams(int status, struct stream *left, struct stream *right, int
 
 void
 nprocess_multiple_streams(int status, struct stream *streams, size_t n_streams, int output_fd, const char* output_fname,
- void (*process)(struct stream *streams, size_t n_streams, size_t n))
+ int shortest, void (*process)(struct stream *streams, size_t n_streams, size_t n))
 {
         size_t closed, i, j, n;
 
_AT_@ -411,6 +411,8 @@ nprocess_multiple_streams(int status, struct stream *streams, size_t n_streams,
                         if (streams[i].ptr < sizeof(streams->buf) && !enread_stream(status, streams + i, SIZE_MAX)) {
                                 close(streams[i].fd);
                                 streams[i].fd = -1;
+ if (shortest)
+ return;
                         }
                         if (streams[i].ptr && streams[i].ptr < n)
                                 n = streams[i].ptr;
diff --git a/src/stream.h b/src/stream.h
index 3e239d4..c77d4aa 100644
--- a/src/stream.h
+++ b/src/stream.h
_AT_@ -90,7 +90,7 @@ void nprocess_two_streams(int status, struct stream *left, struct stream *right,
                           void (*process)(struct stream *left, struct stream *right, size_t n));
 
 void nprocess_multiple_streams(int status, struct stream *streams, size_t n_streams, int output_fd, const char* output_fname,
- void (*process)(struct stream *streams, size_t n_streams, size_t n));
+ int shortest, void (*process)(struct stream *streams, size_t n_streams, size_t n));
 
 void nprocess_each_frame_two_streams(int status, struct stream *left, struct stream *right, int output_fd, const char* output_fname,
                                      void (*process)(char *restrict output, char *restrict lbuf, char *restrict rbuf,
Received on Wed May 31 2017 - 21:14:09 CEST

This archive was generated by hypermail 2.3.0 : Wed May 31 2017 - 21:24:21 CEST