[x264-devel] [PATCH 20/29] Templatize the main C library code

Vittorio Giovara vittorio.giovara at gmail.com
Fri Feb 10 22:18:55 CET 2017


---
 common/api.c           | 24 +++++++++++++++++++++++-
 common/bitstream.h     |  1 +
 common/cabac.h         |  8 ++++++++
 common/common.h        |  3 +++
 common/dct.h           |  2 ++
 common/frame.h         | 32 ++++++++++++++++++++++++++++++++
 common/macroblock.h    | 20 ++++++++++++++++++++
 common/mc.h            |  6 ++++++
 common/pixel.h         | 16 ++++++++++++++++
 common/predict.h       | 23 +++++++++++++++++++++++
 common/quant.h         |  1 +
 common/rectangle.h     |  9 ++++++---
 common/set.h           |  3 +++
 common/threadpool.h    |  4 ++++
 encoder/analyse.h      | 11 +++++++++++
 encoder/encoder.c      |  1 +
 encoder/macroblock.h   | 21 +++++++++++++++++++++
 encoder/me.c           |  1 +
 encoder/me.h           |  7 +++++++
 encoder/ratecontrol.h  | 21 +++++++++++++++++++++
 encoder/rdo.c          |  3 +++
 encoder/set.h          | 16 ++++++++++++++++
 encoder/slicetype-cl.c |  1 +
 encoder/slicetype.c    |  1 +
 24 files changed, 231 insertions(+), 4 deletions(-)

diff --git a/common/api.c b/common/api.c
index 9b2dcea..7d825fa 100644
--- a/common/api.c
+++ b/common/api.c
@@ -48,6 +48,18 @@ int  x264_8_encoder_maximum_delayed_frames( x264_t *h );
 void x264_8_encoder_intra_refresh( x264_t * );
 int  x264_8_encoder_invalidate_reference( x264_t *, int64_t pts );
 
+x264_t *x264_10_encoder_open( x264_param_t * );
+void x264_10_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+int  x264_10_encoder_reconfig( x264_t *, x264_param_t * );
+void x264_10_encoder_parameters( x264_t *, x264_param_t * );
+int  x264_10_encoder_headers( x264_t *, x264_nal_t **pp_nal, int *pi_nal );
+int  x264_10_encoder_encode( x264_t *, x264_nal_t **pp_nal, int *pi_nal, x264_picture_t *pic_in, x264_picture_t *pic_out );
+void x264_10_encoder_close( x264_t * );
+int  x264_10_encoder_delayed_frames( x264_t * );
+int  x264_10_encoder_maximum_delayed_frames( x264_t *h );
+void x264_10_encoder_intra_refresh( x264_t * );
+int  x264_10_encoder_invalidate_reference( x264_t *, int64_t pts );
+
 typedef struct x264_api_t {
     /* Internal reference to x264_t data */
     x264_t *x264;
@@ -84,7 +96,17 @@ x264_t *x264_encoder_open( x264_param_t *param )
 
         api->x264 = x264_8_encoder_open( param );
     } else if( param->i_bitdepth == 10 ) {
-        x264_log_internal( NULL, "Not yet implemented\n");
+        api->encoder_reconfig = x264_10_encoder_reconfig;
+        api->encoder_parameters = x264_10_encoder_parameters;
+        api->encoder_headers = x264_10_encoder_headers;
+        api->encoder_encode = x264_10_encoder_encode;
+        api->encoder_close = x264_10_encoder_close;
+        api->encoder_delayed_frames = x264_10_encoder_delayed_frames;
+        api->encoder_maximum_delayed_frames = x264_10_encoder_maximum_delayed_frames;
+        api->encoder_intra_refresh = x264_10_encoder_intra_refresh;
+        api->encoder_invalidate_reference = x264_10_encoder_invalidate_reference;
+
+        api->x264 = x264_10_encoder_open( param );
     }
 
     if( !api->x264 ) {
diff --git a/common/bitstream.h b/common/bitstream.h
index 9cbb9c8..3cd1227 100644
--- a/common/bitstream.h
+++ b/common/bitstream.h
@@ -67,6 +67,7 @@ typedef struct
                                                   intptr_t ctx_block_cat, x264_cabac_t *cb );
 } x264_bitstream_function_t;
 
+#define x264_bitstream_init x264_template(bitstream_init)
 void x264_bitstream_init( int cpu, x264_bitstream_function_t *pf );
 
 /* A larger level table size theoretically could help a bit at extremely
diff --git a/common/cabac.h b/common/cabac.h
index 5af856a..01bd982 100644
--- a/common/cabac.h
+++ b/common/cabac.h
@@ -55,17 +55,25 @@ extern const uint8_t x264_cabac_transition[128][2];
 extern const uint16_t x264_cabac_entropy[128];
 
 /* init the contexts given i_slice_type, the quantif and the model */
+#define x264_cabac_context_init x264_template(cabac_context_init)
 void x264_cabac_context_init( x264_t *h, x264_cabac_t *cb, int i_slice_type, int i_qp, int i_model );
 
+#define x264_cabac_encode_init_core x264_template(cabac_encode_init_core)
 void x264_cabac_encode_init_core( x264_cabac_t *cb );
+#define x264_cabac_encode_init x264_template(cabac_encode_init)
 void x264_cabac_encode_init( x264_cabac_t *cb, uint8_t *p_data, uint8_t *p_end );
+#define x264_cabac_encode_decision_c x264_template(cabac_encode_decision_c)
 void x264_cabac_encode_decision_c( x264_cabac_t *cb, int i_ctx, int b );
 void x264_cabac_encode_decision_asm( x264_cabac_t *cb, int i_ctx, int b );
+#define x264_cabac_encode_bypass_c x264_template(cabac_encode_bypass_c)
 void x264_cabac_encode_bypass_c( x264_cabac_t *cb, int b );
 void x264_cabac_encode_bypass_asm( x264_cabac_t *cb, int b );
+#define x264_cabac_encode_terminal_c x264_template(cabac_encode_terminal_c)
 void x264_cabac_encode_terminal_c( x264_cabac_t *cb );
 void x264_cabac_encode_terminal_asm( x264_cabac_t *cb );
