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:
@ -63,6 +63,10 @@ TEST_F(TestVp8Impl, TestSwitchingToOneOddStream) {
|
||||
TestVp8Simulcast::TestSwitchingToOneOddStream();
|
||||
}
|
||||
|
||||
TEST_F(TestVp8Impl, TestSwitchingToOneSmallStream) {
|
||||
TestVp8Simulcast::TestSwitchingToOneSmallStream();
|
||||
}
|
||||
|
||||
TEST_F(TestVp8Impl, TestRPSIEncoder) {
|
||||
TestVp8Simulcast::TestRPSIEncoder();
|
||||
}
|
||||
|
||||
@ -610,6 +610,8 @@ class TestVp8Simulcast : public ::testing::Test {
|
||||
|
||||
void TestSwitchingToOneOddStream() { SwitchingToOneStream(1023, 769); }
|
||||
|
||||
void TestSwitchingToOneSmallStream() { SwitchingToOneStream(4, 4); }
|
||||
|
||||
void TestRPSIEncoder() {
|
||||
Vp8TestEncodedImageCallback encoder_callback;
|
||||
encoder_->RegisterEncodeCompleteCallback(&encoder_callback);
|
||||
|
||||
@ -979,6 +979,14 @@ int VP8EncoderImpl::GetEncodedPartitions(const VideoFrame& input_image,
|
||||
switch (pkt->kind) {
|
||||
case VPX_CODEC_CX_FRAME_PKT: {
|
||||
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],
|
||||
pkt->data.frame.buf, pkt->data.frame.sz);
|
||||
frag_info.fragmentationOffset[part_idx] = length;
|
||||
|
||||
Reference in New Issue
Block a user