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

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

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments and rebase Created 4 years, 9 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 <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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "content/common/gpu/gpu_channel.h" 14 #include "content/common/gpu/gpu_channel.h"
15 #include "content/common/gpu/media/shared_memory_region.h"
15 #include "content/public/common/content_switches.h" 16 #include "content/public/common/content_switches.h"
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
17 #include "media/base/android/media_codec_util.h" 18 #include "media/base/android/media_codec_util.h"
18 #include "media/base/bitstream_buffer.h" 19 #include "media/base/bitstream_buffer.h"
19 #include "media/base/limits.h" 20 #include "media/base/limits.h"
20 #include "media/video/picture.h" 21 #include "media/video/picture.h"
21 #include "third_party/libyuv/include/libyuv/convert_from.h" 22 #include "third_party/libyuv/include/libyuv/convert_from.h"
22 #include "ui/gl/android/scoped_java_surface.h" 23 #include "ui/gl/android/scoped_java_surface.h"
23 #include "ui/gl/gl_bindings.h" 24 #include "ui/gl/gl_bindings.h"
24 25
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 break; 415 break;
415 416
416 default: 417 default:
417 NOTREACHED(); 418 NOTREACHED();
418 break; 419 break;
419 } 420 }
420 } while (buf_index < 0); 421 } while (buf_index < 0);
421 422
422 media::BitstreamBuffer bitstream_buffer = available_bitstream_buffers_.back(); 423 media::BitstreamBuffer bitstream_buffer = available_bitstream_buffers_.back();
423 available_bitstream_buffers_.pop_back(); 424 available_bitstream_buffers_.pop_back();
424 scoped_ptr<base::SharedMemory> shm( 425 scoped_ptr<SharedMemoryRegion> shm(
425 new base::SharedMemory(bitstream_buffer.handle(), false)); 426 new SharedMemoryRegion(bitstream_buffer, false));
426 RETURN_ON_FAILURE(shm->Map(bitstream_buffer.size()), 427 RETURN_ON_FAILURE(shm->Map(), "Failed to map SHM", kPlatformFailureError);
427 "Failed to map SHM", 428 RETURN_ON_FAILURE(size <= shm->size(),
428 kPlatformFailureError); 429 "Encoded buffer too large: " << size << ">" << shm->size(),
429 RETURN_ON_FAILURE(size <= shm->mapped_size(),
430 "Encoded buffer too large: " << size << ">"
431 << shm->mapped_size(),
432 kPlatformFailureError); 430 kPlatformFailureError);
433 431
434 media::MediaCodecStatus status = media_codec_->CopyFromOutputBuffer( 432 media::MediaCodecStatus status = media_codec_->CopyFromOutputBuffer(
435 buf_index, offset, shm->memory(), size); 433 buf_index, offset, shm->memory(), size);
436 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK, 434 RETURN_ON_FAILURE(status == media::MEDIA_CODEC_OK,
437 "CopyFromOutputBuffer failed", kPlatformFailureError); 435 "CopyFromOutputBuffer failed", kPlatformFailureError);
438 media_codec_->ReleaseOutputBuffer(buf_index, false); 436 media_codec_->ReleaseOutputBuffer(buf_index, false);
439 --num_buffers_at_codec_; 437 --num_buffers_at_codec_;
440 438
441 UMA_HISTOGRAM_COUNTS_10000("Media.AVEA.EncodedBufferSizeKB", size / 1024); 439 UMA_HISTOGRAM_COUNTS_10000("Media.AVEA.EncodedBufferSizeKB", size / 1024);
442 base::MessageLoop::current()->PostTask( 440 base::MessageLoop::current()->PostTask(
443 FROM_HERE, 441 FROM_HERE,
444 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady, 442 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
445 client_ptr_factory_->GetWeakPtr(), 443 client_ptr_factory_->GetWeakPtr(),
446 bitstream_buffer.id(), 444 bitstream_buffer.id(),
447 size, 445 size,
448 key_frame)); 446 key_frame));
449 } 447 }
450 448
451 } // namespace content 449 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/media/android_video_decode_accelerator.cc ('k') | content/common/gpu/media/gpu_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698