Raspberry Pi deinterlacing of 1080i

This may well be a Kodi issue, but I thought I may as well check.

I decided to splash out and pay for the MPEG-2 and VC-1 hardware decoding keys on my Raspberry Pi. Two things I’ve tried playing with it are a 1080i/60 deinterlacing test pattern (designed to test for whether it can pick up a 2:3:2:3 pattern and engage film mode) and a bit of the original Planet Earth which is a 1080p/25 stream stored on the disk as 1080i/50.

The first thing that was interesting about the 1080i/50 clip is that the output mode defaulted to 1080p/25Hz (where the Vero 4K defaults to 1080p/50Hz with identical whitelist settings).

The second thing was that it was jerky as hell. After playing around with the settings a bit I found that it played smoothly if I set the Deinterlace mode to “Off”, but is jerky with any other option - including Auto-select. This tells me that Auto-select is not doing what it should be doing when it encounters a shot-progressive-but-stored-as-interlaced 1080i source.

On the test pattern, if the deinterlace mode is set to Off then it correctly deinterlaces it using a weave, but if it’s set to anything else, it’s clearly deinterlacing it in video-mode rather than film-mode (with consequent loss of resolution). This probably also accounts for the jerkiness with the 1080i/50 clip - if it’s deinterlacing it as video and then displaying only alternate frames, you would likely get that effect.

I can’t say for certain if this is specific to h/w accelerated VC-1 playback - I don’t have a 1080i test clip in another codec to check. But it could be a general problem.

The Vero 4K, incidentally, has similar issues except that there’s no user-changeable deinterlace setting, so you can’t set Deinterlace to off. But it’s a bit less visible because it defaults to 1080p/50 rather than 1080p/25, so you have resolution loss but no jerkiness unless you set the output to 1080p/25 manually.

Which player did you use?

If you mean “player” as in MMAL or OMX, I was using MMAL.

This is probably a Pi bug. I’m not sure if it likely to be fixed.

Is this something that should (maybe) be raised as a Kodi issue, or is it an OSMC problem?

Sounds like neither OSMC nor Kodi would be the one to fix but the video implementation on the Pi

As Kodi is removing platform specific implementations like MMAL and OMX in the near future, I’m not sure how much effort will be put in to this, particularly as new Pis don’t have hardware acceleration for MPEG2 or VC1

I don’t see any reason to assume that the issue is specific to VC-1; and people are presumably going to continue to use Kodi as a front-end for 1080i TV broadcasts for quite some time.

If you don’t think it is codec or platform specific, then it’s likely a Kodi issue.

I tried running the same clips on Pi, Vero 4K+, and Nvidia Shield TV.

All three devices deinterlace the 1080i/60 clip correctly if hardware acceleration is turned off; all three get it wrong by default if hardware acceleration is on. On the Pi using MMAL you can correct the issue by setting Deinterlacing to Off; the other two devices don’t give you that option.

None of the three is powerful enough to decode the 1080i/50 clip in software. (Surprised me a little - I thought the Shield might be able to).

For the 1080i/50 clip in hardware, the Vero 4K always screws up 1080p/25; the Pi gets it wrong by default but you can correct the problem by turning Deinterlacing off; and the Shield gets 1080p/25 correct by default.

Vero and Shield default to 1080p/50 output (which in the Vero’s case hides the issue a bit); the Pi defaults to 1080p/25, which highlights the problem with the default setting.

So… adding all that lot up, I guess we’re probably looking at several different platform-specific issues on several platforms rather than a single Kodi problem; so it’s probably not going to be worth raising it.

I’ll see what we can do on the Vero side at least.

1 Like

I have lots of 1080i/50 material and have the hardware decoding keys installed on all my Pi’s (I have OSMC and LE), and with deinterlacing set to auto-select, I have never encountered jerky playback, whether the source was natively progressive and then encoded as interlaced, or natively interlaced at source. OMX and MMAL are both fine in terms of motion (the auto-select tends to pick advx2).

However, I just looked at a couple of progressive VC1 1080i/50 titles on a Pi and explored disabling deinterlacing via MMAL, and I would say that there is indeed an increase in resolution. So although the auto-select does fine with my library in terms of motion (and resolution is pretty good too), I now have a mechanism for getting the best-possible resolution (at least via the Pi), so thanks @angry.sardine for highlighting that MMAL allows for user input to force weave.

It would be good to see what developments could be implemented for the Vero, as I find it to be a little behind the Pi in this area.

