~medibuntu-maintainers/mplayer/medibuntu.quantal

« back to all changes in this revision

Viewing changes to ffmpeg/libswscale/swscale_internal.h

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#endif
29
29
 
30
30
#include "libavutil/avutil.h"
31
 
 
32
 
#define STR(s)         AV_TOSTRING(s) //AV_STRINGIFY is too long
33
 
 
34
 
#define FAST_BGR2YV12 //use 7-bit instead of 15-bit coefficients
 
31
#include "libavutil/log.h"
 
32
#include "libavutil/pixfmt.h"
 
33
#include "libavutil/pixdesc.h"
 
34
 
 
35
#define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
 
36
 
 
37
#define FAST_BGR2YV12 // use 7-bit instead of 15-bit coefficients
35
38
 
36
39
#define MAX_FILTER_SIZE 256
37
40
 
42
45
#endif
43
46
 
44
47
#if ARCH_X86_64
45
 
#   define APCK_PTR2 8
 
48
#   define APCK_PTR2  8
46
49
#   define APCK_COEF 16
47
50
#   define APCK_SIZE 24
48
51
#else
49
 
#   define APCK_PTR2 4
50
 
#   define APCK_COEF 8
 
52
#   define APCK_PTR2  4
 
53
#   define APCK_COEF  8
51
54
#   define APCK_SIZE 16
52
55
#endif
53
56
 
54
57
struct SwsContext;
55
58
 
56
 
typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[],
 
59
typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
57
60
                       int srcStride[], int srcSliceY, int srcSliceH,
58
 
                       uint8_t* dst[], int dstStride[]);
59
 
 
60
 
typedef void (*yuv2planar1_fn) (struct SwsContext *c,
61
 
                                const int16_t *lumSrc, const int16_t *chrUSrc,
62
 
                                const int16_t *chrVSrc, const int16_t *alpSrc,
63
 
                                uint8_t *dest,
64
 
                                uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
65
 
                                int dstW, int chrDstW);
66
 
typedef void (*yuv2planarX_fn) (struct SwsContext *c,
67
 
                                const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
68
 
                                const int16_t *chrFilter, const int16_t **chrUSrc,
69
 
                                const int16_t **chrVSrc, int chrFilterSize,
70
 
                                const int16_t **alpSrc,
71
 
                                uint8_t *dest,
72
 
                                uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
73
 
                                int dstW, int chrDstW);
74
 
typedef void (*yuv2packed1_fn) (struct SwsContext *c,
75
 
                                const uint16_t *buf0,
76
 
                                const uint16_t *ubuf0, const uint16_t *ubuf1,
77
 
                                const uint16_t *vbuf0, const uint16_t *vbuf1,
78
 
                                const uint16_t *abuf0,
79
 
                                uint8_t *dest,
80
 
                                int dstW, int uvalpha, int dstFormat, int flags, int y);
81
 
typedef void (*yuv2packed2_fn) (struct SwsContext *c,
82
 
                                const uint16_t *buf0, const uint16_t *buf1,
83
 
                                const uint16_t *ubuf0, const uint16_t *ubuf1,
84
 
                                const uint16_t *vbuf0, const uint16_t *vbuf1,
85
 
                                const uint16_t *abuf0, const uint16_t *abuf1,
86
 
                                uint8_t *dest,
87
 
                                int dstW, int yalpha, int uvalpha, int y);
88
 
typedef void (*yuv2packedX_fn) (struct SwsContext *c,
89
 
                                const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
90
 
                                const int16_t *chrFilter, const int16_t **chrUSrc,
91
 
                                const int16_t **chrVSrc, int chrFilterSize,
92
 
                                const int16_t **alpSrc, uint8_t *dest,
93
 
                                int dstW, int dstY);
 
61
                       uint8_t *dst[], int dstStride[]);
 
62
 
 
63
/**
 
64
 * Write one line of horizontally scaled data to planar output
 
65
 * without any additional vertical scaling (or point-scaling).
 
66
 *
 
67
 * @param src     scaled source data, 15bit for 8-10bit output,
 
68
 *                19-bit for 16bit output (in int32_t)
 
69
 * @param dest    pointer to the output plane. For >8bit
 
70
 *                output, this is in uint16_t
 
71
 * @param dstW    width of destination in pixels
 
72
 * @param dither  ordered dither array of type int16_t and size 8
 
73
 * @param offset  Dither offset
 
74
 */
 
75
typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
 
76
                               const uint8_t *dither, int offset);
 
77
 
 
78
/**
 
79
 * Write one line of horizontally scaled data to planar output
 
80
 * with multi-point vertical scaling between input pixels.
 
81
 *
 
82
 * @param filter        vertical luma/alpha scaling coefficients, 12bit [0,4096]
 
83
 * @param src           scaled luma (Y) or alpha (A) source data, 15bit for 8-10bit output,
 
84
 *                      19-bit for 16bit output (in int32_t)
 
85
 * @param filterSize    number of vertical input lines to scale
 
86
 * @param dest          pointer to output plane. For >8bit
 
87
 *                      output, this is in uint16_t
 
88
 * @param dstW          width of destination pixels
 
89
 * @param offset        Dither offset
 
90
 */
 
