[RESOLVED] Artifacts On GITS VOB Frame Serving

Support forum for DGDecNV
Post Reply
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

[RESOLVED] Artifacts On GITS VOB Frame Serving

Post by himself »

When using DgDecNV (2052) on a source VOB which was ripped from DVD, I get artifacts throughout the video. The artifacts show up within DgDecNV

Image

Using the same VOB source files and Dgindex, the artifacts are not present.

Image

I use DgDecNV on a regular basis and this is the only time I've seen this issue. It must be something specific to this VOB.

Please let me know what I can do to help troubleshoot. :D
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

Oh, that's not good. Can you please give me a sample video that does that? You can set a range in DGIndex(NV) with [ and ] and then do save project and demux video. Upload the resulting .m2v file to a hosting site and post the link here. Thanks!

That is something that should be fixed ASAP. Thanks for reporting it and welcome to the forum.

When you play a stream with open GOPs from an arbitrary location in DGIndex(NV) you can see these frames with errors. That is normal and is done so you can easily see missing references. When served by DGDecode(NV), however, such frames are suppressed (actually copied from the first decodable frame to maintain the frame count) if the project starts with an open GOP. So please serve your video and report the results through DGDecode(NV).
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

When I use DgDecNV to extract a section of the vob, the resulting m2v file is free from problems. I've sent you a link to the original file by PM.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

himself wrote:When I use DgDecNV to extract a section of the vob, the resulting m2v file is free from problems.
Are you sure about that? I am seeing the problem in the demuxed M2V also.

I've contacted nVidia about this as it appears to be a CUVID bug.
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

I extracted about a 30 second segment around the area where I took the original screenshot, and I couldn't see the problem when I looked at the m2v in DGDecNV.

Well, either way, at least you can see it now! :D
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

I found an init param to CUVID that differs from the nVidia decode sample and when I change it the problem goes away. But this parameter should not have such an effect! So I will investigate a little more and wait a while for nVidia to reply to me.

This is the line that causes the problem:

parserInitParams.ulErrorThreshold = 100;

Commenting it out fixes the problem. I have to make sure I am not relying on this for anything before I remove it. ;)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

My whole random access design depends on this line! I can't remove it. All the DirectShow CUVID players (like MPC_HC) do not do this so you'll see no errors.

It all suggests that there are problems in the stream. Yet DGIndex plays it fine and reports no errors.

So I am trying to determine why CUVID does not like some of the frames. Hopefully, too, nVidia may have something for me.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

OK, thanks to nVidia's fine support, the problem is now understood. It is due to a recent CUVID regression. We are investigating the best way to recover from this: workaround or wait for new driver version, or both.

It's not yet clear if this affects only MPEG2 (dear Lord, please be limited to MPEG2!). I will report when I know more.
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

I'm at work still, so can't spend too much time looking up documentation.

Is ulErrorThreshold used to determine whether to render a frame or not based on how much corruption is present in the stream?

I wouldn't be surprised if there was something wrong with the original VOB that other players are ignoring and CUVID is showing the corrupted p-frames (or could it be whole GOPS?) For some reason the GITS stuff on DVD/BD is kinda poorly done.

Lastly, I have no idea what I'm talking about. I'm guessing you've figured that out. :)
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

himself wrote:Is ulErrorThreshold used to determine whether to render a frame or not based on how much corruption is present in the stream?
Yes. My design relies on CUVID returning an output frame (even if macroblocked because the frame is missing references) for every input frame. By setting ulErrorThreshold = 100 all frames are forced to be delivered.

As far as knowing what you are talking about is concerned, no problem, you said enough to get this headed in the right direction, and that is what is important.

It affects MPEG2 only. The thing is even the Avisynth DirectShow CUVID decoders are going to run into audio sync issues (though the players will be OK thanks to timestamps), even if they don't display the "bad" frames.

The problem is that CUVID regressed such that even an inconsequential change in the sequence header marked the GOP as broken. So, if (for example) only the specified bit_rate_value changes (as with the stream here) the GOP gets marked broken and the leading B frames get orphaned even though they are not.

I'm looking into a temporary workaround of rewriting the sequence header to prevent inconsequential changes being passed to CUVID. Otherwise, we have to wait for a fixed driver version.

Looks like DGIndex (or any other SW decoder) is your friend for this stream, at least for now.

Thanks for bringing this to my attention.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

