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

Side by Side Diff: media/gpu/d3d11_h264_accelerator.cc

Issue 2824773002: Rename ScopedComPtr::get() to ScopedComPtr::Get() (Closed)
Patch Set: Update to 5293966 Created 3 years, 8 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
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 #include "media/gpu/d3d11_h264_accelerator.h" 5 #include "media/gpu/d3d11_h264_accelerator.h"
6 6
7 #include <d3d11.h> 7 #include <d3d11.h>
8 #include <dxva.h> 8 #include <dxva.h>
9 #include <windows.h> 9 #include <windows.h>
10 10
(...skipping 30 matching lines...) Expand all
41 base::win::ScopedComPtr<ID3D11VideoDevice> video_device, 41 base::win::ScopedComPtr<ID3D11VideoDevice> video_device,
42 base::win::ScopedComPtr<ID3D11Texture2D> texture, 42 base::win::ScopedComPtr<ID3D11Texture2D> texture,
43 const GUID& decoder_guid) { 43 const GUID& decoder_guid) {
44 texture_ = texture; 44 texture_ = texture;
45 D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC view_desc = {}; 45 D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC view_desc = {};
46 view_desc.DecodeProfile = decoder_guid; 46 view_desc.DecodeProfile = decoder_guid;
47 view_desc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D; 47 view_desc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;
48 view_desc.Texture2D.ArraySlice = (UINT)level_; 48 view_desc.Texture2D.ArraySlice = (UINT)level_;
49 49
50 HRESULT hr = video_device->CreateVideoDecoderOutputView( 50 HRESULT hr = video_device->CreateVideoDecoderOutputView(
51 texture.get(), &view_desc, output_view_.Receive()); 51 texture.Get(), &view_desc, output_view_.Receive());
52 52
53 CHECK(SUCCEEDED(hr)); 53 CHECK(SUCCEEDED(hr));
54 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); 54 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay();
55 const EGLint stream_attributes[] = { 55 const EGLint stream_attributes[] = {
56 EGL_CONSUMER_LATENCY_USEC_KHR, 56 EGL_CONSUMER_LATENCY_USEC_KHR,
57 0, 57 0,
58 EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR, 58 EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR,
59 0, 59 0,
60 EGL_NONE, 60 EGL_NONE,
61 }; 61 };
(...skipping 26 matching lines...) Expand all
88 }; 88 };
89 89
90 result = eglCreateStreamProducerD3DTextureNV12ANGLE(egl_display, stream_, 90 result = eglCreateStreamProducerD3DTextureNV12ANGLE(egl_display, stream_,
91 producer_attributes); 91 producer_attributes);
92 92
93 EGLAttrib frame_attributes[] = { 93 EGLAttrib frame_attributes[] = {
94 EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, level_, EGL_NONE, 94 EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, level_, EGL_NONE,
95 }; 95 };
96 96
97 result = eglStreamPostD3DTextureNV12ANGLE(egl_display, stream_, 97 result = eglStreamPostD3DTextureNV12ANGLE(egl_display, stream_,
98 static_cast<void*>(texture.get()), 98 static_cast<void*>(texture.Get()),
99 frame_attributes); 99 frame_attributes);
100 RETURN_ON_FAILURE(result, "Could not post texture", false); 100 RETURN_ON_FAILURE(result, "Could not post texture", false);
101 result = eglStreamConsumerAcquireKHR(egl_display, stream_); 101 result = eglStreamConsumerAcquireKHR(egl_display, stream_);
102 RETURN_ON_FAILURE(result, "Could not post acquire stream", false); 102 RETURN_ON_FAILURE(result, "Could not post acquire stream", false);
103 return true; 103 return true;
104 } 104 }
105 105
106 class D3D11H264Picture : public H264Picture { 106 class D3D11H264Picture : public H264Picture {
107 public: 107 public:
108 D3D11H264Picture(D3D11PictureBuffer* picture, size_t input_buffer_id) 108 D3D11H264Picture(D3D11PictureBuffer* picture, size_t input_buffer_id)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 const H264DPB& dpb, 146 const H264DPB& dpb,
147 const H264Picture::Vector& ref_pic_listp0, 147 const H264Picture::Vector& ref_pic_listp0,
148 const H264Picture::Vector& ref_pic_listb0, 148 const H264Picture::Vector& ref_pic_listb0,
149 const H264Picture::Vector& ref_pic_listb1, 149 const H264Picture::Vector& ref_pic_listb1,
150 const scoped_refptr<H264Picture>& pic) { 150 const scoped_refptr<H264Picture>& pic) {
151 scoped_refptr<D3D11H264Picture> our_pic( 151 scoped_refptr<D3D11H264Picture> our_pic(
152 static_cast<D3D11H264Picture*>(pic.get())); 152 static_cast<D3D11H264Picture*>(pic.get()));
153 153
154 HRESULT hr; 154 HRESULT hr;
155 hr = video_context_->DecoderBeginFrame( 155 hr = video_context_->DecoderBeginFrame(
156 video_decoder_.get(), our_pic->picture->output_view_.get(), 0, nullptr); 156 video_decoder_.Get(), our_pic->picture->output_view_.Get(), 0, nullptr);
157 CHECK(SUCCEEDED(hr)); 157 CHECK(SUCCEEDED(hr));
158 158
159 sps_ = *sps; 159 sps_ = *sps;
160 for (size_t i = 0; i < 16; i++) { 160 for (size_t i = 0; i < 16; i++) {
161 ref_frame_list_[i].bPicEntry = 0xFF; 161 ref_frame_list_[i].bPicEntry = 0xFF;
162 field_order_cnt_list_[i][0] = 0; 162 field_order_cnt_list_[i][0] = 0;
163 field_order_cnt_list_[i][1] = 0; 163 field_order_cnt_list_[i][1] = 0;
164 frame_num_list_[i] = 0; 164 frame_num_list_[i] = 0;
165 } 165 }
166 used_for_reference_flags_ = 0; 166 used_for_reference_flags_ = 0;
(...skipping 23 matching lines...) Expand all
190 slice_info_.clear(); 190 slice_info_.clear();
191 RetrieveBitstreamBuffer(); 191 RetrieveBitstreamBuffer();
192 return true; 192 return true;
193 } 193 }
194 194
195 void D3D11H264Accelerator::RetrieveBitstreamBuffer() { 195 void D3D11H264Accelerator::RetrieveBitstreamBuffer() {
196 current_offset_ = 0; 196 current_offset_ = 0;
197 void* buffer; 197 void* buffer;
198 UINT buffer_size; 198 UINT buffer_size;
199 HRESULT hr = video_context_->GetDecoderBuffer( 199 HRESULT hr = video_context_->GetDecoderBuffer(
200 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_BITSTREAM, &buffer_size, 200 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_BITSTREAM, &buffer_size,
201 &buffer); 201 &buffer);
202 bitstream_buffer_bytes_ = (uint8_t*)buffer; 202 bitstream_buffer_bytes_ = (uint8_t*)buffer;
203 bitstream_buffer_size_ = buffer_size; 203 bitstream_buffer_size_ = buffer_size;
204 CHECK(SUCCEEDED(hr)); 204 CHECK(SUCCEEDED(hr));
205 } 205 }
206 206
207 bool D3D11H264Accelerator::SubmitSlice(const H264PPS* pps, 207 bool D3D11H264Accelerator::SubmitSlice(const H264PPS* pps,
208 const H264SliceHeader* slice_hdr, 208 const H264SliceHeader* slice_hdr,
209 const H264Picture::Vector& ref_pic_list0, 209 const H264Picture::Vector& ref_pic_list0,
210 const H264Picture::Vector& ref_pic_list1, 210 const H264Picture::Vector& ref_pic_list1,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // UNUSED: slice_group_change_rate 291 // UNUSED: slice_group_change_rate
292 // 292 //
293 // 293 //
294 // 294 //
295 295
296 pic_param.StatusReportFeedbackNumber = 1; 296 pic_param.StatusReportFeedbackNumber = 1;
297 297
298 UINT buffer_size; 298 UINT buffer_size;
299 void* buffer; 299 void* buffer;
300 HRESULT hr = video_context_->GetDecoderBuffer( 300 HRESULT hr = video_context_->GetDecoderBuffer(
301 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS, 301 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS,
302 &buffer_size, &buffer); 302 &buffer_size, &buffer);
303 CHECK(SUCCEEDED(hr)); 303 CHECK(SUCCEEDED(hr));
304 304
305 memcpy(buffer, &pic_param, sizeof(pic_param)); 305 memcpy(buffer, &pic_param, sizeof(pic_param));
306 hr = video_context_->ReleaseDecoderBuffer( 306 hr = video_context_->ReleaseDecoderBuffer(
307 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS); 307 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS);
308 CHECK(SUCCEEDED(hr)); 308 CHECK(SUCCEEDED(hr));
309 309
310 DXVA_Qmatrix_H264 iq_matrix_buf = {}; 310 DXVA_Qmatrix_H264 iq_matrix_buf = {};
311 311
312 if (pps->pic_scaling_matrix_present_flag) { 312 if (pps->pic_scaling_matrix_present_flag) {
313 for (int i = 0; i < 6; ++i) { 313 for (int i = 0; i < 6; ++i) {
314 for (int j = 0; j < 16; ++j) 314 for (int j = 0; j < 16; ++j)
315 iq_matrix_buf.bScalingLists4x4[i][j] = pps->scaling_list4x4[i][j]; 315 iq_matrix_buf.bScalingLists4x4[i][j] = pps->scaling_list4x4[i][j];
316 } 316 }
317 317
318 for (int i = 0; i < 2; ++i) { 318 for (int i = 0; i < 2; ++i) {
319 for (int j = 0; j < 64; ++j) 319 for (int j = 0; j < 64; ++j)
320 iq_matrix_buf.bScalingLists8x8[i][j] = pps->scaling_list8x8[i][j]; 320 iq_matrix_buf.bScalingLists8x8[i][j] = pps->scaling_list8x8[i][j];
321 } 321 }
322 } else { 322 } else {
323 for (int i = 0; i < 6; ++i) { 323 for (int i = 0; i < 6; ++i) {
324 for (int j = 0; j < 16; ++j) 324 for (int j = 0; j < 16; ++j)
325 iq_matrix_buf.bScalingLists4x4[i][j] = sps_.scaling_list4x4[i][j]; 325 iq_matrix_buf.bScalingLists4x4[i][j] = sps_.scaling_list4x4[i][j];
326 } 326 }
327 327
328 for (int i = 0; i < 2; ++i) { 328 for (int i = 0; i < 2; ++i) {
329 for (int j = 0; j < 64; ++j) 329 for (int j = 0; j < 64; ++j)
330 iq_matrix_buf.bScalingLists8x8[i][j] = sps_.scaling_list8x8[i][j]; 330 iq_matrix_buf.bScalingLists8x8[i][j] = sps_.scaling_list8x8[i][j];
331 } 331 }
332 } 332 }
333 hr = video_context_->GetDecoderBuffer( 333 hr = video_context_->GetDecoderBuffer(
334 video_decoder_.get(), 334 video_decoder_.Get(),
335 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX, &buffer_size, 335 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX, &buffer_size,
336 &buffer); 336 &buffer);
337 CHECK(SUCCEEDED(hr)); 337 CHECK(SUCCEEDED(hr));
338 memcpy(buffer, &iq_matrix_buf, sizeof(iq_matrix_buf)); 338 memcpy(buffer, &iq_matrix_buf, sizeof(iq_matrix_buf));
339 hr = video_context_->ReleaseDecoderBuffer( 339 hr = video_context_->ReleaseDecoderBuffer(
340 video_decoder_.get(), 340 video_decoder_.Get(),
341 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX); 341 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX);
342 342
343 // Ideally all slices in a frame are put in the same bitstream buffer. 343 // Ideally all slices in a frame are put in the same bitstream buffer.
344 // However the bitstream buffer may not fit all the data, so split on the 344 // However the bitstream buffer may not fit all the data, so split on the
345 // necessary boundaries. 345 // necessary boundaries.
346 346
347 size_t out_bitstream_size = size + 3; 347 size_t out_bitstream_size = size + 3;
348 348
349 size_t remaining_bitstream = out_bitstream_size; 349 size_t remaining_bitstream = out_bitstream_size;
350 size_t start_location = 0; 350 size_t start_location = 0;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 } 394 }
395 395
396 return true; 396 return true;
397 } 397 }
398 398
399 void D3D11H264Accelerator::SubmitSliceData() { 399 void D3D11H264Accelerator::SubmitSliceData() {
400 CHECK(slice_info_.size() > 0); 400 CHECK(slice_info_.size() > 0);
401 UINT buffer_size; 401 UINT buffer_size;
402 void* buffer; 402 void* buffer;
403 HRESULT hr = video_context_->GetDecoderBuffer( 403 HRESULT hr = video_context_->GetDecoderBuffer(
404 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL, 404 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL,
405 &buffer_size, &buffer); 405 &buffer_size, &buffer);
406 CHECK(SUCCEEDED(hr)); 406 CHECK(SUCCEEDED(hr));
407 CHECK_LE(sizeof(slice_info_[0]) * slice_info_.size(), buffer_size); 407 CHECK_LE(sizeof(slice_info_[0]) * slice_info_.size(), buffer_size);
408 memcpy(buffer, &slice_info_[0], sizeof(slice_info_[0]) * slice_info_.size()); 408 memcpy(buffer, &slice_info_[0], sizeof(slice_info_[0]) * slice_info_.size());
409 hr = video_context_->ReleaseDecoderBuffer( 409 hr = video_context_->ReleaseDecoderBuffer(
410 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL); 410 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL);
411 411
412 hr = video_context_->ReleaseDecoderBuffer( 412 hr = video_context_->ReleaseDecoderBuffer(
413 video_decoder_.get(), D3D11_VIDEO_DECODER_BUFFER_BITSTREAM); 413 video_decoder_.Get(), D3D11_VIDEO_DECODER_BUFFER_BITSTREAM);
414 D3D11_VIDEO_DECODER_BUFFER_DESC buffers[4] = {}; 414 D3D11_VIDEO_DECODER_BUFFER_DESC buffers[4] = {};
415 buffers[0].BufferType = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS; 415 buffers[0].BufferType = D3D11_VIDEO_DECODER_BUFFER_PICTURE_PARAMETERS;
416 buffers[0].DataOffset = 0; 416 buffers[0].DataOffset = 0;
417 buffers[0].DataSize = sizeof(DXVA_PicParams_H264); 417 buffers[0].DataSize = sizeof(DXVA_PicParams_H264);
418 buffers[1].BufferType = 418 buffers[1].BufferType =
419 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX; 419 D3D11_VIDEO_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX;
420 buffers[1].DataOffset = 0; 420 buffers[1].DataOffset = 0;
421 buffers[1].DataSize = sizeof(DXVA_Qmatrix_H264); 421 buffers[1].DataSize = sizeof(DXVA_Qmatrix_H264);
422 buffers[2].BufferType = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL; 422 buffers[2].BufferType = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
423 buffers[2].DataOffset = 0; 423 buffers[2].DataOffset = 0;
424 buffers[2].DataSize = (UINT)(sizeof(slice_info_[0]) * slice_info_.size()); 424 buffers[2].DataSize = (UINT)(sizeof(slice_info_[0]) * slice_info_.size());
425 buffers[3].BufferType = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM; 425 buffers[3].BufferType = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
426 buffers[3].DataOffset = 0; 426 buffers[3].DataOffset = 0;
427 buffers[3].DataSize = (UINT)current_offset_; 427 buffers[3].DataSize = (UINT)current_offset_;
428 428
429 hr = video_context_->SubmitDecoderBuffers(video_decoder_.get(), 4, buffers); 429 hr = video_context_->SubmitDecoderBuffers(video_decoder_.Get(), 4, buffers);
430 current_offset_ = 0; 430 current_offset_ = 0;
431 slice_info_.clear(); 431 slice_info_.clear();
432 } 432 }
433 433
434 bool D3D11H264Accelerator::SubmitDecode(const scoped_refptr<H264Picture>& pic) { 434 bool D3D11H264Accelerator::SubmitDecode(const scoped_refptr<H264Picture>& pic) {
435 SubmitSliceData(); 435 SubmitSliceData();
436 436
437 HRESULT hr = video_context_->DecoderEndFrame(video_decoder_.get()); 437 HRESULT hr = video_context_->DecoderEndFrame(video_decoder_.Get());
438 CHECK(SUCCEEDED(hr)); 438 CHECK(SUCCEEDED(hr));
439 439
440 return true; 440 return true;
441 } 441 }
442 442
443 bool D3D11H264Accelerator::OutputPicture( 443 bool D3D11H264Accelerator::OutputPicture(
444 const scoped_refptr<H264Picture>& pic) { 444 const scoped_refptr<H264Picture>& pic) {
445 scoped_refptr<D3D11H264Picture> our_pic( 445 scoped_refptr<D3D11H264Picture> our_pic(
446 static_cast<D3D11H264Picture*>(pic.get())); 446 static_cast<D3D11H264Picture*>(pic.get()));
447 client_->OutputResult(our_pic->picture, our_pic->input_buffer_id_); 447 client_->OutputResult(our_pic->picture, our_pic->input_buffer_id_);
448 return true; 448 return true;
449 } 449 }
450 450
451 D3D11H264Picture::~D3D11H264Picture() { 451 D3D11H264Picture::~D3D11H264Picture() {
452 picture->set_in_picture_use(false); 452 picture->set_in_picture_use(false);
453 } 453 }
454 454
455 } // namespace media 455 } // namespace media
OLDNEW
« no previous file with comments | « media/capture/video/win/video_capture_device_win.cc ('k') | media/gpu/d3d11_video_decode_accelerator_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698