From e93cfd6adcdd246372a38f2598590c0ab7c69b7d Mon Sep 17 00:00:00 2001 From: Anton Mitrofanov Date: Wed, 20 Jul 2011 18:06:41 +0400 Subject: [PATCH] Various cosmetics --- common/macroblock.c | 6 +- common/mc.c | 2 +- common/mc.h | 2 +- common/pixel.c | 2 +- encoder/analyse.c | 28 ++++----- encoder/encoder.c | 4 +- encoder/me.c | 6 +- encoder/slicetype.c | 6 +- filters/video/source.c | 10 ++-- input/input.h | 2 +- input/thread.c | 4 +- input/timecode.c | 2 +- output/flv.c | 124 ++++++++++++++++++++-------------------- output/flv_bytestream.c | 48 ++++++++-------- output/flv_bytestream.h | 23 ++++---- tools/checkasm.c | 4 +- x264.c | 48 ++++++++-------- 17 files changed, 160 insertions(+), 161 deletions(-) diff --git a/common/macroblock.c b/common/macroblock.c index 0fb7d12c..8d1c157e 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -32,7 +32,7 @@ h->mc.mc_luma( &h->mb.pic.p_fdec[p][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, \ &h->mb.pic.p_fref[list][i_ref][p*4], h->mb.pic.i_stride[p], \ mvx, mvy, 4*width, 4*height, \ - list ? weight_none : &h->sh.weight[i_ref][p] ); + list ? x264_weight_none : &h->sh.weight[i_ref][p] ); static NOINLINE void x264_mb_mc_0xywh( x264_t *h, int x, int y, int width, int height ) { @@ -97,9 +97,9 @@ static NOINLINE void x264_mb_mc_1xywh( x264_t *h, int x, int y, int width, int h #define MC_LUMA_BI(p) \ src0 = h->mc.get_ref( tmp0, &i_stride0, &h->mb.pic.p_fref[0][i_ref0][p*4], h->mb.pic.i_stride[p], \ - mvx0, mvy0, 4*width, 4*height, weight_none ); \ + mvx0, mvy0, 4*width, 4*height, x264_weight_none ); \ src1 = h->mc.get_ref( tmp1, &i_stride1, &h->mb.pic.p_fref[1][i_ref1][p*4], h->mb.pic.i_stride[p], \ - mvx1, mvy1, 4*width, 4*height, weight_none ); \ + mvx1, mvy1, 4*width, 4*height, x264_weight_none ); \ h->mc.avg[i_mode]( &h->mb.pic.p_fdec[p][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, \ src0, i_stride0, src1, i_stride1, weight ); diff --git a/common/mc.c b/common/mc.c index de1c6784..5352be14 100644 --- a/common/mc.c +++ b/common/mc.c @@ -143,7 +143,7 @@ static weight_fn_t x264_mc_weight_wtab[6] = mc_weight_w16, mc_weight_w20, }; -const x264_weight_t weight_none[3] = { {{0}} }; +const x264_weight_t x264_weight_none[3] = { {{0}} }; static void mc_copy( pixel *src, int i_src_stride, pixel *dst, int i_dst_stride, int i_width, int i_height ) { for( int y = 0; y < i_height; y++ ) diff --git a/common/mc.h b/common/mc.h index f19a9979..15a0a254 100644 --- a/common/mc.h +++ b/common/mc.h @@ -40,7 +40,7 @@ typedef struct x264_weight_t weight_fn_t *weightfn; } ALIGNED_16( x264_weight_t ); -extern const x264_weight_t weight_none[3]; +extern const x264_weight_t x264_weight_none[3]; #define SET_WEIGHT( w, b, s, d, o )\ {\ diff --git a/common/pixel.c b/common/pixel.c index aa490308..043342e2 100644 --- a/common/pixel.c +++ b/common/pixel.c @@ -642,7 +642,7 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, return ssim; } -int pixel_vsad( pixel *src, int stride, int height ) +static int pixel_vsad( pixel *src, int stride, int height ) { int score = 0; for( int i = 1; i < height; i++, src += stride ) diff --git a/encoder/analyse.c b/encoder/analyse.c index 21d4421f..36cdd707 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -1281,7 +1281,7 @@ static void x264_intra_rd_refine( x264_t *h, x264_mb_analysis_t *a ) else \ (m)->p_fref[4] = &(src)[4][(xoff)+((yoff)>>1)*(m)->i_stride[1]]; \ (m)->integral = &h->mb.pic.p_integral[list][ref][(xoff)+(yoff)*(m)->i_stride[0]]; \ - (m)->weight = weight_none; \ + (m)->weight = x264_weight_none; \ (m)->i_ref = ref; \ } @@ -1831,13 +1831,13 @@ static ALWAYS_INLINE int x264_analyse_bi_chroma( x264_t *h, x264_mb_analysis_t * if( CHROMA444 ) \ { \ h->mc.mc_luma( pix[0], 16, &m0.p_fref[4], m0.i_stride[1], \ - m0.mv[0], m0.mv[1], 2*width, 2*height, weight_none ); \ + m0.mv[0], m0.mv[1], 2*width, 2*height, x264_weight_none ); \ h->mc.mc_luma( pix[1], 16, &m0.p_fref[8], m0.i_stride[2], \ - m0.mv[0], m0.mv[1], 2*width, 2*height, weight_none ); \ + m0.mv[0], m0.mv[1], 2*width, 2*height, x264_weight_none ); \ h->mc.mc_luma( pix[2], 16, &m1.p_fref[4], m1.i_stride[1], \ - m1.mv[0], m1.mv[1], 2*width, 2*height, weight_none ); \ + m1.mv[0], m1.mv[1], 2*width, 2*height, x264_weight_none ); \ h->mc.mc_luma( pix[3], 16, &m1.p_fref[8], m1.i_stride[2], \ - m1.mv[0], m1.mv[1], 2*width, 2*height, weight_none ); \ + m1.mv[0], m1.mv[1], 2*width, 2*height, x264_weight_none ); \ h->mc.avg[i_pixel]( bi[0], 16, pix[0], 16, pix[2], 16, h->mb.bipred_weight[m0.i_ref][m1.i_ref] ); \ h->mc.avg[i_pixel]( bi[1], 16, pix[1], 16, pix[3], 16, h->mb.bipred_weight[m0.i_ref][m1.i_ref] ); \ i_chroma_cost = h->pixf.mbcmp[i_pixel]( m0.p_fenc[1], FENC_STRIDE, bi[0], 16 ); \ @@ -2003,10 +2003,10 @@ static void x264_mb_analyse_inter_b16x16( x264_t *h, x264_mb_analysis_t *a ) int ref_costs = REF_COST( 0, a->l0.bi16x16.i_ref ) + REF_COST( 1, a->l1.bi16x16.i_ref ); src0 = h->mc.get_ref( pix0, &stride0, h->mb.pic.p_fref[0][a->l0.bi16x16.i_ref], h->mb.pic.i_stride[0], - a->l0.bi16x16.mv[0], a->l0.bi16x16.mv[1], 16, 16, weight_none ); + a->l0.bi16x16.mv[0], a->l0.bi16x16.mv[1], 16, 16, x264_weight_none ); src1 = h->mc.get_ref( pix1, &stride1, h->mb.pic.p_fref[1][a->l1.bi16x16.i_ref], h->mb.pic.i_stride[0], - a->l1.bi16x16.mv[0], a->l1.bi16x16.mv[1], 16, 16, weight_none ); + a->l1.bi16x16.mv[0], a->l1.bi16x16.mv[1], 16, 16, x264_weight_none ); h->mc.avg[PIXEL_16x16]( pix0, 16, src0, stride0, src1, stride1, h->mb.bipred_weight[a->l0.bi16x16.i_ref][a->l1.bi16x16.i_ref] ); @@ -2264,9 +2264,9 @@ static void x264_mb_analyse_inter_b8x8_mixed_ref( x264_t *h, x264_mb_analysis_t /* BI mode */ src[0] = h->mc.get_ref( pix[0], &stride[0], a->l0.me8x8[i].p_fref, a->l0.me8x8[i].i_stride[0], - a->l0.me8x8[i].mv[0], a->l0.me8x8[i].mv[1], 8, 8, weight_none ); + a->l0.me8x8[i].mv[0], a->l0.me8x8[i].mv[1], 8, 8, x264_weight_none ); src[1] = h->mc.get_ref( pix[1], &stride[1], a->l1.me8x8[i].p_fref, a->l1.me8x8[i].i_stride[0], - a->l1.me8x8[i].mv[0], a->l1.me8x8[i].mv[1], 8, 8, weight_none ); + a->l1.me8x8[i].mv[0], a->l1.me8x8[i].mv[1], 8, 8, x264_weight_none ); h->mc.avg[PIXEL_8x8]( pix[0], 8, src[0], stride[0], src[1], stride[1], h->mb.bipred_weight[a->l0.me8x8[i].i_ref][a->l1.me8x8[i].i_ref] ); @@ -2346,7 +2346,7 @@ static void x264_mb_analyse_inter_b8x8( x264_t *h, x264_mb_analysis_t *a ) /* BI mode */ src[l] = h->mc.get_ref( pix[l], &stride[l], m->p_fref, m->i_stride[0], - m->mv[0], m->mv[1], 8, 8, weight_none ); + m->mv[0], m->mv[1], 8, 8, x264_weight_none ); i_part_cost_bi += m->cost_mv + m->i_ref_cost; } h->mc.avg[PIXEL_8x8]( pix[0], 8, src[0], stride[0], src[1], stride[1], h->mb.bipred_weight[a->l0.me16x16.i_ref][a->l1.me16x16.i_ref] ); @@ -2424,9 +2424,9 @@ static void x264_mb_analyse_inter_b16x8( x264_t *h, x264_mb_analysis_t *a, int i /* BI mode */ src[0] = h->mc.get_ref( pix[0], &stride[0], a->l0.me16x8[i].p_fref, a->l0.me16x8[i].i_stride[0], - a->l0.me16x8[i].mv[0], a->l0.me16x8[i].mv[1], 16, 8, weight_none ); + a->l0.me16x8[i].mv[0], a->l0.me16x8[i].mv[1], 16, 8, x264_weight_none ); src[1] = h->mc.get_ref( pix[1], &stride[1], a->l1.me16x8[i].p_fref, a->l1.me16x8[i].i_stride[0], - a->l1.me16x8[i].mv[0], a->l1.me16x8[i].mv[1], 16, 8, weight_none ); + a->l1.me16x8[i].mv[0], a->l1.me16x8[i].mv[1], 16, 8, x264_weight_none ); h->mc.avg[PIXEL_16x8]( pix[0], 16, src[0], stride[0], src[1], stride[1], h->mb.bipred_weight[a->l0.me16x8[i].i_ref][a->l1.me16x8[i].i_ref] ); @@ -2518,9 +2518,9 @@ static void x264_mb_analyse_inter_b8x16( x264_t *h, x264_mb_analysis_t *a, int i /* BI mode */ src[0] = h->mc.get_ref( pix[0], &stride[0], a->l0.me8x16[i].p_fref, a->l0.me8x16[i].i_stride[0], - a->l0.me8x16[i].mv[0], a->l0.me8x16[i].mv[1], 8, 16, weight_none ); + a->l0.me8x16[i].mv[0], a->l0.me8x16[i].mv[1], 8, 16, x264_weight_none ); src[1] = h->mc.get_ref( pix[1], &stride[1], a->l1.me8x16[i].p_fref, a->l1.me8x16[i].i_stride[0], - a->l1.me8x16[i].mv[0], a->l1.me8x16[i].mv[1], 8, 16, weight_none ); + a->l1.me8x16[i].mv[0], a->l1.me8x16[i].mv[1], 8, 16, x264_weight_none ); h->mc.avg[PIXEL_8x16]( pix[0], 8, src[0], stride[0], src[1], stride[1], h->mb.bipred_weight[a->l0.me8x16[i].i_ref][a->l1.me8x16[i].i_ref] ); i_part_cost_bi = h->pixf.mbcmp[PIXEL_8x16]( a->l0.me8x16[i].p_fenc[0], FENC_STRIDE, pix[0], 8 ) diff --git a/encoder/encoder.c b/encoder/encoder.c index 1c6989b0..927e4226 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -1519,7 +1519,7 @@ int x264_weighted_reference_duplicate( x264_t *h, int i_ref, const x264_weight_t /* Duplication is a hack to compensate for crappy rounding in motion compensation. * With high bit depth, it's not worth doing, so turn it off except in the case of * unweighted dupes. */ - if( BIT_DEPTH > 8 && w != weight_none ) + if( BIT_DEPTH > 8 && w != x264_weight_none ) return -1; newframe = x264_frame_pop_blank_unused( h ); @@ -1719,7 +1719,7 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc ) { SET_WEIGHT( h->fenc->weight[0][0], 1, 1, 0, h->fenc->weight[0][0].i_offset ); } - x264_weighted_reference_duplicate( h, 0, weight_none ); + x264_weighted_reference_duplicate( h, 0, x264_weight_none ); if( h->fenc->weight[0][0].i_offset > -128 ) { w[0] = h->fenc->weight[0][0]; diff --git a/encoder/me.c b/encoder/me.c index 230a555b..68518647 100644 --- a/encoder/me.c +++ b/encoder/me.c @@ -937,17 +937,17 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite int mvy = bm##list##y+dy;\ stride[0][list][i] = bw;\ src[0][list][i] = h->mc.get_ref( pixy_buf[list][i], &stride[0][list][i], &m->p_fref[0],\ - m->i_stride[0], mvx, mvy, bw, bh, weight_none );\ + m->i_stride[0], mvx, mvy, bw, bh, x264_weight_none );\ if( rd )\ {\ if( CHROMA444 )\ {\ stride[1][list][i] = bw;\ src[1][list][i] = h->mc.get_ref( pixu_buf[list][i], &stride[1][list][i], &m->p_fref[4],\ - m->i_stride[1], mvx, mvy, bw, bh, weight_none );\ + m->i_stride[1], mvx, mvy, bw, bh, x264_weight_none );\ stride[2][list][i] = bw;\ src[2][list][i] = h->mc.get_ref( pixv_buf[list][i], &stride[2][list][i], &m->p_fref[8],\ - m->i_stride[2], mvx, mvy, bw, bh, weight_none );\ + m->i_stride[2], mvx, mvy, bw, bh, x264_weight_none );\ }\ else\ h->mc.mc_chroma( pixu_buf[list][i], pixv_buf[list][i], 8, m->p_fref[4], m->i_stride[1],\ diff --git a/encoder/slicetype.c b/encoder/slicetype.c index 88186610..72e26cf6 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -87,7 +87,7 @@ static NOINLINE pixel *x264_weight_cost_init_luma( x264_t *h, x264_frame_t *fenc int mvx = fenc->lowres_mvs[0][ref0_distance][i_mb_xy][0]; int mvy = fenc->lowres_mvs[0][ref0_distance][i_mb_xy][1]; h->mc.mc_luma( p+x, i_stride, ref->lowres, i_stride, - mvx+(x<<2), mvy+(y<<2), 8, 8, weight_none ); + mvx+(x<<2), mvy+(y<<2), 8, 8, x264_weight_none ); } x264_emms(); return dest; @@ -531,7 +531,7 @@ static void x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a, m[1].i_stride[0] = i_stride; m[1].p_fenc[0] = h->mb.pic.p_fenc[0]; m[1].i_ref = 0; - m[1].weight = weight_none; + m[1].weight = x264_weight_none; LOAD_HPELS_LUMA( m[1].p_fref, fref1->lowres ); m[1].p_fref_w = m[1].p_fref[0]; @@ -703,7 +703,7 @@ static int x264_slicetype_frame_cost( x264_t *h, x264_mb_analysis_t *a, { int i_score = 0; int do_search[2]; - const x264_weight_t *w = weight_none; + const x264_weight_t *w = x264_weight_none; /* Check whether we already evaluated this frame * If we have tried this frame as P, then we have also tried * the preceding frames as B. (is this still true?) */ diff --git a/filters/video/source.c b/filters/video/source.c index 2f2244b2..c04b45c5 100644 --- a/filters/video/source.c +++ b/filters/video/source.c @@ -44,7 +44,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2 return -1; h->cur_frame = -1; - if( input.picture_alloc( &h->pic, info->csp, info->width, info->height ) ) + if( cli_input.picture_alloc( &h->pic, info->csp, info->width, info->height ) ) return -1; h->hin = *handle; @@ -58,7 +58,7 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) { source_hnd_t *h = handle; /* do not allow requesting of frames from before the current position */ - if( frame <= h->cur_frame || input.read_frame( &h->pic, h->hin, frame ) ) + if( frame <= h->cur_frame || cli_input.read_frame( &h->pic, h->hin, frame ) ) return -1; h->cur_frame = frame; *output = h->pic; @@ -68,7 +68,7 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) static int release_frame( hnd_t handle, cli_pic_t *pic, int frame ) { source_hnd_t *h = handle; - if( input.release_frame && input.release_frame( &h->pic, h->hin ) ) + if( cli_input.release_frame && cli_input.release_frame( &h->pic, h->hin ) ) return -1; return 0; } @@ -76,8 +76,8 @@ static int release_frame( hnd_t handle, cli_pic_t *pic, int frame ) static void free_filter( hnd_t handle ) { source_hnd_t *h = handle; - input.picture_clean( &h->pic ); - input.close_file( h->hin ); + cli_input.picture_clean( &h->pic ); + cli_input.close_file( h->hin ); free( h ); } diff --git a/input/input.h b/input/input.h index eb928eac..4a4bb0b2 100644 --- a/input/input.h +++ b/input/input.h @@ -100,7 +100,7 @@ extern const cli_input_t lavf_input; extern const cli_input_t ffms_input; extern cli_input_t timecode_input; -extern cli_input_t input; +extern cli_input_t cli_input; /* extended colorspace list that isn't supported by libx264 but by the cli */ #define X264_CSP_I422 X264_CSP_MAX /* yuv 4:2:2 planar */ diff --git a/input/thread.c b/input/thread.c index 15d03c69..7d037377 100644 --- a/input/thread.c +++ b/input/thread.c @@ -48,9 +48,9 @@ typedef struct thread_input_arg_t static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, cli_input_opt_t *opt ) { thread_hnd_t *h = malloc( sizeof(thread_hnd_t) ); - FAIL_IF_ERR( !h || input.picture_alloc( &h->pic, info->csp, info->width, info->height ), + FAIL_IF_ERR( !h || cli_input.picture_alloc( &h->pic, info->csp, info->width, info->height ), "x264", "malloc failed\n" ) - h->input = input; + h->input = cli_input; h->p_handle = *p_handle; h->next_frame = -1; h->next_args = malloc( sizeof(thread_input_arg_t) ); diff --git a/input/timecode.c b/input/timecode.c index dfb0dfd0..7767896d 100644 --- a/input/timecode.c +++ b/input/timecode.c @@ -340,7 +340,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c FILE *tcfile_in; timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) ); FAIL_IF_ERROR( !h, "malloc failed\n" ) - h->input = input; + h->input = cli_input; h->p_handle = *p_handle; if( opt->timebase ) { diff --git a/output/flv.c b/output/flv.c index 87335b83..0637c380 100644 --- a/output/flv.c +++ b/output/flv.c @@ -64,11 +64,11 @@ typedef struct static int write_header( flv_buffer *c ) { - x264_put_tag( c, "FLV" ); // Signature - x264_put_byte( c, 1 ); // Version - x264_put_byte( c, 1 ); // Video Only - x264_put_be32( c, 9 ); // DataOffset - x264_put_be32( c, 0 ); // PreviousTagSize0 + flv_put_tag( c, "FLV" ); // Signature + flv_put_byte( c, 1 ); // Version + flv_put_byte( c, 1 ); // Video Only + flv_put_be32( c, 9 ); // DataOffset + flv_put_be32( c, 0 ); // PreviousTagSize0 return flv_flush_data( c ); } @@ -98,57 +98,57 @@ static int set_param( hnd_t handle, x264_param_t *p_param ) flv_hnd_t *p_flv = handle; flv_buffer *c = p_flv->c; - x264_put_byte( c, FLV_TAG_TYPE_META ); // Tag Type "script data" + flv_put_byte( c, FLV_TAG_TYPE_META ); // Tag Type "script data" int start = c->d_cur; - x264_put_be24( c, 0 ); // data length - x264_put_be24( c, 0 ); // timestamp - x264_put_be32( c, 0 ); // reserved + flv_put_be24( c, 0 ); // data length + flv_put_be24( c, 0 ); // timestamp + flv_put_be32( c, 0 ); // reserved - x264_put_byte( c, AMF_DATA_TYPE_STRING ); - x264_put_amf_string( c, "onMetaData" ); + flv_put_byte( c, AMF_DATA_TYPE_STRING ); + flv_put_amf_string( c, "onMetaData" ); - x264_put_byte( c, AMF_DATA_TYPE_MIXEDARRAY ); - x264_put_be32( c, 7 ); + flv_put_byte( c, AMF_DATA_TYPE_MIXEDARRAY ); + flv_put_be32( c, 7 ); - x264_put_amf_string( c, "width" ); - x264_put_amf_double( c, p_param->i_width ); + flv_put_amf_string( c, "width" ); + flv_put_amf_double( c, p_param->i_width ); - x264_put_amf_string( c, "height" ); - x264_put_amf_double( c, p_param->i_height ); + flv_put_amf_string( c, "height" ); + flv_put_amf_double( c, p_param->i_height ); - x264_put_amf_string( c, "framerate" ); + flv_put_amf_string( c, "framerate" ); if( !p_param->b_vfr_input ) - x264_put_amf_double( c, (double)p_param->i_fps_num / p_param->i_fps_den ); + flv_put_amf_double( c, (double)p_param->i_fps_num / p_param->i_fps_den ); else { p_flv->i_framerate_pos = c->d_cur + c->d_total + 1; - x264_put_amf_double( c, 0 ); // written at end of encoding + flv_put_amf_double( c, 0 ); // written at end of encoding } - x264_put_amf_string( c, "videocodecid" ); - x264_put_amf_double( c, FLV_CODECID_H264 ); + flv_put_amf_string( c, "videocodecid" ); + flv_put_amf_double( c, FLV_CODECID_H264 ); - x264_put_amf_string( c, "duration" ); + flv_put_amf_string( c, "duration" ); p_flv->i_duration_pos = c->d_cur + c->d_total + 1; - x264_put_amf_double( c, 0 ); // written at end of encoding + flv_put_amf_double( c, 0 ); // written at end of encoding - x264_put_amf_string( c, "filesize" ); + flv_put_amf_string( c, "filesize" ); p_flv->i_filesize_pos = c->d_cur + c->d_total + 1; - x264_put_amf_double( c, 0 ); // written at end of encoding + flv_put_amf_double( c, 0 ); // written at end of encoding - x264_put_amf_string( c, "videodatarate" ); + flv_put_amf_string( c, "videodatarate" ); p_flv->i_bitrate_pos = c->d_cur + c->d_total + 1; - x264_put_amf_double( c, 0 ); // written at end of encoding + flv_put_amf_double( c, 0 ); // written at end of encoding - x264_put_amf_string( c, "" ); - x264_put_byte( c, AMF_END_OF_OBJECT ); + flv_put_amf_string( c, "" ); + flv_put_byte( c, AMF_END_OF_OBJECT ); unsigned length = c->d_cur - start; - rewrite_amf_be24( c, length - 10, start ); + flv_rewrite_amf_be24( c, length - 10, start ); - x264_put_be32( c, length + 1 ); // tag length + flv_put_be32( c, length + 1 ); // tag length p_flv->i_fps_num = p_param->i_fps_num; p_flv->i_fps_den = p_param->i_fps_den; @@ -182,36 +182,36 @@ static int write_headers( hnd_t handle, x264_nal_t *p_nal ) // SPS uint8_t *sps = p_nal[0].p_payload + 4; - x264_put_byte( c, FLV_TAG_TYPE_VIDEO ); - x264_put_be24( c, 0 ); // rewrite later - x264_put_be24( c, 0 ); // timestamp - x264_put_byte( c, 0 ); // timestamp extended - x264_put_be24( c, 0 ); // StreamID - Always 0 + flv_put_byte( c, FLV_TAG_TYPE_VIDEO ); + flv_put_be24( c, 0 ); // rewrite later + flv_put_be24( c, 0 ); // timestamp + flv_put_byte( c, 0 ); // timestamp extended + flv_put_be24( c, 0 ); // StreamID - Always 0 p_flv->start = c->d_cur; // needed for overwriting length - x264_put_byte( c, 7 | FLV_FRAME_KEY ); // Frametype and CodecID - x264_put_byte( c, 0 ); // AVC sequence header - x264_put_be24( c, 0 ); // composition time + flv_put_byte( c, 7 | FLV_FRAME_KEY ); // Frametype and CodecID + flv_put_byte( c, 0 ); // AVC sequence header + flv_put_be24( c, 0 ); // composition time - x264_put_byte( c, 1 ); // version - x264_put_byte( c, sps[1] ); // profile - x264_put_byte( c, sps[2] ); // profile - x264_put_byte( c, sps[3] ); // level - x264_put_byte( c, 0xff ); // 6 bits reserved (111111) + 2 bits nal size length - 1 (11) - x264_put_byte( c, 0xe1 ); // 3 bits reserved (111) + 5 bits number of sps (00001) + flv_put_byte( c, 1 ); // version + flv_put_byte( c, sps[1] ); // profile + flv_put_byte( c, sps[2] ); // profile + flv_put_byte( c, sps[3] ); // level + flv_put_byte( c, 0xff ); // 6 bits reserved (111111) + 2 bits nal size length - 1 (11) + flv_put_byte( c, 0xe1 ); // 3 bits reserved (111) + 5 bits number of sps (00001) - x264_put_be16( c, sps_size - 4 ); + flv_put_be16( c, sps_size - 4 ); flv_append_data( c, sps, sps_size - 4 ); // PPS - x264_put_byte( c, 1 ); // number of pps - x264_put_be16( c, pps_size - 4 ); + flv_put_byte( c, 1 ); // number of pps + flv_put_be16( c, pps_size - 4 ); flv_append_data( c, p_nal[1].p_payload + 4, pps_size - 4 ); // rewrite data length info unsigned length = c->d_cur - p_flv->start; - rewrite_amf_be24( c, length, p_flv->start - 10 ); - x264_put_be32( c, length + 11 ); // Last tag size + flv_rewrite_amf_be24( c, length, p_flv->start - 10 ); + flv_put_be32( c, length + 11 ); // Last tag size CHECK( flv_flush_data( c ) ); return sei_size + sps_size + pps_size; @@ -265,16 +265,16 @@ static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_ p_flv->i_prev_cts = cts; // A new frame - write packet header - x264_put_byte( c, FLV_TAG_TYPE_VIDEO ); - x264_put_be24( c, 0 ); // calculated later - x264_put_be24( c, dts ); - x264_put_byte( c, dts >> 24 ); - x264_put_be24( c, 0 ); + flv_put_byte( c, FLV_TAG_TYPE_VIDEO ); + flv_put_be24( c, 0 ); // calculated later + flv_put_be24( c, dts ); + flv_put_byte( c, dts >> 24 ); + flv_put_be24( c, 0 ); p_flv->start = c->d_cur; - x264_put_byte( c, p_picture->b_keyframe ? FLV_FRAME_KEY : FLV_FRAME_INTER ); - x264_put_byte( c, 1 ); // AVC NALU - x264_put_be24( c, offset ); + flv_put_byte( c, p_picture->b_keyframe ? FLV_FRAME_KEY : FLV_FRAME_INTER ); + flv_put_byte( c, 1 ); // AVC NALU + flv_put_be24( c, offset ); if( p_flv->sei ) { @@ -285,8 +285,8 @@ static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_ flv_append_data( c, p_nalu, i_size ); unsigned length = c->d_cur - p_flv->start; - rewrite_amf_be24( c, length, p_flv->start - 10 ); - x264_put_be32( c, 11 + length ); // Last tag size + flv_rewrite_amf_be24( c, length, p_flv->start - 10 ); + flv_put_be32( c, 11 + length ); // Last tag size CHECK( flv_flush_data( c ) ); p_flv->i_framenum++; @@ -296,7 +296,7 @@ static int write_frame( hnd_t handle, uint8_t *p_nalu, int i_size, x264_picture_ static void rewrite_amf_double( FILE *fp, uint64_t position, double value ) { - uint64_t x = endian_fix64( dbl2int( value ) ); + uint64_t x = endian_fix64( flv_dbl2int( value ) ); fseek( fp, position, SEEK_SET ); fwrite( &x, 8, 1, fp ); } diff --git a/output/flv_bytestream.c b/output/flv_bytestream.c index 293dc81a..ca99db7b 100644 --- a/output/flv_bytestream.c +++ b/output/flv_bytestream.c @@ -26,61 +26,61 @@ #include "output.h" #include "flv_bytestream.h" -uint64_t dbl2int( double value ) +uint64_t flv_dbl2int( double value ) { return (union {double f; uint64_t i;}){value}.i; } /* Put functions */ -void x264_put_byte( flv_buffer *c, uint8_t b ) +void flv_put_byte( flv_buffer *c, uint8_t b ) { flv_append_data( c, &b, 1 ); } -void x264_put_be32( flv_buffer *c, uint32_t val ) +void flv_put_be32( flv_buffer *c, uint32_t val ) { - x264_put_byte( c, val >> 24 ); - x264_put_byte( c, val >> 16 ); - x264_put_byte( c, val >> 8 ); - x264_put_byte( c, val ); + flv_put_byte( c, val >> 24 ); + flv_put_byte( c, val >> 16 ); + flv_put_byte( c, val >> 8 ); + flv_put_byte( c, val ); } -void x264_put_be64( flv_buffer *c, uint64_t val ) +void flv_put_be64( flv_buffer *c, uint64_t val ) { - x264_put_be32( c, val >> 32 ); - x264_put_be32( c, val ); + flv_put_be32( c, val >> 32 ); + flv_put_be32( c, val ); } -void x264_put_be16( flv_buffer *c, uint16_t val ) +void flv_put_be16( flv_buffer *c, uint16_t val ) { - x264_put_byte( c, val >> 8 ); - x264_put_byte( c, val ); + flv_put_byte( c, val >> 8 ); + flv_put_byte( c, val ); } -void x264_put_be24( flv_buffer *c, uint32_t val ) +void flv_put_be24( flv_buffer *c, uint32_t val ) { - x264_put_be16( c, val >> 8 ); - x264_put_byte( c, val ); + flv_put_be16( c, val >> 8 ); + flv_put_byte( c, val ); } -void x264_put_tag( flv_buffer *c, const char *tag ) +void flv_put_tag( flv_buffer *c, const char *tag ) { while( *tag ) - x264_put_byte( c, *tag++ ); + flv_put_byte( c, *tag++ ); } -void x264_put_amf_string( flv_buffer *c, const char *str ) +void flv_put_amf_string( flv_buffer *c, const char *str ) { uint16_t len = strlen( str ); - x264_put_be16( c, len ); + flv_put_be16( c, len ); flv_append_data( c, (uint8_t*)str, len ); } -void x264_put_amf_double( flv_buffer *c, double d ) +void flv_put_amf_double( flv_buffer *c, double d ) { - x264_put_byte( c, AMF_DATA_TYPE_NUMBER ); - x264_put_be64( c, dbl2int( d ) ); + flv_put_byte( c, AMF_DATA_TYPE_NUMBER ); + flv_put_be64( c, flv_dbl2int( d ) ); } /* flv writing functions */ @@ -132,7 +132,7 @@ int flv_append_data( flv_buffer *c, uint8_t *data, unsigned size ) return 0; } -void rewrite_amf_be24( flv_buffer *c, unsigned length, unsigned start ) +void flv_rewrite_amf_be24( flv_buffer *c, unsigned length, unsigned start ) { *(c->data + start + 0) = length >> 16; *(c->data + start + 1) = length >> 8; diff --git a/output/flv_bytestream.h b/output/flv_bytestream.h index dc1a3cf0..f961dd9b 100644 --- a/output/flv_bytestream.h +++ b/output/flv_bytestream.h @@ -124,17 +124,16 @@ flv_buffer *flv_create_writer( const char *filename ); int flv_append_data( flv_buffer *c, uint8_t *data, unsigned size ); int flv_write_byte( flv_buffer *c, uint8_t *byte ); int flv_flush_data( flv_buffer *c ); -void rewrite_amf_be24( flv_buffer *c, unsigned length, unsigned start ); - -uint64_t dbl2int( double value ); -uint64_t get_amf_double( double value ); -void x264_put_byte( flv_buffer *c, uint8_t b ); -void x264_put_be32( flv_buffer *c, uint32_t val ); -void x264_put_be64( flv_buffer *c, uint64_t val ); -void x264_put_be16( flv_buffer *c, uint16_t val ); -void x264_put_be24( flv_buffer *c, uint32_t val ); -void x264_put_tag( flv_buffer *c, const char *tag ); -void x264_put_amf_string( flv_buffer *c, const char *str ); -void x264_put_amf_double( flv_buffer *c, double d ); +void flv_rewrite_amf_be24( flv_buffer *c, unsigned length, unsigned start ); + +uint64_t flv_dbl2int( double value ); +void flv_put_byte( flv_buffer *c, uint8_t b ); +void flv_put_be32( flv_buffer *c, uint32_t val ); +void flv_put_be64( flv_buffer *c, uint64_t val ); +void flv_put_be16( flv_buffer *c, uint16_t val ); +void flv_put_be24( flv_buffer *c, uint32_t val ); +void flv_put_tag( flv_buffer *c, const char *tag ); +void flv_put_amf_string( flv_buffer *c, const char *str ); +void flv_put_amf_double( flv_buffer *c, double d ); #endif diff --git a/tools/checkasm.c b/tools/checkasm.c index ce737ecb..61b0f4b3 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -852,7 +852,7 @@ static int check_mc( int cpu_ref, int cpu_new ) #define MC_TEST_LUMA( w, h ) \ if( mc_a.mc_luma != mc_ref.mc_luma && !(w&(w-1)) && h<=16 ) \ { \ - const x264_weight_t *weight = weight_none; \ + const x264_weight_t *weight = x264_weight_none; \ set_func_name( "mc_luma_%dx%d", w, h ); \ used_asm = 1; \ for( int i = 0; i < 1024; i++ ) \ @@ -870,7 +870,7 @@ static int check_mc( int cpu_ref, int cpu_new ) pixel *ref = dst2; \ int ref_stride = 32; \ int w_checked = ( ( sizeof(pixel) == 2 && (w == 12 || w == 20)) ? w-2 : w ); \ - const x264_weight_t *weight = weight_none; \ + const x264_weight_t *weight = x264_weight_none; \ set_func_name( "get_ref_%dx%d", w_checked, h ); \ used_asm = 1; \ for( int i = 0; i < 1024; i++ ) \ diff --git a/x264.c b/x264.c index 3b58aa7d..bfa67b44 100644 --- a/x264.c +++ b/x264.c @@ -84,8 +84,8 @@ typedef struct { } cli_opt_t; /* file i/o operation structs */ -cli_input_t input; -static cli_output_t output; +cli_input_t cli_input; +static cli_output_t cli_output; /* video filter operation struct */ static cli_vid_filter_t filter; @@ -283,9 +283,9 @@ int main( int argc, char **argv ) if( filter.free ) filter.free( opt.hin ); else if( opt.hin ) - input.close_file( opt.hin ); + cli_input.close_file( opt.hin ); if( opt.hout ) - output.close_file( opt.hout, 0, 0 ); + cli_output.close_file( opt.hout, 0, 0 ); if( opt.tcfile_out ) fclose( opt.tcfile_out ); if( opt.qpfile ) @@ -781,7 +781,7 @@ static void help( x264_param_t *defaults, int longhelp ) H0( "\n" ); } -enum +typedef enum { OPT_FRAMES = 256, OPT_SEEK, @@ -983,7 +983,7 @@ static int select_output( const char *muxer, char *filename, x264_param_t *param if( !strcasecmp( ext, "mp4" ) ) { #if HAVE_GPAC - output = mp4_output; + cli_output = mp4_output; param->b_annexb = 0; param->b_repeat_headers = 0; if( param->i_nal_hrd == X264_NAL_HRD_CBR ) @@ -998,18 +998,18 @@ static int select_output( const char *muxer, char *filename, x264_param_t *param } else if( !strcasecmp( ext, "mkv" ) ) { - output = mkv_output; + cli_output = mkv_output; param->b_annexb = 0; param->b_repeat_headers = 0; } else if( !strcasecmp( ext, "flv" ) ) { - output = flv_output; + cli_output = flv_output; param->b_annexb = 0; param->b_repeat_headers = 0; } else - output = raw_output; + cli_output = raw_output; return 0; } @@ -1036,7 +1036,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename if( !strcasecmp( module, "avs" ) || !strcasecmp( ext, "d2v" ) || !strcasecmp( ext, "dga" ) ) { #if HAVE_AVS - input = avs_input; + cli_input = avs_input; module = "avs"; #else x264_cli_log( "x264", X264_LOG_ERROR, "not compiled with AVS input support\n" ); @@ -1044,9 +1044,9 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename #endif } else if( !strcasecmp( module, "y4m" ) ) - input = y4m_input; + cli_input = y4m_input; else if( !strcasecmp( module, "raw" ) || !strcasecmp( ext, "yuv" ) ) - input = raw_input; + cli_input = raw_input; else { #if HAVE_FFMS @@ -1055,7 +1055,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename { module = "ffms"; b_auto = 0; - input = ffms_input; + cli_input = ffms_input; } #endif #if HAVE_LAVF @@ -1064,7 +1064,7 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename { module = "lavf"; b_auto = 0; - input = lavf_input; + cli_input = lavf_input; } #endif #if HAVE_AVS @@ -1073,14 +1073,14 @@ static int select_input( const char *demuxer, char *used_demuxer, char *filename { module = "avs"; b_auto = 0; - input = avs_input; + cli_input = avs_input; } #endif if( b_auto && !raw_input.open_file( filename, p_handle, info, opt ) ) { module = "raw"; b_auto = 0; - input = raw_input; + cli_input = raw_input; } FAIL_IF_ERROR( !(*p_handle), "could not open input file `%s' via any method!\n", filename ) @@ -1397,7 +1397,7 @@ generic_option: if( select_output( muxer, output_filename, param ) ) return -1; - FAIL_IF_ERROR( output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename ) + FAIL_IF_ERROR( cli_output.open_file( output_filename, &opt->hout, &output_opt ), "could not open output file `%s'\n", output_filename ) input_filename = argv[optind++]; video_info_t info = {0}; @@ -1420,7 +1420,7 @@ generic_option: if( select_input( demuxer, demuxername, input_filename, &opt->hin, &info, &input_opt ) ) return -1; - FAIL_IF_ERROR( !opt->hin && input.open_file( input_filename, &opt->hin, &info, &input_opt ), + FAIL_IF_ERROR( !opt->hin && cli_input.open_file( input_filename, &opt->hin, &info, &input_opt ), "could not open input file `%s'\n", input_filename ) x264_reduce_fraction( &info.sar_width, &info.sar_height ); @@ -1433,7 +1433,7 @@ generic_option: { FAIL_IF_ERROR( b_user_fps, "--fps + --tcfile-in is incompatible.\n" ) FAIL_IF_ERROR( timecode_input.open_file( tcfile_name, &opt->hin, &info, &input_opt ), "timecode input failed\n" ) - input = timecode_input; + cli_input = timecode_input; } else FAIL_IF_ERROR( !info.vfr && input_opt.timebase, "--timebase is incompatible with cfr input\n" ) @@ -1447,7 +1447,7 @@ generic_option: fprintf( stderr, "x264 [error]: threaded input failed\n" ); return -1; } - input = thread_input; + cli_input = thread_input; } #endif @@ -1595,7 +1595,7 @@ static int encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic, int64_t *la if( i_frame_size ) { - i_frame_size = output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out ); + i_frame_size = cli_output.write_frame( hout, nal[0].p_payload, i_frame_size, &pic_out ); *last_dts = pic_out.i_dts; } @@ -1692,7 +1692,7 @@ static int encode( x264_param_t *param, cli_opt_t *opt ) x264_encoder_parameters( h, param ); - FAIL_IF_ERROR2( output.set_param( opt->hout, param ), "can't set outfile param\n" ); + FAIL_IF_ERROR2( cli_output.set_param( opt->hout, param ), "can't set outfile param\n" ); i_start = x264_mdate(); @@ -1708,7 +1708,7 @@ static int encode( x264_param_t *param, cli_opt_t *opt ) int i_nal; FAIL_IF_ERROR2( x264_encoder_headers( h, &headers, &i_nal ) < 0, "x264_encoder_headers failed\n" ) - FAIL_IF_ERROR2( (i_file = output.write_headers( opt->hout, headers )) < 0, "error writing headers to output file\n" ); + FAIL_IF_ERROR2( (i_file = cli_output.write_headers( opt->hout, headers )) < 0, "error writing headers to output file\n" ); } if( opt->tcfile_out ) @@ -1818,7 +1818,7 @@ fail: if( b_ctrl_c ) fprintf( stderr, "aborted at input frame %d, output frame %d\n", opt->i_seek + i_frame, i_frame_output ); - output.close_file( opt->hout, largest_pts, second_largest_pts ); + cli_output.close_file( opt->hout, largest_pts, second_largest_pts ); opt->hout = NULL; if( i_frame_output > 0 ) -- 2.40.0