| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 struct VCMResolutionScale { | 24 struct VCMResolutionScale { |
| 25 VCMResolutionScale() | 25 VCMResolutionScale() |
| 26 : codec_width(640), | 26 : codec_width(640), |
| 27 codec_height(480), | 27 codec_height(480), |
| 28 frame_rate(30.0f), | 28 frame_rate(30.0f), |
| 29 spatial_width_fact(1.0f), | 29 spatial_width_fact(1.0f), |
| 30 spatial_height_fact(1.0f), | 30 spatial_height_fact(1.0f), |
| 31 temporal_fact(1.0f), | 31 temporal_fact(1.0f), |
| 32 change_resolution_spatial(false), | 32 change_resolution_spatial(false), |
| 33 change_resolution_temporal(false) { | 33 change_resolution_temporal(false) {} |
| 34 } | |
| 35 uint16_t codec_width; | 34 uint16_t codec_width; |
| 36 uint16_t codec_height; | 35 uint16_t codec_height; |
| 37 float frame_rate; | 36 float frame_rate; |
| 38 float spatial_width_fact; | 37 float spatial_width_fact; |
| 39 float spatial_height_fact; | 38 float spatial_height_fact; |
| 40 float temporal_fact; | 39 float temporal_fact; |
| 41 bool change_resolution_spatial; | 40 bool change_resolution_spatial; |
| 42 bool change_resolution_temporal; | 41 bool change_resolution_temporal; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 enum ImageType { | 44 enum ImageType { |
| 46 kQCIF = 0, // 176x144 | 45 kQCIF = 0, // 176x144 |
| 47 kHCIF, // 264x216 = half(~3/4x3/4) CIF. | 46 kHCIF, // 264x216 = half(~3/4x3/4) CIF. |
| 48 kQVGA, // 320x240 = quarter VGA. | 47 kQVGA, // 320x240 = quarter VGA. |
| 49 kCIF, // 352x288 | 48 kCIF, // 352x288 |
| 50 kHVGA, // 480x360 = half(~3/4x3/4) VGA. | 49 kHVGA, // 480x360 = half(~3/4x3/4) VGA. |
| 51 kVGA, // 640x480 | 50 kVGA, // 640x480 |
| 52 kQFULLHD, // 960x540 = quarter FULLHD, and half(~3/4x3/4) WHD. | 51 kQFULLHD, // 960x540 = quarter FULLHD, and half(~3/4x3/4) WHD. |
| 53 kWHD, // 1280x720 | 52 kWHD, // 1280x720 |
| 54 kFULLHD, // 1920x1080 | 53 kFULLHD, // 1920x1080 |
| 55 kNumImageTypes | 54 kNumImageTypes |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 const uint32_t kSizeOfImageType[kNumImageTypes] = | 57 const uint32_t kSizeOfImageType[kNumImageTypes] = { |
| 59 { 25344, 57024, 76800, 101376, 172800, 307200, 518400, 921600, 2073600 }; | 58 25344, 57024, 76800, 101376, 172800, 307200, 518400, 921600, 2073600}; |
| 60 | 59 |
| 61 enum FrameRateLevelClass { | 60 enum FrameRateLevelClass { |
| 62 kFrameRateLow, | 61 kFrameRateLow, |
| 63 kFrameRateMiddle1, | 62 kFrameRateMiddle1, |
| 64 kFrameRateMiddle2, | 63 kFrameRateMiddle2, |
| 65 kFrameRateHigh | 64 kFrameRateHigh |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 enum ContentLevelClass { | 67 enum ContentLevelClass { kLow, kHigh, kDefault }; |
| 69 kLow, | |
| 70 kHigh, | |
| 71 kDefault | |
| 72 }; | |
| 73 | 68 |
| 74 struct VCMContFeature { | 69 struct VCMContFeature { |
| 75 VCMContFeature() | 70 VCMContFeature() : value(0.0f), level(kDefault) {} |
| 76 : value(0.0f), | |
| 77 level(kDefault) { | |
| 78 } | |
| 79 void Reset() { | 71 void Reset() { |
| 80 value = 0.0f; | 72 value = 0.0f; |
| 81 level = kDefault; | 73 level = kDefault; |
| 82 } | 74 } |
| 83 float value; | 75 float value; |
| 84 ContentLevelClass level; | 76 ContentLevelClass level; |
| 85 }; | 77 }; |
| 86 | 78 |
| 87 enum UpDownAction { | 79 enum UpDownAction { kUpResolution, kDownResolution }; |
| 88 kUpResolution, | |
| 89 kDownResolution | |
| 90 }; | |
| 91 | 80 |
| 92 enum SpatialAction { | 81 enum SpatialAction { |
| 93 kNoChangeSpatial, | 82 kNoChangeSpatial, |
| 94 kOneHalfSpatialUniform, // 3/4 x 3/4: 9/6 ~1/2 pixel reduction. | 83 kOneHalfSpatialUniform, // 3/4 x 3/4: 9/6 ~1/2 pixel reduction. |
| 95 kOneQuarterSpatialUniform, // 1/2 x 1/2: 1/4 pixel reduction. | 84 kOneQuarterSpatialUniform, // 1/2 x 1/2: 1/4 pixel reduction. |
| 96 kNumModesSpatial | 85 kNumModesSpatial |
| 97 }; | 86 }; |
| 98 | 87 |
| 99 enum TemporalAction { | 88 enum TemporalAction { |
| 100 kNoChangeTemporal, | 89 kNoChangeTemporal, |
| 101 kTwoThirdsTemporal, // 2/3 frame rate reduction | 90 kTwoThirdsTemporal, // 2/3 frame rate reduction |
| 102 kOneHalfTemporal, // 1/2 frame rate reduction | 91 kOneHalfTemporal, // 1/2 frame rate reduction |
| 103 kNumModesTemporal | 92 kNumModesTemporal |
| 104 }; | 93 }; |
| 105 | 94 |
| 106 struct ResolutionAction { | 95 struct ResolutionAction { |
| 107 ResolutionAction() | 96 ResolutionAction() : spatial(kNoChangeSpatial), temporal(kNoChangeTemporal) {} |
| 108 : spatial(kNoChangeSpatial), | |
| 109 temporal(kNoChangeTemporal) { | |
| 110 } | |
| 111 SpatialAction spatial; | 97 SpatialAction spatial; |
| 112 TemporalAction temporal; | 98 TemporalAction temporal; |
| 113 }; | 99 }; |
| 114 | 100 |
| 115 // Down-sampling factors for spatial (width and height), and temporal. | 101 // Down-sampling factors for spatial (width and height), and temporal. |
| 116 const float kFactorWidthSpatial[kNumModesSpatial] = | 102 const float kFactorWidthSpatial[kNumModesSpatial] = {1.0f, 4.0f / 3.0f, 2.0f}; |
| 117 { 1.0f, 4.0f / 3.0f, 2.0f }; | |
| 118 | 103 |
| 119 const float kFactorHeightSpatial[kNumModesSpatial] = | 104 const float kFactorHeightSpatial[kNumModesSpatial] = {1.0f, 4.0f / 3.0f, 2.0f}; |
| 120 { 1.0f, 4.0f / 3.0f, 2.0f }; | |
| 121 | 105 |
| 122 const float kFactorTemporal[kNumModesTemporal] = | 106 const float kFactorTemporal[kNumModesTemporal] = {1.0f, 1.5f, 2.0f}; |
| 123 { 1.0f, 1.5f, 2.0f }; | |
| 124 | 107 |
| 125 enum EncoderState { | 108 enum EncoderState { |
| 126 kStableEncoding, // Low rate mis-match, stable buffer levels. | 109 kStableEncoding, // Low rate mis-match, stable buffer levels. |
| 127 kStressedEncoding, // Significant over-shooting of target rate, | 110 kStressedEncoding, // Significant over-shooting of target rate, |
| 128 // Buffer under-flow, etc. | 111 // Buffer under-flow, etc. |
| 129 kEasyEncoding // Significant under-shooting of target rate. | 112 kEasyEncoding // Significant under-shooting of target rate. |
| 130 }; | 113 }; |
| 131 | 114 |
| 132 // QmMethod class: main class for resolution and robustness settings | 115 // QmMethod class: main class for resolution and robustness settings |
| 133 | 116 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 // Check constraints on the amount of down-sampling allowed. | 273 // Check constraints on the amount of down-sampling allowed. |
| 291 void ConstrainAmountOfDownSampling(); | 274 void ConstrainAmountOfDownSampling(); |
| 292 | 275 |
| 293 // For going up in resolution: pick spatial or temporal action, | 276 // For going up in resolution: pick spatial or temporal action, |
| 294 // if both actions were separately selected. | 277 // if both actions were separately selected. |
| 295 void PickSpatialOrTemporal(); | 278 void PickSpatialOrTemporal(); |
| 296 | 279 |
| 297 // Select the directional (1x2 or 2x1) spatial down-sampling action. | 280 // Select the directional (1x2 or 2x1) spatial down-sampling action. |
| 298 void SelectSpatialDirectionMode(float transition_rate); | 281 void SelectSpatialDirectionMode(float transition_rate); |
| 299 | 282 |
| 300 enum { kDownActionHistorySize = 10}; | 283 enum { kDownActionHistorySize = 10 }; |
| 301 | 284 |
| 302 VCMResolutionScale* qm_; | 285 VCMResolutionScale* qm_; |
| 303 // Encoder rate control parameters. | 286 // Encoder rate control parameters. |
| 304 float target_bitrate_; | 287 float target_bitrate_; |
| 305 float incoming_framerate_; | 288 float incoming_framerate_; |
| 306 float per_frame_bandwidth_; | 289 float per_frame_bandwidth_; |
| 307 float buffer_level_; | 290 float buffer_level_; |
| 308 | 291 |
| 309 // Data accumulated every ~1sec from MediaOpt. | 292 // Data accumulated every ~1sec from MediaOpt. |
| 310 float sum_target_rate_; | 293 float sum_target_rate_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 347 |
| 365 private: | 348 private: |
| 366 // Previous state of network parameters. | 349 // Previous state of network parameters. |
| 367 float prev_total_rate_; | 350 float prev_total_rate_; |
| 368 int64_t prev_rtt_time_; | 351 int64_t prev_rtt_time_; |
| 369 uint8_t prev_packet_loss_; | 352 uint8_t prev_packet_loss_; |
| 370 uint8_t prev_code_rate_delta_; | 353 uint8_t prev_code_rate_delta_; |
| 371 }; | 354 }; |
| 372 } // namespace webrtc | 355 } // namespace webrtc |
| 373 #endif // WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_H_ | 356 #endif // WEBRTC_MODULES_VIDEO_CODING_QM_SELECT_H_ |
| OLD | NEW |