niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 1 | /* |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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 | |
Henrik Kjellander | 2557b86 | 2015-11-18 21:00:21 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_ |
| 12 | #define WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 13 | |
| 14 | /*************************************************************** |
| 15 | *QMSelectData.h |
| 16 | * This file includes parameters for content-aware media optimization |
| 17 | ****************************************************************/ |
| 18 | |
pbos@webrtc.org | a440732 | 2013-07-16 12:32:05 | [diff] [blame] | 19 | #include "webrtc/typedefs.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 20 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 21 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 22 | // |
| 23 | // PARAMETERS FOR RESOLUTION ADAPTATION |
| 24 | // |
| 25 | |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 26 | // Initial level of buffer in secs. |
| 27 | const float kInitBufferLevel = 0.5f; |
marpan@google.com | 86548c6 | 2011-07-12 17:12:57 | [diff] [blame] | 28 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 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. |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 33 | const float kMaxBufferLow = 0.30f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 34 | |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 35 | // Threshold on rate mismatch. |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 36 | const float kMaxRateMisMatch = 0.5f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 37 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 38 | // Threshold on amount of under/over encoder shooting. |
| 39 | const float kRateOverShoot = 0.75f; |
| 40 | const float kRateUnderShoot = 0.75f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 41 | |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 42 | // Factor to favor weighting the average rates with the current/last data. |
| 43 | const float kWeightRate = 0.70f; |
| 44 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 49 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 50 | // Threshold on packet loss rate, above which favor resolution reduction. |
| 51 | const float kPacketLossThr = 0.1f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 52 | |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 53 | // Factor for reducing transitional bitrate under packet loss. |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 54 | const float kPacketLossRateFac = 1.0f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 55 | |
| 56 | // Maximum possible transitional rate for down-sampling: |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 57 | // (units in kbps), for 30fps. |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 58 | const uint16_t kMaxRateQm[9] = { |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 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 |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | // Frame rate scale for maximum transition rate. |
marpan@webrtc.org | e22d81c | 2012-03-20 18:21:53 | [diff] [blame] | 71 | const float kFrameRateFac[4] = { |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 72 | 0.5f, // Low |
| 73 | 0.7f, // Middle level 1 |
| 74 | 0.85f, // Middle level 2 |
| 75 | 1.0f, // High |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 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] = { |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 81 | // VGA and lower |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 91 | |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 92 | // over VGA |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 102 | }; |
| 103 | |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 104 | // Threshold on the target rate relative to transitional rate. |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 105 | const float kFacLowRate = 0.5f; |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 106 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 107 | // Action for down-sampling: |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 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] = { |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 121 | |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 132 | |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 143 | }; |
| 144 | |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 145 | const uint8_t kTemporalAction[27] = { |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 156 | |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 167 | |
philipel | 9d3ab61 | 2015-12-21 12:12:39 | [diff] [blame] | 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 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 178 | }; |
| 179 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 180 | // Control the total amount of down-sampling allowed. |
marpan@webrtc.org | accf607 | 2012-03-07 17:16:10 | [diff] [blame] | 181 | const float kMaxSpatialDown = 8.0f; |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 182 | const float kMaxTempDown = 3.0f; |
| 183 | const float kMaxTotalDown = 9.0f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 184 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 185 | // Minimum image size for a spatial down-sampling. |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 186 | const int kMinImageSize = 176 * 144; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 187 | |
| 188 | // Minimum frame rate for temporal down-sampling: |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 189 | // no frame rate reduction if incomingFrameRate <= MIN_FRAME_RATE. |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 190 | const int kMinFrameRate = 8; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 191 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 192 | // |
| 193 | // PARAMETERS FOR FEC ADJUSTMENT: TODO (marpan) |
| 194 | // |
| 195 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 196 | // |
| 197 | // PARAMETETS FOR SETTING LOW/HIGH STATES OF CONTENT METRICS: |
| 198 | // |
| 199 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 200 | // Thresholds for frame rate: |
| 201 | const int kLowFrameRate = 10; |
marpan@webrtc.org | e22d81c | 2012-03-20 18:21:53 | [diff] [blame] | 202 | const int kMiddleFrameRate = 15; |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 203 | const int kHighFrameRate = 25; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 204 | |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 205 | // Thresholds for motion: motion level is from NFD. |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 206 | const float kHighMotionNfd = 0.075f; |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 207 | const float kLowMotionNfd = 0.03f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 208 | |
| 209 | // Thresholds for spatial prediction error: |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 210 | // this is applied on the average of (2x2,1x2,2x1). |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 211 | const float kHighTexture = 0.035f; |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 212 | const float kLowTexture = 0.020f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 213 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 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; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 217 | |
marpan@webrtc.org | c5b392e | 2012-06-29 21:44:55 | [diff] [blame] | 218 | // Percentage reduction in transitional bitrate for 2x2 selected over 1x2/2x1. |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 219 | const float kRateRedSpatial2X2 = 0.6f; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 220 | |
marpan@webrtc.org | 9d76b4e | 2012-02-28 23:39:31 | [diff] [blame] | 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 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 224 | |
pbos@webrtc.org | d900e8b | 2013-07-03 15:12:26 | [diff] [blame] | 225 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 | [diff] [blame] | 226 | |
Henrik Kjellander | 2557b86 | 2015-11-18 21:00:21 | [diff] [blame] | 227 | #endif // WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_ |