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 17th December 2008, 18:08   #41  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
So you want to implement your own wrapper for the Windows API to get a pthread-style interface.

What is the benefit over using the pthreads library, which basically does the same, is already working stable, saves you a lot of work and keeps your code clean & simple?
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th December 2008 at 18:12.
LoRd_MuldeR is offline   Reply With Quote
Old 17th December 2008, 18:22   #42  |  Link
squid_80
Registered User
 
Join Date: Dec 2004
Location: Melbourne, AU
Posts: 1,963
Quote:
Originally Posted by roozhou View Post
Code from xvidcore/motion_smp.h
Code:
#ifdef WIN32

# include <windows.h>
# define pthread_t				HANDLE
# define pthread_create(t,u,f,d) *(t)=CreateThread(NULL,0,f,d,0,NULL)
# define pthread_join(t,s)		{ WaitForSingleObject(t,INFINITE); \
									CloseHandle(t); } 
# define sched_yield()			Sleep(0);
Xvid doesn't use any* synchronization methods though, I think x264 does.

(*Sleep() is not a synchronization primitive.)
squid_80 is offline   Reply With Quote
Old 17th December 2008, 19:12   #43  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by LoRd_MuldeR View Post
So you want to implement your own wrapper for the Windows API to get a pthread-style interface.

What is the benefit over using the pthreads library, which basically does the same, is already working stable, saves you a lot of work and keeps your code clean & simple?
That's not true. To build under MSVC one needs to download and compile pthread (it's neither in x264's git repository nor shipped with Visual Studio). This does cost me more time than writing a simple wrapper for Windows API as well as producing larger and slower binaries.
roozhou is offline   Reply With Quote
Old 17th December 2008, 19:15   #44  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by roozhou View Post
That's not true. To build under MSVC one needs to download and compile pthread (it's neither in x264's git repository nor shipped with Visual Studio). This does cost me more time than writing a simple wrapper for Windows API as well as producing larger and slower binaries.
You do know the reason that pthreads were switched to in the first place, right?

They were very significantly faster than native threads. I doubt that Windows threads sped up that much in the 2 intervening years...
Dark Shikari is offline   Reply With Quote
Old 17th December 2008, 19:23   #45  |  Link
roozhou
Registered User
 
Join Date: Apr 2008
Posts: 1,181
Quote:
Originally Posted by Dark Shikari View Post
You do know the reason that pthreads were switched to in the first place, right?

They were very significantly faster than native threads. I doubt that Windows threads sped up that much in the 2 intervening years...
This is very interesting because pthread uses native threads at last. If native thread runs slower than pthread that means you are not using threads in the right way.
roozhou is offline   Reply With Quote
Old 17th December 2008, 19:28   #46  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by roozhou View Post
This is very interesting because pthread uses native threads at last. If native thread runs slower than pthread that means you are not using threads in the right way.
So just because the pthreads library makes use of the Windows API, doesn't mean that every single operation in the pthreads API will be mapped 1:1 to a Windows API function!

Whenever an operation can be handled in a library, which is running in user mode, an expensive syscall to the os kernel (switch context from user mode to kernel mode and back to user mode) can be avoided.

For the same reason pthreads on Linux now uses Futexes in order to avoid expensive syscalls whenever possible....

(BTW: In fact the Win32 API is a "high level" API (implemented by kernel32.dll and friends). There also is the "native" API (implemented in ntdll.dll), which usually is never called directly by an application. Only indirectly through Win32 API calls. The calls to the "native" API finally trap into kernel mode and execute the corresponding kernel function. So much for Win32 API is fast ^^)
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 17th December 2008 at 20:02.
LoRd_MuldeR is offline   Reply With Quote
Old 17th December 2008, 19:50   #47  |  Link
MasterNobody
Registered User
 
Join Date: Jul 2007
Posts: 552
MSVC 2008 build with pthreads: x264win64_r1057_msvc2008.rar
I have problems to compile with pthreads in MinGW. Would try it little more and then post patch in mailing list.
MasterNobody is offline   Reply With Quote
Old 17th December 2008, 22:08   #48  |  Link
MasterNobody
Registered User
 
