Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: webrtc/modules/video_coding/media_opt_util.cc

Issue 2625903004: Rename fec_tables_xor.h -> fec_rate_table.h (Closed)
Patch Set: sprang comments 1. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/fec_tables_xor.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "webrtc/modules/video_coding/media_opt_util.h" 11 #include "webrtc/modules/video_coding/media_opt_util.h"
12 12
13 #include <float.h> 13 #include <float.h>
14 #include <limits.h> 14 #include <limits.h>
15 #include <math.h> 15 #include <math.h>
16 16
17 #include <algorithm> 17 #include <algorithm>
18 #include <limits> 18 #include <limits>
19 19
20 #include "webrtc/modules/include/module_common_types.h" 20 #include "webrtc/modules/include/module_common_types.h"
21 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h" 21 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8_common_types.h"
22 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 22 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
23 #include "webrtc/modules/video_coding/fec_tables_xor.h" 23 #include "webrtc/modules/video_coding/fec_rate_table.h"
24 #include "webrtc/modules/video_coding/nack_fec_tables.h" 24 #include "webrtc/modules/video_coding/nack_fec_tables.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 // Max value of loss rates in off-line model 27 // Max value of loss rates in off-line model
28 static const int kPacketLossMax = 129; 28 static const int kPacketLossMax = 129;
29 29
30 namespace media_optimization { 30 namespace media_optimization {
31 31
32 VCMProtectionMethod::VCMProtectionMethod() 32 VCMProtectionMethod::VCMProtectionMethod()
33 : _effectivePacketLoss(0), 33 : _effectivePacketLoss(0),
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 VCM_MAX(VCM_MIN((effRateFecTable - ratePar1) / ratePar1, ratePar2), 0)); 302 VCM_MAX(VCM_MIN((effRateFecTable - ratePar1) / ratePar1, ratePar2), 0));
303 303
304 // Restrict packet loss range to 50: 304 // Restrict packet loss range to 50:
305 // current tables defined only up to 50% 305 // current tables defined only up to 50%
306 if (packetLoss >= kPacketLossMax) { 306 if (packetLoss >= kPacketLossMax) {
307 packetLoss = kPacketLossMax - 1; 307 packetLoss = kPacketLossMax - 1;
308 } 308 }
309 uint16_t indexTable = rateIndexTable * kPacketLossMax + packetLoss; 309 uint16_t indexTable = rateIndexTable * kPacketLossMax + packetLoss;
310 310
311 // Check on table index 311 // Check on table index
312 assert(indexTable < kSizeCodeRateXORTable); 312 RTC_DCHECK_LT(indexTable, kFecRateTableSize);
313 313
314 // Protection factor for P frame 314 // Protection factor for P frame
315 codeRateDelta = kCodeRateXORTable[indexTable]; 315 codeRateDelta = kFecRateTable[indexTable];
316 316
317 if (packetLoss > lossThr && avgTotPackets > packetNumThr) { 317 if (packetLoss > lossThr && avgTotPackets > packetNumThr) {
318 // Set a minimum based on first partition size. 318 // Set a minimum based on first partition size.
319 if (codeRateDelta < firstPartitionProt) { 319 if (codeRateDelta < firstPartitionProt) {
320 codeRateDelta = firstPartitionProt; 320 codeRateDelta = firstPartitionProt;
321 } 321 }
322 } 322 }
323 323
324 // Check limit on amount of protection for P frame; 50% is max. 324 // Check limit on amount of protection for P frame; 50% is max.
325 if (codeRateDelta >= kPacketLossMax) { 325 if (codeRateDelta >= kPacketLossMax) {
326 codeRateDelta = kPacketLossMax - 1; 326 codeRateDelta = kPacketLossMax - 1;
327 } 327 }
328 328
329 // For Key frame: 329 // For Key frame:
330 // Effectively at a higher rate, so we scale/boost the rate 330 // Effectively at a higher rate, so we scale/boost the rate
331 // The boost factor may depend on several factors: ratio of packet 331 // The boost factor may depend on several factors: ratio of packet
332 // number of I to P frames, how much protection placed on P frames, etc. 332 // number of I to P frames, how much protection placed on P frames, etc.
333 const uint8_t packetFrameDelta = 333 const uint8_t packetFrameDelta =
334 static_cast<uint8_t>(0.5 + parameters->packetsPerFrame); 334 static_cast<uint8_t>(0.5 + parameters->packetsPerFrame);
335 const uint8_t packetFrameKey = 335 const uint8_t packetFrameKey =
336 static_cast<uint8_t>(0.5 + parameters->packetsPerFrameKey); 336 static_cast<uint8_t>(0.5 + parameters->packetsPerFrameKey);
337 const uint8_t boostKey = BoostCodeRateKey(packetFrameDelta, packetFrameKey); 337 const uint8_t boostKey = BoostCodeRateKey(packetFrameDelta, packetFrameKey);
338 338
339 rateIndexTable = static_cast<uint8_t>(VCM_MAX( 339 rateIndexTable = static_cast<uint8_t>(VCM_MAX(
340 VCM_MIN(1 + (boostKey * effRateFecTable - ratePar1) / ratePar1, ratePar2), 340 VCM_MIN(1 + (boostKey * effRateFecTable - ratePar1) / ratePar1, ratePar2),
341 0)); 341 0));
342 uint16_t indexTableKey = rateIndexTable * kPacketLossMax + packetLoss; 342 uint16_t indexTableKey = rateIndexTable * kPacketLossMax + packetLoss;
343 343
344 indexTableKey = VCM_MIN(indexTableKey, kSizeCodeRateXORTable); 344 indexTableKey = VCM_MIN(indexTableKey, kFecRateTableSize);
345 345
346 // Check on table index 346 // Check on table index
347 assert(indexTableKey < kSizeCodeRateXORTable); 347 assert(indexTableKey < kFecRateTableSize);
348 348
349 // Protection factor for I frame 349 // Protection factor for I frame
350 codeRateKey = kCodeRateXORTable[indexTableKey]; 350 codeRateKey = kFecRateTable[indexTableKey];
351 351
352 // Boosting for Key frame. 352 // Boosting for Key frame.
353 int boostKeyProt = _scaleProtKey * codeRateDelta; 353 int boostKeyProt = _scaleProtKey * codeRateDelta;
354 if (boostKeyProt >= kPacketLossMax) { 354 if (boostKeyProt >= kPacketLossMax) {
355 boostKeyProt = kPacketLossMax - 1; 355 boostKeyProt = kPacketLossMax - 1;
356 } 356 }
357 357
358 // Make sure I frame protection is at least larger than P frame protection, 358 // Make sure I frame protection is at least larger than P frame protection,
359 // and at least as high as filtered packet loss. 359 // and at least as high as filtered packet loss.
360 codeRateKey = static_cast<uint8_t>( 360 codeRateKey = static_cast<uint8_t>(
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 _shortMaxLossPr255 = 0; 651 _shortMaxLossPr255 = 0;
652 Release(); 652 Release();
653 } 653 }
654 654
655 void VCMLossProtectionLogic::Release() { 655 void VCMLossProtectionLogic::Release() {
656 _selectedMethod.reset(); 656 _selectedMethod.reset();
657 } 657 }
658 658
659 } // namespace media_optimization 659 } // namespace media_optimization
660 } // namespace webrtc 660 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/fec_tables_xor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698