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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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 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/video_sender.h" 5 #include "media/cast/sender/video_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring> 9 #include <cstring>
10 10
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 scoped_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() { 281 scoped_ptr<VideoFrameFactory> VideoSender::CreateVideoFrameFactory() {
282 return video_encoder_ ? video_encoder_->CreateVideoFrameFactory() : nullptr; 282 return video_encoder_ ? video_encoder_->CreateVideoFrameFactory() : nullptr;
283 } 283 }
284 284
285 int VideoSender::GetNumberOfFramesInEncoder() const { 285 int VideoSender::GetNumberOfFramesInEncoder() const {
286 return frames_in_encoder_; 286 return frames_in_encoder_;
287 } 287 }
288 288
289 base::TimeDelta VideoSender::GetInFlightMediaDuration() const { 289 base::TimeDelta VideoSender::GetInFlightMediaDuration() const {
290 if (GetUnacknowledgedFrameCount() > 0) { 290 if (GetUnacknowledgedFrameCount() > 0) {
291 const uint32 oldest_unacked_frame_id = latest_acked_frame_id_ + 1; 291 const uint32_t oldest_unacked_frame_id = latest_acked_frame_id_ + 1;
292 return last_enqueued_frame_reference_time_ - 292 return last_enqueued_frame_reference_time_ -
293 GetRecordedReferenceTime(oldest_unacked_frame_id); 293 GetRecordedReferenceTime(oldest_unacked_frame_id);
294 } else { 294 } else {
295 return duration_in_encoder_; 295 return duration_in_encoder_;
296 } 296 }
297 } 297 }
298 298
299 // static 299 // static
300 int VideoSender::GetMaximumTargetBitrateForFrame( 300 int VideoSender::GetMaximumTargetBitrateForFrame(
301 const media::VideoFrame& frame) { 301 const media::VideoFrame& frame) {
(...skipping 19 matching lines...) Expand all
321 321
322 // Determine the approximate height of a 16:9 frame having the same area 322 // Determine the approximate height of a 16:9 frame having the same area
323 // (number of pixels) as |frame|. 323 // (number of pixels) as |frame|.
324 const gfx::Size& resolution = frame.visible_rect().size(); 324 const gfx::Size& resolution = frame.visible_rect().size();
325 const int lines_of_resolution = 325 const int lines_of_resolution =
326 ((resolution.width() * 9) == (resolution.height() * 16)) ? 326 ((resolution.width() * 9) == (resolution.height() * 16)) ?
327 resolution.height() : 327 resolution.height() :
328 static_cast<int>(sqrt(resolution.GetArea() * 9.0 / 16.0)); 328 static_cast<int>(sqrt(resolution.GetArea() * 9.0 / 16.0));
329 329
330 // Linearly translate from |lines_of_resolution| to a maximum target bitrate. 330 // Linearly translate from |lines_of_resolution| to a maximum target bitrate.
331 int64 result = lines_of_resolution - STANDARD_RESOLUTION_LINES; 331 int64_t result = lines_of_resolution - STANDARD_RESOLUTION_LINES;
332 result *= BITRATE_FOR_HIGH_RESOLUTION - BITRATE_FOR_STANDARD_RESOLUTION; 332 result *= BITRATE_FOR_HIGH_RESOLUTION - BITRATE_FOR_STANDARD_RESOLUTION;
333 result /= HIGH_RESOLUTION_LINES - STANDARD_RESOLUTION_LINES; 333 result /= HIGH_RESOLUTION_LINES - STANDARD_RESOLUTION_LINES;
334 result += BITRATE_FOR_STANDARD_RESOLUTION; 334 result += BITRATE_FOR_STANDARD_RESOLUTION;
335 335
336 // Boost the result for high frame rate content. 336 // Boost the result for high frame rate content.
337 base::TimeDelta frame_duration; 337 base::TimeDelta frame_duration;
338 if (frame.metadata()->GetTimeDelta(media::VideoFrameMetadata::FRAME_DURATION, 338 if (frame.metadata()->GetTimeDelta(media::VideoFrameMetadata::FRAME_DURATION,
339 &frame_duration) && 339 &frame_duration) &&
340 frame_duration > base::TimeDelta() && 340 frame_duration > base::TimeDelta() &&
341 frame_duration.InMicroseconds() <= HIGH_FRAME_RATE_THRESHOLD_USEC) { 341 frame_duration.InMicroseconds() <= HIGH_FRAME_RATE_THRESHOLD_USEC) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 media::VideoFrameMetadata::RESOURCE_UTILIZATION, 381 media::VideoFrameMetadata::RESOURCE_UTILIZATION,
382 encoded_frame->dependency == EncodedFrame::KEY ? 382 encoded_frame->dependency == EncodedFrame::KEY ?
383 std::min(1.0, attenuated_utilization) : attenuated_utilization); 383 std::min(1.0, attenuated_utilization) : attenuated_utilization);
384 } 384 }
385 385
386 SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); 386 SendEncodedFrame(encoder_bitrate, encoded_frame.Pass());
387 } 387 }
388 388
389 } // namespace cast 389 } // namespace cast
390 } // namespace media 390 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698