Statistics
| Branch: | Revision:

ffmpeg / postproc / swscale.h @ c7a810cc

History | View | Annotate | Download (4.28 KB)

1 fe8054c0 Michael Niedermayer
/*
2
    Copyright (C) 2001-2002 Michael Niedermayer <michaelni@gmx.at>
3

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.
8

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.
13

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
17
*/
18 3db822b0 Arpi
19 28bf81c9 Michael Niedermayer
/* values for the flags, the stuff on the command line is different */
20
#define SWS_FAST_BILINEAR 1
21
#define SWS_BILINEAR 2
22
#define SWS_BICUBIC  4
23
#define SWS_X        8
24 ff7ba856 Michael Niedermayer
#define SWS_POINT    0x10
25 d8863d37 Michael Niedermayer
#define SWS_AREA     0x20
26 1e621b18 Michael Niedermayer
27
//the following 4 flags are not completly implemented
28
//internal chrominace subsamling info
29
#define SWS_FULL_CHR_V                0x100
30
#define SWS_FULL_CHR_H_INT        0x200
31
//input subsampling info
32
#define SWS_FULL_CHR_H_INP        0x400
33
#define SWS_DIRECT_BGR                0x800
34
35 28bf81c9 Michael Niedermayer
#define SWS_PRINT_INFO 0x1000
36
37 c7f822d9 Michael Niedermayer
#define SWS_MAX_REDUCE_CUTOFF 0.002
38 28bf81c9 Michael Niedermayer
39
/* this struct should be aligned on at least 32-byte boundary */
40 37079906 Michael Niedermayer
typedef struct SwsContext{
41 28bf81c9 Michael Niedermayer
        int srcW, srcH, dstW, dstH;
42 1e621b18 Michael Niedermayer
        int chrSrcW, chrSrcH, chrDstW, chrDstH;
43 28bf81c9 Michael Niedermayer
        int lumXInc, chrXInc;
44
        int lumYInc, chrYInc;
45
        int dstFormat, srcFormat;
46 c7a810cc Michael Niedermayer
        int chrSrcHSubSample, chrSrcVSubSample;
47
        int chrIntHSubSample, chrIntVSubSample;
48
        int chrDstHSubSample, chrDstVSubSample;
49 c7f822d9 Michael Niedermayer
50
        int16_t **lumPixBuf;
51
        int16_t **chrPixBuf;
52
        int16_t *hLumFilter;
53
        int16_t *hLumFilterPos;
54
        int16_t *hChrFilter;
55
        int16_t *hChrFilterPos;
56
        int16_t *vLumFilter;
57
        int16_t *vLumFilterPos;
58
        int16_t *vChrFilter;
59
        int16_t *vChrFilterPos;
60 28bf81c9 Michael Niedermayer
61
// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
62 c7f822d9 Michael Niedermayer
        int16_t  *lumMmxFilter;
63
        int16_t  *chrMmxFilter;
64 1e621b18 Michael Niedermayer
        uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
65 28bf81c9 Michael Niedermayer
66
        int hLumFilterSize;
67
        int hChrFilterSize;
68
        int vLumFilterSize;
69
        int vChrFilterSize;
70
        int vLumBufSize;
71
        int vChrBufSize;
72
73
        uint8_t __attribute__((aligned(32))) funnyYCode[10000];
74
        uint8_t __attribute__((aligned(32))) funnyUVCode[10000];
75 b7dc6f66 Michael Niedermayer
        int32_t *lumMmx2FilterPos;
76
        int32_t *chrMmx2FilterPos;
77
        int16_t *lumMmx2Filter;
78
        int16_t *chrMmx2Filter;
79 28bf81c9 Michael Niedermayer
80
        int canMMX2BeUsed;
81
82
        int lastInLumBuf;
83
        int lastInChrBuf;
84
        int lumBufIndex;
85
        int chrBufIndex;
86
        int dstY;
87
        int flags;
88 37079906 Michael Niedermayer
89
        void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
90
             int srcSliceH, uint8_t* dst[], int dstStride[]);
91 28bf81c9 Michael Niedermayer
} SwsContext;
92
//FIXME check init (where 0)
93
94 c7f822d9 Michael Niedermayer
// when used for filters they must have an odd number of elements
95
// coeffs cannot be shared between vectors
96 28bf81c9 Michael Niedermayer
typedef struct {
97 c7f822d9 Michael Niedermayer
        double *coeff;
98 28bf81c9 Michael Niedermayer
        int length;
99 c7f822d9 Michael Niedermayer
} SwsVector;
100
101
// vectors can be shared
102
typedef struct {
103
        SwsVector *lumH;
104
        SwsVector *lumV;
105
        SwsVector *chrH;
106
        SwsVector *chrV;
107 28bf81c9 Michael Niedermayer
} SwsFilter;
108
109 077ea8a7 Michael Niedermayer
110 38858470 Michael Niedermayer
// *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
111 3db822b0 Arpi
// *** Note: it's called multiple times while decoding a frame, first time y==0
112 38858470 Michael Niedermayer
// dstbpp == 12 -> yv12 output
113 28bf81c9 Michael Niedermayer
// will use sws_flags
114
void SwScale_YV12slice(unsigned char* src[],int srcStride[], int srcSliceY,
115
                             int srcSliceH, uint8_t* dst[], int dstStride, int dstbpp,
116 d1fac6cf Michael Niedermayer
                             int srcW, int srcH, int dstW, int dstH);
117 28bf81c9 Michael Niedermayer
118
// Obsolete, will be removed soon
119
void SwScale_Init();
120
121
122
123 c7f822d9 Michael Niedermayer
void freeSwsContext(SwsContext *swsContext);
124 28bf81c9 Michael Niedermayer
125 6c7506de Michael Niedermayer
SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
126 28bf81c9 Michael Niedermayer
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
127
                         SwsFilter *srcFilter, SwsFilter *dstFilter);
128
129 c7f822d9 Michael Niedermayer
SwsVector *getGaussianVec(double variance, double quality);
130 5521b193 Michael Niedermayer
SwsVector *getConstVec(double c, int length);
131 c7f822d9 Michael Niedermayer
SwsVector *getIdentityVec(void);
132
void scaleVec(SwsVector *a, double scalar);
133
void normalizeVec(SwsVector *a, double height);
134 5cebb24b Michael Niedermayer
void convVec(SwsVector *a, SwsVector *b);
135
void addVec(SwsVector *a, SwsVector *b);
136
void subVec(SwsVector *a, SwsVector *b);
137
void shiftVec(SwsVector *a, int shift);
138
SwsVector *cloneVec(SwsVector *a);
139 c7f822d9 Michael Niedermayer
140
void printVec(SwsVector *a);
141
void freeVec(SwsVector *a);