@@ -169,6 +169,7 @@ VideoBitrateAllocation UpdateAllocationFromEncoderInfo(
169169 new_allocation.set_bw_limited (allocation.is_bw_limited ());
170170 return new_allocation;
171171}
172+
172173} // namespace
173174
174175const int VideoStreamEncoder::kDefaultLastFrameInfoWidth = 176 ;
@@ -1360,6 +1361,37 @@ EncodedImageCallback::Result VideoStreamEncoder::OnEncodedImage(
13601361 RTC_CHECK (videocontenttypehelpers::SetSimulcastId (
13611362 &image_copy.content_type_ , static_cast <uint8_t >(spatial_idx + 1 )));
13621363
1364+ // Currently internal quality scaler is used for VP9 instead of webrtc qp
1365+ // scaler (in no-svc case or if only a single spatial layer is encoded).
1366+ // It has to be explicitly detected and reported to adaptation metrics.
1367+ // Post a task because |send_codec_| requires |encoder_queue_| lock.
1368+ unsigned int image_width = image_copy._encodedWidth ;
1369+ unsigned int image_height = image_copy._encodedHeight ;
1370+ VideoCodecType codec = codec_specific_info
1371+ ? codec_specific_info->codecType
1372+ : VideoCodecType::kVideoCodecGeneric ;
1373+ encoder_queue_.PostTask ([this , codec, image_width, image_height] {
1374+ RTC_DCHECK_RUN_ON (&encoder_queue_);
1375+ if (codec == VideoCodecType::kVideoCodecVP9 &&
1376+ send_codec_.VP9 ()->automaticResizeOn ) {
1377+ unsigned int expected_width = send_codec_.width ;
1378+ unsigned int expected_height = send_codec_.height ;
1379+ int num_active_layers = 0 ;
1380+ for (int i = 0 ; i < send_codec_.VP9 ()->numberOfSpatialLayers ; ++i) {
1381+ if (send_codec_.spatialLayers [i].active ) {
1382+ ++num_active_layers;
1383+ expected_width = send_codec_.spatialLayers [i].width ;
1384+ expected_height = send_codec_.spatialLayers [i].height ;
1385+ }
1386+ }
1387+ RTC_DCHECK_LE (num_active_layers, 1 )
1388+ << " VP9 quality scaling is enabled for "
1389+ " SVC with several active layers." ;
1390+ encoder_stats_observer_->OnEncoderInternalScalerUpdate (
1391+ image_width < expected_width || image_height < expected_height);
1392+ }
1393+ });
1394+
13631395 // Encoded is called on whatever thread the real encoder implementation run
13641396 // on. In the case of hardware encoders, there might be several encoders
13651397 // running in parallel on different threads.
0 commit comments