Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dxva] fix hw decoding on some mpeg2 files and DVDs #10644

Merged
merged 3 commits into from Oct 13, 2016

Conversation

Projects
None yet
6 participants
@afedchin
Copy link
Member

commented Oct 7, 2016

see title

@Voyager1 iirc you had the issue on some DVDs. could you check them on this? I've checked on WILLEM only.
@FernetMenta ping

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2016

kicked off build on jenkins http://jenkins.kodi.tv/job/WIN-32/10193/

@FernetMenta

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

should work, the other hw accelerators like vdpau and vaapi work with this content

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

great news! I'll give it a try and report in a little while.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

sorry to report, it's not working well, at least on my AMD HD7650M...
"Disney Magic English" and "Willem Van Oranje" DVD are giving green pictures. There is "some" improvement, because before, this was solid green, now you can at least see something, but it's not quite there yet. Some examples are included below.

screenshot000
screenshot001
screenshot002

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2016

strange Willem works well on my Intel gpu. seems now we faced with an amd specific issue. could you try to remove/comment this line https://github.com/xbmc/xbmc/blob/master/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp#L882 and try again?

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2016

or try to add SLICE_FLAG_CODED_ORDER here https://github.com/xbmc/xbmc/pull/10644/files#diff-579f094e6f9b9ab531645bac98fe277aR900 like vdpau/vaapi does.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

@afedchin - just tried both suggestions, no difference unfortunately...

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2016

@Voyager1 I have no more ideas except last one d2534b0

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

@afedchin - tried with this and still no luck. I don't know if it helps, but I get the impression that the green video is constantly jumping back and forth as if the frames are not in sequence... It still progresses forward, but in a weird way. Note that the last commit didn't change this, I just forgot to mention this in the beginning.

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 7, 2016

will try to find solution on monday. it will be hard to check without ati/amd card...

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

@afedchin - I wonder whether you can actually really solve this problem. I don't think there is anything wrong with the DXVA code, because if it was wrong, then those videos, when extracted from DVD to MKV (using MakeMKV) would play correctly on other players too. The reason to extract as MKV is because none of the other players use HW-decoding on DVDs, so this way we can do a meaningful test.
Now I have extracted the other example, "Magic English" and put a 100MB fragment here: https://www.dropbox.com/s/080m247h1l5314v/MAGIC.mkv?dl=0

I tried with MPC-HC, with Windows Media Player and with the Windows 10 film/tv universal app: the video plays just as bad as on Kodi. MPC-HC and WMP are slightly different, there the video flashes between black and color images, while with the Win10 film/tv app I get the same greenish interlaced look as on Kodi.

With PowerDVD 16 it plays fine (although I can't tell if it really uses HW accel) and with VLC it crashes when I force HW accel. Only the "auto" setting works so then again I don't know if it uses HW accel.

@fritsch

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

Can we just blacklist AMD for everything besides h264? Is that an option?

2016-10-08 9:32 GMT+02:00 Voyager1 notifications@github.com:

@afedchin https://github.com/afedchin - I wonder whether you can
actually really solve this problem. I don't think there is anything wrong
with the DXVA code, because if it was wrong, then those videos, when
extracted from DVD to MKV (using MakeMKV) would play correctly on other
players too. The reason to extract as MKV is because none of the other
players use HW-decoding on DVDs, so this way we can do a meaningful test.
Now I have extracted the other example, "Magic English" and put a 100MB
fragment here: https://www.dropbox.com/s/080m247h1l5314v/MAGIC.mkv?dl=0

I tried with MPC-HC, with Windows Media Player and with the Windows 10
film/tv universal app: the video plays just as bad as on Kodi. MPC-HC and
WMP are slightly different, there the video flashes between black and color
images, while with the Win10 film/tv app I get the same greenish interlaced
look as on Kodi.

With PowerDVD 16 it plays fine (although I can't tell if it really uses HW
accel) and with VLC it crashes when I force HW accel. Only the "auto"
setting works so then again I don't know if it uses HW accel.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#10644 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABCfHXDgWx1LdSMhrJXJLru2-YRpEjJ6ks5qx0cRgaJpZM4KQ28H
.

               Key-ID:     0x1A995A9B
               keyserver: pgp.mit.edu

Fingerprint: 4606 DA19 EC2E 9A0B 0157 C81B DA07 CF63 1A99 5A9B

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

I wouldn't blacklist AMD for everything besides h264. The code as it currently is in master, bypassing HW decoding for anything that has the DVD or STILLS flag, should be fine. These odd MPEG2 videos are only found inside DVDs anyways. I don't really understand what the issue is - MPEG2 SD video can be decoded in SW by most CPUs without much effort... Forcing HW decoding onto this has no added value.

@fritsch

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

Value: Advanced deinterlacing, in e.g. VDPAU / DXVA or on the RPi / IMX machines this is the only way to use proper upscaling / deinterlacing.

@hurda

This comment has been minimized.

Copy link

commented Oct 8, 2016

Maybe this helps:

Are both samples showing this in mediainfo:
Format settings, picture structure : Field

I found a thread in the kodi-forum, with hw-decoding issues on a Radeon 8xxx and a "Field"-coded MPEG2, and a VDPAU-bugreport, also with a Radeon and a "Field"-coded MPEG2.
Maybe the AMD-GPU or their drivers just can't handle this kind of MPEG2s.

AFAIK field-encoded DVDs are very rare.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

@hurda if there was a way to detect this type of coding, we could perhaps dynamically disable HW decoding?

@fritsch

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

If someone would post a sample I could find out. It should be something ffmpeg knows and we should be able to put it into hints and then disable hw accel the moment we hit such a file.

Edit: Especially one that @Voyager1 has an issue with.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 8, 2016

@fritsch - posted already above... https://www.dropbox.com/s/080m247h1l5314v/MAGIC.mkv?dl=0
edit: this is a 100MB MKV ripped from a DVD that has this issue. The first screenshot posted above is from this sample.

@fritsch

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

See:

Video
ID                                       : 1
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : Main@Main
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Default
Format settings, GOP                     : M=5, N=26
Format settings, picture structure       : Field
Codec ID                                 : V_MPEG2
Codec ID/Info                            : MPEG 1 or 2 Video
Duration                                 : 1mn 42s
Bit rate                                 : 8 000 Kbps
Width                                    : 720 pixels
Height                                   : 576 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 25.000 fps
Standard                                 : PAL
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Interlaced
Scan order                               : Top Field First
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.772
Time code of first frame                 : 10:00:00:00
Time code source                         : Group of pictures header
GOP, Open/Closed                         : Open
Stream size                              : 97.4 MiB (97%)
Language                                 : English
Default                                  : No
Forced                                   : No
Color primaries                          : BT.601 PAL
Transfer characteristics                 : BT.470 System B, BT.470 System G
Matrix coefficients                      : BT.601

Format settings, picture structure : Field <- we can get that into hints and disable it for AMD when we detect that?

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

on the forum there has been a mention of this as well here: http://forum.kodi.tv/showthread.php?tid=150029
There it's not linked to "field" structure but rather the last three parameters: Color primaries, Transfer characteristics and Matrix coefficients... Can this be detected prior to enabling the HW decoder?
edit: ... and of course AMD/Radeon only...

@FernetMenta

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

@Voyager1 there is a mpeg2 sample (Sonique - Alive (Pal-AC3_thehicham).sample.mpg) in folder "pike" on our ftp server. There was a bug in former vdpau driver that made it not play. Can you try this sample?

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

@FernetMenta - seems like the FTP password I have is no longer valid. can you pls PM me the details at voyager@kodi.tv ? thx.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

@FernetMenta - just tried the sample and it works well (HW decoding)

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 9, 2016

@Voyager1 I've added a check for mpeg2 and AMD/ATI compartibility. could you please test?

@afedchin afedchin force-pushed the afedchin:dxva branch from 8314a3d to ee08cc9 Oct 9, 2016

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 9, 2016

@afedchin hi, thanks. This works indeed very well, however we're excluding too many good video's now. I think we have to add the condition of the picture structure "field". I have tried to filter on avctx->field_order but that didn't help much either. There progressive ones are all good, but there is AV_FIELD_UNKNOWN that happens quite often too. I'll do a bit of testing, I think we can get this right...

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 9, 2016

@Voyager1 please do. I can't check on my hw.

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 11, 2016

@afedchin I've been playing with this but I can't find a way to detect picture structure "field", or "interlaced" in a consistent way. In fact I'm getting AV_FIELD_UNKNOWN all the time. The good news is that the proportion of DVDs with those color parameters is not as big as I thought, so perhaps we can just keep it. How about adding a condition to only consider SD (avctx->height <= 576)?

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 11, 2016

@Voyager1 please correct me if I'm wrong. You suggested to blacklist all SD mpeg2 content on ATI/AMD?

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 11, 2016

@afedchin not at all. Your latest commit is fine (ee08cc9) but I would also add the condition avctx->height <= 576 so that we only filter SD videos that have these color particulars. Sorry if it wasn't clear :-)

@afedchin afedchin force-pushed the afedchin:dxva branch from ee08cc9 to ce16d88 Oct 12, 2016

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 12, 2016

@Voyager1 updated

@Voyager1

This comment has been minimized.

Copy link
Member

commented Oct 13, 2016

Looks good to me.

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Oct 13, 2016

jenkins build this please

@afedchin afedchin merged commit 8122157 into xbmc:master Oct 13, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins4kodi You did a great job. Have a cookie.
Details

@afedchin afedchin deleted the afedchin:dxva branch Oct 13, 2016

@Memphiz

This comment has been minimized.

Copy link
Member

commented Dec 14, 2016

@afedchin

This comment has been minimized.

Copy link
Member Author

commented Dec 14, 2016

@Memphiz capture isn't related to decoding. when DXVA decoding switched off in most cases PS renderer is used. I was unable to reproduce the issue with any renderer, so seems it's a driver related.

@Memphiz

This comment has been minimized.

Copy link
Member

commented Dec 15, 2016

Ok - thx for taking a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.