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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

Issue 2911193002: Implement timing frames. (Closed)
Patch Set: Implement Asapersson@ comments Created 3 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
11 11
12 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h" 12 #include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
13 13
14 #include <limits> 14 #include <limits>
15 #include <string> 15 #include <string>
16 16
17 #include "third_party/openh264/src/codec/api/svc/codec_api.h" 17 #include "third_party/openh264/src/codec/api/svc/codec_api.h"
18 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" 18 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
19 #include "third_party/openh264/src/codec/api/svc/codec_def.h" 19 #include "third_party/openh264/src/codec/api/svc/codec_def.h"
20 #include "third_party/openh264/src/codec/api/svc/codec_ver.h" 20 #include "third_party/openh264/src/codec/api/svc/codec_ver.h"
21 21
22 #include "webrtc/base/checks.h" 22 #include "webrtc/base/checks.h"
23 #include "webrtc/base/logging.h" 23 #include "webrtc/base/logging.h"
24 #include "webrtc/base/timeutils.h"
24 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 25 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
25 #include "webrtc/media/base/mediaconstants.h"
26 #include "webrtc/system_wrappers/include/metrics.h" 26 #include "webrtc/system_wrappers/include/metrics.h"
27 27
28 namespace webrtc { 28 namespace webrtc {
29 29
30 namespace { 30 namespace {
31 31
32 const bool kOpenH264EncoderDetailedLogging = false; 32 const bool kOpenH264EncoderDetailedLogging = false;
33 33
34 // Used by histograms. Values of entries should not be changed. 34 // Used by histograms. Values of entries should not be changed.
35 enum H264EncoderImplEvent { 35 enum H264EncoderImplEvent {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // Force key frame? 326 // Force key frame?
327 force_key_frame = (*frame_types)[0] == kVideoFrameKey; 327 force_key_frame = (*frame_types)[0] == kVideoFrameKey;
328 } 328 }
329 if (force_key_frame) { 329 if (force_key_frame) {
330 // API doc says ForceIntraFrame(false) does nothing, but calling this 330 // API doc says ForceIntraFrame(false) does nothing, but calling this
331 // function forces a key frame regardless of the |bIDR| argument's value. 331 // function forces a key frame regardless of the |bIDR| argument's value.
332 // (If every frame is a key frame we get lag/delays.) 332 // (If every frame is a key frame we get lag/delays.)
333 openh264_encoder_->ForceIntraFrame(true); 333 openh264_encoder_->ForceIntraFrame(true);
334 } 334 }
335 rtc::scoped_refptr<const I420BufferInterface> frame_buffer = 335 rtc::scoped_refptr<const I420BufferInterface> frame_buffer =
336 input_frame.video_frame_buffer()->ToI420(); 336 input_frame.video_frame_buffer()->ToI420();
sprang_webrtc 2017/06/13 14:14:14 Why? Rebase?
ilnik 2017/06/13 14:55:44 Yes.
337 // EncodeFrame input. 337 // EncodeFrame input.
338 SSourcePicture picture; 338 SSourcePicture picture;
339 memset(&picture, 0, sizeof(SSourcePicture)); 339 memset(&picture, 0, sizeof(SSourcePicture));
340 picture.iPicWidth = frame_buffer->width(); 340 picture.iPicWidth = frame_buffer->width();
341 picture.iPicHeight = frame_buffer->height(); 341 picture.iPicHeight = frame_buffer->height();
342 picture.iColorFormat = EVideoFormatType::videoFormatI420; 342 picture.iColorFormat = EVideoFormatType::videoFormatI420;
343 picture.uiTimeStamp = input_frame.ntp_time_ms(); 343 picture.uiTimeStamp = input_frame.ntp_time_ms();
344 picture.iStride[0] = frame_buffer->StrideY(); 344 picture.iStride[0] = frame_buffer->StrideY();
345 picture.iStride[1] = frame_buffer->StrideU(); 345 picture.iStride[1] = frame_buffer->StrideU();
346 picture.iStride[2] = frame_buffer->StrideV(); 346 picture.iStride[2] = frame_buffer->StrideV();
(...skipping 16 matching lines...) Expand all
363 363
364 encoded_image_._encodedWidth = frame_buffer->width(); 364 encoded_image_._encodedWidth = frame_buffer->width();
365 encoded_image_._encodedHeight = frame_buffer->height(); 365 encoded_image_._encodedHeight = frame_buffer->height();
366 encoded_image_._timeStamp = input_frame.timestamp(); 366 encoded_image_._timeStamp = input_frame.timestamp();
367 encoded_image_.ntp_time_ms_ = input_frame.ntp_time_ms(); 367 encoded_image_.ntp_time_ms_ = input_frame.ntp_time_ms();
368 encoded_image_.capture_time_ms_ = input_frame.render_time_ms(); 368 encoded_image_.capture_time_ms_ = input_frame.render_time_ms();
369 encoded_image_.rotation_ = input_frame.rotation(); 369 encoded_image_.rotation_ = input_frame.rotation();
370 encoded_image_.content_type_ = (mode_ == kScreensharing) 370 encoded_image_.content_type_ = (mode_ == kScreensharing)
371 ? VideoContentType::SCREENSHARE 371 ? VideoContentType::SCREENSHARE
372 : VideoContentType::UNSPECIFIED; 372 : VideoContentType::UNSPECIFIED;
373 encoded_image_.timing_.is_timing_frame = false;
373 encoded_image_._frameType = ConvertToVideoFrameType(info.eFrameType); 374 encoded_image_._frameType = ConvertToVideoFrameType(info.eFrameType);
374 375
375 // Split encoded image up into fragments. This also updates |encoded_image_|. 376 // Split encoded image up into fragments. This also updates |encoded_image_|.
376 RTPFragmentationHeader frag_header; 377 RTPFragmentationHeader frag_header;
377 RtpFragmentize(&encoded_image_, &encoded_image_buffer_, *frame_buffer, &info, 378 RtpFragmentize(&encoded_image_, &encoded_image_buffer_, *frame_buffer, &info,
378 &frag_header); 379 &frag_header);
379 380
380 // Encoder can skip frames to save bandwidth in which case 381 // Encoder can skip frames to save bandwidth in which case
381 // |encoded_image_._length| == 0. 382 // |encoded_image_._length| == 0.
382 if (encoded_image_._length > 0) { 383 if (encoded_image_._length > 0) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 498
498 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { 499 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) {
499 return WEBRTC_VIDEO_CODEC_OK; 500 return WEBRTC_VIDEO_CODEC_OK;
500 } 501 }
501 502
502 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const { 503 VideoEncoder::ScalingSettings H264EncoderImpl::GetScalingSettings() const {
503 return VideoEncoder::ScalingSettings(true); 504 return VideoEncoder::ScalingSettings(true);
504 } 505 }
505 506
506 } // namespace webrtc 507 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698