+#define x264_cabac_encode_ue_bypass x264_template(cabac_encode_ue_bypass)
 void x264_cabac_encode_ue_bypass( x264_cabac_t *cb, int exp_bits, int val );
+#define x264_cabac_encode_flush x264_template(cabac_encode_flush)
 void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb );
 
 #if HAVE_MMX
diff --git a/common/common.h b/common/common.h
index 1c9f0df..f228e62 100644
--- a/common/common.h
+++ b/common/common.h
@@ -267,9 +267,12 @@ static const uint8_t x264_scan8[16*3 + 3] =
 char *x264_param2string( x264_param_t *p, int b_res );
 
 /* log */
+#define x264_log x264_template(log)
 void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... );
 
+#define x264_cavlc_init x264_template(cavlc_init)
 void x264_cavlc_init( x264_t *h );
+#define x264_cabac_init x264_template(cabac_init)
 void x264_cabac_init( x264_t *h );
 
 static ALWAYS_INLINE pixel x264_clip_pixel( int x )
diff --git a/common/dct.h b/common/dct.h
index 3008a40..932d5b6 100644
--- a/common/dct.h
+++ b/common/dct.h
@@ -69,7 +69,9 @@ typedef struct
 
 } x264_zigzag_function_t;
 
+#define x264_dct_init x264_template(dct_init)
 void x264_dct_init( int cpu, x264_dct_function_t *dctf );
+#define x264_zigzag_init x264_template(zigzag_init)
 void x264_zigzag_init( int cpu, x264_zigzag_function_t *pf_progressive, x264_zigzag_function_t *pf_interlaced );
 
 #endif
diff --git a/common/frame.h b/common/frame.h
index 18eb427..7d60ac4 100644
--- a/common/frame.h
+++ b/common/frame.h
@@ -216,47 +216,79 @@ typedef struct
                               int bframe );
 } x264_deblock_function_t;
 
+#define x264_frame_delete x264_template(frame_delete)
 void          x264_frame_delete( x264_frame_t *frame );
 
+#define x264_frame_copy_picture x264_template(frame_copy_picture)
 int           x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_picture_t *src );
 
+#define x264_frame_expand_border x264_template(frame_expand_border)
 void          x264_frame_expand_border( x264_t *h, x264_frame_t *frame, int mb_y );
+#define x264_frame_expand_border_filtered x264_template(frame_expand_border_filtered)
 void          x264_frame_expand_border_filtered( x264_t *h, x264_frame_t *frame, int mb_y, int b_end );
+#define x264_frame_expand_border_lowres x264_template(frame_expand_border_lowres)
 void          x264_frame_expand_border_lowres( x264_frame_t *frame );
+#define x264_frame_expand_border_chroma x264_template(frame_expand_border_chroma)
 void          x264_frame_expand_border_chroma( x264_t *h, x264_frame_t *frame, int plane );
+#define x264_frame_expand_border_mod16 x264_template(frame_expand_border_mod16)
 void          x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame );
+#define x264_expand_border_mbpair x264_template(expand_border_mbpair)
 void          x264_expand_border_mbpair( x264_t *h, int mb_x, int mb_y );
 
+#define x264_frame_deblock_row x264_template(frame_deblock_row)
 void          x264_frame_deblock_row( x264_t *h, int mb_y );
+#define x264_macroblock_deblock x264_template(macroblock_deblock)
 void          x264_macroblock_deblock( x264_t *h );
 
+#define x264_frame_filter x264_template(frame_filter)
 void          x264_frame_filter( x264_t *h, x264_frame_t *frame, int mb_y, int b_end );
+#define x264_frame_init_lowres x264_template(frame_init_lowres)
 void          x264_frame_init_lowres( x264_t *h, x264_frame_t *frame );
 
+#define x264_deblock_init x264_template(deblock_init)
 void          x264_deblock_init( int cpu, x264_deblock_function_t *pf, int b_mbaff );
 
+#define x264_frame_cond_broadcast x264_template(frame_cond_broadcast)
 void          x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed );
+#define x264_frame_cond_wait x264_template(frame_cond_wait)
 void          x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed );
+#define x264_frame_new_slice x264_template(frame_new_slice)
 int           x264_frame_new_slice( x264_t *h, x264_frame_t *frame );
 
+#define x264_threadslice_cond_broadcast x264_template(threadslice_cond_broadcast)
 void          x264_threadslice_cond_broadcast( x264_t *h, int pass );
+#define x264_threadslice_cond_wait x264_template(threadslice_cond_wait)
 void          x264_threadslice_cond_wait( x264_t *h, int pass );
 
+#define x264_frame_push x264_template(frame_push)
 void          x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
+#define x264_frame_pop x264_template(frame_pop)
 x264_frame_t *x264_frame_pop( x264_frame_t **list );
+#define x264_frame_unshift x264_template(frame_unshift)
 void          x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
+#define x264_frame_shift x264_template(frame_shift)
 x264_frame_t *x264_frame_shift( x264_frame_t **list );
+#define x264_frame_push_unused x264_template(frame_push_unused)
 void          x264_frame_push_unused( x264_t *h, x264_frame_t *frame );
+#define x264_frame_push_blank_unused x264_template(frame_push_blank_unused)
 void          x264_frame_push_blank_unused( x264_t *h, x264_frame_t *frame );
+#define x264_frame_pop_blank_unused x264_template(frame_pop_blank_unused)
 x264_frame_t *x264_frame_pop_blank_unused( x264_t *h );
+#define x264_weight_scale_plane x264_template(weight_scale_plane)
 void x264_weight_scale_plane( x264_t *h, pixel *dst, intptr_t i_dst_stride, pixel *src, intptr_t i_src_stride,
                               int i_width, int i_height, x264_weight_t *w );
+#define x264_frame_pop_unused x264_template(frame_pop_unused)
 x264_frame_t *x264_frame_pop_unused( x264_t *h, int b_fdec );
