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

Side by Side Diff: webrtc/modules/include/module_common_types.h

Issue 1316523002: Convert channel counts to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix compile Created 4 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
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
(...skipping 10 matching lines...) Expand all
21 #include "webrtc/common_types.h" 21 #include "webrtc/common_types.h"
22 #include "webrtc/common_video/rotation.h" 22 #include "webrtc/common_video/rotation.h"
23 #include "webrtc/typedefs.h" 23 #include "webrtc/typedefs.h"
24 24
25 namespace webrtc { 25 namespace webrtc {
26 26
27 struct RTPAudioHeader { 27 struct RTPAudioHeader {
28 uint8_t numEnergy; // number of valid entries in arrOfEnergy 28 uint8_t numEnergy; // number of valid entries in arrOfEnergy
29 uint8_t arrOfEnergy[kRtpCsrcSize]; // one energy byte (0-9) per channel 29 uint8_t arrOfEnergy[kRtpCsrcSize]; // one energy byte (0-9) per channel
30 bool isCNG; // is this CNG 30 bool isCNG; // is this CNG
31 uint8_t channel; // number of channels 2 = stereo 31 size_t channel; // number of channels 2 = stereo
32 }; 32 };
33 33
34 const int16_t kNoPictureId = -1; 34 const int16_t kNoPictureId = -1;
35 const int16_t kMaxOneBytePictureId = 0x7F; // 7 bits 35 const int16_t kMaxOneBytePictureId = 0x7F; // 7 bits
36 const int16_t kMaxTwoBytePictureId = 0x7FFF; // 15 bits 36 const int16_t kMaxTwoBytePictureId = 0x7FFF; // 15 bits
37 const int16_t kNoTl0PicIdx = -1; 37 const int16_t kNoTl0PicIdx = -1;
38 const uint8_t kNoTemporalIdx = 0xFF; 38 const uint8_t kNoTemporalIdx = 0xFF;
39 const uint8_t kNoSpatialIdx = 0xFF; 39 const uint8_t kNoSpatialIdx = 0xFF;
40 const uint8_t kNoGofIdx = 0xFF; 40 const uint8_t kNoGofIdx = 0xFF;
41 const uint8_t kNumVp9Buffers = 8; 41 const uint8_t kNumVp9Buffers = 8;
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 virtual ~AudioFrame() {} 501 virtual ~AudioFrame() {}
502 502
503 // Resets all members to their default state (except does not modify the 503 // Resets all members to their default state (except does not modify the
504 // contents of |data_|). 504 // contents of |data_|).
505 void Reset(); 505 void Reset();
506 506
507 // |interleaved_| is not changed by this method. 507 // |interleaved_| is not changed by this method.
508 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data, 508 void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
509 size_t samples_per_channel, int sample_rate_hz, 509 size_t samples_per_channel, int sample_rate_hz,
510 SpeechType speech_type, VADActivity vad_activity, 510 SpeechType speech_type, VADActivity vad_activity,
511 int num_channels = 1, uint32_t energy = -1); 511 size_t num_channels = 1, uint32_t energy = -1);
512 512
513 AudioFrame& Append(const AudioFrame& rhs); 513 AudioFrame& Append(const AudioFrame& rhs);
514 514
515 void CopyFrom(const AudioFrame& src); 515 void CopyFrom(const AudioFrame& src);
516 516
517 void Mute(); 517 void Mute();
518 518
519 AudioFrame& operator>>=(const int rhs); 519 AudioFrame& operator>>=(const int rhs);
520 AudioFrame& operator+=(const AudioFrame& rhs); 520 AudioFrame& operator+=(const AudioFrame& rhs);
521 AudioFrame& operator-=(const AudioFrame& rhs); 521 AudioFrame& operator-=(const AudioFrame& rhs);
522 522
523 int id_; 523 int id_;
524 // RTP timestamp of the first sample in the AudioFrame. 524 // RTP timestamp of the first sample in the AudioFrame.
525 uint32_t timestamp_; 525 uint32_t timestamp_;
526 // Time since the first frame in milliseconds. 526 // Time since the first frame in milliseconds.
527 // -1 represents an uninitialized value. 527 // -1 represents an uninitialized value.
528 int64_t elapsed_time_ms_; 528 int64_t elapsed_time_ms_;
529 // NTP time of the estimated capture time in local timebase in milliseconds. 529 // NTP time of the estimated capture time in local timebase in milliseconds.
530 // -1 represents an uninitialized value. 530 // -1 represents an uninitialized value.
531 int64_t ntp_time_ms_; 531 int64_t ntp_time_ms_;
532 int16_t data_[kMaxDataSizeSamples]; 532 int16_t data_[kMaxDataSizeSamples];
533 size_t samples_per_channel_; 533 size_t samples_per_channel_;
534 int sample_rate_hz_; 534 int sample_rate_hz_;
535 int num_channels_; 535 size_t num_channels_;
536 SpeechType speech_type_; 536 SpeechType speech_type_;
537 VADActivity vad_activity_; 537 VADActivity vad_activity_;
538 // Note that there is no guarantee that |energy_| is correct. Any user of this 538 // Note that there is no guarantee that |energy_| is correct. Any user of this
539 // member must verify that the value is correct. 539 // member must verify that the value is correct.
540 // TODO(henrike) Remove |energy_|. 540 // TODO(henrike) Remove |energy_|.
541 // See https://code.google.com/p/webrtc/issues/detail?id=3315. 541 // See https://code.google.com/p/webrtc/issues/detail?id=3315.
542 uint32_t energy_; 542 uint32_t energy_;
543 bool interleaved_; 543 bool interleaved_;
544 544
545 private: 545 private:
(...skipping 21 matching lines...) Expand all
567 interleaved_ = true; 567 interleaved_ = true;
568 } 568 }
569 569
570 inline void AudioFrame::UpdateFrame(int id, 570 inline void AudioFrame::UpdateFrame(int id,
571 uint32_t timestamp, 571 uint32_t timestamp,
572 const int16_t* data, 572 const int16_t* data,
573 size_t samples_per_channel, 573 size_t samples_per_channel,
574 int sample_rate_hz, 574 int sample_rate_hz,
575 SpeechType speech_type, 575 SpeechType speech_type,
576 VADActivity vad_activity, 576 VADActivity vad_activity,
577 int num_channels, 577 size_t num_channels,
578 uint32_t energy) { 578 uint32_t energy) {
579 id_ = id; 579 id_ = id;
580 timestamp_ = timestamp; 580 timestamp_ = timestamp;
581 samples_per_channel_ = samples_per_channel; 581 samples_per_channel_ = samples_per_channel;
582 sample_rate_hz_ = sample_rate_hz; 582 sample_rate_hz_ = sample_rate_hz;
583 speech_type_ = speech_type; 583 speech_type_ = speech_type;
584 vad_activity_ = vad_activity; 584 vad_activity_ = vad_activity;
585 num_channels_ = num_channels; 585 num_channels_ = num_channels;
586 energy_ = energy; 586 energy_ = energy;
587 587
588 assert(num_channels >= 0);
589 const size_t length = samples_per_channel * num_channels; 588 const size_t length = samples_per_channel * num_channels;
590 assert(length <= kMaxDataSizeSamples); 589 assert(length <= kMaxDataSizeSamples);
591 if (data != NULL) { 590 if (data != NULL) {
592 memcpy(data_, data, sizeof(int16_t) * length); 591 memcpy(data_, data, sizeof(int16_t) * length);
593 } else { 592 } else {
594 memset(data_, 0, sizeof(int16_t) * length); 593 memset(data_, 0, sizeof(int16_t) * length);
595 } 594 }
596 } 595 }
597 596
598 inline void AudioFrame::CopyFrom(const AudioFrame& src) { 597 inline void AudioFrame::CopyFrom(const AudioFrame& src) {
599 if (this == &src) return; 598 if (this == &src) return;
600 599
601 id_ = src.id_; 600 id_ = src.id_;
602 timestamp_ = src.timestamp_; 601 timestamp_ = src.timestamp_;
603 elapsed_time_ms_ = src.elapsed_time_ms_; 602 elapsed_time_ms_ = src.elapsed_time_ms_;
604 ntp_time_ms_ = src.ntp_time_ms_; 603 ntp_time_ms_ = src.ntp_time_ms_;
605 samples_per_channel_ = src.samples_per_channel_; 604 samples_per_channel_ = src.samples_per_channel_;
606 sample_rate_hz_ = src.sample_rate_hz_; 605 sample_rate_hz_ = src.sample_rate_hz_;
607 speech_type_ = src.speech_type_; 606 speech_type_ = src.speech_type_;
608 vad_activity_ = src.vad_activity_; 607 vad_activity_ = src.vad_activity_;
609 num_channels_ = src.num_channels_; 608 num_channels_ = src.num_channels_;
610 energy_ = src.energy_; 609 energy_ = src.energy_;
611 interleaved_ = src.interleaved_; 610 interleaved_ = src.interleaved_;
612 611
613 assert(num_channels_ >= 0);
614 const size_t length = samples_per_channel_ * num_channels_; 612 const size_t length = samples_per_channel_ * num_channels_;
615 assert(length <= kMaxDataSizeSamples); 613 assert(length <= kMaxDataSizeSamples);
616 memcpy(data_, src.data_, sizeof(int16_t) * length); 614 memcpy(data_, src.data_, sizeof(int16_t) * length);
617 } 615 }
618 616
619 inline void AudioFrame::Mute() { 617 inline void AudioFrame::Mute() {
620 memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t)); 618 memset(data_, 0, samples_per_channel_ * num_channels_ * sizeof(int16_t));
621 } 619 }
622 620
623 inline AudioFrame& AudioFrame::operator>>=(const int rhs) { 621 inline AudioFrame& AudioFrame::operator>>=(const int rhs) {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 return unwrapped; 800 return unwrapped;
803 } 801 }
804 802
805 private: 803 private:
806 int64_t last_seq_; 804 int64_t last_seq_;
807 }; 805 };
808 806
809 } // namespace webrtc 807 } // namespace webrtc
810 808
811 #endif // WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_ 809 #endif // WEBRTC_MODULES_INCLUDE_MODULE_COMMON_TYPES_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_processing/vad/voice_activity_detector.cc ('k') | webrtc/modules/media_file/media_file_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698