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

Various cosmetics

parent 3ef68d34
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
h->mc.mc_luma( &h->mb.pic.p_fdec[p][4*y*FDEC_STRIDE+4*x], FDEC_STRIDE, \ 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], \ &h->mb.pic.p_fref[list][i_ref][p*4], h->mb.pic.i_stride[p], \
mvx, mvy, 4*width, 4*height, \ 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 ) 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 ...@@ -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) \ #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], \ 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], \ 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, \ 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 ); src0, i_stride0, src1, i_stride1, weight );
......
...@@ -143,7 +143,7 @@ static weight_fn_t x264_mc_weight_wtab[6] = ...@@ -143,7 +143,7 @@ static weight_fn_t x264_mc_weight_wtab[6] =
mc_weight_w16, mc_weight_w16,
mc_weight_w20, 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 ) 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++ ) for( int y = 0; y < i_height; y++ )
......
...@@ -40,7 +40,7 @@ typedef struct x264_weight_t ...@@ -40,7 +40,7 @@ typedef struct x264_weight_t
weight_fn_t *weightfn; weight_fn_t *weightfn;
} ALIGNED_16( x264_weight_t ); } 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 )\ #define SET_WEIGHT( w, b, s, d, o )\
{\ {\
......
...@@ -642,7 +642,7 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf, ...@@ -642,7 +642,7 @@ float x264_pixel_ssim_wxh( x264_pixel_function_t *pf,
return ssim; return ssim;
} }
int pixel_vsad( pixel *src, int stride, int height ) static int pixel_vsad( pixel *src, int stride, int height )
{ {
int score = 0; int score = 0;
for( int i = 1; i < height; i++, src += stride ) 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 ) ...@@ -1281,7 +1281,7 @@ static void x264_intra_rd_refine( x264_t *h, x264_mb_analysis_t *a )
else \ else \
(m)->p_fref[4] = &(src)[4][(xoff)+((yoff)>>1)*(m)->i_stride[1]]; \ (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)->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; \ (m)->i_ref = ref; \
} }
...@@ -1831,13 +1831,13 @@ static ALWAYS_INLINE int x264_analyse_bi_chroma( x264_t *h, x264_mb_analysis_t * ...@@ -1831,13 +1831,13 @@ static ALWAYS_INLINE int x264_analyse_bi_chroma( x264_t *h, x264_mb_analysis_t *
if( CHROMA444 ) \ if( CHROMA444 ) \
{ \ { \
h->mc.mc_luma( pix[0], 16, &m0.p_fref[4], m0.i_stride[1], \ 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], \ 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], \ 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], \ 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[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] ); \ 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 ); \ 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 ) ...@@ -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 ); 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, src0 = h->mc.get_ref( pix0, &stride0,
h->mb.pic.p_fref[0][a->l0.bi16x16.i_ref], h->mb.pic.i_stride[0], 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, src1 = h->mc.get_ref( pix1, &stride1,
h->mb.pic.p_fref[1][a->l1.bi16x16.i_ref], h->mb.pic.i_stride[0], 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] ); 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 ...@@ -2264,9 +2264,9 @@ static void x264_mb_analyse_inter_b8x8_mixed_ref( x264_t *h, x264_mb_analysis_t
/* BI mode */ /* 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], 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], 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->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] ); 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 ) ...@@ -2346,7 +2346,7 @@ static void x264_mb_analyse_inter_b8x8( x264_t *h, x264_mb_analysis_t *a )
/* BI mode */ /* BI mode */
src[l] = h->mc.get_ref( pix[l], &stride[l], m->p_fref, m->i_stride[0], 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; 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] ); 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 ...@@ -2424,9 +2424,9 @@ static void x264_mb_analyse_inter_b16x8( x264_t *h, x264_mb_analysis_t *a, int i
/* BI mode */ /* 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], 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], 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->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] ); 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 ...@@ -2518,9 +2518,9 @@ static void x264_mb_analyse_inter_b8x16( x264_t *h, x264_mb_analysis_t *a, int i
/* BI mode */ /* 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], 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], 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] ); 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 ) 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 ...@@ -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. /* 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 * With high bit depth, it's not worth doing, so turn it off except in the case of
* unweighted dupes. */ * unweighted dupes. */
if( BIT_DEPTH > 8 && w != weight_none ) if( BIT_DEPTH > 8 && w != x264_weight_none )
return -1; return -1;
newframe = x264_frame_pop_blank_unused( h ); newframe = x264_frame_pop_blank_unused( h );
...@@ -1719,7 +1719,7 @@ static inline void x264_reference_build_list( x264_t *h, int i_poc ) ...@@ -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 ); 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 ) if( h->fenc->weight[0][0].i_offset > -128 )
{ {
w[0] = h->fenc->weight[0][0]; 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 ...@@ -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;\ int mvy = bm##list##y+dy;\
stride[0][list][i] = bw;\ 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],\ 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( rd )\
{\ {\
if( CHROMA444 )\ if( CHROMA444 )\
{\ {\
stride[1][list][i] = bw;\ 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],\ 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;\ 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],\ 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\ else\
h->mc.mc_chroma( pixu_buf[list][i], pixv_buf[list][i], 8, m->p_fref[4], m->i_stride[1],\ 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 ...@@ -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 mvx = fenc->lowres_mvs[0][ref0_distance][i_mb_xy][0];
int mvy = fenc->lowres_mvs[0][ref0_distance][i_mb_xy][1]; int mvy = fenc->lowres_mvs[0][ref0_distance][i_mb_xy][1];
h->mc.mc_luma( p+x, i_stride, ref->lowres, i_stride, 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(); x264_emms();
return dest; return dest;
...@@ -531,7 +531,7 @@ static void x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a, ...@@ -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].i_stride[0] = i_stride;
m[1].p_fenc[0] = h->mb.pic.p_fenc[0]; m[1].p_fenc[0] = h->mb.pic.p_fenc[0];
m[1].i_ref = 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 ); LOAD_HPELS_LUMA( m[1].p_fref, fref1->lowres );
m[1].p_fref_w = m[1].p_fref[0]; 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, ...@@ -703,7 +703,7 @@ static int x264_slicetype_frame_cost( x264_t *h, x264_mb_analysis_t *a,
{ {
int i_score = 0; int i_score = 0;
int do_search[2]; 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 /* Check whether we already evaluated this frame
* If we have tried this frame as P, then we have also tried * If we have tried this frame as P, then we have also tried
* the preceding frames as B. (is this still true?) */ * 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 ...@@ -44,7 +44,7 @@ static int init( hnd_t *handle, cli_vid_filter_t *filter, video_info_t *info, x2
return -1; return -1;
h->cur_frame = -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; return -1;
h->hin = *handle; h->hin = *handle;
...@@ -58,7 +58,7 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) ...@@ -58,7 +58,7 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame )
{ {
source_hnd_t *h = handle; source_hnd_t *h = handle;
/* do not allow requesting of frames from before the current position */ /* 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; return -1;
h->cur_frame = frame; h->cur_frame = frame;
*output = h->pic; *output = h->pic;
...@@ -68,7 +68,7 @@ static int get_frame( hnd_t handle, cli_pic_t *output, int frame ) ...@@ -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 ) static int release_frame( hnd_t handle, cli_pic_t *pic, int frame )
{ {
source_hnd_t *h = handle; 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 -1;
return 0; return 0;
} }
...@@ -76,8 +76,8 @@ static int release_frame( hnd_t handle, cli_pic_t *pic, int frame ) ...@@ -76,8 +76,8 @@ static int release_frame( hnd_t handle, cli_pic_t *pic, int frame )
static void free_filter( hnd_t handle ) static void free_filter( hnd_t handle )
{ {
source_hnd_t *h = handle; source_hnd_t *h = handle;
input.picture_clean( &h->pic ); cli_input.picture_clean( &h->pic );
input.close_file( h->hin ); cli_input.close_file( h->hin );
free( h ); free( h );
} }
......
...@@ -100,7 +100,7 @@ extern const cli_input_t lavf_input; ...@@ -100,7 +100,7 @@ extern const cli_input_t lavf_input;
extern const cli_input_t ffms_input; extern const cli_input_t ffms_input;
extern cli_input_t timecode_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 */ /* 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 */ #define X264_CSP_I422 X264_CSP_MAX /* yuv 4:2:2 planar */
......
...@@ -48,9 +48,9 @@ typedef struct thread_input_arg_t ...@@ -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 ) 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) ); 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" ) "x264", "malloc failed\n" )
h->input = input; h->input = cli_input;
h->p_handle = *p_handle; h->p_handle = *p_handle;
h->next_frame = -1; h->next_frame = -1;
h->next_args = malloc( sizeof(thread_input_arg_t) ); 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 ...@@ -340,7 +340,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
FILE *tcfile_in; FILE *tcfile_in;
timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) ); timecode_hnd_t *h = malloc( sizeof(timecode_hnd_t) );
FAIL_IF_ERROR( !h, "malloc failed\n" ) FAIL_IF_ERROR( !h, "malloc failed\n" )
h->input = input; h->input = cli_input;
h->p_handle = *p_handle; h->p_handle = *p_handle;
if( opt->timebase ) if( opt->timebase )
{ {
......
...@@ -64,11 +64,11 @@ typedef struct ...@@ -64,11 +64,11 @@ typedef struct
static int write_header( flv_buffer *c ) static int write_header( flv_buffer *c )
{ {
x264_put_tag( c, "FLV" ); // Signature flv_put_tag( c, "FLV" ); // Signature
x264_put_byte( c, 1 ); // Version flv_put_byte( c, 1 ); // Version
x264_put_byte( c, 1 ); // Video Only flv_put_byte( c, 1 ); // Video Only
x264_put_be32( c, 9 ); // DataOffset flv_put_be32( c, 9 ); // DataOffset
x264_put_be32( c, 0 ); // PreviousTagSize0 flv_put_be32( c, 0 ); // PreviousTagSize0
return flv_flush_data( c ); return flv_flush_data( c );
} }
...@@ -98,57 +98,57 @@ static int set_param( hnd_t handle, x264_param_t *p_param ) ...@@ -98,57 +98,57 @@ static int set_param( hnd_t handle, x264_param_t *p_param )
flv_hnd_t *p_flv = handle; flv_hnd_t *p_flv = handle;
flv_buffer *c = p_flv->c; 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; int start = c->d_cur;
x264_put_be24( c, 0 ); // data length flv_put_be24( c, 0 ); // data length
x264_put_be24( c, 0 ); // timestamp flv_put_be24( c, 0 ); // timestamp
x264_put_be32( c, 0 ); // reserved flv_put_be32( c, 0 ); // reserved
x264_put_byte( c, AMF_DATA_TYPE_STRING ); flv_put_byte( c, AMF_DATA_TYPE_STRING );
x264_put_amf_string( c, "onMetaData" ); flv_put_amf_string( c, "onMetaData" );
x264_put_byte( c, AMF_DATA_TYPE_MIXEDARRAY ); flv_put_byte( c, AMF_DATA_TYPE_MIXEDARRAY );
x264_put_be32( c, 7 ); flv_put_be32( c, 7 );
x264_put_amf_string( c, "width" ); flv_put_amf_string( c, "width" );
x264_put_amf_double( c, p_param->i_width ); flv_put_amf_double( c, p_param->i_width );
x264_put_amf_string( c, "height" ); flv_put_amf_string( c, "height" );
x264_put_amf_double( c, p_param->i_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 ) 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 else
{ {
p_flv->i_framerate_pos = c->d_cur + c->d_total + 1; 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" ); flv_put_amf_string( c, "videocodecid" );
x264_put_amf_double( c, FLV_CODECID_H264 ); 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; 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; 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; 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, "" ); flv_put_amf_string( c, "" );
x264_put_byte( c, AMF_END_OF_OBJECT ); flv_put_byte( c, AMF_END_OF_OBJECT );
unsigned length = c->d_cur - start; 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_num = p_param->i_fps_num;
p_flv->i_fps_den = p_param->i_fps_den; 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 ) ...@@ -182,36 +182,36 @@ static int write_headers( hnd_t handle, x264_nal_t *p_nal )
// SPS // SPS
uint8_t *sps = p_nal[0].p_payload + 4; uint8_t *sps = p_nal[0].p_payload + 4;
x264_put_byte( c, FLV_TAG_TYPE_VIDEO ); flv_put_byte( c, FLV_TAG_TYPE_VIDEO );
x264_put_be24( c, 0 ); // rewrite later flv_put_be24( c, 0 ); // rewrite later
x264_put_be24( c, 0 ); // timestamp flv_put_be24( c, 0 ); // timestamp
x264_put_byte( c, 0 ); // timestamp extended flv_put_byte( c, 0 ); // timestamp extended
x264_put_be24( c, 0 ); // StreamID - Always 0 flv_put_be24( c, 0 ); // StreamID - Always 0
p_flv->start = c->d_cur; // needed for overwriting length p_flv->start = c->d_cur; // needed for overwriting length
x264_put_byte( c, 7 | FLV_FRAME_KEY ); // Frametype and CodecID flv_put_byte( c, 7 | FLV_FRAME_KEY ); // Frametype and CodecID
x264_put_byte( c, 0 ); // AVC sequence header flv_put_byte( c, 0 ); // AVC sequence header
x264_put_be24( c, 0 ); // composition time flv_put_be24( c, 0 ); // composition time
x264_put_byte( c, 1 ); // version flv_put_byte( c, 1 ); // version
x264_put_byte( c, sps[1] ); // profile flv_put_byte( c, sps[1] ); // profile
x264_put_byte( c, sps[2] ); // profile flv_put_byte( c, sps[2] ); // profile
x264_put_byte( c, sps[3] ); // level flv_put_byte( c, sps[3] ); // level
x264_put_byte( c, 0xff ); // 6 bits reserved (111111) + 2 bits nal size length - 1 (11) flv_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, 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 ); flv_append_data( c, sps, sps_size - 4 );
// PPS // PPS
x264_put_byte( c, 1 ); // number of pps flv_put_byte( c, 1 ); // number of pps
x264_put_be16( c, pps_size - 4 ); flv_put_be16( c, pps_size - 4 );
flv_append_data( c, p_nal[1].p_payload + 4, pps_size - 4 ); flv_append_data( c, p_nal[1].p_payload + 4, pps_size - 4 );
// rewrite data length info // rewrite data length info
unsigned length = c->d_cur - p_flv->start; unsigned length = c->d_cur - p_flv->start;
rewrite_amf_be24( c, length, p_flv->start - 10 ); flv_rewrite_amf_be24( c, length, p_flv->start - 10 );