Kodi Community Forum

Full Version: Force Film Mode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hollywood feature films and most TV shows on Region 1 DVDs are "soft-telecined," meaning the video is actually encoded progressively at 23.976fps. Pulldown flags are added to instruct the MPEG-2 decoder (e.g. consumer DVD player) to output 29.97fps NTSC video. Commercial ripping software (e.g. MakeMKV) maintains the pulldown flags.

Kodi on the Rasperry Pi 2 currently decodes these videos like a consumer DVD player -- outputting telecined 29.97fps NTSC video. Since interlaced video looks ugly on modern progressive displays, the Pi 2 then applies a de-interlacing filter (e.g. MMAL-Advanced). Unfortunately, the MMAL-Advanced filter cannot fully reconstruct the source image. The picture quality difference between the progressive source video and the MMAL-Advanced de-interlaced output is night-and-day, especially on content like scrolling credits. Any laymen could spot the difference if asked.

A "Force Film" mode that simply ignores the Repeat Field Flag (RFF) would provide a significant picture quality boost for owners of Region 1 content.



EDIT: This is a follow-on to my previous thread on IVTC. As I've learned more about the topic, I feel that thread is better suited to discussing "hard-telecine" content (i.e. content encoded as 29.97fps NTSC video).
Start with providing a sample file encoded in the way you describe.
Give an example of a media player that plays the file how you want (e.g. does kodi on windows do what you want?)
Sample File: https://www.dropbox.com/s/x8zwooq2n7sc5a...s.mkv?dl=0

VLC plays the file how I want using it's Film NTSC (IVTC) deinterlace mode. I'll report back after trying it with Kodi on Windows.



Edit: Not available with a stock Kodi install on my 2009-vintage Windows laptop. Only had "Blend," "Deinterlace - Half" and "Deinterlace" as options. I can't confirm, but I believe MPlayer plays files how I want. They tout the feature in their man pages.

If it helps, here's another reference to clarify what I'm talking about.
Yep - there are two approaches for 23.976p carried using 3:2 pull-down in a 59.94i container (aka i29.97).

Both require that you detect the redundant field, discard it, creating a 47.952i 2:2 sequence. Then you de-interlace this to 23.976p. If you have a repeated-field flagged source then this step is redundant.

Then you either output this at 23.976p by changing the output refresh rate (which means your output refresh rate is NOT the same as your source video frame rate) OR you then add the 3:2 repetition in the progressive domain and generate a 59.94p (not i) sequence from the 23.976p content (so you get 3 clean repeated source frames followed by 2 clean repeated source frames)
I remember under windows 7 i had no problem on dvd ntsc. MPC-HC with external decoder of cyberlink or arcsoft (because was need idct) just ignored pulldown flags and played 23,976. RPi recognises this like 29,97
But i don't watch dvd any more Big Grin
(2015-12-17, 17:59)ZwartePiet Wrote: [ -> ]VLC plays the file how I want using it's Film NTSC (IVTC) deinterlace mode. I'll report back after trying it with Kodi on Windows.

So can any player do this automatically (i.e. without the user having to know it is IVTC?)

I had a look at what comes out of our decoder (with your sample) and it doesn't seem to have enough information to detect this automatically:
http://paste.ubuntu.com/14098583/

The interesting numbers follow the "interlace:" tag. The first number is one of these:
Code:
INTERLACE_TYPE_FRAME = 0,               //!< Progressive frame
INTERLACE_TYPE_TOP_FIELD_FIRST = 1,     //!< Frame consists of two fields, top field first in display order
INTERLACE_TYPE_BOTTOM_FIELD_FIRST = 2,  //!< Frame consists of two fields, bottom field first in display order

// Flags which are combined to form the isolated-field values
INTERLACE_TYPE_SINGLE_FIELD_FLAG = 4,     //!< Only a single field is present
INTERLACE_TYPE_BOTTOM_FIELD_FLAG = 8,     //!< The field present is a bottom field
INTERLACE_TYPE_FIELD_CLONED_FLAG = 0x10,  //!< The field which is present has been cloned into the other field.

and the third number is the repeat count:
Code:
//! \c repeat_count is always specified in units of one field.  When
//! \c repeat_count == 1, the first captured field (see \c top_field_first) is
//! to be repeated once.  When \c repeat_count is even, i.e.
//! \c repeat_count == 2, 4, ... the whole frame repeat once, twice, etc.
unsigned int repeat_count;

But almost every frame is flagged as frame/progressive without a repeat count.
There seem to be a random scattering of frames reported as TFF/BFF with a repeat but not enough to automatically IVTC.
From:
https://wiki.videolan.org/Deinterlacing/
Code:
Inverse telecine algorithms try to extract the original progressive film frames and to display them at the original framerate (24 pictures per second). In the ideal case, this perfectly restores the progressive signal. There is no loss of information and no need to generate anything out of thin air.

Due to practical reasons, these algorithms are always based on analyzing the picture. They are not and cannot be perfectly accurate, but in practice they work well for most telecined sources.

