forked from colin121/x264-dsp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdownsample.h
62 lines (58 loc) · 2.19 KB
/
downsample.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef DOWNSAMPLE_H
#define DOWNSAMPLE_H 1
#include <stddef.h>
#include <stdint.h>
#include "config.h"
#define DOWNSAMPLE_BILINEAR 1
#define DOWNSAMPLE_BICUBIC 2
// https://pytorch.org/vision/stable/generated/torchvision.transforms.Pad.html
#define PADDING_EDGE 1
#define PADDING_REFLECT 2
// matlab's imresize()
#define PADDING_SYMMETRIC 3
#if PADDING == PADDING_SYMMETRIC
#define PAD SYMMETRIC
#elif PADDING == PADDING_REFLECT
#define PAD REFLECT
#elif PADDING == PADDING_EDGE
#define PAD CLAMP
#endif
#define SYMMETRIC(input, min, max) \
do { \
__typeof__(input) _min = (min); \
__typeof__(input) _max = (max); \
__typeof__(input) _input = (input); \
if (_input < _min) \
_input = 2 * _min - _input - 1; \
if (_input > _max) \
_input = 2 * _max - _input + 1; \
(input) = _input; \
} while (0)
#define REFLECT(input, min, max) \
do { \
__typeof__(input) _min = (min); \
__typeof__(input) _max = (max); \
__typeof__(input) _input = (input); \
if (_input < _min) \
_input = 2 * _min - _input; \
if (_input > _max) \
_input = 2 * _max - _input; \
(input) = _input; \
} while (0)
#define CLAMP(input, min, max) \
do { \
__typeof__(input) _min = (min); \
__typeof__(input) _max = (max); \
__typeof__(input) _input = (input); \
if (_input < _min) \
_input = _min; \
if (_input > _max) \
_input = _max; \
(input) = _input; \
} while (0)
double cubic_hermite(double f_1, double f0, double f1, double f2, double t);
uint8_t sample_bicubic(uint8_t *src, size_t src_width, size_t src_height, double u, double v);
void resize(void *dst, const void *src, size_t dst_width, size_t dst_height);
void resize2(void *dst, const void *src, size_t dst_width, size_t dst_height);
void resize4(void *dst, const void *src, size_t dst_width, size_t dst_height);
#endif /* downsample.h */