Page 1 of 1

[SOLVED] Framerate doubling - crash?

Posted: 03 Jan 2011 19:52
by Technologicat
Hi all,

After developing an IVTC filter, I thought I'd have a go at another kind of deinterlacer... that doesn't deinterlace at all :)

That is, I'm simulating an old CRT in software. If we don't mind that the pixel positions don't exactly match between an LCD display and a CRT TV, this can be done with a framerate doubler, which dims the "old" field (simulating phosphor light output decay) while the "new" one is being rendered. With a two-frame cache, ComposeFrame() from my IVTC filter, and a trivial luma dimmer (which I still need to MMX), this was easy.

And it actually works. The output looks pretty good, no interlacing artifacts are visible and 60 fps camera pans look very smooth. Note that for pure 24 fps NTSC telecined progressive material, IVTC is better, while this "CRT simulation" looks better for hybrid 24/60 fps (because it won't cause a framerate mismatch).

This brings me to the topic of this post.

I'm getting crashes during playback whenever I activate a framerate doubling deinterlacer. It's not only my new filter - it happens e.g. with "Yadif2x" and "Bob", too. The crashes occur randomly, but more often if I seek around in the video.

This is what gdb gives me:

Code: Select all

Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb1fabb70 (LWP 15184)] 0xb7f6b2bc in video_format_CopyCrop (p_dst=0x0, p_src=0x8419b08) at ../../src/misc/es_format.c:212 212 p_dst->i_x_offset = p_src->i_x_offset; (gdb) backtrace #0 0xb7f6b2bc in video_format_CopyCrop (p_dst=0x0, p_src=0x8419b08) at ../../src/misc/es_format.c:212 #1 0xb7f45418 in VideoFormatCopyCropAr (vout=<value optimized out>, now=<value optimized out>, deadline=0xb1fab360) at ../../src/video_output/video_output.c:98 #2 ThreadDisplayRenderPicture (vout=<value optimized out>, now=<value optimized out>, deadline=0xb1fab360) at ../../src/video_output/video_output.c:938 #3 ThreadDisplayPicture (vout=<value optimized out>, now=<value optimized out>, deadline=0xb1fab360) at ../../src/video_output/video_output.c:1048 #4 0xb7f4620c in ThreadManage (object=0x84148d4) at ../../src/video_output/video_output.c:1060 #5 Thread (object=0x84148d4) at ../../src/video_output/video_output.c:1488 #6 0xb7e33955 in start_thread (arg=0xb1fabb70) at pthread_create.c:300 #7 0xb7daee7e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
So, something is passing a null p_dst to video_format_CopyCrop(). Everything looks all right on the deinterlacer end, and it only happens when a framerate doubling deinterlacer is enabled.

Also, this same crash happens immediately (at the third frame after opening a stream) if a framerate doubling deinterlacer is chosen as the default in the options.

The version I have is 1.2-git from around mid-December.

I'd like to contribute the code for my new filter, but also to get this working to actually make it useful.

Anyone else seen this problem? Any ideas?

Re: Framerate doubling - crash?

Posted: 04 Jan 2011 00:02
by Technologicat
Update:

I debugged this a bit. Fixed.

The function ThreadDisplayRenderPicture() (in src/video_output/video_output.c) attempts to generate its direct buffer, and this sometimes fails. Sure enough, gdb pointed to the last line of the following snippet (at this point, "direct" is a new local variable initialized as NULL):

Code: Select all

if (vout->p->is_decoder_pool_slow) { direct = picture_pool_Get(vout->p->display_pool); if (direct) picture_Copy(direct, render); picture_Release(render); } else { direct = render; } VideoFormatCopyCropAr(&direct->format, &filtered->format);
which will crash if direct == NULL. If vout->p->is_decoder_pool_slow is true, but for some reason there is no picture in the display pool, this can happen.

So, I changed my copy to:

Code: Select all

if (vout->p->is_decoder_pool_slow) { direct = picture_pool_Get(vout->p->display_pool); if (direct) picture_Copy(direct, render); picture_Release(render); } else { direct = render; } if(direct) VideoFormatCopyCropAr(&direct->format, &filtered->format); else msg_Warn( vout, "ThreadDisplayRenderPicture(): direct is NULL, aborting" );
and sure enough, I get the occasional warning I just added, but the crashing stopped. This error occurs very rarely, but when it does, there can be a burst of them. In one debug test I got 14 in a row.

(The original code does indeed abort after this if direct == NULL, so I suspect the above line has just slipped the original dev's attention.)

Any VLC devs willing to comment, or to take it from here? :)

Re: Framerate doubling - crash?

Posted: 04 Jan 2011 21:59
by Rémi Denis-Courmont
Better post on vlc-devel. Many devs don't read the forums.

Re: Framerate doubling - crash?

Posted: 04 Jan 2011 23:36
by Technologicat
Better post on vlc-devel. Many devs don't read the forums.
Done. Posted a description of the problem and my solution. Thanks for the tip.

Re: Framerate doubling - crash?

Posted: 05 Jan 2011 17:22
by Jean-Baptiste Kempf
Better post on vlc-devel. Many devs don't read the forums.
s/Many/Most
:D
Although I have to say that this subforum is of way much higher quality than the rest.

Re: Framerate doubling - crash?

Posted: 05 Jan 2011 20:39
by Technologicat
s/Many/Most
:D
I see :)

Re: [SOLVED] Framerate doubling - crash?

Posted: 05 Jan 2011 22:30
by Technologicat
Final update:

Rémi has fixed the crash properly in today's 1.2-git. This issue can be considered closed.