diff options
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/eval.h | 2 | ||||
-rw-r--r-- | libavutil/intfloat.h | 73 | ||||
-rw-r--r-- | libavutil/intfloat_readwrite.h | 12 |
3 files changed, 80 insertions, 7 deletions
diff --git a/libavutil/eval.h b/libavutil/eval.h index ee378a29b4..22fa121127 100644 --- a/libavutil/eval.h +++ b/libavutil/eval.h @@ -58,7 +58,7 @@ int av_expr_parse_and_eval(double *res, const char *s, * Parse an expression. * * @param expr a pointer where is put an AVExpr containing the parsed - * value in case of successfull parsing, or NULL otherwise. + * value in case of successful parsing, or NULL otherwise. * The pointed to AVExpr must be freed with av_expr_free() by the user * when it is not needed anymore. * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" diff --git a/libavutil/intfloat.h b/libavutil/intfloat.h new file mode 100644 index 0000000000..9db624a6ce --- /dev/null +++ b/libavutil/intfloat.h @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_H +#define AVUTIL_INTFLOAT_H + +#include <stdint.h> +#include "attributes.h" + +union av_intfloat32 { + uint32_t i; + float f; +}; + +union av_intfloat64 { + uint64_t i; + double f; +}; + +/** + * Reinterpret a 32-bit integer as a float. + */ +static av_always_inline float av_int2float(uint32_t i) +{ + union av_intfloat32 v = { .i = i }; + return v.f; +} + +/** + * Reinterpret a float as a 32-bit integer. + */ +static av_always_inline uint32_t av_float2int(float f) +{ + union av_intfloat32 v = { .f = f }; + return v.i; +} + +/** + * Reinterpret a 64-bit integer as a double. + */ +static av_always_inline double av_int2double(uint64_t i) +{ + union av_intfloat64 v = { .i = i }; + return v.f; +} + +/** + * Reinterpret a double as a 64-bit integer. + */ +static av_always_inline uint64_t av_double2int(double f) +{ + union av_intfloat64 v = { .f = f }; + return v.i; +} + +#endif /* AVUTIL_INTFLOAT_H */ diff --git a/libavutil/intfloat_readwrite.h b/libavutil/intfloat_readwrite.h index 1b80fc6e95..9709f4dae4 100644 --- a/libavutil/intfloat_readwrite.h +++ b/libavutil/intfloat_readwrite.h @@ -30,11 +30,11 @@ typedef struct AVExtFloat { uint8_t mantissa[8]; } AVExtFloat; -double av_int2dbl(int64_t v) av_const; -float av_int2flt(int32_t v) av_const; -double av_ext2dbl(const AVExtFloat ext) av_const; -int64_t av_dbl2int(double d) av_const; -int32_t av_flt2int(float d) av_const; -AVExtFloat av_dbl2ext(double d) av_const; +attribute_deprecated double av_int2dbl(int64_t v) av_const; +attribute_deprecated float av_int2flt(int32_t v) av_const; +attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const; +attribute_deprecated int64_t av_dbl2int(double d) av_const; +attribute_deprecated int32_t av_flt2int(float d) av_const; +attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const; #endif /* AVUTIL_INTFLOAT_READWRITE_H */ |