Fix planarCopy to ignore the GRAY8 "pseudo"-palette, fixes libavtest regression test.
[mplayer/glamo.git] / libmpcodecs / vf_flip.c
blob8134ff83b64ab3c5946e5d72db5f48e3375fefcf
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "config.h"
6 #include "mp_msg.h"
8 #include "mp_image.h"
9 #include "vf.h"
11 #include "libvo/video_out.h"
13 //===========================================================================//
15 static int config(struct vf_instance_s* vf,
16 int width, int height, int d_width, int d_height,
17 unsigned int flags, unsigned int outfmt){
18 flags&=~VOFLAG_FLIPPING; // remove the FLIP flag
19 return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
22 static void get_image(struct vf_instance_s* vf, mp_image_t *mpi){
23 if(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE){
24 // try full DR !
25 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
26 mpi->type, mpi->flags, mpi->width, mpi->height);
27 // set up mpi as a upside-down image of dmpi:
28 mpi->planes[0]=vf->dmpi->planes[0]+
29 vf->dmpi->stride[0]*(vf->dmpi->height-1);
30 mpi->stride[0]=-vf->dmpi->stride[0];
31 if(mpi->flags&MP_IMGFLAG_PLANAR){
32 mpi->planes[1]=vf->dmpi->planes[1]+
33 vf->dmpi->stride[1]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
34 mpi->stride[1]=-vf->dmpi->stride[1];
35 mpi->planes[2]=vf->dmpi->planes[2]+
36 vf->dmpi->stride[2]*((vf->dmpi->height>>mpi->chroma_y_shift)-1);
37 mpi->stride[2]=-vf->dmpi->stride[2];
39 mpi->flags|=MP_IMGFLAG_DIRECT;
40 mpi->priv=(void*)vf->dmpi;
44 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi, double pts){
45 if(mpi->flags&MP_IMGFLAG_DIRECT){
46 // we've used DR, so we're ready...
47 if(!(mpi->flags&MP_IMGFLAG_PLANAR))
48 ((mp_image_t*)mpi->priv)->planes[1] = mpi->planes[1]; // passthrough rgb8 palette
49 return vf_next_put_image(vf,(mp_image_t*)mpi->priv, pts);
52 vf->dmpi=vf_get_image(vf->next,mpi->imgfmt,
53 MP_IMGTYPE_EXPORT, MP_IMGFLAG_ACCEPT_STRIDE,
54 mpi->width, mpi->height);
56 // set up mpi as a upside-down image of dmpi:
57 vf->dmpi->planes[0]=mpi->planes[0]+
58 mpi->stride[0]*(mpi->height-1);
59 vf->dmpi->stride[0]=-mpi->stride[0];
60 if(vf->dmpi->flags&MP_IMGFLAG_PLANAR){
61 vf->dmpi->planes[1]=mpi->planes[1]+
62 mpi->stride[1]*((mpi->height>>mpi->chroma_y_shift)-1);
63 vf->dmpi->stride[1]=-mpi->stride[1];
64 vf->dmpi->planes[2]=mpi->planes[2]+
65 mpi->stride[2]*((mpi->height>>mpi->chroma_y_shift)-1);
66 vf->dmpi->stride[2]=-mpi->stride[2];
67 } else
68 vf->dmpi->planes[1]=mpi->planes[1]; // passthru bgr8 palette!!!
70 return vf_next_put_image(vf,vf->dmpi, pts);
73 //===========================================================================//
75 static int open(vf_instance_t *vf, char* args){
76 vf->config=config;
77 vf->get_image=get_image;
78 vf->put_image=put_image;
79 vf->default_reqs=VFCAP_ACCEPT_STRIDE;
80 return 1;
83 const vf_info_t vf_info_flip = {
84 "flip image upside-down",
85 "flip",
86 "A'rpi",
87 "",
88 open,
89 NULL
92 //===========================================================================//