Chromium Code Reviews| 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 #include "media/filters/vpx_video_decoder.h" | 5 #include "media/filters/vpx_video_decoder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 // Default to the color space from the config, but if the bistream specifies | 578 // Default to the color space from the config, but if the bistream specifies |
| 579 // one, prefer that instead. | 579 // one, prefer that instead. |
| 580 ColorSpace color_space = config_.color_space(); | 580 ColorSpace color_space = config_.color_space(); |
| 581 if (vpx_image->cs == VPX_CS_BT_709) | 581 if (vpx_image->cs == VPX_CS_BT_709) |
| 582 color_space = COLOR_SPACE_HD_REC709; | 582 color_space = COLOR_SPACE_HD_REC709; |
| 583 else if (vpx_image->cs == VPX_CS_BT_601 || vpx_image->cs == VPX_CS_SMPTE_170) | 583 else if (vpx_image->cs == VPX_CS_BT_601 || vpx_image->cs == VPX_CS_SMPTE_170) |
| 584 color_space = COLOR_SPACE_SD_REC601; | 584 color_space = COLOR_SPACE_SD_REC601; |
| 585 (*video_frame) | 585 (*video_frame) |
| 586 ->metadata() | 586 ->metadata() |
| 587 ->SetInteger(VideoFrameMetadata::COLOR_SPACE, color_space); | 587 ->SetInteger(VideoFrameMetadata::COLOR_SPACE, color_space); |
| 588 | |
| 589 gfx::ColorSpace::PrimaryID primaries = | |
| 590 gfx::ColorSpace::PrimaryID::UNSPECIFIED; | |
| 591 gfx::ColorSpace::TransferID transfer = | |
| 592 gfx::ColorSpace::TransferID::UNSPECIFIED; | |
| 593 gfx::ColorSpace::MatrixID matrix = gfx::ColorSpace::MatrixID::UNSPECIFIED; | |
| 594 gfx::ColorSpace::RangeID range = vpx_image->range == VPX_CR_FULL_RANGE | |
| 595 ? gfx::ColorSpace::RangeID::FULL | |
| 596 : gfx::ColorSpace::RangeID::LIMITED; | |
| 597 | |
| 598 switch (vpx_image->cs) { | |
|
DaleCurtis
2016/08/16 18:58:03
Worth caching?
hubbe
2016/08/16 19:24:57
No, gfx::ColorSpace is super-lightweight unless yo
| |
| 599 case VPX_CS_BT_601: | |
| 600 case VPX_CS_SMPTE_170: | |
| 601 primaries = gfx::ColorSpace::PrimaryID::SMPTE170M; | |
| 602 transfer = gfx::ColorSpace::TransferID::SMPTE170M; | |
| 603 matrix = gfx::ColorSpace::MatrixID::SMPTE170M; | |
| 604 break; | |
| 605 case VPX_CS_SMPTE_240: | |
| 606 primaries = gfx::ColorSpace::PrimaryID::SMPTE240M; | |
| 607 transfer = gfx::ColorSpace::TransferID::SMPTE240M; | |
| 608 matrix = gfx::ColorSpace::MatrixID::SMPTE240M; | |
| 609 break; | |
| 610 case VPX_CS_BT_709: | |
| 611 primaries = gfx::ColorSpace::PrimaryID::BT709; | |
| 612 transfer = gfx::ColorSpace::TransferID::BT709; | |
| 613 matrix = gfx::ColorSpace::MatrixID::BT709; | |
| 614 break; | |
| 615 case VPX_CS_BT_2020: | |
| 616 primaries = gfx::ColorSpace::PrimaryID::BT2020; | |
| 617 if (vpx_image->bit_depth >= 12) { | |
| 618 transfer = gfx::ColorSpace::TransferID::BT2020_12; | |
| 619 } else if (vpx_image->bit_depth >= 10) { | |
| 620 transfer = gfx::ColorSpace::TransferID::BT2020_10; | |
| 621 } else { | |
| 622 transfer = gfx::ColorSpace::TransferID::BT709; | |
| 623 } | |
| 624 matrix = gfx::ColorSpace::MatrixID::BT2020_NCL; // is this right? | |
| 625 break; | |
| 626 case VPX_CS_SRGB: | |
| 627 primaries = gfx::ColorSpace::PrimaryID::BT709; | |
| 628 transfer = gfx::ColorSpace::TransferID::IEC61966_2_1; | |
| 629 matrix = gfx::ColorSpace::MatrixID::BT709; | |
| 630 break; | |
| 631 | |
| 632 default: | |
| 633 break; | |
| 634 } | |
| 635 | |
| 636 if (primaries != gfx::ColorSpace::PrimaryID::UNSPECIFIED) { | |
| 637 (*video_frame) | |
| 638 ->set_color_space(gfx::ColorSpace(primaries, transfer, matrix, range)); | |
| 639 } | |
| 640 | |
| 588 return true; | 641 return true; |
| 589 } | 642 } |
| 590 | 643 |
| 591 VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane( | 644 VpxVideoDecoder::AlphaDecodeStatus VpxVideoDecoder::DecodeAlphaPlane( |
| 592 const struct vpx_image* vpx_image, | 645 const struct vpx_image* vpx_image, |
| 593 const struct vpx_image** vpx_image_alpha, | 646 const struct vpx_image** vpx_image_alpha, |
| 594 const scoped_refptr<DecoderBuffer>& buffer) { | 647 const scoped_refptr<DecoderBuffer>& buffer) { |
| 595 if (!vpx_codec_alpha_ || buffer->side_data_size() < 8) { | 648 if (!vpx_codec_alpha_ || buffer->side_data_size() < 8) { |
| 596 return kAlphaPlaneProcessed; | 649 return kAlphaPlaneProcessed; |
| 597 } | 650 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 731 (*video_frame)->visible_data(VideoFrame::kUPlane), | 784 (*video_frame)->visible_data(VideoFrame::kUPlane), |
| 732 (*video_frame)->stride(VideoFrame::kUPlane), | 785 (*video_frame)->stride(VideoFrame::kUPlane), |
| 733 (*video_frame)->visible_data(VideoFrame::kVPlane), | 786 (*video_frame)->visible_data(VideoFrame::kVPlane), |
| 734 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), | 787 (*video_frame)->stride(VideoFrame::kVPlane), coded_size.width(), |
| 735 coded_size.height()); | 788 coded_size.height()); |
| 736 | 789 |
| 737 return true; | 790 return true; |
| 738 } | 791 } |
| 739 | 792 |
| 740 } // namespace media | 793 } // namespace media |
| OLD | NEW |