convert_yuv_to_rgb.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef MEDIA_BASE_SIMD_CONVERT_YUV_TO_RGB_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define MEDIA_BASE_SIMD_CONVERT_YUV_TO_RGB_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "media/base/yuv_convert.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace media {
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// These methods are exported for testing purposes only.  Library users should
1490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)// only call the methods listed in yuv_convert.h.
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32_C(const uint8* yplane,
1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      const uint8* uplane,
1890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      const uint8* vplane,
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      uint8* rgbframe,
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int width,
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int height,
2290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int ystride,
2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int uvstride,
2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int rgbstride,
2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      YUVType yuv_type);
2690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
2790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32Row_C(const uint8* yplane,
2890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* uplane,
2990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* vplane,
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         uint8* rgbframe,
3190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t width);
3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVAToARGB_C(const uint8* yplane,
3490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      const uint8* uplane,
3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      const uint8* vplane,
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      const uint8* aplane,
3790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      uint8* rgbframe,
3890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int width,
3990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int height,
4090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int ystride,
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int uvstride,
4290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int avstride,
4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      int rgbstride,
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                      YUVType yuv_type);
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVAToARGBRow_C(const uint8* yplane,
4790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* uplane,
4890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* vplane,
4990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* aplane,
5090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         uint8* rgbframe,
5190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t width);
5290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
5390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32_SSE(const uint8* yplane,
5490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* uplane,
5590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* vplane,
5690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        uint8* rgbframe,
5790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int width,
5890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int height,
5990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int ystride,
6090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int uvstride,
6190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int rgbstride,
6290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        YUVType yuv_type);
6390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
6490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32_MMX(const uint8* yplane,
6590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* uplane,
6690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* vplane,
6790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        uint8* rgbframe,
6890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int width,
6990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int height,
7090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int ystride,
7190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int uvstride,
7290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int rgbstride,
7390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        YUVType yuv_type);
7490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
7590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVAToARGB_MMX(const uint8* yplane,
7690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* uplane,
7790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* vplane,
7890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        const uint8* aplane,
7990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        uint8* rgbframe,
8090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int width,
8190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int height,
8290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int ystride,
8390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int uvstride,
8490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int avstride,
8590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        int rgbstride,
8690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                        YUVType yuv_type);
8790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
8890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ScaleYUVToRGB32Row_C(const uint8* y_buf,
8990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                       const uint8* u_buf,
9090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                       const uint8* v_buf,
9190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                       uint8* rgb_buf,
9290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                       ptrdiff_t width,
9390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                       ptrdiff_t source_dx);
9490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
9590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void LinearScaleYUVToRGB32Row_C(const uint8* y_buf,
9690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                             const uint8* u_buf,
9790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                             const uint8* v_buf,
9890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                             uint8* rgb_buf,
9990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                             ptrdiff_t width,
10090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                             ptrdiff_t source_dx);
10190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
10290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void LinearScaleYUVToRGB32RowWithRange_C(const uint8* y_buf,
10390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      const uint8* u_buf,
10490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      const uint8* v_buf,
10590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      uint8* rgb_buf,
10690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      int dest_width,
10790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      int source_x,
10890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                      int source_dx);
109c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace media
1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Assembly functions are declared without namespace.
1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)extern "C" {
1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// We use ptrdiff_t instead of int for yasm routine parameters to portably
1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// sign-extend int. On Win64, MSVC does not sign-extend the value in the stack
1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// home of int function parameters, and yasm routines are unaware of this lack
1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// of extension and fault.  ptrdiff_t is portably sign-extended and fixes this
1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// issue on at least Win64.  The C-equivalent RowProc versions' prototypes
1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// include the same change to ptrdiff_t to reuse the typedefs.
1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
12290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32Row_MMX(const uint8* yplane,
12390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* uplane,
12490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* vplane,
12590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           uint8* rgbframe,
12690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           ptrdiff_t width);
12790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
12890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVAToARGBRow_MMX(const uint8* yplane,
12990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* uplane,
13090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* vplane,
13190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* aplane,
13290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           uint8* rgbframe,
13390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           ptrdiff_t width);
13490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
13590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ConvertYUVToRGB32Row_SSE(const uint8* yplane,
13690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* uplane,
13790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           const uint8* vplane,
13890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           uint8* rgbframe,
13990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                           ptrdiff_t width);
14090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
14190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ScaleYUVToRGB32Row_MMX(const uint8* y_buf,
1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         const uint8* u_buf,
1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         const uint8* v_buf,
1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                         uint8* rgb_buf,
14590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t width,
14690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t source_dx);
14790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
14890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ScaleYUVToRGB32Row_SSE(const uint8* y_buf,
14990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* u_buf,
15090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         const uint8* v_buf,
15190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         uint8* rgb_buf,
15290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t width,
15390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                         ptrdiff_t source_dx);
15490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
15590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void ScaleYUVToRGB32Row_SSE2_X64(const uint8* y_buf,
15690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                              const uint8* u_buf,
15790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                              const uint8* v_buf,
15890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                              uint8* rgb_buf,
15990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                              ptrdiff_t width,
16090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                              ptrdiff_t source_dx);
16190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
16290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void LinearScaleYUVToRGB32Row_MMX(const uint8* y_buf,
16390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               const uint8* u_buf,
16490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               const uint8* v_buf,
16590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               uint8* rgb_buf,
16690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               ptrdiff_t width,
16790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               ptrdiff_t source_dx);
16890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
16990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void LinearScaleYUVToRGB32Row_SSE(const uint8* y_buf,
17090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               const uint8* u_buf,
17190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               const uint8* v_buf,
17290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               uint8* rgb_buf,
17390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               ptrdiff_t width,
17490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                               ptrdiff_t source_dx);
17590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)
17690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)MEDIA_EXPORT void LinearScaleYUVToRGB32Row_MMX_X64(const uint8* y_buf,
17790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                   const uint8* u_buf,
17890dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                   const uint8* v_buf,
17990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                   uint8* rgb_buf,
18090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                   ptrdiff_t width,
18190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)                                                   ptrdiff_t source_dx);
1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // extern "C"
1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // MEDIA_BASE_SIMD_CONVERT_YUV_TO_RGB_H_
186