9 #include "img_format.h"
17 //===========================================================================//
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
);
25 static inline int clamp_y(int x
){
26 return (x
> 235) ? 235 : (x
< 16) ? 16 : x
;
29 static inline int clamp_c(int x
){
30 return (x
> 240) ? 240 : (x
< 16) ? 16 : x
;
33 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
){
35 uint8_t *y_in
, *cb_in
, *cr_in
;
36 uint8_t *y_out
, *cb_out
, *cr_out
;
38 vf
->dmpi
=vf_get_image(vf
->next
,mpi
->imgfmt
,
39 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
40 mpi
->width
, mpi
->height
);
42 y_in
= mpi
->planes
[0];
43 cb_in
= mpi
->planes
[1];
44 cr_in
= mpi
->planes
[2];
46 y_out
= vf
->dmpi
->planes
[0];
47 cb_out
= vf
->dmpi
->planes
[1];
48 cr_out
= vf
->dmpi
->planes
[2];
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
]);
54 for (i
= 0; i
< mpi
->chroma_height
; i
++)
55 for (j
= 0; j
< mpi
->chroma_width
; j
++)
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
]);
61 return vf_next_put_image(vf
,vf
->dmpi
, pts
);
64 //===========================================================================//
67 static void uninit(struct vf_instance_s* vf){
72 static int query_format(struct vf_instance_s
* vf
, unsigned int fmt
){
82 static int open(vf_instance_t
*vf
, char* args
){
84 vf
->put_image
=put_image
;
86 vf
->query_format
=query_format
;
87 // vf->priv=calloc(1, sizeof(struct vf_priv_s));
89 // vf->priv->csp = atoi(args);
93 const vf_info_t vf_info_yuvcsp
= {
94 "yuv colorspace converter",
102 //===========================================================================//