Add speech flag to EncodedInfo
The flag indicates if the encoded bitstream is speech or comfort noise.
COAUTHOR=kwiberg@webrtc.org
R=jmarusic@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/42629004
Cr-Commit-Position: refs/heads/master@{#8598}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8598 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h
index 738669d..c0ec210 100644
--- a/webrtc/modules/audio_coding/codecs/audio_encoder.h
+++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h
@@ -27,12 +27,14 @@
: encoded_bytes(0),
encoded_timestamp(0),
payload_type(0),
- send_even_if_empty(false) {}
+ send_even_if_empty(false),
+ speech(true) {}
size_t encoded_bytes;
uint32_t encoded_timestamp;
int payload_type;
bool send_even_if_empty;
+ bool speech;
};
// This is the main struct for auxiliary encoding information. Each encoded
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
index e14ac93..14b210c 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
@@ -150,6 +150,7 @@
info->encoded_timestamp = first_timestamp_in_buffer_;
info->payload_type = cng_payload_type_;
info->send_even_if_empty = true;
+ info->speech = false;
last_frame_active_ = false;
break;
}
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
index 03e7ba0..c5d436e 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc
@@ -261,6 +261,7 @@
if ((i % (config_.sid_frame_interval_ms / 10)) < kBlocksPerFrame) {
// If so, verify that we got a CNG encoding.
EXPECT_EQ(kCngPayloadType, encoded_info_.payload_type);
+ EXPECT_FALSE(encoded_info_.speech);
EXPECT_EQ(static_cast<size_t>(config_.num_cng_coefficients) + 1,
encoded_info_.encoded_bytes);
EXPECT_EQ(expected_timestamp, encoded_info_.encoded_timestamp);
@@ -282,19 +283,23 @@
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
.Times(6);
EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kActive));
+ EXPECT_TRUE(encoded_info_.speech);
// First half of the frame is active speech.
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
.Times(6);
EXPECT_TRUE(CheckMixedActivePassive(Vad::kActive, Vad::kPassive));
+ EXPECT_TRUE(encoded_info_.speech);
// Second half of the frame is active speech.
EXPECT_CALL(mock_encoder_, EncodeInternal(_, _, _, _, _))
.Times(6);
EXPECT_TRUE(CheckMixedActivePassive(Vad::kPassive, Vad::kActive));
+ EXPECT_TRUE(encoded_info_.speech);
// All of the frame is passive speech. Expect no calls to |mock_encoder_|.
EXPECT_FALSE(CheckMixedActivePassive(Vad::kPassive, Vad::kPassive));
+ EXPECT_FALSE(encoded_info_.speech);
}
// These tests verify that the audio is partitioned into larger blocks before
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 4739018..e4779aa 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -202,6 +202,7 @@
info->payload_type = payload_type_;
// Allows Opus to send empty packets.
info->send_even_if_empty = true;
+ info->speech = r > 0;
}
} // namespace webrtc
diff --git a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
index afc6391..92e1c0b 100644
--- a/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
+++ b/webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.cc
@@ -88,6 +88,7 @@
CHECK(secondary_encoded_);
memcpy(secondary_encoded_.get(), encoded, info->encoded_bytes);
secondary_info_ = *info;
+ DCHECK_EQ(info->speech, info->redundant[0].speech);
}
// Update main EncodedInfo.
info->payload_type = red_payload_type_;