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

Unified Diff: content/common/gpu/media/v4l2_video_decode_accelerator.cc

Issue 137023008: Add support for Tegra V4L2 VDA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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/v4l2_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/v4l2_video_decode_accelerator.cc b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
index 587da6bbc04ed5449ccadf7bf00f693f9273d3e4..7006f95a036ffdd1a2f03d174583b73512c08e71 100644
--- a/content/common/gpu/media/v4l2_video_decode_accelerator.cc
+++ b/content/common/gpu/media/v4l2_video_decode_accelerator.cc
@@ -270,6 +270,8 @@ bool V4L2VideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
format.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12M;
IOCTL_OR_ERROR_RETURN_FALSE(VIDIOC_S_FMT, &format);
+ memset(&current_format_, 0, sizeof(current_format_));
+
// Subscribe to the resolution change event.
struct v4l2_event_subscription sub;
memset(&sub, 0, sizeof(sub));
@@ -360,9 +362,8 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffers(
attrs[13] = output_record.fds[1];
attrs[15] = 0;
attrs[17] = frame_buffer_size_.width();
-
- EGLImageKHR egl_image = eglCreateImageKHR(
- egl_display_, EGL_NO_CONTEXT, EGL_LINUX_DMA_BUF_EXT, NULL, attrs);
+ EGLImageKHR egl_image = device_->CreateEGLImage(
+ egl_display_, attrs, buffers[i].texture_id(), i);
if (egl_image == EGL_NO_IMAGE_KHR) {
DLOG(ERROR) << "AssignPictureBuffers(): could not create EGLImageKHR";
// Ownership of EGLImages allocated in previous iterations of this loop
@@ -372,9 +373,6 @@ void V4L2VideoDecodeAccelerator::AssignPictureBuffers(
return;
}
- glBindTexture(GL_TEXTURE_EXTERNAL_OES, buffers[i].texture_id());
- glEGLImageTargetTexture2DOES(GL_TEXTURE_EXTERNAL_OES, egl_image);
-
output_record.egl_image = egl_image;
output_record.picture_id = buffers[i].id();
free_output_buffers_.push(i);
@@ -744,6 +742,7 @@ bool V4L2VideoDecodeAccelerator::DecodeBufferInitial(
// Run this initialization only on first startup.
if (decoder_state_ == kInitialized) {
DVLOG(3) << "DecodeBufferInitial(): running initialization";
+ current_format_ = format;
// Success! Setup our parameters.
if (!CreateBuffersForFormat(format))
return false;
@@ -1005,7 +1004,31 @@ void V4L2VideoDecodeAccelerator::DequeueEvents() {
if (ev.type == V4L2_EVENT_RESOLUTION_CHANGE) {
DVLOG(3) << "DequeueEvents(): got resolution change event.";
DCHECK(!resolution_change_pending_);
- resolution_change_pending_ = true;
+ // Check if we already have current_format_ set or this is an event
+ // to trigger decoder initialization.
+ if ((current_format_.fmt.pix_mp.width == 0) ||
+ (current_format_.fmt.pix_mp.height == 0)) {
+ DVLOG(3) << "DequeueEvents(): Decoder init through resolution change ";
+ resolution_change_pending_ = true;
+ } else {
+ // Check if this is real RESOLUTION CHANGE event or not.
+ struct v4l2_format format;
+ bool again = false;
+ bool ret = GetFormatInfo(&format, &again);
+ if (!ret || again) {
+ DVLOG(3) << "DequeueEvents(): GetFormatInfo() failed ";
+ NOTIFY_ERROR(PLATFORM_FAILURE);
+ return;
+ }
+ if ((format.fmt.pix_mp.width != current_format_.fmt.pix_mp.width) ||
+ (format.fmt.pix_mp.height != current_format_.fmt.pix_mp.height)) {
+ DVLOG(2) << "DequeueEvents(): Resolution change detected";
+ current_format_ = format;
+ resolution_change_pending_ = true;
+ } else {
+ DVLOG(2) << "DequeueEvents(): Dropping resolution change event";
+ }
+ }
sheu 2014/03/21 23:19:54 Pawel brought up the point that it might be a chan
shivdasp 2014/03/24 06:01:27 Done, please refer patchset#9. On 2014/03/21 23:19
} else {
DLOG(FATAL) << "DequeueEvents(): got an event (" << ev.type
<< ") we haven't subscribed to.";
@@ -1759,7 +1782,7 @@ bool V4L2VideoDecodeAccelerator::CreateOutputBuffers() {
client_,
output_buffer_map_.size(),
frame_buffer_size_,
- GL_TEXTURE_EXTERNAL_OES));
+ device_->GetTextureTarget()));
// Wait for the client to call AssignPictureBuffers() on the Child thread.
// We do this, because if we continue decoding without finishing buffer

Powered by Google App Engine
This is Rietveld 408576698