I though you will be able to find better solution, like recent dxva patch, since bigger MAX_SLICES is more calculations in Lavfilters. Also close to this issues were present before.
The problem here if you will check the second file (remux it first to mp4) can be only happening on part of the image and only for a couple of seconds.
Setting the value of MAX_SLICES to 256 fixes the issue (there's still a glitch that is also present in software decoding, not sure it's related as we don't fail anymore due to MAX_SLICES).
there's still a glitch that is also present in software decoding
SW decoder does not fail in ffmpeg even with only 32 slices, it is bitperfect with 256. Also consider that 64 is enough as QtAV shows. Nev argued that it should be 256, but I dunno! In fact it very hard to generate such samples in x264 and some 32 samples were done by SIP phone PC app as a joke, I am sure. I think the first sample is not actually using any of those slices, while the second sample may use more than 32 but that somehow does not warn.
I think there should be a way to make d3d11va to decode it without changes to h264 native decoder.
Also consider that #define can be changed per file!
I checked the return of this call in dxva2_h264_decode_slice()
if (ctx_pic->slice_count >= MAX_SLICES) return -1;
It had some slice_count higher than 128 but none higher than 256. So 256 should be enough, for this sample. I don't know the logic behind though. Maybe even higher values are possible. MPEG2 and VC1 use 1024.
And yes, the value may be changed only in dxva2_h264.c.
Nev did not push it or even submitted to mailing list. Also hwaccel cuda is not affected and so is older -c:v h264_cuvid decoders. That alone is confusing, since at least first still uses h264 code to preparse. I did not check linux or macos... dxva code and d3d11va defines should be both modified too. And of course there is a problem that SW decoder does not care there is more than 32 slices... Why? New samples created by x264 -slices option are needed.
Oh and also, how many slices does Nvidia Turing support?? It cannot be 8100, can it?
Also this patch may cause strange verbose warnings in dxva decoder.
I also verified in JM 19.0 that I compiled with Visual Studio 2022 by changing #define MAX_NUM_SLICES 500
that ffmpeg decoder is bitperfect on both samples (md5 of first yuv FILE is E47FDCC046210054BA90953B95A62ADF and second 31486A6EBD8A98EFE8FC54F13667A504). Checking second sample with ffplay.exe -video_size 1280x720 -pixel_format yuv420p -f rawvideo oldexa.yuv no artifacts.
In fact WHAT I DID I modified define MAX_NUM_SLICES 32 so that it will be same as ffmpeg.
The second sample then prints "Maximum number of supported slices exceeded." on 96th frame!! (Counting from 0.) That is why HW decoding does fail not immediately. I then modifed to 64 and that is enough to decode bitperfectly. 48 is enough. 40 is not enough it fails in the middle... 44 is enough, 42 is enough, 41 is enough! Lets just say this is hillarious. You need 41 SLICES for second sample. FFmpeg does not permit 41 slice though, only a power of 2.
[h264 @ 000001fe7ab6d9c0] Buffer for type 5 was too small[h264 @ 000001fe7ab6d9c0] Failed to add bitstream or slice control buffer[h264 @ 000001fe7ab6d9c0] hardware accelerator failed to decode pictureError while decoding stream #0:0: Operation not permittedMD5=b79d3517ca63de456208b5eb00559297
While both nvdec:
Lav\ffmpeg.exe -hwaccel cuda -i error_4942.264 -f md5 -
Well then pinging VideoLAN for a ffmpeg bug seems a bit weird
Anyway the point stands, when the bug will be closed because ffmpeg pushed a patch and we update our contribs you'll be notified. But keep in mind that despite the overwhelming charisma of our great president VideoLAN cannot force FFMPEG to do anything :).
The cool news is that apparently you can just modify dxva2_h264 file (and d3d11va file)! And that will just work. You do not need to change the main file like done above by Nev.
Well then pinging VideoLAN for a ffmpeg bug seems a bit weird
Again this is VLC's bugtracker not FFMpeg's. If it's one line feel free to propose a patch on ffmpeg-devel instead of posting passive aggressive comments here.
Considering the escalation despite the warning this issue is now locked. And comments were removed. FFMpeg IRC channel doesn't depends on VideoLAN's code of conduct and there's nothing related to a bug in VLC.