2014-11-01 06:10:48 +00:00
|
|
|
/*
|
2020-12-09 20:58:21 +01:00
|
|
|
* Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
|
2014-11-01 06:10:48 +00:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-12-09 20:58:21 +01:00
|
|
|
#ifndef MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_ENCODER_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_ENCODER_H_
|
2015-12-21 03:04:49 -08:00
|
|
|
|
2018-11-19 09:52:37 +01:00
|
|
|
#ifdef RTC_ENABLE_VP9
|
|
|
|
|
|
2022-07-28 09:58:58 +02:00
|
|
|
#include <array>
|
2016-02-29 05:51:59 -08:00
|
|
|
#include <memory>
|
2015-12-21 03:04:49 -08:00
|
|
|
#include <vector>
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2019-06-28 15:19:43 +02:00
|
|
|
#include "api/fec_controller_override.h"
|
2022-03-29 11:04:48 +02:00
|
|
|
#include "api/field_trials_view.h"
|
2022-12-06 10:09:10 +00:00
|
|
|
#include "api/video_codecs/scalability_mode.h"
|
2019-06-11 14:57:57 +02:00
|
|
|
#include "api/video_codecs/video_encoder.h"
|
2021-04-19 09:09:26 +02:00
|
|
|
#include "api/video_codecs/vp9_profile.h"
|
2020-09-29 10:37:32 +02:00
|
|
|
#include "common_video/include/video_frame_buffer_pool.h"
|
2020-12-09 20:58:21 +01:00
|
|
|
#include "modules/video_coding/codecs/interface/libvpx_interface.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/codecs/vp9/include/vp9.h"
|
|
|
|
|
#include "modules/video_coding/codecs/vp9/vp9_frame_buffer_pool.h"
|
2020-10-15 17:26:46 +02:00
|
|
|
#include "modules/video_coding/svc/scalable_video_controller.h"
|
2021-08-16 09:33:13 +02:00
|
|
|
#include "modules/video_coding/utility/framerate_controller_deprecated.h"
|
2022-04-06 16:44:30 +02:00
|
|
|
#include "rtc_base/containers/flat_map.h"
|
2021-02-01 09:20:05 +01:00
|
|
|
#include "rtc_base/experiments/encoder_info_settings.h"
|
2017-01-26 13:23:44 -08:00
|
|
|
#include "vpx/vp8cx.h"
|
2014-11-01 06:10:48 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2020-12-09 20:58:21 +01:00
|
|
|
class LibvpxVp9Encoder : public VP9Encoder {
|
2014-11-01 06:10:48 +00:00
|
|
|
public:
|
2020-12-09 20:58:21 +01:00
|
|
|
LibvpxVp9Encoder(const cricket::VideoCodec& codec,
|
|
|
|
|
std::unique_ptr<LibvpxInterface> interface,
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& trials);
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2020-12-09 20:58:21 +01:00
|
|
|
~LibvpxVp9Encoder() override;
|
2019-06-28 15:19:43 +02:00
|
|
|
|
|
|
|
|
void SetFecControllerOverride(
|
|
|
|
|
FecControllerOverride* fec_controller_override) override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int Release() override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int InitEncode(const VideoCodec* codec_settings,
|
2019-06-11 14:57:57 +02:00
|
|
|
const Settings& settings) override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2015-05-29 17:21:40 -07:00
|
|
|
int Encode(const VideoFrame& input_image,
|
2019-03-07 10:18:23 +01:00
|
|
|
const std::vector<VideoFrameType>* frame_types) override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
int RegisterEncodeCompleteCallback(EncodedImageCallback* callback) override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2019-04-12 13:59:09 +02:00
|
|
|
void SetRates(const RateControlParameters& parameters) override;
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2018-11-07 16:54:15 +01:00
|
|
|
EncoderInfo GetEncoderInfo() const override;
|
2015-12-18 16:01:11 +01:00
|
|
|
|
2014-11-01 06:10:48 +00:00
|
|
|
private:
|
2015-01-26 15:21:36 +00:00
|
|
|
// Determine number of encoder threads to use.
|
|
|
|
|
int NumberOfThreads(int width, int height, int number_of_cores);
|
|
|
|
|
|
2014-11-01 06:10:48 +00:00
|
|
|
// Call encoder initialize function and set control settings.
|
|
|
|
|
int InitAndSetControlSettings(const VideoCodec* inst);
|
|
|
|
|
|
2021-02-03 12:33:17 +01:00
|
|
|
bool PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
|
2018-08-27 15:33:42 +02:00
|
|
|
absl::optional<int>* spatial_idx,
|
2022-04-25 17:28:00 +02:00
|
|
|
absl::optional<int>* temporal_idx,
|
2022-01-19 14:17:14 +01:00
|
|
|
const vpx_codec_cx_pkt& pkt);
|
2018-05-28 12:26:36 +02:00
|
|
|
void FillReferenceIndices(const vpx_codec_cx_pkt& pkt,
|
2022-01-25 13:27:19 +01:00
|
|
|
size_t pic_num,
|
|
|
|
|
bool inter_layer_predicted,
|
2018-05-28 12:26:36 +02:00
|
|
|
CodecSpecificInfoVP9* vp9_info);
|
2022-01-25 13:27:19 +01:00
|
|
|
void UpdateReferenceBuffers(const vpx_codec_cx_pkt& pkt, size_t pic_num);
|
2022-07-28 09:58:58 +02:00
|
|
|
vpx_svc_ref_frame_config_t SetReferences(bool is_key_pic,
|
|
|
|
|
int first_active_spatial_layer_id);
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2015-11-02 07:23:20 -08:00
|
|
|
bool ExplicitlyConfiguredSpatialLayers() const;
|
2018-04-23 12:32:22 +02:00
|
|
|
bool SetSvcRates(const VideoBitrateAllocation& bitrate_allocation);
|
2015-07-31 06:10:09 -07:00
|
|
|
|
2021-09-10 12:30:09 +02:00
|
|
|
// Configures which spatial layers libvpx should encode according to
|
|
|
|
|
// configuration provided by svc_controller_.
|
|
|
|
|
void EnableSpatialLayer(int sid);
|
|
|
|
|
void DisableSpatialLayer(int sid);
|
|
|
|
|
void SetActiveSpatialLayers();
|
|
|
|
|
|
2021-02-03 12:33:17 +01:00
|
|
|
void GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt);
|
2015-07-31 06:10:09 -07:00
|
|
|
|
|
|
|
|
// Callback function for outputting packets per spatial layer.
|
|
|
|
|
static void EncoderOutputCodedPacketCallback(vpx_codec_cx_pkt* pkt,
|
|
|
|
|
void* user_data);
|
2014-11-01 06:10:48 +00:00
|
|
|
|
2018-04-24 21:29:14 +02:00
|
|
|
void DeliverBufferedFrame(bool end_of_picture);
|
2018-04-04 11:45:41 +02:00
|
|
|
|
2018-08-29 01:05:26 +02:00
|
|
|
bool DropFrame(uint8_t spatial_idx, uint32_t rtp_timestamp);
|
2018-05-17 16:46:43 +02:00
|
|
|
|
2014-11-01 06:10:48 +00:00
|
|
|
// Determine maximum target for Intra frames
|
|
|
|
|
//
|
|
|
|
|
// Input:
|
|
|
|
|
// - optimal_buffer_size : Optimal buffer size
|
|
|
|
|
// Return Value : Max target size for Intra frames represented as
|
|
|
|
|
// percentage of the per frame bandwidth
|
|
|
|
|
uint32_t MaxIntraTarget(uint32_t optimal_buffer_size);
|
|
|
|
|
|
2019-03-06 16:04:32 +01:00
|
|
|
size_t SteadyStateSize(int sid, int tid);
|
|
|
|
|
|
2022-01-25 13:27:19 +01:00
|
|
|
void MaybeRewrapRawWithFormat(vpx_img_fmt fmt);
|
2021-08-09 13:02:57 +02:00
|
|
|
// Prepares `raw_` to reference image data of `buffer`, or of mapped or scaled
|
|
|
|
|
// versions of `buffer`. Returns the buffer that got referenced as a result,
|
Support native scaling of VideoFrameBuffers in LibvpxVp9Encoder.
This CL is part of Optimized Scaling efforts. In Chromium, the native
frame buffer is getting an optimized CropAndScale() implementation. To
support HW accelerated scaling, returning pre-scaled images and skipping
unnecessary intermediate downscales, WebRTC needs to 1) use CropAndScale
instead of libyuv::XXXXScale and 2) only map buffers it actually intends
to encode.
- To achieve this, WebRTC encoders are updated to map kNative video
buffers so that in a follow-up CL VideoStreamEncoder can stop mapping
intermediate buffer sizes.
In this CL LibvpxVp9Encoder is updated to map kNative buffers of pixel
formats it supports and convert ToI420() if the kNative buffer is
something else. A fake native buffer that keeps track of which
resolutions were mapped, MappableNativeBuffer, is added.
Because VP9 is currently an SVC encoder and not a simulcast encoder, it
does not need to invoke CropAndScale.
This CL also fixes MultiplexEncoderAdapter, but because it simply
forwards frames it only cares about the pixel format when
|supports_augmented_data_| is true so this is the only time we map it.
Because this encoder is not used with kNative in practise, we don't care
to make this path optimal.
Bug: webrtc:12469, chromium:1157072
Change-Id: I74edf85b18eccd0d250776bbade7a6444478efce
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/212580
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#33526}
2021-03-22 12:24:30 +01:00
|
|
|
// allowing the caller to keep a reference to it until after encoding has
|
|
|
|
|
// finished. On failure to convert the buffer, null is returned.
|
|
|
|
|
rtc::scoped_refptr<VideoFrameBuffer> PrepareBufferForProfile0(
|
|
|
|
|
rtc::scoped_refptr<VideoFrameBuffer> buffer);
|
2020-09-28 12:04:11 +02:00
|
|
|
|
2020-12-09 20:58:21 +01:00
|
|
|
const std::unique_ptr<LibvpxInterface> libvpx_;
|
2014-11-01 06:10:48 +00:00
|
|
|
EncodedImage encoded_image_;
|
2018-04-04 11:45:41 +02:00
|
|
|
CodecSpecificInfo codec_specific_;
|
2014-11-01 06:10:48 +00:00
|
|
|
EncodedImageCallback* encoded_complete_callback_;
|
|
|
|
|
VideoCodec codec_;
|
2018-06-28 10:59:02 -07:00
|
|
|
const VP9Profile profile_;
|
2014-11-01 06:10:48 +00:00
|
|
|
bool inited_;
|
|
|
|
|
int64_t timestamp_;
|
|
|
|
|
uint32_t rc_max_intra_target_;
|
|
|
|
|
vpx_codec_ctx_t* encoder_;
|
|
|
|
|
vpx_codec_enc_cfg_t* config_;
|
|
|
|
|
vpx_image_t* raw_;
|
2017-01-26 13:23:44 -08:00
|
|
|
vpx_svc_extra_cfg_t svc_params_;
|
2015-07-31 06:10:09 -07:00
|
|
|
const VideoFrame* input_image_;
|
2018-05-28 12:26:36 +02:00
|
|
|
GofInfoVP9 gof_; // Contains each frame's temporal information for
|
|
|
|
|
// non-flexible mode.
|
2018-05-03 14:14:09 +02:00
|
|
|
bool force_key_frame_;
|
2018-04-26 11:03:49 +02:00
|
|
|
size_t pics_since_key_;
|
2015-07-31 06:10:09 -07:00
|
|
|
uint8_t num_temporal_layers_;
|
2018-06-21 11:07:21 -05:00
|
|
|
uint8_t num_spatial_layers_; // Number of configured SLs
|
|
|
|
|
uint8_t num_active_spatial_layers_; // Number of actively encoded SLs
|
2019-09-25 09:10:33 +00:00
|
|
|
uint8_t first_active_layer_;
|
2018-10-03 18:04:57 +02:00
|
|
|
bool layer_deactivation_requires_key_frame_;
|
2018-05-28 12:26:36 +02:00
|
|
|
bool is_svc_;
|
2018-04-26 11:03:49 +02:00
|
|
|
InterLayerPredMode inter_layer_pred_;
|
2018-10-01 17:13:50 +02:00
|
|
|
bool external_ref_control_;
|
2018-11-08 16:56:43 +01:00
|
|
|
const bool trusted_rate_controller_;
|
2019-05-24 16:50:00 +02:00
|
|
|
vpx_svc_frame_drop_t svc_drop_frame_;
|
2018-11-23 13:59:24 +01:00
|
|
|
bool first_frame_in_picture_;
|
2018-12-04 15:54:52 +01:00
|
|
|
VideoBitrateAllocation current_bitrate_allocation_;
|
|
|
|
|
bool ss_info_needed_;
|
2019-09-25 09:10:33 +00:00
|
|
|
bool force_all_active_layers_;
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
|
2020-10-15 17:26:46 +02:00
|
|
|
std::unique_ptr<ScalableVideoController> svc_controller_;
|
2022-12-06 10:09:10 +00:00
|
|
|
absl::optional<ScalabilityMode> scalability_mode_;
|
2021-08-16 09:33:13 +02:00
|
|
|
std::vector<FramerateControllerDeprecated> framerate_controller_;
|
2018-05-18 17:31:19 +02:00
|
|
|
|
Reland of Work on flexible mode and screen sharing. (patchset #1 id:1 of https://codereview.webrtc.org/1438543002/ )
Reason for revert:
Failed test not related to this CL (test fails on
master at an earlier date), re-landing original CL..
(This time from my @webrtc account.)
Original issue's description:
> Revert of Work on flexible mode and screen sharing. (patchset #28 id:520001 of https://codereview.webrtc.org/1328113004/ )
>
> Reason for revert:
> Seems to break VideoSendStreamTest.ReconfigureBitratesSetsEncoderBitratesCorrectly on Linux Memcheck buildbot.
>
> Original issue's description:
> > Work on flexible mode and screen sharing.
> >
> > Implement VP8 style screensharing but with spatial layers.
> > Implement flexible mode.
> >
> > Files from other patches:
> > generic_encoder.cc
> > layer_filtering_transport.cc
> >
> > BUG=webrtc:4914
> >
> > Committed: https://crrev.com/77ccfb4d16c148e61a316746bb5d9705e8b39f4a
> > Cr-Commit-Position: refs/heads/master@{#10572}
>
> TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,philipel@webrtc.org
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:4914
>
> Committed: https://crrev.com/0be8f1d347bdb171462df89c2a4c69b3f3eb7519
> Cr-Commit-Position: refs/heads/master@{#10578}
TBR=sprang@webrtc.org,stefan@webrtc.org,philipel@google.com,asapersson@webrtc.org,mflodman@webrtc.org,terelius@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4914
Review URL: https://codereview.webrtc.org/1431283002
Cr-Commit-Position: refs/heads/master@{#10581}
2015-11-10 07:17:23 -08:00
|
|
|
// Used for flexible mode.
|
|
|
|
|
bool is_flexible_mode_;
|
2018-05-28 12:26:36 +02:00
|
|
|
struct RefFrameBuffer {
|
2018-08-27 14:54:20 +02:00
|
|
|
bool operator==(const RefFrameBuffer& o) {
|
|
|
|
|
return pic_num == o.pic_num && spatial_layer_id == o.spatial_layer_id &&
|
|
|
|
|
temporal_layer_id == o.temporal_layer_id;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-28 12:26:36 +02:00
|
|
|
size_t pic_num = 0;
|
2022-07-28 09:58:58 +02:00
|
|
|
int spatial_layer_id = 0;
|
|
|
|
|
int temporal_layer_id = 0;
|
2018-05-28 12:26:36 +02:00
|
|
|
};
|
2022-07-28 09:58:58 +02:00
|
|
|
std::array<RefFrameBuffer, kNumVp9Buffers> ref_buf_;
|
2020-10-15 17:26:46 +02:00
|
|
|
std::vector<ScalableVideoController::LayerFrameConfig> layer_frames_;
|
2019-03-06 16:04:32 +01:00
|
|
|
|
|
|
|
|
// Variable frame-rate related fields and methods.
|
|
|
|
|
const struct VariableFramerateExperiment {
|
|
|
|
|
bool enabled;
|
|
|
|
|
// Framerate is limited to this value in steady state.
|
|
|
|
|
float framerate_limit;
|
|
|
|
|
// This qp or below is considered a steady state.
|
|
|
|
|
int steady_state_qp;
|
|
|
|
|
// Frames of at least this percentage below ideal for configured bitrate are
|
|
|
|
|
// considered in a steady state.
|
|
|
|
|
int steady_state_undershoot_percentage;
|
|
|
|
|
// Number of consecutive frames with good QP and size required to detect
|
|
|
|
|
// the steady state.
|
|
|
|
|
int frames_before_steady_state;
|
|
|
|
|
} variable_framerate_experiment_;
|
|
|
|
|
static VariableFramerateExperiment ParseVariableFramerateConfig(
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& trials);
|
2021-08-16 09:33:13 +02:00
|
|
|
FramerateControllerDeprecated variable_framerate_controller_;
|
2020-06-18 19:16:53 +02:00
|
|
|
|
|
|
|
|
const struct QualityScalerExperiment {
|
|
|
|
|
int low_qp;
|
|
|
|
|
int high_qp;
|
|
|
|
|
bool enabled;
|
|
|
|
|
} quality_scaler_experiment_;
|
|
|
|
|
static QualityScalerExperiment ParseQualityScalerConfig(
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& trials);
|
2020-10-01 19:13:13 +02:00
|
|
|
const bool external_ref_ctrl_;
|
|
|
|
|
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
// Flags that can affect speed vs quality tradeoff, and are configureable per
|
|
|
|
|
// resolution ranges.
|
|
|
|
|
struct PerformanceFlags {
|
2021-08-09 13:02:57 +02:00
|
|
|
// If false, a lookup will be made in `settings_by_resolution` base on the
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
// highest currently active resolution, and the overall speed then set to
|
2021-08-09 13:02:57 +02:00
|
|
|
// to the `base_layer_speed` matching that entry.
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
// If true, each active resolution will have it's speed and deblock_mode set
|
|
|
|
|
// based on it resolution, and the high layer speed configured for non
|
|
|
|
|
// base temporal layer frames.
|
|
|
|
|
bool use_per_layer_speed = false;
|
|
|
|
|
|
|
|
|
|
struct ParameterSet {
|
|
|
|
|
int base_layer_speed = -1; // Speed setting for TL0.
|
|
|
|
|
int high_layer_speed = -1; // Speed setting for TL1-TL3.
|
|
|
|
|
// 0 = deblock all temporal layers (TL)
|
|
|
|
|
// 1 = disable deblock for top-most TL
|
|
|
|
|
// 2 = disable deblock for all TLs
|
|
|
|
|
int deblock_mode = 0;
|
2022-03-31 16:11:15 +02:00
|
|
|
bool allow_denoising = true;
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
};
|
|
|
|
|
// Map from min pixel count to settings for that resolution and above.
|
|
|
|
|
// E.g. if you want some settings A if below wvga (640x360) and some other
|
|
|
|
|
// setting B at wvga and above, you'd use map {{0, A}, {230400, B}}.
|
2022-04-06 16:44:30 +02:00
|
|
|
flat_map<int, ParameterSet> settings_by_resolution;
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
};
|
2021-08-09 13:02:57 +02:00
|
|
|
// Performance flags, ordered by `min_pixel_count`.
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
const PerformanceFlags performance_flags_;
|
2021-08-09 13:02:57 +02:00
|
|
|
// Caching of of `speed_configs_`, where index i maps to the resolution as
|
2021-08-10 01:22:31 +02:00
|
|
|
// specified in `codec_.spatialLayer[i]`.
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
std::vector<PerformanceFlags::ParameterSet>
|
|
|
|
|
performance_flags_by_spatial_index_;
|
|
|
|
|
void UpdatePerformanceFlags();
|
|
|
|
|
static PerformanceFlags ParsePerformanceFlagsFromTrials(
|
2022-03-29 11:04:48 +02:00
|
|
|
const FieldTrialsView& trials);
|
Reland "Adds experimental libvpx VP9 speed settings."
This is a reland of 6e7167456b5eba36c7985d6a74f1d191958d4e0f
Patch set 1 is the original.
Later patch sets fix a parsing bug, and adds a new flag which enables
or disabled the ability to set separate per spatial layer speed
(use_per_layer_speed).
Original change's description:
> Adds experimental libvpx VP9 speed settings.
>
> Using the field trial WebRTC-VP9-PerformanceFlags, this CL allows you to
> configure the libvpx VP9 encoder with a list of flags to affect the
> quality vs speed tradeoff. This CL adds support for:
>
> * Speed (effort), for the temporal base layer frames
> * Speed for higher (non-base) layer frames
> * De-blocking (as part of the loopfilter) enabled for:
> 0 = all frames
> 1 = all but frames from the highest temporal layer
> 2 = no frames
>
> Each entry in the list has a threshold in min number of pixels needed
> for settings in the entry to apply.
>
> Example: Two spatial layers (180p, 360p) with three temporal
> layers are configured. Field trial "WebRTC-VP9-PerformanceFlags" set to:
> "use_per_layer_speed,min_pixel_count:0|129600,base_layer_speed:5|7,high_layer_speed:8|8,deblock_mode:1|2"
> This translates to:
> S0:
> - TL0: Speed 5, deblocked
> - TL1: Speed 8, deblocked
> - TL2: Speed 8, not deblocked
> S1:
> - TL0: Speed 7, not deblocked
> - TL1: Speed 8, not deblocked
> - TL2: Speed 8, not deblocked
>
> Bug: webrtc:11551
> Change-Id: Ieef6816d3e0831ff53348ecc4a90260e2ef10422
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188461
> Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
> Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
> Commit-Queue: Erik Språng <sprang@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32749}
Bug: webrtc:11551
Change-Id: Ie7c703eb122197235d8ce77cb72db7a347382468
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/196345
Reviewed-by: Michael Horowitz <mhoro@webrtc.org>
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32780}
2020-12-04 14:04:10 +01:00
|
|
|
static PerformanceFlags GetDefaultPerformanceFlags();
|
2020-06-18 19:16:53 +02:00
|
|
|
|
2019-03-06 16:04:32 +01:00
|
|
|
int num_steady_state_frames_;
|
2020-02-21 10:47:10 -08:00
|
|
|
// Only set config when this flag is set.
|
|
|
|
|
bool config_changed_;
|
2021-02-01 09:20:05 +01:00
|
|
|
|
|
|
|
|
const LibvpxVp9EncoderInfoSettings encoder_info_override_;
|
2014-11-01 06:10:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2018-11-19 09:52:37 +01:00
|
|
|
#endif // RTC_ENABLE_VP9
|
|
|
|
|
|
2020-12-09 20:58:21 +01:00
|
|
|
#endif // MODULES_VIDEO_CODING_CODECS_VP9_LIBVPX_VP9_ENCODER_H_
|