From f7813a5324be39d13ab536c245d15dfc602a7849 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 29 Dec 2013 12:19:38 +0000 Subject: basic type mechanism working --- ffmpeg/libavcodec/cos_tablegen.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ffmpeg/libavcodec/cos_tablegen.c') diff --git a/ffmpeg/libavcodec/cos_tablegen.c b/ffmpeg/libavcodec/cos_tablegen.c index 313a1d2..48b7b90 100644 --- a/ffmpeg/libavcodec/cos_tablegen.c +++ b/ffmpeg/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[]) -- cgit v1.2.3