91
typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
 
92
                               const int16_t **src, uint8_t *dest, int dstW,
 
93
                               const uint8_t *dither, int offset);
 
94
 
 
95
/**
 
96
 * Write one line of horizontally scaled chroma to interleaved output
 
97
 * with multi-point vertical scaling between input pixels.
 
98
 *
 
99
 * @param c             SWS scaling context
 
100
 * @param chrFilter     vertical chroma scaling coefficients, 12bit [0,4096]
 
101
 * @param chrUSrc       scaled chroma (U) source data, 15bit for 8-10bit output,
 
102
 *                      19-bit for 16bit output (in int32_t)
 
103
 * @param chrVSrc       scaled chroma (V) source data, 15bit for 8-10bit output,
 
104
 *                      19-bit for 16bit output (in int32_t)
 
105
 * @param chrFilterSize number of vertical chroma input lines to scale
 
106
 * @param dest          pointer to the output plane. For >8bit
 
107
 *                      output, this is in uint16_t
 
108
 * @param dstW          width of chroma planes
 
109
 */
 
110
typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
 
111
                                    const int16_t *chrFilter,
 
112
                                    int chrFilterSize,
 
113
                                    const int16_t **chrUSrc,
 
114
                                    const int16_t **chrVSrc,
 
115
                                    uint8_t *dest, int dstW);
 
116
 
 
117
/**
 
118
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
 
119
 * output without any additional vertical scaling (or point-scaling). Note
 
120
 * that this function may do chroma scaling, see the "uvalpha" argument.
 
121
 *
 
122
 * @param c       SWS scaling context
 
123
 * @param lumSrc  scaled luma (Y) source data, 15bit for 8-10bit output,
 
124
 *                19-bit for 16bit output (in int32_t)
 
125
 * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
 
126
 *                19-bit for 16bit output (in int32_t)
 
127
 * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
 
128
 *                19-bit for 16bit output (in int32_t)
 
129
 * @param alpSrc  scaled alpha (A) source data, 15bit for 8-10bit output,
 
130
 *                19-bit for 16bit output (in int32_t)
 
131
 * @param dest    pointer to the output plane. For 16bit output, this is
 
132
 *                uint16_t
 
133
 * @param dstW    width of lumSrc and alpSrc in pixels, number of pixels
 
134
 *                to write into dest[]
 
135
 * @param uvalpha chroma scaling coefficient for the second line of chroma
 
136
 *                pixels, either 2048 or 0. If 0, one chroma input is used
 
137
 *                for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
 
138
 *                is set, it generates 1 output pixel). If 2048, two chroma
 
139
 *                input pixels should be averaged for 2 output pixels (this
 
140
 *                only happens if SWS_FLAG_FULL_CHR_INT is not set)
 
141
 * @param y       vertical line number for this output. This does not need
 
142
 *                to be used to calculate the offset in the destination,
 
143
 *                but can be used to generate comfort noise using dithering
 
144
 *                for some output formats.
 
145
 */
 
146
typedef void (*yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc,
 
147
                               const int16_t *chrUSrc[2],
 
148
                               const int16_t *chrVSrc[2],
 
149
                               const int16_t *alpSrc, uint8_t *dest,
 
150
                               int dstW, int uvalpha, int y);
 
151
/**
 
152
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
 
153
 * output by doing bilinear scaling between two input lines.
 
154
 *
 
155
 * @param c       SWS scaling context
 
156
 * @param lumSrc  scaled luma (Y) source data, 15bit for 8-10bit output,
 
157
 *                19-bit for 16bit output (in int32_t)
 
158
 * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
 
159
 *                19-bit for 16bit output (in int32_t)
 
160
 * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
 
161
 *                19-bit for 16bit output (in int32_t)
 
162
 * @param alpSrc  scaled alpha (A) source data, 15bit for 8-10bit output,
 
163
 *                19-bit for 16bit output (in int32_t)
 
164
 * @param dest    pointer to the output plane. For 16bit output, this is
 
165
 *                uint16_t
 
166
 * @param dstW    width of lumSrc and alpSrc in pixels, number of pixels
 
167
 *                to write into dest[]
 
168
 * @param yalpha  luma/alpha scaling coefficients for the second input line.
 
169
 *                The first line's coefficients can be calculated by using
 
170
 *                4096 - yalpha
 
171
 * @param uvalpha chroma scaling coefficient for the second input line. The
 
172
 *                first line's coefficients can be calculated by using
 
173
 *                4096 - uvalpha
 
174
 * @param y       vertical line number for this output. This does not need
 
175
 *                to be used to calculate the offset in the destination,
 
176
 *                but can be used to generate comfort noise using dithering
 
177
 *                for some output formats.
 
178
 */
 
179
typedef void (*yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2],
 
180
                               const int16_t *chrUSrc[2],
 
