Fix glScalerCalculator not clearing background in FIT mode
In FIT mode, the image is scaled in an aspect ratio preserving way. That means, the calculator does not render a full-screen quad. The letterbox areas are not drawn. This can cause artifacts, e.g. when MediaPipe reuses the GPU buffer from some other operation. This CL always clears the render target in FIT mode. PiperOrigin-RevId: 566562715
This commit is contained in:
parent
94cda40a83
commit
0ed199186b
|
@ -292,6 +292,14 @@ absl::Status GlScalerCalculator::Process(CalculatorContext* cc) {
|
||||||
GetOutputFormat());
|
GetOutputFormat());
|
||||||
|
|
||||||
helper_.BindFramebuffer(dst);
|
helper_.BindFramebuffer(dst);
|
||||||
|
|
||||||
|
if (scale_mode_ == FrameScaleMode::kFit) {
|
||||||
|
// In kFit scale mode, the rendered quad does not fill the whole
|
||||||
|
// framebuffer, so clear it beforehand.
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(src1.target(), src1.name());
|
glBindTexture(src1.target(), src1.name());
|
||||||
if (src2.name()) {
|
if (src2.name()) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user