9 #include "img_format.h"
13 #include "libvo/fastmemcpy.h"
14 #include "libswscale/rgb2rgb.h"
16 //===========================================================================//
23 static unsigned int getfmt(unsigned int outfmt
,int forced
){
24 if(forced
) switch(outfmt
){
32 case IMGFMT_RGB24
: return IMGFMT_BGR24
;
33 case IMGFMT_RGB32
: return IMGFMT_BGR32
;
34 case IMGFMT_BGR24
: return IMGFMT_RGB24
;
35 case IMGFMT_BGR32
: return IMGFMT_RGB32
;
40 static int config(struct vf_instance_s
* vf
,
41 int width
, int height
, int d_width
, int d_height
,
42 unsigned int flags
, unsigned int outfmt
){
43 vf
->priv
->fmt
=getfmt(outfmt
,vf
->priv
->forced
);
44 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,vf
->priv
->fmt
);
47 static int put_image(struct vf_instance_s
* vf
, mp_image_t
*mpi
, double pts
){
50 // hope we'll get DR buffer:
51 dmpi
=vf_get_image(vf
->next
,vf
->priv
->fmt
,
52 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
55 if(mpi
->stride
[0]!=dmpi
->stride
[0] || mpi
->stride
[0]!=mpi
->w
*(mpi
->bpp
/8)){
57 unsigned char* src
=mpi
->planes
[0];
58 unsigned char* dst
=dmpi
->planes
[0];
59 int srcsize
=mpi
->w
*mpi
->bpp
/8;
60 for(y
=0;y
<mpi
->h
;y
++){
62 rgb32tobgr32(src
,dst
,srcsize
);
64 rgb24tobgr24(src
,dst
,srcsize
);
70 rgb32tobgr32(mpi
->planes
[0],dmpi
->planes
[0],mpi
->w
*mpi
->h
*4);
72 rgb24tobgr24(mpi
->planes
[0],dmpi
->planes
[0],mpi
->w
*mpi
->h
*3);
75 return vf_next_put_image(vf
,dmpi
, pts
);
78 //===========================================================================//
80 static int query_format(struct vf_instance_s
* vf
, unsigned int outfmt
){
81 unsigned int fmt
=getfmt(outfmt
,vf
->priv
->forced
);
83 return vf_next_query_format(vf
,fmt
) & (~VFCAP_CSP_SUPPORTED_BY_HW
);
86 static int open(vf_instance_t
*vf
, char* args
){
88 vf
->put_image
=put_image
;
89 vf
->query_format
=query_format
;
90 vf
->priv
=malloc(sizeof(struct vf_priv_s
));
91 vf
->priv
->forced
=args
&& !strcasecmp(args
,"swap");
95 vf_info_t vf_info_rgb2bgr
= {
96 "fast 24/32bpp RGB<->BGR conversion",
104 //===========================================================================//