• 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14
[PATCH] Hardware deinterlacing for both software and DXVA2 decoded material
#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.
Reply
#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?
Reply
#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).
Reply
#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
Reply
#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...
Reply
#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
Reply
#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;  
  }
Reply
#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.
Reply
#9
Thumbs Up 
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!
Reply
#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
Reply
#11
@isidrogar: I have a DVD that starts with a still menu (actually there's quite a few like that). The still is displayed in BLACK with your patch. Reverting back to a11559 commit everything is OK. I'm investigating the root cause.
Reply
#12
@isidrogar
I have found a quick and dirty fix to the 'black still image' problem. Apparently the issue is that the still is only one frame and that it doesn't have enough data to actually deinterlace. So the dirty trick is to add the frame a second time, if pts==0 (case of still image). I don't understand the code enough but I was hoping you could be the judge of this or any better fix.

Summary, change the method signature to take pts, and at the end check if pts==0 and if so add the surface again.

Code:
bool CProcessor::ProcessPicture(DVDVideoPicture* picture, double pts)
{
...
    picture->proc_id = picture->iFlags & DVP_FLAG_DROPPED ? 0 : Add(surface);
    if (pts==0) Add(surface);
...
}
Reply
#13
@Voyager-xbmc
Thanks for your comments.

Yes, the problem about "black still image" is generated because the processor must have enough forward and backward reference frames to render the image. My code differs from a11559's in that the Render method verifies it has all the frames.

Obiously this may cause problems in case there is only one frame to show. Your workaround about adding the same surface is a good idea but the problem it only will work in case only one backward refererence frame is needed.

I have updated the code with a more generic solution where the Add method do all the work:
Code:
do {
      m_time += 2;
      
      m_samples[m_index].Time = m_time;
      m_samples[m_index].SrcSurface = source;
      
      m_index = (m_index + 1) % m_size;
  }
  while (m_samples[m_index].SrcSurface == NULL);
Reply
#14
thespecialist Wrote: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

@thespecialist
Your patch is a great job! Thank you for sharing.

I have uploaded a new installer version with all the fixes for bugs found in previous posts and also including your patch for VC-1 and mine for H264. Smile
Reply
#15
@isidrogar

You mentioned in your first post that you are following the PVR branch of XBMC - are your installers based on the PVR branch ?

I quickly took a look at one earlier today but it didn't appear to have any LiveTV option Huh

Cheers!
Reply
  • 1(current)
  • 2
  • 3
  • 4
  • 5
  • 14

Logout Mark Read Team Forum Stats Members Help
[PATCH] Hardware deinterlacing for both software and DXVA2 decoded material0