OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Class to provide JPEG decode acceleration for Intel systems with hardware | 28 // Class to provide JPEG decode acceleration for Intel systems with hardware |
29 // support for it, and on which libva is available. | 29 // support for it, and on which libva is available. |
30 // Decoding tasks are performed in a separate decoding thread. | 30 // Decoding tasks are performed in a separate decoding thread. |
31 // | 31 // |
32 // Threading/life-cycle: this object is created & destroyed on the GPU | 32 // Threading/life-cycle: this object is created & destroyed on the GPU |
33 // ChildThread. A few methods on it are called on the decoder thread which is | 33 // ChildThread. A few methods on it are called on the decoder thread which is |
34 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread | 34 // stopped during |this->Destroy()|, so any tasks posted to the decoder thread |
35 // can assume |*this| is still alive. See |weak_this_| below for more details. | 35 // can assume |*this| is still alive. See |weak_this_| below for more details. |
36 class MEDIA_GPU_EXPORT VaapiJpegDecodeAccelerator | 36 class MEDIA_GPU_EXPORT VaapiJpegDecodeAccelerator |
37 : public media::JpegDecodeAccelerator { | 37 : public JpegDecodeAccelerator { |
38 public: | 38 public: |
39 VaapiJpegDecodeAccelerator( | 39 VaapiJpegDecodeAccelerator( |
40 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 40 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
41 ~VaapiJpegDecodeAccelerator() override; | 41 ~VaapiJpegDecodeAccelerator() override; |
42 | 42 |
43 // media::JpegDecodeAccelerator implementation. | 43 // JpegDecodeAccelerator implementation. |
44 bool Initialize(media::JpegDecodeAccelerator::Client* client) override; | 44 bool Initialize(JpegDecodeAccelerator::Client* client) override; |
45 void Decode(const media::BitstreamBuffer& bitstream_buffer, | 45 void Decode(const BitstreamBuffer& bitstream_buffer, |
46 const scoped_refptr<media::VideoFrame>& video_frame) override; | 46 const scoped_refptr<VideoFrame>& video_frame) override; |
47 bool IsSupported() override; | 47 bool IsSupported() override; |
48 | 48 |
49 private: | 49 private: |
50 // An input buffer and the corresponding output video frame awaiting | 50 // An input buffer and the corresponding output video frame awaiting |
51 // consumption, provided by the client. | 51 // consumption, provided by the client. |
52 struct DecodeRequest { | 52 struct DecodeRequest { |
53 DecodeRequest(int32_t bitstream_buffer_id, | 53 DecodeRequest(int32_t bitstream_buffer_id, |
54 std::unique_ptr<SharedMemoryRegion> shm, | 54 std::unique_ptr<SharedMemoryRegion> shm, |
55 const scoped_refptr<media::VideoFrame>& video_frame); | 55 const scoped_refptr<VideoFrame>& video_frame); |
56 ~DecodeRequest(); | 56 ~DecodeRequest(); |
57 | 57 |
58 int32_t bitstream_buffer_id; | 58 int32_t bitstream_buffer_id; |
59 std::unique_ptr<SharedMemoryRegion> shm; | 59 std::unique_ptr<SharedMemoryRegion> shm; |
60 scoped_refptr<media::VideoFrame> video_frame; | 60 scoped_refptr<VideoFrame> video_frame; |
61 }; | 61 }; |
62 | 62 |
63 // Notifies the client that an error has occurred and decoding cannot | 63 // Notifies the client that an error has occurred and decoding cannot |
64 // continue. | 64 // continue. |
65 void NotifyError(int32_t bitstream_buffer_id, Error error); | 65 void NotifyError(int32_t bitstream_buffer_id, Error error); |
66 void NotifyErrorFromDecoderThread(int32_t bitstream_buffer_id, Error error); | 66 void NotifyErrorFromDecoderThread(int32_t bitstream_buffer_id, Error error); |
67 void VideoFrameReady(int32_t bitstream_buffer_id); | 67 void VideoFrameReady(int32_t bitstream_buffer_id); |
68 | 68 |
69 // Processes one decode |request|. | 69 // Processes one decode |request|. |
70 void DecodeTask(const std::unique_ptr<DecodeRequest>& request); | 70 void DecodeTask(const std::unique_ptr<DecodeRequest>& request); |
71 | 71 |
72 // Puts contents of |va_surface| into given |video_frame|, releases the | 72 // Puts contents of |va_surface| into given |video_frame|, releases the |
73 // surface and passes the |input_buffer_id| of the resulting picture to | 73 // surface and passes the |input_buffer_id| of the resulting picture to |
74 // client for output. | 74 // client for output. |
75 bool OutputPicture(VASurfaceID va_surface_id, | 75 bool OutputPicture(VASurfaceID va_surface_id, |
76 int32_t input_buffer_id, | 76 int32_t input_buffer_id, |
77 const scoped_refptr<media::VideoFrame>& video_frame); | 77 const scoped_refptr<VideoFrame>& video_frame); |
78 | 78 |
79 // ChildThread's task runner. | 79 // ChildThread's task runner. |
80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
81 | 81 |
82 // GPU IO task runner. | 82 // GPU IO task runner. |
83 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 83 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
84 | 84 |
85 // The client of this class. | 85 // The client of this class. |
86 Client* client_; | 86 Client* client_; |
87 | 87 |
(...skipping 25 matching lines...) Expand all Loading... |
113 | 113 |
114 // The WeakPtrFactory for |weak_this_|. | 114 // The WeakPtrFactory for |weak_this_|. |
115 base::WeakPtrFactory<VaapiJpegDecodeAccelerator> weak_this_factory_; | 115 base::WeakPtrFactory<VaapiJpegDecodeAccelerator> weak_this_factory_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(VaapiJpegDecodeAccelerator); | 117 DISALLOW_COPY_AND_ASSIGN(VaapiJpegDecodeAccelerator); |
118 }; | 118 }; |
119 | 119 |
120 } // namespace media | 120 } // namespace media |
121 | 121 |
122 #endif // MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ | 122 #endif // MEDIA_GPU_VAAPI_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |