You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.9KB

  1. /*
  2. * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <inttypes.h>
  19. #include <stdio.h>
  20. #include <assert.h>
  21. #include "softfloat.h"
  22. #include "common.h"
  23. #include "log.h"
  24. #undef printf
  25. int main(){
  26. SoftFloat one= av_int2sf(1, 0);
  27. SoftFloat sf1, sf2;
  28. double d1, d2;
  29. int i, j;
  30. av_log_level = AV_LOG_DEBUG;
  31. d1= 1;
  32. for(i= 0; i<10; i++){
  33. d1= 1/(d1+1);
  34. }
  35. printf("test1 double=%d\n", (int)(d1 * (1<<24)));
  36. sf1= one;
  37. for(i= 0; i<10; i++){
  38. sf1= av_div_sf(one, av_normalize_sf(av_add_sf(one, sf1)));
  39. }
  40. printf("test1 sf =%d\n", av_sf2int(sf1, 24));
  41. for(i= 0; i<100; i++){
  42. START_TIMER
  43. d1= i;
  44. d2= i/100.0;
  45. for(j= 0; j<1000; j++){
  46. d1= (d1+1)*d2;
  47. }
  48. STOP_TIMER("float add mul")
  49. }
  50. printf("test2 double=%d\n", (int)(d1 * (1<<24)));
  51. for(i= 0; i<100; i++){
  52. START_TIMER
  53. sf1= av_int2sf(i, 0);
  54. sf2= av_div_sf(av_int2sf(i, 2), av_int2sf(200, 3));
  55. for(j= 0; j<1000; j++){
  56. sf1= av_mul_sf(av_add_sf(sf1, one),sf2);
  57. }
  58. STOP_TIMER("softfloat add mul")
  59. }
  60. printf("test2 sf =%d (%d %d)\n", av_sf2int(sf1, 24), sf1.exp, sf1.mant);
  61. return 0;
  62. }