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 10 matching lines...) Expand all Loading... |
21 #include "media/base/bitstream_buffer.h" | 21 #include "media/base/bitstream_buffer.h" |
22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
23 #include "media/gpu/media_gpu_export.h" | 23 #include "media/gpu/media_gpu_export.h" |
24 #include "media/gpu/shared_memory_region.h" | 24 #include "media/gpu/shared_memory_region.h" |
25 #include "media/gpu/v4l2_device.h" | 25 #include "media/gpu/v4l2_device.h" |
26 #include "media/video/jpeg_decode_accelerator.h" | 26 #include "media/video/jpeg_decode_accelerator.h" |
27 | 27 |
28 namespace media { | 28 namespace media { |
29 | 29 |
30 class MEDIA_GPU_EXPORT V4L2JpegDecodeAccelerator | 30 class MEDIA_GPU_EXPORT V4L2JpegDecodeAccelerator |
31 : public media::JpegDecodeAccelerator { | 31 : public JpegDecodeAccelerator { |
32 public: | 32 public: |
33 V4L2JpegDecodeAccelerator( | 33 V4L2JpegDecodeAccelerator( |
34 const scoped_refptr<V4L2Device>& device, | 34 const scoped_refptr<V4L2Device>& device, |
35 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 35 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
36 ~V4L2JpegDecodeAccelerator() override; | 36 ~V4L2JpegDecodeAccelerator() override; |
37 | 37 |
38 // media::JpegDecodeAccelerator implementation. | 38 // JpegDecodeAccelerator implementation. |
39 bool Initialize(Client* client) override; | 39 bool Initialize(Client* client) override; |
40 void Decode(const media::BitstreamBuffer& bitstream_buffer, | 40 void Decode(const BitstreamBuffer& bitstream_buffer, |
41 const scoped_refptr<media::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; // mmap() address. |
50 size_t length; // mmap() length. | 50 size_t length; // 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 |
61 // to submit input to the device). | 61 // to submit input to the device). |
62 struct JobRecord { | 62 struct JobRecord { |
63 JobRecord(const media::BitstreamBuffer& bitstream_buffer, | 63 JobRecord(const BitstreamBuffer& bitstream_buffer, |
64 scoped_refptr<media::VideoFrame> video_frame); | 64 scoped_refptr<VideoFrame> video_frame); |
65 ~JobRecord(); | 65 ~JobRecord(); |
66 | 66 |
67 // Input image buffer ID. | 67 // Input image buffer ID. |
68 int32_t bitstream_buffer_id; | 68 int32_t bitstream_buffer_id; |
69 // Memory mapped from |bitstream_buffer|. | 69 // Memory mapped from |bitstream_buffer|. |
70 SharedMemoryRegion shm; | 70 SharedMemoryRegion shm; |
71 // Output frame buffer. | 71 // Output frame buffer. |
72 scoped_refptr<media::VideoFrame> out_frame; | 72 scoped_refptr<VideoFrame> out_frame; |
73 }; | 73 }; |
74 | 74 |
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(); |
(...skipping 91 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 | 174 // Point to |this| for use in posting tasks from the decoder thread back to |
175 // the ChildThread. | 175 // the ChildThread. |
176 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_; | 176 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_; |
177 | 177 |
178 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator); | 178 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator); |
179 }; | 179 }; |
180 | 180 |
181 } // namespace media | 181 } // namespace media |
182 | 182 |
183 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ | 183 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ |
OLD | NEW |