swscale_internal.h 23 KB

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