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 #ifndef CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
9 #include <map> | 9 #include <map> |
10 #include <queue> | 10 #include <queue> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "base/message_loop.h" | 19 #include "base/message_loop.h" |
20 #include "base/shared_memory.h" | 20 #include "base/shared_memory.h" |
21 #include "media/video/video_decode_accelerator.h" | 21 #include "media/video/video_decode_accelerator.h" |
22 #include "third_party/angle/include/EGL/egl.h" | 22 #include "third_party/angle/include/EGL/egl.h" |
23 #include "third_party/angle/include/EGL/eglext.h" | 23 #include "third_party/angle/include/EGL/eglext.h" |
24 #include "third_party/openmax/il/OMX_Component.h" | 24 #include "third_party/openmax/il/OMX_Component.h" |
25 #include "third_party/openmax/il/OMX_Core.h" | 25 #include "third_party/openmax/il/OMX_Core.h" |
26 #include "third_party/openmax/il/OMX_Video.h" | 26 #include "third_party/openmax/il/OMX_Video.h" |
27 | 27 |
| 28 class Gles2TextureToEglImageTranslator; |
| 29 |
28 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. | 30 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. |
29 // The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to | 31 // The implementation assumes an OpenMAX IL 1.1.2 implementation conforming to |
30 // http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pd
f | 32 // http://www.khronos.org/registry/omxil/specs/OpenMAX_IL_1_1_2_Specification.pd
f |
31 // | 33 // |
32 // This class lives on a single thread and DCHECKs that it is never accessed | 34 // This class lives on a single thread and DCHECKs that it is never accessed |
33 // from any other. OMX callbacks are trampolined from the OMX component's | 35 // from any other. OMX callbacks are trampolined from the OMX component's |
34 // thread to maintain this invariant. The only exception to thread-unsafety is | 36 // thread to maintain this invariant. The only exception to thread-unsafety is |
35 // that references can be added from any thread (practically used only by the | 37 // that references can be added from any thread (practically used only by the |
36 // OMX thread). | 38 // OMX thread). |
37 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 39 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 }; | 82 }; |
81 typedef std::map<int32, OutputPicture> OutputPictureById; | 83 typedef std::map<int32, OutputPicture> OutputPictureById; |
82 | 84 |
83 MessageLoop* message_loop_; | 85 MessageLoop* message_loop_; |
84 OMX_HANDLETYPE component_handle_; | 86 OMX_HANDLETYPE component_handle_; |
85 | 87 |
86 // Create the Component for OMX. Handles all OMX initialization. | 88 // Create the Component for OMX. Handles all OMX initialization. |
87 bool CreateComponent(); | 89 bool CreateComponent(); |
88 // Buffer allocation/free methods for input and output buffers. | 90 // Buffer allocation/free methods for input and output buffers. |
89 bool AllocateInputBuffers(); | 91 bool AllocateInputBuffers(); |
| 92 bool AllocateFakeOutputBuffers(); |
90 bool AllocateOutputBuffers(); | 93 bool AllocateOutputBuffers(); |
91 void FreeInputBuffers(); | 94 void FreeInputBuffers(); |
92 void FreeOutputBuffers(); | 95 void FreeOutputBuffers(); |
93 | 96 |
94 // Methods to handle OMX state transitions. See section 3.1.1.2 of the spec. | 97 // Methods to handle OMX state transitions. See section 3.1.1.2 of the spec. |
95 // Request transitioning OMX component to some other state. | 98 // Request transitioning OMX component to some other state. |
96 void BeginTransitionToState(OMX_STATETYPE new_state); | 99 void BeginTransitionToState(OMX_STATETYPE new_state); |
97 // The callback received when the OMX component has transitioned. | 100 // The callback received when the OMX component has transitioned. |
98 void DispatchStateReached(OMX_STATETYPE reached); | 101 void DispatchStateReached(OMX_STATETYPE reached); |
99 // Callbacks handling transitioning to specific states during state changes. | 102 // Callbacks handling transitioning to specific states during state changes. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // Following are input port related variables. | 144 // Following are input port related variables. |
142 int input_buffer_count_; | 145 int input_buffer_count_; |
143 int input_buffer_size_; | 146 int input_buffer_size_; |
144 OMX_U32 input_port_; | 147 OMX_U32 input_port_; |
145 int input_buffers_at_component_; | 148 int input_buffers_at_component_; |
146 | 149 |
147 // Following are output port related variables. | 150 // Following are output port related variables. |
148 OMX_U32 output_port_; | 151 OMX_U32 output_port_; |
149 int output_buffers_at_component_; | 152 int output_buffers_at_component_; |
150 | 153 |
| 154 gfx::Size last_requested_picture_buffer_dimensions_; |
| 155 |
151 // NOTE: someday there may be multiple contexts for a single decoder. But not | 156 // NOTE: someday there may be multiple contexts for a single decoder. But not |
152 // today. | 157 // today. |
153 // TODO(fischman,vrk): handle lost contexts? | 158 // TODO(fischman,vrk): handle lost contexts? |
154 EGLDisplay egl_display_; | 159 EGLDisplay egl_display_; |
155 EGLContext egl_context_; | 160 EGLContext egl_context_; |
156 | 161 |
157 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. | 162 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. |
158 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; | 163 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; |
159 | 164 |
160 // For output buffer recycling cases. | 165 // For output buffer recycling cases. |
(...skipping 11 matching lines...) Expand all Loading... |
172 BitstreamBufferList queued_bitstream_buffers_; | 177 BitstreamBufferList queued_bitstream_buffers_; |
173 // Available output picture buffers released during Reset() and awaiting | 178 // Available output picture buffers released during Reset() and awaiting |
174 // re-use once Reset is done. Is empty most of the time and drained right | 179 // re-use once Reset is done. Is empty most of the time and drained right |
175 // before NotifyResetDone is sent. | 180 // before NotifyResetDone is sent. |
176 std::vector<int> queued_picture_buffer_ids_; | 181 std::vector<int> queued_picture_buffer_ids_; |
177 | 182 |
178 // To expose client callbacks from VideoDecodeAccelerator. | 183 // To expose client callbacks from VideoDecodeAccelerator. |
179 // NOTE: all calls to this object *MUST* be executed in message_loop_. | 184 // NOTE: all calls to this object *MUST* be executed in message_loop_. |
180 Client* client_; | 185 Client* client_; |
181 | 186 |
182 // These two members are only used during Initialization. | 187 scoped_ptr<Gles2TextureToEglImageTranslator> texture_to_egl_image_translator_; |
| 188 |
| 189 // These members are only used during Initialization. |
183 // OMX_AVCProfile requested during Initialization. | 190 // OMX_AVCProfile requested during Initialization. |
184 uint32 profile_; | 191 uint32 profile_; |
185 bool component_name_is_nvidia_h264ext_; | 192 bool component_name_is_nvidia_h264ext_; |
186 | 193 |
187 // Method to handle events | 194 // Method to handle events |
188 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 195 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
189 OMX_U32 data1, | 196 OMX_U32 data1, |
190 OMX_U32 data2); | 197 OMX_U32 data2); |
191 | 198 |
192 // Method to receive buffers from component's input port | 199 // Method to receive buffers from component's input port |
(...skipping 16 matching lines...) Expand all Loading... |
209 OMX_PTR event_data); | 216 OMX_PTR event_data); |
210 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 217 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
211 OMX_PTR priv_data, | 218 OMX_PTR priv_data, |
212 OMX_BUFFERHEADERTYPE* buffer); | 219 OMX_BUFFERHEADERTYPE* buffer); |
213 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 220 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
214 OMX_PTR priv_data, | 221 OMX_PTR priv_data, |
215 OMX_BUFFERHEADERTYPE* buffer); | 222 OMX_BUFFERHEADERTYPE* buffer); |
216 }; | 223 }; |
217 | 224 |
218 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 225 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |