2002-01-21 18:32:31 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2001-10-15 19:06:16 +00:00
|
|
|
|
2002-01-20 05:30:23 +00:00
|
|
|
/* values for the flags, the stuff on the command line is different */
|
|
|
|
#define SWS_FAST_BILINEAR 1
|
|
|
|
#define SWS_BILINEAR 2
|
|
|
|
#define SWS_BICUBIC 4
|
|
|
|
#define SWS_X 8
|
2002-01-28 23:57:18 +00:00
|
|
|
#define SWS_POINT 0x10
|
2002-01-29 01:43:15 +00:00
|
|
|
#define SWS_AREA 0x20
|
2002-06-27 19:17:25 +00:00
|
|
|
#define SWS_BICUBLIN 0x40
|
2002-02-01 19:25:09 +00:00
|
|
|
|
2002-06-24 00:18:29 +00:00
|
|
|
#define SWS_SRC_V_CHR_DROP_MASK 0x300
|
|
|
|
#define SWS_SRC_V_CHR_DROP_SHIFT 8
|
|
|
|
|
2002-02-01 19:25:09 +00:00
|
|
|
//the following 4 flags are not completly implemented
|
|
|
|
//internal chrominace subsamling info
|
2002-06-24 00:56:27 +00:00
|
|
|
#define SWS_FULL_CHR_H_INT 0x2000
|
2002-02-01 19:25:09 +00:00
|
|
|
//input subsampling info
|
2002-06-24 00:56:27 +00:00
|
|
|
#define SWS_FULL_CHR_H_INP 0x4000
|
|
|
|
#define SWS_DIRECT_BGR 0x8000
|
2002-02-01 19:25:09 +00:00
|
|
|
|
2002-01-20 05:30:23 +00:00
|
|
|
#define SWS_PRINT_INFO 0x1000
|
|
|
|
|
2002-01-21 03:56:47 +00:00
|
|
|
#define SWS_MAX_REDUCE_CUTOFF 0.002
|
2002-01-20 05:30:23 +00:00
|
|
|
|
|
|
|
/* this struct should be aligned on at least 32-byte boundary */
|
2002-02-06 20:52:14 +00:00
|
|
|
typedef struct SwsContext{
|
2002-01-20 05:30:23 +00:00
|
|
|
int srcW, srcH, dstW, dstH;
|
2002-02-01 19:25:09 +00:00
|
|
|
int chrSrcW, chrSrcH, chrDstW, chrDstH;
|
2002-01-20 05:30:23 +00:00
|
|
|
int lumXInc, chrXInc;
|
|
|
|
int lumYInc, chrYInc;
|
|
|
|
int dstFormat, srcFormat;
|
2002-06-23 10:36:18 +00:00
|
|
|
int chrSrcHSubSample, chrSrcVSubSample;
|
|
|
|
int chrIntHSubSample, chrIntVSubSample;
|
|
|
|
int chrDstHSubSample, chrDstVSubSample;
|
2002-06-24 00:18:29 +00:00
|
|
|
int vChrDrop;
|
2002-01-21 03:56:47 +00:00
|
|
|
|
|
|
|
int16_t **lumPixBuf;
|
|
|
|
int16_t **chrPixBuf;
|
|
|
|
int16_t *hLumFilter;
|
|
|
|
int16_t *hLumFilterPos;
|
|
|
|
int16_t *hChrFilter;
|
|
|
|
int16_t *hChrFilterPos;
|
|
|
|
int16_t *vLumFilter;
|
|
|
|
int16_t *vLumFilterPos;
|
|
|
|
int16_t *vChrFilter;
|
|
|
|
int16_t *vChrFilterPos;
|
2002-01-20 05:30:23 +00:00
|
|
|
|
|
|
|
// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
|
2002-01-21 03:56:47 +00:00
|
|
|
int16_t *lumMmxFilter;
|
|
|
|
int16_t *chrMmxFilter;
|
2002-02-01 19:25:09 +00:00
|
|
|
uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
|
2002-01-20 05:30:23 +00:00
|
|
|
|
|
|
|
int hLumFilterSize;
|
|
|
|
int hChrFilterSize;
|
|
|
|
int vLumFilterSize;
|
|
|
|
int vChrFilterSize;
|
|
|
|
int vLumBufSize;
|
|
|
|
int vChrBufSize;
|
|
|
|
|
|
|
|
uint8_t __attribute__((aligned(32))) funnyYCode[10000];
|
|
|
|
uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
|
2002-04-01 14:01:22 +00:00
|
|
|
int32_t *lumMmx2FilterPos;
|
|
|
|
int32_t *chrMmx2FilterPos;
|
|
|
|
int16_t *lumMmx2Filter;
|
|
|
|
int16_t *chrMmx2Filter;
|
2002-01-20 05:30:23 +00:00
|
|
|
|
|
|
|
int canMMX2BeUsed;
|
|
|
|
|
|
|
|
int lastInLumBuf;
|
|
|
|
int lastInChrBuf;
|
|
|
|
int lumBufIndex;
|
|
|
|
int chrBufIndex;
|
|
|
|
int dstY;
|
|
|
|
int flags;
|
2002-06-27 18:00:47 +00:00
|
|
|
void * yuvTable;
|
|
|
|
void * table_rV[256];
|
|
|
|
void * table_gU[256];
|
|
|
|
int table_gV[256];
|
|
|
|
void * table_bU[256];
|
2002-02-06 20:52:14 +00:00
|
|
|
|
|
|
|
void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
|
|
|
|
int srcSliceH, uint8_t* dst[], int dstStride[]);
|
2002-01-20 05:30:23 +00:00
|
|
|
} SwsContext;
|
|
|
|
//FIXME check init (where 0)
|
|
|
|
|
2002-01-21 03:56:47 +00:00
|
|
|
// when used for filters they must have an odd number of elements
|
|
|
|
// coeffs cannot be shared between vectors
|
2002-01-20 05:30:23 +00:00
|
|
|
typedef struct {
|
2002-01-21 03:56:47 +00:00
|
|
|
double *coeff;
|
2002-01-20 05:30:23 +00:00
|
|
|
int length;
|
2002-01-21 03:56:47 +00:00
|
|
|
} SwsVector;
|
|
|
|
|
|
|
|
// vectors can be shared
|
|
|
|
typedef struct {
|
|
|
|
SwsVector *lumH;
|
|
|
|
SwsVector *lumV;
|
|
|
|
SwsVector *chrH;
|
|
|
|
SwsVector *chrV;
|
2002-01-20 05:30:23 +00:00
|
|
|
} SwsFilter;
|
|
|
|
|
2001-12-02 20:03:26 +00:00
|
|
|
|
2001-10-28 18:30:59 +00:00
|
|
|
// *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
|
2001-10-15 19:06:16 +00:00
|
|
|
// *** Note: it's called multiple times while decoding a frame, first time y==0
|
2001-10-28 18:30:59 +00:00
|
|
|
// dstbpp == 12 -> yv12 output
|
2002-01-20 05:30:23 +00:00
|
|
|
// will use sws_flags
|
|
|
|
void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
|
|
|
|
int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
|
2001-11-29 20:19:17 +00:00
|
|
|
int srcW, int srcH, int dstW, int dstH);
|
2002-01-20 05:30:23 +00:00
|
|
|
|
|
|
|
// Obsolete, will be removed soon
|
|
|
|
void SwScale_Init();
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-01-21 03:56:47 +00:00
|
|
|
void freeSwsContext(SwsContext *swsContext);
|
2002-01-20 05:30:23 +00:00
|
|
|
|
2002-01-30 15:21:08 +00:00
|
|
|
SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
|
2002-01-20 05:30:23 +00:00
|
|
|
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
|
|
|
|
SwsFilter *srcFilter, SwsFilter *dstFilter);
|
2002-06-24 00:18:29 +00:00
|
|
|
void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
|
2002-01-20 05:30:23 +00:00
|
|
|
|
2002-01-21 03:56:47 +00:00
|
|
|
SwsVector *getGaussianVec(double variance, double quality);
|
2002-01-21 22:11:09 +00:00
|
|
|
SwsVector *getConstVec(double c, int length);
|
2002-01-21 03:56:47 +00:00
|
|
|
SwsVector *getIdentityVec(void);
|
|
|
|
void scaleVec(SwsVector *a, double scalar);
|
|
|
|
void normalizeVec(SwsVector *a, double height);
|
2002-01-21 15:22:28 +00:00
|
|
|
void convVec(SwsVector *a, SwsVector *b);
|
|
|
|
void addVec(SwsVector *a, SwsVector *b);
|
|
|
|
void subVec(SwsVector *a, SwsVector *b);
|
|
|
|
void shiftVec(SwsVector *a, int shift);
|
|
|
|
SwsVector *cloneVec(SwsVector *a);
|
2002-01-21 03:56:47 +00:00
|
|
|
|
|
|
|
void printVec(SwsVector *a);
|
|
|
|
void freeVec(SwsVector *a);
|
2002-01-20 05:30:23 +00:00
|
|
|
|