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

Unified Diff: media/gpu/vaapi_video_decode_accelerator.cc

Issue 1882373004: Migrate content/common/gpu/media code to media/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix several more bot-identified build issues Created 4 years, 8 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: media/gpu/vaapi_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/vaapi_video_decode_accelerator.cc b/media/gpu/vaapi_video_decode_accelerator.cc
similarity index 92%
rename from content/common/gpu/media/vaapi_video_decode_accelerator.cc
rename to media/gpu/vaapi_video_decode_accelerator.cc
index 4d59c37c747c1404be2e2b4814211fee5a9799c1..78332f7b8a90c516ab33d6428d7a352691beb342 100644
--- a/content/common/gpu/media/vaapi_video_decode_accelerator.cc
+++ b/media/gpu/vaapi_video_decode_accelerator.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
+#include "media/gpu/vaapi_video_decode_accelerator.h"
#include <string.h>
@@ -14,41 +14,40 @@
#include "base/strings/string_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/trace_event/trace_event.h"
-#include "content/common/gpu/media/accelerated_video_decoder.h"
-#include "content/common/gpu/media/h264_decoder.h"
-#include "content/common/gpu/media/vaapi_picture.h"
-#include "content/common/gpu/media/vp8_decoder.h"
-#include "content/common/gpu/media/vp9_decoder.h"
#include "gpu/ipc/service/gpu_channel.h"
#include "media/base/bind_to_current_loop.h"
+#include "media/gpu/accelerated_video_decoder.h"
+#include "media/gpu/h264_decoder.h"
+#include "media/gpu/vaapi_picture.h"
+#include "media/gpu/vp8_decoder.h"
+#include "media/gpu/vp9_decoder.h"
#include "media/video/picture.h"
#include "third_party/libva/va/va_dec_vp8.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_image.h"
-namespace content {
+namespace media {
namespace {
// UMA errors that the VaapiVideoDecodeAccelerator class reports.
enum VAVDADecoderFailure {
VAAPI_ERROR = 0,
- // UMA requires that max must be greater than 1.
- VAVDA_DECODER_FAILURES_MAX = 2,
+ VAVDA_DECODER_FAILURES_MAX,
};
}
static void ReportToUMA(VAVDADecoderFailure failure) {
UMA_HISTOGRAM_ENUMERATION("Media.VAVDA.DecoderFailure", failure,
- VAVDA_DECODER_FAILURES_MAX);
+ VAVDA_DECODER_FAILURES_MAX + 1);
}
-#define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \
- do { \
- if (!(result)) { \
- LOG(ERROR) << log; \
- NotifyError(error_code); \
- return ret; \
- } \
+#define RETURN_AND_NOTIFY_ON_FAILURE(result, log, error_code, ret) \
+ do { \
+ if (!(result)) { \
+ LOG(ERROR) << log; \
+ NotifyError(error_code); \
+ return ret; \
+ } \
} while (0)
class VaapiVideoDecodeAccelerator::VaapiDecodeSurface
@@ -73,13 +72,13 @@ VaapiVideoDecodeAccelerator::VaapiDecodeSurface::VaapiDecodeSurface(
const scoped_refptr<VASurface>& va_surface)
: bitstream_id_(bitstream_id), va_surface_(va_surface) {}
-VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {
-}
+VaapiVideoDecodeAccelerator::VaapiDecodeSurface::~VaapiDecodeSurface() {}
class VaapiH264Picture : public H264Picture {
public:
- VaapiH264Picture(const scoped_refptr<
- VaapiVideoDecodeAccelerator::VaapiDecodeSurface>& dec_surface);
+ VaapiH264Picture(
+ const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
+ dec_surface);
VaapiH264Picture* AsVaapiH264Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() {
@@ -94,13 +93,12 @@ class VaapiH264Picture : public H264Picture {
DISALLOW_COPY_AND_ASSIGN(VaapiH264Picture);
};
-VaapiH264Picture::VaapiH264Picture(const scoped_refptr<
- VaapiVideoDecodeAccelerator::VaapiDecodeSurface>& dec_surface)
- : dec_surface_(dec_surface) {
-}
+VaapiH264Picture::VaapiH264Picture(
+ const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
+ dec_surface)
+ : dec_surface_(dec_surface) {}
-VaapiH264Picture::~VaapiH264Picture() {
-}
+VaapiH264Picture::~VaapiH264Picture() {}
class VaapiVideoDecodeAccelerator::VaapiH264Accelerator
: public H264Decoder::H264Accelerator {
@@ -150,8 +148,9 @@ class VaapiVideoDecodeAccelerator::VaapiH264Accelerator
class VaapiVP8Picture : public VP8Picture {
public:
- VaapiVP8Picture(const scoped_refptr<
- VaapiVideoDecodeAccelerator::VaapiDecodeSurface>& dec_surface);
+ VaapiVP8Picture(
+ const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
+ dec_surface);
VaapiVP8Picture* AsVaapiVP8Picture() override { return this; }
scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface> dec_surface() {
@@ -166,13 +165,12 @@ class VaapiVP8Picture : public VP8Picture {
DISALLOW_COPY_AND_ASSIGN(VaapiVP8Picture);
};
-VaapiVP8Picture::VaapiVP8Picture(const scoped_refptr<
- VaapiVideoDecodeAccelerator::VaapiDecodeSurface>& dec_surface)
- : dec_surface_(dec_surface) {
-}
+VaapiVP8Picture::VaapiVP8Picture(
+ const scoped_refptr<VaapiVideoDecodeAccelerator::VaapiDecodeSurface>&
+ dec_surface)
+ : dec_surface_(dec_surface) {}
-VaapiVP8Picture::~VaapiVP8Picture() {
-}
+VaapiVP8Picture::~VaapiVP8Picture() {}
class VaapiVideoDecodeAccelerator::VaapiVP8Accelerator
: public VP8Decoder::VP8Accelerator {
@@ -258,20 +256,20 @@ class VaapiVideoDecodeAccelerator::VaapiVP9Accelerator
VaapiVideoDecodeAccelerator::InputBuffer::InputBuffer() : id(0) {}
-VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() {
-}
+VaapiVideoDecodeAccelerator::InputBuffer::~InputBuffer() {}
void VaapiVideoDecodeAccelerator::NotifyError(Error error) {
if (message_loop_ != base::MessageLoop::current()) {
DCHECK(decoder_thread_task_runner_->BelongsToCurrentThread());
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::NotifyError, weak_this_, error));
+ message_loop_->PostTask(
+ FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::NotifyError,
+ weak_this_, error));
return;
}
// Post Cleanup() as a task so we don't recursively acquire lock_.
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::Cleanup, weak_this_));
+ message_loop_->PostTask(
+ FROM_HERE, base::Bind(&VaapiVideoDecodeAccelerator::Cleanup, weak_this_));
LOG(ERROR) << "Notifying of error " << error;
if (client_) {
@@ -393,8 +391,7 @@ void VaapiVideoDecodeAccelerator::OutputPicture(
int32_t output_id = picture->picture_buffer_id();
- TRACE_EVENT2("Video Decoder", "VAVDA::OutputSurface",
- "input_id", input_id,
+ TRACE_EVENT2("Video Decoder", "VAVDA::OutputSurface", "input_id", input_id,
"output_id", output_id);
DVLOG(3) << "Outputting VASurface " << va_surface->id()
@@ -407,14 +404,13 @@ void VaapiVideoDecodeAccelerator::OutputPicture(
// Notify the client a picture is ready to be displayed.
++num_frames_at_client_;
TRACE_COUNTER1("Video Decoder", "Textures at client", num_frames_at_client_);
- DVLOG(4) << "Notifying output picture id " << output_id
- << " for input "<< input_id << " is ready";
+ DVLOG(4) << "Notifying output picture id " << output_id << " for input "
+ << input_id << " is ready";
// TODO(posciak): Use visible size from decoder here instead
// (crbug.com/402760). Passing (0, 0) results in the client using the
// visible size extracted from the container instead.
if (client_)
- client_->PictureReady(media::Picture(output_id, input_id,
- gfx::Rect(0, 0),
+ client_->PictureReady(media::Picture(output_id, input_id, gfx::Rect(0, 0),
picture->AllowOverlay()));
}
@@ -445,7 +441,7 @@ void VaapiVideoDecodeAccelerator::MapAndQueueNewInputBuffer(
const media::BitstreamBuffer& bitstream_buffer) {
DCHECK_EQ(message_loop_, base::MessageLoop::current());
TRACE_EVENT1("Video Decoder", "MapAndQueueNewInputBuffer", "input_id",
- bitstream_buffer.id());
+ bitstream_buffer.id());
DVLOG(4) << "Mapping new input buffer id: " << bitstream_buffer.id()
<< " size: " << (int)bitstream_buffer.size();
@@ -491,7 +487,7 @@ bool VaapiVideoDecodeAccelerator::GetInputBuffer_Locked() {
// already queued up. Otherwise will stop decoding.
if (input_buffers_.empty())
return false;
- // else fallthrough
+ // else fallthrough
Pawel Osciak 2016/04/19 09:22:55 Please keep the original indent.
Mark Dittmer 2016/05/02 03:51:24 Done.
case kDecoding:
case kIdle:
DCHECK(!input_buffers_.empty());
@@ -522,8 +518,8 @@ void VaapiVideoDecodeAccelerator::ReturnCurrInputBuffer_Locked() {
int32_t id = curr_input_buffer_->id;
curr_input_buffer_.reset();
DVLOG(4) << "End of input buffer " << id;
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &Client::NotifyEndOfBitstreamBuffer, client_, id));
+ message_loop_->PostTask(
+ FROM_HERE, base::Bind(&Client::NotifyEndOfBitstreamBuffer, client_, id));
--num_stream_bufs_at_decoder_;
TRACE_COUNTER1("Video Decoder", "Stream buffers at decoder",
@@ -577,10 +573,11 @@ void VaapiVideoDecodeAccelerator::DecodeTask() {
switch (res) {
case AcceleratedVideoDecoder::kAllocateNewSurfaces:
DVLOG(1) << "Decoder requesting a new set of surfaces";
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::InitiateSurfaceSetChange, weak_this_,
- decoder_->GetRequiredNumOfPictures(),
- decoder_->GetPicSize()));
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&VaapiVideoDecodeAccelerator::InitiateSurfaceSetChange,
+ weak_this_, decoder_->GetRequiredNumOfPictures(),
+ decoder_->GetPicSize()));
// We'll get rescheduled once ProvidePictureBuffers() finishes.
return;
@@ -639,8 +636,10 @@ void VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange() {
// as the result, but not all have executed yet. Post ourselves after them
// to let them release surfaces.
DVLOG(2) << "Awaiting pending output/surface release callbacks to finish";
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange, weak_this_));
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange,
+ weak_this_));
return;
}
@@ -658,8 +657,8 @@ void VaapiVideoDecodeAccelerator::TryFinishSurfaceSetChange() {
pictures_.clear();
// And ask for a new set as requested.
- DVLOG(1) << "Requesting " << requested_num_pics_ << " pictures of size: "
- << requested_pic_size_.ToString();
+ DVLOG(1) << "Requesting " << requested_num_pics_
+ << " pictures of size: " << requested_pic_size_.ToString();
message_loop_->PostTask(
FROM_HERE,
@@ -693,7 +692,7 @@ void VaapiVideoDecodeAccelerator::Decode(
break;
case kDecoding:
- // Decoder already running, fallthrough.
+ // Decoder already running, fallthrough.
case kResetting:
// When resetting, allow accumulating bitstream buffers, so that
// the client can queue after-seek-buffers while we are finishing with
@@ -701,8 +700,8 @@ void VaapiVideoDecodeAccelerator::Decode(
break;
default:
- RETURN_AND_NOTIFY_ON_FAILURE(false,
- "Decode request from client in invalid state: " << state_,
+ RETURN_AND_NOTIFY_ON_FAILURE(
+ false, "Decode request from client in invalid state: " << state_,
PLATFORM_FAILURE, );
break;
}
@@ -727,10 +726,11 @@ void VaapiVideoDecodeAccelerator::AssignPictureBuffers(
while (!output_buffers_.empty())
output_buffers_.pop();
- RETURN_AND_NOTIFY_ON_FAILURE(
- buffers.size() >= requested_num_pics_,
- "Got an invalid number of picture buffers. (Got " << buffers.size()
- << ", requested " << requested_num_pics_ << ")", INVALID_ARGUMENT, );
+ RETURN_AND_NOTIFY_ON_FAILURE(buffers.size() >= requested_num_pics_,
+ "Got an invalid number of picture buffers. (Got "
+ << buffers.size() << ", requested "
+ << requested_num_pics_ << ")",
+ INVALID_ARGUMENT, );
DCHECK(requested_pic_size_ == buffers[0].size());
std::vector<VASurfaceID> va_surface_ids;
@@ -804,8 +804,9 @@ void VaapiVideoDecodeAccelerator::FlushTask() {
// Put the decoder in idle state, ready to resume.
decoder_->Reset();
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::FinishFlush, weak_this_));
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&VaapiVideoDecodeAccelerator::FinishFlush, weak_this_));
}
void VaapiVideoDecodeAccelerator::Flush() {
@@ -843,8 +844,8 @@ void VaapiVideoDecodeAccelerator::FinishFlush() {
state_ = kIdle;
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &Client::NotifyFlushDone, client_));
+ message_loop_->PostTask(FROM_HERE,
+ base::Bind(&Client::NotifyFlushDone, client_));
DVLOG(1) << "Flush finished";
}
@@ -865,8 +866,9 @@ void VaapiVideoDecodeAccelerator::ResetTask() {
ReturnCurrInputBuffer_Locked();
// And let client know that we are done with reset.
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::FinishReset, weak_this_));
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&VaapiVideoDecodeAccelerator::FinishReset, weak_this_));
}
void VaapiVideoDecodeAccelerator::Reset() {
@@ -880,9 +882,9 @@ void VaapiVideoDecodeAccelerator::Reset() {
// Drop all remaining input buffers, if present.
while (!input_buffers_.empty()) {
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &Client::NotifyEndOfBitstreamBuffer, client_,
- input_buffers_.front()->id));
+ message_loop_->PostTask(
+ FROM_HERE, base::Bind(&Client::NotifyEndOfBitstreamBuffer, client_,
+ input_buffers_.front()->id));
input_buffers_.pop();
}
@@ -912,16 +914,17 @@ void VaapiVideoDecodeAccelerator::FinishReset() {
// Decoder requested a new surface set while we were waiting for it to
// finish the last DecodeTask, running at the time of Reset().
// Let the surface set change finish first before resetting.
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &VaapiVideoDecodeAccelerator::FinishReset, weak_this_));
+ message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&VaapiVideoDecodeAccelerator::FinishReset, weak_this_));
return;
}
num_stream_bufs_at_decoder_ = 0;
state_ = kIdle;
- message_loop_->PostTask(FROM_HERE, base::Bind(
- &Client::NotifyResetDone, client_));
+ message_loop_->PostTask(FROM_HERE,
+ base::Bind(&Client::NotifyResetDone, client_));
// The client might have given us new buffers via Decode() while we were
// resetting and might be waiting for our move, and not call Decode() anymore
@@ -1041,8 +1044,7 @@ VaapiVideoDecodeAccelerator::VaapiH264Accelerator::VaapiH264Accelerator(
DCHECK(vaapi_dec_);
}
-VaapiVideoDecodeAccelerator::VaapiH264Accelerator::~VaapiH264Accelerator() {
-}
+VaapiVideoDecodeAccelerator::VaapiH264Accelerator::~VaapiH264Accelerator() {}
scoped_refptr<H264Picture>
VaapiVideoDecodeAccelerator::VaapiH264Accelerator::CreateH264Picture() {
@@ -1141,8 +1143,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitFrameMetadata(
pic_param.num_ref_frames = sps->max_num_ref_frames;
if (!vaapi_wrapper_->SubmitBuffer(VAPictureParameterBufferType,
- sizeof(pic_param),
- &pic_param))
+ sizeof(pic_param), &pic_param))
return false;
VAIQMatrixBufferH264 iq_matrix_buf;
@@ -1171,8 +1172,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitFrameMetadata(
}
return vaapi_wrapper_->SubmitBuffer(VAIQMatrixBufferType,
- sizeof(iq_matrix_buf),
- &iq_matrix_buf);
+ sizeof(iq_matrix_buf), &iq_matrix_buf);
}
bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice(
@@ -1272,8 +1272,7 @@ bool VaapiVideoDecodeAccelerator::VaapiH264Accelerator::SubmitSlice(
}
if (!vaapi_wrapper_->SubmitBuffer(VASliceParameterBufferType,
- sizeof(slice_param),
- &slice_param))
+ sizeof(slice_param), &slice_param))
return false;
// Can't help it, blame libva...
@@ -1374,8 +1373,7 @@ VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::VaapiVP8Accelerator(
DCHECK(vaapi_dec_);
}
-VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::~VaapiVP8Accelerator() {
-}
+VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::~VaapiVP8Accelerator() {}
scoped_refptr<VP8Picture>
VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::CreateVP8Picture() {
@@ -1430,9 +1428,8 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode(
#undef CLAMP_Q
}
- if (!vaapi_wrapper_->SubmitBuffer(VAIQMatrixBufferType,
- sizeof(VAIQMatrixBufferVP8),
- &iq_matrix_buf))
+ if (!vaapi_wrapper_->SubmitBuffer(
+ VAIQMatrixBufferType, sizeof(VAIQMatrixBufferVP8), &iq_matrix_buf))
return false;
VAProbabilityDataBufferVP8 prob_buf;
@@ -1517,13 +1514,13 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode(
pic_param.loop_filter_level[i] = lf_level;
}
- static_assert(arraysize(lf_hdr.ref_frame_delta) ==
- arraysize(pic_param.loop_filter_deltas_ref_frame) &&
- arraysize(lf_hdr.mb_mode_delta) ==
- arraysize(pic_param.loop_filter_deltas_mode) &&
- arraysize(lf_hdr.ref_frame_delta) ==
- arraysize(lf_hdr.mb_mode_delta),
- "loop filter deltas arrays size mismatch");
+ static_assert(
+ arraysize(lf_hdr.ref_frame_delta) ==
+ arraysize(pic_param.loop_filter_deltas_ref_frame) &&
+ arraysize(lf_hdr.mb_mode_delta) ==
+ arraysize(pic_param.loop_filter_deltas_mode) &&
+ arraysize(lf_hdr.ref_frame_delta) == arraysize(lf_hdr.mb_mode_delta),
+ "loop filter deltas arrays size mismatch");
for (size_t i = 0; i < arraysize(lf_hdr.ref_frame_delta); ++i) {
pic_param.loop_filter_deltas_ref_frame[i] = lf_hdr.ref_frame_delta[i];
pic_param.loop_filter_deltas_mode[i] = lf_hdr.mb_mode_delta[i];
@@ -1572,8 +1569,7 @@ bool VaapiVideoDecodeAccelerator::VaapiVP8Accelerator::SubmitDecode(
void* non_const_ptr = const_cast<uint8_t*>(frame_hdr->data);
if (!vaapi_wrapper_->SubmitBuffer(VASliceDataBufferType,
- frame_hdr->frame_size,
- non_const_ptr))
+ frame_hdr->frame_size, non_const_ptr))
return false;
scoped_refptr<VaapiDecodeSurface> dec_surface =
@@ -1761,4 +1757,4 @@ VaapiVideoDecodeAccelerator::GetSupportedProfiles() {
return VaapiWrapper::GetSupportedDecodeProfiles();
}
-} // namespace content
+} // namespace media

Powered by Google App Engine
This is Rietveld 408576698