Page 1 of 2

Re: 7 extra frames on 1 source

Posted: Tue Feb 04, 2020 11:22 am
by MeteorRain
Random access to 23 and move forward to 24 I'm seeing the end of the program.

Random access to 24 and I'm seeing the next program.

(I recall there's a tool that can play avs forward and backward and check seeking accuracy but I don't remember where it is.)

Using VirtualDub2 64-bit, AviSynth+, DG 2053SS203.

Re: 7 extra frames on 1 source

Posted: Tue Feb 04, 2020 11:42 am
by Rocky
OK, I see it now. Investigating...

Re: 7 extra frames on 1 source

Posted: Wed Feb 05, 2020 5:09 pm
by Rocky
Hmm, it's those pesky negative POCs again. I have a fix working locally but have to do a lot of functional and regression testing.

Re: 7 extra frames on 1 source

Posted: Wed Feb 05, 2020 11:45 pm
by MeteorRain
Any reason keeping them as-is? Like, what if we just shift it to above zero? Just my 0.02 guess though.

Re: 7 extra frames on 1 source

Posted: Thu Feb 06, 2020 2:44 pm
by Rocky
It's not the negativity; it's the fact that the leading RADLs are B frames, and leading B frame code hasn't been implemented for HEVC hithertoo. This is actually the first HEVC stream seen here that has leading B frames. I knew the day must come, so now it's time to take care of business.

Re: 7 extra frames on 1 source

Posted: Thu Feb 06, 2020 4:19 pm
by MeteorRain
I see.

Well, this is the part I don't understand well. They used to be very conservative on broadcasting (Hint: mpeg2 interlaced 1440x1080 SAR 2ch aac) but all in a sudden they are going to the moon (hevc 10bit 4k / 8k with open-gop rasl+radl and 22.2 channel latm aac audio). :scratch:

Re: 7 extra frames on 1 source

Posted: Thu Feb 06, 2020 8:37 pm
by Rocky
22 channel? That's insane.

BTW, just to help with your already excellent English, we say "all of a sudden".

Re: 7 extra frames on 1 source

Posted: Thu Feb 06, 2020 8:38 pm
by Boris
We say, she say, speak for yourself. Who is broadcaster? We can blow up studio. Animals will not be harmed.

Re: 7 extra frames on 1 source

Posted: Thu Feb 06, 2020 9:02 pm
by Sherman
I'm so confused. Help me.

Re: 7 extra frames on 1 source

Posted: Fri Feb 07, 2020 5:11 pm
by MeteorRain
:scratch: Thanks for the correction.

By the way, they used 22.2 channels so it's 24 in total :scratch: I don't even think there's any OSS decoder yet.

Re: 7 extra frames on 1 source

Posted: Fri Feb 07, 2020 7:30 pm
by Natasha
Sherman, poor baby, come to me, I will help you.

Re: 7 extra frames on 1 source

Posted: Sun Feb 09, 2020 5:38 pm
by Bullwinkle
Sherman, you are a beloved child of the divine.

https://www.youtube.com/watch?v=2EaflX0MWRo (released version)
https://www.youtube.com/watch?v=Ma09CIqapwk (extended version)
https://www.youtube.com/watch?v=NlqJ44IpAJ0 (happy version)
https://www.youtube.com/watch?v=yqFz7T5v3iU (with lyrics)
https://www.youtube.com/watch?v=b-3eSxlgOhY (Motown remix)

Highest genius of the human spirit. RIP Levi Stubbs.

"When the world falls apart, some things stay in place
Levi Stubbs' tears run down his face."

-Billy Bragg

Re: 7 extra frames on 1 source

Posted: Mon Feb 10, 2020 12:38 pm
by Sherman
Thank you, Bullwinkle. But are emotions irrational? Should we suppress them? Is it an evolutionary mistake? How do emotions know what is right?

Re: 7 extra frames on 1 source

