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

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

Issue 821453003: Update legacy Tuple-using code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: media Created 6 years 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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 if (status != media::MEDIA_CODEC_OK) { 313 if (status != media::MEDIA_CODEC_OK) {
314 DCHECK(status == media::MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER || 314 DCHECK(status == media::MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER ||
315 status == media::MEDIA_CODEC_ERROR); 315 status == media::MEDIA_CODEC_ERROR);
316 RETURN_ON_FAILURE(status != media::MEDIA_CODEC_ERROR, 316 RETURN_ON_FAILURE(status != media::MEDIA_CODEC_ERROR,
317 "MediaCodec error", 317 "MediaCodec error",
318 kPlatformFailureError); 318 kPlatformFailureError);
319 return; 319 return;
320 } 320 }
321 321
322 const PendingFrames::value_type& input = pending_frames_.front(); 322 const PendingFrames::value_type& input = pending_frames_.front();
323 bool is_key_frame = input.b; 323 bool is_key_frame = get<1>(input);
324 if (is_key_frame) { 324 if (is_key_frame) {
325 // Ideally MediaCodec would honor BUFFER_FLAG_SYNC_FRAME so we could 325 // Ideally MediaCodec would honor BUFFER_FLAG_SYNC_FRAME so we could
326 // indicate this in the QueueInputBuffer() call below and guarantee _this_ 326 // indicate this in the QueueInputBuffer() call below and guarantee _this_
327 // frame be encoded as a key frame, but sadly that flag is ignored. 327 // frame be encoded as a key frame, but sadly that flag is ignored.
328 // Instead, we request a key frame "soon". 328 // Instead, we request a key frame "soon".
329 media_codec_->RequestKeyFrameSoon(); 329 media_codec_->RequestKeyFrameSoon();
330 } 330 }
331 scoped_refptr<VideoFrame> frame = input.a; 331 scoped_refptr<VideoFrame> frame = get<0>(input);
332 332
333 uint8* buffer = NULL; 333 uint8* buffer = NULL;
334 size_t capacity = 0; 334 size_t capacity = 0;
335 media_codec_->GetInputBuffer(input_buf_index, &buffer, &capacity); 335 media_codec_->GetInputBuffer(input_buf_index, &buffer, &capacity);
336 336
337 size_t queued_size = 337 size_t queued_size =
338 VideoFrame::AllocationSize(VideoFrame::I420, frame->coded_size()); 338 VideoFrame::AllocationSize(VideoFrame::I420, frame->coded_size());
339 RETURN_ON_FAILURE(capacity >= queued_size, 339 RETURN_ON_FAILURE(capacity >= queued_size,
340 "Failed to get input buffer: " << input_buf_index, 340 "Failed to get input buffer: " << input_buf_index,
341 kPlatformFailureError); 341 kPlatformFailureError);
(...skipping 15 matching lines...) Expand all
357 dst_stride_y, 357 dst_stride_y,
358 dst_uv, 358 dst_uv,
359 dst_stride_uv, 359 dst_stride_uv,
360 frame->coded_size().width(), 360 frame->coded_size().width(),
361 frame->coded_size().height()); 361 frame->coded_size().height());
362 RETURN_ON_FAILURE(converted, "Failed to I420ToNV12!", kPlatformFailureError); 362 RETURN_ON_FAILURE(converted, "Failed to I420ToNV12!", kPlatformFailureError);
363 363
364 fake_input_timestamp_ += base::TimeDelta::FromMicroseconds(1); 364 fake_input_timestamp_ += base::TimeDelta::FromMicroseconds(1);
365 status = media_codec_->QueueInputBuffer( 365 status = media_codec_->QueueInputBuffer(
366 input_buf_index, NULL, queued_size, fake_input_timestamp_); 366 input_buf_index, NULL, queued_size, fake_input_timestamp_);
367 UMA_HISTOGRAM_TIMES("Media.AVEA.InputQueueTime", base::Time::Now() - input.c); 367 UMA_HISTOGRAM_TIMES("Media.AVEA.InputQueueTime",
368 base::Time::Now() - get<2>(input));
368 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK, 369 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK,
369 "Failed to QueueInputBuffer: " << status, 370 "Failed to QueueInputBuffer: " << status,
370 kPlatformFailureError); 371 kPlatformFailureError);
371 ++num_buffers_at_codec_; 372 ++num_buffers_at_codec_;
372 pending_frames_.pop(); 373 pending_frames_.pop();
373 } 374 }
374 375
375 bool AndroidVideoEncodeAccelerator::DoOutputBuffersSuffice() { 376 bool AndroidVideoEncodeAccelerator::DoOutputBuffersSuffice() {
376 // If this returns false ever, then the VEA::Client interface will need to 377 // If this returns false ever, then the VEA::Client interface will need to
377 // grow a DismissBitstreamBuffer() call, and VEA::Client impls will have to be 378 // grow a DismissBitstreamBuffer() call, and VEA::Client impls will have to be
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 base::MessageLoop::current()->PostTask( 447 base::MessageLoop::current()->PostTask(
447 FROM_HERE, 448 FROM_HERE,
448 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady, 449 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
449 client_ptr_factory_->GetWeakPtr(), 450 client_ptr_factory_->GetWeakPtr(),
450 bitstream_buffer.id(), 451 bitstream_buffer.id(),
451 size, 452 size,
452 key_frame)); 453 key_frame));
453 } 454 }
454 455
455 } // namespace content 456 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698