libavutil/softfloat.c

Go to the documentation of this file.
00001 /*
00002  * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #include <inttypes.h>
00022 #include <stdio.h>
00023 #include <assert.h>
00024 #include "softfloat.h"
00025 #include "common.h"
00026 #include "log.h"
00027 
00028 #undef printf
00029 
00030 int main(void){
00031 SoftFloat one= av_int2sf(1, 0);
00032 SoftFloat sf1, sf2;
00033 double d1, d2;
00034 int i, j;
00035 av_log_level = AV_LOG_DEBUG;
00036 
00037 d1= 1;
00038 for(i= 0; i<10; i++){
00039 d1= 1/(d1+1);
00040 }
00041 printf("test1 double=%d\n", (int)(d1 * (1<<24)));
00042 
00043 sf1= one;
00044 for(i= 0; i<10; i++){
00045 sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
00046 }
00047 printf("test1 sf =%d\n", av_sf2int(sf1, 24));
00048 
00049 
00050 for(i= 0; i<100; i++){
00051 START_TIMER
00052 d1= i;
00053 d2= i/100.0;
00054 for(j= 0; j<1000; j++){
00055 d1= (d1+1)*d2;
00056 }
00057 STOP_TIMER("float add mul")
00058 }
00059 printf("test2 double=%d\n", (int)(d1 * (1<<24)));
00060 
00061 for(i= 0; i<100; i++){
00062 START_TIMER
00063 sf1= av_int2sf(i, 0);
00064 sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
00065 for(j= 0; j<1000; j++){
00066 sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
00067 }
00068 STOP_TIMER("softfloat add mul")
00069 }
00070 printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
00071 return 0;
00072 }

Generated on Fri Oct 26 02:35:41 2012 for FFmpeg by doxygen 1.5.8

AltStyle によって変換されたページ (->オリジナル) /