webpmux -duration: set default 'end' value equal to 'start'

The options are now:
  -duration d     -> set the whole animation to duration 'd'
  -duration d,s   -> set only frame 's' to duration 'd'
  -duration d,s,e -> set only interval [s,d] to duration 'd'

+ style fix

Change-Id: I72e95282d520146f76696666f44280ad9506affa
This commit is contained in:
Pascal Massimino 2016-11-09 23:26:01 -08:00 committed by James Zern
parent f90c60d129
commit c0699515af
3 changed files with 64 additions and 29 deletions

View File

@ -51,12 +51,15 @@ SET_OPTIONS:
'file.xmp' contains the XMP metadata to be set
DURATION_OPTIONS:
Set constant duration of frames:
duration[,start[,end]]
where: 'duration' is the duration in milliseconds,
'start' is the start frame index (optional)(default=1),
'end' is the inclusive end frame index (optional).
The special value '0' means: last frame (default=0).
Set duration of selected frames:
duration set duration for each frames
duration,frame set duration of a particular frame
duration,start,end set duration of frames in the
interval [start,end])
where: 'duration' is the duration in milliseconds
'start' is the start frame index
'end' is the inclusive end frame index
The special 'end' value '0' means: last frame.
STRIP_OPTIONS:
Strip color profile/metadata:

View File

@ -40,8 +40,8 @@
Change duration of frame intervals:
webpmux -duration 150 in.webp -o out.webp
webpmux -duration 33,10,0 in.webp -o out.webp
webpmux -duration 200,2 -duration 150,0,50 in.webp -o out.webp
webpmux -duration 33,2 in.webp -o out.webp
webpmux -duration 200,10,0 -duration 150,6,50 in.webp -o out.webp
Misc:
webpmux -info in.webp
@ -322,12 +322,15 @@ static void PrintHelp(void) {
printf("\n");
printf("DURATION_OPTIONS:\n");
printf(" Set constant duration of frames:\n");
printf(" duration[,start[,end]]\n");
printf(" where: 'duration' is the duration in milliseconds,\n");
printf(" 'start' is the start frame index (optional)(default=1),\n");
printf(" 'end' is the inclusive end frame index (optional).\n");
printf(" The special value '0' means: last frame (default=0).\n");
printf(" Set duration of selected frames:\n");
printf(" duration set duration for each frames\n");
printf(" duration,frame set duration of a particular frame\n");
printf(" duration,start,end set duration of frames in the\n");
printf(" interval [start,end])\n");
printf(" where: 'duration' is the duration in milliseconds\n");
printf(" 'start' is the start frame index\n");
printf(" 'end' is the inclusive end frame index\n");
printf(" The special 'end' value '0' means: last frame.\n");
printf("\n");
printf("STRIP_OPTIONS:\n");
@ -1053,12 +1056,19 @@ static int Process(const WebPMuxConfig* config) {
ERROR_GOTO1("ERROR: duration must be strictly positive.\n", Err3);
}
start = (nb_args >= 2) ? args[1] : 1;
if (start <= 0) start = 1;
end = (nb_args >= 3) ? args[2] : num_frames;
if (end == 0) end = num_frames;
if (end > num_frames) end = num_frames;
if (nb_args == 1) { // only duration is present -> use full interval
start = 1;
end = num_frames;
} else {
start = args[1];
if (start <= 0) {
start = 1;
} else if (start > num_frames) {
start = num_frames;
}
end = (nb_args >= 3) ? args[2] : start;
if (end == 0 || end > num_frames) end = num_frames;
}
for (k = start; k <= end; ++k) {
assert(k >= 1 && k <= num_frames);
@ -1085,7 +1095,7 @@ static int Process(const WebPMuxConfig* config) {
mux = new_mux; // transfer for the WebPMuxDelete() call
new_mux = NULL;
Err3:
Err3:
free(durations);
WebPMuxDelete(new_mux);
if (!ok) goto Err2;

View File

@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
.TH WEBPMUX 1 "November 8, 2016"
.TH WEBPMUX 1 "November 10, 2016"
.SH NAME
webpmux \- create animated WebP files from non\-animated WebP images, extract
frames from animated WebP images, and manage XMP/EXIF metadata and ICC profile.
@ -99,17 +99,39 @@ Strip EXIF metadata.
Strip XMP metadata.
.SS DURATION_OPTIONS (\-duration)
Amend the duration of a specific interval of frames.
Amend the duration of a specific interval of frames. This option is only
effective on animated WebP and has no effect on a single-frame file.
.TP
.I duration[,start[,end]]
Where:
'duration' is the duration for the interval (mandatory). Must be non-negative.
'start' is the starting frame index of the interval (optional). If 'start'
is less or equal to '1', its value will be set to '1'.
'end' is the ending frame index (inclusive) of the interval (optional). The
value '0' has the special meaning 'last frame of the animation'.
.br
.B duration
is the duration for the interval in milliseconds (mandatory).
Must be non-negative.
.br
.B start
is the starting frame index of the interval (optional).
.br
.B end
is the ending frame index (inclusive) of the interval (optional).
.TP
The three typical usages of this option are:
.br
.B -duration d
set the duration to 'd' for the whole animation.
.br
.B -duration d,f
set the duration of frame 'f' to 'd'.
.br
.B -duration d,start,end
set the duration to 'd' for the whole [start,end] interval.
.TP
.P
Note that the frames outside of the [start, end] interval will remain untouched.
.I Reminder: frame indexing starts at '1'.
The 'end' value '0' has the special meaning 'last frame of the animation'.
.TP
.I Reminder:
frame indexing starts at '1'.
.br
.SS FRAME_OPTIONS (\-frame)