Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: media/gpu/v4l2_jpeg_decode_accelerator.h

Issue 2559423002: media/gpu: switch v4l2_jpeg_decode_accelerator to use multi-planar APIs (Closed)
Patch Set: add static_assert for kMaxInputPlanes Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
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 // JpegDecodeAccelerator implementation. 38 // JpegDecodeAccelerator implementation.
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 // Input pixel format (i.e. V4L2_PIX_FMT_JPEG) has only one physical plane.
46 static const uint32_t kMaxInputPlanes = 1;
47 // Ouput pixel format may have at most three physical planes.
48 static const uint32_t kMaxOutputPlanes = 3;
49
45 // Record for input/output buffers. 50 // Record for input/output buffers.
46 struct BufferRecord { 51 struct BufferRecord {
47 BufferRecord(); 52 BufferRecord();
48 ~BufferRecord(); 53 ~BufferRecord();
49 void* address; // mmap() address. 54 void* address[kMaxOutputPlanes]; // mmap() address.
50 size_t length; // mmap() length. 55 size_t length[kMaxOutputPlanes]; // mmap() length.
51 56
52 // Set true during QBUF and DQBUF. |address| will be accessed by hardware. 57 // Set true during QBUF and DQBUF. |address| will be accessed by hardware.
53 bool at_device; 58 bool at_device;
54 }; 59 };
55 60
56 // Job record. Jobs are processed in a FIFO order. This is separate from 61 // 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 62 // BufferRecord of input, because a BufferRecord of input may be returned
58 // before we dequeue the corresponding output buffer. It can't always be 63 // before we dequeue the corresponding output buffer. It can't always be
59 // associated with a BufferRecord of output immediately either, because at 64 // 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 65 // the time of submission we may not have one available (and don't need one
(...skipping 14 matching lines...) Expand all
75 void EnqueueInput(); 80 void EnqueueInput();
76 void EnqueueOutput(); 81 void EnqueueOutput();
77 void Dequeue(); 82 void Dequeue();
78 bool EnqueueInputRecord(); 83 bool EnqueueInputRecord();
79 bool EnqueueOutputRecord(); 84 bool EnqueueOutputRecord();
80 bool CreateInputBuffers(); 85 bool CreateInputBuffers();
81 bool CreateOutputBuffers(); 86 bool CreateOutputBuffers();
82 void DestroyInputBuffers(); 87 void DestroyInputBuffers();
83 void DestroyOutputBuffers(); 88 void DestroyOutputBuffers();
84 89
90 // Convert |src_buffer| to I420 and copy the result to |dst_frame|.
91 // The function currently accepts the following format as |src_pixelformat|:
92 // - All splane formats that libyuv::ConvertToI420 can handle.
93 // - V4L2_YUV_420M
94 // - V4L2_YUV_422M
Pawel Osciak 2016/12/20 05:19:12 s/V4L2_YUV_420M/V4L2_PIX_FMT_YUV420M/ s/V4L2_YUV_4
jcliang 2016/12/20 08:33:22 Done.
95 bool ConvertOutputImage(const BufferRecord& output_buffer,
96 const scoped_refptr<VideoFrame>& dst_frame);
97
85 // Return the number of input/output buffers enqueued to the device. 98 // Return the number of input/output buffers enqueued to the device.
86 size_t InputBufferQueuedCount(); 99 size_t InputBufferQueuedCount();
87 size_t OutputBufferQueuedCount(); 100 size_t OutputBufferQueuedCount();
88 101
89 // Return true if input buffer size is not enough. 102 // Return true if input buffer size is not enough.
90 bool ShouldRecreateInputBuffers(); 103 bool ShouldRecreateInputBuffers();
91 // Destroy and create input buffers. Return false on error. 104 // Destroy and create input buffers. Return false on error.
92 bool RecreateInputBuffers(); 105 bool RecreateInputBuffers();
93 // Destroy and create output buffers. Return false on error. 106 // Destroy and create output buffers. Return false on error.
94 bool RecreateOutputBuffers(); 107 bool RecreateOutputBuffers();
(...skipping 25 matching lines...) Expand all
120 133
121 // The number of input buffers and output buffers. 134 // The number of input buffers and output buffers.
122 const size_t kBufferCount = 2; 135 const size_t kBufferCount = 2;
123 136
124 // Coded size of output buffer. 137 // Coded size of output buffer.
125 gfx::Size output_buffer_coded_size_; 138 gfx::Size output_buffer_coded_size_;
126 139
127 // Pixel format of output buffer. 140 // Pixel format of output buffer.
128 uint32_t output_buffer_pixelformat_; 141 uint32_t output_buffer_pixelformat_;
129 142
143 // Number of physical planes the output buffers have.
144 uint32_t output_buffer_num_planes_;
Pawel Osciak 2016/12/20 05:19:12 s/uint32_t/size_t/
jcliang 2016/12/20 08:33:22 Done.
145
130 // ChildThread's task runner. 146 // ChildThread's task runner.
131 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_; 147 scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
132 148
133 // GPU IO task runner. 149 // GPU IO task runner.
134 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 150 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
135 151
136 // The client of this class. 152 // The client of this class.
137 Client* client_; 153 Client* client_;
138 154
139 // The V4L2Device this class is operating upon. 155 // The V4L2Device this class is operating upon.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // Point to |this| for use in posting tasks from the decoder thread back to 190 // Point to |this| for use in posting tasks from the decoder thread back to
175 // the ChildThread. 191 // the ChildThread.
176 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_; 192 base::WeakPtr<V4L2JpegDecodeAccelerator> weak_ptr_;
177 193
178 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator); 194 DISALLOW_COPY_AND_ASSIGN(V4L2JpegDecodeAccelerator);
179 }; 195 };
180 196
181 } // namespace media 197 } // namespace media
182 198
183 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_ 199 #endif // MEDIA_GPU_V4L2_JPEG_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698