diff options
author | Jerome Jiang <jianj@google.com> | 2021-08-31 10:22:22 -0700 |
---|---|---|
committer | Jerome Jiang <jianj@google.com> | 2021-09-10 10:46:26 -0700 |
commit | 65a1751e5b98bf7f1d21bcbfdef352af34fb205d (patch) | |
tree | aea196d324f1f5c09861f015bbfa08da2773e672 /vp8/vp8_ratectrl_rtc.h | |
parent | ca40ca9bed87687eb0b534bf3974c95182dd29a1 (diff) | |
download | libvpx-65a1751e5b98bf7f1d21bcbfdef352af34fb205d.tar libvpx-65a1751e5b98bf7f1d21bcbfdef352af34fb205d.tar.gz libvpx-65a1751e5b98bf7f1d21bcbfdef352af34fb205d.tar.bz2 libvpx-65a1751e5b98bf7f1d21bcbfdef352af34fb205d.zip |
Add vp8 support to rc lib
For 1 layer CBR only.
Support for temporal layers comes later.
Rename the library to libvpxrc
Bug: b/188853141
Change-Id: Ib7f977b64c05b1a0596870cb7f8e6768cb483850
Diffstat (limited to 'vp8/vp8_ratectrl_rtc.h')
-rw-r--r-- | vp8/vp8_ratectrl_rtc.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/vp8/vp8_ratectrl_rtc.h b/vp8/vp8_ratectrl_rtc.h new file mode 100644 index 000000000..a1cd52b05 --- /dev/null +++ b/vp8/vp8_ratectrl_rtc.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2021 The WebM project authors. All Rights Reserved. + * + * 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. + */ + +#ifndef VPX_VP8_RATECTRL_RTC_H_ +#define VPX_VP8_RATECTRL_RTC_H_ + +#include <cstdint> +#include <memory> + +#include "vp8/encoder/onyx_int.h" +#include "vp8/common/common.h" +#include "vpx/internal/vpx_ratectrl_rtc.h" + +namespace libvpx { +struct VP8RateControlRtcConfig : public VpxRateControlRtcConfig { + public: + VP8RateControlRtcConfig() { + vp8_zero(layer_target_bitrate); + vp8_zero(ts_rate_decimator); + } +}; + +struct VP8FrameParamsQpRTC { + FRAME_TYPE frame_type; +}; + +class VP8RateControlRTC { + public: + static std::unique_ptr<VP8RateControlRTC> Create( + const VP8RateControlRtcConfig &cfg); + ~VP8RateControlRTC() { + if (cpi_) { + vpx_free(cpi_->gf_active_flags); + vpx_free(cpi_); + } + } + + void UpdateRateControl(const VP8RateControlRtcConfig &rc_cfg); + // GetQP() needs to be called after ComputeQP() to get the latest QP + int GetQP() const; + // int GetLoopfilterLevel() const; + void ComputeQP(const VP8FrameParamsQpRTC &frame_params); + // Feedback to rate control with the size of current encoded frame + void PostEncodeUpdate(uint64_t encoded_frame_size); + + private: + VP8RateControlRTC() {} + void InitRateControl(const VP8RateControlRtcConfig &cfg); + VP8_COMP *cpi_; + int q_; +}; + +} // namespace libvpx + +#endif // VPX_VP8_RATECTRL_RTC_H_ |