[MPlayer-dev-eng] Re: More on inverse telecine!

Billy Biggs vektor at dumbterm.net
Mon Apr 14 13:04:35 CEST 2003


Andriy N. Gritsenko (andrej at lucky.net):

> When I wrote my dint filter then I've started from comparison with
> previous frame too. But then I've found it gives me not the best
> results.  Anyway I don't know what your sources are but on two DVDs
> I've encoded were no standard telecine at all - somewhere they seemed
> as 30fps source, somewhere as 24fps with telecine, somewhere as source
> with about 60% of interlaced frames. The best results I've got with
> pp=lb,dint=0.2:0.002 but anyway there are still interlaced frames and
> some good frames was skipped too. :(  I still wonder if there is a way
> to really deinterlace such kind of sources...

  NTSC DVDs are always done for an _output_ framerate of 59.94 fields
per second, however, you are allowed to mark frames as being progressive
and having a duration of three fields.  There are two flags on each
frame of video: top_field_first, and repeat_first_field, which you must
watch.  They lets you encode 23.976fps film sequences on a DVD.  It
usually looks like this:

   Frame   Top_Field_First  Repeat_First_Field   Output fields
     1         1                   1             Top Bot Top
     2         0                   0             Bot Top
     3         0                   1             Bot Top Bot
     4         1                   0             Top Bot

  So the output (in fields) looks like:   1 1 1 2 2 3 3 3 4 4, a perfect
pulldown pattern.  Notice that if you use these flags, the framerate of
the video is effectively 23.976fps progressive, if you just look at the
encoded frames.

  But if you expand everything, the output field rate is still exactly
59.94fps, and this is all you need to keep constant on a DVD.  That is,
you can use these flags for a while, then switch back to normal
interlaced content, then switch back to the flags.  For example:

     1         1                   1             Top Bot Top
     2         0                   0             Bot Top
     3         0                   1             Bot Top Bot
     4         1                   0             Top Bot
     5         1                   0             Top Bot
     5         1                   0             Top Bot
     6         1                   0             Top Bot
     7         1                   0             Top Bot
     8         1                   0             Top Bot
     9         1                   1             Top Bot Top
    10         0                   0             Bot Top

  That is perfectly valid, and in fact, you see this alot.  A great
example is the 'Mallrats' NTSC DVD.  It has a special 'angle' track
where for some chapters, it shows a video sequence of the director and
some of the actors discussing the movie.  This is shot on video at
59.94fps.  While this angle is going on, the film sequence must be
expanded as interlaced frames, otherwise it would lag behind the other
angle including the director.  So, some chapters are interlaced 29.97,
other chapters are progressive 23.976.

  Even worse, some DVDs like my copy of Akira seem to have been touched
up at video speed.  That is, you'll see short sequences of like 10
interlaced frames, then back to 23.976fps encoded material.

  You may think that all is lost, but no.  There are two approaches.
The first is to have the MPEG2 decoding layer expand all content on the
DVD to 59.94 interlaced fields per second, and pass it to a heuristics
engine like vf_detc.  You may say: why do that, when the flags tell you
exactly what to do!  However, remember that if you do this, copied
fields will be byte-for-byte identical, and they'll be easy to test for,
and secondly this will get around some problem cases.

  The other method is to enable pulldown detection whenever you see
interlaced frames, and remember where you were in the pulldown sequence
based on what sequence the flags were telling you.  I do this in my DVD
player app 'movietime' (www.sf.net/projects/movietime).  Whenever I see
interlaced content, I fill my diff_factor history with the ideal based
on what I was decoding, and assume the interlaced content is pulldown
and go at it.  It works ok.

  Check out my 'DVD tech page' where it discusses some very difficult
cases in pulldown encoding:

  http://vektor.theorem.ca/dvd/tech/

  Hope that helps,
  -Billy




More information about the MPlayer-dev-eng mailing list