Hi Joachim, I hope I can help.
DVDs may only use either 29.97fps NTSC or 25fps PAL. As such, they
are authored only for displaying on interlaced output. However, to save
space on the DVD and improve quality, the DVD may offload the work of
performing pulldown to the player. For each video frame on a DVD, the
following flags are used:
progressive_frame: indicates that the frame is progressive or
top_field_first: indicates which field of the interlaced image is
to be displayed first on the video output.
repeat_first_field: indicates that the first field of the frame should
be displayed twice (for pulldown).
progressive_sequence: used to indicate that the progressive frame
should be displayed multiple times. I have yet
to see a DVD use this, and I suspect it is not
allowed for DVD-Video discs.
The repeat_first_field/top_field_first flags are used to tell the
player how to perform pulldown. Here is some output from my app looking
at how the Mallrats: Collector's Edition DVD uses the pulldown flags:
[ 0: 0] I Top Bot Top Progressive [rff=1, tff=1]
[ 1: 1] B Bot Top Progressive [rff=0, tff=0]
[ 2: 2] B Bot Top Bot Progressive [rff=1, tff=0]
[ 3: 3] P Top Bot Progressive [rff=0, tff=1]
Here, I show the frame picture coding type, the fields to output (per
the rff/tff flags), and whether the frame is progressive or interlaced.
This DVD contains progressive frames (24fps worth of them) with flags to
tell the player how to bring it up to 30fps. As we can see above,
libmpeg2 gives my application 4 frames, and tells me how to output 10
fields (or 5 "frames" - remember that interlacing removes the concept of
frames, since the two fields aren't displayed concurrently).
While the DVD is an NTSC DVD where the frame_rate value is 29.97fps,
the DVD actually stores 24fps data and tells the player how to upscale
it. Nowhere in the MPEG2 headers or the IFO files does it indicate
which parts of the DVD use these flags: the player must perform the
pulldown as it goes.
With that in mind, also note that the DVD may decide to switch between
storing progressive frames or interlaced frames at any time: even within
a cell or VOBU, making prescanning difficult. Here is an example from
the same DVD:
[ 44: 44] B Top Bot Top Progressive
[ 45: 45] P Bot Top Progressive
[ 46: 46] P Bot Top Top Progressive
[ 47: 47] P Top Bot Progressive
[ 48: 48] B Top Bot Interlaced
[ 49: 48] B Top Bot Interlaced
[ 50: 48] I Top Bot Interlaced
[ 51: 48] B Top Bot Interlaced
[ 52: 48] B Top Bot Interlaced
At frame 48 the DVD switches from progressive frames at 24fps to
interlaced frames at 30fps: this point in the movie was edited at
30fps, after performing pulldown. When xine plays this DVD, every 2nd
and 3rd frame (out of 5) looks like crap on a computer monitor. In
order to correctly play this movie back on a computer monitor, some sort
of pulldown detection must occur.
To complicate things slightly, some DVDs only set the
progressive_frame flag when they use repeat_first_field. An example of
this (from the Ghost In The Shell DVD) is:
[ 62: 60] I Bot Top Interlaced
[ 63: 61] B Bot Top Bot Progressive
[ 64: 62] B Top Bot Interlaced
[ 65: 63] P Top Bot Top Progressive
[ 66: 64] B Bot Top Interlaced
[ 67: 65] B Bot Top Bot Progressive
This is something to consider in your algorithm.
> I found that on a DVD the interlaced flag is always set in the mpeg
I think I have clarified this above.
> I have a G400 and use the backendscaler for displaying the stream.
> There I can do hardware deinterlacing if need be, but of course I want
> to display progressive if the stream is progressive.
The G400 doesn't need to do hardware deinterlacing, it outputs to an
> Does this also mean that the material is progressive video with 24 fps
> and interlaced video with 30 fps ?
If progressive_frame == 1, then you know for sure the frame is
progressive. Otherwise, you don't know anything. It may be interlaced,
it may be progressive, you don't know. More heuristics are necessary.
> Do you know how this is on a PAL DVD.
With PAL, there is no pulldown. 24fps films are played back at a
higher speed so that they run at 25fps. If the DVD is nice, it should
set progressive_frame to 1, indicating to you conclusively that the
frames are progressive and you don't need to do any work. Otherwise,
you will have to run some algorithms to test for combing before making
any decisions on what to do with it.
I'm attaching my current code for dealing with detecting pulldown. It
is very unoptimized, since I'm writing it first for a recompressor,
where speed is not a big issue. It also isn't perfect, and parts of it
are unimplemented. But it may help you understand stuff a bit.
My code is part of a recompressor where I cannot output 60 frames per
second, nor can I switch framerate in the middle, in case you're
wondering. A good project on deinterlacing where we may be able to
borrow some algorithms is at:
Billy Biggs bbiggs@...