Commit 3383a53e authored by Mans Rullgard's avatar Mans Rullgard

lavu: replace int/float punning functions

The existing functions defined in intfloat_readwrite.[ch] are
both slow and incorrect (infinities are not handled).

This introduces a new header with fast, inline conversion
functions using direct union punning assuming an IEEE-754
system, an assumption already made throughout the code.

The one use of Intel/Motorola extended 80-bit format is
replaced by simpler code sufficient under the present
constraints (positive normal values).

The old functions are marked deprecated and retained for
compatibility.
Signed-off-by: default avatarMans Rullgard <mans@mansr.com>
parent 5b3265a7
......@@ -35,7 +35,7 @@
#include "dct.h"
#include "rdft.h"
#include "fmtconvert.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
extern const uint16_t ff_wma_critical_freqs[25];
......@@ -193,8 +193,8 @@ static int decode_block(BinkAudioContext *s, int16_t *out, int use_dct)
if (s->version_b) {
if (get_bits_left(gb) < 64)
return AVERROR_INVALIDDATA;
coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root;
coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root;
coeffs[0] = av_int2float(get_bits_long(gb, 32)) * s->root;
coeffs[1] = av_int2float(get_bits_long(gb, 32)) * s->root;
} else {
if (get_bits_left(gb) < 58)
return AVERROR_INVALIDDATA;
......
......@@ -28,7 +28,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
......@@ -131,7 +131,7 @@ static int fourxm_read_header(AVFormatContext *s,
size = AV_RL32(&header[i + 4]);
if (fourcc_tag == std__TAG) {
fourxm->fps = av_int2flt(AV_RL32(&header[i + 12]));
fourxm->fps = av_int2float(AV_RL32(&header[i + 12]));
} else if (fourcc_tag == vtrk_TAG) {
/* check that there is enough data */
if (size != vtrk_SIZE) {
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/mathematics.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
......@@ -88,7 +88,8 @@ static void get_meta(AVFormatContext *s, const char *key, int size)
static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec,
int size, unsigned version)
{
AVExtFloat ext;
int exp;
uint64_t val;
double sample_rate;
unsigned int num_frames;
......@@ -99,8 +100,9 @@ static unsigned int get_aiff_header(AVIOContext *pb, AVCodecContext *codec,
num_frames = avio_rb32(pb);
codec->bits_per_coded_sample = avio_rb16(pb);
avio_read(pb, (uint8_t*)&ext, sizeof(ext));/* Sample rate is in */
sample_rate = av_ext2dbl(ext); /* 80 bits BE IEEE extended float */
exp = avio_rb16(pb);
val = avio_rb64(pb);
sample_rate = ldexp(val, exp - 16383 - 63);
codec->sample_rate = sample_rate;
size -= 18;
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
#include "aiff.h"
......@@ -36,7 +36,7 @@ static int aiff_write_header(AVFormatContext *s)
AIFFOutputContext *aiff = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVExtFloat sample_rate;
uint64_t sample_rate;
int aifc = 0;
/* First verify if format is ok */
......@@ -82,8 +82,9 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */
sample_rate = av_dbl2ext((double)enc->sample_rate);
avio_write(pb, (uint8_t*)&sample_rate, sizeof(sample_rate));
sample_rate = av_double2int(enc->sample_rate);
avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023));
avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11);
if (aifc) {
avio_wl32(pb, enc->codec_tag);
......
......@@ -30,7 +30,7 @@
#include "riff.h"
#include "isom.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/dict.h"
#include "caf.h"
......@@ -68,7 +68,7 @@ static int read_desc_chunk(AVFormatContext *s)
/* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = av_int2dbl(avio_rb64(pb));
st->codec->sample_rate = av_int2double(avio_rb64(pb));
st->codec->codec_tag = avio_rb32(pb);
flags = avio_rb32(pb);
caf->bytes_per_packet = avio_rb32(pb);
......
......@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
#include "ffm.h"
......@@ -325,10 +325,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2dbl(avio_rb64(pb));
codec->b_quant_factor = av_int2dbl(avio_rb64(pb));
codec->i_quant_offset = av_int2dbl(avio_rb64(pb));
codec->b_quant_offset = av_int2dbl(avio_rb64(pb));
codec->i_quant_factor = av_int2double(avio_rb64(pb));
codec->b_quant_factor = av_int2double(avio_rb64(pb));
codec->i_quant_offset = av_int2double(avio_rb64(pb));
codec->b_quant_offset = av_int2double(avio_rb64(pb));
codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = avio_rb32(pb);
......@@ -340,7 +340,7 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2dbl(avio_rb64(pb));
codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
codec->codec_tag = avio_rb32(pb);
codec->thread_count = avio_r8(pb);
codec->coder_type = avio_rb32(pb);
......@@ -350,8 +350,8 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2dbl(avio_rb64(pb));
codec->qblur = av_int2dbl(avio_rb64(pb));
codec->qcompress = av_int2double(avio_rb64(pb));
codec->qblur = av_int2double(avio_rb64(pb));
codec->max_qdiff = avio_rb32(pb);
codec->refs = avio_rb32(pb);
break;
......
......@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
#include "ffm.h"
......@@ -137,10 +137,10 @@ static int ffm_write_header(AVFormatContext *s)
avio_wb32(pb, codec->rc_max_rate);
avio_wb32(pb, codec->rc_min_rate);
avio_wb32(pb, codec->rc_buffer_size);
avio_wb64(pb, av_dbl2int(codec->i_quant_factor));
avio_wb64(pb, av_dbl2int(codec->b_quant_factor));
avio_wb64(pb, av_dbl2int(codec->i_quant_offset));
avio_wb64(pb, av_dbl2int(codec->b_quant_offset));
avio_wb64(pb, av_double2int(codec->i_quant_factor));
avio_wb64(pb, av_double2int(codec->b_quant_factor));
avio_wb64(pb, av_double2int(codec->i_quant_offset));
avio_wb64(pb, av_double2int(codec->b_quant_offset));
avio_wb32(pb, codec->dct_algo);
avio_wb32(pb, codec->strict_std_compliance);
avio_wb32(pb, codec->max_b_frames);
......@@ -152,7 +152,7 @@ static int ffm_write_header(AVFormatContext *s)
avio_wb32(pb, codec->mb_decision);
avio_wb32(pb, codec->nsse_weight);
avio_wb32(pb, codec->frame_skip_cmp);
avio_wb64(pb, av_dbl2int(codec->rc_buffer_aggressivity));
avio_wb64(pb, av_double2int(codec->rc_buffer_aggressivity));
avio_wb32(pb, codec->codec_tag);
avio_w8(pb, codec->thread_count);
avio_wb32(pb, codec->coder_type);
......@@ -162,8 +162,8 @@ static int ffm_write_header(AVFormatContext *s)
avio_wb32(pb, codec->keyint_min);
avio_wb32(pb, codec->scenechange_threshold);
avio_wb32(pb, codec->b_frame_strategy);
avio_wb64(pb, av_dbl2int(codec->qcompress));
avio_wb64(pb, av_dbl2int(codec->qblur));
avio_wb64(pb, av_double2int(codec->qcompress));
avio_wb64(pb, av_double2int(codec->qblur));
avio_wb32(pb, codec->max_qdiff);
avio_wb32(pb, codec->refs);
break;
......
......@@ -26,7 +26,7 @@
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavcodec/bytestream.h"
#include "libavcodec/mpeg4audio.h"
......@@ -189,7 +189,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, AVStream
for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) {
if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER)
goto finish;
num_val = av_int2dbl(avio_rb64(ioc));
num_val = av_int2double(avio_rb64(ioc));
current_array[i] = num_val;
}
if (times && filepositions) {
......@@ -230,7 +230,7 @@ static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vst
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2dbl(avio_rb64(ioc)); break;
num_val = av_int2double(avio_rb64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
num_val = avio_r8(ioc); break;
case AMF_DATA_TYPE_STRING:
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "flv.h"
#include "internal.h"
......@@ -162,7 +162,7 @@ static void put_avc_eos_tag(AVIOContext *pb, unsigned ts) {
static void put_amf_double(AVIOContext *pb, double d)
{
avio_w8(pb, AMF_DATA_TYPE_NUMBER);
avio_wb64(pb, av_dbl2int(d));
avio_wb64(pb, av_double2int(d));
}
static void put_amf_bool(AVIOContext *pb, int b) {
......
......@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "avformat.h"
#include "internal.h"
......@@ -520,8 +520,8 @@ static int gxf_write_umf_media_dv(AVIOContext *pb, GXFStreamContext *sc)
static int gxf_write_umf_media_audio(AVIOContext *pb, GXFStreamContext *sc)
{
avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
avio_wl64(pb, av_dbl2int(1)); /* sound level to begin to */
avio_wl64(pb, av_double2int(1)); /* sound level to begin to */
avio_wl64(pb, av_double2int(1)); /* sound level to begin to */
avio_wl32(pb, 0); /* number of fields over which to ramp up sound level */
avio_wl32(pb, 0); /* number of fields over which to ramp down sound level */
avio_wl32(pb, 0); /* reserved */
......
......@@ -38,7 +38,7 @@
#include "rm.h"
#include "matroska.h"
#include "libavcodec/mpeg4audio.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include "libavutil/lzo.h"
......@@ -624,9 +624,9 @@ static int ebml_read_float(AVIOContext *pb, int size, double *num)
if (size == 0) {
*num = 0;
} else if (size == 4) {
*num= av_int2flt(avio_rb32(pb));
} else if(size==8){
*num= av_int2dbl(avio_rb64(pb));
*num = av_int2float(avio_rb32(pb));
} else if (size == 8){
*num = av_int2double(avio_rb64(pb));
} else
return AVERROR_INVALIDDATA;
......
......@@ -29,7 +29,7 @@
#include "avlanguage.h"
#include "libavutil/samplefmt.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/random_seed.h"
#include "libavutil/lfg.h"
......@@ -185,7 +185,7 @@ static void put_ebml_float(AVIOContext *pb, unsigned int elementid, double val)
{
put_ebml_id(pb, elementid);
put_ebml_num(pb, 8, 0);
avio_wb64(pb, av_dbl2int(val));
avio_wb64(pb, av_double2int(val));
}
static void put_ebml_binary(AVIOContext *pb, unsigned int elementid,
......
......@@ -26,7 +26,7 @@
//#define MOV_EXPORT_ALL_METADATA
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
......@@ -1218,7 +1218,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
avio_rb32(pb); /* bytes per sample */
} else if (version==2) {
avio_rb32(pb); /* sizeof struct only */
st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */
st->codec->sample_rate = av_int2double(avio_rb64(pb)); /* float 64 */
st->codec->channels = avio_rb32(pb);
avio_rb32(pb); /* always 0x7F000000 */
st->codec->bits_per_coded_sample = avio_rb32(pb); /* bits per channel if sound is uncompressed */
......
......@@ -32,7 +32,7 @@
#include "libavcodec/put_bits.h"
#include "internal.h"
#include "libavutil/avstring.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
......@@ -468,7 +468,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
avio_wb16(pb, 0);
avio_wb32(pb, 0x00010000);
avio_wb32(pb, 72);
avio_wb64(pb, av_dbl2int(track->timescale));
avio_wb64(pb, av_double2int(track->timescale));
avio_wb32(pb, track->enc->channels);
avio_wb32(pb, 0x7F000000);
avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
......
......@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
#include "riff.h"
......@@ -140,10 +140,10 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
avio_rl32(pb); // unused, "desiredheight"
avio_r8(pb); // 'P' == progressive, 'I' == interlaced
avio_skip(pb, 3); // padding
aspect = av_int2dbl(avio_rl64(pb));
aspect = av_int2double(avio_rl64(pb));
if (aspect > 0.9999 && aspect < 1.0001)
aspect = 4.0 / 3.0;
fps = av_int2dbl(avio_rl64(pb));
fps = av_int2double(avio_rl64(pb));
// number of packets per stream type, -1 means unknown, e.g. streaming
v_packs = avio_rl32(pb);
......
......@@ -21,7 +21,7 @@
#include "libavcodec/bytestream.h"
#include "libavutil/avstring.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "rtmppkt.h"
......@@ -37,7 +37,7 @@ void ff_amf_write_bool(uint8_t **dst, int val)
void ff_amf_write_number(uint8_t **dst, double val)
{
bytestream_put_byte(dst, AMF_DATA_TYPE_NUMBER);
bytestream_put_be64(dst, av_dbl2int(val));
bytestream_put_be64(dst, av_double2int(val));
}
void ff_amf_write_string(uint8_t **dst, const char *str)
......@@ -318,7 +318,7 @@ int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
if (size == namelen && !memcmp(data-size, name, namelen)) {
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
snprintf(dst, dst_size, "%g", av_int2dbl(AV_RB64(data)));
snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data)));
break;
case AMF_DATA_TYPE_BOOL:
snprintf(dst, dst_size, "%s", *data ? "true" : "false");
......@@ -370,7 +370,7 @@ static void ff_amf_tag_contents(void *ctx, const uint8_t *data, const uint8_t *d
return;
switch (*data++) {
case AMF_DATA_TYPE_NUMBER:
av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2dbl(AV_RB64(data)));
av_log(ctx, AV_LOG_DEBUG, " number %g\n", av_int2double(AV_RB64(data)));
return;
case AMF_DATA_TYPE_BOOL:
av_log(ctx, AV_LOG_DEBUG, " bool %d\n", *data);
......
......@@ -26,7 +26,7 @@
#include "libavcodec/bytestream.h"
#include "libavutil/avstring.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/lfg.h"
#include "libavutil/sha.h"
#include "avformat.h"
......@@ -615,7 +615,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
/* hack for Wowza Media Server, it does not send result for
* releaseStream and FCPublish calls */
if (!pkt->data[10]) {
int pkt_id = (int) av_int2dbl(AV_RB64(pkt->data + 11));
int pkt_id = av_int2double(AV_RB64(pkt->data + 11));
if (pkt_id == rt->create_stream_invoke)
rt->state = STATE_CONNECTING;
}
......@@ -626,7 +626,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
if (pkt->data[10] || pkt->data[19] != 5 || pkt->data[20]) {
av_log(s, AV_LOG_WARNING, "Unexpected reply on connect()\n");
} else {
rt->main_channel_id = (int) av_int2dbl(AV_RB64(pkt->data + 21));
rt->main_channel_id = av_int2double(AV_RB64(pkt->data + 21));
}
if (rt->is_input) {
gen_play(s, rt);
......
......@@ -30,7 +30,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
......@@ -62,14 +62,14 @@ static int sox_read_header(AVFormatContext *s,
st->codec->codec_id = CODEC_ID_PCM_S32LE;
header_size = avio_rl32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2dbl(avio_rl64(pb));
sample_rate = av_int2double(avio_rl64(pb));
st->codec->channels = avio_rl32(pb);
comment_size = avio_rl32(pb);
} else {
st->codec->codec_id = CODEC_ID_PCM_S32BE;
header_size = avio_rb32(pb);
avio_skip(pb, 8); /* sample count */
sample_rate = av_int2dbl(avio_rb64(pb));
sample_rate = av_int2double(avio_rb64(pb));
st->codec->channels = avio_rb32(pb);
comment_size = avio_rb32(pb);
}
......
......@@ -30,7 +30,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "avio_internal.h"
......@@ -59,14 +59,14 @@ static int sox_write_header(AVFormatContext *s)
ffio_wfourcc(pb, ".SoX");
avio_wl32(pb, sox->header_size);
avio_wl64(pb, 0); /* number of samples */
avio_wl64(pb, av_dbl2int(enc->sample_rate));
avio_wl64(pb, av_double2int(enc->sample_rate));
avio_wl32(pb, enc->channels);
avio_wl32(pb, comment_size);
} else if (enc->codec_id == CODEC_ID_PCM_S32BE) {
ffio_wfourcc(pb, "XoS.");
avio_wb32(pb, sox->header_size);
avio_wb64(pb, 0); /* number of samples */
avio_wb64(pb, av_dbl2int(enc->sample_rate));
avio_wb64(pb, av_double2int(enc->sample_rate));
avio_wb32(pb, enc->channels);
avio_wb32(pb, comment_size);
} else {
......
......@@ -20,7 +20,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "internal.h"
......@@ -69,7 +69,7 @@ static int thp_read_header(AVFormatContext *s,
avio_rb32(pb); /* Max buf size. */
avio_rb32(pb); /* Max samples. */
thp->fps = av_d2q(av_int2flt(avio_rb32(pb)), INT_MAX);
thp->fps = av_d2q(av_int2float(avio_rb32(pb)), INT_MAX);
thp->framecnt = avio_rb32(pb);
thp->first_framesz = avio_rb32(pb);
avio_rb32(pb); /* Data size. */
......
......@@ -26,7 +26,7 @@
*/
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat_readwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
......@@ -458,7 +458,7 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
*/
static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{
time_t t = 631112400LL + 86400*av_int2dbl(value);
time_t t = 631112400LL + 86400*av_int2double(value);
strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
}
......@@ -523,7 +523,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
else if (!strcmp(key, "WM/WMRVExpirationDate"))
oledate_to_iso8601(buf, buf_size, num);
else if (!strcmp(key, "WM/WMRVBitrate"))
snprintf(buf, buf_size, "%f", av_int2dbl(num));
snprintf(buf, buf_size, "%f", av_int2double(num));
else
snprintf(buf, buf_size, "%"PRIi64, num);
} else if (type == 5 && length == 2) {
......
/*
* 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 */
......@@ -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<