~ubuntu-branches/ubuntu/wily/mpv/wily

« back to all changes in this revision

Viewing changes to video/out/vo.c

  • Committer: Package Import Robot
  • Author(s): Alessandro Ghedini
  • Date: 2013-10-16 12:38:59 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20131016123859-wj70wr6n3mzimx3e
Tags: 0.2.0-1
* New upstream release
* Install sample configuration files as examples
* Enable Lua scripting support
* Remove copyright for talloc (not used anymore)
* Update installed docs list
* Update 01_spelling.patch
* Enable VAAPI support

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
extern struct vo_driver video_out_direct3d_shaders;
62
62
extern struct vo_driver video_out_sdl;
63
63
extern struct vo_driver video_out_corevideo;
 
64
extern struct vo_driver video_out_vaapi;
 
65
extern struct vo_driver video_out_wayland;
64
66
 
65
67
const struct vo_driver *video_out_drivers[] =
66
68
{
86
88
#ifdef CONFIG_GL
87
89
        &video_out_opengl_old,
88
90
#endif
 
91
#if CONFIG_VAAPI
 
92
        &video_out_vaapi,
 
93
#endif
89
94
#ifdef CONFIG_X11
90
95
        &video_out_x11,
91
96
#endif
101
106
#ifdef CONFIG_GL
102
107
        &video_out_opengl_hq,
103
108
#endif
 
109
#ifdef CONFIG_WAYLAND
 
110
        &video_out_wayland,
 
111
#endif
104
112
        NULL
105
113
};
106
114
 
194
202
 
195
203
int vo_redraw_frame(struct vo *vo)
196
204
{
197
 
    if (!vo->config_ok || !vo->hasframe)
 
205
    if (!vo->config_ok)
198
206
        return -1;
199
207
    if (vo_control(vo, VOCTRL_REDRAW_FRAME, NULL) == true) {
200
208
        vo->want_redraw = false;
206
214
 
207
215
bool vo_get_want_redraw(struct vo *vo)
208
216
{
209
 
    if (!vo->config_ok || !vo->hasframe)
 
217
    if (!vo->config_ok)
210
218
        return false;
211
219
    return vo->want_redraw;
212
220
}
399
407
    vo->dwidth = d_width;
400
408
    vo->dheight = d_height;
401
409
 
 
410
    talloc_free(vo->params);
 
411
    vo->params = NULL;
 
412
 
402
413
    struct mp_image_params p2 = *params;
403
 
    p2.d_w = vo->aspdat.prew;
404
 
    p2.d_h = vo->aspdat.preh;
405
414
 
406
415
    int ret;
407
416
    if (vo->driver->reconfig) {
414
423
    }
415
424
    vo->config_ok = (ret >= 0);
416
425
    vo->config_count += vo->config_ok;
 
426
    if (vo->config_ok)
 
427
        vo->params = talloc_memdup(vo, &p2, sizeof(p2));
417
428
    if (vo->registered_fd == -1 && vo->event_fd != -1 && vo->config_ok) {
418
429
        mp_input_add_key_fd(vo->input_ctx, vo->event_fd, 1, event_fd_callback,
419
430
                            NULL, vo);
428
439
        struct mp_csp_details csp;
429
440
        if (vo_control(vo, VOCTRL_GET_YUV_COLORSPACE, &csp) > 0) {
430
441
            csp.levels_in = params->colorlevels;
 
442
            csp.levels_out = params->outputlevels;
431
443
            csp.format = params->colorspace;
432
444
            vo_control(vo, VOCTRL_SET_YUV_COLORSPACE, &csp);
433
445
        }
483
495
#define VID_SRC_ROUND_UP(x) (((x) + 1) & ~1)
484
496
 
485
497
static void src_dst_split_scaling(int src_size, int dst_size,
486
 
                                  int scaled_src_size,
 
498
                                  int scaled_src_size, bool unscaled,
 
499
                                  float zoom, float align, float pan,
487
500
                                  int *src_start, int *src_end,
488
501
                                  int *dst_start, int *dst_end,
489
502
                                  int *osd_margin_a, int *osd_margin_b)
490
503
{
 
504
    if (unscaled)
 
505
        scaled_src_size = src_size;
 
506
 
 
507
    scaled_src_size += zoom * src_size;
 
508
    align = (align + 1) / 2;
 
509
 
491
510
    *src_start = 0;
492
511
    *src_end = src_size;
493
 
    *dst_start = (dst_size - scaled_src_size) / 2;
 
512
    *dst_start = (dst_size - scaled_src_size) * align + pan * scaled_src_size;
494
513
    *dst_end = *dst_start + scaled_src_size;
495
514
 
496
515
    // Distance of screen frame to video
511
530
        *dst_end = dst_size;
512
531
    }
513
532
 
 
533
    if (unscaled && zoom == 1.0) {
 
534
        // Force unscaled by reducing the range for src or dst
 
535
        int src_s = *src_end - *src_start;
 
536
        int dst_s = *dst_end - *dst_start;
 
537
        if (src_s > dst_s) {
 
538
            *src_end = *src_start + dst_s;
 
539
        } else if (src_s < dst_s) {
 
540
            *dst_end = *dst_start + src_s;
 
541
        }
 
542
    }
 
543
 
514
544
    // For sanity: avoid bothering VOs with corner cases
515
545
    clamp_size(src_size, src_start, src_end);
516
546
    clamp_size(dst_size, dst_start, dst_end);
538
568
    if (opts->keepaspect) {
539
569
        int scaled_width, scaled_height;
540
570
        aspect_calc_panscan(vo, &scaled_width, &scaled_height);
541
 
        src_dst_split_scaling(src_w, vo->dwidth, scaled_width,
 
571
        src_dst_split_scaling(src_w, vo->dwidth, scaled_width, opts->unscaled,
 
572
                              opts->zoom, opts->align_x, opts->pan_x,
542
573
                              &src.x0, &src.x1, &dst.x0, &dst.x1,
543
574
                              &osd.ml, &osd.mr);
544
 
        src_dst_split_scaling(src_h, vo->dheight, scaled_height,
 
575
        src_dst_split_scaling(src_h, vo->dheight, scaled_height, opts->unscaled,
 
576
                              opts->zoom, opts->align_y, opts->pan_y,
545
577
                              &src.y0, &src.y1, &dst.y0, &dst.y1,
546
578
                              &osd.mt, &osd.mb);
547
579
    }
574
606
{
575
607
    if (!vo->opts->enable_mouse_movements)
576
608
        return;
577
 
    mp_input_set_mouse_pos(vo->input_ctx, posx, posy);
 
609
    float p[2] = {posx, posy};
 
610
    vo_control(vo, VOCTRL_WINDOW_TO_OSD_COORDS, p);
 
611
    mp_input_set_mouse_pos(vo->input_ctx, p[0], p[1]);
578
612
}