00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdio.h>
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <inttypes.h>
00025 #include <assert.h>
00026
00027 #include "mp_msg.h"
00028 #include "img_format.h"
00029 #include "mp_image.h"
00030 #include "vf.h"
00031
00032
00033
00034
00035 static void get_image(struct vf_instance *vf, mp_image_t *mpi){
00036 mp_image_t *dmpi= vf_get_image(vf->next, mpi->imgfmt,
00037 mpi->type, mpi->flags, mpi->w, mpi->h);
00038
00039 mpi->planes[0]=dmpi->planes[0];
00040 mpi->planes[1]=dmpi->planes[2];
00041 mpi->planes[2]=dmpi->planes[1];
00042 mpi->stride[0]=dmpi->stride[0];
00043 mpi->stride[1]=dmpi->stride[2];
00044 mpi->stride[2]=dmpi->stride[1];
00045 mpi->width=dmpi->width;
00046
00047 mpi->flags|=MP_IMGFLAG_DIRECT;
00048 mpi->priv=(void*)dmpi;
00049 }
00050
00051 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00052 mp_image_t *dmpi;
00053
00054 if(mpi->flags&MP_IMGFLAG_DIRECT){
00055 dmpi=(mp_image_t*)mpi->priv;
00056 } else {
00057 dmpi=vf_get_image(vf->next, mpi->imgfmt, MP_IMGTYPE_EXPORT, 0, mpi->w, mpi->h);
00058 assert(mpi->flags&MP_IMGFLAG_PLANAR);
00059 dmpi->planes[0]=mpi->planes[0];
00060 dmpi->planes[1]=mpi->planes[2];
00061 dmpi->planes[2]=mpi->planes[1];
00062 dmpi->stride[0]=mpi->stride[0];
00063 dmpi->stride[1]=mpi->stride[2];
00064 dmpi->stride[2]=mpi->stride[1];
00065 dmpi->width=mpi->width;
00066 }
00067
00068 vf_clone_mpi_attributes(dmpi, mpi);
00069
00070 return vf_next_put_image(vf,dmpi, pts);
00071 }
00072
00073
00074
00075 static int query_format(struct vf_instance *vf, unsigned int fmt){
00076 switch(fmt)
00077 {
00078 case IMGFMT_YV12:
00079 case IMGFMT_I420:
00080 case IMGFMT_IYUV:
00081 case IMGFMT_YVU9:
00082 case IMGFMT_444P:
00083 case IMGFMT_422P:
00084 case IMGFMT_411P:
00085 return vf_next_query_format(vf, fmt);
00086 }
00087 return 0;
00088 }
00089
00090 static int vf_open(vf_instance_t *vf, char *args){
00091 vf->put_image=put_image;
00092 vf->get_image=get_image;
00093 vf->query_format=query_format;
00094 return 1;
00095 }
00096
00097 const vf_info_t vf_info_swapuv = {
00098 "UV swapper",
00099 "swapuv",
00100 "Michael Niedermayer",
00101 "",
00102 vf_open,
00103 NULL
00104 };
00105
00106