misc/winutils/include/libavutil/mathematics.h
author sheepluva
Fri, 21 Nov 2014 02:03:19 +0100
changeset 10523 00ac079fa51f
parent 7813 7ac83d79b897
permissions -rw-r--r--
fix some nasty rendering issues reported by Nexia - thanks a lot!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7813
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     1
/*
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     2
 * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at>
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     3
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     4
 * This file is part of Libav.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     5
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     6
 * Libav is free software; you can redistribute it and/or
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     7
 * modify it under the terms of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     8
 * License as published by the Free Software Foundation; either
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
     9
 * version 2.1 of the License, or (at your option) any later version.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    10
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    11
 * Libav is distributed in the hope that it will be useful,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    14
 * Lesser General Public License for more details.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    15
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    16
 * You should have received a copy of the GNU Lesser General Public
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    17
 * License along with Libav; if not, write to the Free Software
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    19
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    20
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    21
#ifndef AVUTIL_MATHEMATICS_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    22
#define AVUTIL_MATHEMATICS_H
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    23
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    24
#include <stdint.h>
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    25
#include <math.h>
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    26
#include "attributes.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    27
#include "rational.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    28
#include "intfloat.h"
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    29
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    30
#ifndef M_LOG2_10
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    31
#define M_LOG2_10      3.32192809488736234787  /* log_2 10 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    32
#endif
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    33
#ifndef M_PHI
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    34
#define M_PHI          1.61803398874989484820   /* phi / golden ratio */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    35
#endif
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    36
#ifndef NAN
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    37
#define NAN            av_int2float(0x7fc00000)
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    38
#endif
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    39
#ifndef INFINITY
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    40
#define INFINITY       av_int2float(0x7f800000)
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    41
#endif
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    42
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    43
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    44
 * @addtogroup lavu_math
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    45
 * @{
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    46
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    47
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    48
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    49
enum AVRounding {
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    50
    AV_ROUND_ZERO     = 0, ///< Round toward zero.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    51
    AV_ROUND_INF      = 1, ///< Round away from zero.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    52
    AV_ROUND_DOWN     = 2, ///< Round toward -infinity.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    53
    AV_ROUND_UP       = 3, ///< Round toward +infinity.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    54
    AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    55
};
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    56
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    57
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    58
 * Return the greatest common divisor of a and b.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    59
 * If both a and b are 0 or either or both are <0 then behavior is
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    60
 * undefined.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    61
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    62
int64_t av_const av_gcd(int64_t a, int64_t b);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    63
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    64
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    65
 * Rescale a 64-bit integer with rounding to nearest.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    66
 * A simple a*b/c isn't possible as it can overflow.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    67
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    68
int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    69
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    70
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    71
 * Rescale a 64-bit integer with specified rounding.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    72
 * A simple a*b/c isn't possible as it can overflow.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    73
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    74
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    75
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    76
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    77
 * Rescale a 64-bit integer by 2 rational numbers.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    78
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    79
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    80
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    81
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    82
 * Rescale a 64-bit integer by 2 rational numbers with specified rounding.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    83
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    84
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    85
                         enum AVRounding) av_const;
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    86
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    87
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    88
 * Compare 2 timestamps each in its own timebases.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    89
 * The result of the function is undefined if one of the timestamps
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    90
 * is outside the int64_t range when represented in the others timebase.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    91
 * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    92
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    93
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    94
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    95
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    96
 * Compare 2 integers modulo mod.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    97
 * That is we compare integers a and b for which only the least
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    98
 * significant log2(mod) bits are known.
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
    99
 *
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   100
 * @param mod must be a power of 2
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   101
 * @return a negative value if a is smaller than b
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   102
 *         a positive value if a is greater than b
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   103
 *         0                if a equals          b
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   104
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   105
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   106
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   107
/**
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   108
 * @}
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   109
 */
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   110
7ac83d79b897 support video recording on windows with automation and headers
koda
parents:
diff changeset
   111
#endif /* AVUTIL_MATHEMATICS_H */