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

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

Issue 1541353002: Add offset support to BitstreamBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address dcheng's comments Created 4 years, 11 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "content/common/gpu/gpu_channel.h" 17 #include "content/common/gpu/gpu_channel.h"
18 #include "content/common/gpu/media/android_copying_backing_strategy.h" 18 #include "content/common/gpu/media/android_copying_backing_strategy.h"
19 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " 19 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h "
20 #include "content/common/gpu/media/shared_memory_region.h"
20 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 21 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
21 #include "media/base/bind_to_current_loop.h" 22 #include "media/base/bind_to_current_loop.h"
22 #include "media/base/bitstream_buffer.h" 23 #include "media/base/bitstream_buffer.h"
23 #include "media/base/limits.h" 24 #include "media/base/limits.h"
24 #include "media/base/media_switches.h" 25 #include "media/base/media_switches.h"
25 #include "media/base/timestamp_constants.h" 26 #include "media/base/timestamp_constants.h"
26 #include "media/base/video_decoder_config.h" 27 #include "media/base/video_decoder_config.h"
27 #include "media/video/picture.h" 28 #include "media/video/picture.h"
28 #include "ui/gl/android/scoped_java_surface.h" 29 #include "ui/gl/android/scoped_java_surface.h"
29 #include "ui/gl/android/surface_texture.h" 30 #include "ui/gl/android/surface_texture.h"
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 340
340 if (bitstream_buffer.id() == -1) { 341 if (bitstream_buffer.id() == -1) {
341 pending_bitstream_buffers_.pop(); 342 pending_bitstream_buffers_.pop();
342 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount", 343 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount",
343 pending_bitstream_buffers_.size()); 344 pending_bitstream_buffers_.size());
344 345
345 media_codec_->QueueEOS(input_buf_index); 346 media_codec_->QueueEOS(input_buf_index);
346 return true; 347 return true;
347 } 348 }
348 349
349 scoped_ptr<base::SharedMemory> shm; 350 scoped_ptr<SharedMemoryRegion> shm;
350 351
351 if (pending_input_buf_index_ != -1) { 352 if (pending_input_buf_index_ != -1) {
352 // The buffer is already dequeued from MediaCodec, filled with data and 353 // The buffer is already dequeued from MediaCodec, filled with data and
353 // bitstream_buffer.handle() is closed. 354 // bitstream_buffer.handle() is closed.
354 shm.reset(new base::SharedMemory()); 355 shm.reset(new SharedMemoryRegion(base::SharedMemoryHandle(), 0, 0, false));
355 } else { 356 } else {
356 shm.reset(new base::SharedMemory(bitstream_buffer.handle(), true)); 357 shm.reset(new SharedMemoryRegion(bitstream_buffer, true));
357 358
358 if (!shm->Map(bitstream_buffer.size())) { 359 if (!shm->Map()) {
359 POST_ERROR(UNREADABLE_INPUT, "Failed to SharedMemory::Map()"); 360 POST_ERROR(UNREADABLE_INPUT, "Failed to SharedMemoryRegion::Map()");
360 return false; 361 return false;
361 } 362 }
362 } 363 }
363 364
364 const base::TimeDelta presentation_timestamp = 365 const base::TimeDelta presentation_timestamp =
365 bitstream_buffer.presentation_timestamp(); 366 bitstream_buffer.presentation_timestamp();
366 DCHECK(presentation_timestamp != media::kNoTimestamp()) 367 DCHECK(presentation_timestamp != media::kNoTimestamp())
367 << "Bitstream buffers must have valid presentation timestamps"; 368 << "Bitstream buffers must have valid presentation timestamps";
368 369
369 // There may already be a bitstream buffer with this timestamp, e.g., VP9 alt 370 // There may already be a bitstream buffer with this timestamp, e.g., VP9 alt
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 964
964 if (UseDeferredRenderingStrategy()) { 965 if (UseDeferredRenderingStrategy()) {
965 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: 966 capabilities.flags = media::VideoDecodeAccelerator::Capabilities::
966 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; 967 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE;
967 } 968 }
968 969
969 return capabilities; 970 return capabilities;
970 } 971 }
971 972
972 } // namespace content 973 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698