int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
int seg_map_index = (mb_row * cpi->common.mb_cols);
-
+#if CONFIG_SEGMENTATION
+ int left_id, above_id;
+ int sum;
++#endif
+ #if CONFIG_MULTITHREAD
+ const int nsync = cpi->mt_sync_range;
+ const int rightmost_col = cm->mb_cols - 1;
+ volatile const int *last_row_current_mb_col;
+
+ if ((cpi->b_multi_threaded != 0) && (mb_row != 0))
+ last_row_current_mb_col = &cpi->mt_current_mb_col[mb_row - 1];
+ else
+ last_row_current_mb_col = &rightmost_col;
#endif
-
// reset above block coeffs
xd->above_context = cm->above_context;
xd->mode_info_context++;
x->partition_info++;
x->activity_sum += activity_sum;
-
+ #if CONFIG_MULTITHREAD
+ if ((cpi->b_multi_threaded != 0) && (mb_row == cm->mb_rows - 1))
+ {
+ sem_post(&cpi->h_event_end_encoding); /* signal frame encoding end */
+ }
+ #endif
}
--
void vp8_encode_frame(VP8_COMP *cpi)
{
int mb_row;
break;
//if(WaitForSingleObject(cpi->h_event_mbrencoding[ithread], INFINITE) == WAIT_OBJECT_0)
- if (sem_wait(&cpi->h_event_mbrencoding[ithread]) == 0)
+ if (sem_wait(&cpi->h_event_start_encoding[ithread]) == 0)
{
+ VP8_COMMON *cm = &cpi->common;
+ int mb_row;
+ MACROBLOCK *x = &mbri->mb;
+ MACROBLOCKD *xd = &x->e_mbd;
+ TOKENEXTRA *tp ;
+
+ int *segment_counts = mbri->segment_counts;
+ int *totalrate = &mbri->totalrate;
+
if (cpi->b_multi_threaded == FALSE) // we're shutting down
break;
- else
+
+ for (mb_row = ithread + 1; mb_row < cm->mb_rows; mb_row += (cpi->encoding_thread_count + 1))
{
- VP8_COMMON *cm = &cpi->common;
- int mb_row = mbri->mb_row;
- MACROBLOCK *x = &mbri->mb;
- MACROBLOCKD *xd = &x->e_mbd;
- TOKENEXTRA **tp = &mbri->tp;
- int *segment_counts = mbri->segment_counts;
- int *totalrate = &mbri->totalrate;
- {
- int i;
- int recon_yoffset, recon_uvoffset;
- int mb_col;
- int ref_fb_idx = cm->lst_fb_idx;
- int dst_fb_idx = cm->new_fb_idx;
- int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
- int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
- volatile int *last_row_current_mb_col;
- INT64 activity_sum = 0;
-
- if (ithread > 0)
- last_row_current_mb_col = &cpi->mb_row_ei[ithread-1].current_mb_col;
- else
- last_row_current_mb_col = &cpi->current_mb_col_main;
+ int i;
+ int recon_yoffset, recon_uvoffset;
+ int mb_col;
+ int ref_fb_idx = cm->lst_fb_idx;
+ int dst_fb_idx = cm->new_fb_idx;
+ int recon_y_stride = cm->yv12_fb[ref_fb_idx].y_stride;
+ int recon_uv_stride = cm->yv12_fb[ref_fb_idx].uv_stride;
+ volatile int *last_row_current_mb_col;
+ INT64 activity_sum = 0;
- // reset above block coeffs
- xd->above_context = cm->above_context;
- xd->left_context = &mb_row_left_context;
+ tp = cpi->tok + (mb_row * (cm->mb_cols * 16 * 24));
- vp8_zero(mb_row_left_context);
+ last_row_current_mb_col = &cpi->mt_current_mb_col[mb_row - 1];
- xd->up_available = (mb_row != 0);
- recon_yoffset = (mb_row * recon_y_stride * 16);
- recon_uvoffset = (mb_row * recon_uv_stride * 8);
+ // reset above block coeffs
+ xd->above_context = cm->above_context;
+ xd->left_context = &mb_row_left_context;
+ vp8_zero(mb_row_left_context);
- cpi->tplist[mb_row].start = *tp;
+ xd->up_available = (mb_row != 0);
+ recon_yoffset = (mb_row * recon_y_stride * 16);
+ recon_uvoffset = (mb_row * recon_uv_stride * 8);
- //printf("Thread mb_row = %d\n", mb_row);
+ cpi->tplist[mb_row].start = tp;
- // for each macroblock col in image
- for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
- {
- int seg_map_index = (mb_row * cm->mb_cols);
+ //printf("Thread mb_row = %d\n", mb_row);
+
+ // for each macroblock col in image
+ for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
+ {
+ int seg_map_index = (mb_row * cm->mb_cols);
-
+
- while (mb_col > (*last_row_current_mb_col - 1) && *last_row_current_mb_col != cm->mb_cols - 1)
+ if ((mb_col & (nsync - 1)) == 0)
+ {
+ while (mb_col > (*last_row_current_mb_col - nsync) && *last_row_current_mb_col != cm->mb_cols - 1)
{
x86_pause_hint();
thread_sleep(0);