| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/cast/sender/external_video_encoder.h" | 5 #include "media/cast/sender/external_video_encoder.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 output_buffer_size, | 241 output_buffer_size, |
| 242 base::Bind(&VEAClientImpl::OnCreateSharedMemory, this)); | 242 base::Bind(&VEAClientImpl::OnCreateSharedMemory, this)); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Encoder has encoded a frame and it's available in one of the output | 246 // Encoder has encoded a frame and it's available in one of the output |
| 247 // buffers. Package the result in a media::cast::EncodedFrame and post it | 247 // buffers. Package the result in a media::cast::EncodedFrame and post it |
| 248 // to the Cast MAIN thread via the supplied callback. | 248 // to the Cast MAIN thread via the supplied callback. |
| 249 void BitstreamBufferReady(int32_t bitstream_buffer_id, | 249 void BitstreamBufferReady(int32_t bitstream_buffer_id, |
| 250 size_t payload_size, | 250 size_t payload_size, |
| 251 bool key_frame) final { | 251 bool key_frame, |
| 252 base::TimeDelta /* timestamp */) final { |
| 252 DCHECK(task_runner_->RunsTasksOnCurrentThread()); | 253 DCHECK(task_runner_->RunsTasksOnCurrentThread()); |
| 253 if (bitstream_buffer_id < 0 || | 254 if (bitstream_buffer_id < 0 || |
| 254 bitstream_buffer_id >= static_cast<int32_t>(output_buffers_.size())) { | 255 bitstream_buffer_id >= static_cast<int32_t>(output_buffers_.size())) { |
| 255 NOTREACHED(); | 256 NOTREACHED(); |
| 256 VLOG(1) << "BitstreamBufferReady(): invalid bitstream_buffer_id=" | 257 VLOG(1) << "BitstreamBufferReady(): invalid bitstream_buffer_id=" |
| 257 << bitstream_buffer_id; | 258 << bitstream_buffer_id; |
| 258 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 259 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
| 259 return; | 260 return; |
| 260 } | 261 } |
| 261 base::SharedMemory* output_buffer = | 262 base::SharedMemory* output_buffer = |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 893 const double kEntropyAtMaxQuantizer = 7.5; | 894 const double kEntropyAtMaxQuantizer = 7.5; |
| 894 const double slope = | 895 const double slope = |
| 895 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer; | 896 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer; |
| 896 const double quantizer = std::min<double>( | 897 const double quantizer = std::min<double>( |
| 897 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy); | 898 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy); |
| 898 return quantizer; | 899 return quantizer; |
| 899 } | 900 } |
| 900 | 901 |
| 901 } // namespace cast | 902 } // namespace cast |
| 902 } // namespace media | 903 } // namespace media |
| OLD | NEW |