Mercurial > mplayer.hg
annotate libmpcodecs/vf_yuvcsp.c @ 22188:b9fa8b0ddab9
strncat() misuses, may have been exploitable.
Reported by Sascha Sommer.
author | rtogni |
---|---|
date | Sun, 11 Feb 2007 18:00:06 +0000 |
parents | 20aca9baf5d8 |
children | e5b4a794ac92 |
rev | line source |
---|---|
11536 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <inttypes.h> | |
5 | |
17012 | 6 #include "config.h" |
7 #include "mp_msg.h" | |
11536 | 8 |
9 #include "img_format.h" | |
10 #include "mp_image.h" | |
11 #include "vf.h" | |
12 | |
13 struct vf_priv_s { | |
14 int csp; | |
15 }; | |
16 | |
17 //===========================================================================// | |
18 | |
19 static int config(struct vf_instance_s* vf, | |
20 int width, int height, int d_width, int d_height, | |
21 unsigned int flags, unsigned int outfmt){ | |
22 return vf_next_config(vf, width, height, d_width, d_height, flags, outfmt); | |
23 } | |
24 | |
25 static inline int clamp_y(int x){ | |
26 return (x > 235) ? 235 : (x < 16) ? 16 : x; | |
27 } | |
28 | |
29 static inline int clamp_c(int x){ | |
30 return (x > 240) ? 240 : (x < 16) ? 16 : x; | |
31 } | |
32 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
33 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){ |
11536 | 34 int i,j; |
35 uint8_t *y_in, *cb_in, *cr_in; | |
36 uint8_t *y_out, *cb_out, *cr_out; | |
37 | |
38 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt, | |
39 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, | |
40 mpi->width, mpi->height); | |
41 | |
42 y_in = mpi->planes[0]; | |
43 cb_in = mpi->planes[1]; | |
44 cr_in = mpi->planes[2]; | |
45 | |
46 y_out = vf->dmpi->planes[0]; | |
47 cb_out = vf->dmpi->planes[1]; | |
48 cr_out = vf->dmpi->planes[2]; | |
49 | |
50 for (i = 0; i < mpi->height; i++) | |
51 for (j = 0; j < mpi->width; j++) | |
52 y_out[i*vf->dmpi->stride[0]+j] = clamp_y(y_in[i*mpi->stride[0]+j]); | |
53 | |
54 for (i = 0; i < mpi->chroma_height; i++) | |
55 for (j = 0; j < mpi->chroma_width; j++) | |
56 { | |
57 cb_out[i*vf->dmpi->stride[1]+j] = clamp_c(cb_in[i*mpi->stride[1]+j]); | |
58 cr_out[i*vf->dmpi->stride[2]+j] = clamp_c(cr_in[i*mpi->stride[2]+j]); | |
59 } | |
60 | |
17906
20aca9baf5d8
passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents:
17012
diff
changeset
|
61 return vf_next_put_image(vf,vf->dmpi, pts); |
11536 | 62 } |
63 | |
64 //===========================================================================// | |
65 | |
66 static void uninit(struct vf_instance_s* vf){ | |
67 free(vf->priv); | |
68 } | |
69 | |
70 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
71 switch(fmt){ | |
72 case IMGFMT_YV12: | |
73 case IMGFMT_I420: | |
74 case IMGFMT_IYUV: | |
75 return 1; | |
76 } | |
77 return 0; | |
78 } | |
79 | |
80 static int open(vf_instance_t *vf, char* args){ | |
81 vf->config=config; | |
82 vf->put_image=put_image; | |
83 // vf->uninit=uninit; | |
84 vf->query_format=query_format; | |
85 // vf->priv=calloc(1, sizeof(struct vf_priv_s)); | |
86 // if (args) | |
87 // vf->priv->csp = atoi(args); | |
88 return 1; | |
89 } | |
90 | |
91 vf_info_t vf_info_yuvcsp = { | |
92 "yuv colorspace converter", | |
93 "yuvcsp", | |
94 "Alex Beregszaszi", | |
95 "", | |
96 open, | |
97 NULL | |
98 }; | |
99 | |
100 //===========================================================================// |