181
                               const int16_t *chrVSrc[2],
 
182
                               const int16_t *alpSrc[2],
 
183
                               uint8_t *dest,
 
184
                               int dstW, int yalpha, int uvalpha, int y);
 
185
/**
 
186
 * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
 
187
 * output by doing multi-point vertical scaling between input pixels.
 
188
 *
 
189
 * @param c             SWS scaling context
 
190
 * @param lumFilter     vertical luma/alpha scaling coefficients, 12bit [0,4096]
 
191
 * @param lumSrc        scaled luma (Y) source data, 15bit for 8-10bit output,
 
192
 *                      19-bit for 16bit output (in int32_t)
 
193
 * @param lumFilterSize number of vertical luma/alpha input lines to scale
 
194
 * @param chrFilter     vertical chroma scaling coefficients, 12bit [0,4096]
 
195
 * @param chrUSrc       scaled chroma (U) source data, 15bit for 8-10bit output,
 
196
 *                      19-bit for 16bit output (in int32_t)
 
197
 * @param chrVSrc       scaled chroma (V) source data, 15bit for 8-10bit output,
 
198
 *                      19-bit for 16bit output (in int32_t)
 
199
 * @param chrFilterSize number of vertical chroma input lines to scale
 
200
 * @param alpSrc        scaled alpha (A) source data, 15bit for 8-10bit output,
 
201
 *                      19-bit for 16bit output (in int32_t)
 
202
 * @param dest          pointer to the output plane. For 16bit output, this is
 
203
 *                      uint16_t
 
204
 * @param dstW          width of lumSrc and alpSrc in pixels, number of pixels
 
205
 *                      to write into dest[]
 
206
 * @param y             vertical line number for this output. This does not need
 
207
 *                      to be used to calculate the offset in the destination,
 
208
 *                      but can be used to generate comfort noise using dithering
 
209
 *                      or some output formats.
 
210
 */
 
211
typedef void (*yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter,
 
212
                               const int16_t **lumSrc, int lumFilterSize,
 
213
                               const int16_t *chrFilter,
 
214
                               const int16_t **chrUSrc,
 
215
                               const int16_t **chrVSrc, int chrFilterSize,
 
216
                               const int16_t **alpSrc, uint8_t *dest,
 
217
                               int dstW, int y);
94
218
 
