xine-lib: xine-lib-1.2.13/include/xine/vo_scale.h Source File

xine-lib 1.2.13-20230125hg15249

vo_scale.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2020 the xine project
3 *
4 * This file is part of xine, a free video player.
5 *
6 * xine is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * xine 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 *
20 * vo_scale.h
21 *
22 * keeps video scaling information
23 */
24
25#ifndef HAVE_VO_SCALE_H
26#define HAVE_VO_SCALE_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <xine/configfile.h>
33
34 typedef struct {
35 int x, y;
36 int w, h;
37} vo_scale_rect_t;
38
39 struct vo_scale_s {
40
41 /* true if driver supports frame zooming */
42 int support_zoom;
43
44 /* forces direct mapping between frame pixels and screen pixels */
45 int scaling_disabled;
46
47 /* size / aspect ratio calculations */
48
49 /*
50 * "delivered" size:
51 * frame dimension / aspect as delivered by the decoder
52 * used (among other things) to detect frame size changes
53 * units: frame pixels
54 */
55 int delivered_width;
56 int delivered_height;
57 double delivered_ratio;
58
59 /*
60 * required cropping:
61 * units: frame pixels
62 */
63 int crop_left;
64 int crop_right;
65 int crop_top;
66 int crop_bottom;
67
68 /*
69 * displayed part of delivered images,
70 * taking zoom into account
71 * units: frame pixels
72 */
73 int displayed_xoffset;
74 int displayed_yoffset;
75 int displayed_width;
76 int displayed_height;
77 double zoom_factor_x, zoom_factor_y;
78
79 /*
80 * user's aspect selection
81 */
82 int user_ratio;
83
84 /*
85 * "gui" size / offset:
86 * what gui told us about where to display the video
87 * units: screen pixels
88 */
89 int gui_x, gui_y;
90 int gui_width, gui_height;
91 int gui_win_x, gui_win_y;
92
93 /* */
94 int force_redraw;
95
96 /*
97 * video + display pixel aspect
98 * One pixel of height 1 has this width
99 * This may be corrected by the driver in order to fit the video seamlessly
100 */
101 double gui_pixel_aspect;
102 double video_pixel_aspect;
103
104 /*
105 * "output" size:
106 *
107 * this is finally the ideal size "fitted" into the
108 * gui size while maintaining the aspect ratio
109 * units: screen pixels
110 */
111 int output_width;
112 int output_height;
113 int output_xoffset;
114 int output_yoffset;
115
116
117 /* gui callbacks */
118
119 void *user_data;
120 void (*frame_output_cb) (void *user_data,
121 int video_width, int video_height,
122 double video_pixel_aspect,
123 int *dest_x, int *dest_y,
124 int *dest_width, int *dest_height,
125 double *dest_pixel_aspect,
126 int *win_x, int *win_y);
127
128 void (*dest_size_cb) (void *user_data,
129 int video_width, int video_height,
130 double video_pixel_aspect,
131 int *dest_width, int *dest_height,
132 double *dest_pixel_aspect);
133
134 /* borders */
135 vo_scale_rect_t border[4];
136
137 /*
138 * border ratios to determine image position in the
139 * viewport; these are set by user config
140 */
141 double output_horizontal_position;
142 double output_vertical_position;
143
144};
145
146 typedef struct vo_scale_s vo_scale_t;
147
148
149/*
150 * convert delivered height/width to ideal width/height
151 * taking into account aspect ratio and zoom factor
152 */
153
154void _x_vo_scale_compute_ideal_size (vo_scale_t *self) XINE_PROTECTED;
155
156
157/*
158 * make ideal width/height "fit" into the gui
159 */
160
161void _x_vo_scale_compute_output_size (vo_scale_t *self) XINE_PROTECTED;
162
163/*
164 * return true if a redraw is needed due resizing, zooming,
165 * aspect ratio changing, etc.
166 */
167
168int _x_vo_scale_redraw_needed (vo_scale_t *self) XINE_PROTECTED;
169
170/*
171 *
172 */
173
174void _x_vo_scale_translate_gui2video(vo_scale_t *self,
175 int x, int y,
176 int *vid_x, int *vid_y) XINE_PROTECTED;
177
178 typedef struct {
179 struct {
180 int x0, y0, x1, y1;
181 } in, out;
182} vo_scale_map_t;
183
184 typedef enum {
185 VO_SCALE_MAP_OK = 0,
186 VO_SCALE_MAP_OUTSIDE,
187 VO_SCALE_MAP_WRONG_ARGS,
188 VO_SCALE_MAP_ERROR
189} vo_scale_map_res_t;
190
199 vo_scale_map_res_t _x_vo_scale_map (vo_scale_t *self, vo_scale_map_t *map) XINE_PROTECTED;
200
201/*
202 * Returns description of a given ratio code
203 */
204
205extern const char _x_vo_scale_aspect_ratio_name_table[][8] XINE_PROTECTED;
206
207/*
208 * initialize rescaling struct
209 */
210
211void _x_vo_scale_init(vo_scale_t *self, int support_zoom,
212 int scaling_disabled, config_values_t *config ) XINE_PROTECTED;
213
214void _x_vo_scale_cleanup(vo_scale_t *self, config_values_t *config) XINE_PROTECTED;
215
216#ifdef __cplusplus
217}
218#endif
219
220#endif
configfile.h
XINE_PROTECTED
#define XINE_PROTECTED
Definition attributes.h:75
config_values_s
Definition configfile.h:83
vo_scale_map_t
Definition vo_scale.h:178
vo_scale_map_t::x0
int x0
Definition vo_scale.h:180
vo_scale_rect_t
Definition vo_scale.h:34
vo_scale_rect_t::h
int h
Definition vo_scale.h:36
vo_scale_rect_t::x
int x
Definition vo_scale.h:35
vo_scale_s
Definition vo_scale.h:39
vo_scale_s::displayed_width
int displayed_width
Definition vo_scale.h:75
vo_scale_s::zoom_factor_x
double zoom_factor_x
Definition vo_scale.h:77
vo_scale_s::displayed_height
int displayed_height
Definition vo_scale.h:76
vo_scale_s::border
vo_scale_rect_t border[4]
Definition vo_scale.h:135
vo_scale_s::displayed_yoffset
int displayed_yoffset
Definition vo_scale.h:74
vo_scale_s::crop_left
int crop_left
Definition vo_scale.h:63
vo_scale_s::user_data
void * user_data
Definition vo_scale.h:119
vo_scale_s::output_width
int output_width
Definition vo_scale.h:111
vo_scale_s::gui_win_y
int gui_win_y
Definition vo_scale.h:91
vo_scale_s::displayed_xoffset
int displayed_xoffset
Definition vo_scale.h:73
vo_scale_s::scaling_disabled
int scaling_disabled
Definition vo_scale.h:45
vo_scale_s::dest_size_cb
void(* dest_size_cb)(void *user_data, int video_width, int video_height, double video_pixel_aspect, int *dest_width, int *dest_height, double *dest_pixel_aspect)
Definition vo_scale.h:128
vo_scale_s::output_horizontal_position
double output_horizontal_position
Definition vo_scale.h:141
vo_scale_s::video_pixel_aspect
double video_pixel_aspect
Definition vo_scale.h:102
vo_scale_s::gui_pixel_aspect
double gui_pixel_aspect
Definition vo_scale.h:101
vo_scale_s::crop_right
int crop_right
Definition vo_scale.h:64
vo_scale_s::crop_bottom
int crop_bottom
Definition vo_scale.h:66
vo_scale_s::force_redraw
int force_redraw
Definition vo_scale.h:94
vo_scale_s::gui_width
int gui_width
Definition vo_scale.h:90
vo_scale_s::output_yoffset
int output_yoffset
Definition vo_scale.h:114
vo_scale_s::output_vertical_position
double output_vertical_position
Definition vo_scale.h:142
vo_scale_s::delivered_ratio
double delivered_ratio
Definition vo_scale.h:57
vo_scale_s::delivered_height
int delivered_height
Definition vo_scale.h:56
vo_scale_s::gui_win_x
int gui_win_x
Definition vo_scale.h:91
vo_scale_s::gui_x
int gui_x
Definition vo_scale.h:89
vo_scale_s::support_zoom
int support_zoom
Definition vo_scale.h:42
vo_scale_s::gui_y
int gui_y
Definition vo_scale.h:89
vo_scale_s::user_ratio
int user_ratio
Definition vo_scale.h:82
vo_scale_s::gui_height
int gui_height
Definition vo_scale.h:90
vo_scale_s::output_height
int output_height
Definition vo_scale.h:112
vo_scale_s::frame_output_cb
void(* frame_output_cb)(void *user_data, int video_width, int video_height, double video_pixel_aspect, int *dest_x, int *dest_y, int *dest_width, int *dest_height, double *dest_pixel_aspect, int *win_x, int *win_y)
Definition vo_scale.h:120
vo_scale_s::crop_top
int crop_top
Definition vo_scale.h:65
vo_scale_s::delivered_width
int delivered_width
Definition vo_scale.h:55
vo_scale_s::zoom_factor_y
double zoom_factor_y
Definition vo_scale.h:77
vo_scale_s::output_xoffset
int output_xoffset
Definition vo_scale.h:113
_x_vo_scale_translate_gui2video
void _x_vo_scale_translate_gui2video(vo_scale_t *self, int x, int y, int *vid_x, int *vid_y)
Definition vo_scale.c:312
_x_vo_scale_aspect_ratio_name_table
const char _x_vo_scale_aspect_ratio_name_table[][8]
Definition vo_scale.c:419
_x_vo_scale_compute_ideal_size
void _x_vo_scale_compute_ideal_size(vo_scale_t *self)
Definition vo_scale.c:47
_x_vo_scale_compute_output_size
void _x_vo_scale_compute_output_size(vo_scale_t *self)
Definition vo_scale.c:113
_x_vo_scale_cleanup
void _x_vo_scale_cleanup(vo_scale_t *self, config_values_t *config)
Definition vo_scale.c:465
vo_scale_map_res_t
vo_scale_map_res_t
Definition vo_scale.h:184
VO_SCALE_MAP_WRONG_ARGS
@ VO_SCALE_MAP_WRONG_ARGS
Definition vo_scale.h:187
VO_SCALE_MAP_OK
@ VO_SCALE_MAP_OK
Definition vo_scale.h:185
VO_SCALE_MAP_OUTSIDE
@ VO_SCALE_MAP_OUTSIDE
Definition vo_scale.h:186
VO_SCALE_MAP_ERROR
@ VO_SCALE_MAP_ERROR
Definition vo_scale.h:188
_x_vo_scale_redraw_needed
int _x_vo_scale_redraw_needed(vo_scale_t *self)
Definition vo_scale.c:266
_x_vo_scale_init
void _x_vo_scale_init(vo_scale_t *self, int support_zoom, int scaling_disabled, config_values_t *config)
Definition vo_scale.c:469
_x_vo_scale_map
vo_scale_map_res_t _x_vo_scale_map(vo_scale_t *self, vo_scale_map_t *map)
Map a rectangle to video out window.
Definition vo_scale.c:342