Statistics
| Branch: | Revision:

ffmpeg / postproc / swscale.h @ c7a810cc

History | View | Annotate | Download (4.28 KB)

1
/*
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

    
19
/* 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
#define SWS_POINT    0x10
25
#define SWS_AREA     0x20
26

    
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
#define SWS_PRINT_INFO 0x1000
36

    
37
#define SWS_MAX_REDUCE_CUTOFF 0.002
38

    
39
/* this struct should be aligned on at least 32-byte boundary */
40
typedef struct SwsContext{
41
        int srcW, srcH, dstW, dstH;
42
        int chrSrcW, chrSrcH, chrDstW, chrDstH;
43
        int lumXInc, chrXInc;
44
        int lumYInc, chrYInc;
45
        int dstFormat, srcFormat;
46
        int chrSrcHSubSample, chrSrcVSubSample;
47
        int chrIntHSubSample, chrIntVSubSample;
48
        int chrDstHSubSample, chrDstVSubSample;
49

    
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

    
61
// Contain simply the values from v(Lum|Chr)Filter just nicely packed for mmx
62
        int16_t  *lumMmxFilter;
63
        int16_t  *chrMmxFilter;
64
        uint8_t formatConvBuffer[4000]; //FIXME dynamic alloc, but we have to change alot of code for this to be usefull
65

    
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
        int32_t *lumMmx2FilterPos;
76
        int32_t *chrMmx2FilterPos;
77
        int16_t *lumMmx2Filter;
78
        int16_t *chrMmx2Filter;
79

    
80
        int canMMX2BeUsed;
81

    
82
        int lastInLumBuf;
83
        int lastInChrBuf;
84
        int lumBufIndex;
85
        int chrBufIndex;
86
        int dstY;
87
        int flags;
88

    
89
        void (*swScale)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
90
             int srcSliceH, uint8_t* dst[], int dstStride[]);
91
} SwsContext;
92
//FIXME check init (where 0)
93

    
94
// when used for filters they must have an odd number of elements
95
// coeffs cannot be shared between vectors
96
typedef struct {
97
        double *coeff;
98
        int length;
99
} SwsVector;
100

    
101
// vectors can be shared
102
typedef struct {
103
        SwsVector *lumH;
104
        SwsVector *lumV;
105
        SwsVector *chrH;
106
        SwsVector *chrV;
107
} SwsFilter;
108

    
109

    
110
// *** bilinear scaling and yuv->rgb & yuv->yuv conversion of yv12 slices:
111
// *** Note: it's called multiple times while decoding a frame, first time y==0
112
// dstbpp == 12 -> yv12 output
113
// 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
                             int srcW, int srcH, int dstW, int dstH);
117

    
118
// Obsolete, will be removed soon
119
void SwScale_Init();
120

    
121

    
122

    
123
void freeSwsContext(SwsContext *swsContext);
124

    
125
SwsContext *getSwsContextFromCmdLine(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat);
126
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags,
127
                         SwsFilter *srcFilter, SwsFilter *dstFilter);
128

    
129
SwsVector *getGaussianVec(double variance, double quality);
130
SwsVector *getConstVec(double c, int length);
131
SwsVector *getIdentityVec(void);
132
void scaleVec(SwsVector *a, double scalar);
133
void normalizeVec(SwsVector *a, double height);
134
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

    
140
void printVec(SwsVector *a);
141
void freeVec(SwsVector *a);
142