Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-01-16 01:28:04 +0400
committerDerek Buitenhuis <derek.buitenhuis@gmail.com>2013-10-15 19:52:12 +0400
commit50867209930fd03c05b879bd6223b52c7305c90a (patch)
treed876bd61c23fa54ba88ad9415dddb4a7e4953c54 /libavcodec/cos_tablegen.c
parent008014b5e72442fe7c8bf4a31e6bb74469b81359 (diff)
cos_tablegen: Don't use lrint
You cannot count on it being present on all systems, and you cannot include libm.h in a host tool, so just hard code a baseline implementation. Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec/cos_tablegen.c')
-rw-r--r--libavcodec/cos_tablegen.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/libavcodec/cos_tablegen.c b/libavcodec/cos_tablegen.c
index 313a1d2663..48b7b90010 100644
--- a/libavcodec/cos_tablegen.c
+++ b/libavcodec/cos_tablegen.c
@@ -37,11 +37,16 @@ static int clip_f15(int v)
static void printval(double val, int fixed)
{
- if (fixed)
- printf(" "FIXEDFMT",", clip_f15(lrint(val * (double)(1<<15))));
- else
- printf(" "FLOATFMT",", val);
+ if (fixed) {
+ /* lrint() isn't always available, so round and cast manually. */
+ double new_val = val * (double) (1 << 15);
+
+ new_val = new_val >= 0 ? floor(new_val + 0.5) : ceil(new_val - 0.5);
+ printf(" "FIXEDFMT",", clip_f15((long int) new_val));
+ } else {
+ printf(" "FLOATFMT",", val);
+ }
}
int main(int argc, char *argv[])