Commit e93cfd6a authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Various cosmetics

parent 3ef68d34
......@@ -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 );
......
......@@ -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++ )
......
......@@ -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 )\
{\
......
......@@ -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 )
......
......@@ -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 )
......
......@@ -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];
......
......@@ -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],\
......
......@@ -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?) */
......
......@@ -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 );
}
......
......@@ -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 */
......
......@@ -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) );
......
......@@ -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 )
{
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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 );