| 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 26 matching lines...) Expand all Loading... |
| 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<uint32>& config) OVERRIDE; | 45 bool Initialize(const std::vector<uint32>& config) OVERRIDE; |
| 46 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 46 void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
| 47 virtual void AssignGLESBuffers( | 47 virtual void AssignPictureBuffers( |
| 48 const std::vector<media::GLESBuffer>& 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 |
| 56 private: | 56 private: |
| 57 virtual ~OmxVideoDecodeAccelerator(); | 57 virtual ~OmxVideoDecodeAccelerator(); |
| 58 | 58 |
| 59 // Because OMX state-transitions are described solely by the "state reached" | 59 // Because OMX state-transitions are described solely by the "state reached" |
| 60 // (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested | 60 // (3.1.2.9.1, table 3-7 of the spec), we track what transition was requested |
| 61 // using this enum. Note that it is an error to request a transition while | 61 // using this enum. Note that it is an error to request a transition while |
| 62 // |*this| is in any state other than NO_TRANSITION. | 62 // |*this| is in any state other than NO_TRANSITION. |
| 63 enum CurrentStateChange { | 63 enum CurrentStateChange { |
| 64 NO_TRANSITION, // Not in the middle of a transition. | 64 NO_TRANSITION, // Not in the middle of a transition. |
| 65 INITIALIZING, | 65 INITIALIZING, |
| 66 FLUSHING, | 66 FLUSHING, |
| 67 RESETTING, | 67 RESETTING, |
| 68 DESTROYING, | 68 DESTROYING, |
| 69 ERRORING, // Trumps all other transitions; no recovery is possible. | 69 ERRORING, // Trumps all other transitions; no recovery is possible. |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 // Helper struct for keeping track of the relationship between an OMX output | 72 // Helper struct for keeping track of the relationship between an OMX output |
| 73 // buffer and the GLESBuffer it points to. | 73 // buffer and the PictureBuffer it points to. |
| 74 struct OutputPicture { | 74 struct OutputPicture { |
| 75 OutputPicture(media::GLESBuffer g_b, OMX_BUFFERHEADERTYPE* o_b_h, | 75 OutputPicture(media::PictureBuffer p_b, OMX_BUFFERHEADERTYPE* o_b_h, |
| 76 EGLImageKHR e_i) | 76 EGLImageKHR e_i) |
| 77 : gles_buffer(g_b), omx_buffer_header(o_b_h), egl_image(e_i) {} | 77 : picture_buffer(p_b), omx_buffer_header(o_b_h), egl_image(e_i) {} |
| 78 media::GLESBuffer gles_buffer; | 78 media::PictureBuffer picture_buffer; |
| 79 OMX_BUFFERHEADERTYPE* omx_buffer_header; | 79 OMX_BUFFERHEADERTYPE* omx_buffer_header; |
| 80 EGLImageKHR egl_image; | 80 EGLImageKHR egl_image; |
| 81 }; | 81 }; |
| 82 typedef std::map<int32, OutputPicture> OutputPictureById; | 82 typedef std::map<int32, OutputPicture> OutputPictureById; |
| 83 | 83 |
| 84 // Verify that |config| is compatible with this class and hardware. | 84 // Verify that |config| is compatible with this class and hardware. |
| 85 bool VerifyConfigs(const std::vector<uint32>& configs); | 85 bool VerifyConfigs(const std::vector<uint32>& configs); |
| 86 | 86 |
| 87 MessageLoop* message_loop_; | 87 MessageLoop* message_loop_; |
| 88 OMX_HANDLETYPE component_handle_; | 88 OMX_HANDLETYPE component_handle_; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 OMX_PTR event_data); | 202 OMX_PTR event_data); |
| 203 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, | 203 static OMX_ERRORTYPE EmptyBufferCallback(OMX_HANDLETYPE component, |
| 204 OMX_PTR priv_data, | 204 OMX_PTR priv_data, |
| 205 OMX_BUFFERHEADERTYPE* buffer); | 205 OMX_BUFFERHEADERTYPE* buffer); |
| 206 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, | 206 static OMX_ERRORTYPE FillBufferCallback(OMX_HANDLETYPE component, |
| 207 OMX_PTR priv_data, | 207 OMX_PTR priv_data, |
| 208 OMX_BUFFERHEADERTYPE* buffer); | 208 OMX_BUFFERHEADERTYPE* buffer); |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ | 211 #endif // CONTENT_COMMON_GPU_MEDIA_OMX_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |