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

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

Issue 1666043002: Attempt to fix a crash in the H.264 decoder on Windows in the GPU process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | no next file » | 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/dxva_video_decode_accelerator_win.h" 5 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h"
6 6
7 #if !defined(OS_WIN) 7 #if !defined(OS_WIN)
8 #error This file should only be built on Windows. 8 #error This file should only be built on Windows.
9 #endif // !defined(OS_WIN) 9 #endif // !defined(OS_WIN)
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 DWORD max_length = 0; 229 DWORD max_length = 0;
230 DWORD current_length = 0; 230 DWORD current_length = 0;
231 uint8_t* destination = NULL; 231 uint8_t* destination = NULL;
232 hr = buffer->Lock(&destination, &max_length, &current_length); 232 hr = buffer->Lock(&destination, &max_length, &current_length);
233 RETURN_ON_HR_FAILURE(hr, "Failed to lock buffer", NULL); 233 RETURN_ON_HR_FAILURE(hr, "Failed to lock buffer", NULL);
234 234
235 CHECK_EQ(current_length, 0u); 235 CHECK_EQ(current_length, 0u);
236 CHECK_GE(static_cast<int>(max_length), size); 236 CHECK_GE(static_cast<int>(max_length), size);
237 memcpy(destination, stream, size); 237 memcpy(destination, stream, size);
238 238
239 hr = buffer->SetCurrentLength(size);
240 RETURN_ON_HR_FAILURE(hr, "Failed to set buffer length", NULL);
241
239 hr = buffer->Unlock(); 242 hr = buffer->Unlock();
240 RETURN_ON_HR_FAILURE(hr, "Failed to unlock buffer", NULL); 243 RETURN_ON_HR_FAILURE(hr, "Failed to unlock buffer", NULL);
241 244
242 hr = buffer->SetCurrentLength(size);
243 RETURN_ON_HR_FAILURE(hr, "Failed to set buffer length", NULL);
244
245 return sample.Detach(); 245 return sample.Detach();
246 } 246 }
247 247
248 static IMFSample* CreateSampleFromInputBuffer( 248 static IMFSample* CreateSampleFromInputBuffer(
249 const media::BitstreamBuffer& bitstream_buffer, 249 const media::BitstreamBuffer& bitstream_buffer,
250 DWORD stream_size, 250 DWORD stream_size,
251 DWORD alignment) { 251 DWORD alignment) {
252 base::SharedMemory shm(bitstream_buffer.handle(), true); 252 base::SharedMemory shm(bitstream_buffer.handle(), true);
253 RETURN_ON_FAILURE(shm.Map(bitstream_buffer.size()), 253 RETURN_ON_FAILURE(shm.Map(bitstream_buffer.size()),
254 "Failed in base::SharedMemory::Map", NULL); 254 "Failed in base::SharedMemory::Map", NULL);
255 255
256 return CreateInputSample(reinterpret_cast<const uint8_t*>(shm.memory()), 256 return CreateInputSample(reinterpret_cast<const uint8_t*>(shm.memory()),
257 bitstream_buffer.size(), stream_size, alignment); 257 bitstream_buffer.size(),
258 std::min<int>(bitstream_buffer.size(), stream_size),
DaleCurtis 2016/02/04 22:13:18 seems this should be uint32_t or DWORD, not int? D
ananta 2016/02/04 22:32:21 Done.
259 alignment);
258 } 260 }
259 261
260 // Helper function to create a COM object instance from a DLL. The alternative 262 // Helper function to create a COM object instance from a DLL. The alternative
261 // is to use the CoCreateInstance API which requires the COM apartment to be 263 // is to use the CoCreateInstance API which requires the COM apartment to be
262 // initialized which is not the case on the GPU main thread. We want to avoid 264 // initialized which is not the case on the GPU main thread. We want to avoid
263 // initializing COM as it may have sideeffects. 265 // initializing COM as it may have sideeffects.
264 HRESULT CreateCOMObjectFromDll(HMODULE dll, const CLSID& clsid, const IID& iid, 266 HRESULT CreateCOMObjectFromDll(HMODULE dll, const CLSID& clsid, const IID& iid,
265 void** object) { 267 void** object) {
266 if (!dll || !object) 268 if (!dll || !object)
267 return E_INVALIDARG; 269 return E_INVALIDARG;
(...skipping 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 } 2379 }
2378 RETURN_ON_HR_FAILURE(hr, "Failed to set output type", false); 2380 RETURN_ON_HR_FAILURE(hr, "Failed to set output type", false);
2379 return true; 2381 return true;
2380 } 2382 }
2381 media_type.Release(); 2383 media_type.Release();
2382 } 2384 }
2383 return false; 2385 return false;
2384 } 2386 }
2385 2387
2386 } // namespace content 2388 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698