summaryrefslogtreecommitdiff
path: root/libavcodec/cos_tablegen.c
diff options
context:
space:
mode:
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 8a9085704e..9cf9cef6aa 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[])