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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } while (0) | 91 } while (0) |
92 | 92 |
93 // OMX-specific version of RETURN_ON_FAILURE which compares with OMX_ErrorNone. | 93 // OMX-specific version of RETURN_ON_FAILURE which compares with OMX_ErrorNone. |
94 #define RETURN_ON_OMX_FAILURE(omx_result, log, error, ret_val) \ | 94 #define RETURN_ON_OMX_FAILURE(omx_result, log, error, ret_val) \ |
95 RETURN_ON_FAILURE( \ | 95 RETURN_ON_FAILURE( \ |
96 ((omx_result) == OMX_ErrorNone), \ | 96 ((omx_result) == OMX_ErrorNone), \ |
97 log << ", OMX result: 0x" << std::hex << omx_result, \ | 97 log << ", OMX result: 0x" << std::hex << omx_result, \ |
98 error, ret_val) | 98 error, ret_val) |
99 | 99 |
100 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( | 100 OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator( |
| 101 EGLDisplay egl_display, EGLContext egl_context, |
101 media::VideoDecodeAccelerator::Client* client) | 102 media::VideoDecodeAccelerator::Client* client) |
102 : message_loop_(MessageLoop::current()), | 103 : message_loop_(MessageLoop::current()), |
103 component_handle_(NULL), | 104 component_handle_(NULL), |
104 weak_this_(base::AsWeakPtr(this)), | 105 weak_this_(base::AsWeakPtr(this)), |
105 init_begun_(false), | 106 init_begun_(false), |
106 client_state_(OMX_StateMax), | 107 client_state_(OMX_StateMax), |
107 current_state_change_(NO_TRANSITION), | 108 current_state_change_(NO_TRANSITION), |
108 input_buffer_count_(0), | 109 input_buffer_count_(0), |
109 input_buffer_size_(0), | 110 input_buffer_size_(0), |
110 input_port_(0), | 111 input_port_(0), |
111 input_buffers_at_component_(0), | 112 input_buffers_at_component_(0), |
112 output_port_(0), | 113 output_port_(0), |
113 output_buffers_at_component_(0), | 114 output_buffers_at_component_(0), |
| 115 egl_display_(egl_display), |
| 116 egl_context_(egl_context), |
114 client_(client), | 117 client_(client), |
115 codec_(UNKNOWN), | 118 codec_(UNKNOWN), |
116 h264_profile_(OMX_VIDEO_AVCProfileMax), | 119 h264_profile_(OMX_VIDEO_AVCProfileMax), |
117 component_name_is_nvidia_h264ext_(false) { | 120 component_name_is_nvidia_h264ext_(false) { |
118 RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(), | 121 RETURN_ON_FAILURE(AreOMXFunctionPointersInitialized(), |
119 "Failed to load openmax library", PLATFORM_FAILURE,); | 122 "Failed to load openmax library", PLATFORM_FAILURE,); |
120 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core", | 123 RETURN_ON_OMX_FAILURE(omx_init(), "Failed to init OpenMAX core", |
121 PLATFORM_FAILURE,); | 124 PLATFORM_FAILURE,); |
122 } | 125 } |
123 | 126 |
124 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { | 127 OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() { |
125 DCHECK_EQ(message_loop_, MessageLoop::current()); | 128 DCHECK_EQ(message_loop_, MessageLoop::current()); |
126 DCHECK(free_input_buffers_.empty()); | 129 DCHECK(free_input_buffers_.empty()); |
127 DCHECK_EQ(0, input_buffers_at_component_); | 130 DCHECK_EQ(0, input_buffers_at_component_); |
128 DCHECK_EQ(0, output_buffers_at_component_); | 131 DCHECK_EQ(0, output_buffers_at_component_); |
129 DCHECK(pictures_.empty()); | 132 DCHECK(pictures_.empty()); |
130 } | 133 } |
131 | 134 |
132 void OmxVideoDecodeAccelerator::SetEglState( | |
133 EGLDisplay egl_display, EGLContext egl_context) { | |
134 DCHECK_EQ(message_loop_, MessageLoop::current()); | |
135 egl_display_ = egl_display; | |
136 egl_context_ = egl_context; | |
137 } | |
138 | |
139 // This is to initialize the OMX data structures to default values. | 135 // This is to initialize the OMX data structures to default values. |
140 template <typename T> | 136 template <typename T> |
141 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { | 137 static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) { |
142 memset(param, 0, sizeof(T)); | 138 memset(param, 0, sizeof(T)); |
143 param->nVersion.nVersion = 0x00000101; | 139 param->nVersion.nVersion = 0x00000101; |
144 param->nSize = sizeof(T); | 140 param->nSize = sizeof(T); |
145 } | 141 } |
146 | 142 |
147 bool OmxVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) { | 143 bool OmxVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile) { |
148 DCHECK_EQ(message_loop_, MessageLoop::current()); | 144 DCHECK_EQ(message_loop_, MessageLoop::current()); |
(...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1062 | 1058 |
1063 bool OmxVideoDecodeAccelerator::SendCommandToPort( | 1059 bool OmxVideoDecodeAccelerator::SendCommandToPort( |
1064 OMX_COMMANDTYPE cmd, int port_index) { | 1060 OMX_COMMANDTYPE cmd, int port_index) { |
1065 DCHECK_EQ(message_loop_, MessageLoop::current()); | 1061 DCHECK_EQ(message_loop_, MessageLoop::current()); |
1066 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, | 1062 OMX_ERRORTYPE result = OMX_SendCommand(component_handle_, |
1067 cmd, port_index, 0); | 1063 cmd, port_index, 0); |
1068 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, | 1064 RETURN_ON_OMX_FAILURE(result, "SendCommand() failed" << cmd, |
1069 PLATFORM_FAILURE, false); | 1065 PLATFORM_FAILURE, false); |
1070 return true; | 1066 return true; |
1071 } | 1067 } |
OLD | NEW |