From 8bfec7c5bca2823ee9a0aaa92981a466fcd31698 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Thu, 8 Sep 2022 16:33:34 +0200 Subject: [PATCH] Speed up per frame debug log in vp9 encoder wrapper For the linked test case that speeds up chromium fuzzer by ~13% Run time decrease from ~50 seconds to ~44 seconds Bug: chromium:1357929 Change-Id: I702edf4fda7afd31a5288621220dac063f764ced Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/274601 Reviewed-by: Philip Eliasson Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#38038} --- .../codecs/vp9/libvpx_vp9_encoder.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc index add3d5501e..4c27f4ce22 100644 --- a/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc +++ b/modules/video_coding/codecs/vp9/libvpx_vp9_encoder.cc @@ -1462,7 +1462,9 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt, vpx_svc_ref_frame_config_t enc_layer_conf = {{0}}; libvpx_->codec_control(encoder_, VP9E_GET_SVC_REF_FRAME_CONFIG, &enc_layer_conf); - int ref_buf_flags = 0; + char ref_buf_flags[] = "00000000"; + // There should be one character per buffer + 1 termination '\0'. + static_assert(sizeof(ref_buf_flags) == kNumVp9Buffers + 1); if (enc_layer_conf.reference_last[layer_id.spatial_layer_id]) { const size_t fb_idx = @@ -1471,7 +1473,7 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt, if (std::find(ref_buf_list.begin(), ref_buf_list.end(), ref_buf_[fb_idx]) == ref_buf_list.end()) { ref_buf_list.push_back(ref_buf_[fb_idx]); - ref_buf_flags |= 1 << fb_idx; + ref_buf_flags[fb_idx] = '1'; } } @@ -1482,7 +1484,7 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt, if (std::find(ref_buf_list.begin(), ref_buf_list.end(), ref_buf_[fb_idx]) == ref_buf_list.end()) { ref_buf_list.push_back(ref_buf_[fb_idx]); - ref_buf_flags |= 1 << fb_idx; + ref_buf_flags[fb_idx] = '1'; } } @@ -1493,21 +1495,14 @@ void LibvpxVp9Encoder::FillReferenceIndices(const vpx_codec_cx_pkt& pkt, if (std::find(ref_buf_list.begin(), ref_buf_list.end(), ref_buf_[fb_idx]) == ref_buf_list.end()) { ref_buf_list.push_back(ref_buf_[fb_idx]); - ref_buf_flags |= 1 << fb_idx; + ref_buf_flags[fb_idx] = '1'; } } RTC_LOG(LS_VERBOSE) << "Frame " << pic_num << " sl " << layer_id.spatial_layer_id << " tl " << layer_id.temporal_layer_id << " refered buffers " - << (ref_buf_flags & (1 << 0) ? 1 : 0) - << (ref_buf_flags & (1 << 1) ? 1 : 0) - << (ref_buf_flags & (1 << 2) ? 1 : 0) - << (ref_buf_flags & (1 << 3) ? 1 : 0) - << (ref_buf_flags & (1 << 4) ? 1 : 0) - << (ref_buf_flags & (1 << 5) ? 1 : 0) - << (ref_buf_flags & (1 << 6) ? 1 : 0) - << (ref_buf_flags & (1 << 7) ? 1 : 0); + << ref_buf_flags; } else if (!is_key_frame) { RTC_DCHECK_EQ(num_spatial_layers_, 1);