Mercurial > mplayer.hg
annotate libmpcodecs/vf_yuvcsp.c @ 29588:17d7ae586d03
Reduce code duplication for half/normal/double video size handling.
author | reimar |
---|---|
date | Wed, 02 Sep 2009 14:02:15 +0000 |
parents | 0f1b5b68af32 |
children | bbb6ebec87a0 |
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); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25221
diff
changeset
|
41 |
11536 | 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]; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25221
diff
changeset
|
49 |
11536 | 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 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25221
diff
changeset
|
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 | |
24867
e5b4a794ac92
Comment out uninit function, its use is commented out. Fixes warning:
diego
parents:
17906
diff
changeset
|
66 /* |
11536 | 67 static void uninit(struct vf_instance_s* vf){ |
68 free(vf->priv); | |
69 } | |
24867
e5b4a794ac92
Comment out uninit function, its use is commented out. Fixes warning:
diego
parents:
17906
diff
changeset
|
70 */ |
11536 | 71 |
72 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | |
73 switch(fmt){ | |
74 case IMGFMT_YV12: | |
75 case IMGFMT_I420: | |
76 case IMGFMT_IYUV: | |
77 return 1; | |
78 } | |
79 return 0; | |
80 } | |
81 | |
82 static int open(vf_instance_t *vf, char* args){ | |
83 vf->config=config; | |
84 vf->put_image=put_image; | |
85 // vf->uninit=uninit; | |
86 vf->query_format=query_format; | |
87 // vf->priv=calloc(1, sizeof(struct vf_priv_s)); | |
88 // if (args) | |
89 // vf->priv->csp = atoi(args); | |
90 return 1; | |
91 } | |
92 | |
25221 | 93 const vf_info_t vf_info_yuvcsp = { |
11536 | 94 "yuv colorspace converter", |
95 "yuvcsp", | |
96 "Alex Beregszaszi", | |
97 "", | |
98 open, | |
99 NULL | |
100 }; | |
101 | |
102 //===========================================================================// |