summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vf_scale.c
diff options
context:
space:
mode:
authorarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-04-07 21:33:42 +0000
committerarpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-04-07 21:33:42 +0000
commit5679435133fbb046956cccceeff278e08ea79707 (patch)
treeb4d31a869f907674651bc59ceb3429013db60291 /libmpcodecs/vf_scale.c
parentabd870166d55db9437e5913ca608e5cfc27ecf94 (diff)
downloadmpv-5679435133fbb046956cccceeff278e08ea79707.tar.bz2
mpv-5679435133fbb046956cccceeff278e08ea79707.tar.xz
colorspace conversion support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5524 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/vf_scale.c')
-rw-r--r--libmpcodecs/vf_scale.c58
1 files changed, 56 insertions, 2 deletions
diff --git a/libmpcodecs/vf_scale.c b/libmpcodecs/vf_scale.c
index 0f58137178..407151f82d 100644
--- a/libmpcodecs/vf_scale.c
+++ b/libmpcodecs/vf_scale.c
@@ -6,6 +6,7 @@
#include "../config.h"
#include "../mp_msg.h"
+#include "../libvo/img_format.h"
#include "../mp_image.h"
#include "vf.h"
@@ -14,25 +15,58 @@
struct vf_priv_s {
int w,h;
+ unsigned int fmt;
SwsContext *ctx;
};
//===========================================================================//
+static unsigned int outfmt_list[]={
+ IMGFMT_BGR32,
+ IMGFMT_BGR24,
+ IMGFMT_BGR16,
+ IMGFMT_BGR15,
+ IMGFMT_YV12,
+ IMGFMT_I420,
+ IMGFMT_IYUV,
+ NULL
+};
+
static int config(struct vf_instance_s* vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt){
+ unsigned int* p=outfmt_list;
+ unsigned int best=0;
+ // find the best outfmt:
+ while(*p){
+ int ret=vf_next_query_format(vf,*p);
+ mp_msg(MSGT_VFILTER,MSGL_V,"scale: query(%s) -> %d\n",vo_format_name(*p),ret&3);
+ if(ret&2){ best=*p; break;} // no conversion -> bingo!
+ if(ret&1 && !best) best=*p; // best with conversion
+ ++p;
+ }
+ if(!best){
+ printf("SwScale: no supported outfmt found :(\n");
+ return 0;
+ }
+
// calculate the missing parameters:
if(vf->priv->w<=0) vf->priv->w=width;
if(vf->priv->h<=0) vf->priv->h=height;
+
+ printf("SwScale scaling %dx%d %s to %dx%d %s \n",
+ width,height,vo_format_name(outfmt),
+ vf->priv->w,vf->priv->h,vo_format_name(best));
+
// new swscaler:
vf->priv->ctx=getSwsContextFromCmdLine(width,height,outfmt,
- vf->priv->w,vf->priv->h,outfmt);
+ vf->priv->w,vf->priv->h,best);
if(!vf->priv->ctx){
// error...
printf("Couldn't init SwScaler for this setup\n");
return 0;
}
+ vf->priv->fmt=best;
return vf_next_config(vf,vf->priv->w,vf->priv->h,d_width,d_height,flags,outfmt);
}
@@ -40,7 +74,7 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mp_image_t *dmpi;
// hope we'll get DR buffer:
- dmpi=vf_get_image(vf->next,mpi->imgfmt,
+ dmpi=vf_get_image(vf->next,vf->priv->fmt,
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
vf->priv->w, vf->priv->h);
@@ -51,6 +85,26 @@ static void put_image(struct vf_instance_s* vf, mp_image_t *mpi){
//===========================================================================//
+// supported Input formats: YV12, I420, IYUV, YUY2, BGR32, BGR24, BGR16, BGR15, RGB32, RGB24, Y8, Y800
+
+static int query_format(struct vf_instance_s* vf, unsigned int fmt){
+ switch(fmt){
+ case IMGFMT_YV12:
+ case IMGFMT_I420:
+ case IMGFMT_IYUV:
+ case IMGFMT_YUY2:
+ case IMGFMT_BGR32:
+ case IMGFMT_BGR24:
+ case IMGFMT_BGR16:
+ case IMGFMT_BGR15:
+ case IMGFMT_RGB32:
+ case IMGFMT_RGB24:
+ case IMGFMT_Y800:
+ return 3; //vf_next_query_format(vf,fmt);
+ }
+ return 0;
+}
+
static int open(vf_instance_t *vf, char* args){
vf->config=config;
vf->put_image=put_image;