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

Side by Side Diff: media/cast/sender/external_video_encoder.cc

Issue 1515433002: Replace uses of raw uint32's with a type-checked RtpTimeTicks data type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Speculative workaround fix for win8_chromium_ng compile error. Created 4 years, 11 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
« no previous file with comments | « media/cast/sender/audio_sender.cc ('k') | media/cast/sender/fake_software_video_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/debug/crash_logging.h" 11 #include "base/debug/crash_logging.h"
12 #include "base/debug/dump_without_crashing.h" 12 #include "base/debug/dump_without_crashing.h"
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/memory/shared_memory.h" 17 #include "base/memory/shared_memory.h"
18 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
19 #include "base/metrics/histogram.h" 19 #include "base/metrics/histogram.h"
20 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
23 #include "media/base/video_types.h" 23 #include "media/base/video_types.h"
24 #include "media/base/video_util.h" 24 #include "media/base/video_util.h"
25 #include "media/cast/cast_config.h" 25 #include "media/cast/cast_config.h"
26 #include "media/cast/cast_defines.h" 26 #include "media/cast/cast_defines.h"
27 #include "media/cast/common/rtp_time.h"
27 #include "media/cast/logging/logging_defines.h" 28 #include "media/cast/logging/logging_defines.h"
28 #include "media/cast/net/cast_transport_config.h" 29 #include "media/cast/net/cast_transport_config.h"
29 #include "media/cast/sender/vp8_quantizer_parser.h" 30 #include "media/cast/sender/vp8_quantizer_parser.h"
30 #include "media/filters/h264_parser.h" 31 #include "media/filters/h264_parser.h"
31 32
32 namespace { 33 namespace {
33 34
34 enum { MAX_H264_QUANTIZER = 51 }; 35 enum { MAX_H264_QUANTIZER = 51 };
35 static const size_t kOutputBufferCount = 3; 36 static const size_t kOutputBufferCount = 3;
36 37
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 const InProgressFrameEncode& request = in_progress_frame_encodes_.front(); 224 const InProgressFrameEncode& request = in_progress_frame_encodes_.front();
224 225
225 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame()); 226 scoped_ptr<SenderEncodedFrame> encoded_frame(new SenderEncodedFrame());
226 encoded_frame->dependency = key_frame ? EncodedFrame::KEY : 227 encoded_frame->dependency = key_frame ? EncodedFrame::KEY :
227 EncodedFrame::DEPENDENT; 228 EncodedFrame::DEPENDENT;
228 encoded_frame->frame_id = next_frame_id_++; 229 encoded_frame->frame_id = next_frame_id_++;
229 if (key_frame) 230 if (key_frame)
230 encoded_frame->referenced_frame_id = encoded_frame->frame_id; 231 encoded_frame->referenced_frame_id = encoded_frame->frame_id;
231 else 232 else
232 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1; 233 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1;
233 encoded_frame->rtp_timestamp = TimeDeltaToRtpDelta( 234 encoded_frame->rtp_timestamp = RtpTimeTicks::FromTimeDelta(
234 request.video_frame->timestamp(), kVideoFrequency); 235 request.video_frame->timestamp(), kVideoFrequency);
235 encoded_frame->reference_time = request.reference_time; 236 encoded_frame->reference_time = request.reference_time;
236 if (!stream_header_.empty()) { 237 if (!stream_header_.empty()) {
237 encoded_frame->data = stream_header_; 238 encoded_frame->data = stream_header_;
238 stream_header_.clear(); 239 stream_header_.clear();
239 } 240 }
240 encoded_frame->data.append( 241 encoded_frame->data.append(
241 static_cast<const char*>(output_buffer->memory()), payload_size); 242 static_cast<const char*>(output_buffer->memory()), payload_size);
242 243
243 // If FRAME_DURATION metadata was provided in the source VideoFrame, 244 // If FRAME_DURATION metadata was provided in the source VideoFrame,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // which causes crypto crashes. http://crbug.com/519022 310 // which causes crypto crashes. http://crbug.com/519022
310 if (!has_seen_zero_length_encoded_frame_ && encoded_frame->data.empty()) { 311 if (!has_seen_zero_length_encoded_frame_ && encoded_frame->data.empty()) {
311 has_seen_zero_length_encoded_frame_ = true; 312 has_seen_zero_length_encoded_frame_ = true;
312 313
313 const char kZeroEncodeDetails[] = "zero-encode-details"; 314 const char kZeroEncodeDetails[] = "zero-encode-details";
314 const std::string details = base::StringPrintf( 315 const std::string details = base::StringPrintf(
315 ("%c/%c,id=%" PRIu32 ",rtp=%" PRIu32 ",br=%d,q=%" PRIuS 316 ("%c/%c,id=%" PRIu32 ",rtp=%" PRIu32 ",br=%d,q=%" PRIuS
316 ",act=%c,ref=%d"), 317 ",act=%c,ref=%d"),
317 codec_profile_ == media::VP8PROFILE_ANY ? 'V' : 'H', 318 codec_profile_ == media::VP8PROFILE_ANY ? 'V' : 'H',
318 key_frame ? 'K' : 'D', encoded_frame->frame_id, 319 key_frame ? 'K' : 'D', encoded_frame->frame_id,
319 encoded_frame->rtp_timestamp, request.target_bit_rate / 1000, 320 encoded_frame->rtp_timestamp.lower_32_bits(),
320 in_progress_frame_encodes_.size(), encoder_active_ ? 'Y' : 'N', 321 request.target_bit_rate / 1000, in_progress_frame_encodes_.size(),
322 encoder_active_ ? 'Y' : 'N',
321 static_cast<int>(encoded_frame->referenced_frame_id % 1000)); 323 static_cast<int>(encoded_frame->referenced_frame_id % 1000));
322 base::debug::SetCrashKeyValue(kZeroEncodeDetails, details); 324 base::debug::SetCrashKeyValue(kZeroEncodeDetails, details);
323 // Please forward crash reports to http://crbug.com/519022: 325 // Please forward crash reports to http://crbug.com/519022:
324 base::debug::DumpWithoutCrashing(); 326 base::debug::DumpWithoutCrashing();
325 base::debug::ClearCrashKey(kZeroEncodeDetails); 327 base::debug::ClearCrashKey(kZeroEncodeDetails);
326 } 328 }
327 329
328 encoded_frame->encode_completion_time = 330 encoded_frame->encode_completion_time =
329 cast_environment_->Clock()->NowTicks(); 331 cast_environment_->Clock()->NowTicks();
330 cast_environment_->PostTask( 332 cast_environment_->PostTask(
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 const double kEntropyAtMaxQuantizer = 7.5; 787 const double kEntropyAtMaxQuantizer = 7.5;
786 const double slope = 788 const double slope =
787 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer; 789 (MAX_VP8_QUANTIZER - MIN_VP8_QUANTIZER) / kEntropyAtMaxQuantizer;
788 const double quantizer = std::min<double>( 790 const double quantizer = std::min<double>(
789 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy); 791 MAX_VP8_QUANTIZER, MIN_VP8_QUANTIZER + slope * shannon_entropy);
790 return quantizer; 792 return quantizer;
791 } 793 }
792 794
793 } // namespace cast 795 } // namespace cast
794 } // namespace media 796 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/audio_sender.cc ('k') | media/cast/sender/fake_software_video_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698