| OLD | NEW |
| 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/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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit")); | 43 reinterpret_cast<OMXDeinit>(dlsym(omx_handle, "OMX_Deinit")); |
| 44 | 44 |
| 45 static bool AreOMXFunctionPointersInitialized() { | 45 static bool AreOMXFunctionPointersInitialized() { |
| 46 return (omx_init && omx_gethandle && omx_get_components_of_role && | 46 return (omx_init && omx_gethandle && omx_get_components_of_role && |
| 47 omx_free_handle && omx_deinit); | 47 omx_free_handle && omx_deinit); |
| 48 } | 48 } |
| 49 | 49 |
| 50 // Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values. | 50 // Maps h264-related Profile enum values to OMX_VIDEO_AVCPROFILETYPE values. |
| 51 static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { | 51 static OMX_U32 MapH264ProfileToOMXAVCProfile(uint32 profile) { |
| 52 switch (profile) { | 52 switch (profile) { |
| 53 case media::VideoDecodeAccelerator::H264PROFILE_BASELINE: | 53 case media::H264PROFILE_BASELINE: |
| 54 return OMX_VIDEO_AVCProfileBaseline; | 54 return OMX_VIDEO_AVCProfileBaseline; |
| 55 case media::VideoDecodeAccelerator::H264PROFILE_MAIN: | 55 case media::H264PROFILE_MAIN: |
| 56 return OMX_VIDEO_AVCProfileMain; | 56 return OMX_VIDEO_AVCProfileMain; |
| 57 case media::VideoDecodeAccelerator::H264PROFILE_EXTENDED: | 57 case media::H264PROFILE_EXTENDED: |
| 58 return OMX_VIDEO_AVCProfileExtended; | 58 return OMX_VIDEO_AVCProfileExtended; |
| 59 case media::VideoDecodeAccelerator::H264PROFILE_HIGH: | 59 case media::H264PROFILE_HIGH: |
| 60 return OMX_VIDEO_AVCProfileHigh; | 60 return OMX_VIDEO_AVCProfileHigh; |
| 61 case media::VideoDecodeAccelerator::H264PROFILE_HIGH10PROFILE: | 61 case media::H264PROFILE_HIGH10PROFILE: |
| 62 return OMX_VIDEO_AVCProfileHigh10; | 62 return OMX_VIDEO_AVCProfileHigh10; |
| 63 case media::VideoDecodeAccelerator::H264PROFILE_HIGH422PROFILE: | 63 case media::H264PROFILE_HIGH422PROFILE: |
| 64 return OMX_VIDEO_AVCProfileHigh422; | 64 return OMX_VIDEO_AVCProfileHigh422; |
| 65 case media::VideoDecodeAccelerator::H264PROFILE_HIGH444PREDICTIVEPROFILE: | 65 case media::H264PROFILE_HIGH444PREDICTIVEPROFILE: |
| 66 return OMX_VIDEO_AVCProfileHigh444; | 66 return OMX_VIDEO_AVCProfileHigh444; |
| 67 // Below enums don't have equivalent enum in Openmax. | 67 // Below enums don't have equivalent enum in Openmax. |
| 68 case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEBASELINE: | 68 case media::H264PROFILE_SCALABLEBASELINE: |
| 69 case media::VideoDecodeAccelerator::H264PROFILE_SCALABLEHIGH: | 69 case media::H264PROFILE_SCALABLEHIGH: |
| 70 case media::VideoDecodeAccelerator::H264PROFILE_STEREOHIGH: | 70 case media::H264PROFILE_STEREOHIGH: |
| 71 case media::VideoDecodeAccelerator::H264PROFILE_MULTIVIEWHIGH: | 71 case media::H264PROFILE_MULTIVIEWHIGH: |
| 72 // Nvidia OMX video decoder requires the same resources (as that of the | 72 // Nvidia OMX video decoder requires the same resources (as that of the |
| 73 // High profile) in every profile higher to the Main profile. | 73 // High profile) in every profile higher to the Main profile. |
| 74 return OMX_VIDEO_AVCProfileHigh444; | 74 return OMX_VIDEO_AVCProfileHigh444; |
| 75 default: | 75 default: |
| 76 NOTREACHED(); | 76 NOTREACHED(); |
| 77 return OMX_VIDEO_AVCProfileMax; | 77 return OMX_VIDEO_AVCProfileMax; |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Helper macros for dealing with failure. If |result| evaluates false, emit | 81 // Helper macros for dealing with failure. If |result| evaluates false, emit |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 template <typename T> | 137 template <typename T> |
| 138 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { | 138 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { |
| 139 memset(param, 0, sizeof(T)); | 139 memset(param, 0, sizeof(T)); |
| 140 param->nVersion.nVersion = 0x00000101; | 140 param->nVersion.nVersion = 0x00000101; |
| 141 param->nSize = sizeof(T); | 141 param->nSize = sizeof(T); |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool OmxVideoDecodeAccelerator::Initialize(Profile profile) { | 144 bool OmxVideoDecodeAccelerator::Initialize(Profile profile) { |
| 145 DCHECK_EQ(message_loop_, MessageLoop::current()); | 145 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 146 | 146 |
| 147 RETURN_ON_FAILURE(profile >= H264PROFILE_MIN && profile <= H264PROFILE_MAX, | 147 RETURN_ON_FAILURE((profile >= media::H264PROFILE_MIN && |
| 148 profile <= media::H264PROFILE_MAX), |
| 148 "Only h264 supported", INVALID_ARGUMENT, false); | 149 "Only h264 supported", INVALID_ARGUMENT, false); |
| 149 profile_ = MapH264ProfileToOMXAVCProfile(profile); | 150 profile_ = MapH264ProfileToOMXAVCProfile(profile); |
| 150 RETURN_ON_FAILURE(profile_ != OMX_VIDEO_AVCProfileMax, | 151 RETURN_ON_FAILURE(profile_ != OMX_VIDEO_AVCProfileMax, |
| 151 "Unexpected profile", INVALID_ARGUMENT, false); | 152 "Unexpected profile", INVALID_ARGUMENT, false); |
| 152 | 153 |
| 153 if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances. | 154 if (!CreateComponent()) // Does its own RETURN_ON_FAILURE dances. |
| 154 return false; | 155 return false; |
| 155 | 156 |
| 156 DCHECK_EQ(current_state_change_, NO_TRANSITION); | 157 DCHECK_EQ(current_state_change_, NO_TRANSITION); |
| 157 current_state_change_ = INITIALIZING; | 158 current_state_change_ = INITIALIZING; |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 reinterpret_cast<media::Picture*>(buffer->pAppPrivate); | 762 reinterpret_cast<media::Picture*>(buffer->pAppPrivate); |
| 762 int picture_buffer_id = picture ? picture->picture_buffer_id() : -1; | 763 int picture_buffer_id = picture ? picture->picture_buffer_id() : -1; |
| 763 TRACE_EVENT2("Video Decoder", "OVDA::FillBufferDoneTask", | 764 TRACE_EVENT2("Video Decoder", "OVDA::FillBufferDoneTask", |
| 764 "Buffer id", buffer->nTimeStamp, | 765 "Buffer id", buffer->nTimeStamp, |
| 765 "Picture id", picture_buffer_id); | 766 "Picture id", picture_buffer_id); |
| 766 DCHECK_EQ(message_loop_, MessageLoop::current()); | 767 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 767 DCHECK_GT(output_buffers_at_component_, 0); | 768 DCHECK_GT(output_buffers_at_component_, 0); |
| 768 --output_buffers_at_component_; | 769 --output_buffers_at_component_; |
| 769 | 770 |
| 770 if (fake_output_buffers_.size() && fake_output_buffers_.count(buffer)) { | 771 if (fake_output_buffers_.size() && fake_output_buffers_.count(buffer)) { |
| 771 DCHECK_EQ(fake_output_buffers_.erase(buffer), 1U); | 772 size_t erased = fake_output_buffers_.erase(buffer); |
| 773 DCHECK_EQ(erased, 1U); |
| 772 OMX_ERRORTYPE result = | 774 OMX_ERRORTYPE result = |
| 773 OMX_FreeBuffer(component_handle_, output_port_, buffer); | 775 OMX_FreeBuffer(component_handle_, output_port_, buffer); |
| 774 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); | 776 RETURN_ON_OMX_FAILURE(result, "OMX_FreeBuffer failed", PLATFORM_FAILURE,); |
| 775 return; | 777 return; |
| 776 } | 778 } |
| 777 DCHECK(!fake_output_buffers_.size()); | 779 DCHECK(!fake_output_buffers_.size()); |
| 778 | 780 |
| 779 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) { | 781 if (buffer->nFlags & OMX_BUFFERFLAG_EOS) { |
| 780 // Avoid sending the (fake) EOS buffer to the client. | 782 // Avoid sending the (fake) EOS buffer to the client. |
| 781 return; | 783 return; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 | 1027 |
| 1026 bool OmxVideoDecodeAccelerator::SendCommandToPort( | 1028 bool OmxVideoDecodeAccelerator::SendCommandToPort( |
| 1027 OMX_COMMANDTYPE cmd, int port_index) { | 1029 OMX_COMMANDTYPE cmd, int port_index) { |
| 1028 DCHECK_EQ(message_loop_, MessageLoop::current()); | 1030 DCHECK_EQ(message_loop_, MessageLoop::current()); |
| 1029 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1031 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
| 1030 cmd, port_index, 0); | 1032 cmd, port_index, 0); |
| 1031 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, | 1033 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, |
| 1032 PLATFORM_FAILURE, false); | 1034 PLATFORM_FAILURE, false); |
| 1033 return true; | 1035 return true; |
| 1034 } | 1036 } |
| OLD | NEW |