1
/*****************************************************************
5
Copyright (c) 2005 by Burkhard Plaum - plaum@ipf.uni-stuttgart.de
7
http://gmerlin.sourceforge.net
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
18
*****************************************************************/
24
typedef struct gavl_video_scale_context_s gavl_video_scale_context_t;
26
typedef void (*gavl_video_scale_scanline_func)(gavl_video_scale_context_t*);
28
typedef float (*gavl_video_scale_get_weight)(gavl_video_options_t * opt, double t);
30
gavl_video_scale_get_weight gavl_video_scale_get_weight_func(gavl_video_options_t * opt,
37
gavl_video_scale_scanline_func scale_rgb_15;
38
gavl_video_scale_scanline_func scale_rgb_16;
39
gavl_video_scale_scanline_func scale_uint8_x_1;
40
gavl_video_scale_scanline_func scale_uint8_x_3;
41
gavl_video_scale_scanline_func scale_uint8_x_4;
42
gavl_video_scale_scanline_func scale_uint16_x_1;
43
gavl_video_scale_scanline_func scale_uint16_x_3;
44
gavl_video_scale_scanline_func scale_uint16_x_4;
45
gavl_video_scale_scanline_func scale_float_x_3;
46
gavl_video_scale_scanline_func scale_float_x_4;
48
/* Bits needed for the integer scaling coefficient */
53
} gavl_scale_func_tab_t;
57
gavl_scale_func_tab_t funcs_x;
58
gavl_scale_func_tab_t funcs_y;
59
gavl_scale_func_tab_t funcs_xy;
62
void gavl_init_scale_funcs_nearest_c(gavl_scale_funcs_t * tab);
64
void gavl_init_scale_funcs_bilinear_c(gavl_scale_funcs_t * tab);
66
void gavl_init_scale_funcs_quadratic_c(gavl_scale_funcs_t * tab);
68
void gavl_init_scale_funcs_bicubic_c(gavl_scale_funcs_t * tab);
70
void gavl_init_scale_funcs_generic_c(gavl_scale_funcs_t * tab);
73
void gavl_init_scale_funcs_mmxext(gavl_scale_funcs_t * tab,
74
gavl_scale_mode_t scale_mode,
75
int scale_x, int scale_y, int min_scanline_width);
76
void gavl_init_scale_funcs_mmx(gavl_scale_funcs_t * tab,
77
gavl_scale_mode_t scale_mode,
78
int scale_x, int scale_y, int min_scanline_width);
83
float fac_f; /* Scaling coefficient with high precision */
84
int fac_i; /* Scaling coefficient with lower precision */
85
} gavl_video_scale_factor_t;
89
int index; /* Index of the first row/column */
90
gavl_video_scale_factor_t * factor;
91
} gavl_video_scale_pixel_t;
97
int num_pixels; /* Number of pixels (rows/columns) in the output area */
98
gavl_video_scale_factor_t * factors;
99
gavl_video_scale_pixel_t * pixels;
100
int factors_per_pixel;
101
} gavl_video_scale_table_t;
103
void gavl_video_scale_table_init(gavl_video_scale_table_t * tab,
104
gavl_video_options_t * opt,
105
double src_off, double src_size,
109
void gavl_video_scale_table_init_int(gavl_video_scale_table_t * tab,
112
void gavl_video_scale_table_get_src_indices(gavl_video_scale_table_t * tab,
113
int * start, int * size);
115
void gavl_video_scale_table_shift_indices(gavl_video_scale_table_t * tab,
120
void gavl_video_scale_table_cleanup(gavl_video_scale_table_t * tab);
124
void gavl_video_scale_table_dump(gavl_video_scale_table_t * tab);
126
/* Data needed by the scaline function. */
130
/* Offsets and advances are ALWAYS in bytes */
131
int src_advance, dst_advance;
132
int src_offset, dst_offset;
133
} gavl_video_scale_offsets_t;
136
* Scale context is for one plane of one field.
137
* This means, that depending on the video format, we have 1 - 6 scale contexts.
140
struct gavl_video_scale_context_s
142
/* Data initialized at start */
143
gavl_video_scale_table_t table_h;
144
gavl_video_scale_table_t table_v;
145
gavl_video_scale_scanline_func func1;
146
gavl_video_scale_scanline_func func2;
148
gavl_video_scale_offsets_t offset1;
149
gavl_video_scale_offsets_t offset2;
152
gavl_rectangle_f_t src_rect;
153
gavl_rectangle_i_t dst_rect;
155
/* Number of filter taps */
158
/* Indices of source and destination planes inside the frame. Can be 0 for chroma channels of
159
packed YUV formats */
161
int src_frame_plane, dst_frame_plane;
163
int plane; /* Plane */
167
gavl_video_scale_offsets_t * offset;
169
/* Temporary buffer */
174
/* Size of temporary buffer in pixels */
180
/* Minimum and maximum values for clipping.
181
Values can be different for different components */
183
uint32_t min_values[4];
184
uint32_t max_values[4];
186
/* These are used by the generic scaler */
188
int64_t tmp[4]; /* For accumulating values */
193
/* Data changed during scaling */
202
int gavl_video_scale_context_init(gavl_video_scale_context_t*,
203
gavl_video_options_t * opt,
205
const gavl_video_format_t * input_format,
206
const gavl_video_format_t * output_format,
207
gavl_scale_funcs_t * funcs,
208
int src_field, int dst_field,
209
int src_fields, int dst_fields);
211
void gavl_video_scale_context_cleanup(gavl_video_scale_context_t * ctx);
213
void gavl_video_scale_context_scale(gavl_video_scale_context_t * ctx,
214
gavl_video_frame_t * src, gavl_video_frame_t * dst);
216
struct gavl_video_scaler_s
218
gavl_video_options_t opt;
220
/* a context is obtained with contexts[field][plane] */
221
gavl_video_scale_context_t contexts[2][GAVL_MAX_PLANES];
225
/* If src_fields > dst_fields, we deinterlace */
229
gavl_video_frame_t * src;
230
gavl_video_frame_t * dst;
232
gavl_video_frame_t * src_field;
233
gavl_video_frame_t * dst_field;
235
gavl_video_format_t src_format;
236
gavl_video_format_t dst_format;
238
gavl_rectangle_i_t dst_rect;
239
// gavl_rectangle_f_t src_rect;