12d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com/*
2b0c97975894a5eebebf9d93147cdd941a3accb63fbarchard@google.com *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
32d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com *
42d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com *  Use of this source code is governed by a BSD-style license
52d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com *  that can be found in the LICENSE file in the root of the source
62d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com *  tree. An additional intellectual property rights grant can be found
7cde587092fef0dbed2c35602f30b79e7b892e766fbarchard@google.com *  in the file PATENTS. All contributing project authors may
82d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com *  be found in the AUTHORS file in the root of the source tree.
92d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com */
102d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
11f37f9a3542799ed17cc5c1c03f94a7ef279cfc20fbarchard@google.com#ifndef INCLUDE_LIBYUV_CONVERT_FROM_H_  // NOLINT
122d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#define INCLUDE_LIBYUV_CONVERT_FROM_H_
132d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
142d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#include "libyuv/basic_types.h"
152d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#include "libyuv/rotate.h"
162d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
172d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#ifdef __cplusplus
182d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comnamespace libyuv {
192d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comextern "C" {
202d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#endif
212d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
229bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// See Also convert.h for conversions from formats to I420.
232d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
249bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// I420Copy in convert to I420ToI420.
252d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
26fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
272d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToI422(const uint8* src_y, int src_stride_y,
282d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
292d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
302d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
312d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
322d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
332d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
342d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
35fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
362d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToI444(const uint8* src_y, int src_stride_y,
378536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               const uint8* src_u, int src_stride_u,
388536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               const uint8* src_v, int src_stride_v,
398536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_y, int dst_stride_y,
408536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_u, int dst_stride_u,
418536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_v, int dst_stride_v,
428536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               int width, int height);
438536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com
44fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
458536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.comint I420ToI411(const uint8* src_y, int src_stride_y,
462d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
472d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
482d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
492d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
502d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
512d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
522d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
5364ce0ab544591b1e26ae6d276932cacdb8137071fbarchard@google.com// Copy to I400. Source can be I420, I422, I444, I400, NV12 or NV21.
54fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
552d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I400Copy(const uint8* src_y, int src_stride_y,
562d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com             uint8* dst_y, int dst_stride_y,
572d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com             int width, int height);
582d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
592d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// TODO(fbarchard): I420ToM420
602d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// TODO(fbarchard): I420ToQ420
612d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
62fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
6362a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comint I420ToNV12(const uint8* src_y, int src_stride_y,
6462a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               const uint8* src_u, int src_stride_u,
6562a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               const uint8* src_v, int src_stride_v,
6662a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_y, int dst_stride_y,
6762a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_uv, int dst_stride_uv,
6862a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               int width, int height);
6962a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com
7062a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comLIBYUV_API
7162a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comint I420ToNV21(const uint8* src_y, int src_stride_y,
7262a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               const uint8* src_u, int src_stride_u,
7362a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               const uint8* src_v, int src_stride_v,
7462a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_y, int dst_stride_y,
7562a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_vu, int dst_stride_vu,
7662a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               int width, int height);
7762a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com
7862a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comLIBYUV_API
792d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToYUY2(const uint8* src_y, int src_stride_y,
802d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
812d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
822d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_frame, int dst_stride_frame,
832d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
842d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
85fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
862d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToUYVY(const uint8* src_y, int src_stride_y,
872d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
882d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
892d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_frame, int dst_stride_frame,
902d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
912d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
92fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
932d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToARGB(const uint8* src_y, int src_stride_y,
942d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
952d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
962d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_argb, int dst_stride_argb,
972d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
982d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
99fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1002d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToBGRA(const uint8* src_y, int src_stride_y,
1012d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
1022d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
1032d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_argb, int dst_stride_argb,
1042d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
1052d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
106fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1072d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToABGR(const uint8* src_y, int src_stride_y,
1082d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
1092d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
1102d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_argb, int dst_stride_argb,
1112d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
1122d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
113fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1149bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.comint I420ToRGBA(const uint8* src_y, int src_stride_y,
1159bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               const uint8* src_u, int src_stride_u,
1169bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               const uint8* src_v, int src_stride_v,
1179bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               uint8* dst_rgba, int dst_stride_rgba,
1189bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               int width, int height);
1199bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com
120fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1212d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToRGB24(const uint8* src_y, int src_stride_y,
1222d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                const uint8* src_u, int src_stride_u,
1232d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                const uint8* src_v, int src_stride_v,
1242d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                uint8* dst_frame, int dst_stride_frame,
1252d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                int width, int height);
1262d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
127fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1282d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToRAW(const uint8* src_y, int src_stride_y,
1292d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com              const uint8* src_u, int src_stride_u,
1302d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com              const uint8* src_v, int src_stride_v,
1312d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com              uint8* dst_frame, int dst_stride_frame,
1322d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com              int width, int height);
1332d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
134fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1352d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToRGB565(const uint8* src_y, int src_stride_y,
1362d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                 const uint8* src_u, int src_stride_u,
1372d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                 const uint8* src_v, int src_stride_v,
1382d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                 uint8* dst_frame, int dst_stride_frame,
1392d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                 int width, int height);
1402d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
141fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1422d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToARGB1555(const uint8* src_y, int src_stride_y,
1432d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   const uint8* src_u, int src_stride_u,
1442d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   const uint8* src_v, int src_stride_v,
1452d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   uint8* dst_frame, int dst_stride_frame,
1462d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   int width, int height);
1472d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
148fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1492d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I420ToARGB4444(const uint8* src_y, int src_stride_y,
1502d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   const uint8* src_u, int src_stride_u,
1512d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   const uint8* src_v, int src_stride_v,
1522d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   uint8* dst_frame, int dst_stride_frame,
1532d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                   int width, int height);
1542d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
1559bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// Note Bayer formats (BGGR) To I420 are in format_conversion.h.
1562d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
1572d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// Convert I420 to specified format.
1582d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// "dst_sample_stride" is bytes in a row for the destination. Pass 0 if the
1592d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com//    buffer has contiguous rows. Can be negative. A multiple of 16 is optimal.
160fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1612d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint ConvertFromI420(const uint8* y, int y_stride,
1622d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                    const uint8* u, int u_stride,
1632d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                    const uint8* v, int v_stride,
1642d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                    uint8* dst_sample, int dst_sample_stride,
1652d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                    int width, int height,
1662d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com                    uint32 format);
1672d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
1682d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#ifdef __cplusplus
1692d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com}  // extern "C"
1702d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com}  // namespace libyuv
1712d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#endif
1722d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
173f37f9a3542799ed17cc5c1c03f94a7ef279cfc20fbarchard@google.com#endif  // INCLUDE_LIBYUV_CONVERT_FROM_H_  NOLINT
174