OLD | NEW |
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" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 OMX_U32 num_components = 1; | 183 OMX_U32 num_components = 1; |
184 std::string component(OMX_MAX_STRINGNAME_SIZE, '\0'); | 184 std::string component(OMX_MAX_STRINGNAME_SIZE, '\0'); |
185 char* component_as_array = string_as_array(&component); | 185 char* component_as_array = string_as_array(&component); |
186 OMX_ERRORTYPE result = omx_get_components_of_role( | 186 OMX_ERRORTYPE result = omx_get_components_of_role( |
187 role_name, &num_components, | 187 role_name, &num_components, |
188 reinterpret_cast<OMX_U8**>(&component_as_array)); | 188 reinterpret_cast<OMX_U8**>(&component_as_array)); |
189 RETURN_ON_OMX_FAILURE(result, "Unsupported role: " << role_name, | 189 RETURN_ON_OMX_FAILURE(result, "Unsupported role: " << role_name, |
190 PLATFORM_FAILURE, false); | 190 PLATFORM_FAILURE, false); |
191 RETURN_ON_FAILURE(num_components == 1, "No components for: " << role_name, | 191 RETURN_ON_FAILURE(num_components == 1, "No components for: " << role_name, |
192 PLATFORM_FAILURE, false); | 192 PLATFORM_FAILURE, false); |
193 component_name_is_nvidia_h264ext_ = component == "OMX.Nvidia.h264ext.decode"; | 193 component_name_is_nvidia_h264ext_ = StartsWithASCII( |
| 194 component, "OMX.Nvidia.h264ext.decode", true); |
194 | 195 |
195 // Get the handle to the component. | 196 // Get the handle to the component. |
196 result = omx_gethandle( | 197 result = omx_gethandle( |
197 &component_handle_, | 198 &component_handle_, |
198 reinterpret_cast<OMX_STRING>(string_as_array(&component)), | 199 reinterpret_cast<OMX_STRING>(string_as_array(&component)), |
199 this, &omx_accelerator_callbacks); | 200 this, &omx_accelerator_callbacks); |
200 RETURN_ON_OMX_FAILURE(result, | 201 RETURN_ON_OMX_FAILURE(result, |
201 "Failed to OMX_GetHandle on: " << component, | 202 "Failed to OMX_GetHandle on: " << component, |
202 PLATFORM_FAILURE, false); | 203 PLATFORM_FAILURE, false); |
203 client_state_ = OMX_StateLoaded; | 204 client_state_ = OMX_StateLoaded; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 PLATFORM_FAILURE,); | 511 PLATFORM_FAILURE,); |
511 OMX_VIDEO_PARAM_PROFILELEVELTYPE video_profile_level; | 512 OMX_VIDEO_PARAM_PROFILELEVELTYPE video_profile_level; |
512 InitParam(*this, &video_profile_level); | 513 InitParam(*this, &video_profile_level); |
513 DCHECK_EQ(codec_, H264); | 514 DCHECK_EQ(codec_, H264); |
514 video_profile_level.eProfile = h264_profile_; | 515 video_profile_level.eProfile = h264_profile_; |
515 result = OMX_SetConfig(component_handle_, extension_index, | 516 result = OMX_SetConfig(component_handle_, extension_index, |
516 &video_profile_level); | 517 &video_profile_level); |
517 RETURN_ON_OMX_FAILURE(result, | 518 RETURN_ON_OMX_FAILURE(result, |
518 "Resource Allocation failed", | 519 "Resource Allocation failed", |
519 PLATFORM_FAILURE,); | 520 PLATFORM_FAILURE,); |
| 521 |
| 522 // The OMX spec doesn't say whether (0,0) is bottom-left or top-left, but |
| 523 // NVIDIA OMX implementation used with this class chooses the opposite |
| 524 // of other APIs used for HW decode (DXVA, OS/X, VAAPI). So we request |
| 525 // a mirror here to avoid having to track Y-orientation throughout the |
| 526 // stack (particularly unattractive because this is exposed to ppapi |
| 527 // plugin authors and NaCl programs). |
| 528 OMX_CONFIG_MIRRORTYPE mirror_config; |
| 529 InitParam(*this, &mirror_config); |
| 530 result = OMX_GetConfig(component_handle_, |
| 531 OMX_IndexConfigCommonMirror, &mirror_config); |
| 532 RETURN_ON_OMX_FAILURE(result, "Failed to get mirror", PLATFORM_FAILURE,); |
| 533 mirror_config.eMirror = OMX_MirrorVertical; |
| 534 result = OMX_SetConfig(component_handle_, |
| 535 OMX_IndexConfigCommonMirror, &mirror_config); |
| 536 RETURN_ON_OMX_FAILURE(result, "Failed to set mirror", PLATFORM_FAILURE,); |
520 } | 537 } |
521 BeginTransitionToState(OMX_StateExecuting); | 538 BeginTransitionToState(OMX_StateExecuting); |
522 } | 539 } |
523 | 540 |
524 void OmxVideoDecodeAccelerator::OnReachedExecutingInInitializing() { | 541 void OmxVideoDecodeAccelerator::OnReachedExecutingInInitializing() { |
525 DCHECK_EQ(client_state_, OMX_StateIdle); | 542 DCHECK_EQ(client_state_, OMX_StateIdle); |
526 client_state_ = OMX_StateExecuting; | 543 client_state_ = OMX_StateExecuting; |
527 current_state_change_ = NO_TRANSITION; | 544 current_state_change_ = NO_TRANSITION; |
528 | 545 |
529 // Request filling of our fake buffers to trigger decode processing. In | 546 // Request filling of our fake buffers to trigger decode processing. In |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1146 |
1130 bool OmxVideoDecodeAccelerator::SendCommandToPort( | 1147 bool OmxVideoDecodeAccelerator::SendCommandToPort( |
1131 OMX_COMMANDTYPE cmd, int port_index) { | 1148 OMX_COMMANDTYPE cmd, int port_index) { |
1132 DCHECK_EQ(message_loop_, MessageLoop::current()); | 1149 DCHECK_EQ(message_loop_, MessageLoop::current()); |
1133 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1150 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
1134 cmd, port_index, 0); | 1151 cmd, port_index, 0); |
1135 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, | 1152 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, |
1136 PLATFORM_FAILURE, false); | 1153 PLATFORM_FAILURE, false); |
1137 return true; | 1154 return true; |
1138 } | 1155 } |
OLD | NEW |