Mercurial > mplayer.hg
changeset 11894:4c24bad2a86b
rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr
author | michael |
---|---|
date | Fri, 30 Jan 2004 17:38:15 +0000 |
parents | cf34e63146bf |
children | d9489d5581d0 |
files | libmpcodecs/Makefile libmpcodecs/vf.c libmpcodecs/vf_rgbtest.c |
diffstat | 3 files changed, 144 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpcodecs/Makefile Fri Jan 30 11:40:54 2004 +0000 +++ b/libmpcodecs/Makefile Fri Jan 30 17:38:15 2004 +0000 @@ -14,7 +14,7 @@ VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_zrmjpeg.c vd_xanim.c vd_xvid.c vd_xvid4.c vd_libdv.c vd_qtvideo.c vd_theora.c VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT) -VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c +VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c vf_softpulldown.c vf_tinterlace.c vf_pullup.c pullup.c vf_framestep.c vf_tile.c vf_delogo.c vf_fil.c vf_hue.c vf_spp.c vf_yuvcsp.c vf_filmdint.c vf_kerndeint.c vf_rgbtest.c ifeq ($(HAVE_FFPOSTPROCESS),yes) VFILTER_SRCS += vf_pp.c endif
--- a/libmpcodecs/vf.c Fri Jan 30 11:40:54 2004 +0000 +++ b/libmpcodecs/vf.c Fri Jan 30 17:38:15 2004 +0000 @@ -84,6 +84,7 @@ extern vf_info_t vf_info_spp; extern vf_info_t vf_info_yuvcsp; extern vf_info_t vf_info_kerndeint; +extern vf_info_t vf_info_rgbtest; // list of available filters: static vf_info_t* filter_list[]={ @@ -159,6 +160,7 @@ #endif &vf_info_yuvcsp, &vf_info_kerndeint, + &vf_info_rgbtest, NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmpcodecs/vf_rgbtest.c Fri Jan 30 17:38:15 2004 +0000 @@ -0,0 +1,141 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <inttypes.h> + +#include "../config.h" +#include "../mp_msg.h" + +#include "img_format.h" +#include "mp_image.h" +#include "vf.h" + +#include "../libvo/fastmemcpy.h" + +//===========================================================================// + +struct vf_priv_s { + unsigned int fmt; +}; + +static unsigned int getfmt(unsigned int outfmt){ + switch(outfmt){ + case IMGFMT_RGB15: + case IMGFMT_RGB16: + case IMGFMT_RGB24: + case IMGFMT_RGB32: + case IMGFMT_BGR15: + case IMGFMT_BGR16: + case IMGFMT_BGR24: + case IMGFMT_BGR32: + return outfmt; + } + return 0; +} + +static void put_pixel(uint8_t *buf, int x, int y, int stride, int r, int g, int b, int fmt){ + switch(fmt){ + case IMGFMT_RGB15: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<10) | ((g>>3)<<5) | (b>>3); + break; + case IMGFMT_BGR15: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<10) | ((g>>3)<<5) | (r>>3); + break; + case IMGFMT_RGB16: ((uint16_t*)(buf + y*stride))[x]= ((r>>3)<<11) | ((g>>2)<<5) | (b>>3); + break; + case IMGFMT_BGR16: ((uint16_t*)(buf + y*stride))[x]= ((b>>3)<<11) | ((g>>2)<<5) | (r>>3); + break; +/* case IMGFMT_RGB32_ME: ((uint32_t*)(buf + y*stride))[x]= (r<<16) | (g<<8) | b; + break; + case IMGFMT_BGR32_ME: ((uint32_t*)(buf + y*stride))[x]= (b<<16) | (g<<8) | r; + break;*/ + case IMGFMT_RGB24: + buf[3*x + y*stride + 0]= r; + buf[3*x + y*stride + 1]= g; + buf[3*x + y*stride + 2]= b; + break; + case IMGFMT_BGR24: + buf[3*x + y*stride + 0]= b; + buf[3*x + y*stride + 1]= g; + buf[3*x + y*stride + 2]= r; + break; + case IMGFMT_RGB32: + buf[4*x + y*stride + 0]= r; + buf[4*x + y*stride + 1]= g; + buf[4*x + y*stride + 2]= b; + break; + case IMGFMT_BGR32: + buf[4*x + y*stride + 0]= b; + buf[4*x + y*stride + 1]= g; + buf[4*x + y*stride + 2]= r; + break; +/* case IMGFMT_ARGB32: + buf[4*x + y*stride + 1]= r; + buf[4*x + y*stride + 2]= g; + buf[4*x + y*stride + 3]= b; + break; + case IMGFMT_ABGR32: + buf[4*x + y*stride + 1]= b; + buf[4*x + y*stride + 2]= g; + buf[4*x + y*stride + 3]= r; + break;*/ + } +} + +static int config(struct vf_instance_s* vf, + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt){ + vf->priv->fmt=getfmt(outfmt); + mp_msg(MSGT_VFILTER,MSGL_V,"rgb test format:%s\n", vo_format_name(outfmt)); + return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt); +} + +static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ + mp_image_t *dmpi; + int x, y; + + // hope we'll get DR buffer: + dmpi=vf_get_image(vf->next,vf->priv->fmt, + MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, + mpi->w, mpi->h); + + for(y=0; y<mpi->h; y++){ + for(x=0; x<mpi->w; x++){ + int c= 256*x/mpi->w; + int r=0,g=0,b=0; + + if(3*y<mpi->h) r=c; + else if(3*y<2*mpi->h) g=c; + else b=c; + + put_pixel(dmpi->planes[0], x, y, dmpi->stride[0], r, g, b, vf->priv->fmt); + } + } + + return vf_next_put_image(vf,dmpi); +} + +//===========================================================================// + +static int query_format(struct vf_instance_s* vf, unsigned int outfmt){ + unsigned int fmt=getfmt(outfmt); + if(!fmt) return 0; + return vf_next_query_format(vf,fmt) & (~VFCAP_CSP_SUPPORTED_BY_HW); +} + +static int open(vf_instance_t *vf, char* args){ + vf->config=config; + vf->put_image=put_image; + vf->query_format=query_format; + vf->priv=malloc(sizeof(struct vf_priv_s)); + return 1; +} + +vf_info_t vf_info_rgbtest = { + "rgbtest", + "rgbtest", + "Michael Niedermayer", + "", + open, + NULL +}; + +//===========================================================================//