Commit d46d0152 authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

Revert "media/gpu shared memory: update v4l2 UnalignedSharedMemory"

This reverts commit cfe635ce.

Reason for revert: This breaks ARC++ (App and CTS/GTS). See detail in crbug.com/874074

Original change's description:
> media/gpu shared memory: update v4l2 UnalignedSharedMemory
> 
> Uses the new WritableUnalignedMapping class, which changes the ownership
> semantics. See the bug for details on the overall plan.
> 
> Bug: 849207
> Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
> Change-Id: Idacc45e249291bd9d42ff7bf9a8abffe8636f6cf
> Reviewed-on: https://chromium-review.googlesource.com/1117692
> Commit-Queue: Matthew Cary <mattcary@chromium.org>
> Reviewed-by: Daniele Castagna <dcastagna@chromium.org>
> Reviewed-by: Alexandr Ilin <alexilin@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#582270}

TBR=dcastagna@chromium.org,mattcary@chromium.org,alexilin@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 849207
Change-Id: I1fdf459f8b480da412854d0a86ece9a0ac86a1c8
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Reviewed-on: https://chromium-review.googlesource.com/1176841Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583487}
parent bf80e9bb
...@@ -133,9 +133,8 @@ V4L2JpegDecodeAccelerator::JobRecord::JobRecord( ...@@ -133,9 +133,8 @@ V4L2JpegDecodeAccelerator::JobRecord::JobRecord(
const BitstreamBuffer& bitstream_buffer, const BitstreamBuffer& bitstream_buffer,
scoped_refptr<VideoFrame> video_frame) scoped_refptr<VideoFrame> video_frame)
: bitstream_buffer_id(bitstream_buffer.id()), : bitstream_buffer_id(bitstream_buffer.id()),
shm(bitstream_buffer.handle(), shm(bitstream_buffer.handle(), bitstream_buffer.size(), true),
bitstream_buffer.size(), offset(bitstream_buffer.offset()),
bitstream_buffer.offset()),
out_frame(video_frame) {} out_frame(video_frame) {}
V4L2JpegDecodeAccelerator::JobRecord::~JobRecord() {} V4L2JpegDecodeAccelerator::JobRecord::~JobRecord() {}
...@@ -290,7 +289,7 @@ bool V4L2JpegDecodeAccelerator::IsSupported() { ...@@ -290,7 +289,7 @@ bool V4L2JpegDecodeAccelerator::IsSupported() {
void V4L2JpegDecodeAccelerator::DecodeTask( void V4L2JpegDecodeAccelerator::DecodeTask(
std::unique_ptr<JobRecord> job_record) { std::unique_ptr<JobRecord> job_record) {
DCHECK(decoder_task_runner_->BelongsToCurrentThread()); DCHECK(decoder_task_runner_->BelongsToCurrentThread());
if (!job_record->shm.IsValid()) { if (!job_record->shm.MapAt(job_record->offset, job_record->shm.size())) {
VPLOGF(1) << "could not map bitstream_buffer"; VPLOGF(1) << "could not map bitstream_buffer";
PostNotifyError(job_record->bitstream_buffer_id, UNREADABLE_INPUT); PostNotifyError(job_record->bitstream_buffer_id, UNREADABLE_INPUT);
return; return;
......
...@@ -67,7 +67,9 @@ class MEDIA_GPU_EXPORT V4L2JpegDecodeAccelerator ...@@ -67,7 +67,9 @@ class MEDIA_GPU_EXPORT V4L2JpegDecodeAccelerator
// Input image buffer ID. // Input image buffer ID.
int32_t bitstream_buffer_id; int32_t bitstream_buffer_id;
// Memory mapped from |bitstream_buffer|. // Memory mapped from |bitstream_buffer|.
WritableUnalignedMapping shm; UnalignedSharedMemory shm;
// Offset used for shm.
off_t offset;
// Output frame buffer. // Output frame buffer.
scoped_refptr<VideoFrame> out_frame; scoped_refptr<VideoFrame> out_frame;
}; };
......
...@@ -201,7 +201,8 @@ struct V4L2SliceVideoDecodeAccelerator::BitstreamBufferRef { ...@@ -201,7 +201,8 @@ struct V4L2SliceVideoDecodeAccelerator::BitstreamBufferRef {
~BitstreamBufferRef(); ~BitstreamBufferRef();
const base::WeakPtr<VideoDecodeAccelerator::Client> client; const base::WeakPtr<VideoDecodeAccelerator::Client> client;
const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner; const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner;
const std::unique_ptr<WritableUnalignedMapping> shm; const std::unique_ptr<UnalignedSharedMemory> shm;
off_t offset;
off_t bytes_used; off_t bytes_used;
const int32_t input_id; const int32_t input_id;
}; };
...@@ -213,10 +214,11 @@ V4L2SliceVideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( ...@@ -213,10 +214,11 @@ V4L2SliceVideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef(
int32_t input_id) int32_t input_id)
: client(client), : client(client),
client_task_runner(client_task_runner), client_task_runner(client_task_runner),
shm(buffer ? std::make_unique<WritableUnalignedMapping>(buffer->handle(), shm(buffer ? std::make_unique<UnalignedSharedMemory>(buffer->handle(),
buffer->size(), buffer->size(),
buffer->offset()) true)
: nullptr), : nullptr),
offset(buffer ? buffer->offset() : 0),
bytes_used(0), bytes_used(0),
input_id(input_id) {} input_id(input_id) {}
...@@ -1347,12 +1349,12 @@ void V4L2SliceVideoDecodeAccelerator::DecodeTask( ...@@ -1347,12 +1349,12 @@ void V4L2SliceVideoDecodeAccelerator::DecodeTask(
new BitstreamBufferRef(decode_client_, decode_task_runner_, new BitstreamBufferRef(decode_client_, decode_task_runner_,
&bitstream_buffer, bitstream_buffer.id())); &bitstream_buffer, bitstream_buffer.id()));
// Skip empty buffer. This must be done after creating bitstream_record as the // Skip empty buffer.
// handle in the bitstream_buffer needs to be consumed.
if (bitstream_buffer.size() == 0) if (bitstream_buffer.size() == 0)
return; return;
if (!bitstream_record->shm->IsValid()) { if (!bitstream_record->shm->MapAt(bitstream_record->offset,
bitstream_record->shm->size())) {
VLOGF(1) << "Could not map bitstream_buffer"; VLOGF(1) << "Could not map bitstream_buffer";
NOTIFY_ERROR(UNREADABLE_INPUT); NOTIFY_ERROR(UNREADABLE_INPUT);
return; return;
......
...@@ -78,7 +78,8 @@ struct V4L2VideoDecodeAccelerator::BitstreamBufferRef { ...@@ -78,7 +78,8 @@ struct V4L2VideoDecodeAccelerator::BitstreamBufferRef {
~BitstreamBufferRef(); ~BitstreamBufferRef();
const base::WeakPtr<Client> client; const base::WeakPtr<Client> client;
const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner; const scoped_refptr<base::SingleThreadTaskRunner> client_task_runner;
const std::unique_ptr<WritableUnalignedMapping> shm; const std::unique_ptr<UnalignedSharedMemory> shm;
off_t offset;
size_t bytes_used; size_t bytes_used;
const int32_t input_id; const int32_t input_id;
}; };
...@@ -97,10 +98,11 @@ V4L2VideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef( ...@@ -97,10 +98,11 @@ V4L2VideoDecodeAccelerator::BitstreamBufferRef::BitstreamBufferRef(
int32_t input_id) int32_t input_id)
: client(client), : client(client),
client_task_runner(client_task_runner), client_task_runner(client_task_runner),
shm(buffer ? std::make_unique<WritableUnalignedMapping>(buffer->handle(), shm(buffer ? std::make_unique<UnalignedSharedMemory>(buffer->handle(),
buffer->size(), buffer->size(),
buffer->offset()) true)
: nullptr), : nullptr),
offset(buffer ? buffer->offset() : 0),
bytes_used(0), bytes_used(0),
input_id(input_id) {} input_id(input_id) {}
...@@ -777,12 +779,12 @@ void V4L2VideoDecodeAccelerator::DecodeTask( ...@@ -777,12 +779,12 @@ void V4L2VideoDecodeAccelerator::DecodeTask(
new BitstreamBufferRef(decode_client_, decode_task_runner_, new BitstreamBufferRef(decode_client_, decode_task_runner_,
&bitstream_buffer, bitstream_buffer.id())); &bitstream_buffer, bitstream_buffer.id()));
// Skip empty buffer. This must be done after creating bitstream_record as the // Skip empty buffer.
// handle in the bitstream_buffer needs to be consumed.
if (bitstream_buffer.size() == 0) if (bitstream_buffer.size() == 0)
return; return;
if (!bitstream_record->shm->IsValid()) { if (!bitstream_record->shm->MapAt(bitstream_record->offset,
bitstream_record->shm->size())) {
VLOGF(1) << "could not map bitstream_buffer"; VLOGF(1) << "could not map bitstream_buffer";
NOTIFY_ERROR(UNREADABLE_INPUT); NOTIFY_ERROR(UNREADABLE_INPUT);
return; return;
......
...@@ -89,10 +89,10 @@ static void CopyNALUPrependingStartCode(const uint8_t* src, ...@@ -89,10 +89,10 @@ static void CopyNALUPrependingStartCode(const uint8_t* src,
namespace media { namespace media {
struct V4L2VideoEncodeAccelerator::BitstreamBufferRef { struct V4L2VideoEncodeAccelerator::BitstreamBufferRef {
BitstreamBufferRef(int32_t id, std::unique_ptr<WritableUnalignedMapping> shm) BitstreamBufferRef(int32_t id, std::unique_ptr<UnalignedSharedMemory> shm)
: id(id), shm(std::move(shm)) {} : id(id), shm(std::move(shm)) {}
const int32_t id; const int32_t id;
const std::unique_ptr<WritableUnalignedMapping> shm; const std::unique_ptr<UnalignedSharedMemory> shm;
}; };
V4L2VideoEncodeAccelerator::InputRecord::InputRecord() : at_device(false) {} V4L2VideoEncodeAccelerator::InputRecord::InputRecord() : at_device(false) {}
...@@ -309,9 +309,9 @@ void V4L2VideoEncodeAccelerator::UseOutputBitstreamBuffer( ...@@ -309,9 +309,9 @@ void V4L2VideoEncodeAccelerator::UseOutputBitstreamBuffer(
return; return;
} }
auto shm = std::make_unique<WritableUnalignedMapping>( auto shm = std::make_unique<UnalignedSharedMemory>(buffer.handle(),
buffer.handle(), buffer.size(), buffer.offset()); buffer.size(), false);
if (!shm->IsValid()) { if (!shm->MapAt(buffer.offset(), buffer.size())) {
NOTIFY_ERROR(kPlatformFailureError); NOTIFY_ERROR(kPlatformFailureError);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment