[FFMPEG] Fix for artifacts with ATI cards and DXVA2 decoding

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #1
Hi all,

I have created this patch for fixing some artifacts during playback of H264 videos with DXVA2 and ATI cards. What the patch fixes is some kind of wrong colored macroblocks.

I have seen other artifacts like a nearly whole green screen mainly with interlaced content. I am diving in ffmpeg code to find out the bug but I don't have a solution yet.

For those who want to try the patch I have compiled this patched dll. You only have to backup the one with the same name in <XBMC path>\system\players\dvdplayer and copy the new one.

Update: I have uploaded a new version that allows to activate or not the patch using the flag FF_BUG_DXVA2_ATI in workaround_bugs member of AVCodecContext structure. I don't post a new compiled dll because you will need the patched headers to use.
(This post was last modified: 2011-06-18 23:51 by isidrogar.)
find quote
0wing Offline
Senior Member
Posts: 240
Joined: Aug 2010
Reputation: 37
Location: Sweden
Post: #2
AWESOME!!!

I didn't test it with every problematic movie, but this seems to solve the problems with ATI cards without UVD 2+.

Now I can finally stop using DSPlayer and get the latest builds.

Thank you!
find quote
mortstar Offline
Senior Member
Posts: 282
Joined: Aug 2010
Reputation: 3
Post: #3
isidrogar Wrote:Hi all,

I have created this patch for fixing some artifacts during playback of H264 videos with DXVA2 and ATI cards. What the patch fixes is some kind of wrong colored macroblocks.

I have seen other artifacts like a nearly whole green screen mainly with interlaced content. I am diving in ffmpeg code to find out the bug but I don't have a solution yet.

For those who want to try the patch I have compiled this patched dll. You only have to backup the one with the same name in <XBMC path>\system\players\dvdplayer and copy the new one.

Is that patched against HEAD?

[Image: all-banner.jpg]
find quote
Zuphael Offline
Junior Member
Posts: 35
Joined: Sep 2009
Reputation: 0
Location: Germany
Post: #4
Hi there!
Using your DLL XBMC Log tells me:
20:43:15 T:3644 M:2438414336 ERROR: Win32DllLoader::Load: Unable to load special://xbmcbin/system/players/dvdplayer/avcodec-52.dll (126)

Downloaded it from rapidshare and filesonic... no videofile is playing...

[Image: widget]
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #5
mortstar Wrote:Is that patched against HEAD?

Yes, it is patched agaist last HEAD commit, but should work with previous commits after d21c544a.
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #6
Zuphael Wrote:Hi there!
Using your DLL XBMC Log tells me:
20:43:15 T:3644 M:2438414336 ERROR: Win32DllLoader::Load: Unable to load special://xbmcbin/system/players/dvdplayer/avcodec-52.dll (126)

Downloaded it from rapidshare and filesonic... no videofile is playing...

Which build version are you using? The dll must be used for last git builds.
find quote
Zuphael Offline
Junior Member
Posts: 35
Joined: Sep 2009
Reputation: 0
Location: Germany
Post: #7
Sorry my fault xD

So, maybe its me, but i can tell no diffrence between your dll and that normal one...

[Image: screenshot001uy.png]

[Image: widget]
(This post was last modified: 2011-06-15 11:06 by Zuphael.)
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #8
Hi Zuphael,

I can see in your capture some decolored macroblocks but the are not exactly the same artifacts I have seen in my videos.

Just for reference, can you try the same video with MPC-HC and its internal DXVA H264 decoder?

If you also see the artifacts there, it could be possible you to cut a little clip of the video for testing in my system?
find quote
topsyturvy Offline
Member
Posts: 87
Joined: Jul 2010
Reputation: 0
Post: #9
Hi isidrogar,

I'm quite glad to see someone looking in ffmpeg code. I've got a number of problematic h264/dxva videos, there's been a ticket on this for months but nothing yet.

Please see my post at http://forum.xbmc.org/showthread.php?tid=101372

A test clip is included. CAn you do me a huge favor and take a look at this? I already tried your patch hoping that it would fix it for me but no luck.

Thanks in advance.
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #10
topsyturvy Wrote:Hi isidrogar,

I'm quite glad to see someone looking in ffmpeg code. I've got a number of problematic h264/dxva videos, there's been a ticket on this for months but nothing yet.

Please see my post at http://forum.xbmc.org/showthread.php?tid=101372

