10006
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include <inttypes.h>
|
|
5
|
|
6 #include "../config.h"
|
|
7 #include "../mp_msg.h"
|
|
8
|
|
9 #include "img_format.h"
|
|
10 #include "mp_image.h"
|
|
11 #include "vf.h"
|
|
12
|
|
13 struct vf_priv_s {
|
|
14 int w, h;
|
|
15 float aspect;
|
|
16 };
|
|
17
|
|
18 static int config(struct vf_instance_s* vf,
|
|
19 int width, int height, int d_width, int d_height,
|
|
20 unsigned int flags, unsigned int outfmt)
|
|
21 {
|
|
22 if (vf->priv->w && vf->priv->h) {
|
|
23 d_width = vf->priv->w;
|
|
24 d_height = vf->priv->h;
|
|
25 } else {
|
|
26 if (vf->priv->aspect * height > width) {
|
|
27 d_width = height * vf->priv->aspect;
|
|
28 d_height = height;
|
|
29 } else {
|
|
30 d_height = width / vf->priv->aspect;
|
|
31 d_width = width;
|
|
32 }
|
|
33 }
|
|
34 return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
|
|
35 }
|
|
36
|
|
37 static int open(vf_instance_t *vf, char* args)
|
|
38 {
|
|
39 vf->config = config;
|
|
40 vf->draw_slice = vf_next_draw_slice;
|
|
41 //vf->default_caps = 0;
|
|
42 vf->priv = calloc(sizeof(struct vf_priv_s), 1);
|
|
43 vf->priv->aspect = 4.0/3.0;
|
|
44 if (args) {
|
|
45 if (strchr(args, '/')) {
|
|
46 int w, h;
|
|
47 sscanf(args, "%d/%d", &w, &h);
|
|
48 vf->priv->aspect = (float)w/h;
|
|
49 } else if (strchr(args, '.')) {
|
|
50 sscanf(args, "%f", &vf->priv->aspect);
|
|
51 } else {
|
|
52 sscanf(args, "%d:%d", &vf->priv->w, &vf->priv->h);
|
|
53 }
|
|
54 }
|
|
55 return 1;
|
|
56 }
|
|
57
|
|
58 vf_info_t vf_info_dsize = {
|
|
59 "reset displaysize/aspect",
|
|
60 "dsize",
|
|
61 "Rich Felker",
|
|
62 "",
|
|
63 open,
|
|
64 NULL
|
|
65 };
|
|
66
|