+#define x264_frame_delete_list x264_template(frame_delete_list)
 void          x264_frame_delete_list( x264_frame_t **list );
 
+#define x264_sync_frame_list_init x264_template(sync_frame_list_init)
 int           x264_sync_frame_list_init( x264_sync_frame_list_t *slist, int nelem );
+#define x264_sync_frame_list_delete x264_template(sync_frame_list_delete)
 void          x264_sync_frame_list_delete( x264_sync_frame_list_t *slist );
+#define x264_sync_frame_list_push x264_template(sync_frame_list_push)
 void          x264_sync_frame_list_push( x264_sync_frame_list_t *slist, x264_frame_t *frame );
+#define x264_sync_frame_list_pop x264_template(sync_frame_list_pop)
 x264_frame_t *x264_sync_frame_list_pop( x264_sync_frame_list_t *slist );
 
 #endif
diff --git a/common/macroblock.h b/common/macroblock.h
index f1dfb27..8d872f1 100644
--- a/common/macroblock.h
+++ b/common/macroblock.h
@@ -299,38 +299,54 @@ static const uint8_t ctx_cat_plane[6][3] =
 };
 
 /* Per-frame allocation: is allocated per-thread only in frame-threads mode. */
+#define x264_macroblock_cache_allocate x264_template(macroblock_cache_allocate)
 int  x264_macroblock_cache_allocate( x264_t *h );
+#define x264_macroblock_cache_free x264_template(macroblock_cache_free)
 void x264_macroblock_cache_free( x264_t *h );
 
 /* Per-thread allocation: is allocated per-thread even in sliced-threads mode. */
+#define x264_macroblock_thread_allocate x264_template(macroblock_thread_allocate)
 int  x264_macroblock_thread_allocate( x264_t *h, int b_lookahead );
+#define x264_macroblock_thread_free x264_template(macroblock_thread_free)
 void x264_macroblock_thread_free( x264_t *h, int b_lookahead );
 
+#define x264_macroblock_slice_init x264_template(macroblock_slice_init)
 void x264_macroblock_slice_init( x264_t *h );
+#define x264_macroblock_thread_init x264_template(macroblock_thread_init)
 void x264_macroblock_thread_init( x264_t *h );
+#define x264_macroblock_cache_load_interlaced x264_template(macroblock_cache_load_interlaced)
 void x264_macroblock_cache_load_progressive( x264_t *h, int mb_x, int mb_y );
+#define x264_macroblock_cache_load_progressive x264_template(macroblock_cache_load_progressive)
 void x264_macroblock_cache_load_interlaced( x264_t *h, int mb_x, int mb_y );
+#define x264_macroblock_deblock_strength x264_template(macroblock_deblock_strength)
 void x264_macroblock_deblock_strength( x264_t *h );
+#define x264_macroblock_cache_save x264_template(macroblock_cache_save)
 void x264_macroblock_cache_save( x264_t *h );
 
+#define x264_macroblock_bipred_init x264_template(macroblock_bipred_init)
 void x264_macroblock_bipred_init( x264_t *h );
 
+#define x264_prefetch_fenc x264_template(prefetch_fenc)
 void x264_prefetch_fenc( x264_t *h, x264_frame_t *fenc, int i_mb_x, int i_mb_y );
 
+#define x264_copy_column8 x264_template(copy_column8)
 void x264_copy_column8( pixel *dst, pixel *src );
 
 /* x264_mb_predict_mv_16x16:
  *      set mvp with predicted mv for D_16x16 block
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_16x16 x264_template(mb_predict_mv_16x16)
 void x264_mb_predict_mv_16x16( x264_t *h, int i_list, int i_ref, int16_t mvp[2] );
 /* x264_mb_predict_mv_pskip:
  *      set mvp with predicted mv for P_SKIP
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_pskip x264_template(mb_predict_mv_pskip)
 void x264_mb_predict_mv_pskip( x264_t *h, int16_t mv[2] );
 /* x264_mb_predict_mv:
  *      set mvp with predicted mv for all blocks except SKIP and DIRECT
  *      h->mb. need valid ref/partition/sub of current block to be valid
  *      and valid mv/ref from other blocks. */
+#define x264_mb_predict_mv x264_template(mb_predict_mv)
 void x264_mb_predict_mv( x264_t *h, int i_list, int idx, int i_width, int16_t mvp[2] );
 /* x264_mb_predict_mv_direct16x16:
  *      set h->mb.cache.mv and h->mb.cache.ref for B_SKIP or B_DIRECT
@@ -338,14 +354,18 @@ void x264_mb_predict_mv( x264_t *h, int i_list, int idx, int i_width, int16_t mv
  *      return 1 on success, 0 on failure.
  *      if b_changed != NULL, set it to whether refs or mvs differ from
  *      before this functioncall. */
+#define x264_mb_predict_mv_direct16x16 x264_template(mb_predict_mv_direct16x16)
 int x264_mb_predict_mv_direct16x16( x264_t *h, int *b_changed );
 /* x264_mb_predict_mv_ref16x16:
  *      set mvc with D_16x16 prediction.
  *      uses all neighbors, even those that didn't end up using this ref.
  *      h->mb. need only valid values from other blocks */
+#define x264_mb_predict_mv_ref16x16 x264_template(mb_predict_mv_ref16x16)
 void x264_mb_predict_mv_ref16x16( x264_t *h, int i_list, int i_ref, int16_t mvc[8][2], int *i_mvc );
 
+#define x264_mb_mc x264_template(mb_mc)
 void x264_mb_mc( x264_t *h );
+#define x264_mb_mc_8x8 x264_template(mb_mc_8x8)
 void x264_mb_mc_8x8( x264_t *h, int i8 );
 
 static ALWAYS_INLINE uint32_t pack16to32( uint32_t a, uint32_t b )
diff --git a/common/mc.h b/common/mc.h
index f543fa9..70dca65 100644
--- a/common/mc.h
+++ b/common/mc.h
@@ -100,6 +100,7 @@ static void x264_mbtree_propagate_list_##cpu( x264_t *h, uint16_t *ref_costs, in
     }\
 }
 
