Allocate a larger backbuffer to allow resizing without reinit.
[mplayer/glamo.git] / libmpcodecs / vf_swapuv.c
blobf9a65ae6b1c39d252e7464b5b7821fa2273d77e6
1 /*
2 * Copyright (C) 2002 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of MPlayer.
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <inttypes.h>
25 #include <assert.h>
27 #include "config.h"
28 #include "mp_msg.h"
30 #ifdef HAVE_MALLOC_H
31 #include <malloc.h>
32 #endif
34 #include "img_format.h"
35 #include "mp_image.h"
36 #include "vf.h"
39 //===========================================================================//
41 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
42 mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
43 mpi->type, mpi->flags, mpi->w, mpi->h);
45 mpi->planes[0]=dmpi->planes[0];
46 mpi->planes[1]=dmpi->planes[2];
47 mpi->planes[2]=dmpi->planes[1];
48 mpi->stride[0]=dmpi->stride[0];
49 mpi->stride[1]=dmpi->stride[2];
50 mpi->stride[2]=dmpi->stride[1];
51 mpi->width=dmpi->width;
53 mpi->flags|=MP_IMGFLAG_DIRECT;
54 mpi->priv=(void*)dmpi;
57 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
58 mp_image_t *dmpi;
60 if(mpi->flags&MP_IMGFLAG_DIRECT){
61 dmpi=(mp_image_t*)mpi->priv;
62 } else {
63 dmpi=vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
64 assert(mpi->flags&MP_IMGFLAG_PLANAR);
65 dmpi->planes[0]=mpi->planes[0];
66 dmpi->planes[1]=mpi->planes[2];
67 dmpi->planes[2]=mpi->planes[1];
68 dmpi->stride[0]=mpi->stride[0];
69 dmpi->stride[1]=mpi->stride[2];
70 dmpi->stride[2]=mpi->stride[1];
71 dmpi->width=mpi->width;
74 vf_clone_mpi_attributes(dmpi, mpi);
76 return vf_next_put_image(vf,dmpi, pts);
79 //===========================================================================//
81 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
82 switch(fmt)
84 case IMGFMT_YV12:
85 case IMGFMT_I420:
86 case IMGFMT_IYUV:
87 case IMGFMT_YVU9:
88 case IMGFMT_444P:
89 case IMGFMT_422P:
90 case IMGFMT_411P:
91 return vf_next_query_format(vf, fmt);
93 return 0;
96 static int open(vf_instance_t *vf, char* args){
97 vf->put_image=put_image;
98 vf->get_image=get_image;
99 vf->query_format=query_format;
100 return 1;
103 const vf_info_t vf_info_swapuv = {
104 "UV swapper",
105 "swapuv",
106 "Michael Niedermayer",
108 open,
109 NULL
112 //===========================================================================//