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(component, |
194 "OMX.Nvidia.h264ext.decode", true); | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
indent is wrong
| |
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 return; | 492 return; |
492 OMX_ERRORTYPE result = OMX_SendCommand( | 493 OMX_ERRORTYPE result = OMX_SendCommand( |
493 component_handle_, OMX_CommandStateSet, new_state, 0); | 494 component_handle_, OMX_CommandStateSet, new_state, 0); |
494 RETURN_ON_OMX_FAILURE(result, "SendCommand(OMX_CommandStateSet) failed", | 495 RETURN_ON_OMX_FAILURE(result, "SendCommand(OMX_CommandStateSet) failed", |
495 PLATFORM_FAILURE,); | 496 PLATFORM_FAILURE,); |
496 } | 497 } |
497 | 498 |
498 void OmxVideoDecodeAccelerator::OnReachedIdleInInitializing() { | 499 void OmxVideoDecodeAccelerator::OnReachedIdleInInitializing() { |
499 DCHECK_EQ(client_state_, OMX_StateLoaded); | 500 DCHECK_EQ(client_state_, OMX_StateLoaded); |
500 client_state_ = OMX_StateIdle; | 501 client_state_ = OMX_StateIdle; |
502 OMX_ERRORTYPE result = OMX_ErrorNone; | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
unnecessary (and counter to chromium style; declar
| |
501 // Query the resources with the component. | 503 // Query the resources with the component. |
502 if (component_name_is_nvidia_h264ext_) { | 504 if (component_name_is_nvidia_h264ext_) { |
503 OMX_INDEXTYPE extension_index; | 505 OMX_INDEXTYPE extension_index; |
504 OMX_ERRORTYPE result = OMX_GetExtensionIndex( | 506 result = OMX_GetExtensionIndex( |
505 component_handle_, | 507 component_handle_, |
506 const_cast<char*>("OMX.Nvidia.index.config.checkresources"), | 508 const_cast<char*>("OMX.Nvidia.index.config.checkresources"), |
507 &extension_index); | 509 &extension_index); |
508 RETURN_ON_OMX_FAILURE(result, | 510 RETURN_ON_OMX_FAILURE(result, |
509 "Failed to get the extension", | 511 "Failed to get the extension", |
510 PLATFORM_FAILURE,); | 512 PLATFORM_FAILURE,); |
511 OMX_VIDEO_PARAM_PROFILELEVELTYPE video_profile_level; | 513 OMX_VIDEO_PARAM_PROFILELEVELTYPE video_profile_level; |
512 InitParam(*this, &video_profile_level); | 514 InitParam(*this, &video_profile_level); |
513 DCHECK_EQ(codec_, H264); | 515 DCHECK_EQ(codec_, H264); |
514 video_profile_level.eProfile = h264_profile_; | 516 video_profile_level.eProfile = h264_profile_; |
515 result = OMX_SetConfig(component_handle_, extension_index, | 517 result = OMX_SetConfig(component_handle_, extension_index, |
516 &video_profile_level); | 518 &video_profile_level); |
517 RETURN_ON_OMX_FAILURE(result, | 519 RETURN_ON_OMX_FAILURE(result, |
518 "Resource Allocation failed", | 520 "Resource Allocation failed", |
519 PLATFORM_FAILURE,); | 521 PLATFORM_FAILURE,); |
522 | |
523 // The OMX spec doesn't say whether (0,0) is bottom-left or top-left, but both | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
indent is off
| |
524 // OMX implementations used with this class far choose the same, and are the | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
this isn't true anymore (which is why this code is
| |
525 // opposite of other APIs used for HW decode (DXVA, OS/X, VAAPI). So we | |
526 // request a mirror here to avoid having to track Y-orientation throughout the | |
527 // stack (particularly unattractive because this is exposed to ppapi plugin | |
528 // authors and NaCl programs). | |
529 OMX_CONFIG_MIRRORTYPE mirror_config; | |
530 InitParam(*this, &mirror_config); | |
531 result = OMX_GetConfig( component_handle_, | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
extra space
| |
532 OMX_IndexConfigCommonMirror, &mirror_config); | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
indent is off
| |
533 RETURN_ON_OMX_FAILURE(result, "Failed to get mirror", PLATFORM_FAILURE,); | |
534 mirror_config.eMirror = OMX_MirrorVertical; | |
535 result = OMX_SetConfig( component_handle_, | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
extra space
| |
536 OMX_IndexConfigCommonMirror, &mirror_config); | |
Ami GONE FROM CHROMIUM
2012/09/21 16:35:09
indent is off
| |
537 RETURN_ON_OMX_FAILURE(result, "Failed to set mirror", PLATFORM_FAILURE,); | |
520 } | 538 } |
521 BeginTransitionToState(OMX_StateExecuting); | 539 BeginTransitionToState(OMX_StateExecuting); |
522 } | 540 } |
523 | 541 |
524 void OmxVideoDecodeAccelerator::OnReachedExecutingInInitializing() { | 542 void OmxVideoDecodeAccelerator::OnReachedExecutingInInitializing() { |
525 DCHECK_EQ(client_state_, OMX_StateIdle); | 543 DCHECK_EQ(client_state_, OMX_StateIdle); |
526 client_state_ = OMX_StateExecuting; | 544 client_state_ = OMX_StateExecuting; |
527 current_state_change_ = NO_TRANSITION; | 545 current_state_change_ = NO_TRANSITION; |
528 | 546 |
529 // Request filling of our fake buffers to trigger decode processing. In | 547 // 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 | 1147 |
1130 bool OmxVideoDecodeAccelerator::SendCommandToPort( | 1148 bool OmxVideoDecodeAccelerator::SendCommandToPort( |
1131 OMX_COMMANDTYPE cmd, int port_index) { | 1149 OMX_COMMANDTYPE cmd, int port_index) { |
1132 DCHECK_EQ(message_loop_, MessageLoop::current()); | 1150 DCHECK_EQ(message_loop_, MessageLoop::current()); |
1133 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1151 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
1134 cmd, port_index, 0); | 1152 cmd, port_index, 0); |
1135 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, | 1153 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, |
1136 PLATFORM_FAILURE, false); | 1154 PLATFORM_FAILURE, false); |
1137 return true; | 1155 return true; |
1138 } | 1156 } |
OLD | NEW |