Posted: Mon Feb 10, 2020 12:41 pm
by Bullwinkle
Sherman, emotions are beautiful manifestations of the divine spirit that set us apart from microbes. Embrace the divine, and sing your joy!

Re: 7 extra frames on 1 source

Posted: Tue Feb 18, 2020 10:56 pm
by Sherman
Thanks, Bullwinkle! Think I got it:

https://www.youtube.com/watch?v=xhtzMwA5gJI

Re: 7 extra frames on 1 source

Posted: Mon Mar 23, 2020 1:55 pm
by Rocky
I've been working on the seeking issue. It's a doozy. Apparently, it's all caused by the RASL frames. My design assumes that the decoder always returns something for any coded frame. In fact I negotiated that with nVidia when I was working with them on the early CUVID rollout. But now, HEVC comes along with its Random Access Skipped Leading (RASL) frames. A Random Access Decodable Leading (RADL) frame is a frame that is decodable starting with the associated IDR/I, while a RASL is a frame that is not decodable and must be skipped by the decoder upon random access, meaning the decoder returns nothing for them. Oops, there goes my assumption and we need a hack or a re-design. So we have to cogitate on this and decide how to do things given the reality of RASL frames. All hands are on deck, even Natasha is looking into it.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 8:54 am
by Rocky
Hey that wasn't so bad. After discussing this with Curly :salute: I realized we could keep a count of leading RASLs per GOP and then just use that to adjust how many frames we need to decode starting at the IDR/I to get to the seeked-to frame. It seems to be working fine. I'll do some heavy regression testing and then give y'all a slipstream.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 10:11 am
by Curly
Glad to be of assistance, Rock! Nyuk.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 12:24 pm
by Rocky
Glad I decided to test all my HEVC streams with this fix! I found one that starts like this:

SPS 390168
PPS 390234
PREFERRED TRANSFER CHARACTERISTICS 18
0:RASL 0 -23
1:RASL 0 -22
2:RASL 0 -21
3:RASL 0 -20
4:RASL 0 -19
5:RASL 0 -18
6:RASL 0 -17
7:CRA 390719 2 -16
8:TRAIL 0 -15
9:TRAIL 0 -14
10:TRAIL 0 -13
11:TRAIL 0 -12
12:TRAIL 0 -11
13:TRAIL 0 -10
14:TRAIL 0 -9

Yes, there are 7 leading frames that cannot be decoded. And we can't try to start decoding at the previous GOP because this is the first GOP. So I decided to treat this the same way as for AVC leading B frames: repeat the first decodable frame 7 times. The idea is to preserve audio sync.

Formally, an HEVC stream must start with an IDR, but people cut streams all the time and produce such technically illegal streams.

Still have a bunch more to test but things are looking good.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 1:49 pm
by MeteorRain
Yea it happened to TV caps a lot. They use CRAs instead of IDRs as many as possible, so the program can only be cut on CRAs. It's wise to make it work like AVC leading B frames and keep the rest of the video in sync and seek accurate.

Thanks for all the work guys!

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 4:47 pm
by Rocky
Thank you, MeteorRain. Wouldn't have happened without you!

Found another one with 184 leading RADLs preceding an IDR. What is that all about? Anyway, it works fine with the fix.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 6:09 pm
by MeteorRain
Yea occasionally they insert IDRs at some commercials or between programs, it's kinda random. Sometimes it's just full CRAs across multiple programs.

Re: 7 extra frames on 1 source

Posted: Tue Mar 24, 2020 6:58 pm
by Rocky
It's the 184 leading RADLs that has me baffled. Must be for compression efficiency in some way, I suppose.

Re: 7 extra frames on 1 source

Posted: Wed Mar 25, 2020 11:10 am
by Rocky
Fixed in slipstream 205. Marking resolved.

Re: [RESOLVED] 7 extra frames on 1 source

Posted: Fri Mar 27, 2020 1:47 am
by MeteorRain
Thanks, the seek accuracy is back!