95
219
/* This struct should be aligned on at least a 32-byte boundary. */
96
220
typedef struct SwsContext {
117
241
    enum PixelFormat srcFormat;   ///< Source      pixel format.
118
242
    int dstFormatBpp;             ///< Number of bits per pixel of the destination pixel format.
119
243
    int srcFormatBpp;             ///< Number of bits per pixel of the source      pixel format.
 
244
    int dstBpc, srcBpc;
120
245
    int chrSrcHSubSample;         ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source      image.
121
246
    int chrSrcVSubSample;         ///< Binary logarithm of vertical   subsampling factor between luma/alpha and chroma planes in source      image.
122
247
    int chrDstHSubSample;         ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
142
267
    int16_t **chrUPixBuf;         ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
143
268
    int16_t **chrVPixBuf;         ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
144
269
    int16_t **alpPixBuf;          ///< Ring buffer for scaled horizontal alpha  plane lines to be fed to the vertical scaler.
145
 
    int       vLumBufSize;        ///< Number of vertical luma/alpha lines allocated in the ring buffer.
146
 
    int       vChrBufSize;        ///< Number of vertical chroma     lines allocated in the ring buffer.
147
 
    int       lastInLumBuf;       ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
148
 
    int       lastInChrBuf;       ///< Last scaled horizontal chroma     line from source in the ring buffer.
149
 
    int       lumBufIndex;        ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
150
 
    int       chrBufIndex;        ///< Index in ring buffer of the last scaled horizontal chroma     line from source.
 
270
    int vLumBufSize;              ///< Number of vertical luma/alpha lines allocated in the ring buffer.
 
271
    int vChrBufSize;              ///< Number of vertical chroma     lines allocated in the ring buffer.
 
272
    int lastInLumBuf;             ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
 
273
    int lastInChrBuf;             ///< Last scaled horizontal chroma     line from source in the ring buffer.
 
274
    int lumBufIndex;              ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
 
275
    int chrBufIndex;              ///< Index in ring buffer of the last scaled horizontal chroma     line from source.
151
276
    //@}
152
277
 
153
278
    uint8_t *formatConvBuffer;
174
299
    int16_t *hChrFilterPos;       ///< Array of horizontal filter starting positions for each dst[i] for chroma     planes.
175
300
    int16_t *vLumFilterPos;       ///< Array of vertical   filter starting positions for each dst[i] for luma/alpha planes.
176
301
    int16_t *vChrFilterPos;       ///< Array of vertical   filter starting positions for each dst[i] for chroma     planes.
177
 
    int      hLumFilterSize;      ///< Horizontal filter size for luma/alpha pixels.
178
 
    int      hChrFilterSize;      ///< Horizontal filter size for chroma     pixels.
179
 
    int      vLumFilterSize;      ///< Vertical   filter size for luma/alpha pixels.
180
 
    int      vChrFilterSize;      ///< Vertical   filter size for chroma     pixels.
 
302
    int hLumFilterSize;           ///< Horizontal filter size for luma/alpha pixels.
 
303
    int hChrFilterSize;           ///< Horizontal filter size for chroma     pixels.
 
304
    int vLumFilterSize;           ///< Vertical   filter size for luma/alpha pixels.
 
305
    int vChrFilterSize;           ///< Vertical   filter size for chroma     pixels.
181
306
    //@}
182
307
 
183
308
    int lumMmx2FilterCodeSize;    ///< Runtime-generated MMX2 horizontal fast bilinear scaler code size for luma/alpha planes.
189
314
 
190
315
    int dstY;                     ///< Last destination vertical line output from last slice.
191
316
    int flags;                    ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
192
 
    void * yuvTable;            // pointer to the yuv->rgb table start so it can be freed()
193
 
    uint8_t * table_rV[256];
194
 
    uint8_t * table_gU[256];
195
 
    int    table_gV[256];
196
 
    uint8_t * table_bU[256];
 
317
    void *yuvTable;             // pointer to the yuv->rgb table start so it can be freed()
 
318
    uint8_t *table_rV[256];
 
319
    uint8_t *table_gU[256];
 
320
    int table_gV[256];
 
321
    uint8_t *table_bU[256];
197
322
 
198
323
    //Colorspace stuff
199
324
    int contrast, brightness, saturation;    // for sws_getColorspaceDetails
228
353
#define V_TEMP                "11*8+4*4*256*2+32"
229
354
#define Y_TEMP                "11*8+4*4*256*2+40"
230
355
#define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48"
231
 
#define UV_OFF                "11*8+4*4*256*3+48"
232
 
#define UV_OFFx2              "11*8+4*4*256*3+56"
 
356
#define UV_OFF_PX             "11*8+4*4*256*3+48"
 
357
#define UV_OFF_BYTE           "11*8+4*4*256*3+56"
 
358
#define DITHER16              "11*8+4*4*256*3+64"
 
359
#define DITHER32              "11*8+4*4*256*3+80"
233
360
 
234
361
    DECLARE_ALIGNED(8, uint64_t, redDither);
235
362
    DECLARE_ALIGNED(8, uint64_t, greenDither);
243
370
    DECLARE_ALIGNED(8, uint64_t, yOffset);
244
371
    DECLARE_ALIGNED(8, uint64_t, uOffset);
245
372
    DECLARE_ALIGNED(8, uint64_t, vOffset);
246
 
    int32_t  lumMmxFilter[4*MAX_FILTER_SIZE];
247
 
    int32_t  chrMmxFilter[4*MAX_FILTER_SIZE];
 
373
    int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
 
374
    int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
248
375
    int dstW;                     ///< Width  of destination luma/alpha planes.
249
376
    DECLARE_ALIGNED(8, uint64_t, esp);
250
377
    DECLARE_ALIGNED(8, uint64_t, vRounder);
251
378
    DECLARE_ALIGNED(8, uint64_t, u_temp);
252
379
    DECLARE_ALIGNED(8, uint64_t, v_temp);
253
380
    DECLARE_ALIGNED(8, uint64_t, y_temp);
254
 
    int32_t  alpMmxFilter[4*MAX_FILTER_SIZE];
255
 
    DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes
256
 
    DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes
 
381
    int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
 
382
    // alignment of these values is not necessary, but merely here
 
383
    // to maintain the same offset across x8632 and x86-64. Once we
 
384
    // use proper offset macros in the asm, they can be removed.
 
385
    DECLARE_ALIGNED(8, ptrdiff_t, uv_off_px);   ///< offset (in pixels) between u and v planes
 
386
    DECLARE_ALIGNED(8, ptrdiff_t, uv_off_byte); ///< offset (in bytes) between u and v planes
 
387
    DECLARE_ALIGNED(8, uint16_t, dither16)[8];
 
388
    DECLARE_ALIGNED(8, uint32_t, dither32)[8];
 
389
 
 
390
    const uint8_t *chrDither8, *lumDither8;
257
391
 
258
392
#if HAVE_ALTIVEC
259
393
    vector signed short   CY;
263
397
    vector signed short   CGV;
264
398
    vector signed short   OY;
265
399
    vector unsigned short CSHIFT;
266
 
    vector signed short   *vYCoeffsBank, *vCCoeffsBank;
 
400
    vector signed short  *vYCoeffsBank, *vCCoeffsBank;
267
401
#endif
268
402
 
269
403
#if ARCH_BFIN
285
419
#endif
286
420
 
287
421
    /* function pointers for swScale() */
288
 
    yuv2planar1_fn yuv2yuv1;
289
 
    yuv2planarX_fn yuv2yuvX;
 
422
    yuv2planar1_fn yuv2plane1;
 
423
    yuv2planarX_fn yuv2planeX;
 
424
    yuv2interleavedX_fn yuv2nv12cX;
290
425
    yuv2packed1_fn yuv2packed1;
291
426
    yuv2packed2_fn yuv2packed2;
292
427
    yuv2packedX_fn yuv2packedX;
293
428
 
 
429
    /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
294
430
    void (*lumToYV12)(uint8_t *dst, const uint8_t *src,
295
 
                      int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler.
 
431
                      int width, uint32_t *pal);
 
432
    /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
296
433
    void (*alpToYV12)(uint8_t *dst, const uint8_t *src,
297
 
                      int width, uint32_t *pal); ///< Unscaled conversion of alpha plane to YV12 for horizontal scaler.
 
434
                      int width, uint32_t *pal);
 
