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_V4L2_JPEG_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ |
6 #define MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 bool Initialize(Client* client) override; | 39 bool Initialize(Client* client) override; |
40 void Decode(const BitstreamBuffer& bitstream_buffer, | 40 void Decode(const BitstreamBuffer& bitstream_buffer, |
41 const scoped_refptr<VideoFrame>& video_frame) override; | 41 const scoped_refptr<VideoFrame>& video_frame) override; |
42 bool IsSupported() override; | 42 bool IsSupported() override; |
43 | 43 |
44 private: | 44 private: |
45 // Record for input/output buffers. | 45 // Record for input/output buffers. |
46 struct BufferRecord { | 46 struct BufferRecord { |
47 BufferRecord(); | 47 BufferRecord(); |
48 ~BufferRecord(); | 48 ~BufferRecord(); |
49 void* address; // mmap() address. | 49 void* address[VIDEO_MAX_PLANES]; // mmap() address. |
50 size_t length; // mmap() length. | 50 size_t length[VIDEO_MAX_PLANES]; // mmap() length. |
51 | 51 |
52 // Set true during QBUF and DQBUF. |address| will be accessed by hardware. | 52 // Set true during QBUF and DQBUF. |address| will be accessed by hardware. |
53 bool at_device; | 53 bool at_device; |
54 }; | 54 }; |
55 | 55 |
56 // Job record. Jobs are processed in a FIFO order. This is separate from | 56 // Job record. Jobs are processed in a FIFO order. This is separate from |
57 // BufferRecord of input, because a BufferRecord of input may be returned | 57 // BufferRecord of input, because a BufferRecord of input may be returned |
58 // before we dequeue the corresponding output buffer. It can't always be | 58 // before we dequeue the corresponding output buffer. It can't always be |
59 // associated with a BufferRecord of output immediately either, because at | 59 // associated with a BufferRecord of output immediately either, because at |
60 // the time of submission we may not have one available (and don't need one | 60 // the time of submission we may not have one available (and don't need one |
(...skipping 14 matching lines...) Expand all Loading... |
75 void EnqueueInput(); | 75 void EnqueueInput(); |
76 void EnqueueOutput(); | 76 void EnqueueOutput(); |
77 void Dequeue(); | 77 void Dequeue(); |
78 bool EnqueueInputRecord(); | 78 bool EnqueueInputRecord(); |
79 bool EnqueueOutputRecord(); | 79 bool EnqueueOutputRecord(); |
80 bool CreateInputBuffers(); | 80 bool CreateInputBuffers(); |
81 bool CreateOutputBuffers(); | 81 bool CreateOutputBuffers(); |
82 void DestroyInputBuffers(); | 82 void DestroyInputBuffers(); |
83 void DestroyOutputBuffers(); | 83 void DestroyOutputBuffers(); |
84 | 84 |
| 85 // Convert |output_buffer| to I420 and copy the result to |dst_frame|. |
| 86 // The function can convert to I420 from the following formats: |
| 87 // - All splane formats that libyuv::ConvertToI420 can handle. |
| 88 // - V4L2_PIX_FMT_YUV_420M |
| 89 // - V4L2_PIX_FMT_YUV_422M |
| 90 bool ConvertOutputImage(const BufferRecord& output_buffer, |
| 91 const scoped_refptr<VideoFrame>& dst_frame); |
| 92 |
85 // Return the number of input/output buffers enqueued to the device. | 93 // Return the number of input/output buffers enqueued to the device. |
86 size_t InputBufferQueuedCount(); | 94 size_t InputBufferQueuedCount(); |
87 size_t OutputBufferQueuedCount(); | 95 size_t OutputBufferQueuedCount(); |
88 | 96 |
89 // Return true if input buffer size is not enough. | 97 // Return true if input buffer size is not enough. |
90 bool ShouldRecreateInputBuffers(); | 98 bool ShouldRecreateInputBuffers(); |
91 // Destroy and create input buffers. Return false on error. | 99 // Destroy and create input buffers. Return false on error. |
92 bool RecreateInputBuffers(); | 100 bool RecreateInputBuffers(); |
93 // Destroy and create output buffers. Return false on error. | 101 // Destroy and create output buffers. Return false on error. |
94 bool RecreateOutputBuffers(); | 102 bool RecreateOutputBuffers(); |
(...skipping 25 matching lines...) Expand all Loading... |
120 | 128 |
121 // The number of input buffers and output buffers. | 129 // The number of input buffers and output buffers. |
122 const size_t kBufferCount = 2; | 130 const size_t kBufferCount = 2; |
123 | 131 |
124 // Coded size of output buffer. | 132 // Coded size of output buffer. |
125 gfx::Size output_buffer_coded_size_; | 133 gfx::Size output_buffer_coded_size_; |
126 | 134 |
127 // Pixel format of output buffer. | 135 // Pixel format of output buffer. |
128 uint32_t output_buffer_pixelformat_; | 136 uint32_t output_buffer_pixelformat_; |
129 | 137 |
| 138 // Number of physical planes the output buffers have. |
| 139 size_t output_buffer_num_planes_; |
| 140 |
130 // ChildThread's task runner. | 141 // ChildThread's task runner. |
131 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; | 142 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; |
132 | 143 |
133 // GPU IO task runner. | 144 // GPU IO task runner. |
134 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 145 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
135 | 146 |
136 // The client of this class. | 147 // The client of this class. |
137 Client* client_; | 148 Client* client_; |
138 | 149 |
139 // The V4L2Device this class is operating upon. | 150 // The V4L2Device this class is operating upon. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Point to |this| for use in posting tasks from the decoder thread back to | 185 // Point to |this| for use in posting tasks from the decoder thread back to |
175 // the ChildThread. | 186 // the ChildThread. |
176 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_; | 187 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_; |
177 | 188 |
178 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator); | 189 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator); |
179 }; | 190 }; |
180 | 191 |
181 } // namespace media | 192 } // namespace media |
182 | 193 |
183 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ | 194 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |