You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

938 lines
41KB

  1. /*
  2. * Copyright (C) 2001-2011 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef SWSCALE_SWSCALE_INTERNAL_H
  21. #define SWSCALE_SWSCALE_INTERNAL_H
  22. #include "config.h"
  23. #if HAVE_ALTIVEC_H
  24. #include <altivec.h>
  25. #endif
  26. #include "version.h"
  27. #include "libavutil/avassert.h"
  28. #include "libavutil/avutil.h"
  29. #include "libavutil/common.h"
  30. #include "libavutil/intreadwrite.h"
  31. #include "libavutil/log.h"
  32. #include "libavutil/pixfmt.h"
  33. #include "libavutil/pixdesc.h"
  34. #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
  35. #define YUVRGB_TABLE_HEADROOM 256
  36. #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
  37. #define DITHER1XBPP
  38. #if HAVE_BIGENDIAN
  39. #define ALT32_CORR (-1)
  40. #else
  41. #define ALT32_CORR 1
  42. #endif
  43. #if ARCH_X86_64
  44. # define APCK_PTR2 8
  45. # define APCK_COEF 16
  46. # define APCK_SIZE 24
  47. #else
  48. # define APCK_PTR2 4
  49. # define APCK_COEF 8
  50. # define APCK_SIZE 16
  51. #endif
  52. #define RETCODE_USE_CASCADE -12345
  53. struct SwsContext;
  54. typedef enum SwsDither {
  55. SWS_DITHER_NONE = 0,
  56. SWS_DITHER_AUTO,
  57. SWS_DITHER_BAYER,
  58. SWS_DITHER_ED,
  59. SWS_DITHER_A_DITHER,
  60. SWS_DITHER_X_DITHER,
  61. NB_SWS_DITHER,
  62. } SwsDither;
  63. typedef enum SwsAlphaBlend {
  64. SWS_ALPHA_BLEND_NONE = 0,
  65. SWS_ALPHA_BLEND_UNIFORM,
  66. SWS_ALPHA_BLEND_CHECKERBOARD,
  67. SWS_ALPHA_BLEND_NB,
  68. } SwsAlphaBlend;
  69. typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
  70. int srcStride[], int srcSliceY, int srcSliceH,
  71. uint8_t *dst[], int dstStride[]);
  72. /**
  73. * Write one line of horizontally scaled data to planar output
  74. * without any additional vertical scaling (or point-scaling).
  75. *
  76. * @param src scaled source data, 15bit for 8-10bit output,
  77. * 19-bit for 16bit output (in int32_t)
  78. * @param dest pointer to the output plane. For >8bit
  79. * output, this is in uint16_t
  80. * @param dstW width of destination in pixels
  81. * @param dither ordered dither array of type int16_t and size 8
  82. * @param offset Dither offset
  83. */
  84. typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
  85. const uint8_t *dither, int offset);
  86. /**
  87. * Write one line of horizontally scaled data to planar output
  88. * with multi-point vertical scaling between input pixels.
  89. *
  90. * @param filter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  91. * @param src scaled luma (Y) or alpha (A) source data, 15bit for 8-10bit output,
  92. * 19-bit for 16bit output (in int32_t)
  93. * @param filterSize number of vertical input lines to scale
  94. * @param dest pointer to output plane. For >8bit
  95. * output, this is in uint16_t
  96. * @param dstW width of destination pixels
  97. * @param offset Dither offset
  98. */
  99. typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
  100. const int16_t **src, uint8_t *dest, int dstW,
  101. const uint8_t *dither, int offset);
  102. /**
  103. * Write one line of horizontally scaled chroma to interleaved output
  104. * with multi-point vertical scaling between input pixels.
  105. *
  106. * @param c SWS scaling context
  107. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  108. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  109. * 19-bit for 16bit output (in int32_t)
  110. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  111. * 19-bit for 16bit output (in int32_t)
  112. * @param chrFilterSize number of vertical chroma input lines to scale
  113. * @param dest pointer to the output plane. For >8bit
  114. * output, this is in uint16_t
  115. * @param dstW width of chroma planes
  116. */
  117. typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
  118. const int16_t *chrFilter,
  119. int chrFilterSize,
  120. const int16_t **chrUSrc,
  121. const int16_t **chrVSrc,
  122. uint8_t *dest, int dstW);
  123. /**
  124. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  125. * output without any additional vertical scaling (or point-scaling). Note
  126. * that this function may do chroma scaling, see the "uvalpha" argument.
  127. *
  128. * @param c SWS scaling context
  129. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  130. * 19-bit for 16bit output (in int32_t)
  131. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  132. * 19-bit for 16bit output (in int32_t)
  133. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  134. * 19-bit for 16bit output (in int32_t)
  135. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  136. * 19-bit for 16bit output (in int32_t)
  137. * @param dest pointer to the output plane. For 16bit output, this is
  138. * uint16_t
  139. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  140. * to write into dest[]
  141. * @param uvalpha chroma scaling coefficient for the second line of chroma
  142. * pixels, either 2048 or 0. If 0, one chroma input is used
  143. * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
  144. * is set, it generates 1 output pixel). If 2048, two chroma
  145. * input pixels should be averaged for 2 output pixels (this
  146. * only happens if SWS_FLAG_FULL_CHR_INT is not set)
  147. * @param y vertical line number for this output. This does not need
  148. * to be used to calculate the offset in the destination,
  149. * but can be used to generate comfort noise using dithering
  150. * for some output formats.
  151. */
  152. typedef void (*yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc,
  153. const int16_t *chrUSrc[2],
  154. const int16_t *chrVSrc[2],
  155. const int16_t *alpSrc, uint8_t *dest,
  156. int dstW, int uvalpha, int y);
  157. /**
  158. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  159. * output by doing bilinear scaling between two input lines.
  160. *
  161. * @param c SWS scaling context
  162. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  163. * 19-bit for 16bit output (in int32_t)
  164. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  165. * 19-bit for 16bit output (in int32_t)
  166. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  167. * 19-bit for 16bit output (in int32_t)
  168. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  169. * 19-bit for 16bit output (in int32_t)
  170. * @param dest pointer to the output plane. For 16bit output, this is
  171. * uint16_t
  172. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  173. * to write into dest[]
  174. * @param yalpha luma/alpha scaling coefficients for the second input line.
  175. * The first line's coefficients can be calculated by using
  176. * 4096 - yalpha
  177. * @param uvalpha chroma scaling coefficient for the second input line. The
  178. * first line's coefficients can be calculated by using
  179. * 4096 - uvalpha
  180. * @param y vertical line number for this output. This does not need
  181. * to be used to calculate the offset in the destination,
  182. * but can be used to generate comfort noise using dithering
  183. * for some output formats.
  184. */
  185. typedef void (*yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2],
  186. const int16_t *chrUSrc[2],
  187. const int16_t *chrVSrc[2],
  188. const int16_t *alpSrc[2],
  189. uint8_t *dest,
  190. int dstW, int yalpha, int uvalpha, int y);
  191. /**
  192. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  193. * output by doing multi-point vertical scaling between input pixels.
  194. *
  195. * @param c SWS scaling context
  196. * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  197. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  198. * 19-bit for 16bit output (in int32_t)
  199. * @param lumFilterSize number of vertical luma/alpha input lines to scale
  200. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  201. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  202. * 19-bit for 16bit output (in int32_t)
  203. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  204. * 19-bit for 16bit output (in int32_t)
  205. * @param chrFilterSize number of vertical chroma input lines to scale
  206. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  207. * 19-bit for 16bit output (in int32_t)
  208. * @param dest pointer to the output plane. For 16bit output, this is
  209. * uint16_t
  210. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  211. * to write into dest[]
  212. * @param y vertical line number for this output. This does not need
  213. * to be used to calculate the offset in the destination,
  214. * but can be used to generate comfort noise using dithering
  215. * or some output formats.
  216. */
  217. typedef void (*yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter,
  218. const int16_t **lumSrc, int lumFilterSize,
  219. const int16_t *chrFilter,
  220. const int16_t **chrUSrc,
  221. const int16_t **chrVSrc, int chrFilterSize,
  222. const int16_t **alpSrc, uint8_t *dest,
  223. int dstW, int y);
  224. /**
  225. * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
  226. * output by doing multi-point vertical scaling between input pixels.
  227. *
  228. * @param c SWS scaling context
  229. * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  230. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  231. * 19-bit for 16bit output (in int32_t)
  232. * @param lumFilterSize number of vertical luma/alpha input lines to scale
  233. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  234. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  235. * 19-bit for 16bit output (in int32_t)
  236. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  237. * 19-bit for 16bit output (in int32_t)
  238. * @param chrFilterSize number of vertical chroma input lines to scale
  239. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  240. * 19-bit for 16bit output (in int32_t)
  241. * @param dest pointer to the output planes. For 16bit output, this is
  242. * uint16_t
  243. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  244. * to write into dest[]
  245. * @param y vertical line number for this output. This does not need
  246. * to be used to calculate the offset in the destination,
  247. * but can be used to generate comfort noise using dithering
  248. * or some output formats.
  249. */
  250. typedef void (*yuv2anyX_fn)(struct SwsContext *c, const int16_t *lumFilter,
  251. const int16_t **lumSrc, int lumFilterSize,
  252. const int16_t *chrFilter,
  253. const int16_t **chrUSrc,
  254. const int16_t **chrVSrc, int chrFilterSize,
  255. const int16_t **alpSrc, uint8_t **dest,
  256. int dstW, int y);
  257. /* This struct should be aligned on at least a 32-byte boundary. */
  258. typedef struct SwsContext {
  259. /**
  260. * info on struct for av_log
  261. */
  262. const AVClass *av_class;
  263. /**
  264. * Note that src, dst, srcStride, dstStride will be copied in the
  265. * sws_scale() wrapper so they can be freely modified here.
  266. */
  267. SwsFunc swscale;
  268. int srcW; ///< Width of source luma/alpha planes.
  269. int srcH; ///< Height of source luma/alpha planes.
  270. int dstH; ///< Height of destination luma/alpha planes.
  271. int chrSrcW; ///< Width of source chroma planes.
  272. int chrSrcH; ///< Height of source chroma planes.
  273. int chrDstW; ///< Width of destination chroma planes.
  274. int chrDstH; ///< Height of destination chroma planes.
  275. int lumXInc, chrXInc;
  276. int lumYInc, chrYInc;
  277. enum AVPixelFormat dstFormat; ///< Destination pixel format.
  278. enum AVPixelFormat srcFormat; ///< Source pixel format.
  279. int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format.
  280. int srcFormatBpp; ///< Number of bits per pixel of the source pixel format.
  281. int dstBpc, srcBpc;
  282. int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
  283. int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
  284. int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
  285. int chrDstVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
  286. int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
  287. int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
  288. double param[2]; ///< Input parameters for scaling algorithms that need them.
  289. /* The cascaded_* fields allow spliting a scaler task into multiple
  290. * sequential steps, this is for example used to limit the maximum
  291. * downscaling factor that needs to be supported in one scaler.
  292. */
  293. struct SwsContext *cascaded_context[3];
  294. int cascaded_tmpStride[4];
  295. uint8_t *cascaded_tmp[4];
  296. int cascaded1_tmpStride[4];
  297. uint8_t *cascaded1_tmp[4];
  298. double gamma_value;
  299. int gamma_flag;
  300. int is_internal_gamma;
  301. uint16_t *gamma;
  302. uint16_t *inv_gamma;
  303. uint32_t pal_yuv[256];
  304. uint32_t pal_rgb[256];
  305. /**
  306. * @name Scaled horizontal lines ring buffer.
  307. * The horizontal scaler keeps just enough scaled lines in a ring buffer
  308. * so they may be passed to the vertical scaler. The pointers to the
  309. * allocated buffers for each line are duplicated in sequence in the ring
  310. * buffer to simplify indexing and avoid wrapping around between lines
  311. * inside the vertical scaler code. The wrapping is done before the
  312. * vertical scaler is called.
  313. */
  314. //@{
  315. int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
  316. int16_t **chrUPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
  317. int16_t **chrVPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
  318. int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
  319. int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
  320. int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
  321. int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
  322. int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer.
  323. int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
  324. int chrBufIndex; ///< Index in ring buffer of the last scaled horizontal chroma line from source.
  325. //@}
  326. uint8_t *formatConvBuffer;
  327. /**
  328. * @name Horizontal and vertical filters.
  329. * To better understand the following fields, here is a pseudo-code of
  330. * their usage in filtering a horizontal line:
  331. * @code
  332. * for (i = 0; i < width; i++) {
  333. * dst[i] = 0;
  334. * for (j = 0; j < filterSize; j++)
  335. * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
  336. * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
  337. * }
  338. * @endcode
  339. */
  340. //@{
  341. int16_t *hLumFilter; ///< Array of horizontal filter coefficients for luma/alpha planes.
  342. int16_t *hChrFilter; ///< Array of horizontal filter coefficients for chroma planes.
  343. int16_t *vLumFilter; ///< Array of vertical filter coefficients for luma/alpha planes.
  344. int16_t *vChrFilter; ///< Array of vertical filter coefficients for chroma planes.
  345. int32_t *hLumFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
  346. int32_t *hChrFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for chroma planes.
  347. int32_t *vLumFilterPos; ///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
  348. int32_t *vChrFilterPos; ///< Array of vertical filter starting positions for each dst[i] for chroma planes.
  349. int hLumFilterSize; ///< Horizontal filter size for luma/alpha pixels.
  350. int hChrFilterSize; ///< Horizontal filter size for chroma pixels.
  351. int vLumFilterSize; ///< Vertical filter size for luma/alpha pixels.
  352. int vChrFilterSize; ///< Vertical filter size for chroma pixels.
  353. //@}
  354. int lumMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes.
  355. int chrMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
  356. uint8_t *lumMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
  357. uint8_t *chrMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
  358. int canMMXEXTBeUsed;
  359. int dstY; ///< Last destination vertical line output from last slice.
  360. int flags; ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
  361. void *yuvTable; // pointer to the yuv->rgb table start so it can be freed()
  362. // alignment ensures the offset can be added in a single
  363. // instruction on e.g. ARM
  364. DECLARE_ALIGNED(16, int, table_gV)[256 + 2*YUVRGB_TABLE_HEADROOM];
  365. uint8_t *table_rV[256 + 2*YUVRGB_TABLE_HEADROOM];
  366. uint8_t *table_gU[256 + 2*YUVRGB_TABLE_HEADROOM];
  367. uint8_t *table_bU[256 + 2*YUVRGB_TABLE_HEADROOM];
  368. DECLARE_ALIGNED(16, int32_t, input_rgb2yuv_table)[16+40*4]; // This table can contain both C and SIMD formatted values, the C vales are always at the XY_IDX points
  369. #define RY_IDX 0
  370. #define GY_IDX 1
  371. #define BY_IDX 2
  372. #define RU_IDX 3
  373. #define GU_IDX 4
  374. #define BU_IDX 5
  375. #define RV_IDX 6
  376. #define GV_IDX 7
  377. #define BV_IDX 8
  378. #define RGB2YUV_SHIFT 15
  379. int *dither_error[4];
  380. //Colorspace stuff
  381. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  382. int srcColorspaceTable[4];
  383. int dstColorspaceTable[4];
  384. int srcRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
  385. int dstRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
  386. int src0Alpha;
  387. int dst0Alpha;
  388. int srcXYZ;
  389. int dstXYZ;
  390. int src_h_chr_pos;
  391. int dst_h_chr_pos;
  392. int src_v_chr_pos;
  393. int dst_v_chr_pos;
  394. int yuv2rgb_y_offset;
  395. int yuv2rgb_y_coeff;
  396. int yuv2rgb_v2r_coeff;
  397. int yuv2rgb_v2g_coeff;
  398. int yuv2rgb_u2g_coeff;
  399. int yuv2rgb_u2b_coeff;
  400. #define RED_DITHER "0*8"
  401. #define GREEN_DITHER "1*8"
  402. #define BLUE_DITHER "2*8"
  403. #define Y_COEFF "3*8"
  404. #define VR_COEFF "4*8"
  405. #define UB_COEFF "5*8"
  406. #define VG_COEFF "6*8"
  407. #define UG_COEFF "7*8"
  408. #define Y_OFFSET "8*8"
  409. #define U_OFFSET "9*8"
  410. #define V_OFFSET "10*8"
  411. #define LUM_MMX_FILTER_OFFSET "11*8"
  412. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
  413. #define DSTW_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
  414. #define ESP_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
  415. #define VROUNDER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
  416. #define U_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
  417. #define V_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
  418. #define Y_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
  419. #define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
  420. #define UV_OFF_PX "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
  421. #define UV_OFF_BYTE "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
  422. #define DITHER16 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
  423. #define DITHER32 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
  424. #define DITHER32_INT (11*8+4*4*MAX_FILTER_SIZE*3+80) // value equal to above, used for checking that the struct hasn't been changed by mistake
  425. DECLARE_ALIGNED(8, uint64_t, redDither);
  426. DECLARE_ALIGNED(8, uint64_t, greenDither);
  427. DECLARE_ALIGNED(8, uint64_t, blueDither);
  428. DECLARE_ALIGNED(8, uint64_t, yCoeff);
  429. DECLARE_ALIGNED(8, uint64_t, vrCoeff);
  430. DECLARE_ALIGNED(8, uint64_t, ubCoeff);
  431. DECLARE_ALIGNED(8, uint64_t, vgCoeff);
  432. DECLARE_ALIGNED(8, uint64_t, ugCoeff);
  433. DECLARE_ALIGNED(8, uint64_t, yOffset);
  434. DECLARE_ALIGNED(8, uint64_t, uOffset);
  435. DECLARE_ALIGNED(8, uint64_t, vOffset);
  436. int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
  437. int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
  438. int dstW; ///< Width of destination luma/alpha planes.
  439. DECLARE_ALIGNED(8, uint64_t, esp);
  440. DECLARE_ALIGNED(8, uint64_t, vRounder);
  441. DECLARE_ALIGNED(8, uint64_t, u_temp);
  442. DECLARE_ALIGNED(8, uint64_t, v_temp);
  443. DECLARE_ALIGNED(8, uint64_t, y_temp);
  444. int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
  445. // alignment of these values is not necessary, but merely here
  446. // to maintain the same offset across x8632 and x86-64. Once we
  447. // use proper offset macros in the asm, they can be removed.
  448. DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes
  449. DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes
  450. DECLARE_ALIGNED(8, uint16_t, dither16)[8];
  451. DECLARE_ALIGNED(8, uint32_t, dither32)[8];
  452. const uint8_t *chrDither8, *lumDither8;
  453. #if HAVE_ALTIVEC
  454. vector signed short CY;
  455. vector signed short CRV;
  456. vector signed short CBU;
  457. vector signed short CGU;
  458. vector signed short CGV;
  459. vector signed short OY;
  460. vector unsigned short CSHIFT;
  461. vector signed short *vYCoeffsBank, *vCCoeffsBank;
  462. #endif
  463. int use_mmx_vfilter;
  464. /* pre defined color-spaces gamma */
  465. #define XYZ_GAMMA (2.6f)
  466. #define RGB_GAMMA (2.2f)
  467. int16_t *xyzgamma;
  468. int16_t *rgbgamma;
  469. int16_t *xyzgammainv;
  470. int16_t *rgbgammainv;
  471. int16_t xyz2rgb_matrix[3][4];
  472. int16_t rgb2xyz_matrix[3][4];
  473. /* function pointers for swscale() */
  474. yuv2planar1_fn yuv2plane1;
  475. yuv2planarX_fn yuv2planeX;
  476. yuv2interleavedX_fn yuv2nv12cX;
  477. yuv2packed1_fn yuv2packed1;
  478. yuv2packed2_fn yuv2packed2;
  479. yuv2packedX_fn yuv2packedX;
  480. yuv2anyX_fn yuv2anyX;
  481. /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
  482. void (*lumToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
  483. int width, uint32_t *pal);
  484. /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
  485. void (*alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
  486. int width, uint32_t *pal);
  487. /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
  488. void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
  489. const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
  490. int width, uint32_t *pal);
  491. /**
  492. * Functions to read planar input, such as planar RGB, and convert
  493. * internally to Y/UV/A.
  494. */
  495. /** @{ */
  496. void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
  497. void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4],
  498. int width, int32_t *rgb2yuv);
  499. void (*readAlpPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
  500. /** @} */
  501. /**
  502. * Scale one horizontal line of input data using a bilinear filter
  503. * to produce one line of output data. Compared to SwsContext->hScale(),
  504. * please take note of the following caveats when using these:
  505. * - Scaling is done using only 7bit instead of 14bit coefficients.
  506. * - You can use no more than 5 input pixels to produce 4 output
  507. * pixels. Therefore, this filter should not be used for downscaling
  508. * by more than ~20% in width (because that equals more than 5/4th
  509. * downscaling and thus more than 5 pixels input per 4 pixels output).
  510. * - In general, bilinear filters create artifacts during downscaling
  511. * (even when <20%), because one output pixel will span more than one
  512. * input pixel, and thus some pixels will need edges of both neighbor
  513. * pixels to interpolate the output pixel. Since you can use at most
  514. * two input pixels per output pixel in bilinear scaling, this is
  515. * impossible and thus downscaling by any size will create artifacts.
  516. * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
  517. * in SwsContext->flags.
  518. */
  519. /** @{ */
  520. void (*hyscale_fast)(struct SwsContext *c,
  521. int16_t *dst, int dstWidth,
  522. const uint8_t *src, int srcW, int xInc);
  523. void (*hcscale_fast)(struct SwsContext *c,
  524. int16_t *dst1, int16_t *dst2, int dstWidth,
  525. const uint8_t *src1, const uint8_t *src2,
  526. int srcW, int xInc);
  527. /** @} */
  528. /**
  529. * Scale one horizontal line of input data using a filter over the input
  530. * lines, to produce one (differently sized) line of output data.
  531. *
  532. * @param dst pointer to destination buffer for horizontally scaled
  533. * data. If the number of bits per component of one
  534. * destination pixel (SwsContext->dstBpc) is <= 10, data
  535. * will be 15bpc in 16bits (int16_t) width. Else (i.e.
  536. * SwsContext->dstBpc == 16), data will be 19bpc in
  537. * 32bits (int32_t) width.
  538. * @param dstW width of destination image
  539. * @param src pointer to source data to be scaled. If the number of
  540. * bits per component of a source pixel (SwsContext->srcBpc)
  541. * is 8, this is 8bpc in 8bits (uint8_t) width. Else
  542. * (i.e. SwsContext->dstBpc > 8), this is native depth
  543. * in 16bits (uint16_t) width. In other words, for 9-bit
  544. * YUV input, this is 9bpc, for 10-bit YUV input, this is
  545. * 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
  546. * @param filter filter coefficients to be used per output pixel for
  547. * scaling. This contains 14bpp filtering coefficients.
  548. * Guaranteed to contain dstW * filterSize entries.
  549. * @param filterPos position of the first input pixel to be used for
  550. * each output pixel during scaling. Guaranteed to
  551. * contain dstW entries.
  552. * @param filterSize the number of input coefficients to be used (and
  553. * thus the number of input pixels to be used) for
  554. * creating a single output pixel. Is aligned to 4
  555. * (and input coefficients thus padded with zeroes)
  556. * to simplify creating SIMD code.
  557. */
  558. /** @{ */
  559. void (*hyScale)(struct SwsContext *c, int16_t *dst, int dstW,
  560. const uint8_t *src, const int16_t *filter,
  561. const int32_t *filterPos, int filterSize);
  562. void (*hcScale)(struct SwsContext *c, int16_t *dst, int dstW,
  563. const uint8_t *src, const int16_t *filter,
  564. const int32_t *filterPos, int filterSize);
  565. /** @} */
  566. /// Color range conversion function for luma plane if needed.
  567. void (*lumConvertRange)(int16_t *dst, int width);
  568. /// Color range conversion function for chroma planes if needed.
  569. void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width);
  570. int needs_hcscale; ///< Set if there are chroma planes to be converted.
  571. SwsDither dither;
  572. SwsAlphaBlend alphablend;
  573. } SwsContext;
  574. //FIXME check init (where 0)
  575. SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
  576. int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
  577. int fullRange, int brightness,
  578. int contrast, int saturation);
  579. void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4],
  580. int brightness, int contrast, int saturation);
  581. void ff_updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
  582. int lastInLumBuf, int lastInChrBuf);
  583. av_cold void ff_sws_init_range_convert(SwsContext *c);
  584. SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
  585. SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c);
  586. static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
  587. {
  588. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  589. av_assert0(desc);
  590. return desc->comp[0].depth_minus1 == 15;
  591. }
  592. static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
  593. {
  594. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  595. av_assert0(desc);
  596. return desc->comp[0].depth_minus1 >= 8 && desc->comp[0].depth_minus1 <= 13;
  597. }
  598. #define isNBPS(x) is9_OR_10BPS(x)
  599. static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
  600. {
  601. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  602. av_assert0(desc);
  603. return desc->flags & AV_PIX_FMT_FLAG_BE;
  604. }
  605. static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
  606. {
  607. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  608. av_assert0(desc);
  609. return !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
  610. }
  611. static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
  612. {
  613. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  614. av_assert0(desc);
  615. return ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && isYUV(pix_fmt));
  616. }
  617. static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
  618. {
  619. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  620. av_assert0(desc);
  621. return (desc->flags & AV_PIX_FMT_FLAG_RGB);
  622. }
  623. #if 0 // FIXME
  624. #define isGray(x) \
  625. (!(av_pix_fmt_desc_get(x)->flags & AV_PIX_FMT_FLAG_PAL) && \
  626. av_pix_fmt_desc_get(x)->nb_components <= 2)
  627. #else
  628. #define isGray(x) \
  629. ((x) == AV_PIX_FMT_GRAY8 || \
  630. (x) == AV_PIX_FMT_YA8 || \
  631. (x) == AV_PIX_FMT_GRAY16BE || \
  632. (x) == AV_PIX_FMT_GRAY16LE || \
  633. (x) == AV_PIX_FMT_YA16BE || \
  634. (x) == AV_PIX_FMT_YA16LE)
  635. #endif
  636. #define isRGBinInt(x) \
  637. ( \
  638. (x) == AV_PIX_FMT_RGB48BE || \
  639. (x) == AV_PIX_FMT_RGB48LE || \
  640. (x) == AV_PIX_FMT_RGB32 || \
  641. (x) == AV_PIX_FMT_RGB32_1 || \
  642. (x) == AV_PIX_FMT_RGB24 || \
  643. (x) == AV_PIX_FMT_RGB565BE || \
  644. (x) == AV_PIX_FMT_RGB565LE || \
  645. (x) == AV_PIX_FMT_RGB555BE || \
  646. (x) == AV_PIX_FMT_RGB555LE || \
  647. (x) == AV_PIX_FMT_RGB444BE || \
  648. (x) == AV_PIX_FMT_RGB444LE || \
  649. (x) == AV_PIX_FMT_RGB8 || \
  650. (x) == AV_PIX_FMT_RGB4 || \
  651. (x) == AV_PIX_FMT_RGB4_BYTE || \
  652. (x) == AV_PIX_FMT_RGBA64BE || \
  653. (x) == AV_PIX_FMT_RGBA64LE || \
  654. (x) == AV_PIX_FMT_MONOBLACK || \
  655. (x) == AV_PIX_FMT_MONOWHITE \
  656. )
  657. #define isBGRinInt(x) \
  658. ( \
  659. (x) == AV_PIX_FMT_BGR48BE || \
  660. (x) == AV_PIX_FMT_BGR48LE || \
  661. (x) == AV_PIX_FMT_BGR32 || \
  662. (x) == AV_PIX_FMT_BGR32_1 || \
  663. (x) == AV_PIX_FMT_BGR24 || \
  664. (x) == AV_PIX_FMT_BGR565BE || \
  665. (x) == AV_PIX_FMT_BGR565LE || \
  666. (x) == AV_PIX_FMT_BGR555BE || \
  667. (x) == AV_PIX_FMT_BGR555LE || \
  668. (x) == AV_PIX_FMT_BGR444BE || \
  669. (x) == AV_PIX_FMT_BGR444LE || \
  670. (x) == AV_PIX_FMT_BGR8 || \
  671. (x) == AV_PIX_FMT_BGR4 || \
  672. (x) == AV_PIX_FMT_BGR4_BYTE || \
  673. (x) == AV_PIX_FMT_BGRA64BE || \
  674. (x) == AV_PIX_FMT_BGRA64LE || \
  675. (x) == AV_PIX_FMT_MONOBLACK || \
  676. (x) == AV_PIX_FMT_MONOWHITE \
  677. )
  678. #define isRGBinBytes(x) ( \
  679. (x) == AV_PIX_FMT_RGB48BE \
  680. || (x) == AV_PIX_FMT_RGB48LE \
  681. || (x) == AV_PIX_FMT_RGBA64BE \
  682. || (x) == AV_PIX_FMT_RGBA64LE \
  683. || (x) == AV_PIX_FMT_RGBA \
  684. || (x) == AV_PIX_FMT_ARGB \
  685. || (x) == AV_PIX_FMT_RGB24 \
  686. )
  687. #define isBGRinBytes(x) ( \
  688. (x) == AV_PIX_FMT_BGR48BE \
  689. || (x) == AV_PIX_FMT_BGR48LE \
  690. || (x) == AV_PIX_FMT_BGRA64BE \
  691. || (x) == AV_PIX_FMT_BGRA64LE \
  692. || (x) == AV_PIX_FMT_BGRA \
  693. || (x) == AV_PIX_FMT_ABGR \
  694. || (x) == AV_PIX_FMT_BGR24 \
  695. )
  696. #define isBayer(x) ( \
  697. (x)==AV_PIX_FMT_BAYER_BGGR8 \
  698. || (x)==AV_PIX_FMT_BAYER_BGGR16LE \
  699. || (x)==AV_PIX_FMT_BAYER_BGGR16BE \
  700. || (x)==AV_PIX_FMT_BAYER_RGGB8 \
  701. || (x)==AV_PIX_FMT_BAYER_RGGB16LE \
  702. || (x)==AV_PIX_FMT_BAYER_RGGB16BE \
  703. || (x)==AV_PIX_FMT_BAYER_GBRG8 \
  704. || (x)==AV_PIX_FMT_BAYER_GBRG16LE \
  705. || (x)==AV_PIX_FMT_BAYER_GBRG16BE \
  706. || (x)==AV_PIX_FMT_BAYER_GRBG8 \
  707. || (x)==AV_PIX_FMT_BAYER_GRBG16LE \
  708. || (x)==AV_PIX_FMT_BAYER_GRBG16BE \
  709. )
  710. #define isAnyRGB(x) \
  711. ( \
  712. isBayer(x) || \
  713. isRGBinInt(x) || \
  714. isBGRinInt(x) || \
  715. isRGB(x) \
  716. )
  717. static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
  718. {
  719. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  720. av_assert0(desc);
  721. if (pix_fmt == AV_PIX_FMT_PAL8)
  722. return 1;
  723. return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
  724. }
  725. #if 1
  726. #define isPacked(x) ( \
  727. (x)==AV_PIX_FMT_PAL8 \
  728. || (x)==AV_PIX_FMT_YUYV422 \
  729. || (x)==AV_PIX_FMT_YVYU422 \
  730. || (x)==AV_PIX_FMT_UYVY422 \
  731. || (x)==AV_PIX_FMT_YA8 \
  732. || (x)==AV_PIX_FMT_YA16LE \
  733. || (x)==AV_PIX_FMT_YA16BE \
  734. || (x)==AV_PIX_FMT_AYUV64LE \
  735. || (x)==AV_PIX_FMT_AYUV64BE \
  736. || isRGBinInt(x) \
  737. || isBGRinInt(x) \
  738. )
  739. #else
  740. static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
  741. {
  742. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  743. av_assert0(desc);
  744. return ((desc->nb_components >= 2 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) ||
  745. pix_fmt == AV_PIX_FMT_PAL8);
  746. }
  747. #endif
  748. static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
  749. {
  750. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  751. av_assert0(desc);
  752. return (desc->nb_components >= 2 && (desc->flags & AV_PIX_FMT_FLAG_PLANAR));
  753. }
  754. static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
  755. {
  756. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  757. av_assert0(desc);
  758. return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) == AV_PIX_FMT_FLAG_RGB);
  759. }
  760. static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
  761. {
  762. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  763. av_assert0(desc);
  764. return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) ==
  765. (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB));
  766. }
  767. static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
  768. {
  769. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  770. av_assert0(desc);
  771. return (desc->flags & AV_PIX_FMT_FLAG_PAL) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL);
  772. }
  773. extern const uint64_t ff_dither4[2];
  774. extern const uint64_t ff_dither8[2];
  775. extern const uint8_t ff_dither_2x2_4[3][8];
  776. extern const uint8_t ff_dither_2x2_8[3][8];
  777. extern const uint8_t ff_dither_4x4_16[5][8];
  778. extern const uint8_t ff_dither_8x8_32[9][8];
  779. extern const uint8_t ff_dither_8x8_73[9][8];
  780. extern const uint8_t ff_dither_8x8_128[9][8];
  781. extern const uint8_t ff_dither_8x8_220[9][8];
  782. extern const int32_t ff_yuv2rgb_coeffs[8][4];
  783. extern const AVClass sws_context_class;
  784. /**
  785. * Set c->swscale to an unscaled converter if one exists for the specific
  786. * source and destination formats, bit depths, flags, etc.
  787. */
  788. void ff_get_unscaled_swscale(SwsContext *c);
  789. void ff_get_unscaled_swscale_ppc(SwsContext *c);
  790. void ff_get_unscaled_swscale_arm(SwsContext *c);
  791. /**
  792. * Return function pointer to fastest main scaler path function depending
  793. * on architecture and available optimizations.
  794. */
  795. SwsFunc ff_getSwsFunc(SwsContext *c);
  796. void ff_sws_init_input_funcs(SwsContext *c);
  797. void ff_sws_init_output_funcs(SwsContext *c,
  798. yuv2planar1_fn *yuv2plane1,
  799. yuv2planarX_fn *yuv2planeX,
  800. yuv2interleavedX_fn *yuv2nv12cX,
  801. yuv2packed1_fn *yuv2packed1,
  802. yuv2packed2_fn *yuv2packed2,
  803. yuv2packedX_fn *yuv2packedX,
  804. yuv2anyX_fn *yuv2anyX);
  805. void ff_sws_init_swscale_ppc(SwsContext *c);
  806. void ff_sws_init_swscale_x86(SwsContext *c);
  807. void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
  808. const uint8_t *src, int srcW, int xInc);
  809. void ff_hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
  810. int dstWidth, const uint8_t *src1,
  811. const uint8_t *src2, int srcW, int xInc);
  812. int ff_init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
  813. int16_t *filter, int32_t *filterPos,
  814. int numSplits);
  815. void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
  816. int dstWidth, const uint8_t *src,
  817. int srcW, int xInc);
  818. void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
  819. int dstWidth, const uint8_t *src1,
  820. const uint8_t *src2, int srcW, int xInc);
  821. /**
  822. * Allocate and return an SwsContext.
  823. * This is like sws_getContext() but does not perform the init step, allowing
  824. * the user to set additional AVOptions.
  825. *
  826. * @see sws_getContext()
  827. */
  828. struct SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat,
  829. int dstW, int dstH, enum AVPixelFormat dstFormat,
  830. int flags, const double *param);
  831. int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[],
  832. int srcStride[], int srcSliceY, int srcSliceH,
  833. uint8_t *dst[], int dstStride[]);
  834. static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
  835. int alpha, int bits, const int big_endian)
  836. {
  837. int i, j;
  838. uint8_t *ptr = plane + stride * y;
  839. int v = alpha ? 0xFFFF>>(15-bits) : (1<<bits);
  840. for (i = 0; i < height; i++) {
  841. #define FILL(wfunc) \
  842. for (j = 0; j < width; j++) {\
  843. wfunc(ptr+2*j, v);\
  844. }
  845. if (big_endian) {
  846. FILL(AV_WB16);
  847. } else {
  848. FILL(AV_WL16);
  849. }
  850. ptr += stride;
  851. }
  852. }
  853. #endif /* SWSCALE_SWSCALE_INTERNAL_H */