435
    /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
298
436
    void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
299
437
                      const uint8_t *src1, const uint8_t *src2,
300
 
                      int width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler.
 
438
                      int width, uint32_t *pal);
 
439
 
 
440
    /**
 
441
     * Functions to read planar input, such as planar RGB, and convert
 
442
     * internally to Y/UV.
 
443
     */
 
444
    /** @{ */
 
445
    void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width);
 
446
    void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4],
 
447
                          int width);
 
448
    /** @} */
 
449
 
 
450
    /**
 
451
     * Scale one horizontal line of input data using a bilinear filter
 
452
     * to produce one line of output data. Compared to SwsContext->hScale(),
 
453
     * please take note of the following caveats when using these:
 
454
     * - Scaling is done using only 7bit instead of 14bit coefficients.
 
455
     * - You can use no more than 5 input pixels to produce 4 output
 
456
     *   pixels. Therefore, this filter should not be used for downscaling
 
457
     *   by more than ~20% in width (because that equals more than 5/4th
 
458
     *   downscaling and thus more than 5 pixels input per 4 pixels output).
 
459
     * - In general, bilinear filters create artifacts during downscaling
 
460
     *   (even when <20%), because one output pixel will span more than one
 
461
     *   input pixel, and thus some pixels will need edges of both neighbor
 
462
     *   pixels to interpolate the output pixel. Since you can use at most
 
463
     *   two input pixels per output pixel in bilinear scaling, this is
 
464
     *   impossible and thus downscaling by any size will create artifacts.
 
465
     * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
 
466
     * in SwsContext->flags.
 
467
     */
 
468
    /** @{ */
301
469
    void (*hyscale_fast)(struct SwsContext *c,
302
470
                         int16_t *dst, int dstWidth,
303
471
                         const uint8_t *src, int srcW, int xInc);
305
473
                         int16_t *dst1, int16_t *dst2, int dstWidth,
306
474
                         const uint8_t *src1, const uint8_t *src2,
307
475
                         int srcW, int xInc);
308
 
 
309
 
    void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW,
310
 
                   int xInc, const int16_t *filter, const int16_t *filterPos,
311
 
                   int filterSize);
312
 
 
313
 
    void (*lumConvertRange)(int16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
314
 
    void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed.
 
476
    /** @} */
 
477
 
 
478
    /**
 
479
     * Scale one horizontal line of input data using a filter over the input
 
480
     * lines, to produce one (differently sized) line of output data.
 
481
     *
 
482
     * @param dst        pointer to destination buffer for horizontally scaled
 
483
     *                   data. If the number of bits per component of one
 
484
     *                   destination pixel (SwsContext->dstBpc) is <= 10, data
 
485
     *                   will be 15bpc in 16bits (int16_t) width. Else (i.e.
 
486
     *                   SwsContext->dstBpc == 16), data will be 19bpc in
 
487
     *                   32bits (int32_t) width.
 
488
     * @param dstW       width of destination image
 
489
     * @param src        pointer to source data to be scaled. If the number of
 
490
     *                   bits per component of a source pixel (SwsContext->srcBpc)
 
491
     *                   is 8, this is 8bpc in 8bits (uint8_t) width. Else
 
492
     *                   (i.e. SwsContext->dstBpc > 8), this is native depth
 
493
     *                   in 16bits (uint16_t) width. In other words, for 9-bit
 
494
     *                   YUV input, this is 9bpc, for 10-bit YUV input, this is
 
495
     *                   10bpc, and for 16-bit RGB or YUV, this is 16bpc.
 
496
     * @param filter     filter coefficients to be used per output pixel for
 
497
     *                   scaling. This contains 14bpp filtering coefficients.
 
498
     *                   Guaranteed to contain dstW * filterSize entries.
 
499
     * @param filterPos  position of the first input pixel to be used for
 
500
     *                   each output pixel during scaling. Guaranteed to
 
501
     *                   contain dstW entries.
 
502
     * @param filterSize the number of input coefficients to be used (and
 
503
     *                   thus the number of input pixels to be used) for
 
504
     *                   creating a single output pixel. Is aligned to 4
 
505
     *                   (and input coefficients thus padded with zeroes)
 
506
     *                   to simplify creating SIMD code.
 
507
     */
 
508
    /** @{ */
 
509
    void (*hyScale)(struct SwsContext *c, int16_t *dst, int dstW,
 
510
                    const uint8_t *src, const int16_t *filter,
 
511
                    const int16_t *filterPos, int filterSize);
 
512
    void (*hcScale)(struct SwsContext *c, int16_t *dst, int dstW,
 
513
                    const uint8_t *src, const int16_t *filter,
 
514
                    const int16_t *filterPos, int filterSize);
 
515
    /** @} */
 
516
 
 
517
    /// Color range conversion function for luma plane if needed.
 
518
    void (*lumConvertRange)(int16_t *dst, int width);
 
519
    /// Color range conversion function for chroma planes if needed.
 
520
    void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width);
