#include <vlc_sout.h>
#include <vlc_codec.h>
+#ifdef PTW32_STATIC_LIB
+#include <pthread.h>
+#endif
#include <x264.h>
#define SOUT_CFG_PREFIX "sout-x264-"
#define WEIGHTB_LONGTEXT N_( "Weighted prediction for B-frames.")
#define ME_TEXT N_("Integer pixel motion estimation method")
+#if X264_BUILD >= 58 /* r728 */
+#define ME_LONGTEXT N_( "Selects the motion estimation algorithm: "\
+ " - dia: diamond search, radius 1 (fast)\n" \
+ " - hex: hexagonal search, radius 2\n" \
+ " - umh: uneven multi-hexagon search (better but slower)\n" \
+ " - esa: exhaustive search (extremely slow, primarily for testing)\n" \
+ " - tesa: hadamard exhaustive search (extremely slow, primarily for testing)\n" )
+#else
#define ME_LONGTEXT N_( "Selects the motion estimation algorithm: "\
" - dia: diamond search, radius 1 (fast)\n" \
" - hex: hexagonal search, radius 2\n" \
" - umh: uneven multi-hexagon search (better but slower)\n" \
" - esa: exhaustive search (extremely slow, primarily for testing)\n" )
+#endif
#if X264_BUILD >= 24
#define MERANGE_TEXT N_("Maximum motion vector search range")
#define AUD_TEXT N_("Access unit delimiters")
#define AUD_LONGTEXT N_( "Generate access unit delimiter NAL units.")
-#if X264_BUILD >= 24
+#if X264_BUILD >= 24 && X264_BUILD < 58
static const char *enc_me_list[] =
{ "dia", "hex", "umh", "esa" };
static const char *enc_me_list_text[] =
{ N_("dia"), N_("hex"), N_("umh"), N_("esa") };
#endif
+#if X264_BUILD >= 58 /* r728 */
+static const char *enc_me_list[] =
+ { "dia", "hex", "umh", "esa", "tesa" };
+static const char *enc_me_list_text[] =
+ { N_("dia"), N_("hex"), N_("umh"), N_("esa"), N_("tesa") };
+#endif
+
static const char *enc_analyse_list[] =
{ "none", "fast", "normal", "slow", "all" };
static const char *enc_analyse_list_text[] =
change_string_list( direct_pred_list, direct_pred_list_text, 0 );
#if X264_BUILD >= 52 /* r573 */
- add_integer( SOUT_CFG_PREFIX "direct-8x8", 0, NULL, DIRECT_PRED_SIZE_TEXT,
+ add_integer( SOUT_CFG_PREFIX "direct-8x8", -1, NULL, DIRECT_PRED_SIZE_TEXT,
DIRECT_PRED_SIZE_LONGTEXT, VLC_FALSE );
change_integer_range( -1, 1 );
#endif
{
p_sys->param.analyse.i_me_method = X264_ME_ESA;
}
+ #if X264_BUILD >= 58 /* r728 */
+ else if( !strcmp( val.psz_string, "tesa" ) )
+ {
+ p_sys->param.analyse.i_me_method = X264_ME_TESA;
+ }
+ #endif
if( val.psz_string ) free( val.psz_string );
var_Get( p_enc, SOUT_CFG_PREFIX "merange", &val );
p_sys->param.rc.b_stat_read = val.i_int & 2;
}
+ /* 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 */
+#ifdef PTW32_STATIC_LIB
+ vlc_value_t lock, count;
+
+ var_Create( p_enc->p_libvlc, "pthread_win32_mutex", VLC_VAR_MUTEX );
+ var_Get( p_enc->p_libvlc, "pthread_win32_mutex", &lock );
+ vlc_mutex_lock( lock.p_address );
+
+ var_Create( p_enc->p_libvlc, "pthread_win32_count", VLC_VAR_INTEGER );
+ var_Get( p_enc->p_libvlc, "pthread_win32_count", &count );
+
+ if( count.i_int == 0 )
+ {
+ msg_Dbg( p_enc, "initializing pthread-win32" );
+ if( !pthread_win32_process_attach_np() || !pthread_win32_thread_attach_np() )
+ {
+ msg_Warn( p_enc, "pthread Win32 Initialization failed" );
+ vlc_mutex_unlock( lock.p_address );
+ return VLC_EGENERIC;
+ }
+ }
+
+ count.i_int++;
+ var_Set( p_enc->p_libvlc, "pthread_win32_count", count );
+ vlc_mutex_unlock( lock.p_address );
+
+#endif
+
/* Open the encoder */
p_sys->h = x264_encoder_open( &p_sys->param );
p_enc->fmt_out.p_extra = realloc( p_enc->fmt_out.p_extra, p_enc->fmt_out.i_extra + i_size );
- memcpy( p_enc->fmt_out.p_extra + p_enc->fmt_out.i_extra,
- p_sys->p_buffer, i_size );
+ memcpy( (uint8_t*)p_enc->fmt_out.p_extra + p_enc->fmt_out.i_extra,
+ p_sys->p_buffer, i_size );
p_enc->fmt_out.i_extra += i_size;
}
free( p_sys->psz_stat_name );
x264_encoder_close( p_sys->h );
+
+#ifdef PTW32_STATIC_LIB
+ vlc_value_t lock, count;
+
+ var_Create( p_enc->p_libvlc, "pthread_win32_mutex", VLC_VAR_MUTEX );
+ var_Get( p_enc->p_libvlc, "pthread_win32_mutex", &lock );
+ vlc_mutex_lock( lock.p_address );
+
+ var_Create( p_enc->p_libvlc, "pthread_win32_count", VLC_VAR_INTEGER );
+ var_Get( p_enc->p_libvlc, "pthread_win32_count", &count );
+ count.i_int--;
+ var_Set( p_enc->p_libvlc, "pthread_win32_count", count );
+
+ if( count.i_int == 0 )
+ {
+ pthread_win32_thread_detach_np();
+ pthread_win32_process_detach_np();
+ msg_Dbg( p_enc, "pthread-win32 deinitialized" );
+ }
+ vlc_mutex_unlock( lock.p_address );
+#endif
+
free( p_sys->p_buffer );
free( p_sys );
}