+#define x264_plane_copy_c x264_template(plane_copy_c)
 void x264_plane_copy_c( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
 
 #define PLANE_COPY(align, cpu)\
@@ -128,6 +129,7 @@ static void x264_plane_copy_##cpu( pixel *dst, intptr_t i_dst, pixel *src, intpt
     }\
 }
 
+#define x264_plane_copy_swap_c x264_template(plane_copy_swap_c)
 void x264_plane_copy_swap_c( pixel *, intptr_t, pixel *, intptr_t, int w, int h );
 
 #define PLANE_COPY_SWAP(align, cpu)\
@@ -160,6 +162,7 @@ static void x264_plane_copy_swap_##cpu( pixel *dst, intptr_t i_dst, pixel *src,
         x264_plane_copy_swap_c( dst, i_dst, src, i_src, w, h );\
 }
 
+#define x264_plane_copy_deinterleave_c x264_template(plane_copy_deinterleave_c)
 void x264_plane_copy_deinterleave_c( pixel *dsta, intptr_t i_dsta, pixel *dstb, intptr_t i_dstb,
                                      pixel *src, intptr_t i_src, int w, int h );
 
@@ -193,6 +196,7 @@ static void x264_plane_copy_deinterleave_yuyv_##cpu( pixel *dsta, intptr_t i_dst
         x264_plane_copy_deinterleave_c( dsta, i_dsta, dstb, i_dstb, src, i_src, w, h );\
 }
 
+#define x264_plane_copy_interleave_c x264_template(plane_copy_interleave_c)
 void x264_plane_copy_interleave_c( pixel *dst,  intptr_t i_dst,
                                    pixel *srcu, intptr_t i_srcu,
                                    pixel *srcv, intptr_t i_srcv, int w, int h );
@@ -239,6 +243,7 @@ typedef struct x264_weight_t
     weight_fn_t *weightfn;
 } ALIGNED_16( x264_weight_t );
 
+#define x264_weight_none x264_template(weight_none)
 extern const x264_weight_t x264_weight_none[3];
 
 #define SET_WEIGHT( w, b, s, d, o )\
@@ -333,6 +338,7 @@ typedef struct
     void (*mbtree_fix8_unpack)( float *dst, uint16_t *src, int count );
 } x264_mc_functions_t;
 
+#define x264_mc_init x264_template(mc_init)
 void x264_mc_init( int cpu, x264_mc_functions_t *pf, int cpu_independent );
 
 #endif
diff --git a/common/pixel.h b/common/pixel.h
index f634312..ee08156 100644
--- a/common/pixel.h
+++ b/common/pixel.h
@@ -144,13 +144,29 @@ typedef struct
     int (*intra_sad_x9_8x8)  ( pixel *fenc, pixel *fdec, pixel edge[36], uint16_t *bitcosts, uint16_t *satds );
 } x264_pixel_function_t;
 
+#define x264_pixel_init x264_template(pixel_init)
 void x264_pixel_init( int cpu, x264_pixel_function_t *pixf );
+#define x264_pixel_ssd_nv12 x264_template(pixel_ssd_nv12)
 void x264_pixel_ssd_nv12   ( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height, uint64_t *ssd_u, uint64_t *ssd_v );
+#define x264_pixel_ssd_wxh x264_template(pixel_ssd_wxh)
 uint64_t x264_pixel_ssd_wxh( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height );
+#define x264_pixel_ssim_wxh x264_template(pixel_ssim_wxh)
 float x264_pixel_ssim_wxh  ( x264_pixel_function_t *pf, pixel *pix1, intptr_t i_pix1, pixel *pix2, intptr_t i_pix2,
                              int i_width, int i_height, void *buf, int *cnt );
+#define x264_field_vsad x264_template(field_vsad)
 int x264_field_vsad( x264_t *h, int mb_x, int mb_y );
 
+#define x264_intra_sa8d_x3_8x8 x264_template(intra_sa8d_x3_8x8)
+#define x264_intra_sad_x3_16x16 x264_template(intra_sad_x3_16x16)
+#define x264_intra_sad_x3_4x4 x264_template(intra_sad_x3_4x4)
+#define x264_intra_sad_x3_8x16c x264_template(intra_sad_x3_8x16c)
+#define x264_intra_sad_x3_8x8 x264_template(intra_sad_x3_8x8)
+#define x264_intra_sad_x3_8x8c x264_template(intra_sad_x3_8x8c)
+#define x264_intra_satd_x3_16x16 x264_template(intra_satd_x3_16x16)
+#define x264_intra_satd_x3_4x4 x264_template(intra_satd_x3_4x4)
+#define x264_intra_satd_x3_8x16c x264_template(intra_satd_x3_8x16c)
+#define x264_intra_satd_x3_8x8c x264_template(intra_satd_x3_8x8c)
+
 #endif
diff --git a/common/predict.h b/common/predict.h
index 9ec9476..4c7ffe4 100644
--- a/common/predict.h
+++ b/common/predict.h
@@ -109,29 +109,52 @@ enum intra8x8_pred_e
     I_PRED_8x8_DC_128  = 11,
 };
 
