CHECKED_MALLOC( frame->mb_type, i_mb_count * sizeof(int8_t));
CHECKED_MALLOC( frame->mb_partition, i_mb_count * sizeof(uint8_t));
CHECKED_MALLOC( frame->mv[0], 2*16 * i_mb_count * sizeof(int16_t) );
+ CHECKED_MALLOC( frame->mv16x16, 2*i_mb_count * sizeof(int16_t) );
CHECKED_MALLOC( frame->ref[0], 4 * i_mb_count * sizeof(int8_t) );
if( h->param.i_bframe )
{
x264_free( frame->mb_partition );
x264_free( frame->mv[0] );
x264_free( frame->mv[1] );
+ x264_free( frame->mv16x16 );
x264_free( frame->ref[0] );
x264_free( frame->ref[1] );
x264_pthread_mutex_destroy( &frame->mutex );
#include "common.h"
#include "encoder/me.h"
-/* Set up a lookup table for delta pocs to reduce an IDIV to an IMUL */
-static void setup_inverse_delta_pocs( x264_t *h )
-{
- for( int field = 0; field <= h->sh.b_mbaff; field++ )
- {
- int curpoc = h->fdec->i_poc + field*h->sh.i_delta_poc_bottom;
- for( int i = 0; i < (h->i_ref0<<h->sh.b_mbaff); i++ )
- {
- int refpoc = h->fref0[i>>h->sh.b_mbaff]->i_poc;
- if( h->sh.b_mbaff && field^(i&1) )
- refpoc += h->sh.i_delta_poc_bottom;
- int delta = curpoc - refpoc;
-
- h->fdec->inv_ref_poc[field][i] = (256 + delta/2) / delta;
- }
- }
-}
-
static NOINLINE void x264_mb_mc_0xywh( x264_t *h, int x, int y, int width, int height )
{
int i8 = x264_scan8[0]+x+8*y;
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
- for( int j = 0; j < i_refs; j++ )
+ for( int j = !i; j < i_refs; j++ )
CHECKED_MALLOC( h->mb.mvr[i][j], 2 * i_mb_count * sizeof(int16_t) );
}
void x264_macroblock_cache_free( x264_t *h )
{
for( int i = 0; i < 2; i++ )
- for( int j = 0; j < 32; j++ )
+ for( int j = !i; j < 32; j++ )
x264_free( h->mb.mvr[i][j] );
for( int i = 0; i < 16; i++ )
x264_free( h->mb.p_weight_buf[i] );
{
h->mb.mv[0] = h->fdec->mv[0];
h->mb.mv[1] = h->fdec->mv[1];
+ h->mb.mvr[0][0] = h->fdec->mv16x16;
h->mb.ref[0] = h->fdec->ref[0];
h->mb.ref[1] = h->fdec->ref[1];
h->mb.type = h->fdec->mb_type;
/* init with not available (for top right idx=7,15) */
memset( h->mb.cache.ref, -2, sizeof( h->mb.cache.ref ) );
- setup_inverse_delta_pocs( h );
+ if( h->i_ref0 > 0 )
+ for( int field = 0; field <= h->sh.b_mbaff; field++ )
+ {
+ int curpoc = h->fdec->i_poc + field*h->sh.i_delta_poc_bottom;
+ int refpoc = h->fref0[0]->i_poc;
+ if( h->sh.b_mbaff && field )
+ refpoc += h->sh.i_delta_poc_bottom;
+ int delta = curpoc - refpoc;
+
+ h->fdec->inv_ref_poc[field] = (256 + delta/2) / delta;
+ }
h->mb.i_neighbour4[6] =
h->mb.i_neighbour4[9] =
if( h->sh.b_mbaff && field^(i_ref&1) )
refpoc += h->sh.i_delta_poc_bottom;
-#define SET_TMVP(dx, dy) { \
- int i_b4 = h->mb.i_b4_xy + dx*4 + dy*4*h->mb.i_b4_stride; \
- int i_b8 = h->mb.i_b8_xy + dx*2 + dy*2*h->mb.i_b8_stride; \
- int ref_col = l0->ref[0][i_b8]; \
- if( ref_col >= 0 ) \
- { \
- int scale = (curpoc - refpoc) * l0->inv_ref_poc[h->mb.b_interlaced&field][ref_col];\
- mvc[i][0] = (l0->mv[0][i_b4][0]*scale + 128) >> 8;\
- mvc[i][1] = (l0->mv[0][i_b4][1]*scale + 128) >> 8;\
- i++; \
- } \
+#define SET_TMVP( dx, dy )\
+ { \
+ int mb_index = h->mb.i_mb_xy + dx + dy*h->mb.i_mb_stride; \
+ int scale = (curpoc - refpoc) * l0->inv_ref_poc[h->mb.b_interlaced&field];\
+ mvc[i][0] = (l0->mv16x16[mb_index][0]*scale + 128) >> 8;\
+ mvc[i][1] = (l0->mv16x16[mb_index][1]*scale + 128) >> 8;\
+ i++;\
}
SET_TMVP(0,0);