Ignore svn changes up to r30579
[mplayer/kovensky.git] / libmpcodecs / vf_yuy2.c
blob8e1b6f0c8ccef4bb588febc4682011a610a6ad01
1 /*
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.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <inttypes.h>
24 #include "config.h"
25 #include "mp_msg.h"
26 #include "help_mp.h"
28 #include "img_format.h"
29 #include "mp_image.h"
30 #include "vf.h"
32 #include "libswscale/rgb2rgb.h"
33 #include "vf_scale.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_tmsg(MSGT_VFILTER, MSGL_WARN, "%s not supported by next filter/vo :(\n", "YUY2");
45 return 0;
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){
52 mp_image_t *dmpi;
54 // hope we'll get DR buffer:
55 dmpi=vf_get_image(vf->next,IMGFMT_YUY2,
56 MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
57 mpi->w, mpi->h);
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]);
62 else
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){
74 switch(fmt){
75 case IMGFMT_YV12:
76 case IMGFMT_I420:
77 case IMGFMT_IYUV:
78 case IMGFMT_422P:
79 return vf_next_query_format(vf,IMGFMT_YUY2) & (~VFCAP_CSP_SUPPORTED_BY_HW);
81 return 0;
84 static int open(vf_instance_t *vf, char* args){
85 vf->config=config;
86 vf->put_image=put_image;
87 vf->query_format=query_format;
88 return 1;
91 const vf_info_t vf_info_yuy2 = {
92 "fast YV12/Y422p -> YUY2 conversion",
93 "yuy2",
94 "A'rpi",
95 "",
96 open,
97 NULL
100 //===========================================================================//