+#define x264_predict_8x8_dc_c x264_template(predict_8x8_dc_c)
 void x264_predict_8x8_dc_c  ( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_h_c x264_template(predict_8x8_h_c)
 void x264_predict_8x8_h_c   ( pixel *src, pixel edge[36] );
+#define x264_predict_8x8_v_c x264_template(predict_8x8_v_c)
 void x264_predict_8x8_v_c   ( pixel *src, pixel edge[36] );
+#define x264_predict_4x4_dc_c x264_template(predict_4x4_dc_c)
 void x264_predict_4x4_dc_c  ( pixel *src );
+#define x264_predict_4x4_h_c x264_template(predict_4x4_h_c)
 void x264_predict_4x4_h_c   ( pixel *src );
+#define x264_predict_4x4_v_c x264_template(predict_4x4_v_c)
 void x264_predict_4x4_v_c   ( pixel *src );
+#define x264_predict_16x16_dc_c x264_template(predict_16x16_dc_c)
 void x264_predict_16x16_dc_c( pixel *src );
+#define x264_predict_16x16_h_c x264_template(predict_16x16_h_c)
 void x264_predict_16x16_h_c ( pixel *src );
+#define x264_predict_16x16_v_c x264_template(predict_16x16_v_c)
 void x264_predict_16x16_v_c ( pixel *src );
+#define x264_predict_16x16_p_c x264_template(predict_16x16_p_c)
 void x264_predict_16x16_p_c ( pixel *src );
+#define x264_predict_8x8c_dc_c x264_template(predict_8x8c_dc_c)
 void x264_predict_8x8c_dc_c ( pixel *src );
+#define x264_predict_8x8c_h_c x264_template(predict_8x8c_h_c)
 void x264_predict_8x8c_h_c  ( pixel *src );
+#define x264_predict_8x8c_v_c x264_template(predict_8x8c_v_c)
 void x264_predict_8x8c_v_c  ( pixel *src );
+#define x264_predict_8x8c_p_c x264_template(predict_8x8c_p_c)
 void x264_predict_8x8c_p_c  ( pixel *src );
+#define x264_predict_8x16c_dc_c x264_template(predict_8x16c_dc_c)
 void x264_predict_8x16c_dc_c( pixel *src );
+#define x264_predict_8x16c_h_c x264_template(predict_8x16c_h_c)
 void x264_predict_8x16c_h_c ( pixel *src );
+#define x264_predict_8x16c_v_c x264_template(predict_8x16c_v_c)
 void x264_predict_8x16c_v_c ( pixel *src );
+#define x264_predict_8x16c_p_c x264_template(predict_8x16c_p_c)
 void x264_predict_8x16c_p_c ( pixel *src );
 
+#define x264_predict_16x16_init x264_template(predict_16x16_init)
 void x264_predict_16x16_init ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x8c_init x264_template(predict_8x8c_init)
 void x264_predict_8x8c_init  ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_8x16c_init x264_template(predict_8x16c_init)
 void x264_predict_8x16c_init ( int cpu, x264_predict_t pf[7] );
+#define x264_predict_4x4_init x264_template(predict_4x4_init)
 void x264_predict_4x4_init   ( int cpu, x264_predict_t pf[12] );
+#define x264_predict_8x8_init x264_template(predict_8x8_init)
 void x264_predict_8x8_init   ( int cpu, x264_predict8x8_t pf[12], x264_predict_8x8_filter_t *predict_filter );
 
 
diff --git a/common/quant.h b/common/quant.h
index 0bd0c21..265ee61 100644
--- a/common/quant.h
+++ b/common/quant.h
@@ -69,6 +69,7 @@ typedef struct
     int (*trellis_cabac_chroma_422_dc)( TRELLIS_PARAMS );
 } x264_quant_function_t;
 
+#define x264_quant_init x264_template(quant_init)
 void x264_quant_init( x264_t *h, int cpu, x264_quant_function_t *pf );
 
 #endif
diff --git a/common/rectangle.h b/common/rectangle.h
index 2bd2028..113a011 100644
--- a/common/rectangle.h
+++ b/common/rectangle.h
@@ -118,9 +118,12 @@ static ALWAYS_INLINE void x264_macroblock_cache_rect( void *dst, int w, int h, i
         assert(0);
 }
 
-extern void (*x264_cache_mv_func_table[10])(void *, uint32_t);\
-extern void (*x264_cache_mvd_func_table[10])(void *, uint32_t);\
-extern void (*x264_cache_ref_func_table[10])(void *, uint32_t);\
+#define x264_cache_mv_func_table x264_template(cache_mv_func_table)
+extern void (*x264_cache_mv_func_table[10])(void *, uint32_t);
+#define x264_cache_mvd_func_table x264_template(cache_mvd_func_table)
+extern void (*x264_cache_mvd_func_table[10])(void *, uint32_t);
+#define x264_cache_ref_func_table x264_template(cache_ref_func_table)
+extern void (*x264_cache_ref_func_table[10])(void *, uint32_t);
 
 #define x264_macroblock_cache_mv_ptr( a, x, y, w, h, l, mv ) x264_macroblock_cache_mv( a, x, y, w, h, l, M32( mv ) )
 static ALWAYS_INLINE void x264_macroblock_cache_mv( x264_t *h, int x, int y, int width, int height, int i_list, uint32_t mv )
diff --git a/common/set.h b/common/set.h
index c28b902..00f1fc5 100644
--- a/common/set.h
+++ b/common/set.h
@@ -341,8 +341,11 @@ static const uint8_t x264_cqm_avci100_720p_8iy[64] =
     32,32,32,34,34,36,38,42
 };
 
+#define x264_cqm_init x264_template(cqm_init)
 int  x264_cqm_init( x264_t *h );
+#define x264_cqm_delete x264_template(cqm_delete)
 void x264_cqm_delete( x264_t *h );
+#define x264_cqm_parse_file x264_template(cqm_parse_file)
 int  x264_cqm_parse_file( x264_t *h, const char *filename );
 
 #endif
diff --git a/common/threadpool.h b/common/threadpool.h
index 639cad4..7d91ad5 100644
--- a/common/threadpool.h
+++ b/common/threadpool.h
@@ -29,10 +29,14 @@
 typedef struct x264_threadpool_t x264_threadpool_t;
 
 #if HAVE_THREAD
+#define x264_threadpool_init x264_template(threadpool_init)
 int   x264_threadpool_init( x264_threadpool_t **p_pool, int threads,
                             void (*init_func)(void *), void *init_arg );
+#define x264_threadpool_run x264_template(threadpool_run)
 void  x264_threadpool_run( x264_threadpool_t *pool, void *(*func)(void *), void *arg );
+#define x264_threadpool_wait x264_template(threadpool_wait)
 void *x264_threadpool_wait( x264_threadpool_t *pool, void *arg );
+#define x264_threadpool_delete x264_template(threadpool_delete)
 void  x264_threadpool_delete( x264_threadpool_t *pool );
 #else
 #define x264_threadpool_init(p,t,f,a) -1
