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.
28 #include "img_format.h"
32 #include "libswscale/rgb2rgb.h"
35 //===========================================================================//
37 static int config(struct vf_instance
*vf
,
38 int width
, int height
, int d_width
, int d_height
,
39 unsigned int flags
, unsigned int outfmt
){
41 sws_rgb2rgb_init(get_sws_cpuflags());
43 if(vf_next_query_format(vf
,IMGFMT_YUY2
)<=0){
44 mp_msg(MSGT_VFILTER
, MSGL_WARN
, MSGTR_MPCODECS_WarnNextFilterDoesntSupport
, "YUY2");
48 return vf_next_config(vf
,width
,height
,d_width
,d_height
,flags
,IMGFMT_YUY2
);
51 static int put_image(struct vf_instance
*vf
, mp_image_t
*mpi
, double pts
){
54 // hope we'll get DR buffer:
55 dmpi
=vf_get_image(vf
->next
,IMGFMT_YUY2
,
56 MP_IMGTYPE_TEMP
, MP_IMGFLAG_ACCEPT_STRIDE
,
59 if(mpi
->imgfmt
==IMGFMT_422P
)
60 yuv422ptoyuy2(mpi
->planes
[0],mpi
->planes
[1],mpi
->planes
[2], dmpi
->planes
[0],
61 mpi
->w
,mpi
->h
, mpi
->stride
[0],mpi
->stride
[1],dmpi
->stride
[0]);
63 yv12toyuy2(mpi
->planes
[0],mpi
->planes
[1],mpi
->planes
[2], dmpi
->planes
[0],
64 mpi
->w
,mpi
->h
, mpi
->stride
[0],mpi
->stride
[1],dmpi
->stride
[0]);
66 vf_clone_mpi_attributes(dmpi
, mpi
);
68 return vf_next_put_image(vf
,dmpi
, pts
);
71 //===========================================================================//
73 static int query_format(struct vf_instance
*vf
, unsigned int fmt
){
79 return vf_next_query_format(vf
,IMGFMT_YUY2
) & (~VFCAP_CSP_SUPPORTED_BY_HW
);
84 static int vf_open(vf_instance_t
*vf
, char *args
){
86 vf
->put_image
=put_image
;
87 vf
->query_format
=query_format
;
91 const vf_info_t vf_info_yuy2
= {
92 "fast YV12/Y422p -> YUY2 conversion",
100 //===========================================================================//