static void resize(int x,int y){ // simple orthogonal projection for 0-1;0-1 static const float matrix[16] = { 2, 0, 0, 0, 0, -2, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1, }; mp_msg(MSGT_VO,MSGL_V,"[gl_tiled] Resize: %dx%d\n",x,y); if(aspect_scaling()) { glClear(GL_COLOR_BUFFER_BIT); aspect(&x, &y, A_WINZOOM); panscan_calc_windowed(); x += vo_panscan_x; y += vo_panscan_y; glViewport( (vo_dwidth-x)/2, (vo_dheight-y)/2, x, y); } else { //aspect(x, y, A_NOZOOM); if (WinID >= 0) { int left = 0, top = 0, w = x, h = y; geometry(&left, &top, &w, &h, vo_dwidth, vo_dheight); top = y - h - top; glViewport(left, top, w, h); } else glViewport( 0, 0, x, y ); } glLoadMatrixf(matrix); }
static void resize(int x,int y){ // simple orthogonal projection for 0-image_width;0-image_height float matrix[16] = { 2.0/image_width, 0, 0, 0, 0, -2.0/image_height, 0, 0, 0, 0, 0, 0, -1, 1, 0, 1 }; mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); if (WinID >= 0) { int left = 0, top = 0, w = x, h = y; geometry(&left, &top, &w, &h, vo_dwidth, vo_dheight); top = y - h - top; mpglViewport(left, top, w, h); } else mpglViewport( 0, 0, x, y ); mpglMatrixMode(GL_PROJECTION); ass_border_x = ass_border_y = 0; if (aspect_scaling() && use_aspect) { int new_w, new_h; GLdouble scale_x, scale_y; aspect(&new_w, &new_h, A_WINZOOM); panscan_calc_windowed(); new_w += vo_panscan_x; new_h += vo_panscan_y; scale_x = (GLdouble)new_w / (GLdouble)x; scale_y = (GLdouble)new_h / (GLdouble)y; matrix[0] *= scale_x; matrix[12] *= scale_x; matrix[5] *= scale_y; matrix[13] *= scale_y; ass_border_x = (vo_dwidth - new_w) / 2; ass_border_y = (vo_dheight - new_h) / 2; } mpglLoadMatrixf(matrix); mpglMatrixMode(GL_MODELVIEW); mpglLoadIdentity(); if (!scaled_osd) { #ifdef CONFIG_FREETYPE // adjust font size to display size force_load_font = 1; #endif vo_osd_changed(OSDTYPE_OSD); } mpglClear(GL_COLOR_BUFFER_BIT); redraw(); }
static void resize(int x,int y){ mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); if (WinID >= 0) { int top = 0, left = 0, w = x, h = y; geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight); Viewport(top, left, w, h); } else Viewport( 0, 0, x, y ); MatrixMode(GL_PROJECTION); LoadIdentity(); ass_border_x = ass_border_y = 0; if (aspect_scaling() && use_aspect) { int new_w, new_h; GLdouble scale_x, scale_y; aspect(&new_w, &new_h, A_WINZOOM); panscan_calc_windowed(); new_w += vo_panscan_x; new_h += vo_panscan_y; scale_x = (GLdouble)new_w / (GLdouble)x; scale_y = (GLdouble)new_h / (GLdouble)y; Scaled(scale_x, scale_y, 1); ass_border_x = (vo_dwidth - new_w) / 2; ass_border_y = (vo_dheight - new_h) / 2; } Ortho(0, image_width, image_height, 0, -1,1); MatrixMode(GL_MODELVIEW); LoadIdentity(); if (!scaled_osd) { #ifdef CONFIG_FREETYPE // adjust font size to display size force_load_font = 1; #endif vo_osd_changed(OSDTYPE_OSD); } Clear(GL_COLOR_BUFFER_BIT); redraw(); }
/** * Calculate the appropriate source and destination rectangle to * get a correctly scaled picture, including pan-scan. * Can be extended to take future cropping support into account. * * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL * \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires, * may be NULL and only left and top are currently valid. */ void calc_src_dst_rects(int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop) { static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; int scaled_width = 0; int scaled_height = 0; if (!crop) crop = &no_crop; src_width -= crop->left + crop->right; src_height -= crop->top + crop->bottom; if (src_width < 2) src_width = 2; if (src_height < 2) src_height = 2; dst->left = 0; dst->right = vo_dwidth; dst->top = 0; dst->bottom = vo_dheight; src->left = 0; src->right = src_width; src->top = 0; src->bottom = src_height; if (borders) { borders->left = 0; borders->top = 0; } if (aspect_scaling()) { aspect(&scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(); scaled_width += vo_panscan_x; scaled_height += vo_panscan_y; if (borders) { borders->left = (vo_dwidth - scaled_width ) / 2; borders->top = (vo_dheight - scaled_height) / 2; } src_dst_split_scaling(src_width, vo_dwidth, scaled_width, &src->left, &src->right, &dst->left, &dst->right); src_dst_split_scaling(src_height, vo_dheight, scaled_height, &src->top, &src->bottom, &dst->top, &dst->bottom); } src->left += crop->left; src->right += crop->left; src->top += crop->top; src->bottom += crop->top; src->width = src->right - src->left; src->height = src->bottom - src->top; dst->width = dst->right - dst->left; dst->height = dst->bottom - dst->top; }
struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11, struct mp_fifo *key_fifo, struct input_ctx *input_ctx) { char **vo_list = opts->video_driver_list; int i; struct vo *vo = talloc_ptrtype(NULL, vo); struct vo initial_values = { .opts = opts, .x11 = x11, .key_fifo = key_fifo, .input_ctx = input_ctx, .event_fd = -1, .registered_fd = -1, }; // first try the preferred drivers, with their optional subdevice param: if (vo_list && vo_list[0]) while (vo_list[0][0]) { char *name = strdup(vo_list[0]); vo_subdevice = strchr(name,':'); if (!strcmp(name, "pgm")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The pgm video output driver has been replaced by -vo pnm:pgmyuv.\n"); if (!strcmp(name, "md5")) mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "The md5 video output driver has been replaced by -vo md5sum.\n"); if (vo_subdevice) { vo_subdevice[0] = 0; ++vo_subdevice; } for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; const vo_info_t *info = video_driver->info; if (!strcmp(info->short_name, name)) { // name matches, try it *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) { free(name); return vo; // success! } talloc_free_children(vo); } } // continue... free(name); ++vo_list; if (!(vo_list[0])) return NULL; // do NOT fallback to others } // now try the rest... vo_subdevice = NULL; for (i = 0; video_out_drivers[i]; i++) { const struct vo_driver *video_driver = video_out_drivers[i]; *vo = initial_values; vo->driver = video_driver; if (!vo_preinit(vo, vo_subdevice)) return vo; // success! talloc_free_children(vo); } free(vo); return NULL; } static int event_fd_callback(void *ctx, int fd) { struct vo *vo = ctx; vo_check_events(vo); return MP_INPUT_NOTHING; } int vo_config(struct vo *vo, uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { struct MPOpts *opts = vo->opts; panscan_init(vo); aspect_save_orig(vo, width, height); aspect_save_prescale(vo, d_width, d_height); if (vo_control(vo, VOCTRL_UPDATE_SCREENINFO, NULL) == VO_TRUE) { aspect(vo, &d_width, &d_height, A_NOZOOM); vo->dx = (int)(opts->vo_screenwidth - d_width) / 2; vo->dy = (int)(opts->vo_screenheight - d_height) / 2; geometry(&vo->dx, &vo->dy, &d_width, &d_height, opts->vo_screenwidth, opts->vo_screenheight); geometry_xy_changed |= xinerama_screen >= 0; vo->dx += xinerama_x; vo->dy += xinerama_y; vo->dwidth = d_width; vo->dheight = d_height; } int ret = vo->driver->config(vo, width, height, d_width, d_height, flags, title, format); vo->config_ok = (ret == 0); vo->config_count += vo->config_ok; if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) { mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback, NULL, vo); vo->registered_fd = vo->event_fd; } return ret; } /** * \brief lookup an integer in a table, table must have 0 as the last key * \param key key to search for * \result translation corresponding to key or "to" value of last mapping * if not found. */ int lookup_keymap_table(const struct mp_keymap *map, int key) { while (map->from && map->from != key) map++; return map->to; } /** * \brief helper function for the kind of panscan-scaling that needs a source * and destination rectangle like Direct3D and VDPAU */ static void src_dst_split_scaling(int src_size, int dst_size, int scaled_src_size, int *src_start, int *src_end, int *dst_start, int *dst_end) { if (scaled_src_size > dst_size) { int border = src_size * (scaled_src_size - dst_size) / scaled_src_size; // round to a multiple of 2, this is at least needed for vo_direct3d and ATI cards border = (border / 2 + 1) & ~1; *src_start = border; *src_end = src_size - border; *dst_start = 0; *dst_end = dst_size; } else { *src_start = 0; *src_end = src_size; *dst_start = (dst_size - scaled_src_size) / 2; *dst_end = *dst_start + scaled_src_size; } } /** * Calculate the appropriate source and destination rectangle to * get a correctly scaled picture, including pan-scan. * Can be extended to take future cropping support into account. * * \param crop specifies the cropping border size in the left, right, top and bottom members, may be NULL * \param borders the border values as e.g. EOSD (ASS) and properly placed DVD highlight support requires, * may be NULL and only left and top are currently valid. */ void calc_src_dst_rects(struct vo *vo, int src_width, int src_height, struct vo_rect *src, struct vo_rect *dst, struct vo_rect *borders, const struct vo_rect *crop) { static const struct vo_rect no_crop = {0, 0, 0, 0, 0, 0}; int scaled_width = 0; int scaled_height = 0; if (!crop) crop = &no_crop; src_width -= crop->left + crop->right; src_height -= crop->top + crop->bottom; if (src_width < 2) src_width = 2; if (src_height < 2) src_height = 2; dst->left = 0; dst->right = vo->dwidth; dst->top = 0; dst->bottom = vo->dheight; src->left = 0; src->right = src_width; src->top = 0; src->bottom = src_height; if (borders) { borders->left = 0; borders->top = 0; } if (aspect_scaling()) { aspect(vo, &scaled_width, &scaled_height, A_WINZOOM); panscan_calc_windowed(vo); scaled_width += vo->panscan_x; scaled_height += vo->panscan_y; if (borders) { borders->left = (vo->dwidth - scaled_width ) / 2; borders->top = (vo->dheight - scaled_height) / 2; } src_dst_split_scaling(src_width, vo->dwidth, scaled_width, &src->left, &src->right, &dst->left, &dst->right); src_dst_split_scaling(src_height, vo->dheight, scaled_height, &src->top, &src->bottom, &dst->top, &dst->bottom); } src->left += crop->left; src->right += crop->left; src->top += crop->top; src->bottom += crop->top; src->width = src->right - src->left; src->height = src->bottom - src->top; dst->width = dst->right - dst->left; dst->height = dst->bottom - dst->top; } /** * Generates a mouse movement message if those are enable and sends it * to the "main" MPlayer. * * \param posx new x position of mouse * \param posy new y position of mouse */ void vo_mouse_movement(struct vo *vo, int posx, int posy) { char cmd_str[40]; if (!enable_mouse_movements) return; snprintf(cmd_str, sizeof(cmd_str), "set_mouse_pos %i %i", posx, posy); mp_input_queue_cmd(vo->input_ctx, mp_input_parse_cmd(cmd_str)); }