mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 13:48:21 +01:00
3f182d36f4
this will force a constant duration for an interval of frames in an animation. Notes: a) '-duration [...]' can be repeated as many times as needed. b) intervals are taken into account in option order. If they overlap, values will be overwritten. c) 'start' and 'end' can be omitted, but not the duration value. d) 'end' can be equal to '0', in which case it means 'last frame' e) single-image files are untouched (ie. not turned into an animation file). Some example usage: 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 Change-Id: I9b595dafa77f9221bacd080be7858b1457f54636
59 lines
1.8 KiB
C
59 lines
1.8 KiB
C
// Copyright 2012 Google Inc. All Rights Reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license
|
|
// that can be found in the COPYING file in the root of the source
|
|
// tree. An additional intellectual property rights grant can be found
|
|
// in the file PATENTS. All contributing project authors may
|
|
// be found in the AUTHORS file in the root of the source tree.
|
|
// -----------------------------------------------------------------------------
|
|
//
|
|
// Utility functions used by the example programs.
|
|
//
|
|
|
|
#include "./example_util.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
//------------------------------------------------------------------------------
|
|
// String parsing
|
|
|
|
uint32_t ExUtilGetUInt(const char* const v, int base, int* const error) {
|
|
char* end = NULL;
|
|
const uint32_t n = (v != NULL) ? (uint32_t)strtoul(v, &end, base) : 0u;
|
|
if (end == v && error != NULL && !*error) {
|
|
*error = 1;
|
|
fprintf(stderr, "Error! '%s' is not an integer.\n",
|
|
(v != NULL) ? v : "(null)");
|
|
}
|
|
return n;
|
|
}
|
|
|
|
int ExUtilGetInt(const char* const v, int base, int* const error) {
|
|
return (int)ExUtilGetUInt(v, base, error);
|
|
}
|
|
|
|
int ExUtilGetInts(const char* v, int base, int max_output, int output[]) {
|
|
int n, error = 0;
|
|
for (n = 0; v != NULL && n < max_output; ++n) {
|
|
const int value = ExUtilGetInt(v, base, &error);
|
|
if (error) return -1;
|
|
output[n] = value;
|
|
v = strchr(v, ',');
|
|
if (v != NULL) ++v; // skip over the trailing ','
|
|
}
|
|
return n;
|
|
}
|
|
|
|
float ExUtilGetFloat(const char* const v, int* const error) {
|
|
char* end = NULL;
|
|
const float f = (v != NULL) ? (float)strtod(v, &end) : 0.f;
|
|
if (end == v && error != NULL && !*error) {
|
|
*error = 1;
|
|
fprintf(stderr, "Error! '%s' is not a floating point number.\n",
|
|
(v != NULL) ? v : "(null)");
|
|
}
|
|
return f;
|
|
}
|