swscale_internal.h 20 KB

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