Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: media/base/yuv_convert.cc

Issue 7003082: Implements RGB to YV12 conversion in YASM. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This webpage shows layout of YV12 and other YUV formats 5 // This webpage shows layout of YV12 and other YUV formats
6 // http://www.fourcc.org/yuv.php 6 // http://www.fourcc.org/yuv.php
7 // The actual conversion is best described here 7 // The actual conversion is best described here
8 // http://en.wikipedia.org/wiki/YUV 8 // http://en.wikipedia.org/wiki/YUV
9 // An article on optimizing YUV conversion using tables instead of multiplies 9 // An article on optimizing YUV conversion using tables instead of multiplies
10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf 10 // http://lestourtereaux.free.fr/papers/data/yuvrgb.pdf
11 // 11 //
12 // YV12 is a full plane of Y and a half height, half width chroma planes 12 // YV12 is a full plane of Y and a half height, half width chroma planes
13 // YV16 is a full plane of Y and a full height, half width chroma planes 13 // YV16 is a full plane of Y and a full height, half width chroma planes
14 // 14 //
15 // ARGB pixel format is output, which on little endian is stored as BGRA. 15 // ARGB pixel format is output, which on little endian is stored as BGRA.
16 // The alpha is set to 255, allowing the application to use RGBA or RGB32. 16 // The alpha is set to 255, allowing the application to use RGBA or RGB32.
17 17
18 #include "media/base/yuv_convert.h" 18 #include "media/base/yuv_convert.h"
19 19
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 #include "media/base/cpu_features.h" 21 #include "media/base/cpu_features.h"
22 #include "media/base/simd/convert_rgb_to_yuv.h"
23 #include "media/base/simd/convert_yuv_to_rgb.h"
22 #include "media/base/yuv_convert_internal.h" 24 #include "media/base/yuv_convert_internal.h"
23 #include "media/base/yuv_row.h" 25 #include "media/base/yuv_row.h"
24 26
25 #if USE_MMX 27 #if USE_MMX
26 #if defined(_MSC_VER) 28 #if defined(_MSC_VER)
27 #include <intrin.h> 29 #include <intrin.h>
28 #else 30 #else
29 #include <mmintrin.h> 31 #include <mmintrin.h>
30 #endif 32 #endif
31 #endif 33 #endif
(...skipping 13 matching lines...) Expand all
45 void ConvertYUVToRGB32(const uint8* y_buf, 47 void ConvertYUVToRGB32(const uint8* y_buf,
46 const uint8* u_buf, 48 const uint8* u_buf,
47 const uint8* v_buf, 49 const uint8* v_buf,
48 uint8* rgb_buf, 50 uint8* rgb_buf,
49 int width, 51 int width,
50 int height, 52 int height,
51 int y_pitch, 53 int y_pitch,
52 int uv_pitch, 54 int uv_pitch,
53 int rgb_pitch, 55 int rgb_pitch,
54 YUVType yuv_type) { 56 YUVType yuv_type) {
57 if (hasSSSE3()) {
58 simd::ConvertYUVtoRGB32(y_buf, u_buf, v_buf, rgb_buf, width, height,
59 y_pitch, uv_pitch, rgb_pitch, yuv_type);
60 return;
61 }
62
Alpha Left Google 2011/09/01 13:24:45 Add a comment here that we use the MMX version as
55 unsigned int y_shift = yuv_type; 63 unsigned int y_shift = yuv_type;
56 for (int y = 0; y < height; ++y) { 64 for (int y = 0; y < height; ++y) {
57 uint8* rgb_row = rgb_buf + y * rgb_pitch; 65 uint8* rgb_row = rgb_buf + y * rgb_pitch;
58 const uint8* y_ptr = y_buf + y * y_pitch; 66 const uint8* y_ptr = y_buf + y * y_pitch;
59 const uint8* u_ptr = u_buf + (y >> y_shift) * uv_pitch; 67 const uint8* u_ptr = u_buf + (y >> y_shift) * uv_pitch;
60 const uint8* v_ptr = v_buf + (y >> y_shift) * uv_pitch; 68 const uint8* v_ptr = v_buf + (y >> y_shift) * uv_pitch;
61 69
62 FastConvertYUVToRGB32Row(y_ptr, 70 FastConvertYUVToRGB32Row(y_ptr,
63 u_ptr, 71 u_ptr,
64 v_ptr, 72 v_ptr,
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 int ystride, 367 int ystride,
360 int uvstride) { 368 int uvstride) {
361 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, 369 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*,
362 int, int, int, int, int) = NULL; 370 int, int, int, int, int) = NULL;
363 if (!convert_proc) { 371 if (!convert_proc) {
364 #if defined(ARCH_CPU_ARM_FAMILY) 372 #if defined(ARCH_CPU_ARM_FAMILY)
365 // For ARM processors, always use C version. 373 // For ARM processors, always use C version.
366 // TODO(hclam): Implement a NEON version. 374 // TODO(hclam): Implement a NEON version.
367 convert_proc = &ConvertRGB32ToYUV_C; 375 convert_proc = &ConvertRGB32ToYUV_C;
368 #else 376 #else
369 // For x86 processors, check if SSE2 is supported. 377 // For x86 processors, check if SSSE3 (or SSE2) is supported.
370 if (hasSSE2()) 378 if (hasSSSE3())
379 convert_proc = &simd::ConvertRGB32toYUV;
380 else if (hasSSE2())
371 convert_proc = &ConvertRGB32ToYUV_SSE2; 381 convert_proc = &ConvertRGB32ToYUV_SSE2;
372 else 382 else
373 convert_proc = &ConvertRGB32ToYUV_C; 383 convert_proc = &ConvertRGB32ToYUV_C;
374 #endif 384 #endif
375 } 385 }
376 386
377 convert_proc(rgbframe, yplane, uplane, vplane, width, height, 387 convert_proc(rgbframe, yplane, uplane, vplane, width, height,
378 rgbstride, ystride, uvstride); 388 rgbstride, ystride, uvstride);
379 } 389 }
380 390
381 void ConvertRGB24ToYUV(const uint8* rgbframe, 391 void ConvertRGB24ToYUV(const uint8* rgbframe,
382 uint8* yplane, 392 uint8* yplane,
383 uint8* uplane, 393 uint8* uplane,
384 uint8* vplane, 394 uint8* vplane,
385 int width, 395 int width,
386 int height, 396 int height,
387 int rgbstride, 397 int rgbstride,
388 int ystride, 398 int ystride,
389 int uvstride) { 399 int uvstride) {
400 #if defined(ARCH_CPU_ARM_FAMILY)
390 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, 401 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height,
391 rgbstride, ystride, uvstride); 402 rgbstride, ystride, uvstride);
403 #else
404 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*,
405 int, int, int, int, int) = NULL;
406 if (!convert_proc) {
407 if (hasSSSE3())
408 convert_proc = &simd::ConvertRGB24toYUV;
409 else
410 convert_proc = & ConvertRGB24ToYUV_C;
411 }
412 convert_proc(rgbframe, yplane, uplane, vplane, width, height,
413 rgbstride, ystride, uvstride);
414 #endif
392 } 415 }
393 416
394 void ConvertYUY2ToYUV(const uint8* src, 417 void ConvertYUY2ToYUV(const uint8* src,
395 uint8* yplane, 418 uint8* yplane,
396 uint8* uplane, 419 uint8* uplane,
397 uint8* vplane, 420 uint8* vplane,
398 int width, 421 int width,
399 int height) { 422 int height) {
400 ConvertYUY2ToYUV_C(src, yplane, uplane, vplane, width, height); 423 ConvertYUY2ToYUV_C(src, yplane, uplane, vplane, width, height);
401 } 424 }
402 } // namespace media 425 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698