I have a temporary workaround that seems to work but I want to ask nVidia if it's OK to lie in the bit_rate_value field, i.e., will it break something in the decoder if I just write a 1 in there unconditionally? Seems to be OK but I want to get an nVidia A-OK before letting anything loose.

If quant matrices change, though, there is no workaround and we have to wait for a driver fix. In your stream, only the bit_rate_value field changes between sequence headers.
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

Thanks for looking into all of this!

Also, thanks for giving me some pretty detailed background info. I'm genuinely curious about how these tools work. I've got a reasonably good high-level understanding of the basics, but I'm totally lost on any of the actual implementation.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

You know what I always say, I aim to please (except when I don't).

I like to give all the details because there are other developers out there implementing CUVID and they surely like to know about these things. I grokked 10-bit HEVC thanks to another developer, so it's the least I can do to share the things I discover.

You get brownie points for bringing this to light and following up instead of just grumbling to yourself. :bravo:
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

admin wrote:You get brownie points for bringing this to light and following up instead of just grumbling to yourself.
Why thank you kindly! I'm just happy to help out! :D
DAE avatar
himself
Posts: 7
Joined: Wed Jan 18, 2017 7:26 am

Re: Artifacts On GITS VOB Frame Serving

Post by himself »

I went back and extracted a small segment again, and this time it does show problems. I must've done something really absentminded the first time, like open the m2v file in dgindex.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

Hehe, good old human error. It's why I always "trust but verify". I wish you had been right because then it would have been on my program stream parser and it would have been fully in my control.

I'm going to slipstream a fix for you later this morning. Watch out for it.
DAE avatar
Aleron Ives
Posts: 126
Joined: Fri May 31, 2013 8:36 pm

Re: Artifacts On GITS VOB Frame Serving

Post by Aleron Ives »

admin wrote:I'm going to slipstream a fix for you later this morning. Watch out for it.
That sounds like a dangerous and/or violent fix. :wow:

:lol:
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Artifacts On GITS VOB Frame Serving

Post by admin »

Holy fortune cookies. You funny guy. :lol:

BTW, the fix is in.
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: Artifacts On GITS VOB Frame Serving

Post by jpsdr »

admin wrote:OK, thanks to nVidia's fine support, the problem is now understood. It is due to a recent CUVID regression.
Just out of curiosity, as there has been several driver releases since, what is the actual status of this ?
Is it fixed in the driver, or do you still need your workaround ?
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: [RESOLVED] Artifacts On GITS VOB Frame Serving

Post by admin »

Hi jpsdr.

I just updated to version 378.78 and it is indeed fixed. I usually leave harmless workarounds in place so as not to hose people running older drivers.
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: Artifacts On GITS VOB Frame Serving

Post by jpsdr »

admin wrote: If quant matrices change, though, there is no workaround and we have to wait for a driver fix.
Is your workaround safe in that case ? Also, it's possible that i didn't understood this statement properly, and you were not comparing this case with your workaround.
And i thought you were not sure your workaround may not break things in specific cases, but as it was just my thought/feeling, it may be wrong also.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: [RESOLVED] Artifacts On GITS VOB Frame Serving

Post by admin »

Everything is fine; don't worry.

The CUVID bug was this: When a sequence header is encountered that differs from the previous one, the next GOP is erroneously marked as bad link, meaning the referenced frames in the preceding GOP are discarded. That caused macroblocking at that point. A sequence header change should NOT mark the GOP as bad link.

In the case of the stream offered here, the only change in the sequence header was the signaled bit rate. But CUVID does not use this field in any way (other than when comparing the sequence header). That allowed me to simply always write it as 0, so that CUVID would not see a change in the sequence header. If, however, the quant matrices would change, I cannot write those to 0 because decoding would then fail miserably. In that case, the CUVID bug would be triggered with no possible workaround.

So: The workaround is unconditionally safe because it simply writes a field that is never used. I never thought it would break anything. But I did speculate that some streams may be encountered for which the workaround is useless.

All clear?
DAE avatar
jpsdr
Posts: 214
Joined: Tue Sep 21, 2010 4:16 am

Re: [RESOLVED] Artifacts On GITS VOB Frame Serving

Post by jpsdr »

Perfect, thanks.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: [RESOLVED] Artifacts On GITS VOB Frame Serving

Post by admin »

You're welcome, my pleasure. Have a great Sunday!
Post Reply