tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

videocodec_test_stats.cc (5161B)


      1 /*
      2 *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
      3 *
      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
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #include "api/test/videocodec_test_stats.h"
     12 
     13 #include <cstddef>
     14 #include <map>
     15 #include <string>
     16 
     17 #include "rtc_base/strings/string_builder.h"
     18 
     19 namespace webrtc {
     20 namespace test {
     21 
     22 VideoCodecTestStats::FrameStatistics::FrameStatistics(size_t frame_number,
     23                                                      size_t rtp_timestamp,
     24                                                      size_t spatial_idx)
     25    : frame_number(frame_number),
     26      rtp_timestamp(rtp_timestamp),
     27      spatial_idx(spatial_idx) {}
     28 
     29 std::string VideoCodecTestStats::FrameStatistics::ToString() const {
     30  StringBuilder ss;
     31  for (const auto& entry : ToMap()) {
     32    if (ss.size() > 0) {
     33      ss << " ";
     34    }
     35    ss << entry.first << " " << entry.second;
     36  }
     37  return ss.Release();
     38 }
     39 
     40 std::map<std::string, std::string> VideoCodecTestStats::FrameStatistics::ToMap()
     41    const {
     42  std::map<std::string, std::string> map;
     43  map["frame_number"] = std::to_string(frame_number);
     44  map["decoded_width"] = std::to_string(decoded_width);
     45  map["decoded_height"] = std::to_string(decoded_height);
     46  map["spatial_idx"] = std::to_string(spatial_idx);
     47  map["temporal_idx"] = std::to_string(temporal_idx);
     48  map["inter_layer_predicted"] = std::to_string(inter_layer_predicted);
     49  map["non_ref_for_inter_layer_pred"] =
     50      std::to_string(non_ref_for_inter_layer_pred);
     51  map["frame_type"] = std::to_string(static_cast<int>(frame_type));
     52  map["length_bytes"] = std::to_string(length_bytes);
     53  map["qp"] = std::to_string(qp);
     54  map["psnr"] = std::to_string(psnr);
     55  map["psnr_y"] = std::to_string(psnr_y);
     56  map["psnr_u"] = std::to_string(psnr_u);
     57  map["psnr_v"] = std::to_string(psnr_v);
     58  map["ssim"] = std::to_string(ssim);
     59  map["encode_time_us"] = std::to_string(encode_time_us);
     60  map["decode_time_us"] = std::to_string(decode_time_us);
     61  map["rtp_timestamp"] = std::to_string(rtp_timestamp);
     62  map["target_bitrate_kbps"] = std::to_string(target_bitrate_kbps);
     63  map["target_framerate_fps"] = std::to_string(target_framerate_fps);
     64  return map;
     65 }
     66 
     67 std::string VideoCodecTestStats::VideoStatistics::ToString(
     68    std::string prefix) const {
     69  StringBuilder ss;
     70  for (const auto& entry : ToMap()) {
     71    if (ss.size() > 0) {
     72      ss << "\n";
     73    }
     74    ss << prefix << entry.first << ": " << entry.second;
     75  }
     76  return ss.Release();
     77 }
     78 
     79 std::map<std::string, std::string> VideoCodecTestStats::VideoStatistics::ToMap()
     80    const {
     81  std::map<std::string, std::string> map;
     82  map["target_bitrate_kbps"] = std::to_string(target_bitrate_kbps);
     83  map["input_framerate_fps"] = std::to_string(input_framerate_fps);
     84  map["spatial_idx"] = std::to_string(spatial_idx);
     85  map["temporal_idx"] = std::to_string(temporal_idx);
     86  map["width"] = std::to_string(width);
     87  map["height"] = std::to_string(height);
     88  map["length_bytes"] = std::to_string(length_bytes);
     89  map["bitrate_kbps"] = std::to_string(bitrate_kbps);
     90  map["framerate_fps"] = std::to_string(framerate_fps);
     91  map["enc_speed_fps"] = std::to_string(enc_speed_fps);
     92  map["dec_speed_fps"] = std::to_string(dec_speed_fps);
     93  map["avg_encode_latency_sec"] = std::to_string(avg_encode_latency_sec);
     94  map["max_encode_latency_sec"] = std::to_string(max_encode_latency_sec);
     95  map["avg_decode_latency_sec"] = std::to_string(avg_decode_latency_sec);
     96  map["max_decode_latency_sec"] = std::to_string(max_decode_latency_sec);
     97  map["avg_delay_sec"] = std::to_string(avg_delay_sec);
     98  map["max_key_frame_delay_sec"] = std::to_string(max_key_frame_delay_sec);
     99  map["max_delta_frame_delay_sec"] = std::to_string(max_delta_frame_delay_sec);
    100  map["time_to_reach_target_bitrate_sec"] =
    101      std::to_string(time_to_reach_target_bitrate_sec);
    102  map["avg_bitrate_mismatch_pct"] = std::to_string(avg_bitrate_mismatch_pct);
    103  map["avg_framerate_mismatch_pct"] =
    104      std::to_string(avg_framerate_mismatch_pct);
    105  map["avg_key_frame_size_bytes"] = std::to_string(avg_key_frame_size_bytes);
    106  map["avg_delta_frame_size_bytes"] =
    107      std::to_string(avg_delta_frame_size_bytes);
    108  map["avg_qp"] = std::to_string(avg_qp);
    109  map["avg_psnr"] = std::to_string(avg_psnr);
    110  map["min_psnr"] = std::to_string(min_psnr);
    111  map["avg_ssim"] = std::to_string(avg_ssim);
    112  map["min_ssim"] = std::to_string(min_ssim);
    113  map["num_input_frames"] = std::to_string(num_input_frames);
    114  map["num_encoded_frames"] = std::to_string(num_encoded_frames);
    115  map["num_decoded_frames"] = std::to_string(num_decoded_frames);
    116  map["num_dropped_frames"] =
    117      std::to_string(num_input_frames - num_encoded_frames);
    118  map["num_key_frames"] = std::to_string(num_key_frames);
    119  map["num_spatial_resizes"] = std::to_string(num_spatial_resizes);
    120  map["max_nalu_size_bytes"] = std::to_string(max_nalu_size_bytes);
    121  return map;
    122 }
    123 
    124 }  // namespace test
    125 }  // namespace webrtc