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.

524 lines
23KB

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