| 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 "webkit/media/crypto/ppapi/libvpx_cdm_video_decoder.h" | 5 #include "webkit/media/crypto/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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 for (int i = 0; i < rows; ++i) { | 42 for (int i = 0; i < rows; ++i) { |
| 43 const int source_offset = i * source_stride; | 43 const int source_offset = i * source_stride; |
| 44 const int target_offset = i * target_stride; | 44 const int target_offset = i * target_stride; |
| 45 memcpy(target + target_offset, | 45 memcpy(target + target_offset, |
| 46 source + source_offset, | 46 source + source_offset, |
| 47 copy_bytes_per_row); | 47 copy_bytes_per_row); |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 | 50 |
| 51 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Allocator* allocator) | 51 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Host* host) |
| 52 : is_initialized_(false), | 52 : is_initialized_(false), |
| 53 allocator_(allocator), | 53 host_(host), |
| 54 vpx_codec_(NULL), | 54 vpx_codec_(NULL), |
| 55 vpx_image_(NULL) { | 55 vpx_image_(NULL) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 LibvpxCdmVideoDecoder::~LibvpxCdmVideoDecoder() { | 58 LibvpxCdmVideoDecoder::~LibvpxCdmVideoDecoder() { |
| 59 Deinitialize(); | 59 Deinitialize(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool LibvpxCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) { | 62 bool LibvpxCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) { |
| 63 DVLOG(1) << "Initialize()"; | 63 DVLOG(1) << "Initialize()"; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 DCHECK_EQ(vpx_image_->fmt, VPX_IMG_FMT_I420); | 166 DCHECK_EQ(vpx_image_->fmt, VPX_IMG_FMT_I420); |
| 167 DCHECK_EQ(vpx_image_->d_w % 2, 0U); | 167 DCHECK_EQ(vpx_image_->d_w % 2, 0U); |
| 168 DCHECK_EQ(vpx_image_->d_h % 2, 0U); | 168 DCHECK_EQ(vpx_image_->d_h % 2, 0U); |
| 169 | 169 |
| 170 #if defined(USE_COPYPLANE_WITH_LIBVPX) | 170 #if defined(USE_COPYPLANE_WITH_LIBVPX) |
| 171 const int y_size = vpx_image_->d_w * vpx_image_->d_h; | 171 const int y_size = vpx_image_->d_w * vpx_image_->d_h; |
| 172 const int uv_size = y_size / 2; | 172 const int uv_size = y_size / 2; |
| 173 const int space_required = y_size + (uv_size * 2); | 173 const int space_required = y_size + (uv_size * 2); |
| 174 | 174 |
| 175 DCHECK(!cdm_video_frame->FrameBuffer()); | 175 DCHECK(!cdm_video_frame->FrameBuffer()); |
| 176 cdm_video_frame->SetFrameBuffer(allocator_->Allocate(space_required)); | 176 cdm_video_frame->SetFrameBuffer(host_->Allocate(space_required)); |
| 177 if (!cdm_video_frame->FrameBuffer()) { | 177 if (!cdm_video_frame->FrameBuffer()) { |
| 178 LOG(ERROR) << "CopyVpxImageTo() cdm::Allocator::Allocate failed."; | 178 LOG(ERROR) << "CopyVpxImageTo() cdm::Host::Allocate failed."; |
| 179 return false; | 179 return false; |
| 180 } | 180 } |
| 181 cdm_video_frame->FrameBuffer()->SetSize(space_required); | 181 cdm_video_frame->FrameBuffer()->SetSize(space_required); |
| 182 | 182 |
| 183 CopyPlane(vpx_image_->planes[VPX_PLANE_Y], | 183 CopyPlane(vpx_image_->planes[VPX_PLANE_Y], |
| 184 vpx_image_->stride[VPX_PLANE_Y], | 184 vpx_image_->stride[VPX_PLANE_Y], |
| 185 vpx_image_->d_w, | 185 vpx_image_->d_w, |
| 186 vpx_image_->d_h, | 186 vpx_image_->d_h, |
| 187 vpx_image_->d_w, | 187 vpx_image_->d_w, |
| 188 cdm_video_frame->FrameBuffer()->Data()); | 188 cdm_video_frame->FrameBuffer()->Data()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 219 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, uv_stride); | 219 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, uv_stride); |
| 220 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, uv_stride); | 220 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, uv_stride); |
| 221 #else | 221 #else |
| 222 const int y_size = vpx_image_->stride[VPX_PLANE_Y] * vpx_image_->d_h; | 222 const int y_size = vpx_image_->stride[VPX_PLANE_Y] * vpx_image_->d_h; |
| 223 const int uv_rows = vpx_image_->d_h / 2; | 223 const int uv_rows = vpx_image_->d_h / 2; |
| 224 const int u_size = vpx_image_->stride[VPX_PLANE_U] * uv_rows; | 224 const int u_size = vpx_image_->stride[VPX_PLANE_U] * uv_rows; |
| 225 const int v_size = vpx_image_->stride[VPX_PLANE_V] * uv_rows; | 225 const int v_size = vpx_image_->stride[VPX_PLANE_V] * uv_rows; |
| 226 const int space_required = y_size + u_size + v_size; | 226 const int space_required = y_size + u_size + v_size; |
| 227 | 227 |
| 228 DCHECK(!cdm_video_frame->FrameBuffer()); | 228 DCHECK(!cdm_video_frame->FrameBuffer()); |
| 229 cdm_video_frame->SetFrameBuffer(allocator_->Allocate(space_required)); | 229 cdm_video_frame->SetFrameBuffer(host_->Allocate(space_required)); |
| 230 if (!cdm_video_frame->FrameBuffer()) { | 230 if (!cdm_video_frame->FrameBuffer()) { |
| 231 LOG(ERROR) << "CopyVpxImageTo() cdm::Allocator::Allocate failed."; | 231 LOG(ERROR) << "CopyVpxImageTo() cdm::Host::Allocate failed."; |
| 232 return false; | 232 return false; |
| 233 } | 233 } |
| 234 cdm_video_frame->FrameBuffer()->SetSize(space_required); | 234 cdm_video_frame->FrameBuffer()->SetSize(space_required); |
| 235 | 235 |
| 236 memcpy(cdm_video_frame->FrameBuffer()->Data(), | 236 memcpy(cdm_video_frame->FrameBuffer()->Data(), |
| 237 vpx_image_->planes[VPX_PLANE_Y], | 237 vpx_image_->planes[VPX_PLANE_Y], |
| 238 y_size); | 238 y_size); |
| 239 memcpy(cdm_video_frame->FrameBuffer()->Data() + y_size, | 239 memcpy(cdm_video_frame->FrameBuffer()->Data() + y_size, |
| 240 vpx_image_->planes[VPX_PLANE_U], | 240 vpx_image_->planes[VPX_PLANE_U], |
| 241 u_size); | 241 u_size); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 260 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, | 260 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, |
| 261 vpx_image_->stride[VPX_PLANE_U]); | 261 vpx_image_->stride[VPX_PLANE_U]); |
| 262 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, | 262 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, |
| 263 vpx_image_->stride[VPX_PLANE_V]); | 263 vpx_image_->stride[VPX_PLANE_V]); |
| 264 #endif // USE_COPYPLANE_WITH_LIBVPX | 264 #endif // USE_COPYPLANE_WITH_LIBVPX |
| 265 | 265 |
| 266 return true; | 266 return true; |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace webkit_media | 269 } // namespace webkit_media |
| OLD | NEW |