| 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/ffmpeg_cdm_video_decoder.h" | 5 #include "webkit/media/crypto/ppapi/ffmpeg_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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 for (int i = 0; i < rows; ++i) { | 122 for (int i = 0; i < rows; ++i) { |
| 123 const int source_offset = i * source_stride; | 123 const int source_offset = i * source_stride; |
| 124 const int target_offset = i * target_stride; | 124 const int target_offset = i * target_stride; |
| 125 memcpy(target + target_offset, | 125 memcpy(target + target_offset, |
| 126 source + source_offset, | 126 source + source_offset, |
| 127 copy_bytes_per_row); | 127 copy_bytes_per_row); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 FFmpegCdmVideoDecoder::FFmpegCdmVideoDecoder(cdm::Allocator* allocator) | 131 FFmpegCdmVideoDecoder::FFmpegCdmVideoDecoder(cdm::Host* host) |
| 132 : codec_context_(NULL), | 132 : codec_context_(NULL), |
| 133 av_frame_(NULL), | 133 av_frame_(NULL), |
| 134 is_initialized_(false), | 134 is_initialized_(false), |
| 135 allocator_(allocator) { | 135 host_(host) { |
| 136 } | 136 } |
| 137 | 137 |
| 138 FFmpegCdmVideoDecoder::~FFmpegCdmVideoDecoder() { | 138 FFmpegCdmVideoDecoder::~FFmpegCdmVideoDecoder() { |
| 139 ReleaseFFmpegResources(); | 139 ReleaseFFmpegResources(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool FFmpegCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) { | 142 bool FFmpegCdmVideoDecoder::Initialize(const cdm::VideoDecoderConfig& config) { |
| 143 DVLOG(1) << "Initialize()"; | 143 DVLOG(1) << "Initialize()"; |
| 144 | 144 |
| 145 if (!IsValidOutputConfig(config.format, config.coded_size)) { | 145 if (!IsValidOutputConfig(config.format, config.coded_size)) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 DCHECK(cdm_video_frame); | 268 DCHECK(cdm_video_frame); |
| 269 DCHECK_EQ(av_frame_->format, PIX_FMT_YUV420P); | 269 DCHECK_EQ(av_frame_->format, PIX_FMT_YUV420P); |
| 270 DCHECK_EQ(av_frame_->width % 2, 0); | 270 DCHECK_EQ(av_frame_->width % 2, 0); |
| 271 DCHECK_EQ(av_frame_->height % 2, 0); | 271 DCHECK_EQ(av_frame_->height % 2, 0); |
| 272 | 272 |
| 273 const int y_size = av_frame_->width * av_frame_->height; | 273 const int y_size = av_frame_->width * av_frame_->height; |
| 274 const int uv_size = y_size / 2; | 274 const int uv_size = y_size / 2; |
| 275 const int space_required = y_size + (uv_size * 2); | 275 const int space_required = y_size + (uv_size * 2); |
| 276 | 276 |
| 277 DCHECK(!cdm_video_frame->FrameBuffer()); | 277 DCHECK(!cdm_video_frame->FrameBuffer()); |
| 278 cdm_video_frame->SetFrameBuffer(allocator_->Allocate(space_required)); | 278 cdm_video_frame->SetFrameBuffer(host_->Allocate(space_required)); |
| 279 if (!cdm_video_frame->FrameBuffer()) { | 279 if (!cdm_video_frame->FrameBuffer()) { |
| 280 LOG(ERROR) << "CopyAvFrameTo() cdm::Allocator::Allocate failed."; | 280 LOG(ERROR) << "CopyAvFrameTo() cdm::Host::Allocate failed."; |
| 281 return false; | 281 return false; |
| 282 } | 282 } |
| 283 cdm_video_frame->FrameBuffer()->SetSize(space_required); | 283 cdm_video_frame->FrameBuffer()->SetSize(space_required); |
| 284 | 284 |
| 285 CopyPlane(av_frame_->base[cdm::VideoFrame::kYPlane], | 285 CopyPlane(av_frame_->base[cdm::VideoFrame::kYPlane], |
| 286 av_frame_->linesize[cdm::VideoFrame::kYPlane], | 286 av_frame_->linesize[cdm::VideoFrame::kYPlane], |
| 287 av_frame_->width, | 287 av_frame_->width, |
| 288 av_frame_->height, | 288 av_frame_->height, |
| 289 av_frame_->width, | 289 av_frame_->width, |
| 290 cdm_video_frame->FrameBuffer()->Data()); | 290 cdm_video_frame->FrameBuffer()->Data()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 av_free(codec_context_); | 336 av_free(codec_context_); |
| 337 codec_context_ = NULL; | 337 codec_context_ = NULL; |
| 338 } | 338 } |
| 339 if (av_frame_) { | 339 if (av_frame_) { |
| 340 av_free(av_frame_); | 340 av_free(av_frame_); |
| 341 av_frame_ = NULL; | 341 av_frame_ = NULL; |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace webkit_media | 345 } // namespace webkit_media |
| OLD | NEW |