2 Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /* values for the flags, the stuff on the command line is different */
20 #define SWS_FAST_BILINEAR 1
21 #define SWS_BILINEAR 2
24 #define SWS_POINT 0x10
26 #define SWS_BICUBLIN 0x40
27 #define SWS_GAUSS 0x80
28 #define SWS_SINC 0x100
29 #define SWS_LANCZOS 0x200
30 #define SWS_SPLINE 0x400
32 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
33 #define SWS_SRC_V_CHR_DROP_SHIFT 16
35 #define SWS_PARAM_MASK 0x3FC0000
36 #define SWS_PARAM_SHIFT 18
38 #define SWS_PRINT_INFO 0x1000
40 //the following 3 flags are not completly implemented
41 //internal chrominace subsamling info
42 #define SWS_FULL_CHR_H_INT 0x2000
43 //input subsampling info
44 #define SWS_FULL_CHR_H_INP 0x4000
45 #define SWS_DIRECT_BGR 0x8000
47 #define MAX_FILTER_SIZE 256
49 #define SWS_MAX_REDUCE_CUTOFF 0.002
51 /* this struct should be aligned on at least 32-byte boundary */
52 typedef struct SwsContext{
54 int chrSrcW, chrSrcH, chrDstW, chrDstH;
57 int dstFormat, srcFormat;
58 int chrSrcHSubSample, chrSrcVSubSample;
59 int chrIntHSubSample, chrIntVSubSample;
60 int chrDstHSubSample, chrDstVSubSample;
66 int16_t *hLumFilterPos;
68 int16_t *hChrFilterPos;
70 int16_t *vLumFilterPos;
72 int16_t *vChrFilterPos;
74 uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
83 uint8_t __attribute__((aligned(32))) funnyYCode[10000];
84 uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
85 int32_t *lumMmx2FilterPos;
86 int32_t *chrMmx2FilterPos;
87 int16_t *lumMmx2Filter;
88 int16_t *chrMmx2Filter;
100 void * table_gU[256];
102 void * table_bU[256];
104 void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
105 int srcSliceH, uint8_t* dst[], int dstStride[]);
107 #define RED_DITHER "0*8"
108 #define GREEN_DITHER "1*8"
109 #define BLUE_DITHER "2*8"
110 #define Y_COEFF "3*8"
111 #define VR_COEFF "4*8"
112 #define UB_COEFF "5*8"
113 #define VG_COEFF "6*8"
114 #define UG_COEFF "7*8"
115 #define Y_OFFSET "8*8"
116 #define U_OFFSET "9*8"
117 #define V_OFFSET "10*8"
118 #define LUM_MMX_FILTER_OFFSET "11*8"
119 #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
120 #define DSTW_OFFSET "11*8+4*4*256*2"
121 #define ESP_OFFSET "11*8+4*4*256*2+4"
123 uint64_t redDither __attribute__((aligned(8)));
124 uint64_t greenDither __attribute__((aligned(8)));
125 uint64_t blueDither __attribute__((aligned(8)));
127 uint64_t yCoeff __attribute__((aligned(8)));
128 uint64_t vrCoeff __attribute__((aligned(8)));
129 uint64_t ubCoeff __attribute__((aligned(8)));
130 uint64_t vgCoeff __attribute__((aligned(8)));
131 uint64_t ugCoeff __attribute__((aligned(8)));
132 uint64_t yOffset __attribute__((aligned(8)));
133 uint64_t uOffset __attribute__((aligned(8)));
134 uint64_t vOffset __attribute__((aligned(8)));
135 int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
136 int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
140 //FIXME check init (where 0)
141 //FIXME split private & public
144 // when used for filters they must have an odd number of elements
145 // coeffs cannot be shared between vectors
151 // vectors can be shared
160 // *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
161 // *** Note: it's called multiple times while decoding a frame, first time y==0
162 // dstbpp == 12 -> yv12 output
163 // will use sws_flags
164 void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
165 int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
166 int srcW, int srcH, int dstW, int dstH);
168 // Obsolete, will be removed soon
173 void freeSwsContext(SwsContext *swsContext);
175 SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
176 SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
177 SwsFilter *srcFilter, SwsFilter *dstFilter);
178 void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
180 SwsVector *getGaussianVec(double variance, double quality);
181 SwsVector *getConstVec(double c, int length);
182 SwsVector *getIdentityVec(void);
183 void scaleVec(SwsVector *a, double scalar);
184 void normalizeVec(SwsVector *a, double height);
185 void convVec(SwsVector *a, SwsVector *b);
186 void addVec(SwsVector *a, SwsVector *b);
187 void subVec(SwsVector *a, SwsVector *b);
188 void shiftVec(SwsVector *a, int shift);
189 SwsVector *cloneVec(SwsVector *a);
191 void printVec(SwsVector *a);
192 void freeVec(SwsVector *a);