Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 16th February 2009, 14:39   #1  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
Issue introduced in libx264 r1077

Since r1077 of libx264, Avidemux crashes when encoding if b_transform_8x8 (--8x8dct) is turned off. Unfortunately the issue doesn't occur in debug builds or when run through gdb. I have only be able to test the issue on Windows 32-bit so not sure if it occurs on other OSes or CPUs.

The only error I can capture is logged by Avidemux's error handler:

Code:
*********** EXCEPTION **************
Registers:
EAX: 000010C2  EBX: 000001AD  ECX: 10000000  EDX: 00000000  ESI: 00000000
EDI: 00000002  ESP: 0021C260  EBP: 000001AD  EIP: 6F7CF14D  EFlags: 00010246

Exception Code: EXCEPTION_INT_DIVIDE_BY_ZERO (C0000094)
Exception Flags: 00000000

Origin:
C:\Program Files\Avidemux 2.4\libx264-66.dll(x264_macroblock_analyse+0x4F14D) [0x6F7CF14D]
*********** EXCEPTION **************
Anyone have any ideas what's causing this? Perhaps another Windows alignment issue?
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 15:41   #2  |  Link
J_Darnley
Registered User
 
J_Darnley's Avatar
 
Join Date: May 2006
Posts: 957
Are you only getting this with the library? If you can reproduce it with the binary, try a debug build with full optimisations: http://users.telenet.be/darnley/x264/x264-debug+opts.7z
Another bug, which was just fixed, only appeared for one guy when the opts were on.
__________________
x264 log explained || x264 deblocking how-to
preset -> tune -> user set options -> fast first pass -> profile -> level
Doom10 - Of course it's better, it's one more.

Last edited by J_Darnley; 16th February 2009 at 15:44.
J_Darnley is offline   Reply With Quote
Old 16th February 2009, 17:12   #3  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
I'm only getting the problem with the library. I can't get the CLI to fail. Another user is getting the same problem on Windows. Most users probably don't turn off the 8x8dct option (which Avidemux 2.4 turns on by default) so the reports will be low.

Is there an easy way to compile x264.exe to use libx264.dll rather than compiliing everything into the exe?
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 18:50   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Here are fresh builds, please test:
http://forum.doom9.org/showpost.php?...postcount=1041

I included a debug build plus a debug build with optimizations
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th February 2009, 19:04   #5  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Well, we already know where that crash is, because there's only one IDIV in macroblock_analyse.

Code:
if( i_intra_cost == COST_MAX )
                i_intra_cost = i_cost * i_satd_intra / i_satd_inter + 1;
Er, is this supposed to be

Code:
if( i_intra_cost == COST_MAX )
                i_intra_cost = i_cost * i_satd_intra / (i_satd_inter + 1);
Or do I have my C precedence rules wrong again?
Dark Shikari is offline   Reply With Quote
Old 16th February 2009, 19:23   #6  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
So the cause of the problem was found, right? But wouldn't that effect the CLI encoder too?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th February 2009, 19:26   #7  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by LoRd_MuldeR View Post
So the cause of the problem was found, right? But wouldn't that effect the CLI encoder too?
Nor would revision 1077 have anything to do with it...
Dark Shikari is offline   Reply With Quote
Old 16th February 2009, 19:29   #8  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Are you going to fix it anyway?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th February 2009, 19:48   #9  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
I can reproduce a crash with basically every revision from r1077 to r1114. Debug builds or running the process through gdb stops it from crashing so perhaps it may not have been introduced in r1077 but it's the first revision I can reliably reproduce the fault.
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 19:53   #10  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Quote:
Originally Posted by gruntster View Post
Debug builds or running the process through gdb stops it from crashing
Did you try a debug build with optimizations yet? Normally debug builds don't have optimizations enabled.
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th February 2009, 19:55   #11  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
Yes I have.
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 21:10   #12  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
Quote:
Originally Posted by Dark Shikari View Post
Er, is this supposed to be

Code:
if( i_intra_cost == COST_MAX )
                i_intra_cost = i_cost * i_satd_intra / (i_satd_inter + 1);
If it helps, this seems to make the problem disappear.
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 21:40   #13  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
If that makes the problem disappear, there is something more subtle wrong; i_satd_inter should never, ever, ever be zero. A quick trace of the good shows that it being zero is in fact physically impossible if the code works as intended.

More precisely:

a->i_lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;

i_satd_inter cannot equal zero unless this line, for i >= 0 and a->i_lambda >= 1, can equal zero.

Last edited by Dark Shikari; 16th February 2009 at 21:50.
Dark Shikari is offline   Reply With Quote
Old 16th February 2009, 21:49   #14  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
After adding logging, i_satd_inter equals 0 after about 35 frames. Any debug code you'd like me to add to pinpoint it further?
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 21:58   #15  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by gruntster View Post
After adding logging, i_satd_inter equals 0 after about 35 frames. Any debug code you'd like me to add to pinpoint it further?
See my edit in the above post...
Dark Shikari is offline   Reply With Quote
Old 16th February 2009, 22:30   #16  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
So is the fix (maybe better "workaround") proposed in post #5 still valid?

I mean, is it okay to apply that change until the actual cause of the problem is resolved ???
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Old 16th February 2009, 22:32   #17  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
Quote:
Originally Posted by Dark Shikari View Post
a->i_lambda * (log2f(i+1)*2 + 0.718f + !!i) + .5f;

i_satd_inter cannot equal zero unless this line, for i >= 0 and a->i_lambda >= 1, can equal zero.
If I add logging around this line the problem goes away. Since this is one of the lines introduced in r1077 it tends to suggest something is going awry in this area.
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 22:33   #18  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by LoRd_MuldeR View Post
So is the fix (maybe better "workaround") proposed in post #5 still valid?

I mean, is it okay to apply that change until the actual cause of the problem is resolved ???
Theoretically, but it's clear that this bug can only be caused if something else is failing, so that change just covers it up.
Dark Shikari is offline   Reply With Quote
Old 16th February 2009, 22:38   #19  |  Link
gruntster
Registered User
 
gruntster's Avatar
 
Join Date: Nov 2006
Location: London, UK
Posts: 99
Perhaps MinGW's implementation of log2f is faulty?
__________________
Download Avidemux for Windows
gruntster is offline   Reply With Quote
Old 16th February 2009, 22:40   #20  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,269
Quote:
Originally Posted by Dark Shikari View Post
Theoretically, but it's clear that this bug can only be caused if something else is failing, so that change just covers it up.
Thanks. A temporary workaround is better than nothing. Better than a potential crash for sure
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 17:28.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.