[FFMPEG] fix for DXVA-MPEG
#1
As reported a few times on this forum, there's a bug in the DXVA2 MPEG code, that causes partial black picture at the bottom of the screen. Testvideo here: http://www.mediafire.com/?d37o11fcg19wc4g

This is caused by the fact that in the dxva2_mpeg.c code a maximum is set to the amount of slices, being the difference between the highest and the lowest startcode. However, as I found out, some startcodes appear 3 times in a frame, hence there are more slices than different startcodes. The current code rejects slices above the max and that causes those slices not to be decoded.

The reason the code checks for that maximum slices is that an array is being made with the size of max_slices. It's part of the 'dxva2_picture_context':

DXVA_SliceInfo slice[MAX_SLICES];

The most 'beautiful' way to proceed would probably be to make that array dynamic. However that would need a few more changes. I'd suggest just to set that max_slices to a factor 3 of what it currently is right now:
#define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1) * 3

This will only add a few kb of memory. This should work, but of course it's not a really 'beautiful' solution. If somebody wants to change it to dynamic allocation (and then create a ticket for it), that's perfectly fine with me.
Reply
#2
*EDIT* Actually, the size is allocated in mpegvideo.c, it allocates 'priv_data_size' that then again is defined in dxva2_mpeg2.c as .priv_data_size = sizeof(struct dxva2_picture_context). So in other words, it just defines that framebuffer size as the size of that dxva2_picture_context structure. Which indeed means that to create a more beautiful solution, this is going to be more than just 1 changed line of code Wink Hence, again, I'm suggesting to just go with the easy way, at least for now, unless somebody of course wants to invest the time to create that 'better' solution (change mpegvideo.c to dynamically allocate the framebuffer, depending on the number of slices in the frame, instead of the current fixed size way)
Reply
#3
Perfect, let's hope this gets picked up and changed to dynamic and merged! Waiting ever so patiently hehehe


Great work!!
Keep it up!
Reply
#4
YESSSS !!!

I've been waiting for this one. Will try it out and update you asap!

Thanks alot for this one.
Reply
#5
You did it again!
Great job! Smile
Reply
#6
Thanks guys !

@isidrogar: if you want, you can add it to your DXVA deinterlacing build (which should become the main build for anyone using DXVA).
Reply
#7
thespecialist Wrote:Thanks guys !

@isidrogar: if you want, you can add it to your DXVA deinterlacing build (which should become the main build for anyone using DXVA).

I can't speak for others, but this would really be handy for me. Such a build would include the most important patches not in the master, and would save me compiling and updating each patch update...
Reply

Logout Mark Read Team Forum Stats Members Help
[FFMPEG] fix for DXVA-MPEG0