aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Leppkes <h.leppkes@gmail.com>2016-01-02 12:51:26 +0100
committerHendrik Leppkes <h.leppkes@gmail.com>2016-01-02 12:53:14 +0100
commita51c2fcdc15dd37a2d95265a5b74d522b0b0b232 (patch)
tree50f73d0d812f698e86aa62a63b702e77293d0bb5
parentf299d8d9f283453cd7671bd174cfdc81503d5e5f (diff)
parent85990140e7302d1e7fcc9fc0eea316178c19fe03 (diff)
downloadffmpeg-a51c2fcdc15dd37a2d95265a5b74d522b0b0b232.tar.gz
Merge commit '85990140e7302d1e7fcc9fc0eea316178c19fe03'
* commit '85990140e7302d1e7fcc9fc0eea316178c19fe03': dca: Add math helpers. Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
-rw-r--r--libavcodec/dcamath.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/libavcodec/dcamath.h b/libavcodec/dcamath.h
new file mode 100644
index 0000000000..06dc43279b
--- /dev/null
+++ b/libavcodec/dcamath.h
@@ -0,0 +1,42 @@
+/*
+ * 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 "libavutil/common.h"
+
+
+// clip a signed integer into the (-2^23), (2^23-1) range
+static inline int dca_clip23(int a)
+{
+ return av_clip_intp2(a, 23);
+}
+
+static inline int32_t dca_norm(int64_t a, int bits)
+{
+ if (bits > 0)
+ return (int32_t)((a + (INT64_C(1) << (bits - 1))) >> bits);
+ else
+ return (int32_t)a;
+}
+
+static inline int64_t dca_round(int64_t a, int bits)
+{
+ if (bits > 0)
+ return (a + (INT64_C(1) << (bits - 1))) & ~((INT64_C(1) << bits) - 1);
+ else
+ return a;
+}