315
521
 
316
522
    int needs_hcscale; ///< Set if there are chroma planes to be converted.
317
 
 
318
523
} SwsContext;
319
524
//FIXME check init (where 0)
320
525
 
337
542
 
338
543
const char *sws_format_name(enum PixelFormat format);
339
544
 
340
 
//FIXME replace this with something faster
341
 
#define is16BPS(x)      (           \
342
 
           (x)==PIX_FMT_GRAY16BE    \
343
 
        || (x)==PIX_FMT_GRAY16LE    \
344
 
        || (x)==PIX_FMT_BGR48BE     \
345
 
        || (x)==PIX_FMT_BGR48LE     \
346
 
        || (x)==PIX_FMT_RGB48BE     \
347
 
        || (x)==PIX_FMT_RGB48LE     \
348
 
        || (x)==PIX_FMT_YUV420P16LE \
349
 
        || (x)==PIX_FMT_YUV422P16LE \
350
 
        || (x)==PIX_FMT_YUV444P16LE \
351
 
        || (x)==PIX_FMT_YUV420P16BE \
352
 
        || (x)==PIX_FMT_YUV422P16BE \
353
 
        || (x)==PIX_FMT_YUV444P16BE \
354
 
    )
355
 
#define is9_OR_10BPS(x) (           \
356
 
           (x)==PIX_FMT_YUV420P9LE  \
357
 
        || (x)==PIX_FMT_YUV420P9BE  \
358
 
        || (x)==PIX_FMT_YUV444P9BE  \
359
 
        || (x)==PIX_FMT_YUV444P9LE  \
360
 
        || (x)==PIX_FMT_YUV422P10BE \
361
 
        || (x)==PIX_FMT_YUV422P10LE \
362
 
        || (x)==PIX_FMT_YUV444P10BE \
363
 
        || (x)==PIX_FMT_YUV444P10LE \
364
 
        || (x)==PIX_FMT_YUV420P10LE \
365
 
        || (x)==PIX_FMT_YUV420P10BE \
366
 
    )
367
 
#define isBE(x) ((x)&1)
368
 
#define isPlanar8YUV(x) (           \
369
 
           (x)==PIX_FMT_YUV410P     \
370
 
        || (x)==PIX_FMT_YUV420P     \
371
 
        || (x)==PIX_FMT_YUVA420P    \
372
 
        || (x)==PIX_FMT_YUV411P     \
373
 
        || (x)==PIX_FMT_YUV422P     \
374
 
        || (x)==PIX_FMT_YUV444P     \
375
 
        || (x)==PIX_FMT_YUV440P     \
376
 
        || (x)==PIX_FMT_NV12        \
377
 
        || (x)==PIX_FMT_NV21        \
378
 
    )
379
 
#define isPlanarYUV(x)  (           \
380
 
        isPlanar8YUV(x)             \
381
 
        || (x)==PIX_FMT_YUV420P9LE  \
382
 
        || (x)==PIX_FMT_YUV444P9LE  \
383
 
        || (x)==PIX_FMT_YUV420P10LE \
384
 
        || (x)==PIX_FMT_YUV422P10LE \
385
 
        || (x)==PIX_FMT_YUV444P10LE \
386
 
        || (x)==PIX_FMT_YUV420P16LE \
387
 
        || (x)==PIX_FMT_YUV422P16LE \
388
 
        || (x)==PIX_FMT_YUV444P16LE \
389
 
        || (x)==PIX_FMT_YUV420P9BE  \
390
 
        || (x)==PIX_FMT_YUV444P9BE  \
391
 
        || (x)==PIX_FMT_YUV420P10BE \
392
 
        || (x)==PIX_FMT_YUV422P10BE \
393
 
        || (x)==PIX_FMT_YUV444P10BE \
394
 
        || (x)==PIX_FMT_YUV420P16BE \
395
 
        || (x)==PIX_FMT_YUV422P16BE \
396
 
        || (x)==PIX_FMT_YUV444P16BE \
397
 
    )
398
 
#define isYUV(x)        (           \
399
 
           (x)==PIX_FMT_UYVY422     \
400
 
        || (x)==PIX_FMT_YUYV422     \
401
 
        || isPlanarYUV(x)           \
402
 
    )
403
 
#define isGray(x)       (           \
404
 
           (x)==PIX_FMT_GRAY8       \
405
 
        || (x)==PIX_FMT_Y400A      \
