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

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Voyager Offline
Team-XBMC Member
Posts: 307
Joined: Apr 2010
Reputation: 4
Location: Belgium
Post: #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.
find quote
Voyager Offline
Team-XBMC Member
Posts: 307
Joined: Apr 2010
Reputation: 4
Location: Belgium
Post: #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);
...
}
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #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);
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #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
find quote
Swifty Offline
Fan
Posts: 484
Joined: Nov 2008
Reputation: 1
Post: #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 Confused

Cheers!
find quote
thespecialist Offline
Senior Member
Posts: 126
Joined: Mar 2007
Reputation: 0
Post: #16
isidrogar Wrote: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
Cool, thanks for compiling this, must be the ultimate XBMC package for people who are dependent on DXVA2 Smile
find quote
thespecialist Offline
Senior Member
Posts: 126
Joined: Mar 2007
Reputation: 0
Post: #17
isidrogar Wrote:@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);

Hmmm... I just installed your installer and it still has the problem: black screen after playing an interlaced ISO. It happened only with the 3rd interlaced video I tried though... Video played fine with a11559's patch. If you need any more info or anything at all, just let me know.
find quote
Voyager Offline
Team-XBMC Member
Posts: 307
Joined: Apr 2010
Reputation: 4
Location: Belgium
Post: #18
thespecialist Wrote:Hmmm... I just installed your installer and it still has the problem: black screen after playing an interlaced ISO. It happened only with the 3rd interlaced video I tried though... Video played fine with a11559's patch. If you need any more info or anything at all, just let me know.

could it be that there is a stream change right before the still, and that therefore the m_samples array ISN'T empty, so that the fix doesn't work?

I've compiled a version of the code that has this in it: download here
Code:
if (pts==0) {
    CLog::Log(LOGDEBUG,"DXVA - deinterlace encountered still image pts==0 - clearing samples array");
    for (unsigned s=0; s<m_size; s++)
        m_samples[s].SrcSurface = NULL;
  }

(same as before)
    picture->proc = this;
    picture->proc_id = picture->iFlags & DVP_FLAG_DROPPED ? 0 : Add(surface);    
    picture->format = DVDVideoPicture::FMT_DXVA;

Upon pts==0, it will clear the samples array to avoid any black still after black video.
(This post was last modified: 2011-06-19 09:20 by Voyager.)
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #19
Swifty Wrote:@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 Confused

Cheers!

Hi Swifty,

Yes I'm following PVR branch but the installer is only compiled againt master HEAD. I want to fix all the bugs before merging it with PVR.

When the patch become stable I will create a new PVR branch in my GIT and its installer with all things together Smile.
find quote
isidrogar Offline
Member
Posts: 59
Joined: Jun 2011
Reputation: 1
Location: Spain
Post: #20
@Voyager-xbmc, @thespecialist:

Thank you for your help here.

It seems the problem is more complicated. I have tested a DVD with a still menu image and when you navigate into DVD menu pages the background is mixed with last and new page.

This is because the processor is trying to deinterlace with totally different backward reference frames. The same occurs in your videos but in that case the "last page" doesn't exit and a black image is shown.

With this information any solution based in pts==0 will not always work. The a11559's patch is probably working because it defaults to "none" deinterlacing method or you have this selected. Can you please confirm the framerate is not doubled pressing "O" in still menu? Can you also confirm a11559's behavior with a forced deinterlacing method to "Best available" (you must have double framerate in this case)?

To avoid the problem in my code for now you can select "Auto" deinterlacing method as it will properly deinterlace when needed. Anyway I will keep working in a solution for the case you have forced deinterlacing.
find quote
Post Reply