Moved error_bins to macroblock struct

Change-Id: Ic9956ddf1c2ddffcf7be7fdfc23ad9a2426fc47a
WIP: Fixing unsafe threading in VP8 encoder.
This commit is contained in:
Scott LaVarnway 2012-12-10 17:32:58 -08:00
parent 2cd48bdc92
commit a0ad16e203
6 changed files with 13 additions and 6 deletions

View File

@ -19,6 +19,7 @@
#include "vpx_ports/mem.h" #include "vpx_ports/mem.h"
#define MAX_MODES 20 #define MAX_MODES 20
#define MAX_ERROR_BINS 1024
/* motion search site */ /* motion search site */
typedef struct typedef struct
@ -148,6 +149,7 @@ typedef struct macroblock
int last_zbin_over_quant; int last_zbin_over_quant;
int zbin_over_quant; int zbin_over_quant;
int error_bins[MAX_ERROR_BINS];
void (*short_fdct4x4)(short *input, short *output, int pitch); void (*short_fdct4x4)(short *input, short *output, int pitch);
void (*short_fdct8x4)(short *input, short *output, int pitch); void (*short_fdct8x4)(short *input, short *output, int pitch);

View File

@ -897,6 +897,10 @@ void vp8_encode_frame(VP8_COMP *cpi)
cpi->mb.count_mb_ref_frame_usage[c_idx] += cpi->mb.count_mb_ref_frame_usage[c_idx] +=
x->count_mb_ref_frame_usage[c_idx]; x->count_mb_ref_frame_usage[c_idx];
for(c_idx = 0; c_idx < MAX_ERROR_BINS; c_idx++)
cpi->mb.error_bins[c_idx] +=
cpi->mb_row_ei[i].mb.error_bins[c_idx];
/* add up counts for each thread */ /* add up counts for each thread */
sum_coef_counts(x, &cpi->mb_row_ei[i].mb); sum_coef_counts(x, &cpi->mb_row_ei[i].mb);
} }

View File

@ -427,6 +427,8 @@ static void setup_mbby_copy(MACROBLOCK *mbdst, MACROBLOCK *mbsrc)
z->zbin_over_quant = x->zbin_over_quant; z->zbin_over_quant = x->zbin_over_quant;
z->zbin_mode_boost_enabled = x->zbin_mode_boost_enabled; z->zbin_mode_boost_enabled = x->zbin_mode_boost_enabled;
z->zbin_mode_boost = x->zbin_mode_boost; z->zbin_mode_boost = x->zbin_mode_boost;
vpx_memset(z->error_bins, 0, sizeof(z->error_bins));
} }
} }

View File

@ -837,7 +837,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
for (i = 0; i < min; i++) for (i = 0; i < min; i++)
{ {
sum += cpi->error_bins[i]; sum += cpi->mb.error_bins[i];
} }
total_skip = sum; total_skip = sum;
@ -846,7 +846,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
/* i starts from 2 to make sure thresh started from 2048 */ /* i starts from 2 to make sure thresh started from 2048 */
for (; i < 1024; i++) for (; i < 1024; i++)
{ {
sum += cpi->error_bins[i]; sum += cpi->mb.error_bins[i];
if (10 * sum >= (unsigned int)(cpi->Speed - 6)*(total_mbs - total_skip)) if (10 * sum >= (unsigned int)(cpi->Speed - 6)*(total_mbs - total_skip))
break; break;
@ -901,7 +901,7 @@ void vp8_set_speed_features(VP8_COMP *cpi)
if (Speed >= 15) if (Speed >= 15)
sf->half_pixel_search = 0; sf->half_pixel_search = 0;
vpx_memset(cpi->error_bins, 0, sizeof(cpi->error_bins)); vpx_memset(cpi->mb.error_bins, 0, sizeof(cpi->mb.error_bins));
}; /* switch */ }; /* switch */
@ -1998,7 +1998,7 @@ struct VP8_COMP* vp8_create_compressor(VP8_CONFIG *oxcf)
cpi->refining_search_sad = vp8_refining_search_sad; cpi->refining_search_sad = vp8_refining_search_sad;
/* make sure frame 1 is okay */ /* make sure frame 1 is okay */
cpi->error_bins[0] = cpi->common.MBs; cpi->mb.error_bins[0] = cpi->common.MBs;
/* vp8cx_init_quantizer() is first called here. Add check in /* vp8cx_init_quantizer() is first called here. Add check in
* vp8cx_frame_init_quantizer() so that vp8cx_init_quantizer is only * vp8cx_frame_init_quantizer() so that vp8cx_init_quantizer is only

View File

@ -488,7 +488,6 @@ typedef struct VP8_COMP
int ref_frame_flags; int ref_frame_flags;
SPEED_FEATURES sf; SPEED_FEATURES sf;
int error_bins[1024];
/* Count ZEROMV on all reference frames. */ /* Count ZEROMV on all reference frames. */
int zeromv_count; int zeromv_count;

View File

@ -1160,7 +1160,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
this_rdbin = 1023; this_rdbin = 1023;
} }
cpi->error_bins[this_rdbin] ++; x->error_bins[this_rdbin] ++;
} }
#if CONFIG_TEMPORAL_DENOISING #if CONFIG_TEMPORAL_DENOISING