summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-30 11:18:20 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-08-30 11:18:20 +0000
commitc134b4ffffab42793bfe7c07504e0a78ed6177fe (patch)
tree543877582afaa706a97879b3500b7362b813cd18
parent17749b33974b52d5bbff8f08c4318244affd9ee2 (diff)
downloadmpv-c134b4ffffab42793bfe7c07504e0a78ed6177fe.tar.bz2
mpv-c134b4ffffab42793bfe7c07504e0a78ed6177fe.tar.xz
added bgr support and support for forcing output format
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7161 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libmpcodecs/vf_palette.c81
1 files changed, 62 insertions, 19 deletions
diff --git a/libmpcodecs/vf_palette.c b/libmpcodecs/vf_palette.c
index f5b2df2097..8abff62d5c 100644
--- a/libmpcodecs/vf_palette.c
+++ b/libmpcodecs/vf_palette.c
@@ -41,8 +41,8 @@ static unsigned int find_best(struct vf_instance_s* vf, unsigned int fmt){
while(*p){
ret=vf->next->query_format(vf->next,*p);
mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3);
- if(ret&2){ best=*p; break;} // no conversion -> bingo!
- if(ret&1 && !best) best=*p; // best with conversion
+ if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo!
+ if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion
++p;
}
return best;
@@ -57,7 +57,8 @@ struct vf_priv_s {
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=find_best(vf,outfmt);
+ if (!vf->priv->fmt)
+ vf->priv->fmt=find_best(vf,outfmt);
if(!vf->priv->fmt){
// no matching fmt, so force one...
if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32;
@@ -70,33 +71,43 @@ static int config(struct vf_instance_s* vf,
static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
- if (!mpi->planes[1])
- {
- mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given\n",vf->info->name);
- return;
- }
-
// 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);
- if(!mpi->planes[1]) mpi->planes[1]=(unsigned char*)gray_pal;
+ if (!mpi->planes[1])
+ {
+ mp_msg(MSGT_VFILTER,MSGL_V,"[%s] no palette given, assuming builtin grayscale one\n",vf->info->name);
+ mpi->planes[1] = (unsigned char*)gray_pal;
+ }
if(mpi->w==mpi->stride[0] && dmpi->w*(dmpi->bpp>>3)==dmpi->stride[0]){
// no stride conversion needed
switch(dmpi->imgfmt&255){
case 15:
- palette8torgb15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ else
+ palette8torgb15(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
break;
case 16:
- palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ else
+ palette8torgb16(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
break;
case 24:
- palette8torgb24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ else
+ palette8torgb24(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
break;
case 32:
- palette8torgb32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
+ else
+ palette8torgb32(mpi->planes[0],dmpi->planes[0],mpi->h*mpi->w,mpi->planes[1]);
break;
}
} else {
@@ -106,13 +117,29 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
unsigned char* dst=dmpi->planes[0]+y*dmpi->stride[0];
switch(dmpi->imgfmt&255){
case 15:
- palette8torgb15(src,dst,mpi->w,mpi->planes[1]);break;
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr15(src,dst,mpi->w,mpi->planes[1]);
+ else
+ palette8torgb15(src,dst,mpi->w,mpi->planes[1]);
+ break;
case 16:
- palette8torgb16(src,dst,mpi->w,mpi->planes[1]);break;
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr16(src,dst,mpi->w,mpi->planes[1]);
+ else
+ palette8torgb16(src,dst,mpi->w,mpi->planes[1]);
+ break;
case 24:
- palette8torgb24(src,dst,mpi->w,mpi->planes[1]);break;
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr24(src,dst,mpi->w,mpi->planes[1]);
+ else
+ palette8torgb24(src,dst,mpi->w,mpi->planes[1]);
+ break;
case 32:
- palette8torgb32(src,dst,mpi->w,mpi->planes[1]);break;
+ if (mpi->flags & MP_IMGFLAG_SWAPPED)
+ palette8tobgr32(src,dst,mpi->w,mpi->planes[1]);
+ else
+ palette8torgb32(src,dst,mpi->w,mpi->planes[1]);
+ break;
}
}
}
@@ -134,14 +161,30 @@ static int open(vf_instance_t *vf, char* args){
vf->put_image=put_image;
vf->query_format=query_format;
vf->priv=malloc(sizeof(struct vf_priv_s));
+ memset(vf->priv, 0, sizeof(struct vf_priv_s));
for(i=0;i<256;i++) gray_pal[i]=0x01010101*i;
+ if (args)
+ {
+ if (!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else
+ if (!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else
+ if (!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else
+ if (!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else
+ if (!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else
+ if (!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else
+ if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else
+ if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else
+ {
+ printf("Unknown forced format name: '%s'\n", args);
+ return(0);
+ }
+ }
return 1;
}
vf_info_t vf_info_palette = {
"8bpp indexed (using palette) -> BGR 15/16/24/32 conversion",
"palette",
- "A'rpi",
+ "A'rpi & Alex",
"",
open
};