This should make it easier to play around with reference frame counts that exceed the spec maximum.
} while( 0 )
#define X264_BFRAME_MAX 16
+#define X264_REF_MAX 16
#define X264_THREAD_MAX 128
#define X264_PCM_COST (384*BIT_DEPTH+16)
#define X264_LOOKAHEAD_MAX 250
{
int idc;
int arg;
- } ref_pic_list_order[2][16];
+ } ref_pic_list_order[2][X264_REF_MAX];
/* P-frame weighting */
- x264_weight_t weight[32][3];
+ x264_weight_t weight[X264_REF_MAX*2][3];
int i_mmco_remove_from_end;
int i_mmco_command_count;
{
int i_difference_of_pic_nums;
int i_poc;
- } mmco[16];
+ } mmco[X264_REF_MAX];
int i_cabac_init_idc;
x264_frame_t **blank_unused;
/* frames used for reference + sentinels */
- x264_frame_t *reference[16+2];
+ x264_frame_t *reference[X264_REF_MAX+2];
int i_last_keyframe; /* Frame number of the last keyframe */
int i_last_idr; /* Frame number of the last IDR (not RP)*/
/* references lists */
int i_ref0;
- x264_frame_t *fref0[16+3]; /* ref list 0 */
+ x264_frame_t *fref0[X264_REF_MAX+3]; /* ref list 0 */
int i_ref1;
- x264_frame_t *fref1[16+3]; /* ref list 1 */
+ x264_frame_t *fref1[X264_REF_MAX+3]; /* ref list 1 */
int b_ref_reorder[2];
/* hrd */
int16_t (*mv[2])[2]; /* mb mv. set to 0 for intra mb */
uint8_t (*mvd[2])[8][2]; /* absolute value of mb mv difference with predict, clipped to [0,33]. set to 0 if intra. cabac only */
int8_t *ref[2]; /* mb ref. set to -1 if non used (intra or Lx only) */
- int16_t (*mvr[2][32])[2]; /* 16x16 mv for each possible ref */
+ int16_t (*mvr[2][X264_REF_MAX*2])[2];/* 16x16 mv for each possible ref */
int8_t *skipbp; /* block pattern for SKIP or DIRECT (sub)mbs. B-frames + cabac only */
int8_t *mb_transform_size; /* transform_size_8x8_flag of each mb */
uint16_t *slice_table; /* sh->first_mb of the slice that the indexed mb is part of
* NOTE: this will fail on resolutions above 2^16 MBs... */
/* buffer for weighted versions of the reference frames */
- pixel *p_weight_buf[16];
+ pixel *p_weight_buf[X264_REF_MAX];
/* current value */
int i_type;
/* pointer over mb of the references */
int i_fref[2];
- pixel *p_fref[2][32][4+1]; /* last: yN, yH, yV, yHV, uv */
- pixel *p_fref_w[32]; /* weighted fullpel luma */
- uint16_t *p_integral[2][16];
+ pixel *p_fref[2][X264_REF_MAX*2][4+1]; /* last: yN, yH, yV, yHV, uv */
+ pixel *p_fref_w[X264_REF_MAX*2]; /* weighted fullpel luma */
+ uint16_t *p_integral[2][X264_REF_MAX];
/* fref stride */
int i_stride[3];
int i_chroma_lambda2_offset;
/* B_direct and weighted prediction */
- int16_t dist_scale_factor_buf[2][32][4];
+ int16_t dist_scale_factor_buf[2][X264_REF_MAX*2][4];
int16_t (*dist_scale_factor)[4];
- int8_t bipred_weight_buf[2][32][4];
+ int8_t bipred_weight_buf[2][X264_REF_MAX*2][4];
int8_t (*bipred_weight)[4];
/* maps fref1[0]'s ref indices into the current list0 */
#define map_col_to_list0(col) h->mb.map_col_to_list0[(col)+2]
- int8_t map_col_to_list0[18];
+ int8_t map_col_to_list0[X264_REF_MAX+2];
int ref_blind_dupe; /* The index of the blind reference frame duplicate. */
- int8_t deblock_ref_table[32+2];
+ int8_t deblock_ref_table[X264_REF_MAX*2+2];
#define deblock_ref_table(x) h->mb.deblock_ref_table[(x)+2]
} mb;
int i_mb_count_p;
int i_mb_count_skip;
int i_mb_count_8x8dct[2];
- int i_mb_count_ref[2][32];
+ int i_mb_count_ref[2][X264_REF_MAX*2];
int i_mb_partition[17];
int i_mb_cbp[6];
int i_mb_pred_mode[4][13];
int64_t i_mb_count[5][19];
int64_t i_mb_partition[2][17];
int64_t i_mb_count_8x8dct[2];
- int64_t i_mb_count_ref[2][2][32];
+ int64_t i_mb_count_ref[2][2][X264_REF_MAX*2];
int64_t i_mb_cbp[6];
int64_t i_mb_pred_mode[4][13];
/* */
pixel *buffer[4];
pixel *buffer_lowres[4];
- x264_weight_t weight[16][3]; /* [ref_index][plane] */
- pixel *weighted[16]; /* plane[0] weighted of the reference frames */
+ x264_weight_t weight[X264_REF_MAX][3]; /* [ref_index][plane] */
+ pixel *weighted[X264_REF_MAX]; /* plane[0] weighted of the reference frames */
int b_duplicate;
struct x264_frame *orig;
int *lowres_mv_costs[2][X264_BFRAME_MAX+1];
int8_t *ref[2];
int i_ref[2];
- int ref_poc[2][16];
+ int ref_poc[2][X264_REF_MAX];
int16_t inv_ref_poc[2]; // inverse values of ref0 poc to avoid divisions in temporal MV prediction
/* for adaptive B-frame decision.
for( int i = 0; i < 2; i++ )
{
- int i_refs = X264_MIN(16, (i ? 1 + !!h->param.i_bframe_pyramid : h->param.i_frame_reference) ) << h->param.b_interlaced;
+ int i_refs = X264_MIN(X264_REF_MAX, (i ? 1 + !!h->param.i_bframe_pyramid : h->param.i_frame_reference) ) << h->param.b_interlaced;
if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_SMART )
- i_refs = X264_MIN(16, i_refs + 2); //smart weights add two duplicate frames
+ i_refs = X264_MIN(X264_REF_MAX, i_refs + 2); //smart weights add two duplicate frames
else if( h->param.analyse.i_weighted_pred == X264_WEIGHTP_BLIND )
- i_refs = X264_MIN(16, i_refs + 1); //blind weights add one duplicate frame
+ i_refs = X264_MIN(X264_REF_MAX, i_refs + 1); //blind weights add one duplicate frame
for( int j = !i; j < i_refs; j++ )
{
void x264_macroblock_cache_free( x264_t *h )
{
for( int i = 0; i < 2; i++ )
- for( int j = !i; j < 32; j++ )
+ for( int j = !i; j < X264_REF_MAX*2; j++ )
if( h->mb.mvr[i][j] )
x264_free( h->mb.mvr[i][j]-1 );
- for( int i = 0; i < 16; i++ )
+ for( int i = 0; i < X264_REF_MAX; i++ )
x264_free( h->mb.p_weight_buf[i] );
if( h->param.b_cabac )
h->param.i_slice_count = 0;
}
- h->param.i_frame_reference = x264_clip3( h->param.i_frame_reference, 1, 16 );
- h->param.i_dpb_size = x264_clip3( h->param.i_dpb_size, 1, 16 );
+ h->param.i_frame_reference = x264_clip3( h->param.i_frame_reference, 1, X264_REF_MAX );
+ h->param.i_dpb_size = x264_clip3( h->param.i_dpb_size, 1, X264_REF_MAX );
h->param.i_keyint_max = x264_clip3( h->param.i_keyint_max, 1, X264_KEYINT_MAX_INFINITE );
if( h->param.i_scenecut_threshold < 0 )
h->param.i_scenecut_threshold = 0;
CHECKED_MALLOCZERO( h->frames.unused[0], (h->frames.i_delay + 3) * sizeof(x264_frame_t *) );
/* Allocate room for max refs plus a few extra just in case. */
- CHECKED_MALLOCZERO( h->frames.unused[1], (h->i_thread_frames + 20) * sizeof(x264_frame_t *) );
+ CHECKED_MALLOCZERO( h->frames.unused[1], (h->i_thread_frames + X264_REF_MAX + 4) * sizeof(x264_frame_t *) );
CHECKED_MALLOCZERO( h->frames.current, (h->param.i_sync_lookahead + h->param.i_bframe
+ h->i_thread_frames + 3) * sizeof(x264_frame_t *) );
if( h->param.analyse.i_weighted_pred > 0 )
/* shift the frames to make space for the dupe. */
h->b_ref_reorder[0] = 1;
- if( h->i_ref0 < 16 )
+ if( h->i_ref0 < X264_REF_MAX )
++h->i_ref0;
- h->fref0[15] = NULL;
+ h->fref0[X264_REF_MAX-1] = NULL;
x264_frame_unshift( &h->fref0[j], newframe );
return j;
h->mb.ref_blind_dupe = idx;
}
- assert( h->i_ref0 + h->i_ref1 <= 16 );
+ assert( h->i_ref0 + h->i_ref1 <= X264_REF_MAX );
h->mb.pic.i_fref[0] = h->i_ref0;
h->mb.pic.i_fref[1] = h->i_ref1;
}
h->stat.i_mb_pred_mode[i][j] += h->stat.frame.i_mb_pred_mode[i][j];
if( h->sh.i_type != SLICE_TYPE_I )
for( int i_list = 0; i_list < 2; i_list++ )
- for( int i = 0; i < 32; i++ )
+ for( int i = 0; i < X264_REF_MAX*2; i++ )
h->stat.i_mb_count_ref[h->sh.i_type][i_list][i] += h->stat.frame.i_mb_count_ref[i_list][i];
if( h->sh.i_type == SLICE_TYPE_P )
{
char *p = buf;
int64_t i_den = 0;
int i_max = 0;
- for( int i = 0; i < 32; i++ )
+ for( int i = 0; i < X264_REF_MAX*2; i++ )
if( h->stat.i_mb_count_ref[i_slice][i_list][i] )
{
i_den += h->stat.i_mb_count_ref[i_slice][i_list][i];
/* extra slot with pyramid so that we don't have to override the
* order of forgetting old pictures */
sps->vui.i_max_dec_frame_buffering =
- sps->i_num_ref_frames = X264_MIN(16, X264_MAX4(param->i_frame_reference, 1 + sps->vui.i_num_reorder_frames,
+ sps->i_num_ref_frames = X264_MIN(X264_REF_MAX, X264_MAX4(param->i_frame_reference, 1 + sps->vui.i_num_reorder_frames,
param->i_bframe_pyramid ? 4 : 1, param->i_dpb_size));
sps->i_num_ref_frames -= param->i_bframe_pyramid == X264_B_PYRAMID_STRICT;