| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. | 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 uint8* dst_argb, int dst_stride_argb, | 122 uint8* dst_argb, int dst_stride_argb, |
| 123 int width, int height) { | 123 int width, int height) { |
| 124 return I444ToARGBMatrix(src_y, src_stride_y, | 124 return I444ToARGBMatrix(src_y, src_stride_y, |
| 125 src_u, src_stride_u, | 125 src_u, src_stride_u, |
| 126 src_v, src_stride_v, | 126 src_v, src_stride_v, |
| 127 dst_argb, dst_stride_argb, | 127 dst_argb, dst_stride_argb, |
| 128 &kYuvIConstants, | 128 &kYuvIConstants, |
| 129 width, height); | 129 width, height); |
| 130 } | 130 } |
| 131 | 131 |
| 132 | |
| 133 // Convert J444 to ARGB. | 132 // Convert J444 to ARGB. |
| 134 LIBYUV_API | 133 LIBYUV_API |
| 135 int J444ToARGB(const uint8* src_y, int src_stride_y, | 134 int J444ToARGB(const uint8* src_y, int src_stride_y, |
| 136 const uint8* src_u, int src_stride_u, | 135 const uint8* src_u, int src_stride_u, |
| 137 const uint8* src_v, int src_stride_v, | 136 const uint8* src_v, int src_stride_v, |
| 138 uint8* dst_argb, int dst_stride_argb, | 137 uint8* dst_argb, int dst_stride_argb, |
| 139 int width, int height) { | 138 int width, int height) { |
| 140 return I444ToARGBMatrix(src_y, src_stride_y, | 139 return I444ToARGBMatrix(src_y, src_stride_y, |
| 141 src_u, src_stride_u, | 140 src_u, src_stride_u, |
| 142 src_v, src_stride_v, | 141 src_v, src_stride_v, |
| 143 dst_argb, dst_stride_argb, | 142 dst_argb, dst_stride_argb, |
| 144 &kYuvJConstants, | 143 &kYuvJConstants, |
| 145 width, height); | 144 width, height); |
| 146 } | 145 } |
| 147 | 146 |
| 148 | |
| 149 // Convert I444 to ABGR. | 147 // Convert I444 to ABGR. |
| 150 LIBYUV_API | 148 LIBYUV_API |
| 151 int I444ToABGR(const uint8* src_y, int src_stride_y, | 149 int I444ToABGR(const uint8* src_y, int src_stride_y, |
| 152 const uint8* src_u, int src_stride_u, | 150 const uint8* src_u, int src_stride_u, |
| 153 const uint8* src_v, int src_stride_v, | 151 const uint8* src_v, int src_stride_v, |
| 154 uint8* dst_abgr, int dst_stride_abgr, | 152 uint8* dst_abgr, int dst_stride_abgr, |
| 155 int width, int height) { | 153 int width, int height) { |
| 156 int y; | 154 return I444ToARGBMatrix(src_y, src_stride_y, |
| 157 void (*I444ToABGRRow)(const uint8* y_buf, | 155 src_v, src_stride_v, |
| 158 const uint8* u_buf, | 156 src_u, src_stride_u, |
| 159 const uint8* v_buf, | 157 dst_abgr, dst_stride_abgr, |
| 160 uint8* rgb_buf, | 158 &kYvuIConstants, |
| 161 const struct YuvConstants* yuvconstants, | 159 width, height); |
| 162 int width) = I444ToABGRRow_C; | |
| 163 if (!src_y || !src_u || !src_v || | |
| 164 !dst_abgr || | |
| 165 width <= 0 || height == 0) { | |
| 166 return -1; | |
| 167 } | |
| 168 // Negative height means invert the image. | |
| 169 if (height < 0) { | |
| 170 height = -height; | |
| 171 dst_abgr = dst_abgr + (height - 1) * dst_stride_abgr; | |
| 172 dst_stride_abgr = -dst_stride_abgr; | |
| 173 } | |
| 174 // Coalesce rows. | |
| 175 if (src_stride_y == width && | |
| 176 src_stride_u == width && | |
| 177 src_stride_v == width && | |
| 178 dst_stride_abgr == width * 4) { | |
| 179 width *= height; | |
| 180 height = 1; | |
| 181 src_stride_y = src_stride_u = src_stride_v = dst_stride_abgr = 0; | |
| 182 } | |
| 183 #if defined(HAS_I444TOABGRROW_SSSE3) | |
| 184 if (TestCpuFlag(kCpuHasSSSE3)) { | |
| 185 I444ToABGRRow = I444ToABGRRow_Any_SSSE3; | |
| 186 if (IS_ALIGNED(width, 8)) { | |
| 187 I444ToABGRRow = I444ToABGRRow_SSSE3; | |
| 188 } | |
| 189 } | |
| 190 #endif | |
| 191 #if defined(HAS_I444TOABGRROW_AVX2) | |
| 192 if (TestCpuFlag(kCpuHasAVX2)) { | |
| 193 I444ToABGRRow = I444ToABGRRow_Any_AVX2; | |
| 194 if (IS_ALIGNED(width, 16)) { | |
| 195 I444ToABGRRow = I444ToABGRRow_AVX2; | |
| 196 } | |
| 197 } | |
| 198 #endif | |
| 199 #if defined(HAS_I444TOABGRROW_NEON) | |
| 200 if (TestCpuFlag(kCpuHasNEON)) { | |
| 201 I444ToABGRRow = I444ToABGRRow_Any_NEON; | |
| 202 if (IS_ALIGNED(width, 8)) { | |
| 203 I444ToABGRRow = I444ToABGRRow_NEON; | |
| 204 } | |
| 205 } | |
| 206 #endif | |
| 207 | |
| 208 for (y = 0; y < height; ++y) { | |
| 209 I444ToABGRRow(src_y, src_u, src_v, dst_abgr, &kYuvIConstants, width); | |
| 210 dst_abgr += dst_stride_abgr; | |
| 211 src_y += src_stride_y; | |
| 212 src_u += src_stride_u; | |
| 213 src_v += src_stride_v; | |
| 214 } | |
| 215 return 0; | |
| 216 } | 160 } |
| 217 | 161 |
| 218 // Convert I422 to ARGB. | 162 // Convert I422 to ARGB. |
| 219 LIBYUV_API | 163 LIBYUV_API |
| 220 int I422ToARGB(const uint8* src_y, int src_stride_y, | 164 int I422ToARGB(const uint8* src_y, int src_stride_y, |
| 221 const uint8* src_u, int src_stride_u, | 165 const uint8* src_u, int src_stride_u, |
| 222 const uint8* src_v, int src_stride_v, | 166 const uint8* src_v, int src_stride_v, |
| 223 uint8* dst_argb, int dst_stride_argb, | 167 uint8* dst_argb, int dst_stride_argb, |
| 224 int width, int height) { | 168 int width, int height) { |
| 225 int y; | 169 int y; |
| (...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 src_u += src_stride_u; | 1858 src_u += src_stride_u; |
| 1915 src_v += src_stride_v; | 1859 src_v += src_stride_v; |
| 1916 } | 1860 } |
| 1917 return 0; | 1861 return 0; |
| 1918 } | 1862 } |
| 1919 | 1863 |
| 1920 #ifdef __cplusplus | 1864 #ifdef __cplusplus |
| 1921 } // extern "C" | 1865 } // extern "C" |
| 1922 } // namespace libyuv | 1866 } // namespace libyuv |
| 1923 #endif | 1867 #endif |
| OLD | NEW |