1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-20 14:56:55 +00:00

vo_xv: minor simplifications

The draw_osd change is a bit tricky: I guess originally, there was some
intention not to second-guess the generic aspect code, but the result is
the same and the code is more confusing.
This commit is contained in:
wm4 2013-03-14 15:53:59 +01:00
parent 36f5d800d5
commit 59960baa7f

View File

@ -85,8 +85,6 @@ struct xvctx {
int current_buf;
int current_ip_buf;
int num_buffers;
int total_buffers;
int visible_buf;
XvImage *xvimage[2];
struct mp_image *original_image;
uint32_t image_width;
@ -511,8 +509,6 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
return -1;
}
ctx->visible_buf = -1;
/* check image formats */
ctx->xv_format = 0;
for (i = 0; i < ctx->formats; i++) {
@ -535,13 +531,12 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
ctx->xv_port);
// In case config has been called before
for (i = 0; i < ctx->total_buffers; i++)
for (i = 0; i < ctx->num_buffers; i++)
deallocate_xvimage(vo, i);
ctx->num_buffers = 2;
ctx->total_buffers = ctx->num_buffers;
for (i = 0; i < ctx->total_buffers; i++)
for (i = 0; i < ctx->num_buffers; i++)
allocate_xvimage(vo, i);
ctx->current_buf = 0;
@ -681,16 +676,10 @@ static void draw_osd(struct vo *vo, struct osd_state *osd)
struct mp_image img = get_xv_buffer(vo, ctx->current_buf);
struct mp_rect *src = &ctx->src_rect;
struct mp_rect *dst = &ctx->dst_rect;
int dw = dst->x1 - dst->x0, dh = dst->y1 - dst->y0;
int sw = src->x1 - src->x0, sh = src->y1 - src->y0;
double xvpar = (double)dw / dh * sh / sw;
struct mp_osd_res res = {
.w = ctx->image_width,
.h = ctx->image_height,
.display_par = vo->monitor_par / xvpar,
.display_par = 1.0 / vo->aspdat.par,
.video_par = vo->aspdat.par,
};
@ -722,7 +711,6 @@ static void flip_page(struct vo *vo)
put_xvimage(vo, ctx->xvimage[ctx->current_buf]);
/* remember the currently visible buffer */
ctx->visible_buf = ctx->current_buf;
ctx->current_buf = (ctx->current_buf + 1) % ctx->num_buffers;
if (!ctx->Shmem_Flag)
@ -786,7 +774,6 @@ static void uninit(struct vo *vo)
talloc_free(ctx->original_image);
ctx->visible_buf = -1;
if (ctx->ai)
XvFreeAdaptorInfo(ctx->ai);
ctx->ai = NULL;
@ -794,7 +781,7 @@ static void uninit(struct vo *vo)
XFree(ctx->fo);
ctx->fo = NULL;
}
for (i = 0; i < ctx->total_buffers; i++)
for (i = 0; i < ctx->num_buffers; i++)
deallocate_xvimage(vo, i);
// uninit() shouldn't get called unless initialization went past vo_init()
vo_x11_uninit(vo);