1aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org/*
2b0c97975894a5eebebf9d93147cdd941a3accb63fbarchard@google.com *  Copyright 2011 The LibYuv Project Authors. All rights reserved.
3aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org *
4aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org *  Use of this source code is governed by a BSD-style license
5aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org *  that can be found in the LICENSE file in the root of the source
6aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org *  tree. An additional intellectual property rights grant can be found
7cde587092fef0dbed2c35602f30b79e7b892e766fbarchard@google.com *  in the file PATENTS. All contributing project authors may
8aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org *  be found in the AUTHORS file in the root of the source tree.
9aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org */
10aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org
11f37f9a3542799ed17cc5c1c03f94a7ef279cfc20fbarchard@google.com#ifndef INCLUDE_LIBYUV_CONVERT_H_  // NOLINT
12a1280730c24b5c94ef16949777f65e597719488efbarchard@google.com#define INCLUDE_LIBYUV_CONVERT_H_
13aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org
14a1280730c24b5c94ef16949777f65e597719488efbarchard@google.com#include "libyuv/basic_types.h"
159bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// TODO(fbarchard): Remove the following headers includes.
1619932f8dbc5ca3123d87b5b8369e7d7bf3469a97fbarchard@google.com#include "libyuv/convert_from.h"
172d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com#include "libyuv/planar_functions.h"
18b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com#include "libyuv/rotate.h"
19aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org
20fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.com#ifdef __cplusplus
2143575c8fa5a0f18b1ad9146cda3dfb1af13811f2mikhal@webrtc.orgnamespace libyuv {
22fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.comextern "C" {
23fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.com#endif
24280f4fd8bb7d04ca1a5ecd0b6245a4f3726a9df3mikhal@webrtc.org
25bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert I444 to I420.
26fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
27bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint I444ToI420(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);
34585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
35bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert I422 to I420.
36fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
37bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint I422ToI420(const uint8* src_y, int src_stride_y,
382d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_u, int src_stride_u,
392d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_v, int src_stride_v,
402d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
412d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
422d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
432d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
44c9911bcba1b7a59feff8bf7816446306e0096862fbarchard@google.com
458536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com// Convert I411 to I420.
46fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
478536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.comint I411ToI420(const uint8* src_y, int src_stride_y,
488536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               const uint8* src_u, int src_stride_u,
498536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               const uint8* src_v, int src_stride_v,
508536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_y, int dst_stride_y,
518536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_u, int dst_stride_u,
528536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               uint8* dst_v, int dst_stride_v,
538536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com               int width, int height);
548536b2f389dea8f8b7177f4886d995e3315f12e8fbarchard@google.com
55bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Copy I420 to I420.
56bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com#define I420ToI420 I420Copy
57bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comLIBYUV_API
58bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint I420Copy(const uint8* src_y, int src_stride_y,
59bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             const uint8* src_u, int src_stride_u,
60bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             const uint8* src_v, int src_stride_v,
61bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             uint8* dst_y, int dst_stride_y,
62bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             uint8* dst_u, int dst_stride_u,
63bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             uint8* dst_v, int dst_stride_v,
64bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com             int width, int height);
65bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com
662d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// Convert I400 (grey) to I420.
67fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
682d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint I400ToI420(const uint8* src_y, int src_stride_y,
692d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
702d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
712d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
722d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
73585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
7462a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com// Convert NV12 to I420.
75fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
762d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint NV12ToI420(const uint8* src_y, int src_stride_y,
772d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               const uint8* src_uv, int src_stride_uv,
782d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
792d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
802d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
812d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
82585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
8362a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com// Convert NV21 to I420.
8462a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comLIBYUV_API
8562a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.comint NV21ToI420(const uint8* src_y, int src_stride_y,
8662a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               const uint8* src_vu, int src_stride_vu,
8762a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_y, int dst_stride_y,
8862a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_u, int dst_stride_u,
8962a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               uint8* dst_v, int dst_stride_v,
9062a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com               int width, int height);
9162a961bee72e48e4fa14365bd7444c9280540b6ffbarchard@google.com
92bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert YUY2 to I420.
93fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
94bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint YUY2ToI420(const uint8* src_yuy2, int src_stride_yuy2,
952d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
962d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
972d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
982d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
99585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
100bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert UYVY to I420.
101fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
102bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint UYVYToI420(const uint8* src_uyvy, int src_stride_uyvy,
1032d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1042d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1052d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
106585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com               int width, int height);
107585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
108bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert M420 to I420.
109fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
110bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint M420ToI420(const uint8* src_m420, int src_stride_m420,
1112d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1122d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1132d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
11412d048335db029aa66396d2fc09be0612afe8b59fbarchard@google.com               int width, int height);
11512d048335db029aa66396d2fc09be0612afe8b59fbarchard@google.com
116bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com// Convert Q420 to I420.
117fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
118bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.comint Q420ToI420(const uint8* src_y, int src_stride_y,
119bdf7cb591452611090922e690d5104a7d8c6b1e5fbarchard@google.com               const uint8* src_yuy2, int src_stride_yuy2,
1202d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1212d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1222d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
123585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com               int width, int height);
124585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
1259bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// ARGB little endian (bgra in memory) to I420.
126fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1272d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint ARGBToI420(const uint8* src_frame, int src_stride_frame,
1282d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1292d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1302d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
1312d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
1322d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com
1339bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// BGRA little endian (argb in memory) to I420.
134fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1352d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint BGRAToI420(const uint8* src_frame, int src_stride_frame,
1362d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1372d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1382d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
139032b5f990f6673afee7d9a7ad3132ca46448d834fbarchard@google.com               int width, int height);
140032b5f990f6673afee7d9a7ad3132ca46448d834fbarchard@google.com
1419bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// ABGR little endian (rgba in memory) to I420.
142fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1432d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.comint ABGRToI420(const uint8* src_frame, int src_stride_frame,
1442d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_y, int dst_stride_y,
1452d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_u, int dst_stride_u,
1462d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               uint8* dst_v, int dst_stride_v,
1472d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com               int width, int height);
148032b5f990f6673afee7d9a7ad3132ca46448d834fbarchard@google.com
149d5a27f0533d42bd0e241b0a7887abe1a3d9c0633fbarchard@google.com// RGBA little endian (abgr in memory) to I420.
150fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
1519bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.comint RGBAToI420(const uint8* src_frame, int src_stride_frame,
1529bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               uint8* dst_y, int dst_stride_y,
1539bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               uint8* dst_u, int dst_stride_u,
1549bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               uint8* dst_v, int dst_stride_v,
1559bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com               int width, int height);
1569bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com
1579bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// RGB little endian (bgr in memory) to I420.
158fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
159585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.comint RGB24ToI420(const uint8* src_frame, int src_stride_frame,
160585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com                uint8* dst_y, int dst_stride_y,
161585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com                uint8* dst_u, int dst_stride_u,
162585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com                uint8* dst_v, int dst_stride_v,
163585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com                int width, int height);
164585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
1659bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// RGB big endian (rgb in memory) to I420.
166fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
167585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.comint RAWToI420(const uint8* src_frame, int src_stride_frame,
168585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com              uint8* dst_y, int dst_stride_y,
169585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com              uint8* dst_u, int dst_stride_u,
170585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com              uint8* dst_v, int dst_stride_v,
171585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com              int width, int height);
172585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
1739bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// RGB16 (RGBP fourcc) little endian to I420.
174fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
175a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.comint RGB565ToI420(const uint8* src_frame, int src_stride_frame,
176a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                 uint8* dst_y, int dst_stride_y,
177a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                 uint8* dst_u, int dst_stride_u,
178a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                 uint8* dst_v, int dst_stride_v,
179a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                 int width, int height);
180a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com
1819bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// RGB15 (RGBO fourcc) little endian to I420.
182fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
183a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.comint ARGB1555ToI420(const uint8* src_frame, int src_stride_frame,
184a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_y, int dst_stride_y,
185a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_u, int dst_stride_u,
186a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_v, int dst_stride_v,
187a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   int width, int height);
188a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com
1899bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// RGB12 (R444 fourcc) little endian to I420.
190fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
191a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.comint ARGB4444ToI420(const uint8* src_frame, int src_stride_frame,
192a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_y, int dst_stride_y,
193a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_u, int dst_stride_u,
194a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   uint8* dst_v, int dst_stride_v,
195a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com                   int width, int height);
196a7d977ceae6215332f359ab289a93460a24dc1e0fbarchard@google.com
197714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com#ifdef HAVE_JPEG
1989bcc9a25355841f844e9fae3ba40522447312a66fbarchard@google.com// src_width/height provided by capture.
199714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com// dst_width/height for clipping determine final size.
200fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
201714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.comint MJPGToI420(const uint8* sample, size_t sample_size,
202714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com               uint8* dst_y, int dst_stride_y,
203714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com               uint8* dst_u, int dst_stride_u,
204714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com               uint8* dst_v, int dst_stride_v,
205714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com               int src_width, int src_height,
206714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com               int dst_width, int dst_height);
2071c396a3d7d6b219dbef41f630f4f6205a00beb5efbarchard@google.com
2081c396a3d7d6b219dbef41f630f4f6205a00beb5efbarchard@google.com// Query size of MJPG in pixels.
2091c396a3d7d6b219dbef41f630f4f6205a00beb5efbarchard@google.comLIBYUV_API
2101c396a3d7d6b219dbef41f630f4f6205a00beb5efbarchard@google.comint MJPGSize(const uint8* sample, size_t sample_size,
2111c396a3d7d6b219dbef41f630f4f6205a00beb5efbarchard@google.com             int* width, int* height);
212714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com#endif
213714050a29dea9ab6aebb54acb8f79edf9b9f337dfbarchard@google.com
2142d11d43a6e21865b904705acce6535ae4c2d3caffbarchard@google.com// Note Bayer formats (BGGR) To I420 are in format_conversion.h
215585a126140be298e60a4daa26140ead0e94eaaa1fbarchard@google.com
216b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com// Convert camera sample to I420 with cropping, rotation and vertical flip.
217d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "src_size" is needed to parse MJPG.
218d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "dst_stride_y" number of bytes in a row of the dst_y plane.
219d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   Normally this would be the same as dst_width, with recommended alignment
220d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   to 16 bytes for better efficiency.
221d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   If rotation of 90 or 270 is used, stride is affected. The caller should
222d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   allocate the I420 buffer according to rotation.
223d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "dst_stride_u" number of bytes in a row of the dst_u plane.
224d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   Normally this would be the same as (dst_width + 1) / 2, with
225d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   recommended alignment to 16 bytes for better efficiency.
226d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   If rotation of 90 or 270 is used, stride is affected.
227d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "crop_x" and "crop_y" are starting position for cropping.
228d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   To center, crop_x = (src_width - dst_width) / 2
229d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//              crop_y = (src_height - dst_height) / 2
230d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "src_width" / "src_height" is size of src_frame in pixels.
231d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//   "src_height" can be negative indicating a vertically flipped image source.
232f2bd31538e43abaefc51d2a07b7a9f9e5f9911a0fbarchard@google.com// "crop_width" / "crop_height" is the size to crop the src to.
233d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//    Must be less than or equal to src_width/src_height
234d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com//    Cropping parameters are pre-rotation.
235d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// "rotation" can be 0, 90, 180 or 270.
23664ce0ab544591b1e26ae6d276932cacdb8137071fbarchard@google.com// "format" is a fourcc. ie 'I420', 'YUY2'
237d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com// Returns 0 for successful; -1 for invalid parameter. Non-zero for failure.
238fc7314e86bc7a1a88b38b815e881183521801ea9fbarchard@google.comLIBYUV_API
239b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.comint ConvertToI420(const uint8* src_frame, size_t src_size,
240b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com                  uint8* dst_y, int dst_stride_y,
241b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com                  uint8* dst_u, int dst_stride_u,
242b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com                  uint8* dst_v, int dst_stride_v,
243d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com                  int crop_x, int crop_y,
244d4ff5b42e6073879f85c579a2049a929d1170e92fbarchard@google.com                  int src_width, int src_height,
245f2bd31538e43abaefc51d2a07b7a9f9e5f9911a0fbarchard@google.com                  int crop_width, int crop_height,
24633d34eaad81ca9b3e05055f5a669c7ec3cd3fe61fbarchard@google.com                  enum RotationMode rotation,
247b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com                  uint32 format);
248b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com
249fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.com#ifdef __cplusplus
250fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.com}  // extern "C"
251b61497636a648c771ac55d184a80b17aca7414f5fbarchard@google.com}  // namespace libyuv
252fe5ff7ed5451496281697bda9cb85084c532926cfbarchard@google.com#endif
253aed1cc94c105736a5e6010e9c84cc32910b865d6mikhal@webrtc.org
254f37f9a3542799ed17cc5c1c03f94a7ef279cfc20fbarchard@google.com#endif  // INCLUDE_LIBYUV_CONVERT_H_  NOLINT
255