From 6b998b5ed066aeece1146fe245b35965319b3cbd Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 10 May 2017 16:59:26 +0200 Subject: Cleaner code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/blind-cut.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/blind-cut.c') 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 -#include #include -#include 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, ""); - 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) { -- cgit v1.2.3-70-g09d2