• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 The WebRTC 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 WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_
12 #define WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_
13 
14 /***************************************************************
15 *QMSelectData.h
16 * This file includes parameters for content-aware media optimization
17 ****************************************************************/
18 
19 #include "webrtc/typedefs.h"
20 
21 namespace webrtc {
22 //
23 // PARAMETERS FOR RESOLUTION ADAPTATION
24 //
25 
26 // Initial level of buffer in secs.
27 const float kInitBufferLevel = 0.5f;
28 
29 // Threshold of (max) buffer size below which we consider too low (underflow).
30 const float kPercBufferThr = 0.10f;
31 
32 // Threshold on the occurrences of low buffer levels.
33 const float kMaxBufferLow = 0.30f;
34 
35 // Threshold on rate mismatch.
36 const float kMaxRateMisMatch = 0.5f;
37 
38 // Threshold on amount of under/over encoder shooting.
39 const float kRateOverShoot = 0.75f;
40 const float kRateUnderShoot = 0.75f;
41 
42 // Factor to favor weighting the average rates with the current/last data.
43 const float kWeightRate = 0.70f;
44 
45 // Factor for transitional rate for going back up in resolution.
46 const float kTransRateScaleUpSpatial = 1.25f;
47 const float kTransRateScaleUpTemp = 1.25f;
48 const float kTransRateScaleUpSpatialTemp = 1.25f;
49 
50 // Threshold on packet loss rate, above which favor resolution reduction.
51 const float kPacketLossThr = 0.1f;
52 
53 // Factor for reducing transitional bitrate under packet loss.
54 const float kPacketLossRateFac = 1.0f;
55 
56 // Maximum possible transitional rate for down-sampling:
57 // (units in kbps), for 30fps.
58 const uint16_t kMaxRateQm[9] = {
59     0,     // QCIF
60     50,    // kHCIF
61     125,   // kQVGA
62     200,   // CIF
63     280,   // HVGA
64     400,   // VGA
65     700,   // QFULLHD
66     1000,  // WHD
67     1500   // FULLHD
68 };
69 
70 // Frame rate scale for maximum transition rate.
71 const float kFrameRateFac[4] = {
72     0.5f,   // Low
73     0.7f,   // Middle level 1
74     0.85f,  // Middle level 2
75     1.0f,   // High
76 };
77 
78 // Scale for transitional rate: based on content class
79 // motion=L/H/D,spatial==L/H/D: for low, high, middle levels
80 const float kScaleTransRateQm[18] = {
81     // VGA and lower
82     0.40f,  // L, L
83     0.50f,  // L, H
84     0.40f,  // L, D
85     0.60f,  // H ,L
86     0.60f,  // H, H
87     0.60f,  // H, D
88     0.50f,  // D, L
89     0.50f,  // D, D
90     0.50f,  // D, H
91 
92     // over VGA
93     0.40f,  // L, L
94     0.50f,  // L, H
95     0.40f,  // L, D
96     0.60f,  // H ,L
97     0.60f,  // H, H
98     0.60f,  // H, D
99     0.50f,  // D, L
100     0.50f,  // D, D
101     0.50f,  // D, H
102 };
103 
104 // Threshold on the target rate relative to transitional rate.
105 const float kFacLowRate = 0.5f;
106 
107 // Action for down-sampling:
108 // motion=L/H/D,spatial==L/H/D, for low, high, middle levels;
109 // rate = 0/1/2, for target rate state relative to transition rate.
110 const uint8_t kSpatialAction[27] = {
111     // rateClass = 0:
112     1,  // L, L
113     1,  // L, H
114     1,  // L, D
115     4,  // H ,L
116     1,  // H, H
117     4,  // H, D
118     4,  // D, L
119     1,  // D, H
120     2,  // D, D
121 
122     // rateClass = 1:
123     1,  // L, L
124     1,  // L, H
125     1,  // L, D
126     2,  // H ,L
127     1,  // H, H
128     2,  // H, D
129     2,  // D, L
130     1,  // D, H
131     2,  // D, D
132 
133     // rateClass = 2:
134     1,  // L, L
135     1,  // L, H
136     1,  // L, D
137     2,  // H ,L
138     1,  // H, H
139     2,  // H, D
140     2,  // D, L
141     1,  // D, H
142     2,  // D, D
143 };
144 
145 const uint8_t kTemporalAction[27] = {
146     // rateClass = 0:
147     3,  // L, L
148     2,  // L, H
149     2,  // L, D
150     1,  // H ,L
151     3,  // H, H
152     1,  // H, D
153     1,  // D, L
154     2,  // D, H
155     1,  // D, D
156 
157     // rateClass = 1:
158     3,  // L, L
159     3,  // L, H
160     3,  // L, D
161     1,  // H ,L
162     3,  // H, H
163     1,  // H, D
164     1,  // D, L
165     3,  // D, H
166     1,  // D, D
167 
168     // rateClass = 2:
169     1,  // L, L
170     3,  // L, H
171     3,  // L, D
172     1,  // H ,L
173     3,  // H, H
174     1,  // H, D
175     1,  // D, L
176     3,  // D, H
177     1,  // D, D
178 };
179 
180 // Control the total amount of down-sampling allowed.
181 const float kMaxSpatialDown = 8.0f;
182 const float kMaxTempDown = 3.0f;
183 const float kMaxTotalDown = 9.0f;
184 
185 // Minimum image size for a spatial down-sampling.
186 const int kMinImageSize = 176 * 144;
187 
188 // Minimum frame rate for temporal down-sampling:
189 // no frame rate reduction if incomingFrameRate <= MIN_FRAME_RATE.
190 const int kMinFrameRate = 8;
191 
192 //
193 // PARAMETERS FOR FEC ADJUSTMENT: TODO (marpan)
194 //
195 
196 //
197 // PARAMETETS FOR SETTING LOW/HIGH STATES OF CONTENT METRICS:
198 //
199 
200 // Thresholds for frame rate:
201 const int kLowFrameRate = 10;
202 const int kMiddleFrameRate = 15;
203 const int kHighFrameRate = 25;
204 
205 // Thresholds for motion: motion level is from NFD.
206 const float kHighMotionNfd = 0.075f;
207 const float kLowMotionNfd = 0.03f;
208 
209 // Thresholds for spatial prediction error:
210 // this is applied on the average of (2x2,1x2,2x1).
211 const float kHighTexture = 0.035f;
212 const float kLowTexture = 0.020f;
213 
214 // Used to reduce thresholds for larger/HD scenes: correction factor since
215 // higher correlation in HD scenes means lower spatial prediction error.
216 const float kScaleTexture = 0.9f;
217 
218 // Percentage reduction in transitional bitrate for 2x2 selected over 1x2/2x1.
219 const float kRateRedSpatial2X2 = 0.6f;
220 
221 const float kSpatialErr2x2VsHoriz = 0.1f;   // percentage to favor 2x2 over H
222 const float kSpatialErr2X2VsVert = 0.1f;    // percentage to favor 2x2 over V
223 const float kSpatialErrVertVsHoriz = 0.1f;  // percentage to favor H over V
224 
225 }  // namespace webrtc
226 
227 #endif  // WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_
228