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.

507 lines
22KB

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