oil 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/Rakefile +7 -3
- data/ext/oil/jpeg.c +25 -49
- data/ext/oil/oil.c +4 -3
- data/ext/oil/oil_libjpeg.c +104 -0
- data/ext/oil/oil_libjpeg.h +57 -0
- data/ext/oil/oil_libpng.c +161 -0
- data/ext/oil/oil_libpng.h +58 -0
- data/ext/oil/oil_resample.c +1012 -0
- data/ext/oil/oil_resample.h +149 -0
- data/ext/oil/png.c +22 -100
- data/lib/oil.rb +1 -1
- metadata +9 -6
- data/ext/oil/resample.c +0 -938
- data/ext/oil/resample.h +0 -119
data/ext/oil/resample.h
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright (c) 2014-2016 Timothy Elliott
|
3
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
* of this software and associated documentation files (the "Software"), to deal
|
5
|
-
* in the Software without restriction, including without limitation the rights
|
6
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
* copies of the Software, and to permit persons to whom the Software is
|
8
|
-
* furnished to do so, subject to the following conditions:
|
9
|
-
*
|
10
|
-
* The above copyright notice and this permission notice shall be included in
|
11
|
-
* all copies or substantial portions of the Software.
|
12
|
-
*
|
13
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
* THE SOFTWARE.
|
20
|
-
*/
|
21
|
-
|
22
|
-
#ifndef RESAMPLE_H
|
23
|
-
#define RESAMPLE_H
|
24
|
-
|
25
|
-
#include <stdint.h>
|
26
|
-
#include <stddef.h>
|
27
|
-
|
28
|
-
enum oil_colorspace {
|
29
|
-
OIL_CS_G = 0x0001,
|
30
|
-
OIL_CS_GA = 0x0002,
|
31
|
-
OIL_CS_RGB = 0x0003,
|
32
|
-
OIL_CS_RGBX = 0x0004,
|
33
|
-
OIL_CS_RGBA = 0x0104,
|
34
|
-
OIL_CS_CMYK = 0x0204,
|
35
|
-
};
|
36
|
-
#define CS_TO_CMP(x) (x&0xFF)
|
37
|
-
|
38
|
-
struct sl_rbuf {
|
39
|
-
uint32_t height; // number of scanlines that the ring buffer can hold
|
40
|
-
size_t length; // width in bytes of each scanline in the buffer
|
41
|
-
uint32_t count; // total no. of scanlines that have been fed in
|
42
|
-
uint16_t *buf; // buffer for the ring buffer
|
43
|
-
uint16_t **virt; // space to provide scanline pointers for scaling
|
44
|
-
};
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Struct to hold state for y-scaling.
|
48
|
-
*/
|
49
|
-
struct yscaler {
|
50
|
-
struct sl_rbuf rb; // ring buffer holding scanlines.
|
51
|
-
uint32_t in_height; // input image height.
|
52
|
-
uint32_t out_height; // output image height.
|
53
|
-
uint32_t width;
|
54
|
-
enum oil_colorspace cs;
|
55
|
-
uint32_t target; // where the ring buffer should be on next scaling.
|
56
|
-
float ty; // sub-pixel offset for next scaling.
|
57
|
-
};
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Initialize a yscaler struct. Calculates how large the scanline ring buffer
|
61
|
-
* will need to be and allocates it.
|
62
|
-
*/
|
63
|
-
int yscaler_init(struct yscaler *ys, uint32_t in_height, uint32_t out_height,
|
64
|
-
uint32_t width, enum oil_colorspace cs);
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Free a yscaler struct, including the ring buffer.
|
68
|
-
*/
|
69
|
-
void yscaler_free(struct yscaler *ys);
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Get a pointer to the next scanline to be filled in the ring buffer. Returns
|
73
|
-
* null if no more scanlines are needed to perform scaling.
|
74
|
-
*/
|
75
|
-
uint16_t *yscaler_next(struct yscaler *ys);
|
76
|
-
|
77
|
-
/**
|
78
|
-
* Scale the buffered contents of the yscaler to produce the next scaled output
|
79
|
-
* scanline.
|
80
|
-
*
|
81
|
-
* Scaled scanline will be written to the out parameter.
|
82
|
-
* The width parameter is the nuber of samples in each scanline.
|
83
|
-
* The cmp parameter is the number of components per sample (3 for RGB).
|
84
|
-
* The pos parameter is the position of the output scanline.
|
85
|
-
*/
|
86
|
-
int yscaler_scale(struct yscaler *ys, uint8_t *out, uint32_t pos);
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Struct to hold state for x-scaling.
|
90
|
-
*/
|
91
|
-
struct xscaler {
|
92
|
-
uint16_t *psl_buf;
|
93
|
-
uint16_t *psl_pos0;
|
94
|
-
size_t psl_offset;
|
95
|
-
uint32_t width_in;
|
96
|
-
uint32_t width_out;
|
97
|
-
enum oil_colorspace cs;
|
98
|
-
};
|
99
|
-
|
100
|
-
struct preprocess_xscaler {
|
101
|
-
struct xscaler xs;
|
102
|
-
uint32_t width_in;
|
103
|
-
enum oil_colorspace cs_in;
|
104
|
-
uint32_t scale_factor;
|
105
|
-
};
|
106
|
-
|
107
|
-
int preprocess_xscaler_init(struct preprocess_xscaler *pxs, uint32_t width_in,
|
108
|
-
uint32_t width_out, enum oil_colorspace cs_in);
|
109
|
-
void preprocess_xscaler_scale(struct preprocess_xscaler *pxs, uint8_t *in,
|
110
|
-
uint16_t *out);
|
111
|
-
void preprocess_xscaler_free(struct preprocess_xscaler *pxs);
|
112
|
-
|
113
|
-
/**
|
114
|
-
* Utility helpers.
|
115
|
-
*/
|
116
|
-
void fix_ratio(uint32_t src_width, uint32_t src_height, uint32_t *out_width,
|
117
|
-
uint32_t *out_height);
|
118
|
-
|
119
|
-
#endif
|