[Mplayer-cvslog] CVS: main/postproc swscale.c,1.48,1.49 swscale_template.c,1.49,1.50 swscale.h,1.4,1.5
Michael Niedermayer
michael at mplayer.dev.hu
Thu Dec 6 01:10:53 CET 2001
Update of /cvsroot/mplayer/main/postproc
In directory mplayer:/var/tmp.root/cvs-serv6609
Modified Files:
swscale.c swscale_template.c swscale.h
Log Message:
vertical cubic/linear scaling
prints some info (MMX, dstbpp, ...)
mainloop rewritten
Index: swscale.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- swscale.c 2 Dec 2001 20:03:20 -0000 1.48
+++ swscale.c 6 Dec 2001 00:10:42 -0000 1.49
@@ -8,8 +8,11 @@
#include <inttypes.h>
#include <string.h>
#include <math.h>
-//#include <stdio.h> //FOR DEBUG ONLY
+#include <stdio.h>
#include "../config.h"
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
#include "swscale.h"
#include "../cpudetect.h"
#undef MOVNTQ
@@ -24,22 +27,28 @@
int allwaysIpol=0;
#define RET 0xC3 //near return opcode
+
+//#define ASSERT(x) if(!(x)) { printf("ASSERT " #x " failed\n"); *((int*)0)=0; }
+#define ASSERT(x) ;
+
+
/*
NOTES
known BUGS with known cause (no bugreports please!, but patches are welcome :) )
horizontal MMX2 scaler reads 1-7 samples too much (might cause a sig11)
-Supported output formats BGR15 BGR16 BGR24 BGR32
+Supported output formats BGR15 BGR16 BGR24 BGR32, YV12
BGR15 & BGR16 MMX verions support dithering
Special versions: fast Y 1:1 scaling (no interpolation in y direction)
TODO
more intelligent missalignment avoidance for the horizontal scaler
-bicubic scaler
dither in C
change the distance of the u & v buffer
-how to differenciate between x86 an C at runtime ?! (using C for now)
+Move static / global vars into a struct so multiple scalers can be used
+write special vertical cubic upscale version
+Optimize C code (yv12 / minmax)
*/
#define ABS(a) ((a) > 0 ? (a) : (-(a)))
@@ -94,21 +103,35 @@
static uint64_t __attribute__((aligned(8))) asm_yalpha1;
static uint64_t __attribute__((aligned(8))) asm_uvalpha1;
-// temporary storage for 4 yuv lines:
-// 16bit for now (mmx likes it more compact)
-static uint16_t __attribute__((aligned(8))) pix_buf_y[4][2048];
-static uint16_t __attribute__((aligned(8))) pix_buf_uv[2][2048*2];
+static int16_t __attribute__((aligned(8))) *lumPixBuf[2000];
+static int16_t __attribute__((aligned(8))) *chrPixBuf[2000];
static int16_t __attribute__((aligned(8))) hLumFilter[8000];
static int16_t __attribute__((aligned(8))) hLumFilterPos[2000];
static int16_t __attribute__((aligned(8))) hChrFilter[8000];
static int16_t __attribute__((aligned(8))) hChrFilterPos[2000];
+static int16_t __attribute__((aligned(8))) vLumFilter[8000];
+static int16_t __attribute__((aligned(8))) vLumFilterPos[2000];
+static int16_t __attribute__((aligned(8))) vChrFilter[8000];
+static int16_t __attribute__((aligned(8))) vChrFilterPos[2000];
+
+// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
+//FIXME these are very likely too small / 8000 caused problems with 480x480
+static int16_t __attribute__((aligned(8))) lumMmxFilter[16000];
+static int16_t __attribute__((aligned(8))) chrMmxFilter[16000];
#else
-static uint16_t pix_buf_y[4][2048];
-static uint16_t pix_buf_uv[2][2048*2];
+static int16_t *lumPixBuf[2000];
+static int16_t *chrPixBuf[2000];
static int16_t hLumFilter[8000];
static int16_t hLumFilterPos[2000];
static int16_t hChrFilter[8000];
static int16_t hChrFilterPos[2000];
+static int16_t vLumFilter[8000];
+static int16_t vLumFilterPos[2000];
+static int16_t vChrFilter[8000];
+static int16_t vChrFilterPos[2000];
+//FIXME just dummy vars
+static int16_t lumMmxFilter[1];
+static int16_t chrMmxFilter[1];
#endif
// clipping helper table for C implementations:
@@ -127,9 +150,19 @@
static int yuvtab_0c92[256];
static int yuvtab_1a1e[256];
static int yuvtab_40cf[256];
-
-static int hLumFilterSize;
-static int hChrFilterSize;
+// Needed for cubic scaler to catch overflows
+static int clip_yuvtab_2568[768];
+static int clip_yuvtab_3343[768];
+static int clip_yuvtab_0c92[768];
+static int clip_yuvtab_1a1e[768];
+static int clip_yuvtab_40cf[768];
+
+static int hLumFilterSize=0;
+static int hChrFilterSize=0;
+static int vLumFilterSize=0;
+static int vChrFilterSize=0;
+static int vLumBufSize=0;
+static int vChrBufSize=0;
int sws_flags=0;
@@ -274,15 +307,14 @@
void SwScale_Init(){
// generating tables:
int i;
- for(i=0;i<256;i++){
- clip_table[i]=0;
- clip_table[i+256]=i;
- clip_table[i+512]=255;
- yuvtab_2568[i]=(0x2568*(i-16))+(256<<13);
- yuvtab_3343[i]=0x3343*(i-128);
- yuvtab_0c92[i]=-0x0c92*(i-128);
- yuvtab_1a1e[i]=-0x1a1e*(i-128);
- yuvtab_40cf[i]=0x40cf*(i-128);
+ for(i=0; i<768; i++){
+ int c= MIN(MAX(i-256, 0), 255);
+ clip_table[i]=c;
+ yuvtab_2568[c]= clip_yuvtab_2568[i]=(0x2568*(c-16))+(256<<13);
+ yuvtab_3343[c]= clip_yuvtab_3343[i]=0x3343*(c-128);
+ yuvtab_0c92[c]= clip_yuvtab_0c92[i]=-0x0c92*(c-128);
+ yuvtab_1a1e[c]= clip_yuvtab_1a1e[i]=-0x1a1e*(c-128);
+ yuvtab_40cf[c]= clip_yuvtab_40cf[i]=0x40cf*(c-128);
}
for(i=0; i<768; i++)
@@ -295,5 +327,6 @@
clip_table15g[i]= (v<<2)&0x03E0;
clip_table15r[i]= (v<<7)&0x7C00;
}
+
}
Index: swscale_template.c
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale_template.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- swscale_template.c 3 Dec 2001 22:24:43 -0000 1.49
+++ swscale_template.c 6 Dec 2001 00:10:42 -0000 1.50
@@ -5,11 +5,6 @@
// current version mostly by Michael Niedermayer (michaelni at gmx.at)
// the parts written by michael are under GNU GPL
-/* TODO
-Move static / global vars into a struct so multiple scalers can be used
-write vertical cubic upscale / linear downscale stuff
-*/
-
#undef MOVNTQ
#undef PAVGB
#undef PREFETCH
[...1561 lines suppressed...]
- g5Dither= dither8[dstY&1];
- r5Dither= dither8[(dstY+1)&1];
-#endif
-
- if(dstbpp==12) //YV12
- RENAME(yuv2yuv)(buf0, buf1, uvbuf0, uvbuf1, dest, uDest, vDest, dstW, yalpha, uvalpha);
- else if(ABS(s_yinc - 0x10000) < 10)
- RENAME(yuv2rgb1)(buf0, buf1, uvbuf0, uvbuf1, dest, dstW, yalpha, uvalpha, dstbpp);
- else
- RENAME(yuv2rgbX)(buf0, buf1, uvbuf0, uvbuf1, dest, dstW, yalpha, uvalpha, dstbpp);
- }
#ifdef HAVE_MMX
__asm __volatile(SFENCE:::"memory");
__asm __volatile(EMMS:::"memory");
#endif
-}
+ firstTime=0;
+}
\ No newline at end of file
Index: swscale.h
===================================================================
RCS file: /cvsroot/mplayer/main/postproc/swscale.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- swscale.h 2 Dec 2001 20:03:20 -0000 1.4
+++ swscale.h 6 Dec 2001 00:10:42 -0000 1.5
@@ -11,4 +11,4 @@
int srcSliceH, uint8_t* dstptr[], int dststride, int dstbpp,
int srcW, int srcH, int dstW, int dstH);
// generating tables
-void SwScale_Init();
+void SwScale_Init();
\ No newline at end of file
More information about the MPlayer-cvslog
mailing list