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.

485 lines
21KB

  1. /*
  2. * Copyright (C) 2001-2003 Michael Niedermayer <michaelni@gmx.at>
  3. *
  4. * This file is part of Libav.
  5. *
  6. * Libav 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. * Libav 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 Libav; 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 "libavutil/avutil.h"
  27. #define STR(s) AV_TOSTRING(s) //AV_STRINGIFY is too long
  28. #define FAST_BGR2YV12 //use 7-bit instead of 15-bit coefficients
  29. #define MAX_FILTER_SIZE 256
  30. #if ARCH_X86
  31. #define VOFW 5120
  32. #else
  33. #define VOFW 2048 // faster on PPC and not tested on others
  34. #endif
  35. #define VOF (VOFW*2)
  36. #if HAVE_BIGENDIAN
  37. #define ALT32_CORR (-1)
  38. #else
  39. #define ALT32_CORR 1
  40. #endif
  41. #if ARCH_X86_64
  42. # define APCK_PTR2 8
  43. # define APCK_COEF 16
  44. # define APCK_SIZE 24
  45. #else
  46. # define APCK_PTR2 4
  47. # define APCK_COEF 8
  48. # define APCK_SIZE 16
  49. #endif
  50. struct SwsContext;
  51. typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[],
  52. int srcStride[], int srcSliceY, int srcSliceH,
  53. uint8_t* dst[], int dstStride[]);
  54. /* This struct should be aligned on at least a 32-byte boundary. */
  55. typedef struct SwsContext {
  56. /**
  57. * info on struct for av_log
  58. */
  59. const AVClass *av_class;
  60. /**
  61. * Note that src, dst, srcStride, dstStride will be copied in the
  62. * sws_scale() wrapper so they can be freely modified here.
  63. */
  64. SwsFunc swScale;
  65. int srcW; ///< Width of source luma/alpha planes.
  66. int srcH; ///< Height of source luma/alpha planes.
  67. int dstH; ///< Height of destination luma/alpha planes.
  68. int chrSrcW; ///< Width of source chroma planes.
  69. int chrSrcH; ///< Height of source chroma planes.
  70. int chrDstW; ///< Width of destination chroma planes.
  71. int chrDstH; ///< Height of destination chroma planes.
  72. int lumXInc, chrXInc;
  73. int lumYInc, chrYInc;
  74. enum PixelFormat dstFormat; ///< Destination pixel format.
  75. enum PixelFormat srcFormat; ///< Source pixel format.
  76. int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format.
  77. int srcFormatBpp; ///< Number of bits per pixel of the source pixel format.
  78. int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
  79. int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
  80. int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
  81. int chrDstVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
  82. int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
  83. int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
  84. double param[2]; ///< Input parameters for scaling algorithms that need them.
  85. uint32_t pal_yuv[256];
  86. uint32_t pal_rgb[256];
  87. /**
  88. * @name Scaled horizontal lines ring buffer.
  89. * The horizontal scaler keeps just enough scaled lines in a ring buffer
  90. * so they may be passed to the vertical scaler. The pointers to the
  91. * allocated buffers for each line are duplicated in sequence in the ring
  92. * buffer to simplify indexing and avoid wrapping around between lines
  93. * inside the vertical scaler code. The wrapping is done before the
  94. * vertical scaler is called.
  95. */
  96. //@{
  97. int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
  98. int16_t **chrPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
  99. int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
  100. int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
  101. int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
  102. int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
  103. int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer.
  104. int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
  105. int chrBufIndex; ///< Index in ring buffer of the last scaled horizontal chroma line from source.
  106. //@}
  107. uint8_t formatConvBuffer[VOF]; //FIXME dynamic allocation, but we have to change a lot of code for this to be useful
  108. /**
  109. * @name Horizontal and vertical filters.
  110. * To better understand the following fields, here is a pseudo-code of
  111. * their usage in filtering a horizontal line:
  112. * @code
  113. * for (i = 0; i < width; i++) {
  114. * dst[i] = 0;
  115. * for (j = 0; j < filterSize; j++)
  116. * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
  117. * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
  118. * }
  119. * @endcode
  120. */
  121. //@{
  122. int16_t *hLumFilter; ///< Array of horizontal filter coefficients for luma/alpha planes.
  123. int16_t *hChrFilter; ///< Array of horizontal filter coefficients for chroma planes.
  124. int16_t *vLumFilter; ///< Array of vertical filter coefficients for luma/alpha planes.
  125. int16_t *vChrFilter; ///< Array of vertical filter coefficients for chroma planes.
  126. int16_t *hLumFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
  127. int16_t *hChrFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for chroma planes.
  128. int16_t *vLumFilterPos; ///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
  129. int16_t *vChrFilterPos; ///< Array of vertical filter starting positions for each dst[i] for chroma planes.
  130. int hLumFilterSize; ///< Horizontal filter size for luma/alpha pixels.
  131. int hChrFilterSize; ///< Horizontal filter size for chroma pixels.
  132. int vLumFilterSize; ///< Vertical filter size for luma/alpha pixels.
  133. int vChrFilterSize; ///< Vertical filter size for chroma pixels.
  134. //@}
  135. int lumMmx2FilterCodeSize; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code size for luma/alpha planes.
  136. int chrMmx2FilterCodeSize; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code size for chroma planes.
  137. uint8_t *lumMmx2FilterCode; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code for luma/alpha planes.
  138. uint8_t *chrMmx2FilterCode; ///< Runtime-generated MMX2 horizontal fast bilinear scaler code for chroma planes.
  139. int canMMX2BeUsed;
  140. int dstY; ///< Last destination vertical line output from last slice.
  141. int flags; ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
  142. void * yuvTable; // pointer to the yuv->rgb table start so it can be freed()
  143. uint8_t * table_rV[256];
  144. uint8_t * table_gU[256];
  145. int table_gV[256];
  146. uint8_t * table_bU[256];
  147. //Colorspace stuff
  148. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  149. int srcColorspaceTable[4];
  150. int dstColorspaceTable[4];
  151. int srcRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
  152. int dstRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
  153. int yuv2rgb_y_offset;
  154. int yuv2rgb_y_coeff;
  155. int yuv2rgb_v2r_coeff;
  156. int yuv2rgb_v2g_coeff;
  157. int yuv2rgb_u2g_coeff;
  158. int yuv2rgb_u2b_coeff;
  159. #define RED_DITHER "0*8"
  160. #define GREEN_DITHER "1*8"
  161. #define BLUE_DITHER "2*8"
  162. #define Y_COEFF "3*8"
  163. #define VR_COEFF "4*8"
  164. #define UB_COEFF "5*8"
  165. #define VG_COEFF "6*8"
  166. #define UG_COEFF "7*8"
  167. #define Y_OFFSET "8*8"
  168. #define U_OFFSET "9*8"
  169. #define V_OFFSET "10*8"
  170. #define LUM_MMX_FILTER_OFFSET "11*8"
  171. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*256"
  172. #define DSTW_OFFSET "11*8+4*4*256*2" //do not change, it is hardcoded in the ASM
  173. #define ESP_OFFSET "11*8+4*4*256*2+8"
  174. #define VROUNDER_OFFSET "11*8+4*4*256*2+16"
  175. #define U_TEMP "11*8+4*4*256*2+24"
  176. #define V_TEMP "11*8+4*4*256*2+32"
  177. #define Y_TEMP "11*8+4*4*256*2+40"
  178. #define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48"
  179. DECLARE_ALIGNED(8, uint64_t, redDither);
  180. DECLARE_ALIGNED(8, uint64_t, greenDither);
  181. DECLARE_ALIGNED(8, uint64_t, blueDither);
  182. DECLARE_ALIGNED(8, uint64_t, yCoeff);
  183. DECLARE_ALIGNED(8, uint64_t, vrCoeff);
  184. DECLARE_ALIGNED(8, uint64_t, ubCoeff);
  185. DECLARE_ALIGNED(8, uint64_t, vgCoeff);
  186. DECLARE_ALIGNED(8, uint64_t, ugCoeff);
  187. DECLARE_ALIGNED(8, uint64_t, yOffset);
  188. DECLARE_ALIGNED(8, uint64_t, uOffset);
  189. DECLARE_ALIGNED(8, uint64_t, vOffset);
  190. int32_t lumMmxFilter[4*MAX_FILTER_SIZE];
  191. int32_t chrMmxFilter[4*MAX_FILTER_SIZE];
  192. int dstW; ///< Width of destination luma/alpha planes.
  193. DECLARE_ALIGNED(8, uint64_t, esp);
  194. DECLARE_ALIGNED(8, uint64_t, vRounder);
  195. DECLARE_ALIGNED(8, uint64_t, u_temp);
  196. DECLARE_ALIGNED(8, uint64_t, v_temp);
  197. DECLARE_ALIGNED(8, uint64_t, y_temp);
  198. int32_t alpMmxFilter[4*MAX_FILTER_SIZE];
  199. #if HAVE_ALTIVEC
  200. vector signed short CY;
  201. vector signed short CRV;
  202. vector signed short CBU;
  203. vector signed short CGU;
  204. vector signed short CGV;
  205. vector signed short OY;
  206. vector unsigned short CSHIFT;
  207. vector signed short *vYCoeffsBank, *vCCoeffsBank;
  208. #endif
  209. #if ARCH_BFIN
  210. DECLARE_ALIGNED(4, uint32_t, oy);
  211. DECLARE_ALIGNED(4, uint32_t, oc);
  212. DECLARE_ALIGNED(4, uint32_t, zero);
  213. DECLARE_ALIGNED(4, uint32_t, cy);
  214. DECLARE_ALIGNED(4, uint32_t, crv);
  215. DECLARE_ALIGNED(4, uint32_t, rmask);
  216. DECLARE_ALIGNED(4, uint32_t, cbu);
  217. DECLARE_ALIGNED(4, uint32_t, bmask);
  218. DECLARE_ALIGNED(4, uint32_t, cgu);
  219. DECLARE_ALIGNED(4, uint32_t, cgv);
  220. DECLARE_ALIGNED(4, uint32_t, gmask);
  221. #endif
  222. #if HAVE_VIS
  223. DECLARE_ALIGNED(8, uint64_t, sparc_coeffs)[10];
  224. #endif
  225. /* function pointers for swScale() */
  226. void (*yuv2nv12X )(struct SwsContext *c,
  227. const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
  228. const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
  229. uint8_t *dest, uint8_t *uDest,
  230. int dstW, int chrDstW, int dstFormat);
  231. void (*yuv2yuv1 )(struct SwsContext *c,
  232. const int16_t *lumSrc, const int16_t *chrSrc, const int16_t *alpSrc,
  233. uint8_t *dest,
  234. uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
  235. long dstW, long chrDstW);
  236. void (*yuv2yuvX )(struct SwsContext *c,
  237. const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
  238. const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
  239. const int16_t **alpSrc,
  240. uint8_t *dest,
  241. uint8_t *uDest, uint8_t *vDest, uint8_t *aDest,
  242. long dstW, long chrDstW);
  243. void (*yuv2packed1)(struct SwsContext *c,
  244. const uint16_t *buf0,
  245. const uint16_t *uvbuf0, const uint16_t *uvbuf1,
  246. const uint16_t *abuf0,
  247. uint8_t *dest,
  248. int dstW, int uvalpha, int dstFormat, int flags, int y);
  249. void (*yuv2packed2)(struct SwsContext *c,
  250. const uint16_t *buf0, const uint16_t *buf1,
  251. const uint16_t *uvbuf0, const uint16_t *uvbuf1,
  252. const uint16_t *abuf0, const uint16_t *abuf1,
  253. uint8_t *dest,
  254. int dstW, int yalpha, int uvalpha, int y);
  255. void (*yuv2packedX)(struct SwsContext *c,
  256. const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
  257. const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
  258. const int16_t **alpSrc, uint8_t *dest,
  259. long dstW, long dstY);
  260. void (*lumToYV12)(uint8_t *dst, const uint8_t *src,
  261. long width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler.
  262. void (*alpToYV12)(uint8_t *dst, const uint8_t *src,
  263. long width, uint32_t *pal); ///< Unscaled conversion of alpha plane to YV12 for horizontal scaler.
  264. void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
  265. const uint8_t *src1, const uint8_t *src2,
  266. long width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler.
  267. void (*hyscale_fast)(struct SwsContext *c,
  268. int16_t *dst, long dstWidth,
  269. const uint8_t *src, int srcW, int xInc);
  270. void (*hcscale_fast)(struct SwsContext *c,
  271. int16_t *dst, long dstWidth,
  272. const uint8_t *src1, const uint8_t *src2,
  273. int srcW, int xInc);
  274. void (*hScale)(int16_t *dst, int dstW, const uint8_t *src, int srcW,
  275. int xInc, const int16_t *filter, const int16_t *filterPos,
  276. long filterSize);
  277. void (*lumConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for luma plane if needed.
  278. void (*chrConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for chroma planes if needed.
  279. int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions.
  280. int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions.
  281. int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions.
  282. int needs_hcscale; ///< Set if there are chroma planes to be converted.
  283. } SwsContext;
  284. //FIXME check init (where 0)
  285. SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
  286. int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
  287. int fullRange, int brightness,
  288. int contrast, int saturation);
  289. void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4],
  290. int brightness, int contrast, int saturation);
  291. SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c);
  292. SwsFunc ff_yuv2rgb_init_vis(SwsContext *c);
  293. SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c);
  294. SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c);
  295. SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c);
  296. void ff_bfin_get_unscaled_swscale(SwsContext *c);
  297. void ff_yuv2packedX_altivec(SwsContext *c,
  298. const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
  299. const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
  300. uint8_t *dest, int dstW, int dstY);
  301. const char *sws_format_name(enum PixelFormat format);
  302. //FIXME replace this with something faster
  303. #define is16BPS(x) ( \
  304. (x)==PIX_FMT_GRAY16BE \
  305. || (x)==PIX_FMT_GRAY16LE \
  306. || (x)==PIX_FMT_BGR48BE \
  307. || (x)==PIX_FMT_BGR48LE \
  308. || (x)==PIX_FMT_RGB48BE \
  309. || (x)==PIX_FMT_RGB48LE \
  310. || (x)==PIX_FMT_YUV420P16LE \
  311. || (x)==PIX_FMT_YUV422P16LE \
  312. || (x)==PIX_FMT_YUV444P16LE \
  313. || (x)==PIX_FMT_YUV420P16BE \
  314. || (x)==PIX_FMT_YUV422P16BE \
  315. || (x)==PIX_FMT_YUV444P16BE \
  316. )
  317. #define is9_OR_10BPS(x) ( \
  318. (x)==PIX_FMT_YUV420P9LE \
  319. || (x)==PIX_FMT_YUV420P9BE \
  320. || (x)==PIX_FMT_YUV420P10LE \
  321. || (x)==PIX_FMT_YUV420P10BE \
  322. )
  323. #define isBE(x) ((x)&1)
  324. #define isPlanar8YUV(x) ( \
  325. (x)==PIX_FMT_YUV410P \
  326. || (x)==PIX_FMT_YUV420P \
  327. || (x)==PIX_FMT_YUVA420P \
  328. || (x)==PIX_FMT_YUV411P \
  329. || (x)==PIX_FMT_YUV422P \
  330. || (x)==PIX_FMT_YUV444P \
  331. || (x)==PIX_FMT_YUV440P \
  332. || (x)==PIX_FMT_NV12 \
  333. || (x)==PIX_FMT_NV21 \
  334. )
  335. #define isPlanarYUV(x) ( \
  336. isPlanar8YUV(x) \
  337. || (x)==PIX_FMT_YUV420P9LE \
  338. || (x)==PIX_FMT_YUV420P10LE \
  339. || (x)==PIX_FMT_YUV420P16LE \
  340. || (x)==PIX_FMT_YUV422P16LE \
  341. || (x)==PIX_FMT_YUV444P16LE \
  342. || (x)==PIX_FMT_YUV420P9BE \
  343. || (x)==PIX_FMT_YUV420P10BE \
  344. || (x)==PIX_FMT_YUV420P16BE \
  345. || (x)==PIX_FMT_YUV422P16BE \
  346. || (x)==PIX_FMT_YUV444P16BE \
  347. )
  348. #define isYUV(x) ( \
  349. (x)==PIX_FMT_UYVY422 \
  350. || (x)==PIX_FMT_YUYV422 \
  351. || isPlanarYUV(x) \
  352. )
  353. #define isGray(x) ( \
  354. (x)==PIX_FMT_GRAY8 \
  355. || (x)==PIX_FMT_Y400A \
  356. || (x)==PIX_FMT_GRAY16BE \
  357. || (x)==PIX_FMT_GRAY16LE \
  358. )
  359. #define isGray16(x) ( \
  360. (x)==PIX_FMT_GRAY16BE \
  361. || (x)==PIX_FMT_GRAY16LE \
  362. )
  363. #define isRGBinInt(x) ( \
  364. (x)==PIX_FMT_RGB48BE \
  365. || (x)==PIX_FMT_RGB48LE \
  366. || (x)==PIX_FMT_RGB32 \
  367. || (x)==PIX_FMT_RGB32_1 \
  368. || (x)==PIX_FMT_RGB24 \
  369. || (x)==PIX_FMT_RGB565BE \
  370. || (x)==PIX_FMT_RGB565LE \
  371. || (x)==PIX_FMT_RGB555BE \
  372. || (x)==PIX_FMT_RGB555LE \
  373. || (x)==PIX_FMT_RGB444BE \
  374. || (x)==PIX_FMT_RGB444LE \
  375. || (x)==PIX_FMT_RGB8 \
  376. || (x)==PIX_FMT_RGB4 \
  377. || (x)==PIX_FMT_RGB4_BYTE \
  378. || (x)==PIX_FMT_MONOBLACK \
  379. || (x)==PIX_FMT_MONOWHITE \
  380. )
  381. #define isBGRinInt(x) ( \
  382. (x)==PIX_FMT_BGR48BE \
  383. || (x)==PIX_FMT_BGR48LE \
  384. || (x)==PIX_FMT_BGR32 \
  385. || (x)==PIX_FMT_BGR32_1 \
  386. || (x)==PIX_FMT_BGR24 \
  387. || (x)==PIX_FMT_BGR565BE \
  388. || (x)==PIX_FMT_BGR565LE \
  389. || (x)==PIX_FMT_BGR555BE \
  390. || (x)==PIX_FMT_BGR555LE \
  391. || (x)==PIX_FMT_BGR444BE \
  392. || (x)==PIX_FMT_BGR444LE \
  393. || (x)==PIX_FMT_BGR8 \
  394. || (x)==PIX_FMT_BGR4 \
  395. || (x)==PIX_FMT_BGR4_BYTE \
  396. || (x)==PIX_FMT_MONOBLACK \
  397. || (x)==PIX_FMT_MONOWHITE \
  398. )
  399. #define isRGBinBytes(x) ( \
  400. (x)==PIX_FMT_RGB48BE \
  401. || (x)==PIX_FMT_RGB48LE \
  402. || (x)==PIX_FMT_RGBA \
  403. || (x)==PIX_FMT_ARGB \
  404. || (x)==PIX_FMT_RGB24 \
  405. )
  406. #define isBGRinBytes(x) ( \
  407. (x)==PIX_FMT_BGR48BE \
  408. || (x)==PIX_FMT_BGR48LE \
  409. || (x)==PIX_FMT_BGRA \
  410. || (x)==PIX_FMT_ABGR \
  411. || (x)==PIX_FMT_BGR24 \
  412. )
  413. #define isAnyRGB(x) ( \
  414. isRGBinInt(x) \
  415. || isBGRinInt(x) \
  416. )
  417. #define isALPHA(x) ( \
  418. (x)==PIX_FMT_BGR32 \
  419. || (x)==PIX_FMT_BGR32_1 \
  420. || (x)==PIX_FMT_RGB32 \
  421. || (x)==PIX_FMT_RGB32_1 \
  422. || (x)==PIX_FMT_Y400A \
  423. || (x)==PIX_FMT_YUVA420P \
  424. )
  425. #define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_Y400A)
  426. extern const uint64_t ff_dither4[2];
  427. extern const uint64_t ff_dither8[2];
  428. extern const AVClass sws_context_class;
  429. /**
  430. * Sets c->swScale to an unscaled converter if one exists for the specific
  431. * source and destination formats, bit depths, flags, etc.
  432. */
  433. void ff_get_unscaled_swscale(SwsContext *c);
  434. /**
  435. * Returns function pointer to fastest main scaler path function depending
  436. * on architecture and available optimizations.
  437. */
  438. SwsFunc ff_getSwsFunc(SwsContext *c);
  439. #endif /* SWSCALE_SWSCALE_INTERNAL_H */