| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // FFmpeg's decoder, used by H264DecoderImpl, requires up to 8 bytes padding due | 22 // FFmpeg's decoder, used by H264DecoderImpl, requires up to 8 bytes padding due |
| 23 // to optimized bitstream readers. See avcodec_decode_video2. | 23 // to optimized bitstream readers. See avcodec_decode_video2. |
| 24 const size_t EncodedImage::kBufferPaddingBytesH264 = 8; | 24 const size_t EncodedImage::kBufferPaddingBytesH264 = 8; |
| 25 | 25 |
| 26 int ExpectedSize(int plane_stride, int image_height, PlaneType type) { | 26 int ExpectedSize(int plane_stride, int image_height, PlaneType type) { |
| 27 if (type == kYPlane) | 27 if (type == kYPlane) |
| 28 return plane_stride * image_height; | 28 return plane_stride * image_height; |
| 29 return plane_stride * ((image_height + 1) / 2); | 29 return plane_stride * ((image_height + 1) / 2); |
| 30 } | 30 } |
| 31 | 31 |
| 32 VideoFrame::VideoFrame() { | 32 VideoFrame::VideoFrame() |
| 33 // Intentionally using Reset instead of initializer list so that any missed | 33 : video_frame_buffer_(nullptr), |
| 34 // fields in Reset will be caught by memory checkers. | 34 timestamp_(0), |
| 35 Reset(); | 35 ntp_time_ms_(0), |
| 36 } | 36 render_time_ms_(0), |
| 37 rotation_(kVideoRotation_0) {} |
| 37 | 38 |
| 38 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, | 39 VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer, |
| 39 uint32_t timestamp, | 40 uint32_t timestamp, |
| 40 int64_t render_time_ms, | 41 int64_t render_time_ms, |
| 41 VideoRotation rotation) | 42 VideoRotation rotation) |
| 42 : video_frame_buffer_(buffer), | 43 : video_frame_buffer_(buffer), |
| 43 timestamp_(timestamp), | 44 timestamp_(timestamp), |
| 44 ntp_time_ms_(0), | 45 ntp_time_ms_(0), |
| 45 render_time_ms_(render_time_ms), | 46 render_time_ms_(render_time_ms), |
| 46 rotation_(rotation) { | 47 rotation_(rotation) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 133 } |
| 133 | 134 |
| 134 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { | 135 void VideoFrame::ShallowCopy(const VideoFrame& videoFrame) { |
| 135 video_frame_buffer_ = videoFrame.video_frame_buffer(); | 136 video_frame_buffer_ = videoFrame.video_frame_buffer(); |
| 136 timestamp_ = videoFrame.timestamp_; | 137 timestamp_ = videoFrame.timestamp_; |
| 137 ntp_time_ms_ = videoFrame.ntp_time_ms_; | 138 ntp_time_ms_ = videoFrame.ntp_time_ms_; |
| 138 render_time_ms_ = videoFrame.render_time_ms_; | 139 render_time_ms_ = videoFrame.render_time_ms_; |
| 139 rotation_ = videoFrame.rotation_; | 140 rotation_ = videoFrame.rotation_; |
| 140 } | 141 } |
| 141 | 142 |
| 142 void VideoFrame::Reset() { | |
| 143 video_frame_buffer_ = nullptr; | |
| 144 timestamp_ = 0; | |
| 145 ntp_time_ms_ = 0; | |
| 146 render_time_ms_ = 0; | |
| 147 rotation_ = kVideoRotation_0; | |
| 148 } | |
| 149 | |
| 150 uint8_t* VideoFrame::buffer(PlaneType type) { | 143 uint8_t* VideoFrame::buffer(PlaneType type) { |
| 151 return video_frame_buffer_ ? video_frame_buffer_->MutableData(type) | 144 return video_frame_buffer_ ? video_frame_buffer_->MutableData(type) |
| 152 : nullptr; | 145 : nullptr; |
| 153 } | 146 } |
| 154 | 147 |
| 155 const uint8_t* VideoFrame::buffer(PlaneType type) const { | 148 const uint8_t* VideoFrame::buffer(PlaneType type) const { |
| 156 return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr; | 149 return video_frame_buffer_ ? video_frame_buffer_->data(type) : nullptr; |
| 157 } | 150 } |
| 158 | 151 |
| 159 int VideoFrame::allocated_size(PlaneType type) const { | 152 int VideoFrame::allocated_size(PlaneType type) const { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 case kVideoCodecULPFEC: | 203 case kVideoCodecULPFEC: |
| 211 case kVideoCodecGeneric: | 204 case kVideoCodecGeneric: |
| 212 case kVideoCodecUnknown: | 205 case kVideoCodecUnknown: |
| 213 return 0; | 206 return 0; |
| 214 } | 207 } |
| 215 RTC_NOTREACHED(); | 208 RTC_NOTREACHED(); |
| 216 return 0; | 209 return 0; |
| 217 } | 210 } |
| 218 | 211 |
| 219 } // namespace webrtc | 212 } // namespace webrtc |
| OLD | NEW |