annotate postproc/swscale.h @ 9092:fd6bb2bb82c6

sync
author nicolas
date Sat, 25 Jan 2003 21:53:39 +0000
parents f47f12ba3b88
children 0d86fe21b281
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4295
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
1 /*
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
2 Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at>
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
3
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
4 This program is free software; you can redistribute it and/or modify
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
5 it under the terms of the GNU General Public License as published by
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
6 the Free Software Foundation; either version 2 of the License, or
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
7 (at your option) any later version.
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
8
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
9 This program is distributed in the hope that it will be useful,
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
12 GNU General Public License for more details.
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
13
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
14 You should have received a copy of the GNU General Public License
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
15 along with this program; if not, write to the Free Software
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
67c56df76a44 copyright(swscaler) = GPL
michael
parents: 4294
diff changeset
17 */
3272
7e4399d1eb65 horizontal up/downscale linear & cubic
michael
parents: 3209
diff changeset
18
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
19 /* values for the flags, the stuff on the command line is different */
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
20 #define SWS_FAST_BILINEAR 1
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
21 #define SWS_BILINEAR 2
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
22 #define SWS_BICUBIC 4
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
23 #define SWS_X 8
4401
8d00348d0d6b nearest neighbor / sdl emulation ;) scaling (-sws 4)
michael
parents: 4297
diff changeset
24 #define SWS_POINT 0x10
4402
67abbf501b02 area averageing scaling support (-sws 5) (is identical to bilinear for upscale)
michael
parents: 4401
diff changeset
25 #define SWS_AREA 0x20
6580
5059143aa020 -sws 6 (luma bicubic & chroma bilinear)
michael
parents: 6578
diff changeset
26 #define SWS_BICUBLIN 0x40
6637
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
27 #define SWS_GAUSS 0x80
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
28 #define SWS_SINC 0x100
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
29 #define SWS_LANCZOS 0x200
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
30 #define SWS_SPLINE 0x400
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
31
6637
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
32 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
33 #define SWS_SRC_V_CHR_DROP_SHIFT 16
6540
5b3cace64e9d 100l (non mmx versions didnt compile)
michael
parents: 6517
diff changeset
34
6637
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
35 #define SWS_PARAM_MASK 0x3FC0000
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
36 #define SWS_PARAM_SHIFT 18
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
37
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
38 #define SWS_PRINT_INFO 0x1000
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
39
f47f12ba3b88 more scaling algos
michael
parents: 6580
diff changeset
40 //the following 3 flags are not completly implemented
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
41 //internal chrominace subsamling info
6541
michael
parents: 6540
diff changeset
42 #define SWS_FULL_CHR_H_INT 0x2000
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
43 //input subsampling info
6541
michael
parents: 6540
diff changeset
44 #define SWS_FULL_CHR_H_INP 0x4000
michael
parents: 6540
diff changeset
45 #define SWS_DIRECT_BGR 0x8000
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
46
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
47
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
48 #define SWS_MAX_REDUCE_CUTOFF 0.002
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
49
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
50 /* this struct should be aligned on at least 32-byte boundary */
4554
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4467
diff changeset
51 typedef struct SwsContext{
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
52 int srcW, srcH, dstW, dstH;
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
53 int chrSrcW, chrSrcH, chrDstW, chrDstH;
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
54 int lumXInc, chrXInc;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
55 int lumYInc, chrYInc;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
56 int dstFormat, srcFormat;
6517
5ac294a77a87 selftest support
michael
parents: 5452
diff changeset
57 int chrSrcHSubSample, chrSrcVSubSample;
5ac294a77a87 selftest support
michael
parents: 5452
diff changeset
58 int chrIntHSubSample, chrIntVSubSample;
5ac294a77a87 selftest support
michael
parents: 5452
diff changeset
59 int chrDstHSubSample, chrDstVSubSample;
6540
5b3cace64e9d 100l (non mmx versions didnt compile)
michael
parents: 6517
diff changeset
60 int vChrDrop;
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
61
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
62 int16_t **lumPixBuf;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
63 int16_t **chrPixBuf;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
64 int16_t *hLumFilter;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
65 int16_t *hLumFilterPos;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
66 int16_t *hChrFilter;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
67 int16_t *hChrFilterPos;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
68 int16_t *vLumFilter;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
69 int16_t *vLumFilterPos;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
70 int16_t *vChrFilter;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
71 int16_t *vChrFilterPos;
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
72
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
73 // Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
74 int16_t *lumMmxFilter;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
75 int16_t *chrMmxFilter;
4467
9512d6832b38 YUY2, BGR24, BGR32 input support (no mmx yet)
michael
parents: 4419
diff changeset
76 uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
77
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
78 int hLumFilterSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
79 int hChrFilterSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
80 int vLumFilterSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
81 int vChrFilterSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
82 int vLumBufSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
83 int vChrBufSize;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
84
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
85 uint8_t __attribute__((aligned(32))) funnyYCode[10000];
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
86 uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
5452
eb87391a5292 overread in the mmx2 horizontal scaler fixed
michael
parents: 4554
diff changeset
87 int32_t *lumMmx2FilterPos;
eb87391a5292 overread in the mmx2 horizontal scaler fixed
michael
parents: 4554
diff changeset
88 int32_t *chrMmx2FilterPos;
eb87391a5292 overread in the mmx2 horizontal scaler fixed
michael
parents: 4554
diff changeset
89 int16_t *lumMmx2Filter;
eb87391a5292 overread in the mmx2 horizontal scaler fixed
michael
parents: 4554
diff changeset
90 int16_t *chrMmx2Filter;
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
91
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
92 int canMMX2BeUsed;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
93
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
94 int lastInLumBuf;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
95 int lastInChrBuf;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
96 int lumBufIndex;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
97 int chrBufIndex;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
98 int dstY;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
99 int flags;
6578
3727eb94a783 use unified yuv2rgb init
michael
parents: 6541
diff changeset
100 void * yuvTable;
3727eb94a783 use unified yuv2rgb init
michael
parents: 6541
diff changeset
101 void * table_rV[256];
3727eb94a783 use unified yuv2rgb init
michael
parents: 6541
diff changeset
102 void * table_gU[256];
3727eb94a783 use unified yuv2rgb init
michael
parents: 6541
diff changeset
103 int table_gV[256];
3727eb94a783 use unified yuv2rgb init
michael
parents: 6541
diff changeset
104 void * table_bU[256];
4554
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4467
diff changeset
105
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4467
diff changeset
106 void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
16fdb694cf13 swScale internally uses yuv2rgb now if possible
michael
parents: 4467
diff changeset
107 int srcSliceH, uint8_t* dst[], int dstStride[]);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
108 } SwsContext;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
109 //FIXME check init (where 0)
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
110
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
111 // when used for filters they must have an odd number of elements
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
112 // coeffs cannot be shared between vectors
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
113 typedef struct {
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
114 double *coeff;
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
115 int length;
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
116 } SwsVector;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
117
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
118 // vectors can be shared
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
119 typedef struct {
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
120 SwsVector *lumH;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
121 SwsVector *lumV;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
122 SwsVector *chrH;
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
123 SwsVector *chrV;
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
124 } SwsFilter;
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
125
2217
fd9311c3fa42 header for swscale.c
arpi
parents:
diff changeset
126
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2217
diff changeset
127 // *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
2217
fd9311c3fa42 header for swscale.c
arpi
parents:
diff changeset
128 // *** Note: it's called multiple times while decoding a frame, first time y==0
2519
6f3fa9bc3b27 yv12 to yv12 scaler
michael
parents: 2217
diff changeset
129 // dstbpp == 12 -> yv12 output
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
130 // will use sws_flags
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
131 void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
132 int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
3209
0b172eb639f1 swscaler cleanup
michael
parents: 2519
diff changeset
133 int srcW, int srcH, int dstW, int dstH);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
134
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
135 // Obsolete, will be removed soon
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
136 void SwScale_Init();
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
137
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
138
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
139
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
140 void freeSwsContext(SwsContext *swsContext);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
141
4419
f002407e298d YV12 like formats support (I420/IYUV)
michael
parents: 4402
diff changeset
142 SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
143 SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
144 SwsFilter *srcFilter, SwsFilter *dstFilter);
6540
5b3cace64e9d 100l (non mmx versions didnt compile)
michael
parents: 6517
diff changeset
145 void swsGetFlagsAndFilterFromCmdLine(int *flags, SwsFilter **srcFilterParam, SwsFilter **dstFilterParam);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
146
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
147 SwsVector *getGaussianVec(double variance, double quality);
4297
29fef3982238 15/16 bit dithering in C (5% slower, can be disabled by comenting #define DITHER1XBPP out)
michael
parents: 4295
diff changeset
148 SwsVector *getConstVec(double c, int length);
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
149 SwsVector *getIdentityVec(void);
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
150 void scaleVec(SwsVector *a, double scalar);
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
151 void normalizeVec(SwsVector *a, double height);
4294
21dbbbbd5479 a few filters (should be removed/merged when arpis videofilter stuff is finished)
michael
parents: 4290
diff changeset
152 void convVec(SwsVector *a, SwsVector *b);
21dbbbbd5479 a few filters (should be removed/merged when arpis videofilter stuff is finished)
michael
parents: 4290
diff changeset
153 void addVec(SwsVector *a, SwsVector *b);
21dbbbbd5479 a few filters (should be removed/merged when arpis videofilter stuff is finished)
michael
parents: 4290
diff changeset
154 void subVec(SwsVector *a, SwsVector *b);
21dbbbbd5479 a few filters (should be removed/merged when arpis videofilter stuff is finished)
michael
parents: 4290
diff changeset
155 void shiftVec(SwsVector *a, int shift);
21dbbbbd5479 a few filters (should be removed/merged when arpis videofilter stuff is finished)
michael
parents: 4290
diff changeset
156 SwsVector *cloneVec(SwsVector *a);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
157
4290
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
158 void printVec(SwsVector *a);
1f8ceb12284d general convolution filtering of the source picture
michael
parents: 4276
diff changeset
159 void freeVec(SwsVector *a);
4276
9199d15cb4e0 removed global vars so that multiple swscalers can be used
michael
parents: 3344
diff changeset
160