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

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

Issue 7021020: Clean up video frame sizes, types in Video Decode API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: responses to CR Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/omx_video_decode_accelerator.h" 5 #include "content/common/gpu/media/omx_video_decode_accelerator.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h" 10 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 omx_buffer->nTimeStamp = bitstream_buffer.id(); 315 omx_buffer->nTimeStamp = bitstream_buffer.id();
316 316
317 // Give this buffer to OMX. 317 // Give this buffer to OMX.
318 OMX_ERRORTYPE result = OMX_EmptyThisBuffer(component_handle_, omx_buffer); 318 OMX_ERRORTYPE result = OMX_EmptyThisBuffer(component_handle_, omx_buffer);
319 RETURN_ON_OMX_FAILURE(result, "OMX_EmptyThisBuffer() failed", 319 RETURN_ON_OMX_FAILURE(result, "OMX_EmptyThisBuffer() failed",
320 VIDEODECODERERROR_INVALIDINPUT,); 320 VIDEODECODERERROR_INVALIDINPUT,);
321 321
322 input_buffers_at_component_++; 322 input_buffers_at_component_++;
323 } 323 }
324 324
325 void OmxVideoDecodeAccelerator::AssignGLESBuffers( 325 void OmxVideoDecodeAccelerator::AssignPictureBuffers(
326 const std::vector<media::GLESBuffer>& buffers) { 326 const std::vector<media::PictureBuffer>& buffers) {
327 DCHECK_EQ(message_loop_, MessageLoop::current()); 327 DCHECK_EQ(message_loop_, MessageLoop::current());
328 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", 328 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer",
329 VIDEODECODERERROR_UNSUPPORTED,); 329 VIDEODECODERERROR_UNSUPPORTED,);
330 330
331 CHECK_EQ(output_buffers_at_component_, 0); 331 CHECK_EQ(output_buffers_at_component_, 0);
332 CHECK_EQ(fake_output_buffers_.size(), 0U); 332 CHECK_EQ(fake_output_buffers_.size(), 0U);
333 CHECK_EQ(pictures_.size(), 0U); 333 CHECK_EQ(pictures_.size(), 0U);
334 334
335 static Gles2TextureToEglImageTranslator texture2eglImage_translator; 335 static Gles2TextureToEglImageTranslator texture2eglImage_translator;
336 for (size_t i = 0; i < buffers.size(); ++i) { 336 for (size_t i = 0; i < buffers.size(); ++i) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 buffer->nFlags = 0; 612 buffer->nFlags = 0;
613 free_input_buffers_.push(buffer); 613 free_input_buffers_.push(buffer);
614 } 614 }
615 return true; 615 return true;
616 } 616 }
617 617
618 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { 618 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() {
619 DCHECK_EQ(message_loop_, MessageLoop::current()); 619 DCHECK_EQ(message_loop_, MessageLoop::current());
620 620
621 DCHECK(!pictures_.empty()); 621 DCHECK(!pictures_.empty());
622 gfx::Size decoded_pixel_size(pictures_.begin()->second.gles_buffer.size());
623 gfx::Size visible_pixel_size(pictures_.begin()->second.gles_buffer.size());
624 for (OutputPictureById::iterator it = pictures_.begin(); 622 for (OutputPictureById::iterator it = pictures_.begin();
625 it != pictures_.end(); ++it) { 623 it != pictures_.end(); ++it) {
626 media::GLESBuffer& gles_buffer = it->second.gles_buffer; 624 media::PictureBuffer& picture_buffer = it->second.picture_buffer;
627 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header; 625 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header;
628 DCHECK(!*omx_buffer); 626 DCHECK(!*omx_buffer);
629 OMX_ERRORTYPE result = OMX_UseEGLImage( 627 OMX_ERRORTYPE result = OMX_UseEGLImage(
630 component_handle_, omx_buffer, output_port_, &gles_buffer, 628 component_handle_, omx_buffer, output_port_, &picture_buffer,
631 it->second.egl_image); 629 it->second.egl_image);
632 RETURN_ON_OMX_FAILURE(result, "OMX_UseEGLImage", 630 RETURN_ON_OMX_FAILURE(result, "OMX_UseEGLImage",
633 VIDEODECODERERROR_MEMFAILURE, false); 631 VIDEODECODERERROR_MEMFAILURE, false);
634 // Here we set a garbage bitstream buffer id, and then overwrite it before 632 // Here we set a garbage bitstream buffer id, and then overwrite it before
635 // passing to PictureReady. 633 // passing to PictureReady.
636 int garbage_bitstream_buffer_id = -1; 634 int garbage_bitstream_buffer_id = -1;
637 (*omx_buffer)->pAppPrivate = 635 (*omx_buffer)->pAppPrivate =
638 new media::Picture(gles_buffer.id(), garbage_bitstream_buffer_id, 636 new media::Picture(picture_buffer.id(), garbage_bitstream_buffer_id);
639 decoded_pixel_size, visible_pixel_size);
640 } 637 }
641 return true; 638 return true;
642 } 639 }
643 640
644 void OmxVideoDecodeAccelerator::FreeInputBuffers() { 641 void OmxVideoDecodeAccelerator::FreeInputBuffers() {
645 DCHECK_EQ(message_loop_, MessageLoop::current()); 642 DCHECK_EQ(message_loop_, MessageLoop::current());
646 // Calls to OMX to free buffers. 643 // Calls to OMX to free buffers.
647 OMX_ERRORTYPE result; 644 OMX_ERRORTYPE result;
648 OMX_BUFFERHEADERTYPE* omx_buffer; 645 OMX_BUFFERHEADERTYPE* omx_buffer;
649 while (!free_input_buffers_.empty()) { 646 while (!free_input_buffers_.empty()) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 component_handle_, OMX_IndexParamPortDefinition, &port_format); 682 component_handle_, OMX_IndexParamPortDefinition, &port_format);
686 RETURN_ON_OMX_FAILURE(result, "OMX_GetParameter", 683 RETURN_ON_OMX_FAILURE(result, "OMX_GetParameter",
687 VIDEODECODERERROR_UNSUPPORTED,); 684 VIDEODECODERERROR_UNSUPPORTED,);
688 DCHECK_EQ(port_format.nBufferCountMin, kNumPictureBuffers); 685 DCHECK_EQ(port_format.nBufferCountMin, kNumPictureBuffers);
689 686
690 // TODO(fischman): to support mid-stream resize, need to free/dismiss any 687 // TODO(fischman): to support mid-stream resize, need to free/dismiss any
691 // |pictures_| we already have. Make sure that the shutdown-path agrees with 688 // |pictures_| we already have. Make sure that the shutdown-path agrees with
692 // this (there's already freeing logic there, which should not be duplicated). 689 // this (there's already freeing logic there, which should not be duplicated).
693 690
694 // Request picture buffers to be handed to the component. 691 // Request picture buffers to be handed to the component.
695 // ProvidePictureBuffers() will trigger AssignGLESBuffers, which ultimately 692 // ProvidePictureBuffers() will trigger AssignPictureBuffers, which ultimately
696 // assigns the textures to the component and re-enables the port. 693 // assigns the textures to the component and re-enables the port.
697 const OMX_VIDEO_PORTDEFINITIONTYPE& vformat = port_format.format.video; 694 const OMX_VIDEO_PORTDEFINITIONTYPE& vformat = port_format.format.video;
698 if (client_) { 695 if (client_) {
699 client_->ProvidePictureBuffers( 696 client_->ProvidePictureBuffers(
700 kNumPictureBuffers, 697 kNumPictureBuffers,
701 gfx::Size(vformat.nFrameWidth, vformat.nFrameHeight), 698 gfx::Size(vformat.nFrameWidth, vformat.nFrameHeight));
702 PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE);
703 } 699 }
704 } 700 }
705 701
706 void OmxVideoDecodeAccelerator::OnOutputPortEnabled() { 702 void OmxVideoDecodeAccelerator::OnOutputPortEnabled() {
707 DCHECK_EQ(message_loop_, MessageLoop::current()); 703 DCHECK_EQ(message_loop_, MessageLoop::current());
708 704
709 if (!CanFillBuffer()) { 705 if (!CanFillBuffer()) {
710 StopOnError(VIDEODECODERERROR_UNSUPPORTED); // Should be STATE_ERROR. 706 StopOnError(VIDEODECODERERROR_UNSUPPORTED); // Should be STATE_ERROR.
711 return; 707 return;
712 } 708 }
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 982
987 bool OmxVideoDecodeAccelerator::SendCommandToPort( 983 bool OmxVideoDecodeAccelerator::SendCommandToPort(
988 OMX_COMMANDTYPE cmd, int port_index) { 984 OMX_COMMANDTYPE cmd, int port_index) {
989 DCHECK_EQ(message_loop_, MessageLoop::current()); 985 DCHECK_EQ(message_loop_, MessageLoop::current());
990 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, 986 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_,
991 cmd, port_index, 0); 987 cmd, port_index, 0);
992 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, 988 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd,
993 VIDEODECODERERROR_INVALIDINPUT, false); 989 VIDEODECODERERROR_INVALIDINPUT, false);
994 return true; 990 return true;
995 } 991 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698