You won’t see actual jerkiness unless the output is set to 1080p/25 rather than 1080p/50. It could be that the Pi doesn’t generally make that choice - either there’s something odd about my test clip that triggers it or it’s because I have a whitelist set up and 1080p/25 whitelisted.

But yeah, as you say, even with 1080p/50 output you’ll get better resolution by forcing it to weave, so long as the material was captured as progressive frames.

I should probably add a note about this to my whitelist guide article.

I run a shared Kodi database on my server. I noticed when I applied a deinterlacing setting during playback on one Pi, when I resumed playback on another Pi, it picked up the new setting. So it looks like this is stored in the database somewhere. Does anyone know where? If so, I could apply a bulk update at the TV show level via an SQL update command, as that would suit me better than changing the global preference.

By the way, I’ve posted elsewhere that when I change contrast when playing my mkv’s that Kodi 18.x turns on the subtitles. This also happens when I change the deinterlace mode. I don’t think this is an OSMC issue, but I have not seen anyone else report this.

I’ve seen this reported and it’s a Kodi issue.

MariaDB [MyVideos116]> describe settings;
+---------------------+------------+------+-----+---------+-------+
| Field               | Type       | Null | Key | Default | Extra |
+---------------------+------------+------+-----+---------+-------+
| idFile              | int(11)    | YES  | UNI | NULL    |       |
| Deinterlace         | tinyint(1) | YES  |     | NULL    |       |
| ViewMode            | int(11)    | YES  |     | NULL    |       |
| ZoomAmount          | float      | YES  |     | NULL    |       |
| PixelRatio          | float      | YES  |     | NULL    |       |
| VerticalShift       | float      | YES  |     | NULL    |       |
| AudioStream         | int(11)    | YES  |     | NULL    |       |
| SubtitleStream      | int(11)    | YES  |     | NULL    |       |
| SubtitleDelay       | float      | YES  |     | NULL    |       |
| SubtitlesOn         | tinyint(1) | YES  |     | NULL    |       |
| Brightness          | float      | YES  |     | NULL    |       |
| Contrast            | float      | YES  |     | NULL    |       |
| Gamma               | float      | YES  |     | NULL    |       |
| VolumeAmplification | float      | YES  |     | NULL    |       |
| AudioDelay          | float      | YES  |     | NULL    |       |
| ResumeTime          | int(11)    | YES  |     | NULL    |       |
| Sharpness           | float      | YES  |     | NULL    |       |
| NoiseReduction      | float      | YES  |     | NULL    |       |
| NonLinStretch       | tinyint(1) | YES  |     | NULL    |       |
| PostProcess         | tinyint(1) | YES  |     | NULL    |       |
| ScalingMethod       | int(11)    | YES  |     | NULL    |       |
| DeinterlaceMode     | int(11)    | YES  |     | NULL    |       |
| StereoMode          | int(11)    | YES  |     | NULL    |       |
| StereoInvert        | tinyint(1) | YES  |     | NULL    |       |
| VideoStream         | int(11)    | YES  |     | NULL    |       |
| TonemapMethod       | int(11)    | YES  |     | NULL    |       |
| TonemapParam        | float      | YES  |     | NULL    |       |
| Orientation         | int(11)    | YES  |     | NULL    |       |
| CenterMixLevel      | int(11)    | YES  |     | NULL    |       |
+---------------------+------------+------+-----+---------+-------+
29 rows in set (0.01 sec)

Thanks. So it looks like records are only created in the settings table for files where the user has adjusted something for a given file. I can see how Kodi is incorrectly setting a flag for subtitles where I’ve adjusted something else. Having browsed the settings, tvshow and episode tables, it looks like I would have to do the following (beyond my SQL coding skills!)

select c00 and idShow from tvshow where c00=name of show I want to apply deinterlacing update to

select idFile and idShow from episode, only for those records selected from tvshow with the correct show title

we now have a list of idFile values that we want to insert into settings, with Deinterlace set to 0, and all other columns in settings equal to default values, while ensureing there is only one record per idFile value

Are there any SQL coders who can advise? I am using phpMyAdmin to play with queries to get the hang of this.

Well I would suggest you clone the settings from one of the movies where it is set correctly.
You could get that via SELECT * FROM settings WHERE idFile="<ID>"; Or in phpmyadmin you can export the settings table (in SQL format) which then shows insert commands.
You can then use that insert command as a template.