Changeset 78c94529d1006fb64dfbf1629575f1146e1574f6
- Timestamp:
- 02/11/08 02:06:37
(5 months ago)
- Author:
- Benjamin Pracht <bigben@videolan.org>
- git-committer:
- Benjamin Pracht <bigben@videolan.org> 1202691997 +0000
- git-parent:
[e6e14e4e3e52ca9a28ff86ea3131cc20b2f5f5dd]
- git-author:
- Benjamin Pracht <bigben@videolan.org> 1202691997 +0000
- Message:
* fix pthread support for x264 on win32
- Not sure at all the configure.ac part is right, anyone more knowledgable, please check.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| raffff08 |
r78c9452 |
|
| 3742 | 3742 | VLC_ADD_CPPFLAGS([x264],[-I${real_x264_tree}]) |
|---|
| 3743 | 3743 | VLC_ADD_LIBS([x264],[-L${real_x264_tree}]) |
|---|
| 3744 | | LDFLAGS="${LDFLAGS_save} ${LIBS_x264} ${THREAD_LIB}" |
|---|
| 3745 | | AC_CHECK_LIB(x264, x264_encoder_open, [ |
|---|
| 3746 | | VLC_ADD_BUILTINS([x264]) |
|---|
| 3747 | | VLC_ADD_LIBS([x264],[-lx264]) |
|---|
| | 3744 | PKG_CHECK_MODULES(X264,x264, [ |
|---|
| | 3745 | VLC_ADD_PLUGINS([x264]) |
|---|
| | 3746 | VLC_ADD_LDFLAGS([x264],[${X264_LIBS}]) |
|---|
| | 3747 | VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}]) |
|---|
| 3748 | 3748 | ],[ |
|---|
| 3749 | 3749 | AC_MSG_ERROR([the specified tree hasn't been compiled]) |
|---|
| … | … | |
| 3755 | 3755 | fi |
|---|
| 3756 | 3756 | else |
|---|
| 3757 | | LDFLAGS="${LDFLAGS_save} ${LIBS_x264} ${THREAD_LIB}" |
|---|
| 3758 | 3757 | AC_CHECK_HEADERS(x264.h, [ |
|---|
| 3759 | | AC_CHECK_LIB(x264, x264_encoder_open, [ |
|---|
| | 3758 | PKG_CHECK_MODULES(X264,x264, [ |
|---|
| 3760 | 3759 | VLC_ADD_PLUGINS([x264]) |
|---|
| 3761 | | VLC_ADD_LIBS([x264],[-lx264]) |
|---|
| | 3760 | VLC_ADD_LDFLAGS([x264],[${X264_LIBS}]) |
|---|
| | 3761 | VLC_ADD_CFLAGS([x264],[${X264_CFLAGS}]) |
|---|
| 3762 | 3762 | ],[ |
|---|
| 3763 | 3763 | if test "${enable_x264}" = "yes"; then |
|---|
| r0a6c40c |
r78c9452 |
|
| 1 | 1 | Index: configure |
|---|
| 2 | 2 | =================================================================== |
|---|
| 3 | | --- configure (revision 672) |
|---|
| | 3 | --- configure (revision 736) |
|---|
| 4 | 4 | +++ configure (working copy) |
|---|
| 5 | | @@ -339,13 +339,13 @@ |
|---|
| | 5 | @@ -338,6 +338,7 @@ |
|---|
| | 6 | # autodetect options that weren't forced nor disabled |
|---|
| | 7 | |
|---|
| | 8 | libpthread="" |
|---|
| | 9 | +extradef="" |
|---|
| | 10 | if test "$pthread" = "auto" ; then |
|---|
| | 11 | pthread="no" |
|---|
| | 12 | case $SYS in |
|---|
| | 13 | @@ -345,16 +346,18 @@ |
|---|
| 6 | 14 | pthread="yes" |
|---|
| 7 | 15 | ;; |
|---|
| … | … | |
| 20 | 28 | libpthread="-lpthreadGC2 -lwsock32" |
|---|
| 21 | 29 | CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" |
|---|
| 22 | | @@ -428,6 +428,10 @@ |
|---|
| | 30 | + extradef="-DPTW32_STATIC_LIB" |
|---|
| | 31 | + |
|---|
| | 32 | fi |
|---|
| | 33 | ;; |
|---|
| | 34 | *) |
|---|
| | 35 | @@ -438,6 +441,10 @@ |
|---|
| 23 | 36 | ASFLAGS=$ASFLAGS |
|---|
| 24 | 37 | GTK=$gtk |
|---|
| … | … | |
| 31 | 44 | HAVE_GETOPT_LONG=$HAVE_GETOPT_LONG |
|---|
| 32 | 45 | DEVNULL=$DEVNULL |
|---|
| | 46 | @@ -480,7 +487,7 @@ |
|---|
| | 47 | Description: H.264 (MPEG4 AVC) encoder library |
|---|
| | 48 | Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//') |
|---|
| | 49 | Libs: $pclibs |
|---|
| | 50 | -Cflags: -I$includedir |
|---|
| | 51 | +Cflags: -I$includedir $extradef |
|---|
| | 52 | EOF |
|---|
| | 53 | |
|---|
| | 54 | |
|---|
| 33 | 55 | Index: Makefile |
|---|
| 34 | 56 | =================================================================== |
|---|
| 35 | | --- Makefile (revision 672) |
|---|
| | 57 | --- Makefile (revision 736) |
|---|
| 36 | 58 | +++ Makefile (working copy) |
|---|
| 37 | | @@ -73,8 +73,8 @@ |
|---|
| | 59 | @@ -74,8 +74,8 @@ |
|---|
| 38 | 60 | default: $(DEP) x264$(EXE) |
|---|
| 39 | 61 | |
|---|
| … | … | |
| 46 | 68 | $(SONAME): .depend $(OBJS) $(OBJASM) |
|---|
| 47 | 69 | $(CC) -shared -o $@ $(OBJS) $(OBJASM) -Wl,-soname,$(SONAME) $(LDFLAGS) |
|---|
| 48 | | @@ -93,7 +93,7 @@ |
|---|
| | 70 | @@ -94,7 +94,7 @@ |
|---|
| 49 | 71 | %.o: %.asm |
|---|
| 50 | 72 | $(AS) $(ASFLAGS) -o $@ $< |
|---|
| … | … | |
| 55 | 77 | .depend: config.mak |
|---|
| 56 | 78 | rm -f .depend |
|---|
| 57 | | @@ -146,14 +146,14 @@ |
|---|
| | 79 | @@ -149,14 +149,14 @@ |
|---|
| 58 | 80 | rm -rf test/ |
|---|
| 59 | 81 | $(MAKE) -C gtk distclean |
|---|
| r51aed47 |
r78c9452 |
|
| 34 | 34 | #include <vlc_codec.h> |
|---|
| 35 | 35 | |
|---|
| | 36 | #ifdef PTW32_STATIC_LIB |
|---|
| | 37 | #include <pthread.h> |
|---|
| | 38 | #endif |
|---|
| 36 | 39 | #include <x264.h> |
|---|
| 37 | 40 | |
|---|
| … | … | |
| 1183 | 1186 | } |
|---|
| 1184 | 1187 | |
|---|
| | 1188 | /* We need to initialize pthreadw32 before we open the encoder, but only oncce for the whole application. Since pthreadw32 doesn't keep a refcount, do it ouurselves */ |
|---|
| | 1189 | #ifdef PTW32_STATIC_LIB |
|---|
| | 1190 | vlc_value_t lock, count; |
|---|
| | 1191 | |
|---|
| | 1192 | var_Create( p_enc->p_libvlc, "pthread_win32_mutex", VLC_VAR_MUTEX ); |
|---|
| | 1193 | var_Get( p_enc->p_libvlc, "pthread_win32_mutex", &lock ); |
|---|
| | 1194 | vlc_mutex_lock( lock.p_address ); |
|---|
| | 1195 | |
|---|
| | 1196 | var_Create( p_enc->p_libvlc, "pthread_win32_count", VLC_VAR_INTEGER ); |
|---|
| | 1197 | var_Get( p_enc->p_libvlc, "pthread_win32_count", &count ); |
|---|
| | 1198 | |
|---|
| | 1199 | if( count.i_int == 0 ) |
|---|
| | 1200 | { |
|---|
| | 1201 | msg_Dbg( p_enc, "initializing pthread-win32" ); |
|---|
| | 1202 | if( !pthread_win32_process_attach_np() || !pthread_win32_thread_attach_np() ) |
|---|
| | 1203 | { |
|---|
| | 1204 | msg_Warn( p_enc, "pthread Win32 Initialization failed" ); |
|---|
| | 1205 | vlc_mutex_unlock( lock.p_address ); |
|---|
| | 1206 | return VLC_EGENERIC; |
|---|
| | 1207 | } |
|---|
| | 1208 | } |
|---|
| | 1209 | |
|---|
| | 1210 | count.i_int++; |
|---|
| | 1211 | var_Set( p_enc->p_libvlc, "pthread_win32_count", count ); |
|---|
| | 1212 | vlc_mutex_unlock( lock.p_address ); |
|---|
| | 1213 | |
|---|
| | 1214 | #endif |
|---|
| | 1215 | |
|---|
| 1185 | 1216 | /* Open the encoder */ |
|---|
| 1186 | 1217 | p_sys->h = x264_encoder_open( &p_sys->param ); |
|---|
| … | … | |
| 1311 | 1342 | |
|---|
| 1312 | 1343 | x264_encoder_close( p_sys->h ); |
|---|
| | 1344 | |
|---|
| | 1345 | #ifdef PTW32_STATIC_LIB |
|---|
| | 1346 | vlc_value_t lock, count; |
|---|
| | 1347 | |
|---|
| | 1348 | var_Create( p_enc->p_libvlc, "pthread_win32_mutex", VLC_VAR_MUTEX ); |
|---|
| | 1349 | var_Get( p_enc->p_libvlc, "pthread_win32_mutex", &lock ); |
|---|
| | 1350 | vlc_mutex_lock( lock.p_address ); |
|---|
| | 1351 | |
|---|
| | 1352 | var_Create( p_enc->p_libvlc, "pthread_win32_count", VLC_VAR_INTEGER ); |
|---|
| | 1353 | var_Get( p_enc->p_libvlc, "pthread_win32_count", &count ); |
|---|
| | 1354 | count.i_int--; |
|---|
| | 1355 | var_Set( p_enc->p_libvlc, "pthread_win32_count", count ); |
|---|
| | 1356 | |
|---|
| | 1357 | if( count.i_int == 0 ) |
|---|
| | 1358 | { |
|---|
| | 1359 | pthread_win32_thread_detach_np(); |
|---|
| | 1360 | pthread_win32_process_detach_np(); |
|---|
| | 1361 | msg_Dbg( p_enc, "pthread-win32 deinitialized" ); |
|---|
| | 1362 | } |
|---|
| | 1363 | vlc_mutex_unlock( lock.p_address ); |
|---|
| | 1364 | #endif |
|---|
| | 1365 | |
|---|
| 1313 | 1366 | free( p_sys->p_buffer ); |
|---|
| 1314 | 1367 | free( p_sys ); |
|---|