# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_vout.h>
#include <vlc_sout.h>
#include <vlc_codec.h>
#define AUD_LONGTEXT N_( "Generate access unit delimiter NAL units.")
#if X264_BUILD >= 24 && X264_BUILD < 58
-static const char *enc_me_list[] =
+static const char *const enc_me_list[] =
{ "dia", "hex", "umh", "esa" };
-static const char *enc_me_list_text[] =
+static const char *const enc_me_list_text[] =
{ N_("dia"), N_("hex"), N_("umh"), N_("esa") };
#endif
#if X264_BUILD >= 58 /* r728 */
-static const char *enc_me_list[] =
+static const char *const enc_me_list[] =
{ "dia", "hex", "umh", "esa", "tesa" };
-static const char *enc_me_list_text[] =
+static const char *const enc_me_list_text[] =
{ N_("dia"), N_("hex"), N_("umh"), N_("esa"), N_("tesa") };
#endif
-static const char *enc_analyse_list[] =
+static const char *const enc_analyse_list[] =
{ "none", "fast", "normal", "slow", "all" };
-static const char *enc_analyse_list_text[] =
+static const char *const enc_analyse_list_text[] =
{ N_("none"), N_("fast"), N_("normal"), N_("slow"), N_("all") };
#if X264_BUILD >= 45 /* r457 */
-static const char *direct_pred_list[] =
+static const char *const direct_pred_list[] =
{ "none", "spatial", "temporal", "auto" };
-static const char *direct_pred_list_text[] =
+static const char *const direct_pred_list_text[] =
{ N_("none"), N_("spatial"), N_("temporal"), N_("auto") };
#else
-static const char *direct_pred_list[] =
+static const char *const direct_pred_list[] =
{ "none", "spatial", "temporal" };
-static const char *direct_pred_list_text[] =
+static const char *const direct_pred_list_text[] =
{ N_("none"), N_("spatial"), N_("temporal") };
#endif
vlc_module_begin();
- set_description( _("H.264/MPEG4 AVC encoder (using x264 library)"));
+ set_description( N_("H.264/MPEG4 AVC encoder (using x264 library)"));
set_capability( "encoder", 200 );
set_callbacks( Open, Close );
set_category( CAT_INPUT );
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static const char *ppsz_sout_options[] = {
+static const char *const ppsz_sout_options[] = {
"8x8dct", "analyse", "asm", "aud", "bframes", "bime", "bpyramid",
"b-adapt", "b-bias", "b-rdo", "cabac", "chroma-me", "chroma-qp-offset",
"cplxblur", "crf", "dct-decimate", "deadzone-inter", "deadzone-intra",
p_enc->pf_encode_video = Encode;
p_enc->pf_encode_audio = NULL;
p_enc->p_sys = p_sys = malloc( sizeof( encoder_sys_t ) );
+ if( !p_sys )
+ return VLC_ENOMEM;
p_sys->i_interpolated_dts = 0;
p_sys->psz_stat_name = NULL;
/* average bitrate specified by transcode vb */
p_sys->param.rc.i_bitrate = p_enc->fmt_out.i_bitrate / 1000;
-#if X264_BUILD < 48
- /* cbr = 1 overrides qp or crf and sets an average bitrate
- but maxrate = average bitrate is needed for "real" CBR */
- if( p_sys->param.rc.i_bitrate > 0 ) p_sys->param.rc.b_cbr = 1;
-#else
- if( p_sys->param.rc.i_bitrate > 0 ) p_sys->param.rc.i_rc_method = X264_RC_ABR;
-#endif
-
var_Get( p_enc, SOUT_CFG_PREFIX "qpstep", &val );
if( val.i_int >= 0 && val.i_int <= 51 ) p_sys->param.rc.i_qp_step = val.i_int;
var_Get( p_enc, SOUT_CFG_PREFIX "qpmin", &val );
#endif
}
+#if X264_BUILD < 48
+ /* cbr = 1 overrides qp or crf and sets an average bitrate
+ but maxrate = average bitrate is needed for "real" CBR */
+ if( p_sys->param.rc.i_bitrate > 0 ) p_sys->param.rc.b_cbr = 1;
+#else
+ if( p_sys->param.rc.i_bitrate > 0 ) p_sys->param.rc.i_rc_method = X264_RC_ABR;
+#endif
+
#if X264_BUILD >= 24
var_Get( p_enc, SOUT_CFG_PREFIX "ratetol", &val );
p_sys->param.rc.f_rate_tolerance = val.f_float;
{
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 X264_BUILD >= 58 /* r728 */
+ else if( !strcmp( val.psz_string, "tesa" ) )
+ {
+ p_sys->param.analyse.i_me_method = X264_ME_TESA;
+ }
+# endif
free( val.psz_string );
var_Get( p_enc, SOUT_CFG_PREFIX "merange", &val );
var_Get( p_enc, SOUT_CFG_PREFIX "crf", &val );
if( val.i_int > 0 && val.i_int <= 51 )
{
-#if X264_BUILD >= 54
+# if X264_BUILD >= 54
p_sys->param.rc.f_rf_constant = val.i_int;
-#else
+# else
p_sys->param.rc.i_rf_constant = val.i_int;
-#endif
-#if X264_BUILD >= 48
+# endif
+# if X264_BUILD >= 48
p_sys->param.rc.i_rc_method = X264_RC_CRF;
-#endif
+# endif
}
#endif
p_sys->param.vui.i_sar_width = i_dst_num;
p_sys->param.vui.i_sar_height = i_dst_den;
}
+
if( p_enc->fmt_in.video.i_frame_rate_base > 0 )
{
p_sys->param.i_fps_num = p_enc->fmt_in.video.i_frame_rate;
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;
p_sys->i_buffer = 4 * p_enc->fmt_in.video.i_width *
p_enc->fmt_in.video.i_height + 1000;
p_sys->p_buffer = malloc( p_sys->i_buffer );
+ if( !p_sys->p_buffer )
+ {
+ Close( VLC_OBJECT(p_enc) );
+ return VLC_ENOMEM;
+ }
/* get the globals headers */
p_enc->fmt_out.i_extra = 0;
x264_encoder_headers( p_sys->h, &nal, &i_nal );
for( i = 0; i < i_nal; i++ )
{
+ void *p_tmp;
int i_size = p_sys->i_buffer;
x264_nal_encode( p_sys->p_buffer, &i_size, 1, &nal[i] );
- p_enc->fmt_out.p_extra = realloc( p_enc->fmt_out.p_extra, p_enc->fmt_out.i_extra + i_size );
+ p_tmp = realloc( p_enc->fmt_out.p_extra, p_enc->fmt_out.i_extra + i_size );
+ if( !p_tmp )
+ {
+ Close( VLC_OBJECT(p_enc) );
+ return VLC_ENOMEM;
+ }
+ p_enc->fmt_out.p_extra = p_tmp;
memcpy( (uint8_t*)p_enc->fmt_out.p_extra + p_enc->fmt_out.i_extra,
- p_sys->p_buffer, i_size );
+ p_sys->p_buffer, i_size );
p_enc->fmt_out.i_extra += i_size;
}
}
p_block = block_New( p_enc, i_out );
+ if( !p_block ) return NULL;
memcpy( p_block->p_buffer, p_sys->p_buffer, i_out );
if( pic.i_type == X264_TYPE_IDR || pic.i_type == X264_TYPE_I )
p_block->i_flags |= BLOCK_FLAG_TYPE_B;
/* This isn't really valid for streams with B-frames */
- p_block->i_length = I64C(1000000) *
+ p_block->i_length = INT64_C(1000000) *
p_enc->fmt_in.video.i_frame_rate_base /
p_enc->fmt_in.video.i_frame_rate;