Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
|
magjed_webrtc
2016/11/29 15:43:49
2016?
nisse-webrtc
2016/11/29 15:56:14
I just copied the copyright header along with the
magjed_webrtc
2016/11/29 16:40:26
The year has been changed from 2012 to 2014. This
kjellander_webrtc
2016/11/30 07:19:12
Year should be current year if it's a new file, th
nisse-webrtc
2016/11/30 11:26:03
It's moving parts of webrtc/video_frame.h, which h
| |
| 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 #include "webrtc/video_frame.h" | 11 #include "webrtc/api/video/video_frame.h" |
| 12 | 12 |
| 13 #include <string.h> | |
| 14 | |
| 15 #include <algorithm> // swap | |
| 16 | |
| 17 #include "webrtc/base/bind.h" | |
| 18 #include "webrtc/base/checks.h" | 13 #include "webrtc/base/checks.h" |
| 14 #include "webrtc/base/timeutils.h" | |
|
pthatcher1
2016/11/30 00:48:28
Does this need to eventually be moved to webrtc/ap
nisse-webrtc
2016/11/30 11:26:03
This is the implementation file. As far as I under
| |
| 19 | 15 |
| 20 namespace webrtc { | 16 namespace webrtc { |
| 21 | 17 |
| 22 // FFmpeg's decoder, used by H264DecoderImpl, requires up to 8 bytes padding due | |
| 23 // to optimized bitstream readers. See avcodec_decode_video2. | |
| 24 const size_t EncodedImage::kBufferPaddingBytesH264 = 8; | |
| 25 | |
| 26 VideoFrame::VideoFrame() | 18 VideoFrame::VideoFrame() |
| 27 : video_frame_buffer_(nullptr), | 19 : video_frame_buffer_(nullptr), |
| 28 timestamp_rtp_(0), | 20 timestamp_rtp_(0), |
| 29 ntp_time_ms_(0), | 21 ntp_time_ms_(0), |
| 30 timestamp_us_(0), | 22 timestamp_us_(0), |
| 31 rotation_(kVideoRotation_0) {} | 23 rotation_(kVideoRotation_0) {} |
| 32 | 24 |
| 33 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | 25 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, |
| 34 webrtc::VideoRotation rotation, | 26 webrtc::VideoRotation rotation, |
| 35 int64_t timestamp_us) | 27 int64_t timestamp_us) |
| 36 : video_frame_buffer_(buffer), | 28 : video_frame_buffer_(buffer), |
| 37 timestamp_rtp_(0), | 29 timestamp_rtp_(0), |
| 38 ntp_time_ms_(0), | 30 ntp_time_ms_(0), |
| 39 timestamp_us_(timestamp_us), | 31 timestamp_us_(timestamp_us), |
| 40 rotation_(rotation) {} | 32 rotation_(rotation) {} |
| 41 | 33 |
| 42 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | 34 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, |
| 43 uint32_t timestamp, | 35 uint32_t timestamp, |
| 44 int64_t render_time_ms, | 36 int64_t render_time_ms, |
| 45 VideoRotation rotation) | 37 VideoRotation rotation) |
| 46 : video_frame_buffer_(buffer), | 38 : video_frame_buffer_(buffer), |
| 47 timestamp_rtp_(timestamp), | 39 timestamp_rtp_(timestamp), |
| 48 ntp_time_ms_(0), | 40 ntp_time_ms_(0), |
| 49 timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec), | 41 timestamp_us_(render_time_ms * rtc::kNumMicrosecsPerMillisec), |
| 50 rotation_(rotation) { | 42 rotation_(rotation) { |
| 51 RTC_DCHECK(buffer); | 43 RTC_DCHECK(buffer); |
| 52 } | 44 } |
| 53 | 45 |
| 46 VideoFrame::~VideoFrame() {} | |
|
magjed_webrtc
2016/11/29 15:43:49
maybe '= default' is better?
nisse-webrtc
2016/11/29 15:56:15
Makes sense.
nisse-webrtc
2016/11/30 11:26:03
Done.
| |
| 47 | |
| 48 VideoFrame::VideoFrame(const VideoFrame&) = default; | |
| 49 VideoFrame::VideoFrame(VideoFrame&&) = default; | |
| 50 VideoFrame& VideoFrame::operator=(const VideoFrame&) = default; | |
| 51 VideoFrame& VideoFrame::operator=(VideoFrame&&) = default; | |
| 52 | |
| 54 int VideoFrame::width() const { | 53 int VideoFrame::width() const { |
| 55 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; | 54 return video_frame_buffer_ ? video_frame_buffer_->width() : 0; |
| 56 } | 55 } |
| 57 | 56 |
| 58 int VideoFrame::height() const { | 57 int VideoFrame::height() const { |
| 59 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; | 58 return video_frame_buffer_ ? video_frame_buffer_->height() : 0; |
| 60 } | 59 } |
| 61 | 60 |
| 62 bool VideoFrame::IsZeroSize() const { | 61 bool VideoFrame::IsZeroSize() const { |
| 63 return !video_frame_buffer_; | 62 return !video_frame_buffer_; |
| 64 } | 63 } |
| 65 | 64 |
| 66 rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const { | 65 rtc::scoped_refptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const { |
| 67 return video_frame_buffer_; | 66 return video_frame_buffer_; |
| 68 } | 67 } |
| 69 | 68 |
| 70 size_t EncodedImage::GetBufferPaddingBytes(VideoCodecType codec_type) { | 69 void VideoFrame::set_render_time_ms(int64_t render_time_ms) { |
| 71 switch (codec_type) { | 70 set_timestamp_us(render_time_ms * rtc::kNumMicrosecsPerMillisec); |
| 72 case kVideoCodecVP8: | 71 ; |
|
magjed_webrtc
2016/11/29 15:43:49
nit: remove lonely semicolon.
nisse-webrtc
2016/11/30 11:26:03
Done.
| |
| 73 case kVideoCodecVP9: | 72 } |
| 74 return 0; | 73 |
| 75 case kVideoCodecH264: | 74 int64_t VideoFrame::render_time_ms() const { |
| 76 return kBufferPaddingBytesH264; | 75 return timestamp_us() / rtc::kNumMicrosecsPerMillisec; |
| 77 case kVideoCodecI420: | |
| 78 case kVideoCodecRED: | |
| 79 case kVideoCodecULPFEC: | |
| 80 case kVideoCodecFlexfec: | |
| 81 case kVideoCodecGeneric: | |
| 82 case kVideoCodecUnknown: | |
| 83 return 0; | |
| 84 } | |
| 85 RTC_NOTREACHED(); | |
| 86 return 0; | |
| 87 } | 76 } |
| 88 | 77 |
| 89 } // namespace webrtc | 78 } // namespace webrtc |
| OLD | NEW |