diff --git a/encoder/analyse.h b/encoder/analyse.h
index 05e3afb..2dad00e 100644
--- a/encoder/analyse.h
+++ b/encoder/analyse.h
@@ -27,18 +27,29 @@
 #ifndef X264_ANALYSE_H
 #define X264_ANALYSE_H
 
+#define x264_analyse_init_costs x264_template(analyse_init_costs)
 int x264_analyse_init_costs( x264_t *h );
+#define x264_analyse_free_costs x264_template(analyse_free_costs)
 void x264_analyse_free_costs( x264_t *h );
+#define x264_analyse_weight_frame x264_template(analyse_weight_frame)
 void x264_analyse_weight_frame( x264_t *h, int end );
+#define x264_macroblock_analyse x264_template(macroblock_analyse)
 void x264_macroblock_analyse( x264_t *h );
+#define x264_slicetype_decide x264_template(slicetype_decide)
 void x264_slicetype_decide( x264_t *h );
 
+#define x264_slicetype_analyse x264_template(slicetype_analyse)
 void x264_slicetype_analyse( x264_t *h, int intra_minigop );
 
+#define x264_lookahead_init x264_template(lookahead_init)
 int  x264_lookahead_init( x264_t *h, int i_slicetype_length );
+#define x264_lookahead_is_empty x264_template(lookahead_is_empty)
 int  x264_lookahead_is_empty( x264_t *h );
+#define x264_lookahead_put_frame x264_template(lookahead_put_frame)
 void x264_lookahead_put_frame( x264_t *h, x264_frame_t *frame );
+#define x264_lookahead_get_frames x264_template(lookahead_get_frames)
 void x264_lookahead_get_frames( x264_t *h );
+#define x264_lookahead_delete x264_template(lookahead_delete)
 void x264_lookahead_delete( x264_t *h );
 
 #endif
diff --git a/encoder/encoder.c b/encoder/encoder.c
index 7edd671..df6f48c 100644
--- a/encoder/encoder.c
+++ b/encoder/encoder.c
@@ -42,6 +42,7 @@
 
 // forward declaration need for template usage
 void x264_nal_encode( x264_t *h, uint8_t *dst, x264_nal_t *nal );
+void x264_macroblock_cache_load_progressive( x264_t *h, int i_mb_x, int i_mb_y );
 
 static int encoder_frame_end( x264_t *h, x264_t *thread_current,
                               x264_nal_t **pp_nal, int *pi_nal,
diff --git a/encoder/macroblock.h b/encoder/macroblock.h
index 56e9520..20f0eeb 100644
--- a/encoder/macroblock.h
+++ b/encoder/macroblock.h
@@ -29,8 +29,10 @@
 
 #include "common/macroblock.h"
 
+#define x264_rdo_init x264_template(rdo_init)
 void x264_rdo_init( void );
 
+#define x264_macroblock_probe_skip x264_template(macroblock_probe_skip)
 int x264_macroblock_probe_skip( x264_t *h, int b_bidir );
 
 #define x264_macroblock_probe_pskip( h )\
@@ -38,32 +40,51 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir );
 #define x264_macroblock_probe_bskip( h )\
     x264_macroblock_probe_skip( h, 1 )
 
+#define x264_predict_lossless_4x4 x264_template(predict_lossless_4x4)
 void x264_predict_lossless_4x4( x264_t *h, pixel *p_dst, int p, int idx, int i_mode );
+#define x264_predict_lossless_8x8 x264_template(predict_lossless_8x8)
 void x264_predict_lossless_8x8( x264_t *h, pixel *p_dst, int p, int idx, int i_mode, pixel edge[36] );
+#define x264_predict_lossless_16x16 x264_template(predict_lossless_16x16)
 void x264_predict_lossless_16x16( x264_t *h, int p, int i_mode );
+#define x264_predict_lossless_chroma x264_template(predict_lossless_chroma)
 void x264_predict_lossless_chroma( x264_t *h, int i_mode );
 
+#define x264_macroblock_encode x264_template(macroblock_encode)
 void x264_macroblock_encode      ( x264_t *h );
+#define x264_macroblock_write_cabac x264_template(macroblock_write_cabac)
 void x264_macroblock_write_cabac ( x264_t *h, x264_cabac_t *cb );
+#define x264_macroblock_write_cavlc x264_template(macroblock_write_cavlc)
 void x264_macroblock_write_cavlc ( x264_t *h );
 
+#define x264_macroblock_encode_p8x8 x264_template(macroblock_encode_p8x8)
 void x264_macroblock_encode_p8x8( x264_t *h, int i8 );
+#define x264_macroblock_encode_p4x4 x264_template(macroblock_encode_p4x4)
 void x264_macroblock_encode_p4x4( x264_t *h, int i4 );
+#define x264_mb_encode_chroma x264_template(mb_encode_chroma)
 void x264_mb_encode_chroma( x264_t *h, int b_inter, int i_qp );
 
+#define x264_cabac_mb_skip x264_template(cabac_mb_skip)
 void x264_cabac_mb_skip( x264_t *h, int b_skip );
+#define x264_cabac_block_residual_c x264_template(cabac_block_residual_c)
 void x264_cabac_block_residual_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
+#define x264_cabac_block_residual_8x8_rd_c x264_template(cabac_block_residual_8x8_rd_c)
 void x264_cabac_block_residual_8x8_rd_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
+#define x264_cabac_block_residual_rd_c x264_template(cabac_block_residual_rd_c)
 void x264_cabac_block_residual_rd_c( x264_t *h, x264_cabac_t *cb, int ctx_block_cat, dctcoef *l );
 
+#define x264_quant_luma_dc_trellis x264_template(quant_luma_dc_trellis)
 int x264_quant_luma_dc_trellis( x264_t *h, dctcoef *dct, int i_quant_cat, int i_qp,
                                 int ctx_block_cat, int b_intra, int idx );
+#define x264_quant_chroma_dc_trellis x264_template(quant_chroma_dc_trellis)
 int x264_quant_chroma_dc_trellis( x264_t *h, dctcoef *dct, int i_qp, int b_intra, int idx );
