planar_functions.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882
  1. /*
  2. * Copyright 2011 The LibYuv Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
  11. #define INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_
  12. #include "libyuv/basic_types.h"
  13. // TODO(fbarchard): Remove the following headers includes.
  14. #include "libyuv/convert.h"
  15. #include "libyuv/convert_argb.h"
  16. #ifdef __cplusplus
  17. namespace libyuv {
  18. extern "C" {
  19. #endif
  20. // TODO(fbarchard): Move cpu macros to row.h
  21. #if defined(__pnacl__) || defined(__CLR_VER) || \
  22. (defined(__native_client__) && defined(__x86_64__)) || \
  23. (defined(__i386__) && !defined(__SSE__) && !defined(__clang__))
  24. #define LIBYUV_DISABLE_X86
  25. #endif
  26. // MemorySanitizer does not support assembly code yet. http://crbug.com/344505
  27. #if defined(__has_feature)
  28. #if __has_feature(memory_sanitizer)
  29. #define LIBYUV_DISABLE_X86
  30. #endif
  31. #endif
  32. // The following are available on all x86 platforms:
  33. #if !defined(LIBYUV_DISABLE_X86) && \
  34. (defined(_M_IX86) || defined(__x86_64__) || defined(__i386__))
  35. #define HAS_ARGBAFFINEROW_SSE2
  36. #endif
  37. // Copy a plane of data.
  38. LIBYUV_API
  39. void CopyPlane(const uint8_t* src_y,
  40. int src_stride_y,
  41. uint8_t* dst_y,
  42. int dst_stride_y,
  43. int width,
  44. int height);
  45. LIBYUV_API
  46. void CopyPlane_16(const uint16_t* src_y,
  47. int src_stride_y,
  48. uint16_t* dst_y,
  49. int dst_stride_y,
  50. int width,
  51. int height);
  52. LIBYUV_API
  53. void Convert16To8Plane(const uint16_t* src_y,
  54. int src_stride_y,
  55. uint8_t* dst_y,
  56. int dst_stride_y,
  57. int scale, // 16384 for 10 bits
  58. int width,
  59. int height);
  60. LIBYUV_API
  61. void Convert8To16Plane(const uint8_t* src_y,
  62. int src_stride_y,
  63. uint16_t* dst_y,
  64. int dst_stride_y,
  65. int scale, // 1024 for 10 bits
  66. int width,
  67. int height);
  68. // Set a plane of data to a 32 bit value.
  69. LIBYUV_API
  70. void SetPlane(uint8_t* dst_y,
  71. int dst_stride_y,
  72. int width,
  73. int height,
  74. uint32_t value);
  75. // Split interleaved UV plane into separate U and V planes.
  76. LIBYUV_API
  77. void SplitUVPlane(const uint8_t* src_uv,
  78. int src_stride_uv,
  79. uint8_t* dst_u,
  80. int dst_stride_u,
  81. uint8_t* dst_v,
  82. int dst_stride_v,
  83. int width,
  84. int height);
  85. // Merge separate U and V planes into one interleaved UV plane.
  86. LIBYUV_API
  87. void MergeUVPlane(const uint8_t* src_u,
  88. int src_stride_u,
  89. const uint8_t* src_v,
  90. int src_stride_v,
  91. uint8_t* dst_uv,
  92. int dst_stride_uv,
  93. int width,
  94. int height);
  95. // Swap U and V channels in interleaved UV plane.
  96. LIBYUV_API
  97. void SwapUVPlane(const uint8_t* src_uv,
  98. int src_stride_uv,
  99. uint8_t* dst_vu,
  100. int dst_stride_vu,
  101. int width,
  102. int height);
  103. // Split interleaved RGB plane into separate R, G and B planes.
  104. LIBYUV_API
  105. void SplitRGBPlane(const uint8_t* src_rgb,
  106. int src_stride_rgb,
  107. uint8_t* dst_r,
  108. int dst_stride_r,
  109. uint8_t* dst_g,
  110. int dst_stride_g,
  111. uint8_t* dst_b,
  112. int dst_stride_b,
  113. int width,
  114. int height);
  115. // Merge separate R, G and B planes into one interleaved RGB plane.
  116. LIBYUV_API
  117. void MergeRGBPlane(const uint8_t* src_r,
  118. int src_stride_r,
  119. const uint8_t* src_g,
  120. int src_stride_g,
  121. const uint8_t* src_b,
  122. int src_stride_b,
  123. uint8_t* dst_rgb,
  124. int dst_stride_rgb,
  125. int width,
  126. int height);
  127. // Copy I400. Supports inverting.
  128. LIBYUV_API
  129. int I400ToI400(const uint8_t* src_y,
  130. int src_stride_y,
  131. uint8_t* dst_y,
  132. int dst_stride_y,
  133. int width,
  134. int height);
  135. #define J400ToJ400 I400ToI400
  136. // Copy I422 to I422.
  137. #define I422ToI422 I422Copy
  138. LIBYUV_API
  139. int I422Copy(const uint8_t* src_y,
  140. int src_stride_y,
  141. const uint8_t* src_u,
  142. int src_stride_u,
  143. const uint8_t* src_v,
  144. int src_stride_v,
  145. uint8_t* dst_y,
  146. int dst_stride_y,
  147. uint8_t* dst_u,
  148. int dst_stride_u,
  149. uint8_t* dst_v,
  150. int dst_stride_v,
  151. int width,
  152. int height);
  153. // Copy I444 to I444.
  154. #define I444ToI444 I444Copy
  155. LIBYUV_API
  156. int I444Copy(const uint8_t* src_y,
  157. int src_stride_y,
  158. const uint8_t* src_u,
  159. int src_stride_u,
  160. const uint8_t* src_v,
  161. int src_stride_v,
  162. uint8_t* dst_y,
  163. int dst_stride_y,
  164. uint8_t* dst_u,
  165. int dst_stride_u,
  166. uint8_t* dst_v,
  167. int dst_stride_v,
  168. int width,
  169. int height);
  170. // Convert YUY2 to I422.
  171. LIBYUV_API
  172. int YUY2ToI422(const uint8_t* src_yuy2,
  173. int src_stride_yuy2,
  174. uint8_t* dst_y,
  175. int dst_stride_y,
  176. uint8_t* dst_u,
  177. int dst_stride_u,
  178. uint8_t* dst_v,
  179. int dst_stride_v,
  180. int width,
  181. int height);
  182. // Convert UYVY to I422.
  183. LIBYUV_API
  184. int UYVYToI422(const uint8_t* src_uyvy,
  185. int src_stride_uyvy,
  186. uint8_t* dst_y,
  187. int dst_stride_y,
  188. uint8_t* dst_u,
  189. int dst_stride_u,
  190. uint8_t* dst_v,
  191. int dst_stride_v,
  192. int width,
  193. int height);
  194. LIBYUV_API
  195. int YUY2ToNV12(const uint8_t* src_yuy2,
  196. int src_stride_yuy2,
  197. uint8_t* dst_y,
  198. int dst_stride_y,
  199. uint8_t* dst_uv,
  200. int dst_stride_uv,
  201. int width,
  202. int height);
  203. LIBYUV_API
  204. int UYVYToNV12(const uint8_t* src_uyvy,
  205. int src_stride_uyvy,
  206. uint8_t* dst_y,
  207. int dst_stride_y,
  208. uint8_t* dst_uv,
  209. int dst_stride_uv,
  210. int width,
  211. int height);
  212. // Convert NV21 to NV12.
  213. LIBYUV_API
  214. int NV21ToNV12(const uint8_t* src_y,
  215. int src_stride_y,
  216. const uint8_t* src_vu,
  217. int src_stride_vu,
  218. uint8_t* dst_y,
  219. int dst_stride_y,
  220. uint8_t* dst_uv,
  221. int dst_stride_uv,
  222. int width,
  223. int height);
  224. LIBYUV_API
  225. int YUY2ToY(const uint8_t* src_yuy2,
  226. int src_stride_yuy2,
  227. uint8_t* dst_y,
  228. int dst_stride_y,
  229. int width,
  230. int height);
  231. // Convert I420 to I400. (calls CopyPlane ignoring u/v).
  232. LIBYUV_API
  233. int I420ToI400(const uint8_t* src_y,
  234. int src_stride_y,
  235. const uint8_t* src_u,
  236. int src_stride_u,
  237. const uint8_t* src_v,
  238. int src_stride_v,
  239. uint8_t* dst_y,
  240. int dst_stride_y,
  241. int width,
  242. int height);
  243. // Alias
  244. #define J420ToJ400 I420ToI400
  245. #define I420ToI420Mirror I420Mirror
  246. // I420 mirror.
  247. LIBYUV_API
  248. int I420Mirror(const uint8_t* src_y,
  249. int src_stride_y,
  250. const uint8_t* src_u,
  251. int src_stride_u,
  252. const uint8_t* src_v,
  253. int src_stride_v,
  254. uint8_t* dst_y,
  255. int dst_stride_y,
  256. uint8_t* dst_u,
  257. int dst_stride_u,
  258. uint8_t* dst_v,
  259. int dst_stride_v,
  260. int width,
  261. int height);
  262. // Alias
  263. #define I400ToI400Mirror I400Mirror
  264. // I400 mirror. A single plane is mirrored horizontally.
  265. // Pass negative height to achieve 180 degree rotation.
  266. LIBYUV_API
  267. int I400Mirror(const uint8_t* src_y,
  268. int src_stride_y,
  269. uint8_t* dst_y,
  270. int dst_stride_y,
  271. int width,
  272. int height);
  273. // Alias
  274. #define ARGBToARGBMirror ARGBMirror
  275. // ARGB mirror.
  276. LIBYUV_API
  277. int ARGBMirror(const uint8_t* src_argb,
  278. int src_stride_argb,
  279. uint8_t* dst_argb,
  280. int dst_stride_argb,
  281. int width,
  282. int height);
  283. // Convert NV12 to RGB565.
  284. LIBYUV_API
  285. int NV12ToRGB565(const uint8_t* src_y,
  286. int src_stride_y,
  287. const uint8_t* src_uv,
  288. int src_stride_uv,
  289. uint8_t* dst_rgb565,
  290. int dst_stride_rgb565,
  291. int width,
  292. int height);
  293. // I422ToARGB is in convert_argb.h
  294. // Convert I422 to BGRA.
  295. LIBYUV_API
  296. int I422ToBGRA(const uint8_t* src_y,
  297. int src_stride_y,
  298. const uint8_t* src_u,
  299. int src_stride_u,
  300. const uint8_t* src_v,
  301. int src_stride_v,
  302. uint8_t* dst_bgra,
  303. int dst_stride_bgra,
  304. int width,
  305. int height);
  306. // Convert I422 to ABGR.
  307. LIBYUV_API
  308. int I422ToABGR(const uint8_t* src_y,
  309. int src_stride_y,
  310. const uint8_t* src_u,
  311. int src_stride_u,
  312. const uint8_t* src_v,
  313. int src_stride_v,
  314. uint8_t* dst_abgr,
  315. int dst_stride_abgr,
  316. int width,
  317. int height);
  318. // Convert I422 to RGBA.
  319. LIBYUV_API
  320. int I422ToRGBA(const uint8_t* src_y,
  321. int src_stride_y,
  322. const uint8_t* src_u,
  323. int src_stride_u,
  324. const uint8_t* src_v,
  325. int src_stride_v,
  326. uint8_t* dst_rgba,
  327. int dst_stride_rgba,
  328. int width,
  329. int height);
  330. // Alias
  331. #define RGB24ToRAW RAWToRGB24
  332. LIBYUV_API
  333. int RAWToRGB24(const uint8_t* src_raw,
  334. int src_stride_raw,
  335. uint8_t* dst_rgb24,
  336. int dst_stride_rgb24,
  337. int width,
  338. int height);
  339. // Draw a rectangle into I420.
  340. LIBYUV_API
  341. int I420Rect(uint8_t* dst_y,
  342. int dst_stride_y,
  343. uint8_t* dst_u,
  344. int dst_stride_u,
  345. uint8_t* dst_v,
  346. int dst_stride_v,
  347. int x,
  348. int y,
  349. int width,
  350. int height,
  351. int value_y,
  352. int value_u,
  353. int value_v);
  354. // Draw a rectangle into ARGB.
  355. LIBYUV_API
  356. int ARGBRect(uint8_t* dst_argb,
  357. int dst_stride_argb,
  358. int dst_x,
  359. int dst_y,
  360. int width,
  361. int height,
  362. uint32_t value);
  363. // Convert ARGB to gray scale ARGB.
  364. LIBYUV_API
  365. int ARGBGrayTo(const uint8_t* src_argb,
  366. int src_stride_argb,
  367. uint8_t* dst_argb,
  368. int dst_stride_argb,
  369. int width,
  370. int height);
  371. // Make a rectangle of ARGB gray scale.
  372. LIBYUV_API
  373. int ARGBGray(uint8_t* dst_argb,
  374. int dst_stride_argb,
  375. int dst_x,
  376. int dst_y,
  377. int width,
  378. int height);
  379. // Make a rectangle of ARGB Sepia tone.
  380. LIBYUV_API
  381. int ARGBSepia(uint8_t* dst_argb,
  382. int dst_stride_argb,
  383. int dst_x,
  384. int dst_y,
  385. int width,
  386. int height);
  387. // Apply a matrix rotation to each ARGB pixel.
  388. // matrix_argb is 4 signed ARGB values. -128 to 127 representing -2 to 2.
  389. // The first 4 coefficients apply to B, G, R, A and produce B of the output.
  390. // The next 4 coefficients apply to B, G, R, A and produce G of the output.
  391. // The next 4 coefficients apply to B, G, R, A and produce R of the output.
  392. // The last 4 coefficients apply to B, G, R, A and produce A of the output.
  393. LIBYUV_API
  394. int ARGBColorMatrix(const uint8_t* src_argb,
  395. int src_stride_argb,
  396. uint8_t* dst_argb,
  397. int dst_stride_argb,
  398. const int8_t* matrix_argb,
  399. int width,
  400. int height);
  401. // Deprecated. Use ARGBColorMatrix instead.
  402. // Apply a matrix rotation to each ARGB pixel.
  403. // matrix_argb is 3 signed ARGB values. -128 to 127 representing -1 to 1.
  404. // The first 4 coefficients apply to B, G, R, A and produce B of the output.
  405. // The next 4 coefficients apply to B, G, R, A and produce G of the output.
  406. // The last 4 coefficients apply to B, G, R, A and produce R of the output.
  407. LIBYUV_API
  408. int RGBColorMatrix(uint8_t* dst_argb,
  409. int dst_stride_argb,
  410. const int8_t* matrix_rgb,
  411. int dst_x,
  412. int dst_y,
  413. int width,
  414. int height);
  415. // Apply a color table each ARGB pixel.
  416. // Table contains 256 ARGB values.
  417. LIBYUV_API
  418. int ARGBColorTable(uint8_t* dst_argb,
  419. int dst_stride_argb,
  420. const uint8_t* table_argb,
  421. int dst_x,
  422. int dst_y,
  423. int width,
  424. int height);
  425. // Apply a color table each ARGB pixel but preserve destination alpha.
  426. // Table contains 256 ARGB values.
  427. LIBYUV_API
  428. int RGBColorTable(uint8_t* dst_argb,
  429. int dst_stride_argb,
  430. const uint8_t* table_argb,
  431. int dst_x,
  432. int dst_y,
  433. int width,
  434. int height);
  435. // Apply a luma/color table each ARGB pixel but preserve destination alpha.
  436. // Table contains 32768 values indexed by [Y][C] where 7 it 7 bit luma from
  437. // RGB (YJ style) and C is an 8 bit color component (R, G or B).
  438. LIBYUV_API
  439. int ARGBLumaColorTable(const uint8_t* src_argb,
  440. int src_stride_argb,
  441. uint8_t* dst_argb,
  442. int dst_stride_argb,
  443. const uint8_t* luma,
  444. int width,
  445. int height);
  446. // Apply a 3 term polynomial to ARGB values.
  447. // poly points to a 4x4 matrix. The first row is constants. The 2nd row is
  448. // coefficients for b, g, r and a. The 3rd row is coefficients for b squared,
  449. // g squared, r squared and a squared. The 4rd row is coefficients for b to
  450. // the 3, g to the 3, r to the 3 and a to the 3. The values are summed and
  451. // result clamped to 0 to 255.
  452. // A polynomial approximation can be dirived using software such as 'R'.
  453. LIBYUV_API
  454. int ARGBPolynomial(const uint8_t* src_argb,
  455. int src_stride_argb,
  456. uint8_t* dst_argb,
  457. int dst_stride_argb,
  458. const float* poly,
  459. int width,
  460. int height);
  461. // Convert plane of 16 bit shorts to half floats.
  462. // Source values are multiplied by scale before storing as half float.
  463. LIBYUV_API
  464. int HalfFloatPlane(const uint16_t* src_y,
  465. int src_stride_y,
  466. uint16_t* dst_y,
  467. int dst_stride_y,
  468. float scale,
  469. int width,
  470. int height);
  471. // Convert a buffer of bytes to floats, scale the values and store as floats.
  472. LIBYUV_API
  473. int ByteToFloat(const uint8_t* src_y, float* dst_y, float scale, int width);
  474. // Quantize a rectangle of ARGB. Alpha unaffected.
  475. // scale is a 16 bit fractional fixed point scaler between 0 and 65535.
  476. // interval_size should be a value between 1 and 255.
  477. // interval_offset should be a value between 0 and 255.
  478. LIBYUV_API
  479. int ARGBQuantize(uint8_t* dst_argb,
  480. int dst_stride_argb,
  481. int scale,
  482. int interval_size,
  483. int interval_offset,
  484. int dst_x,
  485. int dst_y,
  486. int width,
  487. int height);
  488. // Copy ARGB to ARGB.
  489. LIBYUV_API
  490. int ARGBCopy(const uint8_t* src_argb,
  491. int src_stride_argb,
  492. uint8_t* dst_argb,
  493. int dst_stride_argb,
  494. int width,
  495. int height);
  496. // Copy Alpha channel of ARGB to alpha of ARGB.
  497. LIBYUV_API
  498. int ARGBCopyAlpha(const uint8_t* src_argb,
  499. int src_stride_argb,
  500. uint8_t* dst_argb,
  501. int dst_stride_argb,
  502. int width,
  503. int height);
  504. // Extract the alpha channel from ARGB.
  505. LIBYUV_API
  506. int ARGBExtractAlpha(const uint8_t* src_argb,
  507. int src_stride_argb,
  508. uint8_t* dst_a,
  509. int dst_stride_a,
  510. int width,
  511. int height);
  512. // Copy Y channel to Alpha of ARGB.
  513. LIBYUV_API
  514. int ARGBCopyYToAlpha(const uint8_t* src_y,
  515. int src_stride_y,
  516. uint8_t* dst_argb,
  517. int dst_stride_argb,
  518. int width,
  519. int height);
  520. typedef void (*ARGBBlendRow)(const uint8_t* src_argb0,
  521. const uint8_t* src_argb1,
  522. uint8_t* dst_argb,
  523. int width);
  524. // Get function to Alpha Blend ARGB pixels and store to destination.
  525. LIBYUV_API
  526. ARGBBlendRow GetARGBBlend();
  527. // Alpha Blend ARGB images and store to destination.
  528. // Source is pre-multiplied by alpha using ARGBAttenuate.
  529. // Alpha of destination is set to 255.
  530. LIBYUV_API
  531. int ARGBBlend(const uint8_t* src_argb0,
  532. int src_stride_argb0,
  533. const uint8_t* src_argb1,
  534. int src_stride_argb1,
  535. uint8_t* dst_argb,
  536. int dst_stride_argb,
  537. int width,
  538. int height);
  539. // Alpha Blend plane and store to destination.
  540. // Source is not pre-multiplied by alpha.
  541. LIBYUV_API
  542. int BlendPlane(const uint8_t* src_y0,
  543. int src_stride_y0,
  544. const uint8_t* src_y1,
  545. int src_stride_y1,
  546. const uint8_t* alpha,
  547. int alpha_stride,
  548. uint8_t* dst_y,
  549. int dst_stride_y,
  550. int width,
  551. int height);
  552. // Alpha Blend YUV images and store to destination.
  553. // Source is not pre-multiplied by alpha.
  554. // Alpha is full width x height and subsampled to half size to apply to UV.
  555. LIBYUV_API
  556. int I420Blend(const uint8_t* src_y0,
  557. int src_stride_y0,
  558. const uint8_t* src_u0,
  559. int src_stride_u0,
  560. const uint8_t* src_v0,
  561. int src_stride_v0,
  562. const uint8_t* src_y1,
  563. int src_stride_y1,
  564. const uint8_t* src_u1,
  565. int src_stride_u1,
  566. const uint8_t* src_v1,
  567. int src_stride_v1,
  568. const uint8_t* alpha,
  569. int alpha_stride,
  570. uint8_t* dst_y,
  571. int dst_stride_y,
  572. uint8_t* dst_u,
  573. int dst_stride_u,
  574. uint8_t* dst_v,
  575. int dst_stride_v,
  576. int width,
  577. int height);
  578. // Multiply ARGB image by ARGB image. Shifted down by 8. Saturates to 255.
  579. LIBYUV_API
  580. int ARGBMultiply(const uint8_t* src_argb0,
  581. int src_stride_argb0,
  582. const uint8_t* src_argb1,
  583. int src_stride_argb1,
  584. uint8_t* dst_argb,
  585. int dst_stride_argb,
  586. int width,
  587. int height);
  588. // Add ARGB image with ARGB image. Saturates to 255.
  589. LIBYUV_API
  590. int ARGBAdd(const uint8_t* src_argb0,
  591. int src_stride_argb0,
  592. const uint8_t* src_argb1,
  593. int src_stride_argb1,
  594. uint8_t* dst_argb,
  595. int dst_stride_argb,
  596. int width,
  597. int height);
  598. // Subtract ARGB image (argb1) from ARGB image (argb0). Saturates to 0.
  599. LIBYUV_API
  600. int ARGBSubtract(const uint8_t* src_argb0,
  601. int src_stride_argb0,
  602. const uint8_t* src_argb1,
  603. int src_stride_argb1,
  604. uint8_t* dst_argb,
  605. int dst_stride_argb,
  606. int width,
  607. int height);
  608. // Convert I422 to YUY2.
  609. LIBYUV_API
  610. int I422ToYUY2(const uint8_t* src_y,
  611. int src_stride_y,
  612. const uint8_t* src_u,
  613. int src_stride_u,
  614. const uint8_t* src_v,
  615. int src_stride_v,
  616. uint8_t* dst_yuy2,
  617. int dst_stride_yuy2,
  618. int width,
  619. int height);
  620. // Convert I422 to UYVY.
  621. LIBYUV_API
  622. int I422ToUYVY(const uint8_t* src_y,
  623. int src_stride_y,
  624. const uint8_t* src_u,
  625. int src_stride_u,
  626. const uint8_t* src_v,
  627. int src_stride_v,
  628. uint8_t* dst_uyvy,
  629. int dst_stride_uyvy,
  630. int width,
  631. int height);
  632. // Convert unattentuated ARGB to preattenuated ARGB.
  633. LIBYUV_API
  634. int ARGBAttenuate(const uint8_t* src_argb,
  635. int src_stride_argb,
  636. uint8_t* dst_argb,
  637. int dst_stride_argb,
  638. int width,
  639. int height);
  640. // Convert preattentuated ARGB to unattenuated ARGB.
  641. LIBYUV_API
  642. int ARGBUnattenuate(const uint8_t* src_argb,
  643. int src_stride_argb,
  644. uint8_t* dst_argb,
  645. int dst_stride_argb,
  646. int width,
  647. int height);
  648. // Internal function - do not call directly.
  649. // Computes table of cumulative sum for image where the value is the sum
  650. // of all values above and to the left of the entry. Used by ARGBBlur.
  651. LIBYUV_API
  652. int ARGBComputeCumulativeSum(const uint8_t* src_argb,
  653. int src_stride_argb,
  654. int32_t* dst_cumsum,
  655. int dst_stride32_cumsum,
  656. int width,
  657. int height);
  658. // Blur ARGB image.
  659. // dst_cumsum table of width * (height + 1) * 16 bytes aligned to
  660. // 16 byte boundary.
  661. // dst_stride32_cumsum is number of ints in a row (width * 4).
  662. // radius is number of pixels around the center. e.g. 1 = 3x3. 2=5x5.
  663. // Blur is optimized for radius of 5 (11x11) or less.
  664. LIBYUV_API
  665. int ARGBBlur(const uint8_t* src_argb,
  666. int src_stride_argb,
  667. uint8_t* dst_argb,
  668. int dst_stride_argb,
  669. int32_t* dst_cumsum,
  670. int dst_stride32_cumsum,
  671. int width,
  672. int height,
  673. int radius);
  674. // Gaussian 5x5 blur a float plane.
  675. // Coefficients of 1, 4, 6, 4, 1.
  676. // Each destination pixel is a blur of the 5x5
  677. // pixels from the source.
  678. // Source edges are clamped.
  679. LIBYUV_API
  680. int GaussPlane_F32(const float* src,
  681. int src_stride,
  682. float* dst,
  683. int dst_stride,
  684. int width,
  685. int height);
  686. // Multiply ARGB image by ARGB value.
  687. LIBYUV_API
  688. int ARGBShade(const uint8_t* src_argb,
  689. int src_stride_argb,
  690. uint8_t* dst_argb,
  691. int dst_stride_argb,
  692. int width,
  693. int height,
  694. uint32_t value);
  695. // Interpolate between two images using specified amount of interpolation
  696. // (0 to 255) and store to destination.
  697. // 'interpolation' is specified as 8 bit fraction where 0 means 100% src0
  698. // and 255 means 1% src0 and 99% src1.
  699. LIBYUV_API
  700. int InterpolatePlane(const uint8_t* src0,
  701. int src_stride0,
  702. const uint8_t* src1,
  703. int src_stride1,
  704. uint8_t* dst,
  705. int dst_stride,
  706. int width,
  707. int height,
  708. int interpolation);
  709. // Interpolate between two ARGB images using specified amount of interpolation
  710. // Internally calls InterpolatePlane with width * 4 (bpp).
  711. LIBYUV_API
  712. int ARGBInterpolate(const uint8_t* src_argb0,
  713. int src_stride_argb0,
  714. const uint8_t* src_argb1,
  715. int src_stride_argb1,
  716. uint8_t* dst_argb,
  717. int dst_stride_argb,
  718. int width,
  719. int height,
  720. int interpolation);
  721. // Interpolate between two YUV images using specified amount of interpolation
  722. // Internally calls InterpolatePlane on each plane where the U and V planes
  723. // are half width and half height.
  724. LIBYUV_API
  725. int I420Interpolate(const uint8_t* src0_y,
  726. int src0_stride_y,
  727. const uint8_t* src0_u,
  728. int src0_stride_u,
  729. const uint8_t* src0_v,
  730. int src0_stride_v,
  731. const uint8_t* src1_y,
  732. int src1_stride_y,
  733. const uint8_t* src1_u,
  734. int src1_stride_u,
  735. const uint8_t* src1_v,
  736. int src1_stride_v,
  737. uint8_t* dst_y,
  738. int dst_stride_y,
  739. uint8_t* dst_u,
  740. int dst_stride_u,
  741. uint8_t* dst_v,
  742. int dst_stride_v,
  743. int width,
  744. int height,
  745. int interpolation);
  746. // Row function for copying pixels from a source with a slope to a row
  747. // of destination. Useful for scaling, rotation, mirror, texture mapping.
  748. LIBYUV_API
  749. void ARGBAffineRow_C(const uint8_t* src_argb,
  750. int src_argb_stride,
  751. uint8_t* dst_argb,
  752. const float* uv_dudv,
  753. int width);
  754. // TODO(fbarchard): Move ARGBAffineRow_SSE2 to row.h
  755. LIBYUV_API
  756. void ARGBAffineRow_SSE2(const uint8_t* src_argb,
  757. int src_argb_stride,
  758. uint8_t* dst_argb,
  759. const float* uv_dudv,
  760. int width);
  761. // Shuffle ARGB channel order. e.g. BGRA to ARGB.
  762. // shuffler is 16 bytes and must be aligned.
  763. LIBYUV_API
  764. int ARGBShuffle(const uint8_t* src_bgra,
  765. int src_stride_bgra,
  766. uint8_t* dst_argb,
  767. int dst_stride_argb,
  768. const uint8_t* shuffler,
  769. int width,
  770. int height);
  771. // Sobel ARGB effect with planar output.
  772. LIBYUV_API
  773. int ARGBSobelToPlane(const uint8_t* src_argb,
  774. int src_stride_argb,
  775. uint8_t* dst_y,
  776. int dst_stride_y,
  777. int width,
  778. int height);
  779. // Sobel ARGB effect.
  780. LIBYUV_API
  781. int ARGBSobel(const uint8_t* src_argb,
  782. int src_stride_argb,
  783. uint8_t* dst_argb,
  784. int dst_stride_argb,
  785. int width,
  786. int height);
  787. // Sobel ARGB effect w/ Sobel X, Sobel, Sobel Y in ARGB.
  788. LIBYUV_API
  789. int ARGBSobelXY(const uint8_t* src_argb,
  790. int src_stride_argb,
  791. uint8_t* dst_argb,
  792. int dst_stride_argb,
  793. int width,
  794. int height);
  795. #ifdef __cplusplus
  796. } // extern "C"
  797. } // namespace libyuv
  798. #endif
  799. #endif // INCLUDE_LIBYUV_PLANAR_FUNCTIONS_H_