OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/memory_mapped_file.h" | 9 #include "base/files/memory_mapped_file.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 VEAClient(const TestStream& test_stream, | 241 VEAClient(const TestStream& test_stream, |
242 ClientStateNotification<ClientState>* note, | 242 ClientStateNotification<ClientState>* note, |
243 bool save_to_file, | 243 bool save_to_file, |
244 unsigned int keyframe_period, | 244 unsigned int keyframe_period, |
245 bool force_bitrate); | 245 bool force_bitrate); |
246 virtual ~VEAClient(); | 246 virtual ~VEAClient(); |
247 void CreateEncoder(); | 247 void CreateEncoder(); |
248 void DestroyEncoder(); | 248 void DestroyEncoder(); |
249 | 249 |
250 // VideoDecodeAccelerator::Client implementation. | 250 // VideoDecodeAccelerator::Client implementation. |
251 void NotifyInitializeDone() OVERRIDE; | |
252 void RequireBitstreamBuffers(unsigned int input_count, | 251 void RequireBitstreamBuffers(unsigned int input_count, |
253 const gfx::Size& input_coded_size, | 252 const gfx::Size& input_coded_size, |
254 size_t output_buffer_size) OVERRIDE; | 253 size_t output_buffer_size) OVERRIDE; |
255 void BitstreamBufferReady(int32 bitstream_buffer_id, | 254 void BitstreamBufferReady(int32 bitstream_buffer_id, |
256 size_t payload_size, | 255 size_t payload_size, |
257 bool key_frame) OVERRIDE; | 256 bool key_frame) OVERRIDE; |
258 void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE; | 257 void NotifyError(VideoEncodeAccelerator::Error error) OVERRIDE; |
259 | 258 |
260 private: | 259 private: |
261 bool has_encoder() { return encoder_.get(); } | 260 bool has_encoder() { return encoder_.get(); } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 thread_checker_.DetachFromThread(); | 384 thread_checker_.DetachFromThread(); |
386 } | 385 } |
387 | 386 |
388 VEAClient::~VEAClient() { CHECK(!has_encoder()); } | 387 VEAClient::~VEAClient() { CHECK(!has_encoder()); } |
389 | 388 |
390 void VEAClient::CreateEncoder() { | 389 void VEAClient::CreateEncoder() { |
391 DCHECK(thread_checker_.CalledOnValidThread()); | 390 DCHECK(thread_checker_.CalledOnValidThread()); |
392 CHECK(!has_encoder()); | 391 CHECK(!has_encoder()); |
393 | 392 |
394 encoder_.reset(new ExynosVideoEncodeAccelerator()); | 393 encoder_.reset(new ExynosVideoEncodeAccelerator()); |
| 394 SetState(CS_ENCODER_SET); |
395 | 395 |
396 SetState(CS_ENCODER_SET); | |
397 DVLOG(1) << "Profile: " << test_stream_.requested_profile | 396 DVLOG(1) << "Profile: " << test_stream_.requested_profile |
398 << ", requested bitrate: " << test_stream_.requested_bitrate; | 397 << ", requested bitrate: " << test_stream_.requested_bitrate; |
399 encoder_->Initialize(kInputFormat, | 398 if (!encoder_->Initialize(kInputFormat, |
400 test_stream_.size, | 399 test_stream_.size, |
401 test_stream_.requested_profile, | 400 test_stream_.requested_profile, |
402 test_stream_.requested_bitrate, | 401 test_stream_.requested_bitrate, |
403 this); | 402 this)) { |
| 403 DLOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed"; |
| 404 SetState(CS_ERROR); |
| 405 return; |
| 406 } |
| 407 SetInitialConfiguration(); |
| 408 SetState(CS_INITIALIZED); |
404 } | 409 } |
405 | 410 |
406 void VEAClient::DestroyEncoder() { | 411 void VEAClient::DestroyEncoder() { |
407 DCHECK(thread_checker_.CalledOnValidThread()); | 412 DCHECK(thread_checker_.CalledOnValidThread()); |
408 if (!has_encoder()) | 413 if (!has_encoder()) |
409 return; | 414 return; |
410 encoder_.release()->Destroy(); | 415 encoder_.release()->Destroy(); |
411 } | 416 } |
412 | 417 |
413 void VEAClient::NotifyInitializeDone() { | |
414 DCHECK(thread_checker_.CalledOnValidThread()); | |
415 SetInitialConfiguration(); | |
416 SetState(CS_INITIALIZED); | |
417 } | |
418 | |
419 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, | 418 void VEAClient::RequireBitstreamBuffers(unsigned int input_count, |
420 const gfx::Size& input_coded_size, | 419 const gfx::Size& input_coded_size, |
421 size_t output_size) { | 420 size_t output_size) { |
422 DCHECK(thread_checker_.CalledOnValidThread()); | 421 DCHECK(thread_checker_.CalledOnValidThread()); |
423 ASSERT_EQ(state_, CS_INITIALIZED); | 422 ASSERT_EQ(state_, CS_INITIALIZED); |
424 SetState(CS_ENCODING); | 423 SetState(CS_ENCODING); |
425 | 424 |
426 // TODO(posciak): For now we only support input streams that meet encoder | 425 // TODO(posciak): For now we only support input streams that meet encoder |
427 // size requirements exactly (i.e. coded size == visible size). | 426 // size requirements exactly (i.e. coded size == visible size). |
428 input_coded_size_ = input_coded_size; | 427 input_coded_size_ = input_coded_size; |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 } | 760 } |
762 if (it->first == "v" || it->first == "vmodule") | 761 if (it->first == "v" || it->first == "vmodule") |
763 continue; | 762 continue; |
764 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; | 763 LOG(FATAL) << "Unexpected switch: " << it->first << ":" << it->second; |
765 } | 764 } |
766 | 765 |
767 base::ShadowingAtExitManager at_exit_manager; | 766 base::ShadowingAtExitManager at_exit_manager; |
768 | 767 |
769 return RUN_ALL_TESTS(); | 768 return RUN_ALL_TESTS(); |
770 } | 769 } |
OLD | NEW |