OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 uint8* uplane, | 436 uint8* uplane, |
437 uint8* vplane, | 437 uint8* vplane, |
438 int width, | 438 int width, |
439 int height, | 439 int height, |
440 int rgbstride, | 440 int rgbstride, |
441 int ystride, | 441 int ystride, |
442 int uvstride) { | 442 int uvstride) { |
443 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, | 443 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, |
444 int, int, int, int, int) = NULL; | 444 int, int, int, int, int) = NULL; |
445 if (!convert_proc) { | 445 if (!convert_proc) { |
446 #if defined(ARCH_CPU_ARM_FAMILY) | 446 #if defined(ARCH_CPU_ARM_FAMILY) |
scherkus (not reviewing)
2012/09/19 16:57:54
instead of #elif can you use "|| defined(ARCH_CPU_
petarj
2012/09/20 00:18:25
Done.
| |
447 // For ARM processors, always use C version. | 447 // For ARM processors, always use C version. |
448 // TODO(hclam): Implement a NEON version. | 448 // TODO(hclam): Implement a NEON version. |
449 convert_proc = &ConvertRGB32ToYUV_C; | 449 convert_proc = &ConvertRGB32ToYUV_C; |
450 #elif defined(ARCH_CPU_MIPS_FAMILY) | |
451 // For MIPS processors, always use C version. | |
452 convert_proc = &ConvertRGB32ToYUV_C; | |
450 #else | 453 #else |
451 // TODO(hclam): Switch to SSSE3 version when the cyan problem is solved. | 454 // TODO(hclam): Switch to SSSE3 version when the cyan problem is solved. |
452 // See: crbug.com/100462 | 455 // See: crbug.com/100462 |
453 base::CPU cpu; | 456 base::CPU cpu; |
454 if (cpu.has_sse2()) | 457 if (cpu.has_sse2()) |
455 convert_proc = &ConvertRGB32ToYUV_SSE2; | 458 convert_proc = &ConvertRGB32ToYUV_SSE2; |
456 else | 459 else |
457 convert_proc = &ConvertRGB32ToYUV_C; | 460 convert_proc = &ConvertRGB32ToYUV_C; |
458 #endif | 461 #endif |
459 } | 462 } |
460 | 463 |
461 convert_proc(rgbframe, yplane, uplane, vplane, width, height, | 464 convert_proc(rgbframe, yplane, uplane, vplane, width, height, |
462 rgbstride, ystride, uvstride); | 465 rgbstride, ystride, uvstride); |
463 } | 466 } |
464 | 467 |
465 void ConvertRGB24ToYUV(const uint8* rgbframe, | 468 void ConvertRGB24ToYUV(const uint8* rgbframe, |
466 uint8* yplane, | 469 uint8* yplane, |
467 uint8* uplane, | 470 uint8* uplane, |
468 uint8* vplane, | 471 uint8* vplane, |
469 int width, | 472 int width, |
470 int height, | 473 int height, |
471 int rgbstride, | 474 int rgbstride, |
472 int ystride, | 475 int ystride, |
473 int uvstride) { | 476 int uvstride) { |
474 #if defined(ARCH_CPU_ARM_FAMILY) | 477 #if defined(ARCH_CPU_ARM_FAMILY) |
475 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, | 478 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, |
scherkus (not reviewing)
2012/09/19 16:57:54
ditto
petarj
2012/09/20 00:18:25
Done.
| |
476 rgbstride, ystride, uvstride); | 479 rgbstride, ystride, uvstride); |
480 #elif defined(ARCH_CPU_MIPS_FAMILY) | |
481 ConvertRGB24ToYUV_C(rgbframe, yplane, uplane, vplane, width, height, | |
482 rgbstride, ystride, uvstride); | |
477 #else | 483 #else |
478 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, | 484 static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, |
479 int, int, int, int, int) = NULL; | 485 int, int, int, int, int) = NULL; |
480 if (!convert_proc) { | 486 if (!convert_proc) { |
481 base::CPU cpu; | 487 base::CPU cpu; |
482 if (cpu.has_ssse3()) | 488 if (cpu.has_ssse3()) |
483 convert_proc = &ConvertRGB24ToYUV_SSSE3; | 489 convert_proc = &ConvertRGB24ToYUV_SSSE3; |
484 else | 490 else |
485 convert_proc = &ConvertRGB24ToYUV_C; | 491 convert_proc = &ConvertRGB24ToYUV_C; |
486 } | 492 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
536 const uint8* uplane, | 542 const uint8* uplane, |
537 const uint8* vplane, | 543 const uint8* vplane, |
538 uint8* rgbframe, | 544 uint8* rgbframe, |
539 int width, | 545 int width, |
540 int height, | 546 int height, |
541 int ystride, | 547 int ystride, |
542 int uvstride, | 548 int uvstride, |
543 int rgbstride, | 549 int rgbstride, |
544 YUVType yuv_type) { | 550 YUVType yuv_type) { |
545 #if defined(ARCH_CPU_ARM_FAMILY) | 551 #if defined(ARCH_CPU_ARM_FAMILY) |
546 ConvertYUVToRGB32_C(yplane, uplane, vplane, rgbframe, | 552 ConvertYUVToRGB32_C(yplane, uplane, vplane, rgbframe, |
scherkus (not reviewing)
2012/09/19 16:57:54
ditto
petarj
2012/09/20 00:18:25
Done.
| |
547 width, height, ystride, uvstride, rgbstride, yuv_type); | 553 width, height, ystride, uvstride, rgbstride, yuv_type); |
554 #elif defined(ARCH_CPU_MIPS_FAMILY) | |
555 ConvertYUVToRGB32_C(yplane, uplane, vplane, rgbframe, | |
556 width, height, ystride, uvstride, rgbstride, yuv_type); | |
548 #else | 557 #else |
549 static ConvertYUVToRGB32Proc convert_proc = NULL; | 558 static ConvertYUVToRGB32Proc convert_proc = NULL; |
550 if (!convert_proc) { | 559 if (!convert_proc) { |
551 base::CPU cpu; | 560 base::CPU cpu; |
552 if (cpu.has_sse()) | 561 if (cpu.has_sse()) |
553 convert_proc = &ConvertYUVToRGB32_SSE; | 562 convert_proc = &ConvertYUVToRGB32_SSE; |
554 else if (cpu.has_mmx()) | 563 else if (cpu.has_mmx()) |
555 convert_proc = &ConvertYUVToRGB32_MMX; | 564 convert_proc = &ConvertYUVToRGB32_MMX; |
556 else | 565 else |
557 convert_proc = &ConvertYUVToRGB32_C; | 566 convert_proc = &ConvertYUVToRGB32_C; |
558 } | 567 } |
559 | 568 |
560 convert_proc(yplane, uplane, vplane, rgbframe, | 569 convert_proc(yplane, uplane, vplane, rgbframe, |
561 width, height, ystride, uvstride, rgbstride, yuv_type); | 570 width, height, ystride, uvstride, rgbstride, yuv_type); |
562 #endif | 571 #endif |
563 } | 572 } |
564 | 573 |
565 } // namespace media | 574 } // namespace media |
OLD | NEW |