xref: /aosp_15_r20/external/libvpx/vpx/internal/vpx_ratectrl_rtc.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2021 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VPX_VPX_INTERNAL_VPX_RATECTRL_RTC_H_
12 #define VPX_VPX_INTERNAL_VPX_RATECTRL_RTC_H_
13 
14 #include "vpx/vpx_encoder.h"
15 
16 namespace libvpx {
17 
18 enum class RcFrameType { kKeyFrame = 0, kInterFrame = 1 };
19 
20 enum class FrameDropDecision {
21   kOk,    // Frame is encoded.
22   kDrop,  // Frame is dropped.
23 };
24 
25 struct UVDeltaQP {
26   // For the UV channel: the QP for the dc/ac value is given as
27   // GetQP() + uvdc/ac_delta_q, where the uvdc/ac_delta_q are negative numbers.
28   int uvdc_delta_q;
29   int uvac_delta_q;
30 };
31 
32 struct VpxRateControlRtcConfig {
VpxRateControlRtcConfigVpxRateControlRtcConfig33   VpxRateControlRtcConfig() {
34     width = 1280;
35     height = 720;
36     max_quantizer = 63;
37     min_quantizer = 2;
38     target_bandwidth = 1000;
39     buf_initial_sz = 600;
40     buf_optimal_sz = 600;
41     buf_sz = 1000;
42     undershoot_pct = overshoot_pct = 50;
43     max_intra_bitrate_pct = 50;
44     max_inter_bitrate_pct = 0;
45     framerate = 30.0;
46     ts_number_layers = 1;
47     rc_mode = VPX_CBR;
48     aq_mode = 0;
49     layer_target_bitrate[0] = static_cast<int>(target_bandwidth);
50     ts_rate_decimator[0] = 1;
51     frame_drop_thresh = 0;
52     is_screen = false;
53   }
54 
55   int width;
56   int height;
57   // 0-63
58   int max_quantizer;
59   int min_quantizer;
60   int64_t target_bandwidth;
61   int64_t buf_initial_sz;
62   int64_t buf_optimal_sz;
63   int64_t buf_sz;
64   int undershoot_pct;
65   int overshoot_pct;
66   int max_intra_bitrate_pct;
67   int max_inter_bitrate_pct;
68   double framerate;
69   // Number of temporal layers
70   int ts_number_layers;
71   int layer_target_bitrate[VPX_MAX_LAYERS];
72   int ts_rate_decimator[VPX_TS_MAX_LAYERS];
73   // vbr, cbr
74   enum vpx_rc_mode rc_mode;
75   int aq_mode;
76   int frame_drop_thresh;
77   bool is_screen;
78 };
79 }  // namespace libvpx
80 #endif  // VPX_VPX_INTERNAL_VPX_RATECTRL_RTC_H_
81