Bug 72522 - VPP: deinterlacing of mpeg-2 produces green boarders artifacts on haswell
Summary: VPP: deinterlacing of mpeg-2 produces green boarders artifacts on haswell
Status: RESOLVED FIXED
Alias: None
Product: libva
Classification: Unclassified
Component: intel (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: haihao
QA Contact: Sean V Kelley
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-09 14:18 UTC by Peter Frühberger
Modified: 2014-05-29 06:23 UTC (History)
6 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Image with green artifacts (397.67 KB, text/plain)
2013-12-09 14:18 UTC, Peter Frühberger
Details
Green Image (now really png) (397.67 KB, image/png)
2013-12-09 14:38 UTC, Peter Frühberger
Details
A scratch patch (475 bytes, patch)
2014-05-05 02:41 UTC, haihao
Details | Splinter Review

Description Peter Frühberger 2013-12-09 14:18:27 UTC
Created attachment 90514 [details]
Image with green artifacts

Try to deinterlace a 576i file on haswell using VPP, it will produce images like in the attachement. Same code works perfectly fine on ivb and snb.

Code used: https://github.com/BtbN/xbmc/commits/vaapi-vpp-deinterlacing
Sample available: https://dl.dropboxusercontent.com/u/55728161/walker_interlaced.ts

You might have to workaround some asserts before playing that sample.
Comment 1 Peter Frühberger 2013-12-09 14:38:01 UTC
Created attachment 90515 [details]
Green Image (now really png)

Decoded and deinterlaced 576i frame
Comment 2 haihao 2014-01-07 06:40:04 UTC
Are you sure the image attached at comment 2 is grabbed from your sample ?
Comment 3 Peter Frühberger 2014-01-07 07:03:22 UTC
The screenshot is an example from a mpeg-2 live TV stream. The sample I posted (Walker Texas Ranger) is the same codec / stream type, but of course other content.

Green Bars are the same. I wanted to make clear, that it's not sample dependend but a general defect.
Comment 4 Peter Frühberger 2014-04-21 08:57:02 UTC
@Haihao: Could you reproduce in the meantime? Anything needed from my side to update that bugreport?

Problem still happening with libva 1.3.0 and corresponding libva-driver-intel
Comment 5 zhixinx.liu 2014-04-25 03:44:02 UTC
use gst-launch-0.10 to play this video, cannot find this problem.
the cmd is:
    "gst-launch-0.10 filesrc location=/home/Stream/walker_interlaced.ts ! tsdemux ! vaapidecode ! vaapipostproc deinterlace=1 deinterlace-method=1 ! vaapisink"

you can get gst-vaapi from following URL:
git://gitorious.org/gst-plugins-vaapi/gst-plugins-vaapi.git 0.4
Comment 6 haihao 2014-05-05 02:37:07 UTC
It is not a MPEG-2 related issue, actually I can reproduce this issue with a 720x576 H.264 video.
Comment 7 haihao 2014-05-05 02:41:17 UTC
Created attachment 98439 [details] [review]
A scratch patch
Comment 8 Peter Frühberger 2014-05-05 17:21:35 UTC
Hi Haihao,

yes that fixes it with the VPP implementation of btbns branch. Madi / Maci still has issues, but I need to look more into this.

Thanks much.
Comment 9 Peter Frühberger 2014-05-06 06:34:47 UTC
I think my other response was not that clear:

- VPP BOB: all fine now
- VPP MADI/MACI: Jumping forth and back (I am not sure for that part, if that's our programming error).

I compared the latter code with the gst implementation and yeah it's quite similar, despite the forward references which are not quite clear to me how gst computes them.

The code is (of course) OpenSource and available here, perhaps the error jumps out quite easily: https://github.com/BtbN/xbmc/blob/vaapi-vpp-deinterlacing/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI_VPP.cpp#L364

That patch applied for BOB would be really great. I think we'd need some support on the latter issues - Would be brilliant for the low power baytrail chips.
Comment 10 Gwenole Beauchesne 2014-05-09 09:25:42 UTC
Hi,

(In reply to comment #9)
> I think my other response was not that clear:
> 
> - VPP BOB: all fine now
> - VPP MADI/MACI: Jumping forth and back (I am not sure for that part, if
> that's our programming error).
> 
> I compared the latter code with the gst implementation and yeah it's quite
> similar, despite the forward references which are not quite clear to me how
> gst computes them.
> 
> The code is (of course) OpenSource and available here, perhaps the error
> jumps out quite easily:
> https://github.com/BtbN/xbmc/blob/vaapi-vpp-deinterlacing/xbmc/cores/
> dvdplayer/DVDCodecs/Video/VAAPI_VPP.cpp#L364
> 
> That patch applied for BOB would be really great. I think we'd need some
> support on the latter issues - Would be brilliant for the low power baytrail
> chips.

Some precisions, I probably omitted in the spec?

1. The reference frames used for MADI and MCDI shall be organized, i.e. sorted, by temporal proximity to the current picture we want to deinterlace. [0] is the immediately preceding picture, [1] the one preceding it, etc.

The implementation in gst maintains that as a ring buffer, but the list is really constructed in order by querying index 0 frame, index 1, etc.

2. VA_DEINTERLACING_BOTTOM_FIELD_FIRST and VA_DEINTERLACING_ONE_FIELD flags pertain to how frames in the history buffer are organized. i.e. that's the additional hint to the driver to determine the temporal order of the fields to be used.

3. Only VA_DEINTERLACING_BOTTOM_FIELD flag is a way to indicate what the current picture to process represents, i.e. what you want to deinterlace from: the one you provide to vaBeginPicture() for the VPP pipeline.

4. The filter_flags with VA_TOP_FIELD|VA_BOTTOM_FIELD are only to be seen as a "fast-path" for BobDI, thus avaoiding VPP/deinterlace specific buffers. They should not have any meaning/effect when appropriate VPP/Deinterlace buffers are used for MADI, MCDI, etc.

What I described is the theory of operations. In practice, this is what is implemented in gstreamer-vaapi, down to the VA driver except maybe a few quirks wrt. (4). If it doesn't work with gstreamer-vaapi (http://gitorious.org/vaapi/gstreamer-vaapi) + the latest driver, then please file a bug, and we will have to examine where the reality doesn't match the steps (1) to (4) described above.
Comment 11 Peter Frühberger 2014-05-09 09:43:18 UTC
@Gwenole Beauchesne:

Thank you very much for taking the time. Highly appreciated.
Comment 12 haihao 2014-05-12 02:17:31 UTC
I will close this bug as the original issue has been fixed. It would be better to file new bug if driver is the culprit for your new issue.
Comment 13 Peter Frühberger 2014-05-18 15:56:42 UTC
I took the time over the weekend and tested our Code on different Intel Archs.

Here is the summary:

IVB (core i5 3400 mhz), libva master, libva-intel-driver master + the scratch patch:

VAAPI-BOB: works
VAAPI-MADI: works
VAAPI-MACI: not supported

HSW (core i5-4200U), libva master, libva-intel-driver master + the scratch patch:

VAAPI-BOB: works (!)
VAAPI-MADI: green surfaces mixed with images, stuttering
VAAPI-MACI: jumping forth and back

I am still the opinion that this is a driver bug in the hsw implementation of VPP, some other alignments missing?
Comment 14 Peter Frühberger 2014-05-18 16:18:15 UTC
Concerning gstreamer-vaapi 0.4: I don't get that compiled on a "normal user desktop" system. Is there any other application out there that can show if VPP is working correctly on HSW platform?
Comment 15 haihao 2014-05-19 04:42:29 UTC
Could you tell me how to swith DI method in xbmc ? I can give a try on HSW.
Comment 16 Peter Frühberger 2014-05-19 08:07:41 UTC
Yes, I can do:

First we build the vpp branch, btbn rebased it on final gotham release, if you already have build btbn branch before - then skip that step:

git clone https://github.com/btbn/xbmc.git
git checkout vaapi-vpp-deinterlacing
./bootstrap
./configure
make -j5


Then you need to enable it via advancedsettings.xml - we disabled the advanced methods cause they did not work for now:

Create ~/.xbmc/userdata/advancedsettings.xml with the following content:

<advancedsettings>
<video>
<vaapiadvanceddeint>true</vaapiadvanceddeint>
</video>
</advancedsettings>

Now start xbmc (./xbmc.bin) and enable VAAPI, it's under Video -> Acceleration (see the screenshot here: https://dl.dropboxusercontent.com/u/55728161/vdpau-settingshowto.png

Next is open a video file by adding a directory to your Video File Sources: Video -> Files -> Add Sources (here choose the folder with your interlaced content).

Now start playing one of those, press enter, click on the film reel and change Deinterlace to Auto and Deinterlacing Method to e.g. VAAPI (BOB) VAAPI (MADI) and so on.

Thank you very much in advanced
Comment 17 haihao 2014-05-29 06:20:52 UTC
xbmc passes invalid parameters VAProcPipelineParameterBuffer::num_forward_references (0) and VAProcPipelineParameterBuffer::forward_references[0] to the driver. So the new issue is different from the original issue.
Comment 18 haihao 2014-05-29 06:23:14 UTC
Fixed as the original issue has gone away.  Feel free to file a new bug to track the new issue if the driver is the culprit for the new issue.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.