Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "webkit/renderer/media/crypto/ppapi/libvpx_cdm_video_decoder.h" | 5 #include "media/cdm/ppapi/libvpx_cdm_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
| 10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
| 11 | 11 |
| 12 // Include libvpx header files. | 12 // Include libvpx header files. |
| 13 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide | 13 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide |
| 14 // backwards compatibility for legacy applications using the library. | 14 // backwards compatibility for legacy applications using the library. |
| 15 #define VPX_CODEC_DISABLE_COMPAT 1 | 15 #define VPX_CODEC_DISABLE_COMPAT 1 |
| 16 extern "C" { | 16 extern "C" { |
| 17 // Note: vpx_decoder.h must be first or compile will fail. | |
|
ddorwin
2013/08/09 01:10:38
Should we file a bug against libvpx for IWYU?
DaleCurtis
2013/08/09 18:29:38
Filed https://code.google.com/p/webm/issues/detail
| |
| 18 #include "third_party/libvpx/source/libvpx/vpx/vpx_decoder.h" // NOLINT | |
| 17 #include "third_party/libvpx/source/libvpx/vpx/vp8dx.h" | 19 #include "third_party/libvpx/source/libvpx/vpx/vp8dx.h" |
| 18 #include "third_party/libvpx/source/libvpx/vpx/vpx_decoder.h" | |
| 19 } | 20 } |
| 20 | 21 |
| 21 #include "webkit/renderer/media/crypto/ppapi/cdm/content_decryption_module.h" | |
| 22 | |
| 23 // Enable USE_COPYPLANE_WITH_LIBVPX to use |CopyPlane()| instead of memcpy to | 22 // Enable USE_COPYPLANE_WITH_LIBVPX to use |CopyPlane()| instead of memcpy to |
| 24 // copy video frame data. | 23 // copy video frame data. |
| 25 // #define USE_COPYPLANE_WITH_LIBVPX 1 | 24 // #define USE_COPYPLANE_WITH_LIBVPX 1 |
| 26 | 25 |
| 27 namespace webkit_media { | 26 namespace media { |
| 28 | 27 |
| 29 static const int kDecodeThreads = 2; | 28 static const int kDecodeThreads = 2; |
| 30 | 29 |
| 31 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Host* host) | 30 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Host* host) |
| 32 : is_initialized_(false), | 31 : is_initialized_(false), |
| 33 host_(host), | 32 host_(host), |
| 34 vpx_codec_(NULL), | 33 vpx_codec_(NULL), |
| 35 vpx_image_(NULL) { | 34 vpx_image_(NULL) { |
| 36 } | 35 } |
| 37 | 36 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 void LibvpxCdmVideoDecoder::Reset() { | 86 void LibvpxCdmVideoDecoder::Reset() { |
| 88 DVLOG(1) << "Reset()"; | 87 DVLOG(1) << "Reset()"; |
| 89 } | 88 } |
| 90 | 89 |
| 91 // static | 90 // static |
| 92 bool LibvpxCdmVideoDecoder::IsValidOutputConfig(cdm::VideoFormat format, | 91 bool LibvpxCdmVideoDecoder::IsValidOutputConfig(cdm::VideoFormat format, |
| 93 const cdm::Size& data_size) { | 92 const cdm::Size& data_size) { |
| 94 return ((format == cdm::kYv12 || format == cdm::kI420) && | 93 return ((format == cdm::kYv12 || format == cdm::kI420) && |
| 95 (data_size.width % 2) == 0 && (data_size.height % 2) == 0 && | 94 (data_size.width % 2) == 0 && (data_size.height % 2) == 0 && |
| 96 data_size.width > 0 && data_size.height > 0 && | 95 data_size.width > 0 && data_size.height > 0 && |
| 97 data_size.width <= media::limits::kMaxDimension && | 96 data_size.width <= limits::kMaxDimension && |
| 98 data_size.height <= media::limits::kMaxDimension && | 97 data_size.height <= limits::kMaxDimension && |
| 99 data_size.width * data_size.height <= media::limits::kMaxCanvas); | 98 data_size.width * data_size.height <= limits::kMaxCanvas); |
| 100 } | 99 } |
| 101 | 100 |
| 102 cdm::Status LibvpxCdmVideoDecoder::DecodeFrame( | 101 cdm::Status LibvpxCdmVideoDecoder::DecodeFrame( |
| 103 const uint8_t* compressed_frame, | 102 const uint8_t* compressed_frame, |
| 104 int32_t compressed_frame_size, | 103 int32_t compressed_frame_size, |
| 105 int64_t timestamp, | 104 int64_t timestamp, |
| 106 cdm::VideoFrame* decoded_frame) { | 105 cdm::VideoFrame* decoded_frame) { |
| 107 DVLOG(1) << "DecodeFrame()"; | 106 DVLOG(1) << "DecodeFrame()"; |
| 108 DCHECK(decoded_frame); | 107 DCHECK(decoded_frame); |
| 109 | 108 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 cdm_video_frame->SetStride(cdm::VideoFrame::kYPlane, | 185 cdm_video_frame->SetStride(cdm::VideoFrame::kYPlane, |
| 187 vpx_image_->stride[VPX_PLANE_Y]); | 186 vpx_image_->stride[VPX_PLANE_Y]); |
| 188 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, | 187 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, |
| 189 vpx_image_->stride[VPX_PLANE_U]); | 188 vpx_image_->stride[VPX_PLANE_U]); |
| 190 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, | 189 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, |
| 191 vpx_image_->stride[VPX_PLANE_V]); | 190 vpx_image_->stride[VPX_PLANE_V]); |
| 192 | 191 |
| 193 return true; | 192 return true; |
| 194 } | 193 } |
| 195 | 194 |
| 196 } // namespace webkit_media | 195 } // namespace media |
| OLD | NEW |