OLD | NEW |
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 #include "media/base/win/mf_helpers.h" | 5 #include "media/base/win/mf_helpers.h" |
6 | 6 |
7 namespace media { | 7 namespace media { |
8 | 8 |
9 namespace mf { | 9 namespace mf { |
10 | 10 |
11 void LogDXVAError(int line) { | 11 void LogDXVAError(int line) { |
12 LOG(ERROR) << "Error in dxva_video_decode_accelerator_win.cc on line " | 12 LOG(ERROR) << "Error in dxva_video_decode_accelerator_win.cc on line " |
13 << line; | 13 << line; |
14 } | 14 } |
15 | 15 |
16 base::win::ScopedComPtr<IMFSample> CreateEmptySampleWithBuffer( | 16 base::win::ScopedComPtr<IMFSample> CreateEmptySampleWithBuffer( |
17 uint32_t buffer_length, | 17 uint32_t buffer_length, |
18 int align) { | 18 int align) { |
19 CHECK_GT(buffer_length, 0U); | 19 CHECK_GT(buffer_length, 0U); |
20 | 20 |
21 base::win::ScopedComPtr<IMFSample> sample; | 21 base::win::ScopedComPtr<IMFSample> sample; |
22 HRESULT hr = MFCreateSample(sample.Receive()); | 22 HRESULT hr = MFCreateSample(sample.GetAddressOf()); |
23 RETURN_ON_HR_FAILURE(hr, "MFCreateSample failed", | 23 RETURN_ON_HR_FAILURE(hr, "MFCreateSample failed", |
24 base::win::ScopedComPtr<IMFSample>()); | 24 base::win::ScopedComPtr<IMFSample>()); |
25 | 25 |
26 base::win::ScopedComPtr<IMFMediaBuffer> buffer; | 26 base::win::ScopedComPtr<IMFMediaBuffer> buffer; |
27 if (align == 0) { | 27 if (align == 0) { |
28 // Note that MFCreateMemoryBuffer is same as MFCreateAlignedMemoryBuffer | 28 // Note that MFCreateMemoryBuffer is same as MFCreateAlignedMemoryBuffer |
29 // with the align argument being 0. | 29 // with the align argument being 0. |
30 hr = MFCreateMemoryBuffer(buffer_length, buffer.Receive()); | 30 hr = MFCreateMemoryBuffer(buffer_length, buffer.GetAddressOf()); |
31 } else { | 31 } else { |
32 hr = | 32 hr = MFCreateAlignedMemoryBuffer(buffer_length, align - 1, |
33 MFCreateAlignedMemoryBuffer(buffer_length, align - 1, buffer.Receive()); | 33 buffer.GetAddressOf()); |
34 } | 34 } |
35 RETURN_ON_HR_FAILURE(hr, "Failed to create memory buffer for sample", | 35 RETURN_ON_HR_FAILURE(hr, "Failed to create memory buffer for sample", |
36 base::win::ScopedComPtr<IMFSample>()); | 36 base::win::ScopedComPtr<IMFSample>()); |
37 | 37 |
38 hr = sample->AddBuffer(buffer.Get()); | 38 hr = sample->AddBuffer(buffer.Get()); |
39 RETURN_ON_HR_FAILURE(hr, "Failed to add buffer to sample", | 39 RETURN_ON_HR_FAILURE(hr, "Failed to add buffer to sample", |
40 base::win::ScopedComPtr<IMFSample>()); | 40 base::win::ScopedComPtr<IMFSample>()); |
41 | 41 |
42 buffer->SetCurrentLength(0); | 42 buffer->SetCurrentLength(0); |
43 return sample; | 43 return sample; |
44 } | 44 } |
45 | 45 |
46 MediaBufferScopedPointer::MediaBufferScopedPointer(IMFMediaBuffer* media_buffer) | 46 MediaBufferScopedPointer::MediaBufferScopedPointer(IMFMediaBuffer* media_buffer) |
47 : media_buffer_(media_buffer), | 47 : media_buffer_(media_buffer), |
48 buffer_(nullptr), | 48 buffer_(nullptr), |
49 max_length_(0), | 49 max_length_(0), |
50 current_length_(0) { | 50 current_length_(0) { |
51 HRESULT hr = media_buffer_->Lock(&buffer_, &max_length_, ¤t_length_); | 51 HRESULT hr = media_buffer_->Lock(&buffer_, &max_length_, ¤t_length_); |
52 CHECK(SUCCEEDED(hr)); | 52 CHECK(SUCCEEDED(hr)); |
53 } | 53 } |
54 | 54 |
55 MediaBufferScopedPointer::~MediaBufferScopedPointer() { | 55 MediaBufferScopedPointer::~MediaBufferScopedPointer() { |
56 HRESULT hr = media_buffer_->Unlock(); | 56 HRESULT hr = media_buffer_->Unlock(); |
57 CHECK(SUCCEEDED(hr)); | 57 CHECK(SUCCEEDED(hr)); |
58 } | 58 } |
59 | 59 |
60 } // namespace mf | 60 } // namespace mf |
61 | 61 |
62 } // namespace media | 62 } // namespace media |
OLD | NEW |