Files
platform-external-webrtc/webrtc/video_frame.h
kthelgason 0cd27ba088 Reland of Properly report number of quality downscales in stats. (patchset #1 id:1 of https://codereview.webrtc.org/2586783003/ )
Reason for revert:
Bug affecting perf tests has been fixed. The issue was that I had accidentally disabled cpu overuse adaptation based on the encoders ScalingSettings, not just quality-based scaling.

Original issue's description:
> Revert of Properly report number of quality downscales in stats. (patchset #11 id:220001 of https://codereview.webrtc.org/2564373002/ )
>
> Reason for revert:
> Breaks perf tests
>
> Original issue's description:
> > Properly report number of quality downscales in stats.
> >
> > A regression was introduced in 876222f that caused these stats to
> > be reported incorrectly. This used to be only implemented for VP8
> > but should now be available for all codecs.
> >
> > BUG=webrtc:6860
> >
> > Review-Url: https://codereview.webrtc.org/2564373002
> > Cr-Commit-Position: refs/heads/master@{#15673}
> > Committed: 0c8c538835
>
> TBR=asapersson@webrtc.org,stefan@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:6860
>
> Review-Url: https://codereview.webrtc.org/2586783003
> Cr-Commit-Position: refs/heads/master@{#15678}
> Committed: fe04bd43cc

TBR=asapersson@webrtc.org,stefan@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:6860

Review-Url: https://codereview.webrtc.org/2588743002
Cr-Commit-Position: refs/heads/master@{#15680}
2016-12-19 14:32:16 +00:00

170 lines
5.7 KiB
C++

/*
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_VIDEO_FRAME_H_
#define WEBRTC_VIDEO_FRAME_H_
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/include/video_frame_buffer.h"
#include "webrtc/common_video/rotation.h"
#include "webrtc/typedefs.h"
namespace webrtc {
class VideoFrame {
public:
// TODO(nisse): This constructor is consistent with
// cricket::WebRtcVideoFrame. After the class
// cricket::WebRtcVideoFrame and its baseclass cricket::VideoFrame
// are deleted, we should consider whether or not we want to stick
// to this style and deprecate the other constructors.
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
webrtc::VideoRotation rotation,
int64_t timestamp_us);
// Preferred constructor.
VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
uint32_t timestamp,
int64_t render_time_ms,
VideoRotation rotation);
// Support move and copy.
VideoFrame(const VideoFrame&) = default;
VideoFrame(VideoFrame&&) = default;
VideoFrame& operator=(const VideoFrame&) = default;
VideoFrame& operator=(VideoFrame&&) = default;
// Get frame width.
int width() const;
// Get frame height.
int height() const;
// System monotonic clock, same timebase as rtc::TimeMicros().
int64_t timestamp_us() const { return timestamp_us_; }
void set_timestamp_us(int64_t timestamp_us) {
timestamp_us_ = timestamp_us;
}
// TODO(nisse): After the cricket::VideoFrame and webrtc::VideoFrame
// merge, timestamps other than timestamp_us will likely be
// deprecated.
// Set frame timestamp (90kHz).
void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; }
// Get frame timestamp (90kHz).
uint32_t timestamp() const { return timestamp_rtp_; }
// For now, transport_frame_id and rtp timestamp are the same.
// TODO(nisse): Must be handled differently for QUIC.
uint32_t transport_frame_id() const { return timestamp(); }
// Set capture ntp time in milliseconds.
void set_ntp_time_ms(int64_t ntp_time_ms) {
ntp_time_ms_ = ntp_time_ms;
}
// Get capture ntp time in milliseconds.
int64_t ntp_time_ms() const { return ntp_time_ms_; }
// Naming convention for Coordination of Video Orientation. Please see
// http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf
//
// "pending rotation" or "pending" = a frame that has a VideoRotation > 0.
//
// "not pending" = a frame that has a VideoRotation == 0.
//
// "apply rotation" = modify a frame from being "pending" to being "not
// pending" rotation (a no-op for "unrotated").
//
VideoRotation rotation() const { return rotation_; }
void set_rotation(VideoRotation rotation) {
rotation_ = rotation;
}
// Set render time in milliseconds.
void set_render_time_ms(int64_t render_time_ms) {
set_timestamp_us(render_time_ms * rtc::kNumMicrosecsPerMillisec);;
}
// Get render time in milliseconds.
int64_t render_time_ms() const {
return timestamp_us() / rtc::kNumMicrosecsPerMillisec;
}
// Return the underlying buffer. Never nullptr for a properly
// initialized VideoFrame.
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer() const;
// Return true if the frame is stored in a texture.
bool is_texture() const {
return video_frame_buffer() &&
video_frame_buffer()->native_handle() != nullptr;
}
private:
// An opaque reference counted handle that stores the pixel data.
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
uint32_t timestamp_rtp_;
int64_t ntp_time_ms_;
int64_t timestamp_us_;
VideoRotation rotation_;
};
// TODO(pbos): Rename EncodedFrame and reformat this class' members.
class EncodedImage {
public:
static const size_t kBufferPaddingBytesH264;
// Some decoders require encoded image buffers to be padded with a small
// number of additional bytes (due to over-reading byte readers).
static size_t GetBufferPaddingBytes(VideoCodecType codec_type);
EncodedImage() : EncodedImage(nullptr, 0, 0) {}
EncodedImage(uint8_t* buffer, size_t length, size_t size)
: _buffer(buffer), _length(length), _size(size) {}
// TODO(kthelgason): get rid of this struct as it only has a single member
// remaining.
struct AdaptReason {
AdaptReason() : bw_resolutions_disabled(-1) {}
int bw_resolutions_disabled; // Number of resolutions that are not sent
// due to bandwidth for this frame.
// Or -1 if information is not provided.
};
uint32_t _encodedWidth = 0;
uint32_t _encodedHeight = 0;
uint32_t _timeStamp = 0;
// NTP time of the capture time in local timebase in milliseconds.
int64_t ntp_time_ms_ = 0;
int64_t capture_time_ms_ = 0;
FrameType _frameType = kVideoFrameDelta;
uint8_t* _buffer;
size_t _length;
size_t _size;
VideoRotation rotation_ = kVideoRotation_0;
bool _completeFrame = false;
AdaptReason adapt_reason_;
int qp_ = -1; // Quantizer value.
// When an application indicates non-zero values here, it is taken as an
// indication that all future frames will be constrained with those limits
// until the application indicates a change again.
PlayoutDelay playout_delay_ = {-1, -1};
};
} // namespace webrtc
#endif // WEBRTC_VIDEO_FRAME_H_