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
This commit is contained in:
parent
92f4018d80
commit
c86bbbaa93
@ -27,12 +27,14 @@ class AudioEncoder {
|
||||
: 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
|
||||
|
@ -150,6 +150,7 @@ void AudioEncoderCng::EncodeInternal(uint32_t rtp_timestamp,
|
||||
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;
|
||||
}
|
||||
|
@ -261,6 +261,7 @@ TEST_F(AudioEncoderCngTest, EncodePassive) {
|
||||
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 @@ TEST_F(AudioEncoderCngTest, MixedActivePassive) {
|
||||
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
|
||||
|
@ -202,6 +202,7 @@ void AudioEncoderOpus::EncodeInternal(uint32_t rtp_timestamp,
|
||||
info->payload_type = payload_type_;
|
||||
// Allows Opus to send empty packets.
|
||||
info->send_even_if_empty = true;
|
||||
info->speech = r > 0;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -88,6 +88,7 @@ void AudioEncoderCopyRed::EncodeInternal(uint32_t rtp_timestamp,
|
||||
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_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user