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

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: rebase over crrev.com/1645873002 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 break; 413 break;
413 414
414 default: 415 default:
415 NOTREACHED(); 416 NOTREACHED();
416 break; 417 break;
417 } 418 }
418 } while (buf_index < 0); 419 } while (buf_index < 0);
419 420
420 media::BitstreamBuffer bitstream_buffer = available_bitstream_buffers_.back(); 421 media::BitstreamBuffer bitstream_buffer = available_bitstream_buffers_.back();
421 available_bitstream_buffers_.pop_back(); 422 available_bitstream_buffers_.pop_back();
422 scoped_ptr<base::SharedMemory> shm( 423 scoped_ptr<SharedMemoryRegion> shm(
423 new base::SharedMemory(bitstream_buffer.handle(), false)); 424 new SharedMemoryRegion(bitstream_buffer, false));
424 RETURN_ON_FAILURE(shm->Map(bitstream_buffer.size()), 425 RETURN_ON_FAILURE(shm->Map(), "Failed to map SHM", kPlatformFailureError);
425 "Failed to map SHM", 426 RETURN_ON_FAILURE(size <= shm->size(),
426 kPlatformFailureError); 427 "Encoded buffer too large: " << size << ">" << shm->size(),
427 RETURN_ON_FAILURE(size <= shm->mapped_size(),
428 "Encoded buffer too large: " << size << ">"
429 << shm->mapped_size(),
430 kPlatformFailureError); 428 kPlatformFailureError);
431 429
432 media_codec_->CopyFromOutputBuffer(buf_index, offset, shm->memory(), size); 430 media_codec_->CopyFromOutputBuffer(buf_index, offset, shm->memory(), size);
433 media_codec_->ReleaseOutputBuffer(buf_index, false); 431 media_codec_->ReleaseOutputBuffer(buf_index, false);
434 --num_buffers_at_codec_; 432 --num_buffers_at_codec_;
435 433
436 UMA_HISTOGRAM_COUNTS_10000("Media.AVEA.EncodedBufferSizeKB", size / 1024); 434 UMA_HISTOGRAM_COUNTS_10000("Media.AVEA.EncodedBufferSizeKB", size / 1024);
437 base::MessageLoop::current()->PostTask( 435 base::MessageLoop::current()->PostTask(
438 FROM_HERE, 436 FROM_HERE,
439 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady, 437 base::Bind(&VideoEncodeAccelerator::Client::BitstreamBufferReady,
440 client_ptr_factory_->GetWeakPtr(), 438 client_ptr_factory_->GetWeakPtr(),
441 bitstream_buffer.id(), 439 bitstream_buffer.id(),
442 size, 440 size,
443 key_frame)); 441 key_frame));
444 } 442 }
445 443
446 } // namespace content 444 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698