Skip to content

Commit

Permalink
[VCM] do not copy truncated frame data
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe committed Apr 13, 2021
1 parent 1534c2a commit 2084305
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,21 +418,20 @@ bool OverwriteFrame(IMediaSample* frame, wil::com_ptr_nothrow<IMFSample>& image)
LOG("VideoCaptureProxyPin::OverwriteFrame FAILED imageData");
return false;
}
bool success = true;
if (imageSize > frameSize && failed(frame->SetActualDataLength(imageSize)))
{
char buf[512]{};
sprintf_s(buf, "Error: overlay image size %lu is larger than frame size %lu", imageSize, frameSize);
LOG(buf);
imageSize = frameSize;
success = false;
imageBuf->Unlock();
return false;
}

std::copy(imageData, imageData + imageSize, frameData);
imageBuf->Unlock();
frame->SetActualDataLength(imageSize);

return success;
return true;
}

VideoCaptureProxyFilter::VideoCaptureProxyFilter() :
Expand Down Expand Up @@ -489,6 +488,10 @@ VideoCaptureProxyFilter::VideoCaptureProxyFilter() :
LOG("Couldn't overwrite frame with image with all available quality modes.");
}
}
if (!overwritten && !_overlayImage)
{
OverwriteFrame(_pending_frame, _blankImage);
}
}

_pending_frame = nullptr;
Expand Down

0 comments on commit 2084305

Please sign in to comment.