fstark / macflim

MacFlim flim player source code and utilities
MIT License
90 stars 3 forks source link

Garbage on screen when flim has small stable black areas on top of mostly white background #6

Closed fstark closed 2 years ago

fstark commented 2 years ago

How to reproduce:

Have a 60fps video that starts with a mostly white image with large black patches, and play on real hardware.

Result:

The black patches contain large white patches.

Expected result:

Normal black is black

fstark commented 2 years ago

What is happening is that the screen starts completely black, and most of the screen is white. So, the encoder choses to use the lines codec and fill the screen whit white, using later frames to add back the black areas.

However, the lines codec on the se30 is slightly over-enthusiastic and the amount of available cpu cycles, and cannot be truly executed in the time set up.

So the code is still turning the original black to white, when the second frame wants to put black back on top of the white (which isn't there yet). After this frame, the preceeding one finishes to fill screen with white, replacing the new black by white, which will stay there, as the encoder is convinced that those parts of the screen are black.

In general, this is not a problem, because:

a) In a typical 24 fps flim, there are two or 3 cycles available, so the screen update batch has less risk to slip behind

b) The error is quickly corrected as flim updates

However, a) does not apply in a 60fps flim, and b) when a flim has a long staying black piece in an otherwise white settings (for instance black borders), b) never occurs.

Fix would be to refuse to update when the preceeding frame isn't completed. This will unfortunately break sound in those cases.