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

Side by Side Diff: webkit/media/crypto/ppapi/libvpx_cdm_video_decoder.cc

Issue 12212079: Update Cdm Wrapper and ClearKeyCdm to work with CDM interface version 4. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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
« no previous file with comments | « webkit/media/crypto/ppapi/libvpx_cdm_video_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 for (int i = 0; i < rows; ++i) { 43 for (int i = 0; i < rows; ++i) {
44 const int source_offset = i * source_stride; 44 const int source_offset = i * source_stride;
45 const int target_offset = i * target_stride; 45 const int target_offset = i * target_stride;
46 memcpy(target + target_offset, 46 memcpy(target + target_offset,
47 source + source_offset, 47 source + source_offset,
48 copy_bytes_per_row); 48 copy_bytes_per_row);
49 } 49 }
50 } 50 }
51 #endif // USE_COPYPLANE_WITH_LIBVPX 51 #endif // USE_COPYPLANE_WITH_LIBVPX
52 52
53 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Allocator* allocator) 53 LibvpxCdmVideoDecoder::LibvpxCdmVideoDecoder(cdm::Host* host)
54 : is_initialized_(false), 54 : is_initialized_(false),
55 allocator_(allocator), 55 host_(host),
56 vpx_codec_(NULL), 56 vpx_codec_(NULL),
57 vpx_image_(NULL) { 57 vpx_image_(NULL) {
58 } 58 }
59 59
60 LibvpxCdmVideoDecoder::~LibvpxCdmVideoDecoder() { 60 LibvpxCdmVideoDecoder::~LibvpxCdmVideoDecoder() {
61 Deinitialize(); 61 Deinitialize();
62 } 62 }
63 63
64 bool LibvpxCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) { 64 bool LibvpxCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) {
65 DVLOG(1) << "Initialize()"; 65 DVLOG(1) << "Initialize()";
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 DCHECK_EQ(vpx_image_->fmt, VPX_IMG_FMT_I420); 168 DCHECK_EQ(vpx_image_->fmt, VPX_IMG_FMT_I420);
169 DCHECK_EQ(vpx_image_->d_w % 2, 0U); 169 DCHECK_EQ(vpx_image_->d_w % 2, 0U);
170 DCHECK_EQ(vpx_image_->d_h % 2, 0U); 170 DCHECK_EQ(vpx_image_->d_h % 2, 0U);
171 171
172 #if defined(USE_COPYPLANE_WITH_LIBVPX) 172 #if defined(USE_COPYPLANE_WITH_LIBVPX)
173 const int y_size = vpx_image_->d_w * vpx_image_->d_h; 173 const int y_size = vpx_image_->d_w * vpx_image_->d_h;
174 const int uv_size = y_size / 2; 174 const int uv_size = y_size / 2;
175 const int space_required = y_size + (uv_size * 2); 175 const int space_required = y_size + (uv_size * 2);
176 176
177 DCHECK(!cdm_video_frame->FrameBuffer()); 177 DCHECK(!cdm_video_frame->FrameBuffer());
178 cdm_video_frame->SetFrameBuffer(allocator_->Allocate(space_required)); 178 cdm_video_frame->SetFrameBuffer(host_->Allocate(space_required));
179 if (!cdm_video_frame->FrameBuffer()) { 179 if (!cdm_video_frame->FrameBuffer()) {
180 LOG(ERROR) << "CopyVpxImageTo() cdm::Allocator::Allocate failed."; 180 LOG(ERROR) << "CopyVpxImageTo() cdm::Host::Allocate failed.";
181 return false; 181 return false;
182 } 182 }
183 cdm_video_frame->FrameBuffer()->SetSize(space_required); 183 cdm_video_frame->FrameBuffer()->SetSize(space_required);
184 184
185 CopyPlane(vpx_image_->planes[VPX_PLANE_Y], 185 CopyPlane(vpx_image_->planes[VPX_PLANE_Y],
186 vpx_image_->stride[VPX_PLANE_Y], 186 vpx_image_->stride[VPX_PLANE_Y],
187 vpx_image_->d_w, 187 vpx_image_->d_w,
188 vpx_image_->d_h, 188 vpx_image_->d_h,
189 vpx_image_->d_w, 189 vpx_image_->d_w,
190 cdm_video_frame->FrameBuffer()->Data()); 190 cdm_video_frame->FrameBuffer()->Data());
(...skipping 30 matching lines...) Expand all
221 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, uv_stride); 221 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, uv_stride);
222 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, uv_stride); 222 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, uv_stride);
223 #else 223 #else
224 const int y_size = vpx_image_->stride[VPX_PLANE_Y] * vpx_image_->d_h; 224 const int y_size = vpx_image_->stride[VPX_PLANE_Y] * vpx_image_->d_h;
225 const int uv_rows = vpx_image_->d_h / 2; 225 const int uv_rows = vpx_image_->d_h / 2;
226 const int u_size = vpx_image_->stride[VPX_PLANE_U] * uv_rows; 226 const int u_size = vpx_image_->stride[VPX_PLANE_U] * uv_rows;
227 const int v_size = vpx_image_->stride[VPX_PLANE_V] * uv_rows; 227 const int v_size = vpx_image_->stride[VPX_PLANE_V] * uv_rows;
228 const int space_required = y_size + u_size + v_size; 228 const int space_required = y_size + u_size + v_size;
229 229
230 DCHECK(!cdm_video_frame->FrameBuffer()); 230 DCHECK(!cdm_video_frame->FrameBuffer());
231 cdm_video_frame->SetFrameBuffer(allocator_->Allocate(space_required)); 231 cdm_video_frame->SetFrameBuffer(host_->Allocate(space_required));
232 if (!cdm_video_frame->FrameBuffer()) { 232 if (!cdm_video_frame->FrameBuffer()) {
233 LOG(ERROR) << "CopyVpxImageTo() cdm::Allocator::Allocate failed."; 233 LOG(ERROR) << "CopyVpxImageTo() cdm::Host::Allocate failed.";
234 return false; 234 return false;
235 } 235 }
236 cdm_video_frame->FrameBuffer()->SetSize(space_required); 236 cdm_video_frame->FrameBuffer()->SetSize(space_required);
237 237
238 memcpy(cdm_video_frame->FrameBuffer()->Data(), 238 memcpy(cdm_video_frame->FrameBuffer()->Data(),
239 vpx_image_->planes[VPX_PLANE_Y], 239 vpx_image_->planes[VPX_PLANE_Y],
240 y_size); 240 y_size);
241 memcpy(cdm_video_frame->FrameBuffer()->Data() + y_size, 241 memcpy(cdm_video_frame->FrameBuffer()->Data() + y_size,
242 vpx_image_->planes[VPX_PLANE_U], 242 vpx_image_->planes[VPX_PLANE_U],
243 u_size); 243 u_size);
(...skipping 18 matching lines...) Expand all
262 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane, 262 cdm_video_frame->SetStride(cdm::VideoFrame::kUPlane,
263 vpx_image_->stride[VPX_PLANE_U]); 263 vpx_image_->stride[VPX_PLANE_U]);
264 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane, 264 cdm_video_frame->SetStride(cdm::VideoFrame::kVPlane,
265 vpx_image_->stride[VPX_PLANE_V]); 265 vpx_image_->stride[VPX_PLANE_V]);
266 #endif // USE_COPYPLANE_WITH_LIBVPX 266 #endif // USE_COPYPLANE_WITH_LIBVPX
267 267
268 return true; 268 return true;
269 } 269 }
270 270
271 } // namespace webkit_media 271 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/crypto/ppapi/libvpx_cdm_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698