So that suggests that VLC cannot use flags from the decoder and must analyse the pixels to work out the type of frame. That's likely to be too heavy to handle on a Pi (certainly for HD) and far from simple to implement.
Here is the original VLC addition for IVTC: https://mailman.videolan.org/pipermail/v...77804.html
Gives an idea of the complexity of this request.
I think it's heavy for HD, easy for SD Smile. Under windows i used single core cpu and onboard gpu of laptop. I can upload a piece of vob from classic dvd ntsc if you need it.
(2015-12-19, 17:50)popcornmix Wrote: [ -> ]Here is the original VLC addition for IVTC: https://mailman.videolan.org/pipermail/v...77804.html
Gives an idea of the complexity of this request.

It seems that the complexity exists because VLC's filter was designed to process hard telecined content. Reconstructing a progressive frame from a telecined source requires more computational power than preventing a player from telecining a progressive source on the fly. Segments from the link you provided:

Quote:Simply put, this filter is targeted for NTSC movies and especially
anime. Virtually all 1990s and early 2000s anime is hard-telecined.
Because the source material is like that, the issue affects also
virtually all official R1 (US) anime DVDs, too.

Quote:Theoretically, this whole mess could be avoided, if the original
material is pure 24fps progressive. There are flags for 3:2 pulldown that allow storing
the original progressive frames on the DVD. When set, the DVD player will apply "soft"
pulldown, if the output is set to 60 fields per second interlaced. However, in practice any
material with its origins in Asia (including virtually all official US (R1) anime DVDs) is
always hard-telecined. There are cadence position flags for hard-telecined material, too,
but in practice these are never set correctly. Combined with rendering true
interlaced effects on top of the hard-telecined stream, we have what can only be described as
a monstrosity.
After reading up on how progressive scan DVD players work, it seems that they all use specialized de-interlacing chips. They essentially follow the same cadence-detection method as VLC, but do it in hardware. The reason everyone seems to adopt this method is that it's the best way to cover all contingencies being put out from an industry that (to me) looks like it's held together with baling wire. There are dozens of variations on how video is shot, edited and ultimately authored onto a DVD.

The bulk of Hollywood DVD movies seem to use the following format. Getting a "force film" mode that detects and outputs progressive video from this type of structure would probably do 80% of the job for a fraction of the coding effort. Everything else can fall back to conventional de-interlacing.

Code:
MPEG Picture    Film Frame    Picture_Structure    Progressive_Frame    Repeat_First_Field    Top_Field_First
     1              1              Frame                 True                  True                 True
     2              2              Frame                 True                  False                False
     3              3              Frame                 True                  True                 False
     4              4              Frame                 True                  False                True

If the !/$ isn't there to implement this feature, then no sweat.
Discs with about such mediainfo mpc-hc played as 23.976
Code:
Video
ID                                       : 224 (0xE0)
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : Main@Main
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Custom
Format settings, GOP                     : Variable
Duration                                 : 29mn 1s
Bit rate mode                            : Variable
Bit rate                                 : 3 938 Kbps
Maximum bit rate                         : 7 864 Kbps
Width                                    : 720 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 23.976 fps
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Scan order                               : 2:3 Pulldown
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.475
(2015-12-20, 02:53)ZwartePiet Wrote: [ -> ]After reading up on how progressive scan DVD players work, it seems that they all use specialized de-interlacing chips. They essentially follow the same cadence-detection method as VLC, but do it in hardware. The reason everyone seems to adopt this method is that it's the best way to cover all contingencies being put out from an industry that (to me) looks like it's held together with baling wire.

Yep - though the situation is complicated because you can have multiple cadences on-screen at the same time. Think of a studio TV show shot at 60i running a 24p clip in 3:2, then animating a 60i caption or ticker over this. Life in TV is complicated.
Hmm, it appears that most of my DVD collection does play progressively. The Pi's media player does ignore pulldown flags for most major Hollywood releases. The sample clip I posted must have been an oddball. Beyond MediaInfo, I can't find any open source tools on OS X to analyze the video structure, nor can I say that I fully understand Popcornmix's description in post #6. I don't think the clip is hard-telecined. It may just a be a weird use of pulldown flags that is reversible without a complex IVTC filter. Huh

(2015-12-21, 00:38)noggin Wrote: [ -> ]Yep - though the situation is complicated because you can have multiple cadences on-screen at the same time. Think of a studio TV show shot at 60i running a 24p clip in 3:2, then animating a 60i caption or ticker over this. Life in TV is complicated.

After reading up on Avisynth filters, putting a few sample clips through Handbrake with different settings and researching how content was actually filmed... all I can say is my goodness. You speak the truth. At this point I have a newfound appreciation for the Pi's native de-interlacer. As far as I'm concerned, it really is good enough.

Sorry to be a bother folks. Thought I found a worthwhile area of improvement. Reality is always more complicated... Tongue
(2015-12-22, 10:41)ZwartePiet Wrote: [ -> ]Sorry to be a bother folks. Thought I found a worthwhile area of improvement. Reality is always more complicated... Tongue

Annoyingly - with some sources it IS worth considering. 3:2 is the work of the devil - and with Blu-ray it is pretty much consigned to history. But with broadcast TV and DVD in 60Hz regions it is still a fact of life. In some cases it can be removed - but I suspect the reality is that this is best done off-line and not by a live deinterlacer.