Пример #1
0
SequenceDataPtr CastTransformer::TypedCast<TElementTo>::Apply(SequenceDataPtr sequence)
{
    auto shape = m_parent->m_inputStream.m_sampleLayout;
    if (shape.IsUnknown()) // Taking the shape from the sequence.
        shape = sequence->GetSampleShape();

    if (shape.IsUnknown())
        RuntimeError("Unknown shape of the sample in stream '%ls'.", m_parent->m_inputStream.m_name.c_str());

    auto& inputSequence = static_cast<DenseSequenceData&>(*sequence);
    size_t count = shape.TotalSize() * sequence->m_numberOfSamples;
    auto result = std::make_shared<DenseSequenceWithBuffer<TElementTo>>(m_memBuffers, count, shape);
    result->m_key = sequence->m_key;

    auto src = reinterpret_cast<const TElementFrom*>(inputSequence.GetDataBuffer());
    auto dst = result->GetBuffer();

    for (size_t i = 0; i < count; i++)
    {
        dst[i] = static_cast<TElementTo>(src[i]);
    }

    result->m_numberOfSamples = inputSequence.m_numberOfSamples;
    return result;
}
Пример #2
0
/**
@internalComponent
*/
TInt DMediaDriverFlash::DoCreate(TInt /*aMediaId*/)
//
// Create the media driver.
//
	{
	
	TInt r=Initialise();		// interrogate FLASH etc.
	if (r==KErrNone)
		{
		TUint32 size=TotalSize();
		SetTotalSizeInBytes(size);
		}
	return r;
	}
