Add GetChunkLength to LappedTransform.

R=andrew@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/56529004

Cr-Commit-Position: refs/heads/master@{#9301}
This commit is contained in:
Michael Graczyk 2015-05-27 17:09:47 -07:00
parent fec2c6d7eb
commit 9b720f7016
2 changed files with 31 additions and 1 deletions

View File

@ -57,6 +57,14 @@ class LappedTransform {
// |out_chunk|. Both buffers are caller-owned.
void ProcessChunk(const float* const* in_chunk, float* const* out_chunk);
// Get the chunk length.
//
// The chunk length is the number of samples per channel that must be passed
// to ProcessChunk via the parameter in_chunk.
//
// Returns the same chunk_length passed to the LappedTransform constructor.
int get_chunk_length() const { return chunk_length_; }
private:
// Internal middleware callback, given to the blocker. Transforms each block
// and hands it over to the processing method given at construction time.

View File

@ -177,5 +177,27 @@ TEST(LappedTransformTest, Callbacks) {
ASSERT_EQ(kChunkLength / kBlockLength, call.block_num());
}
} // namespace webrtc
TEST(LappedTransformTest, get_chunk_length) {
const int kBlockLength = 64;
FftCheckerCallback call;
const float window[kBlockLength] = {};
// Make sure that get_chunk_length returns the same value passed to the
// LappedTransform constructor.
{
const int kExpectedChunkLength = 512;
const LappedTransform trans(1, 1, kExpectedChunkLength, window,
kBlockLength, kBlockLength, &call);
EXPECT_EQ(kExpectedChunkLength, trans.get_chunk_length());
}
{
const int kExpectedChunkLength = 160;
const LappedTransform trans(1, 1, kExpectedChunkLength, window,
kBlockLength, kBlockLength, &call);
EXPECT_EQ(kExpectedChunkLength, trans.get_chunk_length());
}
}
} // namespace webrtc