#ifndef _AVUTIL_INTFLOAT_H_dc519942_ #define _AVUTIL_INTFLOAT_H_dc519942_ /* * This file was stolen from ffmpeg and modified for usability here. * The original is * * Copyright (c) 2011 Mans Rullgard * * This version is a derivative work of that version. It is not free * software; it is licensed under the GNU Lesser General Public * License version 2.1, which places nontrivial restrictions on what * may be done with it. (I'm not terribly happy about that, but for * my purposes accepting LGPL-infected code is a lower price than * reimplementing it all myself.) * * The LGPL v2.1 as distributed with ffmpeg is in the accompanying file * `LGPL-v2.1'. */ #include #include "avutil-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