Join Date: Jul 2007
Posts: 552
Here is MinGW build with pthreads: x264win64_r1057_mingw.rar
Now you can test speed between MSVC / MinGW and between 32bit / 64bit (32bit build: http://mirror01.x264.nl/x264/revision1057/x264.exe)

P.S. 64bit is not profiled (because I use cross-compiler on 32bit system)
MasterNobody is offline   Reply With Quote
Old 17th December 2008, 23:27   #49  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
MasterNobody, can you toss me the patches you have?
i can try and see if i can replicate everything in my MinGW64 environment.
__________________
custom x264 builds & patches | F@H | My Specs
kemuri-_9 is offline   Reply With Quote
Old 17th December 2008, 23:53   #50  |  Link
MasterNobody
Registered User
 
Join Date: Jul 2007
Posts: 552
Quote:
Originally Posted by kemuri-_9 View Post
MasterNobody, can you toss me the patches you have?
i can try and see if i can replicate everything in my MinGW64 environment.
http://mailman.videolan.org/pipermai...er/005300.html
MasterNobody is offline   Reply With Quote
Old 18th December 2008, 01:26   #51  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
confirmed as working (and thanks for fixing pthreads64 as well)

here's a build to match the current similar megui build
Code:
Platform:   X86_64
System:     MINGW
asm:        yes
avis input: yes
mp4 output: yes
pthread:    yes
debug:      no
gprof:      no
PIC:        no
shared:     no
visualize:  no

fprofiled:  yes

mods:
x264_win64_support.01.r1057.diff
x264_mingw_has_strtok_r.diff
x264_mingw_aligned_04.diff
x264_hrd_pulldown.09_interlace.diff
x264_x64.exe

getting a 5-10% speedup on my own quick tests compared to x86

Edit:
now with mp4 output support
__________________
custom x264 builds & patches | F@H | My Specs

Last edited by kemuri-_9; 18th December 2008 at 02:44. Reason: mp4 output
kemuri-_9 is offline   Reply With Quote
Old 18th December 2008, 01:59   #52  |  Link
Audionut
Registered User
 
Join Date: Nov 2003
Posts: 1,281
Nice work guys. I wonder if I can get a compiler working.
Audionut is offline   Reply With Quote
Old 18th December 2008, 02:36   #53  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
got gpac to compile in mingw64...
whoever decided that char *'s should be compared by using != in zlib should be shot.

Edit:
it's broken for being used to test string non-equivalency...
__________________
custom x264 builds & patches | F@H | My Specs

Last edited by kemuri-_9; 18th December 2008 at 04:27. Reason: edit to not make a new post on OT topic
kemuri-_9 is offline   Reply With Quote
Old 18th December 2008, 04:00   #54  |  Link
squid_80
Registered User
 
Join Date: Dec 2004
Location: Melbourne, AU
Posts: 1,963
Quote:
Originally Posted by kemuri-_9 View Post
got gpac to compile in mingw64...
whoever decided that char *'s should be compared by using != in zlib should be shot.
What's wrong with checking non-equivalency for a pointer?
squid_80 is offline   Reply With Quote
Old 18th December 2008, 05:15   #55  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by kemuri-_9 View Post

x264_x64.exe

getting a 5-10% speedup on my own quick tests compared to x86
Pardon my ignorance in the matter, but I've been having bad experiences with running the x86 version of x264 in a 64-bit OS (Windows 2008 Server). Keep getting the dreaded "x264 stopped responding" error ever so often. So, does this one run stable inside Windows 2008 (Datacenter)?

And is the 'Ugly fades' issue, mentioned here:

http://forum.doom9.org/showthread.php?t=143444

also resolved in this version? Otherwise there's no point in having the extra threads for my multi-core environment.

Thanks
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 18th December 2008, 05:19   #56  |  Link
Ranguvar
Registered User
 
Ranguvar's Avatar
 
Join Date: Feb 2007
Location: ::1
Posts: 1,236
Quote:
Originally Posted by kemuri-_9 View Post
got gpac to compile in mingw64...
whoever decided that char *'s should be compared by using != in zlib should be shot.
fix nfo pls?
Ranguvar is offline   Reply With Quote
Old 18th December 2008, 06:06   #57  |  Link
squid_80
Registered User
 
Join Date: Dec 2004
Location: Melbourne, AU
Posts: 1,963
Quote:
Originally Posted by kemuri-_9 View Post
got gpac to compile in mingw64...
whoever decided that char *'s should be compared by using != in zlib should be shot.

Edit:
it's broken for being used to test string non-equivalency...
Oh you mean char arrays not pointers

Yeah that's pretty dumb, almost as much as using strcmp for checking security signatures (thanks nintendo!).
squid_80 is offline   Reply With Quote
Old 18th December 2008, 07:00   #58  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
Quote:
Originally Posted by asarian View Post
Pardon my ignorance in the matter, but I've been having bad experiences with running the x86 version of x264 in a 64-bit OS (Windows 2008 Server). Keep getting the dreaded "x264 stopped responding" error ever so often. So, does this one run stable inside Windows 2008 (Datacenter)?

Thanks
Next time that happens, check at what point it crashes. I have seen that happen a couple of times (out of hundreds of encodes), and for me it happens after encoding. The encoded file is intact and you can manually mux it with YAMB, well at least in my case anyway!

I thought it was an issue regarding one of the filters I was using, avisynth, or staxrip
burfadel is offline   Reply With Quote
Old 18th December 2008, 12:41   #59  |  Link
asarian
Registered User
 
Join Date: May 2005
Posts: 1,462
Quote:
Originally Posted by burfadel View Post
Next time that happens, check at what point it crashes. I have seen that happen a couple of times (out of hundreds of encodes), and for me it happens after encoding. The encoded file is intact and you can manually mux it with YAMB, well at least in my case anyway!

I thought it was an issue regarding one of the filters I was using, avisynth, or staxrip
it has happened to me once after encoding, but often in-between somewhere. This "Program X stopped responding" feature in Vista and Windows 2008 is real annoying. Especially since I suspect x264 doesn't really hang, but is just being very busy (as it should be).
__________________
Gorgeous, delicious, deculture!
asarian is offline   Reply With Quote
Old 19th December 2008, 14:32   #60  |  Link
burfadel
Registered User
 
Join Date: Aug 2006
Posts: 2,229
Ah ok! For the couple of times it has happened to me, and its not just with the latest versions, I'm not sure how far back it would go (hasn't always done it), its always at the end of the encode! Its not a major issue since the encoded file is still fine, but it would be good if it didn't happen - I'm guessing that it would be a very difficult problem to find, and it may not even be x264 which is causing it. It could be avisynth... Are you using Avisynth v2.5.8 RC4?
burfadel 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 04:18.


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