+#define x264_quant_4x4_trellis x264_template(quant_4x4_trellis)
 int x264_quant_4x4_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
                              int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
+#define x264_quant_8x8_trellis x264_template(quant_8x8_trellis)
 int x264_quant_8x8_trellis( x264_t *h, dctcoef *dct, int i_quant_cat,
                              int i_qp, int ctx_block_cat, int b_intra, int b_chroma, int idx );
 
+#define x264_noise_reduction_update x264_template(noise_reduction_update)
 void x264_noise_reduction_update( x264_t *h );
 
 static ALWAYS_INLINE int x264_quant_4x4( x264_t *h, dctcoef dct[16], int i_qp, int ctx_block_cat, int b_intra, int p, int idx )
diff --git a/encoder/me.c b/encoder/me.c
index 65ce2a8..0594c67 100644
--- a/encoder/me.c
+++ b/encoder/me.c
@@ -1022,6 +1022,7 @@ static void refine_subpel( x264_t *h, x264_me_t *m, int hpel_iters, int qpel_ite
 
 /* Don't unroll the BIME_CACHE loop. I couldn't find any way to force this
  * other than making its iteration count not a compile-time constant. */
+#define x264_iter_kludge x264_template(iter_kludge)
 int x264_iter_kludge = 0;
 
 static void ALWAYS_INLINE me_refine_bidir( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2, int rd )
diff --git a/encoder/me.h b/encoder/me.h
index 305c42d..3df70ae 100644
--- a/encoder/me.h
+++ b/encoder/me.h
@@ -55,15 +55,22 @@ typedef struct
     ALIGNED_4( int16_t mv[2] );
 } ALIGNED_16( x264_me_t );
 
+#define x264_me_search_ref x264_template(me_search_ref)
 void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh );
 #define x264_me_search( h, m, mvc, i_mvc )\
     x264_me_search_ref( h, m, mvc, i_mvc, NULL )
 
+#define x264_me_refine_qpel x264_template(me_refine_qpel)
 void x264_me_refine_qpel( x264_t *h, x264_me_t *m );
+#define x264_me_refine_qpel_refdupe x264_template(me_refine_qpel_refdupe)
 void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh );
+#define x264_me_refine_qpel_rd x264_template(me_refine_qpel_rd)
 void x264_me_refine_qpel_rd( x264_t *h, x264_me_t *m, int i_lambda2, int i4, int i_list );
+#define x264_me_refine_bidir_rd x264_template(me_refine_bidir_rd)
 void x264_me_refine_bidir_rd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight, int i8, int i_lambda2 );
+#define x264_me_refine_bidir_satd x264_template(me_refine_bidir_satd)
 void x264_me_refine_bidir_satd( x264_t *h, x264_me_t *m0, x264_me_t *m1, int i_weight );
+#define x264_rd_cost_part x264_template(rd_cost_part)
 uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i8, int i_pixel );
 
 extern uint16_t *x264_cost_mv_fpel[QP_MAX+1][4];
diff --git a/encoder/ratecontrol.h b/encoder/ratecontrol.h
index 168b515..d4e389b 100644
--- a/encoder/ratecontrol.h
+++ b/encoder/ratecontrol.h
@@ -39,28 +39,49 @@
 
 #define CLIP_DURATION(f) x264_clip3f(f,MIN_FRAME_DURATION,MAX_FRAME_DURATION)
 
+#define x264_ratecontrol_new x264_template(ratecontrol_new)
 int  x264_ratecontrol_new   ( x264_t * );
+#define x264_ratecontrol_delete x264_template(ratecontrol_delete)
 void x264_ratecontrol_delete( x264_t * );
 
+#define x264_ratecontrol_init_reconfigurable x264_template(ratecontrol_init_reconfigurable)
 void x264_ratecontrol_init_reconfigurable( x264_t *h, int b_init );
+#define x264_encoder_reconfig_apply x264_template(encoder_reconfig_apply)
 int x264_encoder_reconfig_apply( x264_t *h, x264_param_t *param );
 
+#define x264_adaptive_quant_frame x264_template(adaptive_quant_frame)
 void x264_adaptive_quant_frame( x264_t *h, x264_frame_t *frame, float *quant_offsets );
+#define x264_macroblock_tree_read x264_template(macroblock_tree_read)
 int  x264_macroblock_tree_read( x264_t *h, x264_frame_t *frame, float *quant_offsets );
+#define x264_reference_build_list_optimal x264_template(reference_build_list_optimal)
 int  x264_reference_build_list_optimal( x264_t *h );
+#define x264_thread_sync_ratecontrol x264_template(thread_sync_ratecontrol)
 void x264_thread_sync_ratecontrol( x264_t *cur, x264_t *prev, x264_t *next );
+#define x264_ratecontrol_zone_init x264_template(ratecontrol_zone_init)
 void x264_ratecontrol_zone_init( x264_t * );
+#define x264_ratecontrol_start x264_template(ratecontrol_start)
 void x264_ratecontrol_start( x264_t *, int i_force_qp, int overhead );
+#define x264_ratecontrol_slice_type x264_template(ratecontrol_slice_type)
 int  x264_ratecontrol_slice_type( x264_t *, int i_frame );
+#define x264_ratecontrol_set_weights x264_template(ratecontrol_set_weights)
 void x264_ratecontrol_set_weights( x264_t *h, x264_frame_t *frm );
+#define x264_ratecontrol_mb x264_template(ratecontrol_mb)
 int  x264_ratecontrol_mb( x264_t *, int bits );
+#define x264_ratecontrol_qp x264_template(ratecontrol_qp)
 int  x264_ratecontrol_qp( x264_t * );
+#define x264_ratecontrol_mb_qp x264_template(ratecontrol_mb_qp)
 int  x264_ratecontrol_mb_qp( x264_t *h );
+#define x264_ratecontrol_end x264_template(ratecontrol_end)
 int  x264_ratecontrol_end( x264_t *, int bits, int *filler );
