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

Side by Side Diff: chrome/gpu/arc_gpu_video_decode_accelerator.h

Issue 1953683002: Add stride for imported Dmabuf in ArcVideoAccelerator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address posciak's comments Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/gpu/arc_gpu_video_decode_accelerator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ 5 #ifndef CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
6 #define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ 6 #define CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <queue> 10 #include <queue>
(...skipping 24 matching lines...) Expand all
35 bool Initialize(const Config& config, 35 bool Initialize(const Config& config,
36 ArcVideoAccelerator::Client* client) override; 36 ArcVideoAccelerator::Client* client) override;
37 void SetNumberOfOutputBuffers(size_t number) override; 37 void SetNumberOfOutputBuffers(size_t number) override;
38 void BindSharedMemory(PortType port, 38 void BindSharedMemory(PortType port,
39 uint32_t index, 39 uint32_t index,
40 base::ScopedFD ashmem_fd, 40 base::ScopedFD ashmem_fd,
41 off_t offset, 41 off_t offset,
42 size_t length) override; 42 size_t length) override;
43 void BindDmabuf(PortType port, 43 void BindDmabuf(PortType port,
44 uint32_t index, 44 uint32_t index,
45 base::ScopedFD dmabuf_fd) override; 45 base::ScopedFD dmabuf_fd,
46 int32_t stride) override;
46 void UseBuffer(PortType port, 47 void UseBuffer(PortType port,
47 uint32_t index, 48 uint32_t index,
48 const BufferMetadata& metadata) override; 49 const BufferMetadata& metadata) override;
49 void Reset() override; 50 void Reset() override;
50 void Flush() override; 51 void Flush() override;
51 52
52 // Implementation of the VideoDecodeAccelerator::Client interface. 53 // Implementation of the VideoDecodeAccelerator::Client interface.
53 void ProvidePictureBuffers(uint32_t requested_num_of_buffers, 54 void ProvidePictureBuffers(uint32_t requested_num_of_buffers,
54 uint32_t textures_per_buffer, 55 uint32_t textures_per_buffer,
55 const gfx::Size& dimensions, 56 const gfx::Size& dimensions,
(...skipping 16 matching lines...) Expand all
72 InputRecord(int32_t bitstream_buffer_id, 73 InputRecord(int32_t bitstream_buffer_id,
73 uint32_t buffer_index, 74 uint32_t buffer_index,
74 int64_t timestamp); 75 int64_t timestamp);
75 }; 76 };
76 77
77 // The information about the shared memory used as an input buffer. 78 // The information about the shared memory used as an input buffer.
78 struct InputBufferInfo { 79 struct InputBufferInfo {
79 // The file handle to access the buffer. It is owned by this class and 80 // The file handle to access the buffer. It is owned by this class and
80 // should be closed after use. 81 // should be closed after use.
81 base::ScopedFD handle; 82 base::ScopedFD handle;
82 off_t offset; 83
83 size_t length; 84 // The offset of the payload to the beginning of the shared memory.
85 off_t offset = 0;
86
87 // The size of the payload in bytes.
88 size_t length = 0;
84 89
85 InputBufferInfo(); 90 InputBufferInfo();
86 InputBufferInfo(InputBufferInfo&& other); 91 InputBufferInfo(InputBufferInfo&& other);
87 ~InputBufferInfo(); 92 ~InputBufferInfo();
88 }; 93 };
89 94
95 // The information about the dmabuf used as an output buffer.
96 struct OutputBufferInfo {
97 base::ScopedFD handle;
98 int32_t stride = 0; // In bytes.
99
100 OutputBufferInfo();
101 OutputBufferInfo(OutputBufferInfo&& other);
102 ~OutputBufferInfo();
103 };
104
90 // Helper function to validate |port| and |index|. 105 // Helper function to validate |port| and |index|.
91 bool ValidatePortAndIndex(PortType port, uint32_t index); 106 bool ValidatePortAndIndex(PortType port, uint32_t index) const;
107
108 // Helper function to verify the length of stride is legal.
109 bool VerifyStride(const base::ScopedFD& fd, int32_t stride) const;
92 110
93 // Creates an InputRecord for the given |bitstream_buffer_id|. The 111 // Creates an InputRecord for the given |bitstream_buffer_id|. The
94 // |buffer_index| is the index of the associated input buffer. The |timestamp| 112 // |buffer_index| is the index of the associated input buffer. The |timestamp|
95 // is the time the video frame should be displayed. 113 // is the time the video frame should be displayed.
96 void CreateInputRecord(int32_t bitstream_buffer_id, 114 void CreateInputRecord(int32_t bitstream_buffer_id,
97 uint32_t buffer_index, 115 uint32_t buffer_index,
98 int64_t timestamp); 116 int64_t timestamp);
99 117
100 // Finds the InputRecord which matches to given |bitstream_buffer_id|. 118 // Finds the InputRecord which matches to given |bitstream_buffer_id|.
101 // Returns |nullptr| if it cannot be found. 119 // Returns |nullptr| if it cannot be found.
102 InputRecord* FindInputRecord(int32_t bitstream_buffer_id); 120 InputRecord* FindInputRecord(int32_t bitstream_buffer_id);
103 121
104 std::unique_ptr<media::VideoDecodeAccelerator> vda_; 122 std::unique_ptr<media::VideoDecodeAccelerator> vda_;
105 123
106 // It's safe to use the pointer here, the life cycle of the |arc_client_| 124 // It's safe to use the pointer here, the life cycle of the |arc_client_|
107 // is longer than this ArcGpuVideoDecodeAccelerator. 125 // is longer than this ArcGpuVideoDecodeAccelerator.
108 ArcVideoAccelerator::Client* arc_client_; 126 ArcVideoAccelerator::Client* arc_client_;
109 127
110 // The next ID for the bitstream buffer, started from 0. 128 // The next ID for the bitstream buffer, started from 0.
111 int32_t next_bitstream_buffer_id_; 129 int32_t next_bitstream_buffer_id_;
112 130
113 gfx::Size coded_size_; 131 gfx::Size coded_size_;
132 media::VideoPixelFormat output_pixel_format_;
114 133
115 // A list of most recent |kMaxNumberOfInputRecord| InputRecords. 134 // A list of most recent |kMaxNumberOfInputRecord| InputRecords.
116 // |kMaxNumberOfInputRecord| is defined in the cc file. 135 // |kMaxNumberOfInputRecord| is defined in the cc file.
117 std::list<InputRecord> input_records_; 136 std::list<InputRecord> input_records_;
118 137
119 // The details of the shared memory of each input buffers. 138 // The details of the shared memory of each input buffers.
120 std::vector<InputBufferInfo> input_buffer_info_; 139 std::vector<InputBufferInfo> input_buffer_info_;
121 140
122 // To keep those output buffers which have been bound by bindDmabuf() but not 141 // To keep those output buffers which have been bound by bindDmabuf() but
123 // be used yet. Will call VDA::ImportBufferForPicture() when those buffers are 142 // haven't been passed to VDA yet. Will call VDA::ImportBufferForPicture()
124 // used for the first time. 143 // when those buffers are used for the first time.
125 std::vector<base::ScopedFD> buffers_pending_import_; 144 std::vector<OutputBufferInfo> buffers_pending_import_;
126 145
127 base::ThreadChecker thread_checker_; 146 base::ThreadChecker thread_checker_;
128 size_t output_buffer_size_; 147 size_t output_buffer_size_;
129 148
130 gpu::GpuPreferences gpu_preferences_; 149 gpu::GpuPreferences gpu_preferences_;
131 150
132 DISALLOW_COPY_AND_ASSIGN(ArcGpuVideoDecodeAccelerator); 151 DISALLOW_COPY_AND_ASSIGN(ArcGpuVideoDecodeAccelerator);
133 }; 152 };
134 153
135 } // namespace arc 154 } // namespace arc
136 } // namespace chromeos 155 } // namespace chromeos
137 156
138 #endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_ 157 #endif // CHROME_GPU_ARC_GPU_VIDEO_DECODE_ACCELERATOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/gpu/arc_gpu_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698