Originally Posted by nevcairiel
I think i found a rather crude yet theoretically working solution for playback of those mixed soft-telecined / hard-telecined files with CUVID deinterlacing.
A soft-telecine stream typically looks like this:
rtStart: 0, diff: 0, key: 1, repeat: 0, interlaced: 1, tff: 1
rtStart: 333667, diff: 333667, key: 0, repeat: 1, interlaced: 0, tff: 1
rtStart: 834222, diff: 500555, key: 0, repeat: 0, interlaced: 1, tff: 0
rtStart: 1167889, diff: 333667, key: 0, repeat: 1, interlaced: 0, tff: 0
rtStart: 1668333, diff: 500444, key: 0, repeat: 0, interlaced: 1, tff: 1
rtStart: 2002000, diff: 333667, key: 0, repeat: 1, interlaced: 0, tff: 1
rtStart: 2502556, diff: 500556, key: 0, repeat: 0, interlaced: 1, tff: 0
rtStart: 2836222, diff: 333666, key: 0, repeat: 1, interlaced: 0, tff: 0
rtStart: 3336667, diff: 500445, key: 0, repeat: 0, interlaced: 1, tff: 1
rtStart: 3670333, diff: 333666, key: 0, repeat: 1, interlaced: 0, tff: 1
The problem:
- Switching the deinterlacer on/off seems to cause performance issues
- The timestamps of soft-telecined material match a 60 fps stream, instead of 24p (not really a "bad" issue as long as the renderer will match to vsync anyway)
- Double-rate deinterlacing of soft-telecined material causes quite odd results (only the "interlaced: 1" frames above get doubled)
My idea:
- Detect soft-telecined (constant repeat 0/1 switching pattern)
- If detected:
--- Force deinterlacing of all frames, BUT, limit it to 25p/30p mode (no frame doubling) - this eliminates all combing, and doesnt require switching between interlaced/progressive
--- Delay frames with the repeat flag by one field, giving proper 24p timestamps (as an alternative, show frames without the repeat flag one field earlier)
The combination of those options would ensure that there is no combing because the full adaptive deinterlacer is being used, in addition, the timestamps should be smoothed out to ensure smooth playback, even with "stupid" renderers.
The only challenge is properly detecting the soft-telecine. Assuming the pattern is always constant, i could just activate it as soon as i find a repeat flag and turn it off again when there are 2-3 frames without a flag, but that will need investigation on different streams.
Thoughts?
Implementation would probably be somewhat simple.
Note: This mostly only applys to CUVID decoding and deinterlacing. Software decoding is another matter entirely, because i cannot control deinterlacing there.
|