406
 
        || (x)==PIX_FMT_GRAY16BE    \
407
 
        || (x)==PIX_FMT_GRAY16LE    \
408
 
    )
409
 
#define isGray16(x)     (           \
410
 
           (x)==PIX_FMT_GRAY16BE    \
411
 
        || (x)==PIX_FMT_GRAY16LE    \
412
 
    )
413
 
#define isRGBinInt(x)   (           \
414
 
           (x)==PIX_FMT_RGB48BE     \
415
 
        || (x)==PIX_FMT_RGB48LE     \
416
 
        || (x)==PIX_FMT_RGB32       \
417
 
        || (x)==PIX_FMT_RGB32_1     \
418
 
        || (x)==PIX_FMT_RGB24       \
419
 
        || (x)==PIX_FMT_RGB565BE    \
420
 
        || (x)==PIX_FMT_RGB565LE    \
421
 
        || (x)==PIX_FMT_RGB555BE    \
422
 
        || (x)==PIX_FMT_RGB555LE    \
423
 
        || (x)==PIX_FMT_RGB444BE    \
424
 
        || (x)==PIX_FMT_RGB444LE    \
425
 
        || (x)==PIX_FMT_RGB8        \
426
 
        || (x)==PIX_FMT_RGB4        \
427
 
        || (x)==PIX_FMT_RGB4_BYTE   \
428
 
        || (x)==PIX_FMT_MONOBLACK   \
429
 
        || (x)==PIX_FMT_MONOWHITE   \
430
 
    )
431
 
#define isBGRinInt(x)   (           \
432
 
           (x)==PIX_FMT_BGR48BE     \
433
 
        || (x)==PIX_FMT_BGR48LE     \
434
 
        || (x)==PIX_FMT_BGR32       \
435
 
        || (x)==PIX_FMT_BGR32_1     \
436
 
        || (x)==PIX_FMT_BGR24       \
437
 
        || (x)==PIX_FMT_BGR565BE    \
438
 
        || (x)==PIX_FMT_BGR565LE    \
439
 
        || (x)==PIX_FMT_BGR555BE    \
440
 
        || (x)==PIX_FMT_BGR555LE    \
441
 
        || (x)==PIX_FMT_BGR444BE    \
442
 
        || (x)==PIX_FMT_BGR444LE    \
443
 
        || (x)==PIX_FMT_BGR8        \
444
 
        || (x)==PIX_FMT_BGR4        \
445
 
        || (x)==PIX_FMT_BGR4_BYTE   \
446
 
        || (x)==PIX_FMT_MONOBLACK   \
447
 
        || (x)==PIX_FMT_MONOWHITE   \
448
 
    )
449
 
#define isRGBinBytes(x) (           \
450
 
           (x)==PIX_FMT_RGB48BE     \
451
 
        || (x)==PIX_FMT_RGB48LE     \
452
 
        || (x)==PIX_FMT_RGBA        \
453
 
        || (x)==PIX_FMT_ARGB        \
454
 
        || (x)==PIX_FMT_RGB24       \
455
 
    )
456
 
#define isBGRinBytes(x) (           \
457
 
           (x)==PIX_FMT_BGR48BE     \
458
 
        || (x)==PIX_FMT_BGR48LE     \
459
 
        || (x)==PIX_FMT_BGRA        \
460
 
        || (x)==PIX_FMT_ABGR        \
461
 
        || (x)==PIX_FMT_BGR24       \
462
 
    )
463
 
#define isAnyRGB(x)     (           \
464
 
            isRGBinInt(x)           \
465
 
        ||  isBGRinInt(x)           \
466
 
    )
467
 
#define isALPHA(x)      (           \
468
 
           (x)==PIX_FMT_BGR32       \
469
 
        || (x)==PIX_FMT_BGR32_1     \
470
 
        || (x)==PIX_FMT_RGB32       \
471
 
        || (x)==PIX_FMT_RGB32_1     \
472
 
        || (x)==PIX_FMT_Y400A       \
473
 
        || (x)==PIX_FMT_YUVA420P    \
474
 
    )
475
 
#define isPacked(x)         (       \
476
 
           (x)==PIX_FMT_PAL8        \
477
 
        || (x)==PIX_FMT_YUYV422     \
478
 
        || (x)==PIX_FMT_UYVY422     \
479
 
        || (x)==PIX_FMT_Y400A       \
480
 
        || isAnyRGB(x)              \
481
 
    )
 
545
#define is16BPS(x) \
 
546
    (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 15)
 
547
 
 
548
#define is9_OR_10BPS(x) \
 
549
    (av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 8 || \
 
550
     av_pix_fmt_descriptors[x].comp[0].depth_minus1 == 9)
 
551
 
 
552
#define isBE(x) \
 
553
    (av_pix_fmt_descriptors[x].flags & PIX_FMT_BE)
 
554
 
 
555
#define isYUV(x) \
 
556
    (!(av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB) && \
 
557
     av_pix_fmt_descriptors[x].nb_components >= 2)
 
