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

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator.cc

Issue 11826064: Enforce non-negative BitstreamBuffer id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Documented the wrapping at 30 bits. Created 7 years, 11 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 | content/common/gpu/media/video_decode_accelerator_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return; 198 return;
199 #endif 199 #endif
200 200
201 if (!video_decode_accelerator_->Initialize(profile)) 201 if (!video_decode_accelerator_->Initialize(profile))
202 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); 202 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
203 } 203 }
204 204
205 void GpuVideoDecodeAccelerator::OnDecode( 205 void GpuVideoDecodeAccelerator::OnDecode(
206 base::SharedMemoryHandle handle, int32 id, uint32 size) { 206 base::SharedMemoryHandle handle, int32 id, uint32 size) {
207 DCHECK(video_decode_accelerator_.get()); 207 DCHECK(video_decode_accelerator_.get());
208 if (id < 0) {
209 DLOG(FATAL) << "BitstreamBuffer id " << id << " out of range";
210 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
211 return;
212 }
208 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); 213 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size));
209 } 214 }
210 215
211 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( 216 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers(
212 const std::vector<int32>& buffer_ids, 217 const std::vector<int32>& buffer_ids,
213 const std::vector<uint32>& texture_ids, 218 const std::vector<uint32>& texture_ids,
214 const std::vector<gfx::Size>& sizes) { 219 const std::vector<gfx::Size>& sizes) {
215 if (buffer_ids.size() != texture_ids.size() || 220 if (buffer_ids.size() != texture_ids.size() ||
216 buffer_ids.size() != sizes.size()) { 221 buffer_ids.size() != sizes.size()) {
217 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); 222 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
218 return; 223 return;
219 } 224 }
220 225
221 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); 226 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder();
222 gpu::gles2::TextureManager* texture_manager = 227 gpu::gles2::TextureManager* texture_manager =
223 command_decoder->GetContextGroup()->texture_manager(); 228 command_decoder->GetContextGroup()->texture_manager();
224 229
225 std::vector<media::PictureBuffer> buffers; 230 std::vector<media::PictureBuffer> buffers;
226 for (uint32 i = 0; i < buffer_ids.size(); ++i) { 231 for (uint32 i = 0; i < buffer_ids.size(); ++i) {
232 if (buffer_ids[i] < 0) {
233 DLOG(FATAL) << "Buffer id " << buffer_ids[i] << " out of range";
234 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
235 return;
236 }
227 gpu::gles2::TextureManager::TextureInfo* info = 237 gpu::gles2::TextureManager::TextureInfo* info =
228 texture_manager->GetTextureInfo(texture_ids[i]); 238 texture_manager->GetTextureInfo(texture_ids[i]);
229 if (!info) { 239 if (!info) {
230 DLOG(FATAL) << "Failed to find texture id " << texture_ids[i]; 240 DLOG(FATAL) << "Failed to find texture id " << texture_ids[i];
231 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT); 241 NotifyError(media::VideoDecodeAccelerator::INVALID_ARGUMENT);
232 return; 242 return;
233 } 243 }
234 GLsizei width, height; 244 GLsizei width, height;
235 info->GetLevelSize(0, 0, &width, &height); 245 info->GetLevelSize(0, 0, &width, &height);
236 if (width != sizes[i].width() || height != sizes[i].height()) { 246 if (width != sizes[i].width() || height != sizes[i].height()) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 stub_.reset(); 324 stub_.reset();
315 } 325 }
316 } 326 }
317 327
318 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { 328 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) {
319 DCHECK(sender_); 329 DCHECK(sender_);
320 return sender_->Send(message); 330 return sender_->Send(message);
321 } 331 }
322 332
323 } // namespace content 333 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/common/gpu/media/video_decode_accelerator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698