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

Unified Diff: content/common/gpu/media/vaapi_jpeg_decode_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 side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc
diff --git a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc
index d294ae591954025cc7fd0ac133cd673a0273e239..f6d555b2515571eba3a83b87d1648cd3893e8e04 100644
--- a/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc
+++ b/content/common/gpu/media/vaapi_jpeg_decode_accelerator.cc
@@ -14,6 +14,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "content/common/gpu/gpu_channel.h"
+#include "content/common/gpu/media/shared_memory_region.h"
#include "content/common/gpu/media/vaapi_picture.h"
#include "media/base/video_frame.h"
#include "media/filters/jpeg_parser.h"
@@ -76,10 +77,10 @@ static unsigned int VaSurfaceFormatForJpeg(
} // namespace
VaapiJpegDecodeAccelerator::DecodeRequest::DecodeRequest(
- const media::BitstreamBuffer& bitstream_buffer,
- scoped_ptr<base::SharedMemory> shm,
+ int32_t bitstream_buffer_id,
+ scoped_ptr<SharedMemoryRegion> shm,
const scoped_refptr<media::VideoFrame>& video_frame)
- : bitstream_buffer(bitstream_buffer),
+ : bitstream_buffer_id(bitstream_buffer_id),
shm(std::move(shm)),
video_frame(video_frame) {}
@@ -226,9 +227,9 @@ void VaapiJpegDecodeAccelerator::DecodeTask(
media::JpegParseResult parse_result;
if (!media::ParseJpegPicture(
reinterpret_cast<const uint8_t*>(request->shm->memory()),
- request->bitstream_buffer.size(), &parse_result)) {
+ request->shm->size(), &parse_result)) {
DLOG(ERROR) << "ParseJpegPicture failed";
- NotifyErrorFromDecoderThread(request->bitstream_buffer.id(),
+ NotifyErrorFromDecoderThread(request->bitstream_buffer_id,
PARSE_JPEG_FAILED);
return;
}
@@ -237,7 +238,7 @@ void VaapiJpegDecodeAccelerator::DecodeTask(
VaSurfaceFormatForJpeg(parse_result.frame_header);
if (!new_va_rt_format) {
DLOG(ERROR) << "Unsupported subsampling";
- NotifyErrorFromDecoderThread(request->bitstream_buffer.id(),
+ NotifyErrorFromDecoderThread(request->bitstream_buffer_id,
UNSUPPORTED_JPEG);
return;
}
@@ -255,7 +256,7 @@ void VaapiJpegDecodeAccelerator::DecodeTask(
if (!vaapi_wrapper_->CreateSurfaces(va_rt_format_, new_coded_size, 1,
&va_surfaces)) {
LOG(ERROR) << "Create VA surface failed";
- NotifyErrorFromDecoderThread(request->bitstream_buffer.id(),
+ NotifyErrorFromDecoderThread(request->bitstream_buffer_id,
PLATFORM_FAILURE);
return;
}
@@ -266,15 +267,15 @@ void VaapiJpegDecodeAccelerator::DecodeTask(
if (!VaapiJpegDecoder::Decode(vaapi_wrapper_.get(), parse_result,
va_surface_id_)) {
LOG(ERROR) << "Decode JPEG failed";
- NotifyErrorFromDecoderThread(request->bitstream_buffer.id(),
+ NotifyErrorFromDecoderThread(request->bitstream_buffer_id,
PLATFORM_FAILURE);
return;
}
- if (!OutputPicture(va_surface_id_, request->bitstream_buffer.id(),
+ if (!OutputPicture(va_surface_id_, request->bitstream_buffer_id,
request->video_frame)) {
LOG(ERROR) << "Output picture failed";
- NotifyErrorFromDecoderThread(request->bitstream_buffer.id(),
+ NotifyErrorFromDecoderThread(request->bitstream_buffer_id,
PLATFORM_FAILURE);
return;
}
@@ -290,25 +291,24 @@ void VaapiJpegDecodeAccelerator::Decode(
DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id()
<< " size: " << bitstream_buffer.size();
+ // SharedMemoryRegion will take over the |bitstream_buffer.handle()|.
+ scoped_ptr<SharedMemoryRegion> shm(
+ new SharedMemoryRegion(bitstream_buffer, true));
+
if (bitstream_buffer.id() < 0) {
LOG(ERROR) << "Invalid bitstream_buffer, id: " << bitstream_buffer.id();
- if (base::SharedMemory::IsHandleValid(bitstream_buffer.handle()))
- base::SharedMemory::CloseHandle(bitstream_buffer.handle());
NotifyErrorFromDecoderThread(bitstream_buffer.id(), INVALID_ARGUMENT);
return;
}
- scoped_ptr<base::SharedMemory> shm(
- new base::SharedMemory(bitstream_buffer.handle(), true));
-
- if (!shm->Map(bitstream_buffer.size())) {
+ if (!shm->Map()) {
LOG(ERROR) << "Failed to map input buffer";
NotifyErrorFromDecoderThread(bitstream_buffer.id(), UNREADABLE_INPUT);
return;
}
scoped_ptr<DecodeRequest> request(
- new DecodeRequest(bitstream_buffer, std::move(shm), video_frame));
+ new DecodeRequest(bitstream_buffer.id(), std::move(shm), video_frame));
decoder_task_runner_->PostTask(
FROM_HERE, base::Bind(&VaapiJpegDecodeAccelerator::DecodeTask,
« no previous file with comments | « content/common/gpu/media/vaapi_jpeg_decode_accelerator.h ('k') | content/common/gpu/media/vaapi_video_decode_accelerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698