9 #include "img_format.h"
13 //===========================================================================//
19 static unsigned int getfmt(unsigned int outfmt
){
36 static void put_pixel(uint8_t *buf
, int x
, int y
, int stride
, int r
, int g
, int b
, int fmt
){
38 case IMGFMT_BGR15
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((r
>>3)<<10) | ((g
>>3)<<5) | (b
>>3);
40 case IMGFMT_RGB15
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((b
>>3)<<10) | ((g
>>3)<<5) | (r
>>3);
42 case IMGFMT_BGR16
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((r
>>3)<<11) | ((g
>>2)<<5) | (b
>>3);
44 case IMGFMT_RGB16
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((b
>>3)<<11) | ((g
>>2)<<5) | (r
>>3);
47 buf
[3*x
+ y
*stride
+ 0]= r
;
48 buf
[3*x
+ y
*stride
+ 1]= g
;
49 buf
[3*x
+ y
*stride
+ 2]= b
;
52 buf
[3*x
+ y
*stride
+ 0]= b
;
53 buf
[3*x
+ y
*stride
+ 1]= g
;
54 buf
[3*x
+ y
*stride
+ 2]= r
;
57 buf
[4*x
+ y
*stride
+ 0]= r
;
58 buf
[4*x
+ y
*stride
+ 1]= g
;
59 buf
[4*x
+ y
*stride
+ 2]= b
;
62 buf
[4*x
+ y
*stride
+ 0]= b
;
63 buf
[4*x
+ y
*stride
+ 1]= g
;
64 buf
[4*x
+ y
*stride
+ 2]= r
;
67 buf
[4*x
+ y
*stride
+ 1]= r
;
68 buf
[4*x
+ y
*stride
+ 2]= g
;
69 buf
[4*x
+ y
*stride
+ 3]= b
;
72 buf
[4*x
+ y
*stride
+ 1]= b
;
73 buf
[4*x
+ y
*stride
+ 2]= g
;
74 buf
[4*x
+ y
*stride
+ 3]= r
;
79 static int config(struct vf_instance_s
* vf
,
80 int width
, int height
, int d_width
, int d_height
,
81 unsigned int flags
, unsigned int outfmt
){
82 vf
->priv
->fmt
=getfmt(outfmt
);
83 mp_msg(MSGT_VFILTER
,MSGL_V
,"rgb test format:%s\n", vo_format_name(outfmt
));
84 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,vf
->priv
->fmt
);
87 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
){
91 // hope we'll get DR buffer:
92 dmpi
=vf_get_image(vf
->next
,vf
->priv
->fmt
,
93 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
96 for(y
=0; y
<mpi
->h
; y
++){
97 for(x
=0; x
<mpi
->w
; x
++){
102 else if(3*y
<2*mpi
->h
) g
=c
;
105 put_pixel(dmpi
->planes
[0], x
, y
, dmpi
->stride
[0], r
, g
, b
, vf
->priv
->fmt
);
109 return vf_next_put_image(vf
,dmpi
, pts
);
112 //===========================================================================//
114 static int query_format(struct vf_instance_s
* vf
, unsigned int outfmt
){
115 unsigned int fmt
=getfmt(outfmt
);
117 return vf_next_query_format(vf
,fmt
) & (~VFCAP_CSP_SUPPORTED_BY_HW
);
120 static int open(vf_instance_t
*vf
, char* args
){
122 vf
->put_image
=put_image
;
123 vf
->query_format
=query_format
;
124 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
128 const vf_info_t vf_info_rgbtest
= {
131 "Michael Niedermayer",
137 //===========================================================================//