summaryrefslogtreecommitdiff
path: root/src/xine-engine/vo_scale.h
blob: 934da69e5e76970884fe9096d0a439929d6011f8 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
 * Copyright (C) 2000-2002 the xine project
 *
 * This file is part of xine, a free video player.
 *
 * xine is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * xine is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
 *
 * $Id: vo_scale.h,v 1.1 2002/08/15 03:12:27 miguelfreitas Exp $
 * 
 * vo_scale.h
 *
 * keeps video scaling information
 */

#ifndef HAVE_VO_SCALE_H
#define HAVE_VO_SCALE_H

#ifdef __cplusplus
extern "C" {
#endif

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

typedef struct {
  int x, y;
  int w, h;
} vo_scale_rect_t;

struct vo_scale_s {

  /* display anatomy */
  double             display_ratio;        /* given by visual parameter
					      from init function              */

  /* true if driver supports frame zooming */
  int                support_zoom;
  
  /* forces direct mapping between frame pixels and screen pixels */
  int                scaling_disabled;
  
  /* size / aspect ratio calculations */

  /* 
   * "delivered" size:
   * frame dimension / aspect as delivered by the decoder
   * used (among other things) to detect frame size changes
   * units: frame pixels
   */
  int                delivered_width;   
  int                delivered_height;     
  int                delivered_ratio_code;

  /* 
   * displayed part of delivered images,
   * taking zoom into account
   * units: frame pixels
   */
  int                displayed_xoffset;
  int                displayed_yoffset;
  int                displayed_width;
  int                displayed_height;
  double             zoom_factor_x, zoom_factor_y;

  /* 
   * "ideal" size :
   * delivered width/height corrected by aspect ratio and display_ratio
   * units: screen pixels
   */
  int                ideal_width, ideal_height;
  int                user_ratio;

  /*
   * "gui" size / offset:
   * what gui told us about where to display the video
   * units: screen pixels
   */
  int                gui_x, gui_y;
  int                gui_width, gui_height;
  int                gui_win_x, gui_win_y;
  
  /*
   * "output" size:
   *
   * this is finally the ideal size "fitted" into the
   * gui size while maintaining the aspect ratio
   * units: screen pixels
   */
  int                output_width;
  int                output_height;
  int                output_xoffset;
  int                output_yoffset;

  /* */
  int                force_redraw;
  

  /* gui callbacks */

  void              *user_data;
  void (*frame_output_cb) (void *user_data,
			   int video_width, int video_height,
			   int *dest_x, int *dest_y, 
			   int *dest_height, int *dest_width,
			   int *win_x, int *win_y);
  
  void (*dest_size_cb) (void *user_data,
			int video_width, int video_height, 
			int *dest_width, int *dest_height);

  /* borders */
  vo_scale_rect_t     border[4];
};

typedef struct vo_scale_s vo_scale_t; 


/*
 * convert delivered height/width to ideal width/height
 * taking into account aspect ratio and zoom factor
 */

void vo_scale_compute_ideal_size (vo_scale_t *this);


/*
 * make ideal width/height "fit" into the gui
 */

void vo_scale_compute_output_size (vo_scale_t *this);

/*
 * return true if a redraw is needed due resizing, zooming,
 * aspect ratio changing, etc.
 */

int vo_scale_redraw_needed (vo_scale_t *this);

/*
 *
 */
 
void vo_scale_translate_gui2video(vo_scale_t *this,
				 int x, int y,
				 int *vid_x, int *vid_y);

/*
 * Returns description of a given ratio code
 */

char *vo_scale_aspect_ratio_name(int a);

/* 
 * initialize rescaling struct
 */
 
void vo_scale_init(vo_scale_t *this, double display_ratio,
                  int support_zoom, int scaling_disabled );

#ifdef __cplusplus
}
#endif

#endif