annotate libmpcodecs/vf_rectangle.c @ 6821:414ea538b99e

Document rectangle plugin.
author kmkaplan
date Sat, 27 Jul 2002 12:18:53 +0000
parents a99c7700e4f1
children 66427e850216
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6820
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
1 #include <stdio.h>
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
2 #include <stdlib.h>
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
3 #include "mp_image.h"
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
4 #include "vf.h"
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
5
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
6 struct vf_priv_s {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
7 int x, y, w, h;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
8 };
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
9
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
10 static void
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
11 put_image(struct vf_instance_s* vf, mp_image_t* mpi){
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
12 mp_image_t* dmpi;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
13 int x, y, w, h;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
14 unsigned int bpp, count;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
15 unsigned char *p1, *p2;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
16 dmpi = vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_TEMP, 0, mpi->w, mpi->h);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
17 bpp = dmpi->bpp / 8;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
18 memcpy(dmpi->planes[0], mpi->planes[0], dmpi->stride[0] * bpp * mpi->height);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
19 memcpy(dmpi->planes[1], mpi->planes[1], dmpi->stride[1] * mpi->chroma_height);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
20 memcpy(dmpi->planes[2], mpi->planes[2], dmpi->stride[2] * mpi->chroma_height);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
21
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
22 /* Draw the rectangle */
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
23 x = vf->priv->x;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
24 if (x < 0)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
25 x = 0;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
26 y = vf->priv->y;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
27 if (y < 0)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
28 y = 0;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
29 w = vf->priv->w;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
30 if (w < 0)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
31 w = dmpi->w - x;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
32 h = vf->priv->h;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
33 if (h < 0)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
34 h = dmpi->h - y;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
35 count = w * bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
36 p1 = dmpi->planes[0] + y * dmpi->stride[0] + x * bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
37 if (h == 1)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
38 while (count--) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
39 *p1 = 0xff - *p1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
40 ++p1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
41 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
42 else {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
43 p2 = p1 + (h - 1) * dmpi->stride[0];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
44 while (count--) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
45 *p1 = 0xff - *p1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
46 ++p1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
47 *p2 = 0xff - *p2;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
48 ++p2;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
49 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
50 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
51 count = h;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
52 p1 = dmpi->planes[0] + y * dmpi->stride[0] + x * bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
53 if (w == 1)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
54 while (count--) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
55 int i = bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
56 while (i--)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
57 p1[i] ^= 0xff;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
58 p1 += dmpi->stride[0];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
59 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
60 else {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
61 p2 = p1 + (w - 1) * bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
62 while (count--) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
63 int i = bpp;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
64 while (i--) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
65 p1[i] = 0xff - p1[i];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
66 p2[i] = 0xff - p2[i];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
67 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
68 p1 += dmpi->stride[0];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
69 p2 += dmpi->stride[0];
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
70 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
71 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
72 vf_next_put_image(vf, dmpi);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
73 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
74
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
75 static int
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
76 open(vf_instance_t* vf, char* args) {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
77 vf->put_image = put_image;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
78 vf->priv = malloc(sizeof(struct vf_priv_s));
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
79 vf->priv->x = -1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
80 vf->priv->y = -1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
81 vf->priv->w = -1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
82 vf->priv->h = -1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
83 if (args)
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
84 sscanf(args, "%d:%d:%d:%d",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
85 &vf->priv->w, &vf->priv->h, &vf->priv->x, &vf->priv->y);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
86 printf("Crop: %d x %d, %d ; %d\n",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
87 vf->priv->w, vf->priv->h, vf->priv->x, vf->priv->y);
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
88 return 1;
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
89 }
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
90
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
91 vf_info_t vf_info_rectangle = {
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
92 "draw rectangle",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
93 "rectangle",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
94 "Kim Minh Kaplan",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
95 "",
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
96 open
a99c7700e4f1 New plugin to test crop parameters. Arguments are the same as for the
kmkaplan
parents:
diff changeset
97 };