Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

84 lines
2.1 KiB
C
Raw Normal View History

/*
* Copyright (c) 2011 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 MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
#define MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_
#include <vector>
#include "common_types.h" // NOLINT(build/include)
namespace webrtc {
namespace test {
// Statistics for one processed frame.
struct FrameStatistic {
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
explicit FrameStatistic(int frame_number) : frame_number(frame_number) {}
const int frame_number = 0;
// Encoding.
int64_t encode_start_ns = 0;
int encode_return_code = 0;
bool encoding_successful = false;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
int encode_time_us = 0;
int bitrate_kbps = 0;
size_t encoded_frame_size_bytes = 0;
webrtc::FrameType frame_type = kVideoFrameDelta;
// H264 specific.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
rtc::Optional<size_t> max_nalu_length;
// Decoding.
int64_t decode_start_ns = 0;
int decode_return_code = 0;
bool decoding_successful = false;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
int decode_time_us = 0;
int decoded_width = 0;
int decoded_height = 0;
// Quantization.
int qp = -1;
// How many packets were discarded of the encoded frame data (if any).
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
int packets_dropped = 0;
size_t total_packets = 0;
size_t manipulated_length = 0;
// Quality.
float psnr = 0.0;
float ssim = 0.0;
};
// Statistics for a sequence of processed frames. This class is not thread safe.
class Stats {
public:
Stats() = default;
~Stats() = default;
// Creates a FrameStatistic for the next frame to be processed.
FrameStatistic* AddFrame();
// Returns the FrameStatistic corresponding to |frame_number|.
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
FrameStatistic* GetFrame(int frame_number);
size_t size() const;
Revert "Updated analysis in videoprocessor." This reverts commit 1880c7162bd3637c433f9421c798808cd6eacaf7. Reason for revert: breaks internal tests Original change's description: > Updated analysis in videoprocessor. > > - Run analysis after all frames are processed. Before part of it was > done at bitrate change points; > - Analysis is done for whole stream as well as for each rate update > interval; > - Changed units from number of frames to time units for some metrics > and thresholds. E.g. 'num frames to hit tagret bitrate' is changed to > 'time to reach target bitrate, sec'; > - Changed data type of FrameStatistic::max_nalu_length (renamed to > max_nalu_size_bytes) from rtc::Optional to size_t. There it no need to > use such advanced data type in such low level data structure. > > Bug: webrtc:8524 > Change-Id: Ic9f6eab5b15ee12a80324b1f9c101de1bf3c702f > Reviewed-on: https://webrtc-review.googlesource.com/31901 > Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> > Reviewed-by: Stefan Holmer <stefan@webrtc.org> > Reviewed-by: Åsa Persson <asapersson@webrtc.org> > Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#21653} TBR=brandtr@webrtc.org,asapersson@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,ssilkin@webrtc.org Change-Id: Id0b7d387bbba02e71637b229aeed6f6cf012af46 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8524 Reviewed-on: https://webrtc-review.googlesource.com/40220 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Commit-Queue: Sergey Silkin <ssilkin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#21656}
2018-01-17 13:15:57 +00:00
// TODO(brandtr): Add output as CSV.
void PrintSummary() const;
private:
std::vector<FrameStatistic> stats_;
};
} // namespace test
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_TEST_STATS_H_