| 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> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 // 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 |
| 36 // 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 |
| 37 // 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 |
| 38 // OMX thread). | 38 // OMX thread). |
| 39 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { | 39 class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator { |
| 40 public: | 40 public: |
| 41 // Does not take ownership of |client| which must outlive |*this|. | 41 // Does not take ownership of |client| which must outlive |*this|. |
| 42 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); | 42 OmxVideoDecodeAccelerator(media::VideoDecodeAccelerator::Client* client); |
| 43 | 43 |
| 44 // media::VideoDecodeAccelerator implementation. | 44 // media::VideoDecodeAccelerator implementation. |
| 45 bool Initialize(const std::vector<int32>& config) OVERRIDE; | 45 bool Initialize(Profile profile) OVERRIDE; |
| 46 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 46 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 47 virtual void AssignPictureBuffers( | 47 virtual void AssignPictureBuffers( |
| 48 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 48 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
| 49 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 49 void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
| 50 void Flush() OVERRIDE; | 50 void Flush() OVERRIDE; |
| 51 void Reset() OVERRIDE; | 51 void Reset() OVERRIDE; |
| 52 void Destroy() OVERRIDE; | 52 void Destroy() OVERRIDE; |
| 53 | 53 |
| 54 void SetEglState(EGLDisplay egl_display, EGLContext egl_context); | 54 void SetEglState(EGLDisplay egl_display, EGLContext egl_context); |
| 55 | 55 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 75 struct OutputPicture { | 75 struct OutputPicture { |
| 76 OutputPicture(media::PictureBuffer p_b, OMX_BUFFERHEADERTYPE* o_b_h, | 76 OutputPicture(media::PictureBuffer p_b, OMX_BUFFERHEADERTYPE* o_b_h, |
| 77 EGLImageKHR e_i) | 77 EGLImageKHR e_i) |
| 78 : picture_buffer(p_b), omx_buffer_header(o_b_h), egl_image(e_i) {} | 78 : picture_buffer(p_b), omx_buffer_header(o_b_h), egl_image(e_i) {} |
| 79 media::PictureBuffer picture_buffer; | 79 media::PictureBuffer picture_buffer; |
| 80 OMX_BUFFERHEADERTYPE* omx_buffer_header; | 80 OMX_BUFFERHEADERTYPE* omx_buffer_header; |
| 81 EGLImageKHR egl_image; | 81 EGLImageKHR egl_image; |
| 82 }; | 82 }; |
| 83 typedef std::map<int32, OutputPicture> OutputPictureById; | 83 typedef std::map<int32, OutputPicture> OutputPictureById; |
| 84 | 84 |
| 85 // Verify that |config| is compatible with this class and hardware. | |
| 86 bool VerifyConfigs(const std::vector<int32>& configs); | |
| 87 | |
| 88 MessageLoop* message_loop_; | 85 MessageLoop* message_loop_; |
| 89 OMX_HANDLETYPE component_handle_; | 86 OMX_HANDLETYPE component_handle_; |
| 90 | 87 |
| 91 // Create the Component for OMX. Handles all OMX initialization. | 88 // Create the Component for OMX. Handles all OMX initialization. |
| 92 bool CreateComponent(); | 89 bool CreateComponent(); |
| 93 // Buffer allocation/free methods for input and output buffers. | 90 // Buffer allocation/free methods for input and output buffers. |
| 94 bool AllocateInputBuffers(); | 91 bool AllocateInputBuffers(); |
| 95 bool AllocateOutputBuffers(); | 92 bool AllocateOutputBuffers(); |
| 96 void FreeInputBuffers(); | 93 void FreeInputBuffers(); |
| 97 void FreeOutputBuffers(); | 94 void FreeOutputBuffers(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // Available output picture buffers released during Reset() and awaiting | 175 // Available output picture buffers released during Reset() and awaiting |
| 179 // re-use once Reset is done. Is empty most of the time and drained right | 176 // re-use once Reset is done. Is empty most of the time and drained right |
| 180 // before NotifyResetDone is sent. | 177 // before NotifyResetDone is sent. |
| 181 std::vector<int> queued_picture_buffer_ids_; | 178 std::vector<int> queued_picture_buffer_ids_; |
| 182 | 179 |
| 183 // To expose client callbacks from VideoDecodeAccelerator. | 180 // To expose client callbacks from VideoDecodeAccelerator. |
| 184 // NOTE: all calls to this object *MUST* be executed in message_loop_. | 181 // NOTE: all calls to this object *MUST* be executed in message_loop_. |
| 185 Client* client_; | 182 Client* client_; |
| 186 | 183 |
| 187 // These two members are only used during Initialization. | 184 // These two members are only used during Initialization. |
| 188 // OMX_VIDEO_AVCProfile requested during Initialization. | 185 // OMX_AVCProfile requested during Initialization. |
| 189 uint32 profile_; | 186 uint32 profile_; |
| 190 bool component_name_is_nvidia_h264ext_; | 187 bool component_name_is_nvidia_h264ext_; |
| 191 | 188 |
| 192 // Method to handle events | 189 // Method to handle events |
| 193 void EventHandlerCompleteTask(OMX_EVENTTYPE event, | 190 void EventHandlerCompleteTask(OMX_EVENTTYPE event, |
| 194 OMX_U32 data1, | 191 OMX_U32 data1, |
| 195 OMX_U32 data2); | 192 OMX_U32 data2); |
| 196 | 193 |
| 197 // Method to receive buffers from component's input port | 194 // Method to receive buffers from component's input port |
| 198 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); | 195 void EmptyBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 214 OMX_PTR event_data); | 211 OMX_PTR event_data); |
| 215 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 212 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
| 216 OMX_PTR priv_data, | 213 OMX_PTR priv_data, |
| 217 OMX_BUFFERHEADERTYPE* buffer); | 214 OMX_BUFFERHEADERTYPE* buffer); |
| 218 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 215 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
| 219 OMX_PTR priv_data, | 216 OMX_PTR priv_data, |
| 220 OMX_BUFFERHEADERTYPE* buffer); | 217 OMX_BUFFERHEADERTYPE* buffer); |
| 221 }; | 218 }; |
| 222 | 219 |
| 223 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 220 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |