2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "img_format.h"
31 //===========================================================================//
38 static unsigned int getfmt(unsigned int outfmt
){
55 static void put_pixel(uint8_t *buf
, int x
, int y
, int stride
, int r
, int g
, int b
, int fmt
){
57 case IMGFMT_BGR15
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((r
>>3)<<10) | ((g
>>3)<<5) | (b
>>3);
59 case IMGFMT_RGB15
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((b
>>3)<<10) | ((g
>>3)<<5) | (r
>>3);
61 case IMGFMT_BGR16
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((r
>>3)<<11) | ((g
>>2)<<5) | (b
>>3);
63 case IMGFMT_RGB16
: ((uint16_t*)(buf
+ y
*stride
))[x
]= ((b
>>3)<<11) | ((g
>>2)<<5) | (r
>>3);
66 buf
[3*x
+ y
*stride
+ 0]= r
;
67 buf
[3*x
+ y
*stride
+ 1]= g
;
68 buf
[3*x
+ y
*stride
+ 2]= b
;
71 buf
[3*x
+ y
*stride
+ 0]= b
;
72 buf
[3*x
+ y
*stride
+ 1]= g
;
73 buf
[3*x
+ y
*stride
+ 2]= r
;
76 buf
[4*x
+ y
*stride
+ 0]= r
;
77 buf
[4*x
+ y
*stride
+ 1]= g
;
78 buf
[4*x
+ y
*stride
+ 2]= b
;
81 buf
[4*x
+ y
*stride
+ 0]= b
;
82 buf
[4*x
+ y
*stride
+ 1]= g
;
83 buf
[4*x
+ y
*stride
+ 2]= r
;
86 buf
[4*x
+ y
*stride
+ 1]= r
;
87 buf
[4*x
+ y
*stride
+ 2]= g
;
88 buf
[4*x
+ y
*stride
+ 3]= b
;
91 buf
[4*x
+ y
*stride
+ 1]= b
;
92 buf
[4*x
+ y
*stride
+ 2]= g
;
93 buf
[4*x
+ y
*stride
+ 3]= r
;
98 static int config(struct vf_instance
* vf
,
99 int width
, int height
, int d_width
, int d_height
,
100 unsigned int flags
, unsigned int outfmt
){
101 if (vf
->priv
->w
> 0) { d_width
= width
= vf
->priv
->w
; }
102 if (vf
->priv
->h
> 0) { d_height
= height
= vf
->priv
->h
; }
103 vf
->priv
->fmt
=getfmt(outfmt
);
104 mp_msg(MSGT_VFILTER
,MSGL_V
,"rgb test format:%s\n", vo_format_name(outfmt
));
105 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,vf
->priv
->fmt
);
108 static int put_image(struct vf_instance
* vf
, mp_image_t
*mpi
, double pts
){
111 int w
= vf
->priv
->w
> 0 ? vf
->priv
->w
: mpi
->w
;
112 int h
= vf
->priv
->h
> 0 ? vf
->priv
->h
: mpi
->h
;
114 // hope we'll get DR buffer:
115 dmpi
=vf_get_image(vf
->next
,vf
->priv
->fmt
,
116 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
125 else if(3*y
<2*h
) g
=c
;
128 put_pixel(dmpi
->planes
[0], x
, y
, dmpi
->stride
[0], r
, g
, b
, vf
->priv
->fmt
);
132 return vf_next_put_image(vf
,dmpi
, pts
);
135 //===========================================================================//
137 static int query_format(struct vf_instance
* vf
, unsigned int outfmt
){
138 unsigned int fmt
=getfmt(outfmt
);
140 return vf_next_query_format(vf
,fmt
) & (~VFCAP_CSP_SUPPORTED_BY_HW
);
143 static int vf_open(vf_instance_t
*vf
, char *args
){
145 vf
->put_image
=put_image
;
146 vf
->query_format
=query_format
;
147 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
148 vf
->priv
->w
= vf
->priv
->h
= 0;
150 sscanf(args
, "%d:%d", &vf
->priv
->w
, &vf
->priv
->h
);
154 const vf_info_t vf_info_rgbtest
= {
157 "Michael Niedermayer",
163 //===========================================================================//