Reallocate encoded buffer size if needed for VP8. Initially set to the input image size.

Issue may occur for very small input images (e.g. 4x4) when encoded image length > input image size.

BUG=chromium:571594

Review URL: https://codereview.webrtc.org/1626373002

Cr-Commit-Position: refs/heads/master@{#11376}
This commit is contained in:
asapersson
2016-01-26 01:56:32 -08:00
committed by Commit bot
parent e791ffd638
commit ffa3fdc8d6
3 changed files with 14 additions and 0 deletions

View File

@ -63,6 +63,10 @@ TEST_F(TestVp8Impl, TestSwitchingToOneOddStream) {
TestVp8Simulcast::TestSwitchingToOneOddStream(); TestVp8Simulcast::TestSwitchingToOneOddStream();
} }
TEST_F(TestVp8Impl, TestSwitchingToOneSmallStream) {
TestVp8Simulcast::TestSwitchingToOneSmallStream();
}
TEST_F(TestVp8Impl, TestRPSIEncoder) { TEST_F(TestVp8Impl, TestRPSIEncoder) {
TestVp8Simulcast::TestRPSIEncoder(); TestVp8Simulcast::TestRPSIEncoder();
} }

View File

@ -610,6 +610,8 @@ class TestVp8Simulcast : public ::testing::Test {
void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); } void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); }
void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); }
void TestRPSIEncoder() { void TestRPSIEncoder() {
Vp8TestEncodedImageCallback encoder_callback; Vp8TestEncodedImageCallback encoder_callback;
encoder_->RegisterEncodeCompleteCallback(&encoder_callback); encoder_->RegisterEncodeCompleteCallback(&encoder_callback);

View File

@ -979,6 +979,14 @@ int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image,
switch (pkt->kind) { switch (pkt->kind) {
case VPX_CODEC_CX_FRAME_PKT: { case VPX_CODEC_CX_FRAME_PKT: {
uint32_t length = encoded_images_[encoder_idx]._length; uint32_t length = encoded_images_[encoder_idx]._length;
if (pkt->data.frame.sz + length >
encoded_images_[encoder_idx]._size) {
uint8_t* buffer = new uint8_t[pkt->data.frame.sz + length];
memcpy(buffer, encoded_images_[encoder_idx]._buffer, length);
delete[] encoded_images_[encoder_idx]._buffer;
encoded_images_[encoder_idx]._buffer = buffer;
encoded_images_[encoder_idx]._size = pkt->data.frame.sz + length;
}
memcpy(&encoded_images_[encoder_idx]._buffer[length], memcpy(&encoded_images_[encoder_idx]._buffer[length],
pkt->data.frame.buf, pkt->data.frame.sz); pkt->data.frame.buf, pkt->data.frame.sz);
frag_info.fragmentationOffset[part_idx] = length; frag_info.fragmentationOffset[part_idx] = length;