+#define x264_ratecontrol_summary x264_template(ratecontrol_summary)
 void x264_ratecontrol_summary( x264_t * );
+#define x264_rc_analyse_slice x264_template(rc_analyse_slice)
 int  x264_rc_analyse_slice( x264_t *h );
+#define x264_threads_distribute_ratecontrol x264_template(threads_distribute_ratecontrol)
 void x264_threads_distribute_ratecontrol( x264_t *h );
+#define x264_threads_merge_ratecontrol x264_template(threads_merge_ratecontrol)
 void x264_threads_merge_ratecontrol( x264_t *h );
+#define x264_hrd_fullness x264_template(hrd_fullness)
 void x264_hrd_fullness( x264_t *h );
 #endif
 
diff --git a/encoder/rdo.c b/encoder/rdo.c
index 20349a3..fa60ca3 100644
--- a/encoder/rdo.c
+++ b/encoder/rdo.c
@@ -46,6 +46,7 @@ static uint16_t cabac_size_5ones[128];
 #define bs_write_ue(s,v)   ((s)->i_bits_encoded += bs_size_ue(v))
 #define bs_write_se(s,v)   ((s)->i_bits_encoded += bs_size_se(v))
 #define bs_write_te(s,v,l) ((s)->i_bits_encoded += bs_size_te(v,l))
+#undef x264_macroblock_write_cavlc
 #define x264_macroblock_write_cavlc  static x264_macroblock_size_cavlc
 #include "cavlc.c"
 
@@ -55,6 +56,8 @@ static uint16_t cabac_size_5ones[128];
 #undef  x264_cabac_encode_decision_noup
 #undef  x264_cabac_encode_bypass
 #undef  x264_cabac_encode_terminal
+#undef  x264_cabac_encode_ue_bypass
+#undef  x264_macroblock_write_cabac
 #define x264_cabac_encode_decision(c,x,v) x264_cabac_size_decision(c,x,v)
 #define x264_cabac_encode_decision_noup(c,x,v) x264_cabac_size_decision_noup(c,x,v)
 #define x264_cabac_encode_terminal(c)     ((c)->f8_bits_encoded += 7)
diff --git a/encoder/set.h b/encoder/set.h
index 8e11655..20b7481 100644
--- a/encoder/set.h
+++ b/encoder/set.h
@@ -27,21 +27,37 @@
 #ifndef X264_ENCODER_SET_H
 #define X264_ENCODER_SET_H
 
+#define x264_sps_init x264_template(sps_init)
 void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param );
+#define x264_sps_init_reconfigurable x264_template(sps_init_reconfigurable)
 void x264_sps_init_reconfigurable( x264_sps_t *sps, x264_param_t *param );
+#define x264_sps_write x264_template(sps_write)
 void x264_sps_write( bs_t *s, x264_sps_t *sps );
+#define x264_pps_init x264_template(pps_init)
 void x264_pps_init( x264_pps_t *pps, int i_id, x264_param_t *param, x264_sps_t *sps );
+#define x264_pps_write x264_template(pps_write)
 void x264_pps_write( bs_t *s, x264_sps_t *sps, x264_pps_t *pps );
+#define x264_sei_recovery_point_write x264_template(sei_recovery_point_write)
 void x264_sei_recovery_point_write( x264_t *h, bs_t *s, int recovery_frame_cnt );
+#define x264_sei_version_write x264_template(sei_version_write)
 int  x264_sei_version_write( x264_t *h, bs_t *s );
+#define x264_validate_levels x264_template(validate_levels)
 int  x264_validate_levels( x264_t *h, int verbose );
+#define x264_sei_buffering_period_write x264_template(sei_buffering_period_write)
 void x264_sei_buffering_period_write( x264_t *h, bs_t *s );
+#define x264_sei_pic_timing_write x264_template(sei_pic_timing_write)
 void x264_sei_pic_timing_write( x264_t *h, bs_t *s );
+#define x264_sei_dec_ref_pic_marking_write x264_template(sei_dec_ref_pic_marking_write)
 void x264_sei_dec_ref_pic_marking_write( x264_t *h, bs_t *s );
+#define x264_sei_frame_packing_write x264_template(sei_frame_packing_write)
 void x264_sei_frame_packing_write( x264_t *h, bs_t *s );
+#define x264_sei_avcintra_umid_write x264_template(sei_avcintra_umid_write)
 int  x264_sei_avcintra_umid_write( x264_t *h, bs_t *s );
+#define x264_sei_avcintra_vanc_write x264_template(sei_avcintra_vanc_write)
 int  x264_sei_avcintra_vanc_write( x264_t *h, bs_t *s, int len );
+#define x264_sei_write x264_template(sei_write)
 void x264_sei_write( bs_t *s, uint8_t *payload, int payload_size, int payload_type );
+#define x264_filler_write x264_template(filler_write)
 void x264_filler_write( x264_t *h, bs_t *s, int filler );
 
 #endif
diff --git a/encoder/slicetype-cl.c b/encoder/slicetype-cl.c
index 80dc6ec..f1bd9c4 100644
--- a/encoder/slicetype-cl.c
+++ b/encoder/slicetype-cl.c
@@ -32,6 +32,7 @@
 #include <windows.h>
 #endif
 
+#define x264_weights_analyse x264_template(weights_analyse)
 void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int b_lookahead );
 
 /* We define CL_QUEUE_THREAD_HANDLE_AMD here because it is not defined
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index f7cecbf..c56efdc 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -35,6 +35,7 @@ static const uint8_t delta_tfi_divisor[10] = { 0, 2, 1, 1, 2, 2, 3, 3, 4, 6 };
 static int slicetype_frame_cost( x264_t *h, x264_mb_analysis_t *a,
                                       x264_frame_t **frames, int p0, int p1, int b );
 
+#define x264_weights_analyse x264_template(weights_analyse)
 void x264_weights_analyse( x264_t *h, x264_frame_t *fenc, x264_frame_t *ref, int b_lookahead );
 
 #if HAVE_OPENCL
-- 
2.10.0




More information about the x264-devel mailing list