00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <stdlib.h>
00021 #include <string.h>
00022 #include <inttypes.h>
00023
00024 #include "config.h"
00025 #include "mp_msg.h"
00026 #include "help_mp.h"
00027
00028 #include "img_format.h"
00029 #include "mp_image.h"
00030 #include "vf.h"
00031
00032 #include "libvo/fastmemcpy.h"
00033
00034
00035
00036 static int config(struct vf_instance *vf,
00037 int width, int height, int d_width, int d_height,
00038 unsigned int flags, unsigned int outfmt){
00039
00040 if(vf_next_query_format(vf,IMGFMT_YV12)<=0){
00041 mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_WarnNextFilterDoesntSupport, "YVU9");
00042 return 0;
00043 }
00044
00045 return vf_next_config(vf,width,height,d_width,d_height,flags,IMGFMT_YV12);
00046 }
00047
00048 static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
00049 mp_image_t *dmpi;
00050 int y,w,h;
00051
00052
00053 dmpi=vf_get_image(vf->next,IMGFMT_YV12,
00054 MP_IMGTYPE_TEMP, 0,
00055 mpi->w, mpi->h);
00056
00057 for(y=0;y<mpi->h;y++)
00058 fast_memcpy(dmpi->planes[0]+dmpi->stride[0]*y,
00059 mpi->planes[0]+mpi->stride[0]*y,
00060 mpi->w);
00061
00062 w=mpi->w/4; h=mpi->h/2;
00063 for(y=0;y<h;y++){
00064 unsigned char* s=mpi->planes[1]+mpi->stride[1]*(y>>1);
00065 unsigned char* d=dmpi->planes[1]+dmpi->stride[1]*y;
00066 int x;
00067 for(x=0;x<w;x++) d[2*x]=d[2*x+1]=s[x];
00068 }
00069 for(y=0;y<h;y++){
00070 unsigned char* s=mpi->planes[2]+mpi->stride[2]*(y>>1);
00071 unsigned char* d=dmpi->planes[2]+dmpi->stride[2]*y;
00072 int x;
00073 for(x=0;x<w;x++) d[2*x]=d[2*x+1]=s[x];
00074 }
00075
00076 vf_clone_mpi_attributes(dmpi, mpi);
00077
00078 return vf_next_put_image(vf,dmpi, pts);
00079 }
00080
00081
00082
00083 static int query_format(struct vf_instance *vf, unsigned int fmt){
00084 if (fmt == IMGFMT_YVU9 || fmt == IMGFMT_IF09)
00085 return vf_next_query_format(vf,IMGFMT_YV12) & (~VFCAP_CSP_SUPPORTED_BY_HW);
00086 return 0;
00087 }
00088
00089 static int vf_open(vf_instance_t *vf, char *args){
00090 vf->config=config;
00091 vf->put_image=put_image;
00092 vf->query_format=query_format;
00093 return 1;
00094 }
00095
00096 const vf_info_t vf_info_yvu9 = {
00097 "fast YVU9->YV12 conversion",
00098 "yvu9",
00099 "alex",
00100 "",
00101 vf_open,
00102 NULL
00103 };
00104
00105