A test clip is included. CAn you do me a huge favor and take a look at this? I already tried your patch hoping that it would fix it for me but no luck.

Thanks in advance.

Hi topsyturvy,

It seems your problem is related to other bug in ffmpeg's implementation for DXVA. I'm still looking the code to find a fix for "green video screen" with interlaced content so I will also take a look at this problem. It would be great two fix at the same time! Smile
find quote
topsyturvy Offline
Member
Posts: 87
Joined: Jul 2010
Reputation: 0
Post: #11
hey,

thanks thats great to hear!! I tried compiling a new version of ffmpeg into xbmc, but that didn't work out Smile

Looking forward to getting your feedback .

P.S I made a mistake in typing that the problematic videos were h264, these were infact mpeg2 interlaced hdtv captures.
(This post was last modified: 2011-06-19 22:52 by topsyturvy.)
find quote
thespecialist Offline
Senior Member
Posts: 126
Joined: Mar 2007
Reputation: 0
Post: #12
isidrogar Wrote:Hi topsyturvy,

It seems your problem is related to other bug in ffmpeg's implementation for DXVA. I'm still looking the code to find a fix for "green video screen" with interlaced content so I will also take a look at this problem. It would be great two fix at the same time! Smile

I briefly looked at the DXVA2 MPEG implementation: at first glance the pictureparameters seem to be correct (which doesn't mean they ARE, I just couldnt find anything weird at first glance). Without any deeper investigation, I'd put my money on a bug in the filling/handling of the slice ... (but really, more investigation is needed). I'm making this first judgement though because not only do the pictureparameter seem to be correct, the screenoutput itself also doesn't really indicate a problem with the pictureparameters, but it seems it's just missing macroblocks at the end.

Anyway, I'm not going to look further here at the moment, I've got tons of other stuff to focus on for the next few days, and after your great job with the deinterlacing, I'm sure you'll manage !
(This post was last modified: 2011-06-20 04:36 by thespecialist.)
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #13
I appreciate your comments thespecialist, thanks!

So the problem is for interlaced HDTV MPEG2 videos. As I'm dealing with ffmpeg's implementation I'll keep a eye on this bug also. I hope be able to fix all! Frown
find quote
loggio Offline
Fan
Posts: 593
Joined: May 2010
Reputation: 6
Post: #14
Yep, i get the same issue... I've posted several times but not a lot of people seem to suffer it.

Though i'm sure once PVR is implemented into main branch there will be quite a few complaints of this happening to people in their MPEG-2 DXVA enabled Video streams.

I'm from Australia and using current pvr builds on windows 7 using DXVA results in corrupt video on channel '7mate' EXACTLY as found in the screen shot on this thread: http://forum.xbmc.org/showthread.php?tid=101372

Hopefully you come through with a fix isidrogar, i have faith! hehe

Here is a link to my original post:
http://forum.xbmc.org/showthread.php?p=797138

Here is a link to my trac ticket:
http://trac.xbmc.org/ticket/11475

Here is a link to the recorded corrupt video .TS file using PVR builds:
http://www.mediafire.com/?w4dk7mroi1s4ab7

Here is a link to the Debug log:
http://trac.xbmc.org/attachment/ticket/11475/xbmc.log


Hope this can give you some fuel to play with.

Cheers,
Loggio.
find quote
thespecialist Offline
Senior Member
Posts: 126
Joined: Mar 2007
Reputation: 0
Post: #15
@isidrogar:

I just had a little bit of time. I wanted to see if my theory made sense (eg that it's just not decoding enough slices/data). I added:

ctx_pic->slice_count -=30;

Add the beginning of the "commit_bitstream_and_slice_buffer" in dxva2_mpeg2.c (I had first tested that it currently decodes 175 slices per frame for that testvideo http://www.mediafire.com/?d37o11fcg19wc4g). And indeed, as I expected, it just moved up the 'black part' of the screen a bit. So it really looks like that's the problem.

I then wanted to see if the dxva bitstreambuffer that the 'GetBuffer' allocates was big enough to hold the data, since the dxva2_mpeg code doesnt check it (the dxva2_vc1 code does !). However, this was easily the case. The allocated buffer is over 2 MB while only a little more than 100k is needed per frame.

Anyway, now I'm even more convinced that I was right with my judgement. It's simply just not decoding enough slices (or they're too small/not counted correctly) and this is not a pictureparameter problem.

I hope this helps your investigations ...
(This post was last modified: 2011-06-21 04:36 by thespecialist.)
find quote
Post Reply