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

Side by Side Diff: content/common/gpu/media/android_video_encode_accelerator.cc

Issue 649533003: C++11 declares a type safe null pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed Presubmit errors Created 6 years, 2 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
OLDNEW
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 "content/common/gpu/media/android_video_encode_accelerator.h" 5 #include "content/common/gpu/media/android_video_encode_accelerator.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 bool is_key_frame = input.b; 280 bool is_key_frame = input.b;
281 if (is_key_frame) { 281 if (is_key_frame) {
282 // Ideally MediaCodec would honor BUFFER_FLAG_SYNC_FRAME so we could 282 // Ideally MediaCodec would honor BUFFER_FLAG_SYNC_FRAME so we could
283 // indicate this in the QueueInputBuffer() call below and guarantee _this_ 283 // indicate this in the QueueInputBuffer() call below and guarantee _this_
284 // frame be encoded as a key frame, but sadly that flag is ignored. 284 // frame be encoded as a key frame, but sadly that flag is ignored.
285 // Instead, we request a key frame "soon". 285 // Instead, we request a key frame "soon".
286 media_codec_->RequestKeyFrameSoon(); 286 media_codec_->RequestKeyFrameSoon();
287 } 287 }
288 scoped_refptr<VideoFrame> frame = input.a; 288 scoped_refptr<VideoFrame> frame = input.a;
289 289
290 uint8* buffer = NULL; 290 uint8* buffer = nullptr;
291 size_t capacity = 0; 291 size_t capacity = 0;
292 media_codec_->GetInputBuffer(input_buf_index, &buffer, &capacity); 292 media_codec_->GetInputBuffer(input_buf_index, &buffer, &capacity);
293 293
294 size_t queued_size = 294 size_t queued_size =
295 VideoFrame::AllocationSize(VideoFrame::I420, frame->coded_size()); 295 VideoFrame::AllocationSize(VideoFrame::I420, frame->coded_size());
296 RETURN_ON_FAILURE(capacity >= queued_size, 296 RETURN_ON_FAILURE(capacity >= queued_size,
297 "Failed to get input buffer: " << input_buf_index, 297 "Failed to get input buffer: " << input_buf_index,
298 kPlatformFailureError); 298 kPlatformFailureError);
299 299
300 uint8* dst_y = buffer; 300 uint8* dst_y = buffer;
(...skipping 12 matching lines...) Expand all
313 dst_y, 313 dst_y,
314 dst_stride_y, 314 dst_stride_y,
315 dst_uv, 315 dst_uv,
316 dst_stride_uv, 316 dst_stride_uv,
317 frame->coded_size().width(), 317 frame->coded_size().width(),
318 frame->coded_size().height()); 318 frame->coded_size().height());
319 RETURN_ON_FAILURE(converted, "Failed to I420ToNV12!", kPlatformFailureError); 319 RETURN_ON_FAILURE(converted, "Failed to I420ToNV12!", kPlatformFailureError);
320 320
321 fake_input_timestamp_ += base::TimeDelta::FromMicroseconds(1); 321 fake_input_timestamp_ += base::TimeDelta::FromMicroseconds(1);
322 status = media_codec_->QueueInputBuffer( 322 status = media_codec_->QueueInputBuffer(
323 input_buf_index, NULL, queued_size, fake_input_timestamp_); 323 input_buf_index, nullptr, queued_size, fake_input_timestamp_);
324 UMA_HISTOGRAM_TIMES("Media.AVEA.InputQueueTime", base::Time::Now() - input.c); 324 UMA_HISTOGRAM_TIMES("Media.AVEA.InputQueueTime", base::Time::Now() - input.c);
325 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK, 325 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK,
326 "Failed to QueueInputBuffer: " << status, 326 "Failed to QueueInputBuffer: " << status,
327 kPlatformFailureError); 327 kPlatformFailureError);
328 ++num_buffers_at_codec_; 328 ++num_buffers_at_codec_;
329 pending_frames_.pop(); 329 pending_frames_.pop();
330 } 330 }
331 331
332 bool AndroidVideoEncodeAccelerator::DoOutputBuffersSuffice() { 332 bool AndroidVideoEncodeAccelerator::DoOutputBuffersSuffice() {
333 // If this returns false ever, then the VEA::Client interface will need to 333 // If this returns false ever, then the VEA::Client interface will need to
(...skipping 15 matching lines...) Expand all
349 available_bitstream_buffers_.empty() || num_buffers_at_codec_ == 0) { 349 available_bitstream_buffers_.empty() || num_buffers_at_codec_ == 0) {
350 return; 350 return;
351 } 351 }
352 352
353 int32 buf_index = 0; 353 int32 buf_index = 0;
354 size_t offset = 0; 354 size_t offset = 0;
355 size_t size = 0; 355 size_t size = 0;
356 bool key_frame = false; 356 bool key_frame = false;
357 do { 357 do {
358 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer( 358 media::MediaCodecStatus status = media_codec_->DequeueOutputBuffer(
359 NoWaitTimeOut(), &buf_index, &offset, &size, NULL, NULL, &key_frame); 359 NoWaitTimeOut(), &buf_index, &offset, &size, nullptr, nullptr,
360 &key_frame);
360 switch (status) { 361 switch (status) {
361 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER: 362 case media::MEDIA_CODEC_DEQUEUE_OUTPUT_AGAIN_LATER:
362 return; 363 return;
363 364
364 case media::MEDIA_CODEC_ERROR: 365 case media::MEDIA_CODEC_ERROR:
365 RETURN_ON_FAILURE(false, "Codec error", kPlatformFailureError); 366 RETURN_ON_FAILURE(false, "Codec error", kPlatformFailureError);
366 // Unreachable because of previous statement, but included for clarity. 367 // Unreachable because of previous statement, but included for clarity.
367 return; 368 return;
368 369
369 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: // Fall-through. 370 case media::MEDIA_CODEC_OUTPUT_FORMAT_CHANGED: // Fall-through.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 base::MessageLoop::current()->PostTask( 404 base::MessageLoop::current()->PostTask(
404 FROM_HERE, 405 FROM_HERE,
405 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady, 406 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
406 client_ptr_factory_->GetWeakPtr(), 407 client_ptr_factory_->GetWeakPtr(),
407 bitstream_buffer.id(), 408 bitstream_buffer.id(),
408 size, 409 size,
409 key_frame)); 410 key_frame));
410 } 411 }
411 412
412 } // namespace content 413 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698