[PATCH] Hardware deinterlacing for both software and DXVA2 decoded material

  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 modified the DXVA2 engine in XBMC's code and the patch made by a11599 to support hardware deinterlacing to both software and DXVA2 decoded playback in this patch. I think this feature will be great for users (like me) are following the evolution of PVR branch.

For those who want to test the new feature I have compiled an installer in this link. Please note this is a first version of the patch and I have only tested it in my system, so any bug reports are welcome.

To use the feature you don't have to do nothing. The player always applies DVXA2 rendering because at least bob and progressive processing must be implemented for all the video devices (Microsoft specification). To select the deinterlacing technology you can use the configuration described in a11599's post. The quickswitch option is ignored and always enabled because I didn't have any issues with it. You can select ffmpeg software or DXVA2 decoding as usual in general GUI video settings.

What is changed in code is related to CProcessor which is made totally independent of CDecoder. I have algo changed the way DirectX surfaces are created and managed in both classes to make them compatible and faster. I also have included a NV12 colorspace converter for software decoded surfaces to make use of most advanded DXVA2 deinterlacers (specially ATI video cards). You can see all the code changes in my git.

Update: new version of the patch is available with several bug fixes. Here there is also a new installer version with all the fixes and my H264 ATI patch and thespecialist's one for VC-1. Big Grin

Update2:
New installer version based on my new git pvr branch. What this version includes:

- opdenkamp's PVR branch.
- my last DXVA2 deinterlacing patch based on a11599's one.
- last fixes for "black screen" problem and DXVA2 zoom scaling.
- other bug fixes found in my own tests.
- modification in method for detecting and applying ATI cards workaround as pointed by a11599.
- my patch for artifacts with ATI cards and H264 DXVA2 decoding.
- thespecialist's patches for VC-1 and MPEG2 DXVA2 decoding.
(This post was last modified: 2011-06-26 22:18 by isidrogar.)
find quote
Voyager Offline
Team-XBMC Member
Posts: 304
Joined: Apr 2010
Reputation: 4
Location: Belgium
Post: #2
So if I am already using a11599's patch in my git build-environment it would be sufficient to apply your most recent commit (https://github.com/isidrogar/xbmc/commit...e1226cde87) on top of it?
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #3
Yes, I think there will be no problem because this commit is done after patching my git build with a11599's patch but I have not tested it.

In any case, if you have conficts and you want to test without disturbing your main build it's easy to do a branch at point your last merge with XBMC main git and apply my patch (which also includes a11599's one).
find quote
WhiningKhan Offline
Member
Posts: 99
Joined: Aug 2008
Reputation: 0
Post: #4
Awesome.

I've been thinking about attempting to implement this for more than a year now. Never had time to really get into it, and now you and a11599 have made my plans redundant.

There appears to be a problem with Radeon HD3650 though - video output fails when playing any video, in the log it looks like it does not select an appropriate DXVA processor. I'll try with another machine with HD3200 later. Log: http://pastebin.com/3LQ0n7MR
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #5
WhiningKhan Wrote:Awesome.

I've been thinking about attempting to implement this for more than a year now. Never had time to really get into it, and now you and a11599 have made my plans redundant.

There appears to be a problem with Radeon HD3650 though - video output fails when playing any video, in the log it looks like it does not select an appropriate DXVA processor. I'll try with another machine with HD3200 later. Log: http://pastebin.com/3LQ0n7MR

Hi,

Thank you for trying the patch.

It's strange but analysing the log information it seems the processor is using a GUID not detected before. I will check the code to find out if something is missing...
find quote
WhiningKhan Offline
Member
Posts: 99
Joined: Aug 2008
Reputation: 0
Post: #6
I tested with HD3200 IGP now. Same symptoms, but selected processor GUID is not the same as with HD3650 and error code from GetVideoProcessorCaps is not the same.

Log: http://pastebin.com/mcqd08Kk
find quote
WhiningKhan Offline
Member
Posts: 99
Joined: Aug 2008
Reputation: 0
Post: #7
Hmm, I suppose deint contains a value not matching to any cases in switch(deint). There's no default case to catch it.

Yeah, I removed my existing portable data (and hence any preselected deinterlace methods) and now I get video output!

EDIT: And man, does it work beautifully. No more eye-wrenchingly bad motion quality on F1 or football matches! I must say it once more: Awesome.

EDIT2: The culprit was indeed switch(deint), along with whatever my library contains of course - I moved VS_INTERLACEMETHOD_AUTO as the default case and my old library works without problems:
Code:
// Synchronize sample type and render deinterlace method
  switch (deint)
  {
    case VS_INTERLACEMETHOD_NONE:
      m_SampleFormat = DXVA2_SampleProgressiveFrame;
      break;
    case VS_INTERLACEMETHOD_DXVA_BOB:
    case VS_INTERLACEMETHOD_DXVA_HQ:
      m_SampleFormat = DXVA2_SampleFieldInterleavedEvenFirst;
      break;
    case VS_INTERLACEMETHOD_DXVA_BOB_INVERTED:
    case VS_INTERLACEMETHOD_DXVA_HQ_INVERTED:
      m_SampleFormat = DXVA2_SampleFieldInterleavedOddFirst;
      break;
    case VS_INTERLACEMETHOD_AUTO:
    default:
      m_SampleFormat = m_StreamSampleFormat;
      if (m_SampleFormat == DXVA2_SampleFieldInterleavedOddFirst) deint = useautobob ? VS_INTERLACEMETHOD_DXVA_BOB_INVERTED : VS_INTERLACEMETHOD_DXVA_HQ_INVERTED;
      else if (m_SampleFormat == DXVA2_SampleFieldInterleavedEvenFirst) deint = useautobob? VS_INTERLACEMETHOD_DXVA_BOB : VS_INTERLACEMETHOD_DXVA_HQ;
      else deint = VS_INTERLACEMETHOD_NONE;
      break;  
  }
(This post was last modified: 2011-06-17 00:34 by WhiningKhan.)
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #8
Yes you are right. The bug was there!

I'm doing changes in my code and I will upload soon a new installer and updated version of my patch.
find quote
Voyager Offline
Team-XBMC Member
Posts: 304
Joined: Apr 2010
Reputation: 4
Location: Belgium
Thumbs Up    Post: #9
I've tried this (and WhiningKhan's fix) on an interlaced PAL DVD which had severe combing and ghosting effect... Thanks so much, this now plays very smoothly!
find quote
thespecialist Offline
Senior Member
Posts: 126
Joined: Mar 2007
Reputation: 0
Post: #10
isidrogar Wrote:Yes you are right. The bug was there!

I'm doing changes in my code and I will upload soon a new installer and updated version of my patch.

isidrogar,

I love your DXVA2 deinterlacing fix. If you want, could you add the DXVA2 VC1 fix I wrote to your installer ? http://trac.xbmc.org/ticket/11643 I would be honoured ! Smile

I'm on AMD Zacate, people like me are dependant on DXVA2, so we need both your fixes and my VC1 fix Smile Next time anybody on the forums has a problem on AMD Zacate, I can then simply refer them to your installer Wink
(This post was last modified: 2011-06-17 14:17 by thespecialist.)
find quote
Post Reply