aboutsummaryrefslogtreecommitdiffstats
path: root/src/blind-cut.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-05-10 16:59:26 +0200
committerMattias Andrée <maandree@kth.se>2017-05-10 16:59:26 +0200
commit6b998b5ed066aeece1146fe245b35965319b3cbd (patch)
treec963b48fbefafcec89a4e4af238869a1cb51148e /src/blind-cut.c
parentblind-flip is optimal (diff)
downloadblind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.gz
blind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.bz2
blind-6b998b5ed066aeece1146fe245b35965319b3cbd.tar.xz
Cleaner code
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-cut.c')
-rw-r--r--src/blind-cut.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/blind-cut.c b/src/blind-cut.c
index 9f4357c..62ef98b 100644
--- a/src/blind-cut.c
+++ b/src/blind-cut.c
@@ -2,10 +2,7 @@
#include "stream.h"
#include "util.h"
-#include <limits.h>
-#include <stdint.h>
#include <string.h>
-#include <unistd.h>
USAGE("start-point (end-point | 'end') file")
@@ -13,7 +10,7 @@ int
main(int argc, char *argv[])
{
struct stream stream;
- size_t frame_size, start = 0, end = 0, ptr, max;
+ size_t start = 0, end = 0, ptr, max;
ssize_t r;
char buf[BUFSIZ];
int to_end = 0;
@@ -36,19 +33,16 @@ main(int argc, char *argv[])
else if (end > stream.frames)
eprintf("end point is after end of video\n");
stream.frames = end - start;
+ echeck_dimensions(&stream, WIDTH | HEIGHT | LENGTH, NULL);
fprint_stream_head(stdout, &stream);
efflush(stdout, "<stdout>");
- echeck_frame_size(stream.width, stream.height, stream.pixel_size, 0, stream.file);
- frame_size = stream.width * stream.height * stream.pixel_size;
- if (stream.frames > (size_t)SSIZE_MAX / frame_size)
- eprintf("%s: video is too large\n", stream.file);
if (start >= end)
eprintf("%s\n", start > end ?
"start point is after end point" :
"refusing to create video with zero frames");
- end = end * frame_size + stream.headlen;
- start = start * frame_size + stream.headlen;
+ end = end * stream.frame_size + stream.headlen;
+ start = start * stream.frame_size + stream.headlen;
fadvise_sequential(stream.fd, start, end - start);
for (ptr = start; ptr < end; ptr += (size_t)r) {