Commit 34b590b1 authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Various cosmetics

Exorcise some CamelCase.
parent 2bd8c8f5
......@@ -359,18 +359,18 @@ int x264_cpu_num_processors( void )
return info.cpu_count;
#elif SYS_MACOSX || SYS_FREEBSD || SYS_OPENBSD
int numberOfCPUs;
size_t length = sizeof( numberOfCPUs );
int ncpu;
size_t length = sizeof( ncpu );
#if SYS_OPENBSD
int mib[2] = { CTL_HW, HW_NCPU };
if( sysctl(mib, 2, &numberOfCPUs, &length, NULL, 0) )
if( sysctl(mib, 2, &ncpu, &length, NULL, 0) )
#else
if( sysctlbyname("hw.ncpu", &numberOfCPUs, &length, NULL, 0) )
if( sysctlbyname("hw.ncpu", &ncpu, &length, NULL, 0) )
#endif
{
numberOfCPUs = 1;
ncpu = 1;
}
return numberOfCPUs;
return ncpu;
#else
return 1;
......
......@@ -77,7 +77,7 @@ static inline void write16x4( uint8_t *dst, int dst_stride,
}
/** \brief performs a 6x16 transpose of data in src, and stores it to dst */
#define readAndTranspose16x6(src, src_stride, r8, r9, r10, r11, r12, r13)\
#define read_and_transpose16x6(src, src_stride, r8, r9, r10, r11, r12, r13)\
{\
register vec_u8_t r0, r1, r2, r3, r4, r5, r6, r7, r14, r15;\
VEC_LOAD(src, r0, 16, vec_u8_t, pix ); \
......@@ -293,7 +293,7 @@ void x264_deblock_h_luma_altivec( uint8_t *pix, int stride, int alpha, int beta,
return;
PREP_LOAD;
vec_u8_t _pix_ = vec_lvsl(0, pix-3);
readAndTranspose16x6(pix-3, stride, line0, line1, line2, line3, line4, line5);
read_and_transpose16x6(pix-3, stride, line0, line1, line2, line3, line4, line5);
h264_loop_filter_luma_altivec(line0, line1, line2, line3, line4, line5, alpha, beta, tc0);
transpose4x16(line1, line2, line3, line4);
write16x4(pix-2, stride, line1, line2, line3, line4);
......
......@@ -465,7 +465,7 @@ static inline void x264_cabac_mb8x8_mvd( x264_t *h, x264_cabac_t *cb, int i )
}
}
/* i_ctxBlockCat: 0-> DC 16x16 i_idx = 0
/* ctx_block_cat: 0-> DC 16x16 i_idx = 0
* 1-> AC 16x16 i_idx = luma4x4idx
* 2-> Luma4x4 i_idx = luma4x4idx
* 3-> DC Chroma i_idx = iCbCr
......@@ -554,11 +554,11 @@ static const uint8_t coeff_abs_level_transition[2][8] = {
static const uint8_t count_cat_m1[5] = {15, 14, 15, 3, 14};
#if !RDO_SKIP_BS
static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBlockCat, dctcoef *l )
static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l )
{
const int i_ctx_sig = significant_coeff_flag_offset[h->mb.b_interlaced][i_ctxBlockCat];
const int i_ctx_last = last_coeff_flag_offset[h->mb.b_interlaced][i_ctxBlockCat];
const int i_ctx_level = coeff_abs_level_m1_offset[i_ctxBlockCat];
const int i_ctx_sig = significant_coeff_flag_offset[h->mb.b_interlaced][ctx_block_cat];
const int i_ctx_last = last_coeff_flag_offset[h->mb.b_interlaced][ctx_block_cat];
const int i_ctx_level = coeff_abs_level_m1_offset[ctx_block_cat];
const uint8_t *sig_offset = significant_coeff_flag_offset_8x8[h->mb.b_interlaced];
int i_coeff_abs_m1[64];
int i_coeff_sign[64];
......@@ -567,7 +567,7 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
int node_ctx = 0;
int i = 0;
i_last = h->quantf.coeff_last[i_ctxBlockCat](l);
i_last = h->quantf.coeff_last[ctx_block_cat](l);
#define WRITE_SIGMAP( l8x8 )\
while(1)\
......@@ -598,14 +598,14 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
}\
}
if( i_ctxBlockCat == DCT_LUMA_8x8 )
if( ctx_block_cat == DCT_LUMA_8x8 )
{
const int i_count_m1 = 63;
WRITE_SIGMAP( 1 )
}
else
{
const int i_count_m1 = count_cat_m1[i_ctxBlockCat];
const int i_count_m1 = count_cat_m1[ctx_block_cat];
WRITE_SIGMAP( 0 )
}
......@@ -648,20 +648,20 @@ static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBl
* this is slightly incorrect because the sigmap is not reversible
* (contexts are repeated). However, there is nearly no quality penalty
* for this (~0.001db) and the speed boost (~30%) is worth it. */
static void ALWAYS_INLINE block_residual_write_cabac_internal( x264_t *h, x264_cabac_t *cb, int i_ctxBlockCat, dctcoef *l, int b_8x8 )
static void ALWAYS_INLINE block_residual_write_cabac_internal( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l, int b_8x8 )
{
const int i_ctx_sig = significant_coeff_flag_offset[h->mb.b_interlaced][i_ctxBlockCat];
const int i_ctx_last = last_coeff_flag_offset[h->mb.b_interlaced][i_ctxBlockCat];
const int i_ctx_level = coeff_abs_level_m1_offset[i_ctxBlockCat];
const int i_ctx_sig = significant_coeff_flag_offset[h->mb.b_interlaced][ctx_block_cat];
const int i_ctx_last = last_coeff_flag_offset[h->mb.b_interlaced][ctx_block_cat];
const int i_ctx_level = coeff_abs_level_m1_offset[ctx_block_cat];
const uint8_t *sig_offset = significant_coeff_flag_offset_8x8[h->mb.b_interlaced];
int i_last, i_coeff_abs, ctx, node_ctx;
i_last = h->quantf.coeff_last[i_ctxBlockCat](l);
i_last = h->quantf.coeff_last[ctx_block_cat](l);
i_coeff_abs = abs(l[i_last]);
ctx = coeff_abs_level1_ctx[0] + i_ctx_level;
if( i_last != (b_8x8 ? 63 : count_cat_m1[i_ctxBlockCat]) )
if( i_last != (b_8x8 ? 63 : count_cat_m1[ctx_block_cat]) )
{
x264_cabac_encode_decision( cb, i_ctx_sig + (b_8x8?sig_offset[i_last]:i_last), 1 );
x264_cabac_encode_decision( cb, i_ctx_last + (b_8x8?last_coeff_flag_offset_8x8[i_last]:i_last), 1 );
......@@ -733,19 +733,19 @@ static void block_residual_write_cabac_8x8( x264_t *h, x264_cabac_t *cb, dctcoef
{
block_residual_write_cabac_internal( h, cb, DCT_LUMA_8x8, l, 1 );
}
static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int i_ctxBlockCat, dctcoef *l )
static void block_residual_write_cabac( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l )
{
block_residual_write_cabac_internal( h, cb, i_ctxBlockCat, l, 0 );
block_residual_write_cabac_internal( h, cb, ctx_block_cat, l, 0 );
}
#endif
#define block_residual_write_cabac_cbf( h, cb, i_ctxBlockCat, i_idx, l, b_intra )\
#define block_residual_write_cabac_cbf( h, cb, ctx_block_cat, i_idx, l, b_intra )\
{\
int ctxidxinc = x264_cabac_mb_cbf_ctxidxinc( h, i_ctxBlockCat, i_idx, b_intra );\
int ctxidxinc = x264_cabac_mb_cbf_ctxidxinc( h, ctx_block_cat, i_idx, b_intra );\
if( h->mb.cache.non_zero_count[x264_scan8[i_idx]] )\
{\
x264_cabac_encode_decision( cb, ctxidxinc, 1 );\
block_residual_write_cabac( h, cb, i_ctxBlockCat, l );\
block_residual_write_cabac( h, cb, ctx_block_cat, l );\
}\
else\
x264_cabac_encode_decision( cb, ctxidxinc, 0 );\
......
......@@ -116,7 +116,7 @@ static inline int block_residual_write_cavlc_escape( x264_t *h, int i_suffix_len
return i_suffix_length;
}
static int block_residual_write_cavlc_internal( x264_t *h, int i_ctxBlockCat, dctcoef *l, int nC )
static int block_residual_write_cavlc_internal( x264_t *h, int ctx_block_cat, dctcoef *l, int nC )
{
bs_t *s = &h->out.bs;
static const uint8_t ctz_index[8] = {3,0,1,0,2,0,1,0};
......@@ -130,7 +130,7 @@ static int block_residual_write_cavlc_internal( x264_t *h, int i_ctxBlockCat, dc
/* set these to 2 to allow branchless i_trailing calculation */
runlevel.level[1] = 2;
runlevel.level[2] = 2;
i_total = h->quantf.coeff_level_run[i_ctxBlockCat]( l, &runlevel );
i_total = h->quantf.coeff_level_run[ctx_block_cat]( l, &runlevel );
i_total_zero = runlevel.last + 1 - i_total;
i_trailing = ((((runlevel.level[0]+1) | (1-runlevel.level[0])) >> 31) & 1) // abs(runlevel.level[0])>1
......@@ -175,9 +175,9 @@ static int block_residual_write_cavlc_internal( x264_t *h, int i_ctxBlockCat, dc
}
}
if( (uint8_t)i_total < count_cat[i_ctxBlockCat] )
if( (uint8_t)i_total < count_cat[ctx_block_cat] )
{
if( i_ctxBlockCat == DCT_CHROMA_DC )
if( ctx_block_cat == DCT_CHROMA_DC )
bs_write_vlc( s, x264_total_zeros_dc[i_total-1][i_total_zero] );
else
bs_write_vlc( s, x264_total_zeros[i_total-1][i_total_zero] );
......
......@@ -81,11 +81,11 @@ static inline void dct2x2dc( dctcoef d[4], dctcoef dct4x4[4][16] )
dct4x4[3][0] = 0;
}
static ALWAYS_INLINE int x264_quant_4x4( x264_t *h, dctcoef dct[16], int i_qp, int i_ctxBlockCat, int b_intra, int idx )
static ALWAYS_INLINE int x264_quant_4x4( x264_t *h, dctcoef dct[16], int i_qp, int ctx_block_cat, int b_intra, int idx )
{
int i_quant_cat = b_intra ? CQM_4IY : CQM_4PY;
if( h->mb.b_trellis )
return x264_quant_4x4_trellis( h, dct, i_quant_cat, i_qp, i_ctxBlockCat, b_intra, 0, idx );
return x264_quant_4x4_trellis( h, dct, i_quant_cat, i_qp, ctx_block_cat, b_intra, 0, idx );
else
return h->quantf.quant_4x4( dct, h->quant4_mf[i_quant_cat][i_qp], h->quant4_bias[i_quant_cat][i_qp] );
}
......
......@@ -59,9 +59,9 @@ void x264_mb_encode_8x8_chroma( x264_t *h, int b_inter, int i_qp );
void x264_cabac_mb_skip( x264_t *h, int b_skip );
int x264_quant_dc_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
int i_qp, int i_ctxBlockCat, int b_intra, int b_chroma );
int i_qp, int ctx_block_cat, int b_intra, int b_chroma );
int x264_quant_4x4_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
int i_qp, int i_ctxBlockCat, int b_intra, int b_chroma, int idx );
int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
int x264_quant_8x8_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
int i_qp, int b_intra, int idx );
......
......@@ -417,7 +417,7 @@ static ALWAYS_INLINE
int quant_trellis_cabac( x264_t *h, dctcoef *dct,
const uint16_t *quant_mf, const int *unquant_mf,
const int *coef_weight, const uint8_t *zigzag,
int i_ctxBlockCat, int i_lambda2, int b_ac,
int ctx_block_cat, int i_lambda2, int b_ac,
int dc, int i_coefs, int idx )
{
int abs_coefs[64], signs[64];
......@@ -426,8 +426,8 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct,
trellis_node_t *nodes_prev = nodes[1];
trellis_node_t *bnode;
const int b_interlaced = h->mb.b_interlaced;
uint8_t *cabac_state_sig = &h->cabac.state[ significant_coeff_flag_offset[b_interlaced][i_ctxBlockCat] ];
uint8_t *cabac_state_last = &h->cabac.state[ last_coeff_flag_offset[b_interlaced][i_ctxBlockCat] ];
uint8_t *cabac_state_sig = &h->cabac.state[ significant_coeff_flag_offset[b_interlaced][ctx_block_cat] ];
uint8_t *cabac_state_last = &h->cabac.state[ last_coeff_flag_offset[b_interlaced][ctx_block_cat] ];
const int f = 1 << 15; // no deadzone
int i_last_nnz;
int i;
......@@ -480,7 +480,7 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct,
// in 8x8 blocks, some positions share contexts, so we'll just have to hope that
// cabac isn't too sensitive.
memcpy( nodes_cur[0].cabac_state, &h->cabac.state[ coeff_abs_level_m1_offset[i_ctxBlockCat] ], 10 );
memcpy( nodes_cur[0].cabac_state, &h->cabac.state[ coeff_abs_level_m1_offset[ctx_block_cat] ], 10 );
for( i = i_last_nnz; i >= b_ac; i-- )
{
......@@ -544,7 +544,7 @@ int quant_trellis_cabac( x264_t *h, dctcoef *dct,
int d = i_coef - unquant_abs_level;
int64_t ssd;
/* Psy trellis: bias in favor of higher AC coefficients in the reconstructed frame. */
if( h->mb.i_psy_trellis && i && !dc && i_ctxBlockCat != DCT_CHROMA_AC )
if( h->mb.i_psy_trellis && i && !dc && ctx_block_cat != DCT_CHROMA_AC )
{
int orig_coef = (i_coefs == 64) ? h->mb.pic.fenc_dct8[idx][zigzag[i]] : h->mb.pic.fenc_dct4[idx][zigzag[i]];
int predicted_coef = orig_coef - i_coef * signs[i];
......@@ -661,7 +661,7 @@ static ALWAYS_INLINE
int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
const uint16_t *quant_mf, const int *unquant_mf,
const int *coef_weight, const uint8_t *zigzag,
int i_ctxBlockCat, int i_lambda2, int b_ac,
int ctx_block_cat, int i_lambda2, int b_ac,
int dc, int i_coefs, int idx, int b_8x8 )
{
ALIGNED_16( dctcoef quant_coefs[2][16] );
......@@ -670,7 +670,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
int64_t score = 1ULL<<62;
int i, j;
const int f = 1<<15;
int nC = i_ctxBlockCat == DCT_CHROMA_DC ? 4 : ct_index[x264_mb_predict_non_zero_code( h, i_ctxBlockCat == DCT_LUMA_DC ? 0 : idx )];
int nC = ctx_block_cat == DCT_CHROMA_DC ? 4 : ct_index[x264_mb_predict_non_zero_code( h, ctx_block_cat == DCT_LUMA_DC ? 0 : idx )];
/* Code for handling 8x8dct -> 4x4dct CAVLC munging. Input/output use a different
* step/start/end than internal processing. */
......@@ -724,7 +724,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
delta_distortion[i] = (d0*d0 - d1*d1) * (dc?256:coef_weight[j]);
/* Psy trellis: bias in favor of higher AC coefficients in the reconstructed frame. */
if( h->mb.i_psy_trellis && j && !dc && i_ctxBlockCat != DCT_CHROMA_AC )
if( h->mb.i_psy_trellis && j && !dc && ctx_block_cat != DCT_CHROMA_AC )
{
int orig_coef = b_8x8 ? h->mb.pic.fenc_dct8[idx>>2][zigzag[j]] : h->mb.pic.fenc_dct4[idx][zigzag[j]];
int predicted_coef = orig_coef - coef;
......@@ -750,7 +750,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
if( !coef_mask )
bs_write_vlc( &h->out.bs, x264_coeff0_token[nC] );
else
block_residual_write_cavlc_internal( h, i_ctxBlockCat, coefs + b_ac, nC );
block_residual_write_cavlc_internal( h, ctx_block_cat, coefs + b_ac, nC );
score = (int64_t)h->out.bs.i_bits_encoded * i_lambda2;
/* QNS loop: pick the change that improves RD the most, apply it, repeat.
......@@ -783,7 +783,7 @@ int quant_trellis_cavlc( x264_t *h, dctcoef *dct,
if( !cur_mask )
bs_write_vlc( &h->out.bs, x264_coeff0_token[nC] );
else
block_residual_write_cavlc_internal( h, i_ctxBlockCat, coefs + b_ac, nC );
block_residual_write_cavlc_internal( h, ctx_block_cat, coefs + b_ac, nC );
cur_score += (int64_t)h->out.bs.i_bits_encoded * i_lambda2;
coefs[i] = old_coef;
......@@ -834,36 +834,36 @@ zeroblock:
const static uint8_t x264_zigzag_scan2[4] = {0,1,2,3};
int x264_quant_dc_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
int i_qp, int i_ctxBlockCat, int b_intra, int b_chroma )
int i_qp, int ctx_block_cat, int b_intra, int b_chroma )
{
if( h->param.b_cabac )
return quant_trellis_cabac( h, dct,
h->quant4_mf[i_quant_cat][i_qp], h->unquant4_mf[i_quant_cat][i_qp],
NULL, i_ctxBlockCat==DCT_CHROMA_DC ? x264_zigzag_scan2 : x264_zigzag_scan4[h->mb.b_interlaced],
i_ctxBlockCat, h->mb.i_trellis_lambda2[b_chroma][b_intra], 0, 1, i_ctxBlockCat==DCT_CHROMA_DC ? 4 : 16, 0 );
NULL, ctx_block_cat==DCT_CHROMA_DC ? x264_zigzag_scan2 : x264_zigzag_scan4[h->mb.b_interlaced],
ctx_block_cat, h->mb.i_trellis_lambda2[b_chroma][b_intra], 0, 1, ctx_block_cat==DCT_CHROMA_DC ? 4 : 16, 0 );
return quant_trellis_cavlc( h, dct,
h->quant4_mf[i_quant_cat][i_qp], h->unquant4_mf[i_quant_cat][i_qp],
NULL, i_ctxBlockCat==DCT_CHROMA_DC ? x264_zigzag_scan2 : x264_zigzag_scan4[h->mb.b_interlaced],
i_ctxBlockCat, h->mb.i_trellis_lambda2[b_chroma][b_intra], 0, 1, i_ctxBlockCat==DCT_CHROMA_DC ? 4 : 16, 0, 0 );
NULL, ctx_block_cat==DCT_CHROMA_DC ? x264_zigzag_scan2 : x264_zigzag_scan4[h->mb.b_interlaced],
ctx_block_cat, h->mb.i_trellis_lambda2[b_chroma][b_intra], 0, 1, ctx_block_cat==DCT_CHROMA_DC ? 4 : 16, 0, 0 );
}
int x264_quant_4x4_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
int i_qp, int i_ctxBlockCat, int b_intra, int b_chroma, int idx )
int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx )
{
int b_ac = (i_ctxBlockCat == DCT_LUMA_AC || i_ctxBlockCat == DCT_CHROMA_AC);
int b_ac = (ctx_block_cat == DCT_LUMA_AC || ctx_block_cat == DCT_CHROMA_AC);
if( h->param.b_cabac )
return quant_trellis_cabac( h, dct,
h->quant4_mf[i_quant_cat][i_qp], h->unquant4_mf[i_quant_cat][i_qp],
x264_dct4_weight2_zigzag[h->mb.b_interlaced],
x264_zigzag_scan4[h->mb.b_interlaced],
i_ctxBlockCat, h->mb.i_trellis_lambda2[b_chroma][b_intra], b_ac, 0, 16, idx );
ctx_block_cat, h->mb.i_trellis_lambda2[b_chroma][b_intra], b_ac, 0, 16, idx );
return quant_trellis_cavlc( h, dct,
h->quant4_mf[i_quant_cat][i_qp], h->unquant4_mf[i_quant_cat][i_qp],
x264_dct4_weight2_zigzag[h->mb.b_interlaced],
x264_zigzag_scan4[h->mb.b_interlaced],
i_ctxBlockCat, h->mb.i_trellis_lambda2[b_chroma][b_intra], b_ac, 0, 16, idx, 0 );
ctx_block_cat, h->mb.i_trellis_lambda2[b_chroma][b_intra], b_ac, 0, 16, idx, 0 );
}
int x264_quant_8x8_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
......
......@@ -149,10 +149,10 @@ static int write_headers( hnd_t handle, x264_nal_t *p_nal )
memcpy( avcC+11+sps_size, pps, pps_size );
ret = mk_writeHeader( p_mkv->w, "x264" X264_VERSION, "V_MPEG4/ISO/AVC",
avcC, avcC_len, p_mkv->frame_duration, 50000,
p_mkv->width, p_mkv->height,
p_mkv->d_width, p_mkv->d_height, p_mkv->display_size_units );
ret = mk_write_header( p_mkv->w, "x264" X264_VERSION, "V_MPEG4/ISO/AVC",
avcC, avcC_len, p_mkv->frame_duration, 50000,
p_mkv->width, p_mkv->height,
p_mkv->d_width, p_mkv->d_height, p_mkv->display_size_units );
if( ret < 0 )
return ret;
......
......@@ -320,13 +320,13 @@ mk_writer *mk_create_writer( const char *filename )
return w;
}
int mk_writeHeader( mk_writer *w, const char *writing_app,
const char *codec_id,
const void *codec_private, unsigned codec_private_size,
int64_t default_frame_duration,
int64_t timescale,
unsigned width, unsigned height,
unsigned d_width, unsigned d_height, int display_size_units )
int mk_write_header( mk_writer *w, const char *writing_app,
const char *codec_id,
const void *codec_private, unsigned codec_private_size,
int64_t default_frame_duration,
int64_t timescale,
unsigned width, unsigned height,
unsigned d_width, unsigned d_height, int display_size_units )
{
mk_context *c, *ti, *v;
......
......@@ -36,13 +36,13 @@ typedef struct mk_writer mk_writer;
mk_writer *mk_create_writer( const char *filename );
int mk_writeHeader( mk_writer *w, const char *writing_app,
const char *codec_id,
const void *codec_private, unsigned codec_private_size,
int64_t default_frame_duration,
int64_t timescale,
unsigned width, unsigned height,
unsigned d_width, unsigned d_height, int display_size_units );
int mk_write_header( mk_writer *w, const char *writing_app,
const char *codec_id,
const void *codec_private, unsigned codec_private_size,
int64_t default_frame_duration,
int64_t timescale,
unsigned width, unsigned height,
unsigned d_width, unsigned d_height, int display_size_units );
int mk_start_frame( mk_writer *w );
int mk_add_frame_data( mk_writer *w, const void *data, unsigned size );
......
......@@ -58,7 +58,7 @@
/* Ctrl-C handler */
static volatile int b_ctrl_c = 0;
static int b_exit_on_ctrl_c = 0;
static void SigIntHandler( int a )
static void sigint_handler( int a )
{
if( b_exit_on_ctrl_c )
exit(0);
......@@ -155,9 +155,9 @@ static const cli_pulldown_t pulldown_values[] =
// indexed by pic_struct enum
static const float pulldown_frame_duration[10] = { 0.0, 1, 0.5, 0.5, 1, 1, 1.5, 1.5, 2, 3 };
static void Help( x264_param_t *defaults, int longhelp );
static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt );
static int Encode( x264_param_t *param, cli_opt_t *opt );
static void help( x264_param_t *defaults, int longhelp );
static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt );
static int encode( x264_param_t *param, cli_opt_t *opt );
/* logging and printing for within the cli system */
static int cli_log_level;
......@@ -231,9 +231,6 @@ static void print_version_info()
#endif
}
/****************************************************************************
* main:
****************************************************************************/
int main( int argc, char **argv )
{
x264_param_t param;
......@@ -251,13 +248,13 @@ int main( int argc, char **argv )
#endif
/* Parse command line */
if( Parse( argc, argv, &param, &opt ) < 0 )
if( parse( argc, argv, &param, &opt ) < 0 )
return -1;
/* Control-C handler */
signal( SIGINT, SigIntHandler );
signal( SIGINT, sigint_handler );
ret = Encode( &param, &opt );
ret = encode( &param, &opt );
#if PTW32_STATIC_LIB
pthread_win32_thread_detach_np();
......@@ -325,10 +322,7 @@ static void print_csp_names( int longhelp )
printf( "\n" );
}
/*****************************************************************************
* Help:
*****************************************************************************/
static void Help( x264_param_t *defaults, int longhelp )
static void help( x264_param_t *defaults, int longhelp )
{
char buf[50];
#define H0 printf
......@@ -744,7 +738,8 @@ static void Help( x264_param_t *defaults, int longhelp )
H0( "\n" );
}
enum {
enum
{
OPT_FRAMES = 256,
OPT_SEEK,
OPT_QPFILE,
......@@ -1120,10 +1115,7 @@ static int parse_enum_value( const char *arg, const char * const *names, int *ds
return -1;
}
/*****************************************************************************
* Parse:
*****************************************************************************/
static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
static int parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
{
char *input_filename = NULL;
const char *demuxer = demuxer_names[0];
......@@ -1186,13 +1178,13 @@ static int Parse( int argc, char **argv, x264_param_t *param, cli_opt_t *opt )
switch( c )
{
case 'h':
Help( &defaults, 0 );
help( &defaults, 0 );
exit(0);
case OPT_LONGHELP:
Help( &defaults, 1 );
help( &defaults, 1 );
exit(0);
case OPT_FULLHELP:
Help( &defaults, 2 );
help( &defaults, 2 );
exit(0);
case 'V':
print_version_info();
......@@ -1517,11 +1509,7 @@ static void parse_qpfile( cli_opt_t *opt, x264_picture_t *pic, int i_frame )
}
}
/*****************************************************************************
* Encode:
*****************************************************************************/
static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *last_dts )
static int encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *last_dts )
{
x264_picture_t pic_out;
x264_nal_t *nal;
......@@ -1541,9 +1529,9 @@ static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *l
return i_frame_size;
}
static void Print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
static void print_status( int64_t i_start, int i_frame, int i_frame_total, int64_t i_file, x264_param_t *param, int64_t last_ts )
{
char buf[200];
char buf[200];
int64_t i_elapsed = x264_mdate() - i_start;
double fps = i_elapsed > 0 ? i_frame * 1000000. / i_elapsed : 0;
double bitrate;
......@@ -1567,7 +1555,7 @@ static void Print_status( int64_t i_start, int i_frame, int i_frame_total, int64
fflush( stderr ); // needed in windows
}
static void Convert_cli_to_lib_pic( x264_picture_t *lib, cli_pic_t *cli )
static void convert_cli_to_lib_pic( x264_picture_t *lib, cli_pic_t *cli )
{
memcpy( lib->img.i_stride, cli->img.stride, sizeof(cli->img.stride) );
memcpy( lib->img.plane, cli->img.plane, sizeof(cli->img.plane) );
......@@ -1576,7 +1564,7 @@ static void Convert_cli_to_lib_pic( x264_picture_t *lib, cli_pic_t *cli )
lib->i_pts = cli->pts;
}
static int Encode( x264_param_t *param, cli_opt_t *opt )
static int encode( x264_param_t *param, cli_opt_t *opt )
{
x264_t *h;
x264_picture_t pic;
......@@ -1662,7 +1650,7 @@ static int Encode( x264_param_t *param, cli_opt_t *opt )
{
if( filter.get_frame( opt->hin, &cli_pic, i_frame + opt->i_seek ) )
break;
Convert_cli_to_lib_pic( &pic, &cli_pic );
convert_cli_to_lib_pic( &pic, &cli_pic );
if( !param->b_vfr_input )
pic.i_pts = i_frame;
......@@ -1705,7 +1693,7 @@ static int Encode( x264_param_t *param, cli_opt_t *opt )
}
prev_dts = last_dts;
i_frame_size = Encode_frame( h, opt->hout, &pic, &last_dts );
i_frame_size = encode_frame( h, opt->hout, &pic, &last_dts );
if( i_frame_size < 0 )
return -1;
i_file += i_frame_size;
......@@ -1721,13 +1709,13 @@ static int Encode( x264_param_t *param, cli_opt_t *opt )
/* update status line (up to 1000 times per input file) */
if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
Print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
/* Flush delayed frames */
while( !b_ctrl_c && x264_encoder_delayed_frames( h ) )
{
prev_dts = last_dts;
i_frame_size = Encode_frame( h, opt->hout, NULL, &last_dts );
i_frame_size = encode_frame( h, opt->hout, NULL, &last_dts );
if( i_frame_size < 0 )
return -1;
i_file += i_frame_size;
......@@ -1738,7 +1726,7 @@ static int Encode( x264_param_t *param, cli_opt_t *opt )
first_dts = prev_dts = last_dts;
}
if( opt->b_progress && i_frame_output % i_update_interval == 0 && i_frame_output )
Print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
print_status( i_start, i_frame_output, param->i_frame_total, i_file, param, 2 * last_dts - prev_dts - first_dts );
}
if( pts_warning_cnt >= MAX_PTS_WARNING && cli_log_level < X264_LOG_DEBUG )
x264_cli_log( "x264", X264_LOG_WARNING, "%d suppressed nonmonotonic pts warnings\n", pts_warning_cnt-MAX_PTS_WARNING );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment