From d4a6aed4711fcd4ae6ca215209614dc15ff1d325 Mon Sep 17 00:00:00 2001 From: Laurent Fasnacht Date: Fri, 16 May 2014 11:35:47 +0200 Subject: [PATCH] Multi-row jobs --- src/encoder.c | 8 +++--- tools/plot-threadqueue-log.py | 54 ++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/encoder.c b/src/encoder.c index 303a944b..4b524d13 100644 --- a/src/encoder.c +++ b/src/encoder.c @@ -1294,7 +1294,7 @@ static void encoder_state_encode_leaf(encoder_state * const encoder_state) { if (encoder->sao_enable) { PERFORMANCE_MEASURE_START(); sao_reconstruct_frame(encoder_state); - PERFORMANCE_MEASURE_END(encoder_state->encoder_control->threadqueue, "type=sao_reconstruct_frame,frame=%d,tile=%d,slice=%d", encoder_state->global->frame, encoder_state->tile->id, encoder_state->slice->id); + PERFORMANCE_MEASURE_END(encoder_state->encoder_control->threadqueue, "type=sao_reconstruct_frame,frame=%d,tile=%d,slice=%d,row=%d-%d", encoder_state->global->frame, encoder_state->tile->id, encoder_state->slice->id, encoder_state->lcu_order[0].position.y + encoder_state->tile->lcu_offset_y, encoder_state->lcu_order[encoder_state->lcu_order_count-1].position.y + encoder_state->tile->lcu_offset_y); } } else { for (i = 0; i < encoder_state->lcu_order_count; ++i) { @@ -1336,7 +1336,7 @@ static void worker_encoder_state_encode_children(void * opaque) { if (sub_state->type != ENCODER_STATE_TYPE_WAVEFRONT_ROW) { PERFORMANCE_MEASURE_START(); encoder_state_write_bitstream_leaf(sub_state); - PERFORMANCE_MEASURE_END(sub_state->encoder_control->threadqueue, "type=encoder_state_write_bitstream_leaf,frame=%d,tile=%d,slice=%d,row=%d", sub_state->global->frame, sub_state->tile->id, sub_state->slice->id, sub_state->wfrow->lcu_offset_y); + PERFORMANCE_MEASURE_END(sub_state->encoder_control->threadqueue, "type=encoder_state_write_bitstream_leaf,frame=%d,tile=%d,slice=%d,row=%d-%d", sub_state->global->frame, sub_state->tile->id, sub_state->slice->id, sub_state->lcu_order[0].position.y + sub_state->tile->lcu_offset_y, sub_state->lcu_order[sub_state->lcu_order_count-1].position.y + sub_state->tile->lcu_offset_y); } else { threadqueue_job *job; #ifdef _DEBUG @@ -1387,7 +1387,7 @@ static void encoder_state_encode(encoder_state * const main_state) { char job_description[256]; switch (main_state->children[i].type) { case ENCODER_STATE_TYPE_TILE: - sprintf(job_description, "frame=%d,tile=%d,position_x=%d,position_y=%d", main_state->children[i].global->frame, main_state->children[i].tile->id, main_state->children[i].tile->lcu_offset_x, main_state->children[i].tile->lcu_offset_y); + sprintf(job_description, "frame=%d,tile=%d,row=%d-%d,position_x=%d,position_y=%d", main_state->children[i].global->frame, main_state->children[i].tile->id, main_state->children[i].lcu_order[0].position.y + main_state->children[i].tile->lcu_offset_y, main_state->children[i].lcu_order[main_state->children[i].lcu_order_count-1].position.y + main_state->children[i].tile->lcu_offset_y, main_state->children[i].tile->lcu_offset_x, main_state->children[i].tile->lcu_offset_y); break; case ENCODER_STATE_TYPE_SLICE: sprintf(job_description, "frame=%d,slice=%d,start_in_ts=%d", main_state->children[i].global->frame, main_state->children[i].slice->id, main_state->children[i].slice->start_in_ts); @@ -1412,7 +1412,7 @@ static void encoder_state_encode(encoder_state * const main_state) { if (main_state->encoder_control->sao_enable && main_state->children[0].type == ENCODER_STATE_TYPE_WAVEFRONT_ROW) { PERFORMANCE_MEASURE_START(); sao_reconstruct_frame(main_state); - PERFORMANCE_MEASURE_END(main_state->encoder_control->threadqueue, "type=sao_reconstruct_frame,frame=%d,tile=%d,slice=%d", main_state->global->frame, main_state->tile->id, main_state->slice->id); + PERFORMANCE_MEASURE_END(main_state->encoder_control->threadqueue, "type=sao_reconstruct_frame,frame=%d,tile=%d,slice=%d,row=%d-%d", main_state->global->frame, main_state->tile->id, main_state->slice->id,0,main_state->encoder_control->in.height_in_lcu - 1); } } else { diff --git a/tools/plot-threadqueue-log.py b/tools/plot-threadqueue-log.py index e93bef6d..b5966be8 100644 --- a/tools/plot-threadqueue-log.py +++ b/tools/plot-threadqueue-log.py @@ -34,12 +34,42 @@ class LogJob: def _get_properties(self): return dict([x.split('=',1) for x in self._description.split(',')]) + def _position_from_str(self, s): + if re.match('^[0-9]+$', s): + return int(s) + else: + v = [float(x) for x in s.split('-', 1)] + return (v[0] + v[1]) / 2 + + def _height_from_str(self, s): + if self._is_thread_job: + diff = 0.2 + else: + diff = 0.4 + if re.match('^[0-9]+$', s): + return 1.0 - diff + else: + v = [float(x) for x in s.split('-', 1)] + return (max(v) - min(v) + 1) - diff + + def height(self): + desc = self._get_properties() + if 'row' in desc: + return self._height_from_str(desc['row']) + elif 'position_y' in desc: + return self._height_from_str(desc['position_y']) + else: + if self._is_thread_job: + return 0.8 + else: + return 0.6 + def position_y(self): desc = self._get_properties() - if 'position_y' in desc: - return int(desc['position_y']) - elif 'row' in desc: - return int(desc['row']) + if 'row' in desc: + return self._position_from_str(desc['row']) + elif 'position_y' in desc: + return self._position_from_str(desc['position_y']) else: return -1 @@ -206,15 +236,19 @@ class LogParser: for o in self._objects: if isinstance(o, LogJob) and o._is_thread_job: y = o.position_y() - ax.barh(-y, o._stop - o._start, left=o._start, height=0.8, align='center', color=self.get_color(o._worker_id)) - yticks[-y]=y + height = o.height() + ax.barh(-y, o._stop - o._start, left=o._start, height=height, align='center', color=self.get_color(o._worker_id)) + if y % 1 <= 0.0001: + yticks[int(-y)]= int(y) #then jobs for o in self._objects: if isinstance(o, LogJob) and not o._is_thread_job: y = o.position_y() - ax.barh(-y, o._stop - o._start, left=o._start, height=0.8, align='center', color=self.get_color(o._worker_id, False)) - yticks[-y]=y + height = o.height() + ax.barh(-y, o._stop - o._start, left=o._start, height=height, align='center', color=self.get_color(o._worker_id, False)) + if y % 1 <= 0.0001: + yticks[int(-y)]= int(y) for o in self._objects: if isinstance(o, LogJob): @@ -222,9 +256,9 @@ class LogParser: ax.plot([o2._stop, o._start], [-int(o2.position_y()), -int(o.position_y())] , linewidth=1, color='k') for y in yticks.keys(): - ax.axhline(y+0.5) + ax.axhline(y+0.5, color='k') if y - 1 not in yticks.keys(): - ax.axhline(y-0.5) + ax.axhline(y-0.5, color='k') if y == 1: yticks[y] = "None"