Chromium Code Reviews| 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_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_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 <string> | 11 #include <string> |
| 12 #include <utility> | 12 #include <utility> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/shared_memory.h" | 19 #include "base/shared_memory.h" |
| 20 #include "media/video/video_decode_accelerator.h" | 20 #include "media/video/video_decode_accelerator.h" |
| 21 #include "third_party/angle/include/EGL/egl.h" | |
| 21 #include "third_party/openmax/il/OMX_Component.h" | 22 #include "third_party/openmax/il/OMX_Component.h" |
| 22 #include "third_party/openmax/il/OMX_Core.h" | 23 #include "third_party/openmax/il/OMX_Core.h" |
| 23 #include "third_party/openmax/il/OMX_Video.h" | 24 #include "third_party/openmax/il/OMX_Video.h" |
| 24 | 25 |
| 25 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. | 26 // Class to wrap OpenMAX IL accelerator behind VideoDecodeAccelerator interface. |
| 26 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 27 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
| 27 public: | 28 public: |
| 28 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client, | 29 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client, |
| 29 MessageLoop* message_loop); | 30 MessageLoop* message_loop); |
| 30 virtual ~OmxVideoDecodeAccelerator(); | 31 virtual ~OmxVideoDecodeAccelerator(); |
| 31 | 32 |
| 32 // media::VideoDecodeAccelerator implementation. | 33 // media::VideoDecodeAccelerator implementation. |
| 33 void GetConfigs(const std::vector<uint32>& requested_configs, | 34 void GetConfigs(const std::vector<uint32>& requested_configs, |
| 34 std::vector<uint32>* matched_configs) OVERRIDE; | 35 std::vector<uint32>* matched_configs) OVERRIDE; |
| 35 bool Initialize(const std::vector<uint32>& config) OVERRIDE; | 36 bool Initialize(const std::vector<uint32>& config) OVERRIDE; |
| 36 bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 37 bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 37 virtual void AssignGLESBuffers( | 38 virtual void AssignGLESBuffers( |
| 38 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; | 39 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; |
| 39 virtual void AssignSysmemBuffers( | 40 virtual void AssignSysmemBuffers( |
| 40 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; | 41 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; |
| 41 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 42 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 42 bool Flush() OVERRIDE; | 43 bool Flush() OVERRIDE; |
| 43 bool Abort() OVERRIDE; | 44 bool Abort() OVERRIDE; |
| 44 | 45 |
| 46 void SetEglState(EGLDisplay egl_display, EGLContext egl_context); | |
| 47 | |
| 45 private: | 48 private: |
| 46 MessageLoop* message_loop_; | 49 MessageLoop* message_loop_; |
| 47 OMX_HANDLETYPE component_handle_; | 50 OMX_HANDLETYPE component_handle_; |
| 48 | 51 |
| 49 // Common initialization code for Assign{GLES,Sysmem}Buffers. | 52 // Common initialization code for Assign{GLES,Sysmem}Buffers. |
| 50 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers); | 53 void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers); |
| 51 | 54 |
| 52 // Create the Component for OMX. Handles all OMX initialization. | 55 // Create the Component for OMX. Handles all OMX initialization. |
| 53 bool CreateComponent(); | 56 bool CreateComponent(); |
| 54 // Buffer allocation/free methods for input and output buffers. | 57 // Buffer allocation/free methods for input and output buffers. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 int input_port_; | 99 int input_port_; |
| 97 int input_buffers_at_component_; | 100 int input_buffers_at_component_; |
| 98 | 101 |
| 99 // Following are output port related variables. | 102 // Following are output port related variables. |
| 100 int output_buffer_count_; | 103 int output_buffer_count_; |
| 101 int output_buffer_size_; | 104 int output_buffer_size_; |
| 102 int output_port_; | 105 int output_port_; |
| 103 int output_buffers_at_component_; | 106 int output_buffers_at_component_; |
| 104 | 107 |
| 105 bool uses_egl_image_; | 108 bool uses_egl_image_; |
| 109 EGLDisplay egl_display_; | |
| 110 EGLContext egl_context_; | |
|
vrk (LEFT CHROMIUM)
2011/06/03 07:55:24
Someday, one context will not be good enough! Toda
Ami GONE FROM CHROMIUM
2011/06/03 17:43:59
NOTE'd the former, TODO'd the latter.
| |
| 111 | |
| 106 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. | 112 // Free input OpenMAX buffers that can be used to take bitstream from demuxer. |
| 107 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; | 113 std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_; |
| 108 | 114 |
| 109 // For output buffer recycling cases. | 115 // For output buffer recycling cases. |
| 110 std::vector<media::BaseBuffer*> assigned_picture_buffers_; | 116 std::vector<media::BaseBuffer*> assigned_picture_buffers_; |
| 111 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture; | 117 typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture; |
| 112 std::vector<OutputPicture> output_pictures_; | 118 std::vector<OutputPicture> output_pictures_; |
| 113 | 119 |
| 114 // To expose client callbacks from VideoDecodeAccelerator. | 120 // To expose client callbacks from VideoDecodeAccelerator. |
| 121 // NOTE: all calls to this object *MUST* be executed in message_loop_. | |
| 115 Client* client_; | 122 Client* client_; |
| 116 | 123 |
| 117 std::vector<uint32> texture_ids_; | 124 std::vector<uint32> texture_ids_; |
| 118 std::vector<uint32> context_ids_; | 125 std::vector<uint32> context_ids_; |
| 119 // Method to handle events | 126 // Method to handle events |
| 120 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 127 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
| 121 OMX_U32 data1, | 128 OMX_U32 data1, |
| 122 OMX_U32 data2); | 129 OMX_U32 data2); |
| 123 | 130 |
| 124 // Method to receive buffers from component's input port | 131 // Method to receive buffers from component's input port |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 152 OMX_PTR event_data); | 159 OMX_PTR event_data); |
| 153 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 160 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
| 154 OMX_PTR priv_data, | 161 OMX_PTR priv_data, |
| 155 OMX_BUFFERHEADERTYPE* buffer); | 162 OMX_BUFFERHEADERTYPE* buffer); |
| 156 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 163 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
| 157 OMX_PTR priv_data, | 164 OMX_PTR priv_data, |
| 158 OMX_BUFFERHEADERTYPE* buffer); | 165 OMX_BUFFERHEADERTYPE* buffer); |
| 159 }; | 166 }; |
| 160 | 167 |
| 161 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 168 #endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |