FFmpeg
dcamath.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 foo86
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVCODEC_DCAMATH_H
22 #define AVCODEC_DCAMATH_H
23 
24 #include "libavutil/common.h"
25 #include "libavutil/intmath.h"
26 
27 static inline int32_t norm__(int64_t a, int bits)
28 {
29  if (bits > 0)
30  return (int32_t)((a + (INT64_C(1) << (bits - 1))) >> bits);
31  else
32  return (int32_t)a;
33 }
34 
35 static inline int32_t mul__(int32_t a, int32_t b, int bits)
36 {
37  return norm__((int64_t)a * b, bits);
38 }
39 
40 static inline int32_t norm13(int64_t a) { return norm__(a, 13); }
41 static inline int32_t norm16(int64_t a) { return norm__(a, 16); }
42 static inline int32_t norm20(int64_t a) { return norm__(a, 20); }
43 static inline int32_t norm21(int64_t a) { return norm__(a, 21); }
44 static inline int32_t norm23(int64_t a) { return norm__(a, 23); }
45 
46 static inline int32_t mul15(int32_t a, int32_t b) { return mul__(a, b, 15); }
47 static inline int32_t mul16(int32_t a, int32_t b) { return mul__(a, b, 16); }
48 static inline int32_t mul17(int32_t a, int32_t b) { return mul__(a, b, 17); }
49 static inline int32_t mul22(int32_t a, int32_t b) { return mul__(a, b, 22); }
50 static inline int32_t mul23(int32_t a, int32_t b) { return mul__(a, b, 23); }
51 static inline int32_t mul31(int32_t a, int32_t b) { return mul__(a, b, 31); }
52 static inline int32_t mul32(int32_t a, int32_t b) { return mul__(a, b, 32); }
53 
54 static inline int32_t clip23(int32_t a) { return av_clip_intp2(a, 23); }
55 
56 #endif
mul22
static int32_t mul22(int32_t a, int32_t b)
Definition: dcamath.h:49
norm13
static int32_t norm13(int64_t a)
Definition: dcamath.h:40
mul17
static int32_t mul17(int32_t a, int32_t b)
Definition: dcamath.h:48
norm16
static int32_t norm16(int64_t a)
Definition: dcamath.h:41
mul15
static int32_t mul15(int32_t a, int32_t b)
Definition: dcamath.h:46
b
#define b
Definition: input.c:34
mul23
static int32_t mul23(int32_t a, int32_t b)
Definition: dcamath.h:50
norm20
static int32_t norm20(int64_t a)
Definition: dcamath.h:42
mul31
static int32_t mul31(int32_t a, int32_t b)
Definition: dcamath.h:51
clip23
static int32_t clip23(int32_t a)
Definition: dcamath.h:54
bits
uint8_t bits
Definition: vp3data.h:141
mul16
static int32_t mul16(int32_t a, int32_t b)
Definition: dcamath.h:47
av_clip_intp2
#define av_clip_intp2
Definition: common.h:116
mul32
static int32_t mul32(int32_t a, int32_t b)
Definition: dcamath.h:52
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
norm21
static int32_t norm21(int64_t a)
Definition: dcamath.h:43
common.h
norm__
static int32_t norm__(int64_t a, int bits)
Definition: dcamath.h:27
norm23
static int32_t norm23(int64_t a)
Definition: dcamath.h:44
int32_t
int32_t
Definition: audioconvert.c:56
mul__
static int32_t mul__(int32_t a, int32_t b, int bits)
Definition: dcamath.h:35
intmath.h