blob: 49190ef53b92ece32ffd9b6389d742c6136029aa [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
marpan@webrtc.org9d76b4e2012-02-28 23:39:312 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:253 *
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 Kjellander2557b862015-11-18 21:00:2111#ifndef WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_
12#define WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_
niklase@google.com470e71d2011-07-07 08:21:2513
14/***************************************************************
15*QMSelectData.h
16* This file includes parameters for content-aware media optimization
17****************************************************************/
18
pbos@webrtc.orga4407322013-07-16 12:32:0519#include "webrtc/typedefs.h"
niklase@google.com470e71d2011-07-07 08:21:2520
marpan@webrtc.org9d76b4e2012-02-28 23:39:3121namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:2522//
23// PARAMETERS FOR RESOLUTION ADAPTATION
24//
25
marpan@webrtc.orgc5b392e2012-06-29 21:44:5526// Initial level of buffer in secs.
27const float kInitBufferLevel = 0.5f;
marpan@google.com86548c62011-07-12 17:12:5728
marpan@webrtc.org9d76b4e2012-02-28 23:39:3129// Threshold of (max) buffer size below which we consider too low (underflow).
30const float kPercBufferThr = 0.10f;
31
32// Threshold on the occurrences of low buffer levels.
marpan@webrtc.orgc5b392e2012-06-29 21:44:5533const float kMaxBufferLow = 0.30f;
niklase@google.com470e71d2011-07-07 08:21:2534
marpan@webrtc.orgc5b392e2012-06-29 21:44:5535// Threshold on rate mismatch.
marpan@webrtc.org9d76b4e2012-02-28 23:39:3136const float kMaxRateMisMatch = 0.5f;
niklase@google.com470e71d2011-07-07 08:21:2537
marpan@webrtc.org9d76b4e2012-02-28 23:39:3138// Threshold on amount of under/over encoder shooting.
39const float kRateOverShoot = 0.75f;
40const float kRateUnderShoot = 0.75f;
niklase@google.com470e71d2011-07-07 08:21:2541
marpan@webrtc.orgaccf6072012-03-07 17:16:1042// Factor to favor weighting the average rates with the current/last data.
43const float kWeightRate = 0.70f;
44
marpan@webrtc.org9d76b4e2012-02-28 23:39:3145// Factor for transitional rate for going back up in resolution.
46const float kTransRateScaleUpSpatial = 1.25f;
47const float kTransRateScaleUpTemp = 1.25f;
48const float kTransRateScaleUpSpatialTemp = 1.25f;
niklase@google.com470e71d2011-07-07 08:21:2549
marpan@webrtc.org9d76b4e2012-02-28 23:39:3150// Threshold on packet loss rate, above which favor resolution reduction.
51const float kPacketLossThr = 0.1f;
niklase@google.com470e71d2011-07-07 08:21:2552
marpan@webrtc.orgc5b392e2012-06-29 21:44:5553// Factor for reducing transitional bitrate under packet loss.
marpan@webrtc.org9d76b4e2012-02-28 23:39:3154const float kPacketLossRateFac = 1.0f;
niklase@google.com470e71d2011-07-07 08:21:2555
56// Maximum possible transitional rate for down-sampling:
marpan@webrtc.org9d76b4e2012-02-28 23:39:3157// (units in kbps), for 30fps.
marpan@webrtc.orgaccf6072012-03-07 17:16:1058const uint16_t kMaxRateQm[9] = {
marpan@webrtc.orgc5b392e2012-06-29 21:44:5559 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.org9d76b4e2012-02-28 23:39:3168};
69
70// Frame rate scale for maximum transition rate.
marpan@webrtc.orge22d81c2012-03-20 18:21:5371const float kFrameRateFac[4] = {
philipel9d3ab612015-12-21 12:12:3972 0.5f, // Low
73 0.7f, // Middle level 1
74 0.85f, // Middle level 2
75 1.0f, // High
niklase@google.com470e71d2011-07-07 08:21:2576};
77
78// Scale for transitional rate: based on content class
79// motion=L/H/D,spatial==L/H/D: for low, high, middle levels
80const float kScaleTransRateQm[18] = {
marpan@webrtc.orgaccf6072012-03-07 17:16:1081 // VGA and lower
philipel9d3ab612015-12-21 12:12:3982 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.com470e71d2011-07-07 08:21:2591
marpan@webrtc.orgaccf6072012-03-07 17:16:1092 // over VGA
philipel9d3ab612015-12-21 12:12:3993 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.com470e71d2011-07-07 08:21:25102};
103
marpan@webrtc.orgaccf6072012-03-07 17:16:10104// Threshold on the target rate relative to transitional rate.
marpan@webrtc.orgc5b392e2012-06-29 21:44:55105const float kFacLowRate = 0.5f;
marpan@webrtc.orgaccf6072012-03-07 17:16:10106
niklase@google.com470e71d2011-07-07 08:21:25107// Action for down-sampling:
marpan@webrtc.orgaccf6072012-03-07 17:16:10108// 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.
110const uint8_t kSpatialAction[27] = {
philipel9d3ab612015-12-21 12:12:39111 // 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.orgaccf6072012-03-07 17:16:10121
philipel9d3ab612015-12-21 12:12:39122 // 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.orgaccf6072012-03-07 17:16:10132
philipel9d3ab612015-12-21 12:12:39133 // 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.com470e71d2011-07-07 08:21:25143};
144
marpan@webrtc.orgaccf6072012-03-07 17:16:10145const uint8_t kTemporalAction[27] = {
philipel9d3ab612015-12-21 12:12:39146 // 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.orgaccf6072012-03-07 17:16:10156
philipel9d3ab612015-12-21 12:12:39157 // 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.orgaccf6072012-03-07 17:16:10167
philipel9d3ab612015-12-21 12:12:39168 // 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.com470e71d2011-07-07 08:21:25178};
179
marpan@webrtc.org9d76b4e2012-02-28 23:39:31180// Control the total amount of down-sampling allowed.
marpan@webrtc.orgaccf6072012-03-07 17:16:10181const float kMaxSpatialDown = 8.0f;
marpan@webrtc.orgc5b392e2012-06-29 21:44:55182const float kMaxTempDown = 3.0f;
183const float kMaxTotalDown = 9.0f;
niklase@google.com470e71d2011-07-07 08:21:25184
marpan@webrtc.org9d76b4e2012-02-28 23:39:31185// Minimum image size for a spatial down-sampling.
marpan@webrtc.orgc5b392e2012-06-29 21:44:55186const int kMinImageSize = 176 * 144;
niklase@google.com470e71d2011-07-07 08:21:25187
188// Minimum frame rate for temporal down-sampling:
marpan@webrtc.orgc5b392e2012-06-29 21:44:55189// no frame rate reduction if incomingFrameRate <= MIN_FRAME_RATE.
marpan@webrtc.org9d76b4e2012-02-28 23:39:31190const int kMinFrameRate = 8;
niklase@google.com470e71d2011-07-07 08:21:25191
niklase@google.com470e71d2011-07-07 08:21:25192//
193// PARAMETERS FOR FEC ADJUSTMENT: TODO (marpan)
194//
195
niklase@google.com470e71d2011-07-07 08:21:25196//
197// PARAMETETS FOR SETTING LOW/HIGH STATES OF CONTENT METRICS:
198//
199
marpan@webrtc.org9d76b4e2012-02-28 23:39:31200// Thresholds for frame rate:
201const int kLowFrameRate = 10;
marpan@webrtc.orge22d81c2012-03-20 18:21:53202const int kMiddleFrameRate = 15;
marpan@webrtc.org9d76b4e2012-02-28 23:39:31203const int kHighFrameRate = 25;
niklase@google.com470e71d2011-07-07 08:21:25204
marpan@webrtc.orgc5b392e2012-06-29 21:44:55205// Thresholds for motion: motion level is from NFD.
marpan@webrtc.org9d76b4e2012-02-28 23:39:31206const float kHighMotionNfd = 0.075f;
marpan@webrtc.orgc5b392e2012-06-29 21:44:55207const float kLowMotionNfd = 0.03f;
niklase@google.com470e71d2011-07-07 08:21:25208
209// Thresholds for spatial prediction error:
marpan@webrtc.orgc5b392e2012-06-29 21:44:55210// this is applied on the average of (2x2,1x2,2x1).
marpan@webrtc.org9d76b4e2012-02-28 23:39:31211const float kHighTexture = 0.035f;
marpan@webrtc.orgc5b392e2012-06-29 21:44:55212const float kLowTexture = 0.020f;
niklase@google.com470e71d2011-07-07 08:21:25213
marpan@webrtc.org9d76b4e2012-02-28 23:39:31214// Used to reduce thresholds for larger/HD scenes: correction factor since
215// higher correlation in HD scenes means lower spatial prediction error.
216const float kScaleTexture = 0.9f;
niklase@google.com470e71d2011-07-07 08:21:25217
marpan@webrtc.orgc5b392e2012-06-29 21:44:55218// Percentage reduction in transitional bitrate for 2x2 selected over 1x2/2x1.
marpan@webrtc.org9d76b4e2012-02-28 23:39:31219const float kRateRedSpatial2X2 = 0.6f;
niklase@google.com470e71d2011-07-07 08:21:25220
marpan@webrtc.org9d76b4e2012-02-28 23:39:31221const float kSpatialErr2x2VsHoriz = 0.1f; // percentage to favor 2x2 over H
222const float kSpatialErr2X2VsVert = 0.1f; // percentage to favor 2x2 over V
223const float kSpatialErrVertVsHoriz = 0.1f; // percentage to favor H over V
niklase@google.com470e71d2011-07-07 08:21:25224
pbos@webrtc.orgd900e8b2013-07-03 15:12:26225} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25226
Henrik Kjellander2557b862015-11-18 21:00:21227#endif // WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_DATA_H_