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

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

Issue 9346012: Video decode in hardware on ARM platform. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "content/common/gpu/gpu_channel.h" 12 #include "content/common/gpu/gpu_channel.h"
13 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h" 13 #include "content/common/gpu/media/gles2_texture_to_egl_image_translator.h"
14 #include "media/base/bitstream_buffer.h" 14 #include "media/base/bitstream_buffer.h"
15 #include "media/video/picture.h" 15 #include "media/video/picture.h"
16 16
17 // Helper typedef for input buffers. This is used as the pAppPrivate field of 17 // Helper typedef for input buffers. This is used as the pAppPrivate field of
18 // OMX_BUFFERHEADERTYPEs of input buffers, to point to the data associated with 18 // OMX_BUFFERHEADERTYPEs of input buffers, to point to the data associated with
19 // them. 19 // them.
20 typedef std::pair<scoped_ptr<base::SharedMemory>, int32> SharedMemoryAndId; 20 typedef std::pair<scoped_ptr<base::SharedMemory>, int32> SharedMemoryAndId;
21 21
22 enum { kNumPictureBuffers = 4 }; 22 enum { kNumPictureBuffers = 4 };
23 23
24 // Open the libnvomx here for now. 24 // Open the libnvomx here for now.
25 void* omx_handle = dlopen("libnvomx.so", RTLD_NOW); 25 void* omx_handle = dlopen("libOMXCore.so", RTLD_NOW);
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Is this capitalization open to discussion? The teg
26 26
27 typedef OMX_ERRORTYPE (*OMXInit)(); 27 typedef OMX_ERRORTYPE (*OMXInit)();
28 typedef OMX_ERRORTYPE (*OMXGetHandle)( 28 typedef OMX_ERRORTYPE (*OMXGetHandle)(
29 OMX_HANDLETYPE*, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE*); 29 OMX_HANDLETYPE*, OMX_STRING, OMX_PTR, OMX_CALLBACKTYPE*);
30 typedef OMX_ERRORTYPE (*OMXGetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**); 30 typedef OMX_ERRORTYPE (*OMXGetComponentsOfRole)(OMX_STRING, OMX_U32*, OMX_U8**);
31 typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE); 31 typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE);
32 typedef OMX_ERRORTYPE (*OMXDeinit)(); 32 typedef OMX_ERRORTYPE (*OMXDeinit)();
33 33
34 OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init")); 34 OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init"));
35 OMXGetHandle omx_gethandle = 35 OMXGetHandle omx_gethandle =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( 100 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
101 media::VideoDecodeAccelerator::Client* client) 101 media::VideoDecodeAccelerator::Client* client)
102 : message_loop_(MessageLoop::current()), 102 : message_loop_(MessageLoop::current()),
103 component_handle_(NULL), 103 component_handle_(NULL),
104 client_state_(OMX_StateMax), 104 client_state_(OMX_StateMax),
105 current_state_change_(NO_TRANSITION), 105 current_state_change_(NO_TRANSITION),
106 input_buffer_count_(0), 106 input_buffer_count_(0),
107 input_buffer_size_(0), 107 input_buffer_size_(0),
108 input_port_(0), 108 input_port_(0),
109 input_buffers_at_component_(0), 109 input_buffers_at_component_(0),
110 output_buffer_size_(0),
110 output_port_(0), 111 output_port_(0),
111 output_buffers_at_component_(0), 112 output_buffers_at_component_(0),
112 client_(client), 113 client_(client),
113 profile_(OMX_VIDEO_AVCProfileMax), 114 profile_(OMX_VIDEO_AVCProfileMax),
114 component_name_is_nvidia_h264ext_(false) { 115 component_name_is_nvidia_h264ext_(false),
116 component_name_is_sec_h264ext_(false) {
115 RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(), 117 RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(),
116 "Failed to load openmax library", PLATFORM_FAILURE,); 118 "Failed to load openmax library", PLATFORM_FAILURE,);
117 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core", 119 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core",
118 PLATFORM_FAILURE,); 120 PLATFORM_FAILURE,);
119 } 121 }
120 122
121 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { 123 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() {
122 DCHECK_EQ(message_loop_, MessageLoop::current()); 124 DCHECK_EQ(message_loop_, MessageLoop::current());
123 DCHECK(free_input_buffers_.empty()); 125 DCHECK(free_input_buffers_.empty());
124 DCHECK_EQ(0, input_buffers_at_component_); 126 DCHECK_EQ(0, input_buffers_at_component_);
(...skipping 28 matching lines...) Expand all
153 155
154 if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances. 156 if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances.
155 return false; 157 return false;
156 158
157 DCHECK_EQ(current_state_change_, NO_TRANSITION); 159 DCHECK_EQ(current_state_change_, NO_TRANSITION);
158 current_state_change_ = INITIALIZING; 160 current_state_change_ = INITIALIZING;
159 BeginTransitionToState(OMX_StateIdle); 161 BeginTransitionToState(OMX_StateIdle);
160 162
161 if (!AllocateInputBuffers()) // Does its own RETURN_ON_FAILURE dances. 163 if (!AllocateInputBuffers()) // Does its own RETURN_ON_FAILURE dances.
162 return false; 164 return false;
165 if (!AllocateFakeOutputBuffers()) // Does its own RETURN_ON_FAILURE dances.
166 return false;
163 167
164 return true; 168 return true;
165 } 169 }
166 170
167 bool OmxVideoDecodeAccelerator::CreateComponent() { 171 bool OmxVideoDecodeAccelerator::CreateComponent() {
168 DCHECK_EQ(message_loop_, MessageLoop::current()); 172 DCHECK_EQ(message_loop_, MessageLoop::current());
169 OMX_CALLBACKTYPE omx_accelerator_callbacks = { 173 static OMX_CALLBACKTYPE omx_accelerator_callbacks = {
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Why?
170 &OmxVideoDecodeAccelerator::EventHandler, 174 &OmxVideoDecodeAccelerator::EventHandler,
171 &OmxVideoDecodeAccelerator::EmptyBufferCallback, 175 &OmxVideoDecodeAccelerator::EmptyBufferCallback,
172 &OmxVideoDecodeAccelerator::FillBufferCallback 176 &OmxVideoDecodeAccelerator::FillBufferCallback
173 }; 177 };
174 178
175 // TODO(vhiremath@nvidia.com) Get this role_name from the configs 179 // TODO(vhiremath@nvidia.com) Get this role_name from the configs
176 // For now hard coding to avc. 180 // For now hard coding to avc.
177 OMX_STRING role_name = const_cast<OMX_STRING>("video_decoder.avc"); 181 OMX_STRING role_name = const_cast<OMX_STRING>("video_decoder.avc");
178 // Get the first component for this role and set the role on it. 182 // Get the first component for this role and set the role on it.
179 OMX_U32 num_components = 1; 183 OMX_U32 num_components = 1;
(...skipping 12 matching lines...) Expand all
192 this, &omx_accelerator_callbacks); 196 this, &omx_accelerator_callbacks);
193 RETURN_ON_OMX_FAILURE(result, 197 RETURN_ON_OMX_FAILURE(result,
194 "Failed to OMX_GetHandle on: " << component.get(), 198 "Failed to OMX_GetHandle on: " << component.get(),
195 PLATFORM_FAILURE, false); 199 PLATFORM_FAILURE, false);
196 client_state_ = OMX_StateLoaded; 200 client_state_ = OMX_StateLoaded;
197 201
198 component_name_is_nvidia_h264ext_ = !strcmp( 202 component_name_is_nvidia_h264ext_ = !strcmp(
199 reinterpret_cast<char *>(component.get()), 203 reinterpret_cast<char *>(component.get()),
200 "OMX.Nvidia.h264ext.decode"); 204 "OMX.Nvidia.h264ext.decode");
201 205
206 component_name_is_sec_h264ext_ = !strcmp(
207 reinterpret_cast<char *>(component.get()),
208 "OMX.SEC.AVC.Decoder");
209 Gles2TextureToEglImageTranslator* texture_to_egl_image_translator =
210 new Gles2TextureToEglImageTranslator(component_name_is_sec_h264ext_);
211 texture_to_egl_image_translator_.reset(texture_to_egl_image_translator);
212
202 // Get the port information. This will obtain information about the number of 213 // Get the port information. This will obtain information about the number of
203 // ports and index of the first port. 214 // ports and index of the first port.
204 OMX_PORT_PARAM_TYPE port_param; 215 OMX_PORT_PARAM_TYPE port_param;
205 InitParam(*this, &port_param); 216 InitParam(*this, &port_param);
206 result = OMX_GetParameter(component_handle_, OMX_IndexParamVideoInit, 217 result = OMX_GetParameter(component_handle_, OMX_IndexParamVideoInit,
207 &port_param); 218 &port_param);
208 RETURN_ON_FAILURE(result == OMX_ErrorNone && port_param.nPorts == 2, 219 RETURN_ON_FAILURE(result == OMX_ErrorNone && port_param.nPorts == 2,
209 "Failed to get Port Param: " << result << ", " 220 "Failed to get Port Param: " << result << ", "
210 << port_param.nPorts, 221 << port_param.nPorts,
211 PLATFORM_FAILURE, false); 222 PLATFORM_FAILURE, false);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 &port_format); 260 &port_format);
250 RETURN_ON_OMX_FAILURE(result, 261 RETURN_ON_OMX_FAILURE(result,
251 "GetParameter(OMX_IndexParamPortDefinition) failed", 262 "GetParameter(OMX_IndexParamPortDefinition) failed",
252 PLATFORM_FAILURE, false); 263 PLATFORM_FAILURE, false);
253 RETURN_ON_FAILURE(OMX_DirOutput == port_format.eDir, "Expect Output Port", 264 RETURN_ON_FAILURE(OMX_DirOutput == port_format.eDir, "Expect Output Port",
254 PLATFORM_FAILURE, false); 265 PLATFORM_FAILURE, false);
255 266
256 // Set output port parameters. 267 // Set output port parameters.
257 port_format.nBufferCountActual = kNumPictureBuffers; 268 port_format.nBufferCountActual = kNumPictureBuffers;
258 port_format.nBufferCountMin = kNumPictureBuffers; 269 port_format.nBufferCountMin = kNumPictureBuffers;
270 output_buffer_size_ = port_format.nBufferSize;
259 // Force an OMX_EventPortSettingsChanged event to be sent once we know the 271 // Force an OMX_EventPortSettingsChanged event to be sent once we know the
260 // stream's real dimensions (which can only happen once some Decode() work has 272 // stream's real dimensions (which can only happen once some Decode() work has
261 // been done). 273 // been done).
262 port_format.format.video.nFrameWidth = -1; 274 port_format.format.video.nFrameWidth = -1;
263 port_format.format.video.nFrameHeight = -1; 275 port_format.format.video.nFrameHeight = -1;
264 result = OMX_SetParameter(component_handle_, 276 result = OMX_SetParameter(component_handle_,
265 OMX_IndexParamPortDefinition, 277 OMX_IndexParamPortDefinition,
266 &port_format); 278 &port_format);
267 RETURN_ON_OMX_FAILURE(result, 279 RETURN_ON_OMX_FAILURE(result,
268 "SetParameter(OMX_IndexParamPortDefinition) failed", 280 "SetParameter(OMX_IndexParamPortDefinition) failed",
269 PLATFORM_FAILURE, false); 281 PLATFORM_FAILURE, false);
270
271 // Fill the component with fake output buffers. This seems to be required for
272 // the component to move from Loaded to Idle. How bogus.
273 for (int i = 0; i < kNumPictureBuffers; ++i) {
274 OMX_BUFFERHEADERTYPE* buffer;
275 result = OMX_UseBuffer(component_handle_, &buffer, output_port_,
276 NULL, 0, reinterpret_cast<OMX_U8*>(0x1));
277 RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer failed",
278 PLATFORM_FAILURE, false);
279 buffer->pAppPrivate = NULL;
280 buffer->nTimeStamp = -1;
281 buffer->nOutputPortIndex = output_port_;
282 CHECK(fake_output_buffers_.insert(buffer).second);
283 }
284 return true; 282 return true;
285 } 283 }
286 284
287 void OmxVideoDecodeAccelerator::Decode( 285 void OmxVideoDecodeAccelerator::Decode(
288 const media::BitstreamBuffer& bitstream_buffer) { 286 const media::BitstreamBuffer& bitstream_buffer) {
289 TRACE_EVENT1("Video Decoder", "OVDA::Decode", 287 TRACE_EVENT1("Video Decoder", "OVDA::Decode",
290 "Buffer id", bitstream_buffer.id()); 288 "Buffer id", bitstream_buffer.id());
291 DCHECK_EQ(message_loop_, MessageLoop::current()); 289 DCHECK_EQ(message_loop_, MessageLoop::current());
292 290
293 if (current_state_change_ == RESETTING || 291 if (current_state_change_ == RESETTING ||
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 335
338 void OmxVideoDecodeAccelerator::AssignPictureBuffers( 336 void OmxVideoDecodeAccelerator::AssignPictureBuffers(
339 const std::vector<media::PictureBuffer>& buffers) { 337 const std::vector<media::PictureBuffer>& buffers) {
340 DCHECK_EQ(message_loop_, MessageLoop::current()); 338 DCHECK_EQ(message_loop_, MessageLoop::current());
341 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,); 339 RETURN_ON_FAILURE(CanFillBuffer(), "Can't fill buffer", ILLEGAL_STATE,);
342 340
343 DCHECK_EQ(output_buffers_at_component_, 0); 341 DCHECK_EQ(output_buffers_at_component_, 0);
344 DCHECK_EQ(fake_output_buffers_.size(), 0U); 342 DCHECK_EQ(fake_output_buffers_.size(), 0U);
345 DCHECK_EQ(pictures_.size(), 0U); 343 DCHECK_EQ(pictures_.size(), 0U);
346 344
347 static Gles2TextureToEglImageTranslator texture2eglImage_translator;
348 for (size_t i = 0; i < buffers.size(); ++i) { 345 for (size_t i = 0; i < buffers.size(); ++i) {
349 EGLImageKHR egl_image = texture2eglImage_translator.TranslateToEglImage( 346 EGLImageKHR egl_image =
350 egl_display_, egl_context_, buffers[i].texture_id()); 347 texture_to_egl_image_translator_->TranslateToEglImage(
348 egl_display_, egl_context_,
349 buffers[i].texture_id(),
350 last_requested_picture_buffer_dimensions_);
351 CHECK(pictures_.insert(std::make_pair( 351 CHECK(pictures_.insert(std::make_pair(
352 buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second); 352 buffers[i].id(), OutputPicture(buffers[i], NULL, egl_image))).second);
353 } 353 }
354 354
355 if (pictures_.size() < kNumPictureBuffers) 355 if (pictures_.size() < kNumPictureBuffers)
356 return; // get all the buffers first. 356 return; // get all the buffers first.
357 DCHECK_EQ(pictures_.size(), kNumPictureBuffers); 357 DCHECK_EQ(pictures_.size(), kNumPictureBuffers);
358 358
359 // These do their own RETURN_ON_FAILURE dances. 359 // These do their own RETURN_ON_FAILURE dances.
360 if (!AllocateOutputBuffers()) 360 if (!AllocateOutputBuffers())
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer() Input buffer error", 650 RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer() Input buffer error",
651 PLATFORM_FAILURE, false); 651 PLATFORM_FAILURE, false);
652 buffer->nInputPortIndex = input_port_; 652 buffer->nInputPortIndex = input_port_;
653 buffer->nOffset = 0; 653 buffer->nOffset = 0;
654 buffer->nFlags = 0; 654 buffer->nFlags = 0;
655 free_input_buffers_.push(buffer); 655 free_input_buffers_.push(buffer);
656 } 656 }
657 return true; 657 return true;
658 } 658 }
659 659
660 bool OmxVideoDecodeAccelerator::AllocateFakeOutputBuffers() {
661 // Fill the component with fake output buffers.
662 for (unsigned int i = 0; i < kNumPictureBuffers; ++i) {
663 OMX_BUFFERHEADERTYPE* buffer;
664 OMX_ERRORTYPE result;
665 if (component_name_is_sec_h264ext_) {
666 result = OMX_AllocateBuffer(component_handle_, &buffer, output_port_,
667 NULL, output_buffer_size_);
Ami GONE FROM CHROMIUM 2012/03/12 16:48:30 Since this buffer will never be used for anything
668 RETURN_ON_OMX_FAILURE(result, "OMX_AllocateBuffer failed",
669 PLATFORM_FAILURE, false);
670 } else {
671 result = OMX_UseBuffer(component_handle_, &buffer, output_port_,
672 NULL, 0, reinterpret_cast<OMX_U8*>(0x1));
673 RETURN_ON_OMX_FAILURE(result, "OMX_UseBuffer failed",
674 PLATFORM_FAILURE, false);
675 }
676 buffer->pAppPrivate = NULL;
677 buffer->nTimeStamp = -1;
678 buffer->nOutputPortIndex = output_port_;
679 CHECK(fake_output_buffers_.insert(buffer).second);
680 }
681 return true;
682 }
683
660 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() { 684 bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() {
661 DCHECK_EQ(message_loop_, MessageLoop::current()); 685 DCHECK_EQ(message_loop_, MessageLoop::current());
662 686
663 DCHECK(!pictures_.empty()); 687 DCHECK(!pictures_.empty());
664 for (OutputPictureById::iterator it = pictures_.begin(); 688 for (OutputPictureById::iterator it = pictures_.begin();
665 it != pictures_.end(); ++it) { 689 it != pictures_.end(); ++it) {
666 media::PictureBuffer& picture_buffer = it->second.picture_buffer; 690 media::PictureBuffer& picture_buffer = it->second.picture_buffer;
667 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header; 691 OMX_BUFFERHEADERTYPE** omx_buffer = &it->second.omx_buffer_header;
668 DCHECK(!*omx_buffer); 692 DCHECK(!*omx_buffer);
669 OMX_ERRORTYPE result = OMX_UseEGLImage( 693 OMX_ERRORTYPE result = OMX_UseEGLImage(
(...skipping 19 matching lines...) Expand all
689 free_input_buffers_.pop(); 713 free_input_buffers_.pop();
690 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer); 714 result = OMX_FreeBuffer(component_handle_, input_port_, omx_buffer);
691 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,); 715 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,);
692 } 716 }
693 } 717 }
694 718
695 void OmxVideoDecodeAccelerator::FreeOutputBuffers() { 719 void OmxVideoDecodeAccelerator::FreeOutputBuffers() {
696 DCHECK_EQ(message_loop_, MessageLoop::current()); 720 DCHECK_EQ(message_loop_, MessageLoop::current());
697 // Calls to OMX to free buffers. 721 // Calls to OMX to free buffers.
698 OMX_ERRORTYPE result; 722 OMX_ERRORTYPE result;
699 static Gles2TextureToEglImageTranslator texture2eglImage_translator;
700 for (OutputPictureById::iterator it = pictures_.begin(); 723 for (OutputPictureById::iterator it = pictures_.begin();
701 it != pictures_.end(); ++it) { 724 it != pictures_.end(); ++it) {
702 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header; 725 OMX_BUFFERHEADERTYPE* omx_buffer = it->second.omx_buffer_header;
703 DCHECK(omx_buffer); 726 DCHECK(omx_buffer);
704 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate); 727 delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate);
705 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer); 728 result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer);
706 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,); 729 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer", PLATFORM_FAILURE,);
707 texture2eglImage_translator.DestroyEglImage(egl_display_, 730 texture_to_egl_image_translator_->DestroyEglImage(egl_display_,
708 it->second.egl_image); 731 it->second.egl_image);
709 if (client_) 732 if (client_)
710 client_->DismissPictureBuffer(it->first); 733 client_->DismissPictureBuffer(it->first);
711 } 734 }
712 pictures_.clear(); 735 pictures_.clear();
713 } 736 }
714 737
715 void OmxVideoDecodeAccelerator::OnOutputPortDisabled() { 738 void OmxVideoDecodeAccelerator::OnOutputPortDisabled() {
716 DCHECK_EQ(message_loop_, MessageLoop::current()); 739 DCHECK_EQ(message_loop_, MessageLoop::current());
717 OMX_PARAM_PORTDEFINITIONTYPE port_format; 740 OMX_PARAM_PORTDEFINITIONTYPE port_format;
718 InitParam(*this, &port_format); 741 InitParam(*this, &port_format);
719 port_format.nPortIndex = output_port_; 742 port_format.nPortIndex = output_port_;
720 OMX_ERRORTYPE result = OMX_GetParameter( 743 OMX_ERRORTYPE result = OMX_GetParameter(
721 component_handle_, OMX_IndexParamPortDefinition, &port_format); 744 component_handle_, OMX_IndexParamPortDefinition, &port_format);
722 RETURN_ON_OMX_FAILURE(result, "OMX_GetParameter", PLATFORM_FAILURE,); 745 RETURN_ON_OMX_FAILURE(result, "OMX_GetParameter", PLATFORM_FAILURE,);
723 DCHECK_EQ(port_format.nBufferCountMin, kNumPictureBuffers); 746 DCHECK_EQ(port_format.nBufferCountMin, kNumPictureBuffers);
724 747
725 // TODO(fischman): to support mid-stream resize, need to free/dismiss any 748 // TODO(fischman): to support mid-stream resize, need to free/dismiss any
726 // |pictures_| we already have. Make sure that the shutdown-path agrees with 749 // |pictures_| we already have. Make sure that the shutdown-path agrees with
727 // this (there's already freeing logic there, which should not be duplicated). 750 // this (there's already freeing logic there, which should not be duplicated).
728 751
729 // Request picture buffers to be handed to the component. 752 // Request picture buffers to be handed to the component.
730 // ProvidePictureBuffers() will trigger AssignPictureBuffers, which ultimately 753 // ProvidePictureBuffers() will trigger AssignPictureBuffers, which ultimately
731 // assigns the textures to the component and re-enables the port. 754 // assigns the textures to the component and re-enables the port.
732 const OMX_VIDEO_PORTDEFINITIONTYPE& vformat = port_format.format.video; 755 const OMX_VIDEO_PORTDEFINITIONTYPE& vformat = port_format.format.video;
756 last_requested_picture_buffer_dimensions_.SetSize(vformat.nFrameWidth,
757 vformat.nFrameHeight);
733 if (client_) { 758 if (client_) {
734 client_->ProvidePictureBuffers( 759 client_->ProvidePictureBuffers(
735 kNumPictureBuffers, 760 kNumPictureBuffers,
736 gfx::Size(vformat.nFrameWidth, vformat.nFrameHeight)); 761 gfx::Size(vformat.nFrameWidth, vformat.nFrameHeight));
737 } 762 }
738 } 763 }
739 764
740 void OmxVideoDecodeAccelerator::OnOutputPortEnabled() { 765 void OmxVideoDecodeAccelerator::OnOutputPortEnabled() {
741 DCHECK_EQ(message_loop_, MessageLoop::current()); 766 DCHECK_EQ(message_loop_, MessageLoop::current());
742 767
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1058
1034 bool OmxVideoDecodeAccelerator::SendCommandToPort( 1059 bool OmxVideoDecodeAccelerator::SendCommandToPort(
1035 OMX_COMMANDTYPE cmd, int port_index) { 1060 OMX_COMMANDTYPE cmd, int port_index) {
1036 DCHECK_EQ(message_loop_, MessageLoop::current()); 1061 DCHECK_EQ(message_loop_, MessageLoop::current());
1037 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, 1062 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_,
1038 cmd, port_index, 0); 1063 cmd, port_index, 0);
1039 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, 1064 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd,
1040 PLATFORM_FAILURE, false); 1065 PLATFORM_FAILURE, false);
1041 return true; 1066 return true;
1042 } 1067 }
OLDNEW
« no previous file with comments | « content/common/gpu/media/omx_video_decode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698