Use GetTemporalLayerSum

Bug: b/337757868
Change-Id: Ieff4c22425bab06c12419d64db7a2eef69cc54d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/355962
Auto-Submit: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42630}
diff --git a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
index 258d3d3..db92384 100644
--- a/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
+++ b/modules/video_coding/codecs/av1/libaom_av1_encoder.cc
@@ -818,16 +818,12 @@
   if (SvcEnabled()) {
     for (int sid = 0; sid < svc_params_->number_spatial_layers; ++sid) {
       // libaom bitrate for spatial id S and temporal id T means bitrate
-      // of frames with spatial_id=S and temporal_id<=T
-      // while `parameters.bitrate` provdies bitrate of frames with
-      // spatial_id=S and temporal_id=T
-      int accumulated_bitrate_bps = 0;
+      // of frames with spatial_id=S and temporal_id<=T.
       for (int tid = 0; tid < svc_params_->number_temporal_layers; ++tid) {
         int layer_index = sid * svc_params_->number_temporal_layers + tid;
-        accumulated_bitrate_bps += parameters.bitrate.GetBitrate(sid, tid);
         // `svc_params_->layer_target_bitrate` expects bitrate in kbps.
         svc_params_->layer_target_bitrate[layer_index] =
-            accumulated_bitrate_bps / 1000;
+            parameters.bitrate.GetTemporalLayerSum(sid, tid) / 1000;
       }
     }
     SetEncoderControlParameters(AV1E_SET_SVC_PARAMS, &*svc_params_);