1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-06-20 06:16:02 +02:00
Files
doc
ffpresets
libavcodec
libavcore
libavdevice
libavfilter
libavformat
libavutil
arm
avr32
bfin
mips
ppc
sh4
tomi
x86
Makefile
adler32.c
adler32.h
aes.c
aes.h
attributes.h
avstring.c
avstring.h
avutil.h
base64.c
base64.h
bswap.h
colorspace.h
common.h
crc.c
crc.h
crc_data.h
des.c
des.h
error.c
error.h
eval.c
eval.h
fifo.c
fifo.h
integer.c
integer.h
internal.h
intfloat_readwrite.c
intfloat_readwrite.h
intmath.h
intreadwrite.h
inverse.c
lfg.c
lfg.h
libavutil.v
libm.h
lls.c
lls.h
log.c
log.h
lzo.c
lzo.h
mathematics.c
mathematics.h
md5.c
md5.h
mem.c
mem.h
pca.c
pca.h
pixdesc.c
pixdesc.h
pixfmt.h
random_seed.c
random_seed.h
rational.c
rational.h
rc4.c
rc4.h
sha.c
sha.h
sha1.h
softfloat.c
softfloat.h
timer.h
tree.c
tree.h
utils.c
x86_cpu.h
libpostproc
libswscale
tests
tools
COPYING.GPLv2
COPYING.GPLv3
COPYING.LGPLv2.1
COPYING.LGPLv3
CREDITS
Changelog
Doxyfile
INSTALL
LICENSE
MAINTAINERS
Makefile
README
cmdutils.c
cmdutils.h
cmdutils_common_opts.h
common.mak
configure
ffmpeg.c
ffplay.c
ffprobe.c
ffserver.c
ffserver.h
subdir.mak
version.sh
FFmpeg/libavutil/softfloat.c

73 lines
2.0 KiB
C
Raw Normal View History

/*
* copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
*
* This file is part of FFmpeg.
*
* FFmpeg 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.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <inttypes.h>
#include <stdio.h>
#include <assert.h>
#include "softfloat.h"
#include "common.h"
#include "log.h"
#undef printf
int main(void){
SoftFloat one= av_int2sf(1, 0);
SoftFloat sf1, sf2;
double d1, d2;
int i, j;
av_log_set_level(AV_LOG_DEBUG);
d1= 1;
for(i= 0; i<10; i++){
d1= 1/(d1+1);
}
printf("test1 double=%d\n", (int)(d1 * (1<<24)));
sf1= one;
for(i= 0; i<10; i++){
sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
}
printf("test1 sf =%d\n", av_sf2int(sf1, 24));
for(i= 0; i<100; i++){
START_TIMER
d1= i;
d2= i/100.0;
for(j= 0; j<1000; j++){
d1= (d1+1)*d2;
}
STOP_TIMER("float add mul")
}
printf("test2 double=%d\n", (int)(d1 * (1<<24)));
for(i= 0; i<100; i++){
START_TIMER
sf1= av_int2sf(i, 0);
sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
for(j= 0; j<1000; j++){
sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
}
STOP_TIMER("softfloat add mul")
}
printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
return 0;
}