GPU Deinterlacing Techniques

codelogic

Newcomer
I'm looking to implement a module that should be able to identify interlaced content and optionally de-interlace the content using motion adaptive techniques. Detecting interlaced content would mean some sort field/frame/inter-frame analysis since not all videos are correctly flagged as interlaced. In addition, I'd like to implement the algorithm (as much as possible) on the GPU (GLSL/ARB).

Does anyone on B3D have any experience or thoughts regarding this subject?
 
For me, deinterlacing to a very high quality is the hardest problem in video (and has been since I can remember), so Jawed is right!

You can get a lot from tsp's work, and his code's compatibility with PerfHUD is a boon. tritical's website I've never seen before, but it looks worth a bookmark, especially given Jawed's comment.

In my experience, there'll always be a video clip forwarded your way that'll break your deinterlacer in subtle ways, so you'll forever be solving the problem, but if you're willing to persevere it'll teach you plenty.

Good luck!
 
One of the issues I beleive you will run into, is that to do a good job each output pixel will require information from many input pixels something that I don't think GPU's are good at (it is a while since I looked at this, things may be better now).

You will basically have two tasks.
Identify combing artifacts in the frame picture.
Choose/calculate better output sample.

For identifying combing artifacts, a simple mechanism would be to perform a correlation on pixels in the frame picture that are 1 line apart. If the correlation between these is stronger than the correlation with a pixel on the adjacent line then you may have a combing artifact. To improve this you would need to be looking at lines where this is occuring (hence requiring more information from surrounding pixels). There is no doubt plenty of ways this can be done.

Choosing/calculating your output sample can be done a whole number of ways. I would suggest starting simple and simply try and choose if you are going to output the frame pixel or the field pixel. Then start looking at motion steered / interpolated mechanisms.

It is probably worth just trying to implement this on a normal CPU to start and then look at ways you can simplify for a GPU.

CC.
 
You might want to look at these two non-GPU Avisynth/Virtualdub filters from Donald Graft for inspiration:

Avisynth Decomb Filter Package

VirtualDub Smart Deinterlacer

A couple of years ago I have evaluated a lot of deinterlacers for a project and found that especially Smart Deinterlacers gives very good results with a fixed set of parameters for a lot of sources, even problem sources. It may not produce the best still images, but still images don't mean nothing when it comes to the movie experience. I have come across a few filters that produced very high quality still images but the resulting movies were pretty bad compared to the Smart Deinterlacer results.
 
Brave :!:

tritical is your man as far as "deinterlacing" is concerned:

http://web.missouri.edu/~kes25c/

and tsp's work on GPU-based de-noising might give you a good entry into doing your own GPU-based video processing:

http://forum.doom9.org/showthread.php?t=89941

Jawed

Thanks, tritical's page is especially resourceful. Realtime NEDI de-interlacing could be very interesting feature, if ported to the GPU.

Rys said:
In my experience, there'll always be a video clip forwarded your way that'll break your deinterlacer in subtle ways, so you'll forever be solving the problem, but if you're willing to persevere it'll teach you plenty.
That's true and will always be the case for sources that aren't a telecine sequence.

Captain Chickenpants said:
One of the issues I beleive you will run into, is that to do a good job each output pixel will require information from many input pixels something that I don't think GPU's are good at (it is a while since I looked at this, things may be better now).
That's not much of an issue these days, you're basically limited by the maximum number of texture fetches allowed in the fragment shader, which is at least 16 on most modern GPUs I think.

Captain Chickenpants said:
For identifying combing artifacts, a simple mechanism would be to perform a correlation on pixels in the frame picture that are 1 line apart. If the correlation between these is stronger than the correlation with a pixel on the adjacent line then you may have a combing artifact. To improve this you would need to be looking at lines where this is occuring (hence requiring more information from surrounding pixels). There is no doubt plenty of ways this can be done.

Choosing/calculating your output sample can be done a whole number of ways. I would suggest starting simple and simply try and choose if you are going to output the frame pixel or the field pixel. Then start looking at motion steered / interpolated mechanisms.

It is probably worth just trying to implement this on a normal CPU to start and then look at ways you can simplify for a GPU.
Thanks for the suggestion. My intention is for this feature to be part of a media player that can differentiate interlaced content from non-interlaced at runtime. One parameter to consider is how often the frames need to be sampled during playback because some frames, in interlaced sources, will show high correlation both inter-field and intra-field when there is no horizontal motion, leading to a false negative.

Surprisingly I haven't been able to find too much literature or discussion in this area i.e. the automatic detection of sources. I guess this could be because adaptive deinterlacers only deinterlace portions of the frame that it considers interlaced, so it's safe to always have them enabled?

You might want to look at these two non-GPU Avisynth/Virtualdub filters from Donald Graft for inspiration:

Avisynth Decomb Filter Package

VirtualDub Smart Deinterlacer

A couple of years ago I have evaluated a lot of deinterlacers for a project and found that especially Smart Deinterlacers gives very good results with a fixed set of parameters for a lot of sources, even problem sources. It may not produce the best still images, but still images don't mean nothing when it comes to the movie experience. I have come across a few filters that produced very high quality still images but the resulting movies were pretty bad compared to the Smart Deinterlacer results.
The Smart Deinterlacer and Decomber source code is very helpful. Looks like it implements an auto detection algorithm, I'll check it out.

Thanks to everyone for their input.
 
Back
Top