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 // This is defined here to ensure the D3D11, D3D9, and DXVA includes through | 5 // This is defined here to ensure the D3D11, D3D9, and DXVA includes through |
6 // this header have their GUIDs intialized. | 6 // this header have their GUIDs intialized. |
7 #define INITGUID | 7 #define INITGUID |
8 #include "media/gpu/d3d11_video_decode_accelerator_win.h" | 8 #include "media/gpu/d3d11_video_decode_accelerator_win.h" |
9 #undef INITGUID | 9 #undef INITGUID |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 make_context_current_cb_(make_context_current_cb) {} | 41 make_context_current_cb_(make_context_current_cb) {} |
42 | 42 |
43 D3D11VideoDecodeAccelerator::~D3D11VideoDecodeAccelerator() {} | 43 D3D11VideoDecodeAccelerator::~D3D11VideoDecodeAccelerator() {} |
44 | 44 |
45 bool D3D11VideoDecodeAccelerator::Initialize(const Config& config, | 45 bool D3D11VideoDecodeAccelerator::Initialize(const Config& config, |
46 Client* client) { | 46 Client* client) { |
47 client_ = client; | 47 client_ = client; |
48 make_context_current_cb_.Run(); | 48 make_context_current_cb_.Run(); |
49 | 49 |
50 device_ = gl::QueryD3D11DeviceObjectFromANGLE(); | 50 device_ = gl::QueryD3D11DeviceObjectFromANGLE(); |
51 device_->GetImmediateContext(device_context_.Receive()); | 51 device_->GetImmediateContext(device_context_.GetAddressOf()); |
52 | 52 |
53 HRESULT hr = device_context_.CopyTo(video_context_.Receive()); | 53 HRESULT hr = device_context_.CopyTo(video_context_.GetAddressOf()); |
54 CHECK(SUCCEEDED(hr)); | 54 CHECK(SUCCEEDED(hr)); |
55 | 55 |
56 hr = device_.CopyTo(video_device_.Receive()); | 56 hr = device_.CopyTo(video_device_.GetAddressOf()); |
57 CHECK(SUCCEEDED(hr)); | 57 CHECK(SUCCEEDED(hr)); |
58 | 58 |
59 bool is_h264 = | 59 bool is_h264 = |
60 config.profile >= H264PROFILE_MIN && config.profile <= H264PROFILE_MAX; | 60 config.profile >= H264PROFILE_MIN && config.profile <= H264PROFILE_MAX; |
61 if (!is_h264) | 61 if (!is_h264) |
62 return false; | 62 return false; |
63 | 63 |
64 GUID needed_guid; | 64 GUID needed_guid; |
65 memcpy(&needed_guid, &D3D11_DECODER_PROFILE_H264_VLD_NOFGT, | 65 memcpy(&needed_guid, &D3D11_DECODER_PROFILE_H264_VLD_NOFGT, |
66 sizeof(needed_guid)); | 66 sizeof(needed_guid)); |
(...skipping 30 matching lines...) Expand all Loading... |
97 hr = video_device_->GetVideoDecoderConfig(&desc, i, &dec_config); | 97 hr = video_device_->GetVideoDecoderConfig(&desc, i, &dec_config); |
98 if (FAILED(hr)) | 98 if (FAILED(hr)) |
99 CHECK(false); | 99 CHECK(false); |
100 if (dec_config.ConfigBitstreamRaw == 2) | 100 if (dec_config.ConfigBitstreamRaw == 2) |
101 break; | 101 break; |
102 } | 102 } |
103 memcpy(&decoder_guid_, &decoder_guid, sizeof decoder_guid_); | 103 memcpy(&decoder_guid_, &decoder_guid, sizeof decoder_guid_); |
104 | 104 |
105 base::win::ScopedComPtr<ID3D11VideoDecoder> video_decoder; | 105 base::win::ScopedComPtr<ID3D11VideoDecoder> video_decoder; |
106 hr = video_device_->CreateVideoDecoder(&desc, &dec_config, | 106 hr = video_device_->CreateVideoDecoder(&desc, &dec_config, |
107 video_decoder.Receive()); | 107 video_decoder.GetAddressOf()); |
108 CHECK(video_decoder.Get()); | 108 CHECK(video_decoder.Get()); |
109 | 109 |
110 h264_accelerator_.reset(new D3D11H264Accelerator( | 110 h264_accelerator_.reset(new D3D11H264Accelerator( |
111 this, video_decoder, video_device_, video_context_)); | 111 this, video_decoder, video_device_, video_context_)); |
112 decoder_.reset(new media::H264Decoder(h264_accelerator_.get())); | 112 decoder_.reset(new media::H264Decoder(h264_accelerator_.get())); |
113 | 113 |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 void D3D11VideoDecodeAccelerator::Decode( | 117 void D3D11VideoDecodeAccelerator::Decode( |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 texture_desc.Height = decoder_->GetPicSize().height(); | 171 texture_desc.Height = decoder_->GetPicSize().height(); |
172 texture_desc.MipLevels = 1; | 172 texture_desc.MipLevels = 1; |
173 texture_desc.ArraySize = buffers.size(); | 173 texture_desc.ArraySize = buffers.size(); |
174 texture_desc.Format = DXGI_FORMAT_NV12; | 174 texture_desc.Format = DXGI_FORMAT_NV12; |
175 texture_desc.SampleDesc.Count = 1; | 175 texture_desc.SampleDesc.Count = 1; |
176 texture_desc.Usage = D3D11_USAGE_DEFAULT; | 176 texture_desc.Usage = D3D11_USAGE_DEFAULT; |
177 texture_desc.BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE; | 177 texture_desc.BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE; |
178 texture_desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; | 178 texture_desc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; |
179 | 179 |
180 base::win::ScopedComPtr<ID3D11Texture2D> out_texture; | 180 base::win::ScopedComPtr<ID3D11Texture2D> out_texture; |
181 HRESULT hr = | 181 HRESULT hr = device_->CreateTexture2D(&texture_desc, nullptr, |
182 device_->CreateTexture2D(&texture_desc, nullptr, out_texture.Receive()); | 182 out_texture.GetAddressOf()); |
183 CHECK(SUCCEEDED(hr)); | 183 CHECK(SUCCEEDED(hr)); |
184 | 184 |
185 make_context_current_cb_.Run(); | 185 make_context_current_cb_.Run(); |
186 picture_buffers_.clear(); | 186 picture_buffers_.clear(); |
187 | 187 |
188 for (size_t i = 0; i < buffers.size(); i++) { | 188 for (size_t i = 0; i < buffers.size(); i++) { |
189 picture_buffers_.push_back( | 189 picture_buffers_.push_back( |
190 base::MakeUnique<D3D11PictureBuffer>(buffers[i], i)); | 190 base::MakeUnique<D3D11PictureBuffer>(buffers[i], i)); |
191 picture_buffers_[i]->Init(video_device_, out_texture, decoder_guid_); | 191 picture_buffers_[i]->Init(video_device_, out_texture, decoder_guid_); |
192 } | 192 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 | 243 |
244 void D3D11VideoDecodeAccelerator::OutputResult(D3D11PictureBuffer* buffer, | 244 void D3D11VideoDecodeAccelerator::OutputResult(D3D11PictureBuffer* buffer, |
245 size_t input_buffer_id) { | 245 size_t input_buffer_id) { |
246 buffer->set_in_client_use(true); | 246 buffer->set_in_client_use(true); |
247 Picture picture(buffer->picture_buffer().id(), input_buffer_id, | 247 Picture picture(buffer->picture_buffer().id(), input_buffer_id, |
248 gfx::Rect(0, 0), gfx::ColorSpace(), false); | 248 gfx::Rect(0, 0), gfx::ColorSpace(), false); |
249 client_->PictureReady(picture); | 249 client_->PictureReady(picture); |
250 } | 250 } |
251 } // namespace media | 251 } // namespace media |
OLD | NEW |