annotate libmpcodecs/vf_dsize.c @ 13955:d9bdae1d1c04

Free WAVEFORMATEX in sh_audio when all other sh_audio members are freed.
author iive
date Mon, 15 Nov 2004 15:05:12 +0000
parents 6293e6f02fe3
children 72215ea57015
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10006
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
1 #include <stdio.h>
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
2 #include <stdlib.h>
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
3 #include <string.h>
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
4 #include <inttypes.h>
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
5
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
6 #include "../config.h"
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
7 #include "../mp_msg.h"
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
8
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
9 #include "img_format.h"
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
10 #include "mp_image.h"
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
11 #include "vf.h"
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
12
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
13 struct vf_priv_s {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
14 int w, h;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
15 float aspect;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
16 };
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
17
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
18 static int config(struct vf_instance_s* vf,
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
19 int width, int height, int d_width, int d_height,
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
20 unsigned int flags, unsigned int outfmt)
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
21 {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
22 if (vf->priv->w && vf->priv->h) {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
23 d_width = vf->priv->w;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
24 d_height = vf->priv->h;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
25 } else {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
26 if (vf->priv->aspect * height > width) {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
27 d_width = height * vf->priv->aspect;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
28 d_height = height;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
29 } else {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
30 d_height = width / vf->priv->aspect;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
31 d_width = width;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
32 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
33 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
34 return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt);
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
35 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
36
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
37 static int open(vf_instance_t *vf, char* args)
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
38 {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
39 vf->config = config;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
40 vf->draw_slice = vf_next_draw_slice;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
41 //vf->default_caps = 0;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
42 vf->priv = calloc(sizeof(struct vf_priv_s), 1);
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
43 vf->priv->aspect = 4.0/3.0;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
44 if (args) {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
45 if (strchr(args, '/')) {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
46 int w, h;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
47 sscanf(args, "%d/%d", &w, &h);
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
48 vf->priv->aspect = (float)w/h;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
49 } else if (strchr(args, '.')) {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
50 sscanf(args, "%f", &vf->priv->aspect);
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
51 } else {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
52 sscanf(args, "%d:%d", &vf->priv->w, &vf->priv->h);
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
53 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
54 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
55 return 1;
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
56 }
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
57
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
58 vf_info_t vf_info_dsize = {
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
59 "reset displaysize/aspect",
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
60 "dsize",
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
61 "Rich Felker",
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
62 "",
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
63 open,
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
64 NULL
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
65 };
6293e6f02fe3 display size/aspect adjusting filter
rfelker
parents:
diff changeset
66