558
 
 
559
#define isPlanarYUV(x) \
 
560
    ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR) && \
 
561
     isYUV(x))
 
562
 
 
563
#define isRGB(x) \
 
564
    (av_pix_fmt_descriptors[x].flags & PIX_FMT_RGB)
 
565
 
 
566
#if 0 // FIXME
 
567
#define isGray(x) \
 
568
    (!(av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) && \
 
569
     av_pix_fmt_descriptors[x].nb_components <= 2)
 
570
#else
 
571
#define isGray(x)                      \
 
572
    ((x) == PIX_FMT_GRAY8       ||     \
 
573
     (x) == PIX_FMT_Y400A       ||     \
 
574
     (x) == PIX_FMT_GRAY16BE    ||     \
 
575
     (x) == PIX_FMT_GRAY16LE)
 
576
#endif
 
577
 
 
578
#define isRGBinInt(x)                  \
 
579
    ((x) == PIX_FMT_RGB48BE     ||     \
 
580
     (x) == PIX_FMT_RGB48LE     ||     \
 
581
     (x) == PIX_FMT_RGB32       ||     \
 
582
     (x) == PIX_FMT_RGB32_1     ||     \
 
583
     (x) == PIX_FMT_RGB24       ||     \
 
584
     (x) == PIX_FMT_RGB565BE    ||     \
 
585
     (x) == PIX_FMT_RGB565LE    ||     \
 
586
     (x) == PIX_FMT_RGB555BE    ||     \
 
587
     (x) == PIX_FMT_RGB555LE    ||     \
 
588
     (x) == PIX_FMT_RGB444BE    ||     \
 
589
     (x) == PIX_FMT_RGB444LE    ||     \
 
590
     (x) == PIX_FMT_RGB8        ||     \
 
591
     (x) == PIX_FMT_RGB4        ||     \
 
592
     (x) == PIX_FMT_RGB4_BYTE   ||     \
 
593
     (x) == PIX_FMT_MONOBLACK   ||     \
 
594
     (x) == PIX_FMT_MONOWHITE)
 
595
 
 
596
#define isBGRinInt(x)                  \
 
597
    ((x) == PIX_FMT_BGR48BE     ||     \
 
598
     (x) == PIX_FMT_BGR48LE     ||     \
 
599
     (x) == PIX_FMT_BGR32       ||     \
 
600
     (x) == PIX_FMT_BGR32_1     ||     \
 
601
     (x) == PIX_FMT_BGR24       ||     \
 
602
     (x) == PIX_FMT_BGR565BE    ||     \
 
603
     (x) == PIX_FMT_BGR565LE    ||     \
 
604
     (x) == PIX_FMT_BGR555BE    ||     \
 
605
     (x) == PIX_FMT_BGR555LE    ||     \
 
606
     (x) == PIX_FMT_BGR444BE    ||     \
 
607
     (x) == PIX_FMT_BGR444LE    ||     \
 
608
     (x) == PIX_FMT_BGR8        ||     \
 
609
     (x) == PIX_FMT_BGR4        ||     \
 
610
     (x) == PIX_FMT_BGR4_BYTE   ||     \
 
611
     (x) == PIX_FMT_MONOBLACK   ||     \
 
612
     (x) == PIX_FMT_MONOWHITE)
 
613
 
 
614
#define isAnyRGB(x)                    \
 
615
    (isRGBinInt(x)              ||     \
 
616
     isBGRinInt(x))
 
617
 
 
618
#define isALPHA(x)                                            \
 
619
    (av_pix_fmt_descriptors[x].nb_components == 2          || \
 
620
     av_pix_fmt_descriptors[x].nb_components == 4)
 
621
 
 
622
#define isPacked(x)                                            \
 
623
    ((av_pix_fmt_descriptors[x].nb_components >= 2         &&  \
 
624
      !(av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR)) ||  \
 
625
     (x) == PIX_FMT_PAL8)
 
626
 
 
627
#define isPlanar(x) \
 
628
    (av_pix_fmt_descriptors[x].nb_components >= 2          &&  \
 
629
     (av_pix_fmt_descriptors[x].flags & PIX_FMT_PLANAR))
 
630
 
482
631
#define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_Y400A)
483
632
 
484
633
extern const uint64_t ff_dither4[2];
487
636
extern const AVClass sws_context_class;
488
637
 
489
638
/**
490
 
 * Sets c->swScale to an unscaled converter if one exists for the specific
 
639
 * Set c->swScale to an unscaled converter if one exists for the specific
491
640
 * source and destination formats, bit depths, flags, etc.
492
641
 */
493
642
void ff_get_unscaled_swscale(SwsContext *c);
495
644
void ff_swscale_get_unscaled_altivec(SwsContext *c);
496
645
 
497
646
/**
498
 
 * Returns function pointer to fastest main scaler path function depending
 
647
 * Return function pointer to fastest main scaler path function depending
499
648
 * on architecture and available optimizations.
500
649
 */
501
650
SwsFunc ff_getSwsFunc(SwsContext *c);