Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New adaptive mode for ntsc3d decoder #522

Merged
merged 16 commits into from
Aug 4, 2020

Conversation

atsampson
Copy link
Collaborator

@atsampson atsampson commented Aug 3, 2020

3D decoding looks for candidates in the current frame and two fields in either direction, using a similarity heuristic based on the output of the existing 2D decoder. The heuristic is a quality tradeoff: it can produce worse results than the non-adaptive 3D decoder for absolutely still images, but overall the results are much better, particularly for animation and other material with repeated fields/frames.

This is a much-tidied-up version of the branch that @Gamnn has been testing, so there are a couple of known problems that can fool the 3D heuristic: especially bad results from the 2D decoder (e.g. dotcrawl.ldf, Video Essentials frame 29108), and low-saturation colours (e.g. scarf.ldf, VE frame 36430). Any future improvements to ntsc2d will generally benefit ntsc3d as well.

Most of the commits are refactoring Comb; the 3D stuff is all in the last commit. Performance-wise, ntsc2d is a few percent faster than it was before, and ntsc3d is pretty slow (~10 FPS on one core; it would benefit from some vectorisation).

I'll update the docs for ld-chroma-decoder and ld-analyse once this is merged.

This survives from the original version of this code; it looks like the
intent was to use the current and previous lines, not the current line
twice.

Because they're usually very similar, the difference to the result is
tiny -- the cross-colour in the S&W zoneplate is slightly better in a
couple of pixels.
This matches the other decoders -- qreal isn't intended as a general
floating point type; it's Qt's internal type for coordinates (and
doesn't even have to be a floating point type depending on how Qt is
configured).
- The 1D filter actually has negative gain.
- Explain why split2D uses split1D's result.
- Explain how split2D's heuristic works more clearly.
The order of declarations now matches the order in which the functions
are called.
Nearly all of the decoding steps are operating on a single frame, so
they can be a method of FrameBuffer, rather than a method of Comb that
takes a FrameBuffer as a parameter. This simplifies the code quite a bit
because it doesn't need to say currentFrameBuffer->... all over the
place.

The code to load two fields into the framebuffer is also made into a
method, and the Get* helpers are renamed to get*.
Previously the filter delay was also hardcoded as 2, so perhaps the + 2
was originally intended to compensate for the chroma filter (now
disabled).
This simplifies the code a bit later -- e.g. you can subtract the chroma
from the composite signal to get the luma, rather than adding them.
This means we can just create two buffers upfront then cycle between
them, which is marginally more efficient than copying the object.
For 3D decoding in both directions in the future, we can do exactly the
same thing with three buffers.

Since the object isn't being copied any more, there's no need for its
members to be (efficiently) copyable -- so videoParameters and
configuration can be const references, and clpbuffer can be a regular
array.
The maximum size was 910x525 or 911x526 in different places before.
The constructor is the real win here (because it's just
zero-initialisation), but the operators are short enough to benefit too.
There's no need for a wrapper to make this heap-allocated now, so the
buffer can just be an array in Comb::FrameBuffer, and we no longer have
the frame size hardcoded anywhere.
It's not necessarily optical flow now.
1D isn't very useful for real decoding, but it's handy when debugging
the 2D/3D decoders because it's used as the basis for both of them.
@atsampson atsampson added enhancement ld-decode-tools An issue only affecting the ld-decode-tools labels Aug 3, 2020
3D decoding looks for candidates in the current frame and two fields in
either direction, using a similarity heuristic based on the output of
the existing 2D decoder.

The heuristic is a quality tradeoff: it can produce worse results than
the non-adaptive 3D decoder for absolutely still images (because of
spurious chroma returned by the 2D decoder, and content that's similar
enough to fool the 3D heuristic), but overall the results are much
better, particularly for animation and other material with repeated
fields/frames.
@atsampson
Copy link
Collaborator Author

@Gamnn pointed out that the adaptive checkbox didn't work - fixed.

Copy link
Collaborator

@simoninns simoninns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A checked the ld-analyse parts of this and I have no issue with the changes. I'll leave the NTSC filter part to @happycube as he was the real author of it - although I doubt he remembers that far back into the dim and distance past :)

@happycube happycube merged commit d6b5401 into happycube:master Aug 4, 2020
@happycube
Copy link
Owner

Indeed - approved and merged. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ld-decode-tools An issue only affecting the ld-decode-tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants