| 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/gpu/media_foundation_video_encode_accelerator_win.h" | 5 #include "media/gpu/media_foundation_video_encode_accelerator_win.h" |
| 6 | 6 |
| 7 #pragma warning(push) | 7 #pragma warning(push) |
| 8 #pragma warning(disable : 4800) // Disable warning for added padding. | 8 #pragma warning(disable : 4800) // Disable warning for added padding. |
| 9 | 9 |
| 10 #include <codecapi.h> | 10 #include <codecapi.h> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 if (!InitializeInputOutputSamples()) { | 194 if (!InitializeInputOutputSamples()) { |
| 195 DLOG(ERROR) << "Failed initializing input-output samples."; | 195 DLOG(ERROR) << "Failed initializing input-output samples."; |
| 196 return false; | 196 return false; |
| 197 } | 197 } |
| 198 | 198 |
| 199 MFT_INPUT_STREAM_INFO input_stream_info; | 199 MFT_INPUT_STREAM_INFO input_stream_info; |
| 200 HRESULT hr = | 200 HRESULT hr = |
| 201 encoder_->GetInputStreamInfo(input_stream_id_, &input_stream_info); | 201 encoder_->GetInputStreamInfo(input_stream_id_, &input_stream_info); |
| 202 RETURN_ON_HR_FAILURE(hr, "Couldn't get input stream info", false); | 202 RETURN_ON_HR_FAILURE(hr, "Couldn't get input stream info", false); |
| 203 input_sample_.Attach(mf::CreateEmptySampleWithBuffer( | 203 input_sample_ = mf::CreateEmptySampleWithBuffer( |
| 204 input_stream_info.cbSize | 204 input_stream_info.cbSize |
| 205 ? input_stream_info.cbSize | 205 ? input_stream_info.cbSize |
| 206 : VideoFrame::AllocationSize(PIXEL_FORMAT_I420, input_visible_size_), | 206 : VideoFrame::AllocationSize(PIXEL_FORMAT_I420, input_visible_size_), |
| 207 input_stream_info.cbAlignment)); | 207 input_stream_info.cbAlignment); |
| 208 | 208 |
| 209 MFT_OUTPUT_STREAM_INFO output_stream_info; | 209 MFT_OUTPUT_STREAM_INFO output_stream_info; |
| 210 hr = encoder_->GetOutputStreamInfo(output_stream_id_, &output_stream_info); | 210 hr = encoder_->GetOutputStreamInfo(output_stream_id_, &output_stream_info); |
| 211 RETURN_ON_HR_FAILURE(hr, "Couldn't get output stream info", false); | 211 RETURN_ON_HR_FAILURE(hr, "Couldn't get output stream info", false); |
| 212 output_sample_.Attach(mf::CreateEmptySampleWithBuffer( | 212 output_sample_ = mf::CreateEmptySampleWithBuffer( |
| 213 output_stream_info.cbSize | 213 output_stream_info.cbSize |
| 214 ? output_stream_info.cbSize | 214 ? output_stream_info.cbSize |
| 215 : bitstream_buffer_size_ * kOutputSampleBufferSizeRatio, | 215 : bitstream_buffer_size_ * kOutputSampleBufferSizeRatio, |
| 216 output_stream_info.cbAlignment)); | 216 output_stream_info.cbAlignment); |
| 217 | 217 |
| 218 hr = encoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL); | 218 hr = encoder_->ProcessMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, NULL); |
| 219 RETURN_ON_HR_FAILURE(hr, "Couldn't set ProcessMessage", false); | 219 RETURN_ON_HR_FAILURE(hr, "Couldn't set ProcessMessage", false); |
| 220 | 220 |
| 221 // Pin all client callbacks to the main task runner initially. It can be | 221 // Pin all client callbacks to the main task runner initially. It can be |
| 222 // reassigned by TryToSetupEncodeOnSeparateThread(). | 222 // reassigned by TryToSetupEncodeOnSeparateThread(). |
| 223 if (!encode_client_task_runner_) { | 223 if (!encode_client_task_runner_) { |
| 224 encode_client_task_runner_ = main_client_task_runner_; | 224 encode_client_task_runner_ = main_client_task_runner_; |
| 225 encode_client_ = main_client_; | 225 encode_client_ = main_client_; |
| 226 } | 226 } |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 void MediaFoundationVideoEncodeAccelerator::ReleaseEncoderResources() { | 695 void MediaFoundationVideoEncodeAccelerator::ReleaseEncoderResources() { |
| 696 encoder_.Release(); | 696 encoder_.Release(); |
| 697 codec_api_.Release(); | 697 codec_api_.Release(); |
| 698 imf_input_media_type_.Release(); | 698 imf_input_media_type_.Release(); |
| 699 imf_output_media_type_.Release(); | 699 imf_output_media_type_.Release(); |
| 700 input_sample_.Release(); | 700 input_sample_.Release(); |
| 701 output_sample_.Release(); | 701 output_sample_.Release(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 } // namespace content | 704 } // namespace content |
| OLD | NEW |