swscale_internal.h 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. /*
  2. * Copyright (C) 2001-2011 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 "version.h"
  27. #include "libavutil/avassert.h"
  28. #include "libavutil/avutil.h"
  29. #include "libavutil/common.h"
  30. #include "libavutil/intreadwrite.h"
  31. #include "libavutil/log.h"
  32. #include "libavutil/pixfmt.h"
  33. #include "libavutil/pixdesc.h"
  34. #define STR(s) AV_TOSTRING(s) // AV_STRINGIFY is too long
  35. #define YUVRGB_TABLE_HEADROOM 512
  36. #define YUVRGB_TABLE_LUMA_HEADROOM 512
  37. #define MAX_FILTER_SIZE SWS_MAX_FILTER_SIZE
  38. #define DITHER1XBPP
  39. #if HAVE_BIGENDIAN
  40. #define ALT32_CORR (-1)
  41. #else
  42. #define ALT32_CORR 1
  43. #endif
  44. #if ARCH_X86_64
  45. # define APCK_PTR2 8
  46. # define APCK_COEF 16
  47. # define APCK_SIZE 24
  48. #else
  49. # define APCK_PTR2 4
  50. # define APCK_COEF 8
  51. # define APCK_SIZE 16
  52. #endif
  53. #define RETCODE_USE_CASCADE -12345
  54. struct SwsContext;
  55. typedef enum SwsDither {
  56. SWS_DITHER_NONE = 0,
  57. SWS_DITHER_AUTO,
  58. SWS_DITHER_BAYER,
  59. SWS_DITHER_ED,
  60. SWS_DITHER_A_DITHER,
  61. SWS_DITHER_X_DITHER,
  62. NB_SWS_DITHER,
  63. } SwsDither;
  64. typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t *src[],
  65. int srcStride[], int srcSliceY, int srcSliceH,
  66. uint8_t *dst[], int dstStride[]);
  67. /**
  68. * Write one line of horizontally scaled data to planar output
  69. * without any additional vertical scaling (or point-scaling).
  70. *
  71. * @param src scaled source data, 15bit for 8-10bit output,
  72. * 19-bit for 16bit output (in int32_t)
  73. * @param dest pointer to the output plane. For >8bit
  74. * output, this is in uint16_t
  75. * @param dstW width of destination in pixels
  76. * @param dither ordered dither array of type int16_t and size 8
  77. * @param offset Dither offset
  78. */
  79. typedef void (*yuv2planar1_fn)(const int16_t *src, uint8_t *dest, int dstW,
  80. const uint8_t *dither, int offset);
  81. /**
  82. * Write one line of horizontally scaled data to planar output
  83. * with multi-point vertical scaling between input pixels.
  84. *
  85. * @param filter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  86. * @param src scaled luma (Y) or alpha (A) source data, 15bit for 8-10bit output,
  87. * 19-bit for 16bit output (in int32_t)
  88. * @param filterSize number of vertical input lines to scale
  89. * @param dest pointer to output plane. For >8bit
  90. * output, this is in uint16_t
  91. * @param dstW width of destination pixels
  92. * @param offset Dither offset
  93. */
  94. typedef void (*yuv2planarX_fn)(const int16_t *filter, int filterSize,
  95. const int16_t **src, uint8_t *dest, int dstW,
  96. const uint8_t *dither, int offset);
  97. /**
  98. * Write one line of horizontally scaled chroma to interleaved output
  99. * with multi-point vertical scaling between input pixels.
  100. *
  101. * @param c SWS scaling context
  102. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  103. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  104. * 19-bit for 16bit output (in int32_t)
  105. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  106. * 19-bit for 16bit output (in int32_t)
  107. * @param chrFilterSize number of vertical chroma input lines to scale
  108. * @param dest pointer to the output plane. For >8bit
  109. * output, this is in uint16_t
  110. * @param dstW width of chroma planes
  111. */
  112. typedef void (*yuv2interleavedX_fn)(struct SwsContext *c,
  113. const int16_t *chrFilter,
  114. int chrFilterSize,
  115. const int16_t **chrUSrc,
  116. const int16_t **chrVSrc,
  117. uint8_t *dest, int dstW);
  118. /**
  119. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  120. * output without any additional vertical scaling (or point-scaling). Note
  121. * that this function may do chroma scaling, see the "uvalpha" argument.
  122. *
  123. * @param c SWS scaling context
  124. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  125. * 19-bit for 16bit output (in int32_t)
  126. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  127. * 19-bit for 16bit output (in int32_t)
  128. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  129. * 19-bit for 16bit output (in int32_t)
  130. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  131. * 19-bit for 16bit output (in int32_t)
  132. * @param dest pointer to the output plane. For 16bit output, this is
  133. * uint16_t
  134. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  135. * to write into dest[]
  136. * @param uvalpha chroma scaling coefficient for the second line of chroma
  137. * pixels, either 2048 or 0. If 0, one chroma input is used
  138. * for 2 output pixels (or if the SWS_FLAG_FULL_CHR_INT flag
  139. * is set, it generates 1 output pixel). If 2048, two chroma
  140. * input pixels should be averaged for 2 output pixels (this
  141. * only happens if SWS_FLAG_FULL_CHR_INT is not set)
  142. * @param y vertical line number for this output. This does not need
  143. * to be used to calculate the offset in the destination,
  144. * but can be used to generate comfort noise using dithering
  145. * for some output formats.
  146. */
  147. typedef void (*yuv2packed1_fn)(struct SwsContext *c, const int16_t *lumSrc,
  148. const int16_t *chrUSrc[2],
  149. const int16_t *chrVSrc[2],
  150. const int16_t *alpSrc, uint8_t *dest,
  151. int dstW, int uvalpha, int y);
  152. /**
  153. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  154. * output by doing bilinear scaling between two input lines.
  155. *
  156. * @param c SWS scaling context
  157. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  158. * 19-bit for 16bit output (in int32_t)
  159. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  160. * 19-bit for 16bit output (in int32_t)
  161. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  162. * 19-bit for 16bit output (in int32_t)
  163. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  164. * 19-bit for 16bit output (in int32_t)
  165. * @param dest pointer to the output plane. For 16bit output, this is
  166. * uint16_t
  167. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  168. * to write into dest[]
  169. * @param yalpha luma/alpha scaling coefficients for the second input line.
  170. * The first line's coefficients can be calculated by using
  171. * 4096 - yalpha
  172. * @param uvalpha chroma scaling coefficient for the second input line. The
  173. * first line's coefficients can be calculated by using
  174. * 4096 - uvalpha
  175. * @param y vertical line number for this output. This does not need
  176. * to be used to calculate the offset in the destination,
  177. * but can be used to generate comfort noise using dithering
  178. * for some output formats.
  179. */
  180. typedef void (*yuv2packed2_fn)(struct SwsContext *c, const int16_t *lumSrc[2],
  181. const int16_t *chrUSrc[2],
  182. const int16_t *chrVSrc[2],
  183. const int16_t *alpSrc[2],
  184. uint8_t *dest,
  185. int dstW, int yalpha, int uvalpha, int y);
  186. /**
  187. * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB
  188. * output by doing multi-point vertical scaling between input pixels.
  189. *
  190. * @param c SWS scaling context
  191. * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  192. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  193. * 19-bit for 16bit output (in int32_t)
  194. * @param lumFilterSize number of vertical luma/alpha input lines to scale
  195. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  196. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  197. * 19-bit for 16bit output (in int32_t)
  198. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  199. * 19-bit for 16bit output (in int32_t)
  200. * @param chrFilterSize number of vertical chroma input lines to scale
  201. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  202. * 19-bit for 16bit output (in int32_t)
  203. * @param dest pointer to the output plane. For 16bit output, this is
  204. * uint16_t
  205. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  206. * to write into dest[]
  207. * @param y vertical line number for this output. This does not need
  208. * to be used to calculate the offset in the destination,
  209. * but can be used to generate comfort noise using dithering
  210. * or some output formats.
  211. */
  212. typedef void (*yuv2packedX_fn)(struct SwsContext *c, const int16_t *lumFilter,
  213. const int16_t **lumSrc, int lumFilterSize,
  214. const int16_t *chrFilter,
  215. const int16_t **chrUSrc,
  216. const int16_t **chrVSrc, int chrFilterSize,
  217. const int16_t **alpSrc, uint8_t *dest,
  218. int dstW, int y);
  219. /**
  220. * Write one line of horizontally scaled Y/U/V/A to YUV/RGB
  221. * output by doing multi-point vertical scaling between input pixels.
  222. *
  223. * @param c SWS scaling context
  224. * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096]
  225. * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output,
  226. * 19-bit for 16bit output (in int32_t)
  227. * @param lumFilterSize number of vertical luma/alpha input lines to scale
  228. * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096]
  229. * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output,
  230. * 19-bit for 16bit output (in int32_t)
  231. * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output,
  232. * 19-bit for 16bit output (in int32_t)
  233. * @param chrFilterSize number of vertical chroma input lines to scale
  234. * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output,
  235. * 19-bit for 16bit output (in int32_t)
  236. * @param dest pointer to the output planes. For 16bit output, this is
  237. * uint16_t
  238. * @param dstW width of lumSrc and alpSrc in pixels, number of pixels
  239. * to write into dest[]
  240. * @param y vertical line number for this output. This does not need
  241. * to be used to calculate the offset in the destination,
  242. * but can be used to generate comfort noise using dithering
  243. * or some output formats.
  244. */
  245. typedef void (*yuv2anyX_fn)(struct SwsContext *c, const int16_t *lumFilter,
  246. const int16_t **lumSrc, int lumFilterSize,
  247. const int16_t *chrFilter,
  248. const int16_t **chrUSrc,
  249. const int16_t **chrVSrc, int chrFilterSize,
  250. const int16_t **alpSrc, uint8_t **dest,
  251. int dstW, int y);
  252. /* This struct should be aligned on at least a 32-byte boundary. */
  253. typedef struct SwsContext {
  254. /**
  255. * info on struct for av_log
  256. */
  257. const AVClass *av_class;
  258. /**
  259. * Note that src, dst, srcStride, dstStride will be copied in the
  260. * sws_scale() wrapper so they can be freely modified here.
  261. */
  262. SwsFunc swscale;
  263. int srcW; ///< Width of source luma/alpha planes.
  264. int srcH; ///< Height of source luma/alpha planes.
  265. int dstH; ///< Height of destination luma/alpha planes.
  266. int chrSrcW; ///< Width of source chroma planes.
  267. int chrSrcH; ///< Height of source chroma planes.
  268. int chrDstW; ///< Width of destination chroma planes.
  269. int chrDstH; ///< Height of destination chroma planes.
  270. int lumXInc, chrXInc;
  271. int lumYInc, chrYInc;
  272. enum AVPixelFormat dstFormat; ///< Destination pixel format.
  273. enum AVPixelFormat srcFormat; ///< Source pixel format.
  274. int dstFormatBpp; ///< Number of bits per pixel of the destination pixel format.
  275. int srcFormatBpp; ///< Number of bits per pixel of the source pixel format.
  276. int dstBpc, srcBpc;
  277. int chrSrcHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in source image.
  278. int chrSrcVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in source image.
  279. int chrDstHSubSample; ///< Binary logarithm of horizontal subsampling factor between luma/alpha and chroma planes in destination image.
  280. int chrDstVSubSample; ///< Binary logarithm of vertical subsampling factor between luma/alpha and chroma planes in destination image.
  281. int vChrDrop; ///< Binary logarithm of extra vertical subsampling factor in source image chroma planes specified by user.
  282. int sliceDir; ///< Direction that slices are fed to the scaler (1 = top-to-bottom, -1 = bottom-to-top).
  283. double param[2]; ///< Input parameters for scaling algorithms that need them.
  284. /* The cascaded_* fields allow spliting a scaler task into multiple
  285. * sequential steps, this is for example used to limit the maximum
  286. * downscaling factor that needs to be supported in one scaler.
  287. */
  288. struct SwsContext *cascaded_context[2];
  289. int cascaded_tmpStride[4];
  290. uint8_t *cascaded_tmp[4];
  291. uint32_t pal_yuv[256];
  292. uint32_t pal_rgb[256];
  293. /**
  294. * @name Scaled horizontal lines ring buffer.
  295. * The horizontal scaler keeps just enough scaled lines in a ring buffer
  296. * so they may be passed to the vertical scaler. The pointers to the
  297. * allocated buffers for each line are duplicated in sequence in the ring
  298. * buffer to simplify indexing and avoid wrapping around between lines
  299. * inside the vertical scaler code. The wrapping is done before the
  300. * vertical scaler is called.
  301. */
  302. //@{
  303. int16_t **lumPixBuf; ///< Ring buffer for scaled horizontal luma plane lines to be fed to the vertical scaler.
  304. int16_t **chrUPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
  305. int16_t **chrVPixBuf; ///< Ring buffer for scaled horizontal chroma plane lines to be fed to the vertical scaler.
  306. int16_t **alpPixBuf; ///< Ring buffer for scaled horizontal alpha plane lines to be fed to the vertical scaler.
  307. int vLumBufSize; ///< Number of vertical luma/alpha lines allocated in the ring buffer.
  308. int vChrBufSize; ///< Number of vertical chroma lines allocated in the ring buffer.
  309. int lastInLumBuf; ///< Last scaled horizontal luma/alpha line from source in the ring buffer.
  310. int lastInChrBuf; ///< Last scaled horizontal chroma line from source in the ring buffer.
  311. int lumBufIndex; ///< Index in ring buffer of the last scaled horizontal luma/alpha line from source.
  312. int chrBufIndex; ///< Index in ring buffer of the last scaled horizontal chroma line from source.
  313. //@}
  314. uint8_t *formatConvBuffer;
  315. /**
  316. * @name Horizontal and vertical filters.
  317. * To better understand the following fields, here is a pseudo-code of
  318. * their usage in filtering a horizontal line:
  319. * @code
  320. * for (i = 0; i < width; i++) {
  321. * dst[i] = 0;
  322. * for (j = 0; j < filterSize; j++)
  323. * dst[i] += src[ filterPos[i] + j ] * filter[ filterSize * i + j ];
  324. * dst[i] >>= FRAC_BITS; // The actual implementation is fixed-point.
  325. * }
  326. * @endcode
  327. */
  328. //@{
  329. int16_t *hLumFilter; ///< Array of horizontal filter coefficients for luma/alpha planes.
  330. int16_t *hChrFilter; ///< Array of horizontal filter coefficients for chroma planes.
  331. int16_t *vLumFilter; ///< Array of vertical filter coefficients for luma/alpha planes.
  332. int16_t *vChrFilter; ///< Array of vertical filter coefficients for chroma planes.
  333. int32_t *hLumFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for luma/alpha planes.
  334. int32_t *hChrFilterPos; ///< Array of horizontal filter starting positions for each dst[i] for chroma planes.
  335. int32_t *vLumFilterPos; ///< Array of vertical filter starting positions for each dst[i] for luma/alpha planes.
  336. int32_t *vChrFilterPos; ///< Array of vertical filter starting positions for each dst[i] for chroma planes.
  337. int hLumFilterSize; ///< Horizontal filter size for luma/alpha pixels.
  338. int hChrFilterSize; ///< Horizontal filter size for chroma pixels.
  339. int vLumFilterSize; ///< Vertical filter size for luma/alpha pixels.
  340. int vChrFilterSize; ///< Vertical filter size for chroma pixels.
  341. //@}
  342. int lumMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for luma/alpha planes.
  343. int chrMmxextFilterCodeSize; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code size for chroma planes.
  344. uint8_t *lumMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for luma/alpha planes.
  345. uint8_t *chrMmxextFilterCode; ///< Runtime-generated MMXEXT horizontal fast bilinear scaler code for chroma planes.
  346. int canMMXEXTBeUsed;
  347. int dstY; ///< Last destination vertical line output from last slice.
  348. int flags; ///< Flags passed by the user to select scaler algorithm, optimizations, subsampling, etc...
  349. void *yuvTable; // pointer to the yuv->rgb table start so it can be freed()
  350. // alignment ensures the offset can be added in a single
  351. // instruction on e.g. ARM
  352. DECLARE_ALIGNED(16, int, table_gV)[256 + 2*YUVRGB_TABLE_HEADROOM];
  353. uint8_t *table_rV[256 + 2*YUVRGB_TABLE_HEADROOM];
  354. uint8_t *table_gU[256 + 2*YUVRGB_TABLE_HEADROOM];
  355. uint8_t *table_bU[256 + 2*YUVRGB_TABLE_HEADROOM];
  356. DECLARE_ALIGNED(16, int32_t, input_rgb2yuv_table)[16+40*4]; // This table can contain both C and SIMD formatted values, the C vales are always at the XY_IDX points
  357. #define RY_IDX 0
  358. #define GY_IDX 1
  359. #define BY_IDX 2
  360. #define RU_IDX 3
  361. #define GU_IDX 4
  362. #define BU_IDX 5
  363. #define RV_IDX 6
  364. #define GV_IDX 7
  365. #define BV_IDX 8
  366. #define RGB2YUV_SHIFT 15
  367. int *dither_error[4];
  368. //Colorspace stuff
  369. int contrast, brightness, saturation; // for sws_getColorspaceDetails
  370. int srcColorspaceTable[4];
  371. int dstColorspaceTable[4];
  372. int srcRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (source image).
  373. int dstRange; ///< 0 = MPG YUV range, 1 = JPG YUV range (destination image).
  374. int src0Alpha;
  375. int dst0Alpha;
  376. int srcXYZ;
  377. int dstXYZ;
  378. int src_h_chr_pos;
  379. int dst_h_chr_pos;
  380. int src_v_chr_pos;
  381. int dst_v_chr_pos;
  382. int yuv2rgb_y_offset;
  383. int yuv2rgb_y_coeff;
  384. int yuv2rgb_v2r_coeff;
  385. int yuv2rgb_v2g_coeff;
  386. int yuv2rgb_u2g_coeff;
  387. int yuv2rgb_u2b_coeff;
  388. #define RED_DITHER "0*8"
  389. #define GREEN_DITHER "1*8"
  390. #define BLUE_DITHER "2*8"
  391. #define Y_COEFF "3*8"
  392. #define VR_COEFF "4*8"
  393. #define UB_COEFF "5*8"
  394. #define VG_COEFF "6*8"
  395. #define UG_COEFF "7*8"
  396. #define Y_OFFSET "8*8"
  397. #define U_OFFSET "9*8"
  398. #define V_OFFSET "10*8"
  399. #define LUM_MMX_FILTER_OFFSET "11*8"
  400. #define CHR_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)
  401. #define DSTW_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2"
  402. #define ESP_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+8"
  403. #define VROUNDER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+16"
  404. #define U_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+24"
  405. #define V_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+32"
  406. #define Y_TEMP "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+40"
  407. #define ALP_MMX_FILTER_OFFSET "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*2+48"
  408. #define UV_OFF_PX "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+48"
  409. #define UV_OFF_BYTE "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+56"
  410. #define DITHER16 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+64"
  411. #define DITHER32 "11*8+4*4*"AV_STRINGIFY(MAX_FILTER_SIZE)"*3+80"
  412. #define DITHER32_INT (11*8+4*4*MAX_FILTER_SIZE*3+80) // value equal to above, used for checking that the struct hasn't been changed by mistake
  413. DECLARE_ALIGNED(8, uint64_t, redDither);
  414. DECLARE_ALIGNED(8, uint64_t, greenDither);
  415. DECLARE_ALIGNED(8, uint64_t, blueDither);
  416. DECLARE_ALIGNED(8, uint64_t, yCoeff);
  417. DECLARE_ALIGNED(8, uint64_t, vrCoeff);
  418. DECLARE_ALIGNED(8, uint64_t, ubCoeff);
  419. DECLARE_ALIGNED(8, uint64_t, vgCoeff);
  420. DECLARE_ALIGNED(8, uint64_t, ugCoeff);
  421. DECLARE_ALIGNED(8, uint64_t, yOffset);
  422. DECLARE_ALIGNED(8, uint64_t, uOffset);
  423. DECLARE_ALIGNED(8, uint64_t, vOffset);
  424. int32_t lumMmxFilter[4 * MAX_FILTER_SIZE];
  425. int32_t chrMmxFilter[4 * MAX_FILTER_SIZE];
  426. int dstW; ///< Width of destination luma/alpha planes.
  427. DECLARE_ALIGNED(8, uint64_t, esp);
  428. DECLARE_ALIGNED(8, uint64_t, vRounder);
  429. DECLARE_ALIGNED(8, uint64_t, u_temp);
  430. DECLARE_ALIGNED(8, uint64_t, v_temp);
  431. DECLARE_ALIGNED(8, uint64_t, y_temp);
  432. int32_t alpMmxFilter[4 * MAX_FILTER_SIZE];
  433. // alignment of these values is not necessary, but merely here
  434. // to maintain the same offset across x8632 and x86-64. Once we
  435. // use proper offset macros in the asm, they can be removed.
  436. DECLARE_ALIGNED(8, ptrdiff_t, uv_off); ///< offset (in pixels) between u and v planes
  437. DECLARE_ALIGNED(8, ptrdiff_t, uv_offx2); ///< offset (in bytes) between u and v planes
  438. DECLARE_ALIGNED(8, uint16_t, dither16)[8];
  439. DECLARE_ALIGNED(8, uint32_t, dither32)[8];
  440. const uint8_t *chrDither8, *lumDither8;
  441. #if HAVE_ALTIVEC
  442. vector signed short CY;
  443. vector signed short CRV;
  444. vector signed short CBU;
  445. vector signed short CGU;
  446. vector signed short CGV;
  447. vector signed short OY;
  448. vector unsigned short CSHIFT;
  449. vector signed short *vYCoeffsBank, *vCCoeffsBank;
  450. #endif
  451. int use_mmx_vfilter;
  452. /* pre defined color-spaces gamma */
  453. #define XYZ_GAMMA (2.6f)
  454. #define RGB_GAMMA (2.2f)
  455. int16_t *xyzgamma;
  456. int16_t *rgbgamma;
  457. int16_t *xyzgammainv;
  458. int16_t *rgbgammainv;
  459. int16_t xyz2rgb_matrix[3][4];
  460. int16_t rgb2xyz_matrix[3][4];
  461. /* function pointers for swscale() */
  462. yuv2planar1_fn yuv2plane1;
  463. yuv2planarX_fn yuv2planeX;
  464. yuv2interleavedX_fn yuv2nv12cX;
  465. yuv2packed1_fn yuv2packed1;
  466. yuv2packed2_fn yuv2packed2;
  467. yuv2packedX_fn yuv2packedX;
  468. yuv2anyX_fn yuv2anyX;
  469. /// Unscaled conversion of luma plane to YV12 for horizontal scaler.
  470. void (*lumToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
  471. int width, uint32_t *pal);
  472. /// Unscaled conversion of alpha plane to YV12 for horizontal scaler.
  473. void (*alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3,
  474. int width, uint32_t *pal);
  475. /// Unscaled conversion of chroma planes to YV12 for horizontal scaler.
  476. void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV,
  477. const uint8_t *src1, const uint8_t *src2, const uint8_t *src3,
  478. int width, uint32_t *pal);
  479. /**
  480. * Functions to read planar input, such as planar RGB, and convert
  481. * internally to Y/UV/A.
  482. */
  483. /** @{ */
  484. void (*readLumPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
  485. void (*readChrPlanar)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src[4],
  486. int width, int32_t *rgb2yuv);
  487. void (*readAlpPlanar)(uint8_t *dst, const uint8_t *src[4], int width, int32_t *rgb2yuv);
  488. /** @} */
  489. /**
  490. * Scale one horizontal line of input data using a bilinear filter
  491. * to produce one line of output data. Compared to SwsContext->hScale(),
  492. * please take note of the following caveats when using these:
  493. * - Scaling is done using only 7bit instead of 14bit coefficients.
  494. * - You can use no more than 5 input pixels to produce 4 output
  495. * pixels. Therefore, this filter should not be used for downscaling
  496. * by more than ~20% in width (because that equals more than 5/4th
  497. * downscaling and thus more than 5 pixels input per 4 pixels output).
  498. * - In general, bilinear filters create artifacts during downscaling
  499. * (even when <20%), because one output pixel will span more than one
  500. * input pixel, and thus some pixels will need edges of both neighbor
  501. * pixels to interpolate the output pixel. Since you can use at most
  502. * two input pixels per output pixel in bilinear scaling, this is
  503. * impossible and thus downscaling by any size will create artifacts.
  504. * To enable this type of scaling, set SWS_FLAG_FAST_BILINEAR
  505. * in SwsContext->flags.
  506. */
  507. /** @{ */
  508. void (*hyscale_fast)(struct SwsContext *c,
  509. int16_t *dst, int dstWidth,
  510. const uint8_t *src, int srcW, int xInc);
  511. void (*hcscale_fast)(struct SwsContext *c,
  512. int16_t *dst1, int16_t *dst2, int dstWidth,
  513. const uint8_t *src1, const uint8_t *src2,
  514. int srcW, int xInc);
  515. /** @} */
  516. /**
  517. * Scale one horizontal line of input data using a filter over the input
  518. * lines, to produce one (differently sized) line of output data.
  519. *
  520. * @param dst pointer to destination buffer for horizontally scaled
  521. * data. If the number of bits per component of one
  522. * destination pixel (SwsContext->dstBpc) is <= 10, data
  523. * will be 15bpc in 16bits (int16_t) width. Else (i.e.
  524. * SwsContext->dstBpc == 16), data will be 19bpc in
  525. * 32bits (int32_t) width.
  526. * @param dstW width of destination image
  527. * @param src pointer to source data to be scaled. If the number of
  528. * bits per component of a source pixel (SwsContext->srcBpc)
  529. * is 8, this is 8bpc in 8bits (uint8_t) width. Else
  530. * (i.e. SwsContext->dstBpc > 8), this is native depth
  531. * in 16bits (uint16_t) width. In other words, for 9-bit
  532. * YUV input, this is 9bpc, for 10-bit YUV input, this is
  533. * 10bpc, and for 16-bit RGB or YUV, this is 16bpc.
  534. * @param filter filter coefficients to be used per output pixel for
  535. * scaling. This contains 14bpp filtering coefficients.
  536. * Guaranteed to contain dstW * filterSize entries.
  537. * @param filterPos position of the first input pixel to be used for
  538. * each output pixel during scaling. Guaranteed to
  539. * contain dstW entries.
  540. * @param filterSize the number of input coefficients to be used (and
  541. * thus the number of input pixels to be used) for
  542. * creating a single output pixel. Is aligned to 4
  543. * (and input coefficients thus padded with zeroes)
  544. * to simplify creating SIMD code.
  545. */
  546. /** @{ */
  547. void (*hyScale)(struct SwsContext *c, int16_t *dst, int dstW,
  548. const uint8_t *src, const int16_t *filter,
  549. const int32_t *filterPos, int filterSize);
  550. void (*hcScale)(struct SwsContext *c, int16_t *dst, int dstW,
  551. const uint8_t *src, const int16_t *filter,
  552. const int32_t *filterPos, int filterSize);
  553. /** @} */
  554. /// Color range conversion function for luma plane if needed.
  555. void (*lumConvertRange)(int16_t *dst, int width);
  556. /// Color range conversion function for chroma planes if needed.
  557. void (*chrConvertRange)(int16_t *dst1, int16_t *dst2, int width);
  558. int needs_hcscale; ///< Set if there are chroma planes to be converted.
  559. SwsDither dither;
  560. } SwsContext;
  561. //FIXME check init (where 0)
  562. SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
  563. int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4],
  564. int fullRange, int brightness,
  565. int contrast, int saturation);
  566. void ff_yuv2rgb_init_tables_ppc(SwsContext *c, const int inv_table[4],
  567. int brightness, int contrast, int saturation);
  568. void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufIndex,
  569. int lastInLumBuf, int lastInChrBuf);
  570. av_cold void ff_sws_init_range_convert(SwsContext *c);
  571. SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
  572. SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c);
  573. #if FF_API_SWS_FORMAT_NAME
  574. /**
  575. * @deprecated Use av_get_pix_fmt_name() instead.
  576. */
  577. attribute_deprecated
  578. const char *sws_format_name(enum AVPixelFormat format);
  579. #endif
  580. static av_always_inline int is16BPS(enum AVPixelFormat pix_fmt)
  581. {
  582. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  583. av_assert0(desc);
  584. return desc->comp[0].depth_minus1 == 15;
  585. }
  586. static av_always_inline int is9_OR_10BPS(enum AVPixelFormat pix_fmt)
  587. {
  588. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  589. av_assert0(desc);
  590. return desc->comp[0].depth_minus1 >= 8 && desc->comp[0].depth_minus1 <= 13;
  591. }
  592. #define isNBPS(x) is9_OR_10BPS(x)
  593. static av_always_inline int isBE(enum AVPixelFormat pix_fmt)
  594. {
  595. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  596. av_assert0(desc);
  597. return desc->flags & AV_PIX_FMT_FLAG_BE;
  598. }
  599. static av_always_inline int isYUV(enum AVPixelFormat pix_fmt)
  600. {
  601. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  602. av_assert0(desc);
  603. return !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
  604. }
  605. static av_always_inline int isPlanarYUV(enum AVPixelFormat pix_fmt)
  606. {
  607. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  608. av_assert0(desc);
  609. return ((desc->flags & AV_PIX_FMT_FLAG_PLANAR) && isYUV(pix_fmt));
  610. }
  611. static av_always_inline int isRGB(enum AVPixelFormat pix_fmt)
  612. {
  613. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  614. av_assert0(desc);
  615. return (desc->flags & AV_PIX_FMT_FLAG_RGB);
  616. }
  617. #if 0 // FIXME
  618. #define isGray(x) \
  619. (!(av_pix_fmt_desc_get(x)->flags & AV_PIX_FMT_FLAG_PAL) && \
  620. av_pix_fmt_desc_get(x)->nb_components <= 2)
  621. #else
  622. #define isGray(x) \
  623. ((x) == AV_PIX_FMT_GRAY8 || \
  624. (x) == AV_PIX_FMT_YA8 || \
  625. (x) == AV_PIX_FMT_GRAY16BE || \
  626. (x) == AV_PIX_FMT_GRAY16LE || \
  627. (x) == AV_PIX_FMT_YA16BE || \
  628. (x) == AV_PIX_FMT_YA16LE)
  629. #endif
  630. #define isRGBinInt(x) \
  631. ( \
  632. (x) == AV_PIX_FMT_RGB48BE || \
  633. (x) == AV_PIX_FMT_RGB48LE || \
  634. (x) == AV_PIX_FMT_RGB32 || \
  635. (x) == AV_PIX_FMT_RGB32_1 || \
  636. (x) == AV_PIX_FMT_RGB24 || \
  637. (x) == AV_PIX_FMT_RGB565BE || \
  638. (x) == AV_PIX_FMT_RGB565LE || \
  639. (x) == AV_PIX_FMT_RGB555BE || \
  640. (x) == AV_PIX_FMT_RGB555LE || \
  641. (x) == AV_PIX_FMT_RGB444BE || \
  642. (x) == AV_PIX_FMT_RGB444LE || \
  643. (x) == AV_PIX_FMT_RGB8 || \
  644. (x) == AV_PIX_FMT_RGB4 || \
  645. (x) == AV_PIX_FMT_RGB4_BYTE || \
  646. (x) == AV_PIX_FMT_RGBA64BE || \
  647. (x) == AV_PIX_FMT_RGBA64LE || \
  648. (x) == AV_PIX_FMT_MONOBLACK || \
  649. (x) == AV_PIX_FMT_MONOWHITE \
  650. )
  651. #define isBGRinInt(x) \
  652. ( \
  653. (x) == AV_PIX_FMT_BGR48BE || \
  654. (x) == AV_PIX_FMT_BGR48LE || \
  655. (x) == AV_PIX_FMT_BGR32 || \
  656. (x) == AV_PIX_FMT_BGR32_1 || \
  657. (x) == AV_PIX_FMT_BGR24 || \
  658. (x) == AV_PIX_FMT_BGR565BE || \
  659. (x) == AV_PIX_FMT_BGR565LE || \
  660. (x) == AV_PIX_FMT_BGR555BE || \
  661. (x) == AV_PIX_FMT_BGR555LE || \
  662. (x) == AV_PIX_FMT_BGR444BE || \
  663. (x) == AV_PIX_FMT_BGR444LE || \
  664. (x) == AV_PIX_FMT_BGR8 || \
  665. (x) == AV_PIX_FMT_BGR4 || \
  666. (x) == AV_PIX_FMT_BGR4_BYTE || \
  667. (x) == AV_PIX_FMT_BGRA64BE || \
  668. (x) == AV_PIX_FMT_BGRA64LE || \
  669. (x) == AV_PIX_FMT_MONOBLACK || \
  670. (x) == AV_PIX_FMT_MONOWHITE \
  671. )
  672. #define isRGBinBytes(x) ( \
  673. (x) == AV_PIX_FMT_RGB48BE \
  674. || (x) == AV_PIX_FMT_RGB48LE \
  675. || (x) == AV_PIX_FMT_RGBA64BE \
  676. || (x) == AV_PIX_FMT_RGBA64LE \
  677. || (x) == AV_PIX_FMT_RGBA \
  678. || (x) == AV_PIX_FMT_ARGB \
  679. || (x) == AV_PIX_FMT_RGB24 \
  680. )
  681. #define isBGRinBytes(x) ( \
  682. (x) == AV_PIX_FMT_BGR48BE \
  683. || (x) == AV_PIX_FMT_BGR48LE \
  684. || (x) == AV_PIX_FMT_BGRA64BE \
  685. || (x) == AV_PIX_FMT_BGRA64LE \
  686. || (x) == AV_PIX_FMT_BGRA \
  687. || (x) == AV_PIX_FMT_ABGR \
  688. || (x) == AV_PIX_FMT_BGR24 \
  689. )
  690. #define isBayer(x) ( \
  691. (x)==AV_PIX_FMT_BAYER_BGGR8 \
  692. || (x)==AV_PIX_FMT_BAYER_BGGR16LE \
  693. || (x)==AV_PIX_FMT_BAYER_BGGR16BE \
  694. || (x)==AV_PIX_FMT_BAYER_RGGB8 \
  695. || (x)==AV_PIX_FMT_BAYER_RGGB16LE \
  696. || (x)==AV_PIX_FMT_BAYER_RGGB16BE \
  697. || (x)==AV_PIX_FMT_BAYER_GBRG8 \
  698. || (x)==AV_PIX_FMT_BAYER_GBRG16LE \
  699. || (x)==AV_PIX_FMT_BAYER_GBRG16BE \
  700. || (x)==AV_PIX_FMT_BAYER_GRBG8 \
  701. || (x)==AV_PIX_FMT_BAYER_GRBG16LE \
  702. || (x)==AV_PIX_FMT_BAYER_GRBG16BE \
  703. )
  704. #define isAnyRGB(x) \
  705. ( \
  706. isBayer(x) || \
  707. isRGBinInt(x) || \
  708. isBGRinInt(x) || \
  709. isRGB(x) \
  710. )
  711. static av_always_inline int isALPHA(enum AVPixelFormat pix_fmt)
  712. {
  713. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  714. av_assert0(desc);
  715. if (pix_fmt == AV_PIX_FMT_PAL8)
  716. return 1;
  717. return desc->flags & AV_PIX_FMT_FLAG_ALPHA;
  718. }
  719. #if 1
  720. #define isPacked(x) ( \
  721. (x)==AV_PIX_FMT_PAL8 \
  722. || (x)==AV_PIX_FMT_YUYV422 \
  723. || (x)==AV_PIX_FMT_YVYU422 \
  724. || (x)==AV_PIX_FMT_UYVY422 \
  725. || (x)==AV_PIX_FMT_YA8 \
  726. || (x)==AV_PIX_FMT_YA16LE \
  727. || (x)==AV_PIX_FMT_YA16BE \
  728. || isRGBinInt(x) \
  729. || isBGRinInt(x) \
  730. )
  731. #else
  732. static av_always_inline int isPacked(enum AVPixelFormat pix_fmt)
  733. {
  734. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  735. av_assert0(desc);
  736. return ((desc->nb_components >= 2 && !(desc->flags & AV_PIX_FMT_FLAG_PLANAR)) ||
  737. pix_fmt == AV_PIX_FMT_PAL8);
  738. }
  739. #endif
  740. static av_always_inline int isPlanar(enum AVPixelFormat pix_fmt)
  741. {
  742. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  743. av_assert0(desc);
  744. return (desc->nb_components >= 2 && (desc->flags & AV_PIX_FMT_FLAG_PLANAR));
  745. }
  746. static av_always_inline int isPackedRGB(enum AVPixelFormat pix_fmt)
  747. {
  748. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  749. av_assert0(desc);
  750. return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) == AV_PIX_FMT_FLAG_RGB);
  751. }
  752. static av_always_inline int isPlanarRGB(enum AVPixelFormat pix_fmt)
  753. {
  754. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  755. av_assert0(desc);
  756. return ((desc->flags & (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB)) ==
  757. (AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB));
  758. }
  759. static av_always_inline int usePal(enum AVPixelFormat pix_fmt)
  760. {
  761. const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
  762. av_assert0(desc);
  763. return (desc->flags & AV_PIX_FMT_FLAG_PAL) || (desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL);
  764. }
  765. extern const uint64_t ff_dither4[2];
  766. extern const uint64_t ff_dither8[2];
  767. extern const uint8_t ff_dither_2x2_4[3][8];
  768. extern const uint8_t ff_dither_2x2_8[3][8];
  769. extern const uint8_t ff_dither_4x4_16[5][8];
  770. extern const uint8_t ff_dither_8x8_32[9][8];
  771. extern const uint8_t ff_dither_8x8_73[9][8];
  772. extern const uint8_t ff_dither_8x8_128[9][8];
  773. extern const uint8_t ff_dither_8x8_220[9][8];
  774. extern const int32_t ff_yuv2rgb_coeffs[8][4];
  775. extern const AVClass sws_context_class;
  776. /**
  777. * Set c->swscale to an unscaled converter if one exists for the specific
  778. * source and destination formats, bit depths, flags, etc.
  779. */
  780. void ff_get_unscaled_swscale(SwsContext *c);
  781. void ff_get_unscaled_swscale_ppc(SwsContext *c);
  782. void ff_get_unscaled_swscale_arm(SwsContext *c);
  783. /**
  784. * Return function pointer to fastest main scaler path function depending
  785. * on architecture and available optimizations.
  786. */
  787. SwsFunc ff_getSwsFunc(SwsContext *c);
  788. void ff_sws_init_input_funcs(SwsContext *c);
  789. void ff_sws_init_output_funcs(SwsContext *c,
  790. yuv2planar1_fn *yuv2plane1,
  791. yuv2planarX_fn *yuv2planeX,
  792. yuv2interleavedX_fn *yuv2nv12cX,
  793. yuv2packed1_fn *yuv2packed1,
  794. yuv2packed2_fn *yuv2packed2,
  795. yuv2packedX_fn *yuv2packedX,
  796. yuv2anyX_fn *yuv2anyX);
  797. void ff_sws_init_swscale_ppc(SwsContext *c);
  798. void ff_sws_init_swscale_x86(SwsContext *c);
  799. void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
  800. const uint8_t *src, int srcW, int xInc);
  801. void ff_hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
  802. int dstWidth, const uint8_t *src1,
  803. const uint8_t *src2, int srcW, int xInc);
  804. int ff_init_hscaler_mmxext(int dstW, int xInc, uint8_t *filterCode,
  805. int16_t *filter, int32_t *filterPos,
  806. int numSplits);
  807. void ff_hyscale_fast_mmxext(SwsContext *c, int16_t *dst,
  808. int dstWidth, const uint8_t *src,
  809. int srcW, int xInc);
  810. void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
  811. int dstWidth, const uint8_t *src1,
  812. const uint8_t *src2, int srcW, int xInc);
  813. static inline void fillPlane16(uint8_t *plane, int stride, int width, int height, int y,
  814. int alpha, int bits, const int big_endian)
  815. {
  816. int i, j;
  817. uint8_t *ptr = plane + stride * y;
  818. int v = alpha ? 0xFFFF>>(15-bits) : (1<<bits);
  819. for (i = 0; i < height; i++) {
  820. #define FILL(wfunc) \
  821. for (j = 0; j < width; j++) {\
  822. wfunc(ptr+2*j, v);\
  823. }
  824. if (big_endian) {
  825. FILL(AV_WB16);
  826. } else {
  827. FILL(AV_WL16);
  828. }
  829. ptr += stride;
  830. }
  831. }
  832. #endif /* SWSCALE_SWSCALE_INTERNAL_H */