Пример #3
0
int ChildCount(const ND* node, bool recurse)
{
	if (node == NULL || node->children == NULL)
		return 0;
	int i = 0;
	const ND* tmp = node->children;
	while (tmp != NULL) {
		i++;
		if (tmp->children != NULL && recurse == true) {
			i += TotalSize(tmp->children);
		}
		tmp = tmp->next;
	}
	return i;
}
Пример #4
0
void ChipReduction::SmoothBlocks(int well_height, int well_width) {
  m_nn_avg.Init(m_block_height, m_block_width, m_num_frames);
  m_nn_avg.CalcCumulativeSum(m_block_avg, m_bad_wells);
  m_nn_avg.CalcNNAvg(m_y_clip, m_x_clip, 
               well_height / m_y_step, well_width / m_x_step);
  const float *nn_avg = m_nn_avg.GetNNAvgPtr();
  memcpy(m_block_smooth, nn_avg, sizeof(float) * TotalSize());
  for (int row = 0; row < m_block_height; row++) {
    for (int col = 0; col < m_block_width; col++) {
      for (int frame = 0; frame < m_num_frames; frame++) {
        m_well_cont_block_smooth[(row * m_block_width + col) * m_num_frames + frame] = m_block_smooth[frame * m_block_frame_stride + row * m_block_width + col];
      }
    }
  }
}
Пример #5
0
int TotalSize(ND* node)
{
	int i = 0;
	ND* tmp = node;

	if (tmp == NULL) {
		return 0;
	}
	while (tmp != NULL) {
		i++;
		if (tmp->children != NULL ) {
			i += TotalSize(tmp->children);
		}
		tmp = tmp->next;
	}
	return i;
}
bool FNameTableArchiveReader::SerializeNameMap()
{
	int64 NameOffset = 0;
	*this << NameOffset;

	if (IsError() || NameOffset > TotalSize())
	{
		// The file was corrupted. Return false to fail to load the cache an thus regenerate it.
		return false;
	}

	if( NameOffset > 0 )
	{
		int64 OriginalOffset = Tell();
		Seek( NameOffset );

		int32 NameCount = 0;
		*this << NameCount;

		if (IsError())
		{
			return false;
		}

		for ( int32 NameMapIdx = 0; NameMapIdx < NameCount; ++NameMapIdx )
		{
			// Read the name entry from the file.
			FNameEntrySerialized NameEntry(ENAME_LinkerConstructor);
			*this << NameEntry;

			if (IsError())
			{
				return false;
			}

			NameMap.Add(FName(NameEntry));
		}

		Seek( OriginalOffset );
	}

	return true;
}
Пример #7
0
void CWound::Incarnation	(float percent, float min_wound_size)
{
	float total_size = TotalSize();

	if(fis_zero(total_size))
	{
		for(int i=0; i<ALife::eHitTypeMax; i++)
			m_Wounds[i] = 0.f;
		return;
	}

	//заживить все раны пропорционально их размеру
	for(int i=0; i<ALife::eHitTypeMax; i++)
	{
		m_Wounds[i] -= percent/* *m_Wounds[i]*/;
		if(m_Wounds[i]<min_wound_size)
			m_Wounds[i] = 0;
	}
}
Пример #8
0
void ChipReduction::Init(int chip_height, int chip_width, int num_frames,
                         int y_step, int x_step,
                         int y_clip, int x_clip, int min_good_wells) {
  Cleanup();
  m_chip_height = chip_height;
  m_chip_width = chip_width;
  m_num_frames = num_frames;
  m_y_step = y_step;
  m_x_step = x_step;
  m_y_clip = ceil((float)y_clip / m_y_step);
  m_x_clip = ceil((float)x_clip / m_x_step);
  m_min_good_reduced_wells = min_good_wells;
  m_block_height = ceil((float)m_chip_height / m_y_step);
  m_block_width = ceil((float) m_chip_width / m_x_step);
  m_block_frame_stride = m_block_width * m_block_height;
  int total_size = TotalSize();
  m_block_avg = (float *)memalign(VEC8F_SIZE_B, sizeof(float) * total_size);
  m_block_smooth = (float *)memalign(VEC8F_SIZE_B, sizeof(float) * total_size);
  m_well_cont_block_smooth = (float *)memalign(VEC8F_SIZE_B, sizeof(float) * total_size);
  m_good_wells = (int *)memalign(VEC8F_SIZE_B, sizeof(int) * total_size);
  m_bad_wells = (char *)memalign(VEC8F_SIZE_B, sizeof(char) * total_size);
  Reset();
}
Пример #9
0
SequenceDataPtr TransposeTransformer::TypedTranspose<TElementTo>::Apply(ImageSequenceData* inputSequence)
{
    auto shape = m_parent->m_inputStream.m_sampleLayout;
    if (shape.IsUnknown()) // Taking the shape from the sequence.
    {
        shape = inputSequence->m_sampleShape;
    }

    if (shape.IsUnknown())
        RuntimeError("Unknown shape of the sample in stream '%ls'.", m_parent->m_inputStream.m_name.c_str());

    assert(inputSequence->m_numberOfSamples == 1);

    size_t count = shape.TotalSize();

    ImageDimensions dimensions(TensorShape(shape.Dimensions()), ImageLayoutKind::HWC);
    size_t rowCount = dimensions.m_height * dimensions.m_width;
    size_t channelCount = dimensions.m_numChannels;

    auto dims = dimensions.AsTensorShape(CHW).GetDims();
    NDShape resultShape(std::vector<size_t>(dims.begin(), dims.end()));
    auto result = std::make_shared<DenseSequenceWithBuffer<TElementTo>>(m_memBuffers, count, resultShape);
    result->m_key = inputSequence->m_key;

    auto dst = result->GetBuffer();

    if (channelCount == 3) // Unrolling for BGR, the most common case.
    {
        size_t nRows = inputSequence->m_image.rows;
        size_t nCols = inputSequence->m_image.cols;

        TElementTo* b = dst;
        TElementTo* g = dst + rowCount;
        TElementTo* r = dst + 2 * rowCount;

        for (size_t i = 0; i < nRows; ++i)
        {
            auto* x = inputSequence->m_image.ptr<TElementFrom>((int)i);
            for (size_t j = 0; j < nCols; ++j)
            {
                auto row = j * 3;
                *b++ = static_cast<TElementTo>(x[row]);
                *g++ = static_cast<TElementTo>(x[row + 1]);
                *r++ = static_cast<TElementTo>(x[row + 2]);
            }
        }
    }
    else
    {
        auto src = reinterpret_cast<const TElementFrom*>(inputSequence->GetDataBuffer());
        for (size_t irow = 0; irow < rowCount; irow++)
        {
            for (size_t icol = 0; icol < channelCount; icol++)
            {
                dst[icol * rowCount + irow] = static_cast<TElementTo>(src[irow * channelCount + icol]);
            }
        }
    }

    
    result->m_numberOfSamples = inputSequence->m_numberOfSamples;
    return result;
}
Пример #10
0
int main(void)
{
	int l_init = 0;

	l_init = zlog_init("/etc/zlog.conf");
	if (l_init) {
		printf("logging init failed");
		return -1;
	}
	c = zlog_get_category("hngui");
	if (!c) {
		printf("Logging init (category) fail\n");
		return -1;
	}




	zlog_info(c, "Program starting... ");
	DIR           *d;
	struct dirent *dir;
	d = opendir("/var/tmp");
	if (d) {
		while ((dir = readdir(d)) != NULL) {
			zlog_info(c, "%s", dir->d_name);
		}

		closedir(d);
	}

	zlog_info(c, "Created Tree From Sample Text..");
	SetExpansionState(tree, TRUE);
	LogPrintTree(c, tree, PRINT_ONLY_EXPANDED_NODES);
	zlog_info(c, "Tree Size: %d\n", TotalSize(tree));
	initscr();
	mousemask(ALL_MOUSE_EVENTS, NULL);
	cbreak();
	noecho();
	nonl();
	curs_set(0);
	keypad(stdscr, TRUE);
	start_color();
	curs_set(0);
	init_pair(1, COLOR_YELLOW, COLOR_BLACK);
	init_pair(2, COLOR_RED, COLOR_BLACK);
	init_pair(3, COLOR_YELLOW, COLOR_BLUE);
	init_pair(4, COLOR_RED, COLOR_BLUE);

	int startx, starty, width, height;
	height = LINES - 2;
	width  = COLS - 2;
	starty = (LINES - height) / 4;  /* Calculating for a center placement */
	startx = (COLS - width) / 2;    /* of */
	refresh();
	win = create_newwin(height, width, starty, startx);
	if (win == NULL) {
		zlog_info(c, "Window Was null...\n");
		endwin();
		printf("Window was null??\n");
		return -1;
	}

	zlog_info(c, "Rendering Tree into window %p \n", win);
	RenderTreeIntoWindow(tree);
	refresh();
	wrefresh(win);

	int ch;
	while ((ch = getch()) != KEY_F(4)) {
		zlog_info(c, "Trapped Keypress  %d", ch );
		MEVENT event;
		switch (ch) {
		case KEY_RESIZE:
			zlog_info(c, "Resize()");
			RenderTreeIntoWindow(tree);
			refresh();
			wrefresh(win);
			break;
		case KEY_F(3):
			zlog_info(c, "F3=> Refresh");
			RefreshData();
			break;
		case KEY_LEFT:
			zlog_info(c, "Left key");
			toggleExpand(win, false);
			break;
		case KEY_RIGHT:
			zlog_info(c, "Right key");
			toggleExpand(win, true);
			break;
		case KEY_UP:
			zlog_info(c, "Up Key");
			moveUp(win);
			break;
		case KEY_DOWN:
			zlog_info(c, "Down Key");
			moveDown(win);
			break;

		}
		if (getmouse(&event) == OK) {
			zlog_info(c, "Mouse => %d, %d", event.x, event.y);
		}
		//LogPrintTree(c, tree, PRINT_ALL_TREE);

	}

	endwin();
	return 0;
}
Пример #11
0
void RenderTreeIntoWindow(comment_item_tree* tree)
{
	zlog_info(c, "Rendering window %dX%d", win->_maxy, win->_maxx);
	wbkgd(win, COLOR_PAIR(1));
	refresh();
	wmove(win, 2, 1);
	//wattron(win, A_BOLD | A_BLINK);
	wattron(win,  A_BOLD);
	wattron(win, COLOR_PAIR(2));
	zlog_info(c, "Starting to parse the tree");
	if(mode == MODE_LOADING){
		wprintw(win, "Loading in articles...one moment please  ");
	}else{
		wprintw(win, "News Comments for article ( %d in total) ", TotalSize(tree) );
	}
	wattroff(win, COLOR_PAIR(2));

	wattroff(win, A_BOLD);



	int row = 4;
	while (row < 30) {
		wmove(win, row, 1);  wprintw(win, "%*s", 120, "");
		row++;
	}
	if(msg1 != NULL && mode == MODE_LOADING){
		wmove(win, LINES - 4, 1);
		wprintw(win, "%s", msg1);
	}

	row = 4;
	int txcol = 7;
	if(_flat != NULL){
		free(_flat);
	}
	ResetFlatTree(tree);
	_flat = ToFlatTree(tree, &_total_tree_size);

	zlog_info(c, "Rendering total of  %d rows", _total_tree_size);

	while (true) {
		if ( (row - 4) == _total_tree_size || (row - 4) >= WINDOW_SIZE) {
			break;
		}
		int chosen_element = MAX(row + start_row - 4, 0);
		if(chosen_element >= _total_tree_size){
			zlog_info(c, "Hit Max, stopping iteration..");
			break;
		}
		zlog_info(c, ">>Rendering  row  %d, ray elem %d - real elem/index %d ", row, row + start_row - 4, chosen_element);
		RenderRow(win, _flat[chosen_element], &row, txcol, row - 4, 0, -1);
	}


	mvwhline(win, 4 + WINDOW_SIZE + 1,  1, ACS_HLINE, COLS  );

	int _text_start = (int)(LINES/2);
	if(_selected > -1){
		row = _text_start;
		while (row < LINES - 2) {
			wmove(win, row, 2);  wprintw(win, "%*s", 120, "");
			row++;
		}

		wmove(win, _text_start, 1);
		s_segments* segs = splitIntoSegments(_flat[_selected]->text, 90);
		int _p = 0;
		for (_p = 0; _p < segs->count; _p++) {
			wmove(win, _text_start + _p, 4);
			wprintw(win, "%s", segs->segments[_p]->string);
		}
		freeSegs(segs);
		if(msg1 != NULL){
			free(msg1);
		}
		msg1 = malloc(50);
		memset(msg1, 0, 50);
		sprintf(msg1, "ID: %d", _flat[_selected]->id);
		wmove(win, LINES - 4, 1);
		wprintw(win, "%120s", "");
		wmove(win, LINES - 4, 1);
		wprintw(win, "%s", msg1);
	}

	/*

	int BOX_W = 11;
	int BOX_H = 3;
	int _stx = 1;
	int _sty = 21;


	while (_sty < 35) {
		while (_stx < 120) {
			//wattron(win, A_BOLD | A_BLINK);
			DrawBox(win, BOX_H, BOX_W,  _sty, _stx, _stx == 1, _stx > 68);
			//wattroff(win, A_BOLD | A_BLINK);
			_stx += BOX_W;
		}
		_sty += BOX_H;
		_stx = 1;
	}

	*/

}
Пример #12
0
void RenderRow(WINDOW* win, ND* node, int* row, int basecolumn, int rowindex,  int _y, int mode)
{

	int column = basecolumn + (2 * node->_ft_depth);

	if (node == NULL) {
		zlog_info(c, "Null Render (mode=%d, rowindex=%d)", mode, rowindex);
		return;
	}
	zlog_info(c, "[%d/%d]    Real_rende_call() %s at row %d/%d = col %d/%d",
		  rowindex, mode,  node->text,
		  *row, isExpanded(node), column, basecolumn);
	if (node->children != NULL && isExpanded(node)) {
		mvwhline(win, *row, column -  1, ACS_HLINE, 2 );
		mvwhline(win, *row, column - 1, ACS_URCORNER, 1 );

		//if (rowindex > 0) {
		//	mvwvline(win, (*row) - 1, column -  2, ACS_VLINE, 2 );
		//}
	}else{
		//if (node->children != NULL) {
		//	mvwhline(win, *row, column -  2, ACS_PLUS, 1 );
		//}else{
		//	//mvwhline(win, *row, column -  2, ACS_VLINE, 1 );
		//}
	}
	int _fkd = column + 1;
	/*
	 * Draw out all the lines back for the parent nodes
	 */
	if (rowindex == _selected) {
		wattron(win, COLOR_PAIR(4));
	}
	if (node->_ft_depth > 0) {
		while (true ) {
			_fkd--;
			_fkd--;
			if (_fkd <= basecolumn) {
				break;
			}
			mvwvline(win, (*row),  _fkd, ACS_VLINE, 1 );
			zlog_info(c, "         Working back, col now %d, %d, %d", node->_ft_depth,  _fkd, column);
		}
	}
	if (rowindex == _selected) {
		wattron(win, COLOR_PAIR(3));
	}

	/* Actually render the node details.
	 */

	// Clear the row...
	wmove(win, *row, column + 3);  wprintw(win, "                                                       ");
	// Draw the spine line to the text
	int SPLINE_COL = 4;
	mvwhline(win, *row, column - 1, ACS_HLINE, SPLINE_COL );
	if (node->next != NULL) {
		wmove(win, *row, column - 1 );  waddch(win, ACS_LTEE);
	}else{
		wmove(win, *row, column - 1 );  waddch(win, ACS_LLCORNER);
	}

	wmove(win, *row, basecolumn - 3);  wprintw(win, "%d", *row);
	if (node->children != NULL && !isExpanded(node)) {
		wmove(win, *row, column + SPLINE_COL);  wprintw(win, "(%d) %s",  TotalSize(node->children), substring(node->text, 60));
	}else{
		wmove(win, *row, column + SPLINE_COL);  wprintw(win, substring(node->text, 60));
	}
	wattron(win, COLOR_PAIR(3));
	wmove(win, *row, 85); wprintw(win, "cc=%4d  d=%4d ",
				      ChildCount(node, false),
				      node->_ft_depth
				      );
	wattroff(win, COLOR_PAIR(3));
	// deactivate colors
	if (rowindex == _selected) {
		wattroff(win, COLOR_PAIR(2));
	}

	zlog_info(c, "Done Rendering Leaving..");
	(*row)++;

	wattron(win, COLOR_PAIR(3));
	wmove(win, 2, 55); wprintw(win, "cc=%4d  d=%4d TTS=%4d SEL=%3d SR=%d R=%3d, NB=%3d B=%d, WS=%d",
				      ChildCount(node, false),
				      node->_ft_depth,
				      _total_tree_size,
				      _selected,
				      start_row,
				      *row,
				      _selected - start_row,
				      _selected - start_row > WINDOW_SIZE,
				      WINDOW_SIZE

				      );
	wattroff(win, COLOR_PAIR(3));
}
Пример #13
0
bool VStreamFileReader::AtEnd()
{
	return Tell() >= TotalSize();
}
Пример #14
0
void LogPrintTreeItem(zlog_category_t* c, const ND* node, int offset, int *counter,  node_method method)
{
	int newoffset = offset + 1;
	int i = 0;
	ND* tmp = (ND*)node;

	if (tmp == NULL)
		return;
	bool firstChild = true;
	while (tmp != NULL) {
		(*counter)++;
		char* prefix = calloc(20, sizeof(char));
		i++;
		if (offset == 0) {
			strcpy(prefix, "|");
			int y = 0;
			while (y < 18) {
				prefix = strcat(prefix, " ");
				y++;
			}
		}else{
			int y = 0;
			while (y < offset) {
				prefix = strcat(prefix, "  ");
				y++;
			}
			if (firstChild) {
				prefix = strcat(prefix, "\\");
			}else{
				prefix = strcat(prefix, "|_");
			}
			y = strlen(prefix);

			while (y < 18) {
				prefix = strcat(prefix, " ");
				y++;
			}
		}
		if (method == PRINT_ALL_TREE || isExpanded(tmp)) {
			zlog_info(c, "%d[dp/%d - %5d] %s %d (i=%d) F/%d) -> %25s %p, %p, %p"
				  , isExpanded(tmp)
				  , offset
				  , *counter
				  , prefix
				  , TotalSize(tmp)
				  , tmp->id
				  , tmp->flags
				  , tmp->text
				  , tmp
				  , tmp->next
				  , tmp->previous
				  );
		}
		if (ChildCount(tmp, false) > 0) {
			LogPrintTreeItem(c, tmp->children, newoffset, counter, method);
		}
		tmp = tmp->next;
		firstChild = false;
		free(prefix);
	}


}