rgb test pattern generator, so we could change everything to match alex's definition of rgb/bgr

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11895 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
michael 2004-01-30 17:38:15 +00:00
parent 113f516189
commit 4fd6abadcf
3 changed files with 144 additions and 1 deletions

View File

@ -14,7 +14,7 @@ VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_raw.c vd_hmblck.c vd_fli.c vd_qtrle.c v
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

View File

@ -84,6 +84,7 @@ extern vf_info_t vf_info_hue;
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 @@ static vf_info_t* filter_list[]={
#endif
&vf_info_yuvcsp,
&vf_info_kerndeint,
&vf_info_rgbtest,
NULL
};

141
libmpcodecs/vf_rgbtest.c Normal file
View File

@ -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
};
//===========================================================================//