Ejemplo n.º 1
0
struct Globals *globalsCtor()
{
#ifdef REENTRANT
    struct Globals *pG = (struct Globals *)malloc(sizeof(struct Globals));

    if (!pG)
        return (struct Globals *)NULL;
#endif /* REENTRANT */

    /* for REENTRANT version, G is defined as (*pG) */

    memzero(&G, sizeof(struct Globals));

#ifdef CMS_MVS
    G.aflag=1;
    G.C_flag=1;
#endif

    G.lflag=(-1);
    G.wildzipfn = "";
    G.pfnames = fnames;
    G.pxnames = &fnames[1];
    G.pInfo = G.info;
    G.sol = TRUE;          /* at start of line */

#ifndef FUNZIP
    G.message = UzpMessagePrnt;
    G.input = UzpInput;           /* not used by anyone at the moment... */
#if defined(WINDLL) || defined(MACOS)
    G.mpause = NULL;              /* has scrollbars:  no need for pausing */
#else
    G.mpause = UzpMorePause;
#endif
    G.decr_passwd = UzpPassword;
#endif /* !FUNZIP */

#if (!defined(DOS_H68_OS2_W32) && !defined(AMIGA) && !defined(RISCOS))
#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
    G.echofd = -1;
#endif /* !(MACOS || ATARI || VMS) */
#endif /* !(DOS_H68_OS2_W32 || AMIGA || RISCOS) */

#ifdef SYSTEM_SPECIFIC_CTOR
    SYSTEM_SPECIFIC_CTOR(__G);
#endif

#ifdef REENTRANT
#ifdef USETHREADID
    registerGlobalPointer(__G);
#else
    GG = &G;
#endif /* ?USETHREADID */
#endif /* REENTRANT */

    return &G;
}
/* Compute weighted quantization errors for an LPC_order element input vector, over one codebook stage */
void SKP_Silk_NLSF_VQ_sum_error_FIX(int32_t * err_Q20,	/* O    Weighted quantization errors  [N*K]         */
				    const int *in_Q15,	/* I    Input vectors to be quantized [N*LPC_order] */
				    const int *w_Q6,	/* I    Weighting vectors             [N*LPC_order] */
				    const int16_t * pCB_Q15,	/* I    Codebook vectors              [K*LPC_order] */
				    const int N,	/* I    Number of input vectors                     */
				    const int K,	/* I    Number of codebook vectors                  */
				    const int LPC_order	/* I    Number of LPCs                              */
    )
{
	int i, n, m;
	int32_t diff_Q15, sum_error, Wtmp_Q6;
	int32_t Wcpy_Q6[MAX_LPC_ORDER / 2];
	const int16_t *cb_vec_Q15;

	assert(LPC_order <= 16);
	assert((LPC_order & 1) == 0);

	memzero(Wcpy_Q6, (MAX_LPC_ORDER / 2) * sizeof(int32_t));

	/* Copy to local stack and pack two weights per int32 */
	for (m = 0; m < SKP_RSHIFT(LPC_order, 1); m++) {
		Wcpy_Q6[m] =
		    w_Q6[2 * m] | SKP_LSHIFT((int32_t) w_Q6[2 * m + 1], 16);
	}

	/* Loop over input vectors */
	for (n = 0; n < N; n++) {
		/* Loop over codebook */
		cb_vec_Q15 = pCB_Q15;
		for (i = 0; i < K; i++) {
			sum_error = 0;
			for (m = 0; m < LPC_order; m += 2) {
				/* Get two weights packed in an int32 */
				Wtmp_Q6 = Wcpy_Q6[SKP_RSHIFT(m, 1)];

				/* Compute weighted squared quantization error for index m */
				diff_Q15 = in_Q15[m] - *cb_vec_Q15++;	// range: [ -32767 : 32767 ]
				sum_error =
				    SKP_SMLAWB(sum_error,
					       SKP_SMULBB(diff_Q15, diff_Q15),
					       Wtmp_Q6);

				/* Compute weighted squared quantization error for index m + 1 */
				diff_Q15 = in_Q15[m + 1] - *cb_vec_Q15++;	// range: [ -32767 : 32767 ]
				sum_error =
				    SKP_SMLAWT(sum_error,
					       SKP_SMULBB(diff_Q15, diff_Q15),
					       Wtmp_Q6);
			}
			assert(sum_error >= 0);
			err_Q20[i] = sum_error;
		}
		err_Q20 += K;
		in_Q15 += LPC_order;
	}
}
Ejemplo n.º 3
0
// Clears Block Data in specified range
__fi void mVUclear(mV, u32 addr, u32 size) {
	if(!mVU.prog.cleared) {
		mVU.prog.cleared = 1;		// Next execution searches/creates a new microprogram
		memzero(mVU.prog.lpState); // Clear pipeline state
		for(u32 i = 0; i < (mVU.progSize / 2); i++) {
			mVU.prog.quick[i].block = NULL; // Clear current quick-reference block
			mVU.prog.quick[i].prog  = NULL; // Clear current quick-reference prog
		}
	}
}
Ejemplo n.º 4
0
void send_u2fhid_msg(const uint8_t cmd, const uint8_t *data, const uint32_t len)
{
	if (len > U2F_MAXIMUM_PAYLOAD_LENGTH) {
		debugLog(0, "", "send_u2fhid_msg failed");
		return;
	}

	U2FHID_FRAME f;
	uint8_t *p = (uint8_t *)data;
	uint32_t l = len;
	uint32_t psz;
	uint8_t seq = 0;

	// debugLog(0, "", "send_u2fhid_msg");

	memzero(&f, sizeof(f));
	f.cid = cid;
	f.init.cmd = cmd;
	f.init.bcnth = len >> 8;
	f.init.bcntl = len & 0xff;

	// Init packet
	psz = MIN(sizeof(f.init.data), l);
	memcpy(f.init.data, p, psz);
	queue_u2f_pkt(&f);
	l -= psz;
	p += psz;

	// Cont packet(s)
	for (; l > 0; l -= psz, p += psz) {
		// debugLog(0, "", "send_u2fhid_msg con");
		memzero(&f.cont.data, sizeof(f.cont.data));
		f.cont.seq = seq++;
		psz = MIN(sizeof(f.cont.data), l);
		memcpy(f.cont.data, p, psz);
		queue_u2f_pkt(&f);
	}

	if (data + len != p) {
		debugLog(0, "", "send_u2fhid_msg is bad");
		debugInt(data + len - p);
	}
}
Ejemplo n.º 5
0
void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key)
{
#if BYTE_ORDER == LITTLE_ENDIAN
	for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH/sizeof(uint32_t); k++) {
		REVERSE32(pctx->f[k], pctx->f[k]);
	}
#endif
	memcpy(key, pctx->f, SHA256_DIGEST_LENGTH);
	memzero(pctx, sizeof(PBKDF2_HMAC_SHA256_CTX));
}
Ejemplo n.º 6
0
static void scsi_cmd_init(struct scsi_cmd *cmd) {
        memzero(cmd, sizeof(struct scsi_cmd));
        cmd->cgc.quiet = 1;
        cmd->cgc.sense = &cmd->_sense.s;
        cmd->sg_io.interface_id = 'S';
        cmd->sg_io.mx_sb_len = sizeof(cmd->_sense);
        cmd->sg_io.cmdp = cmd->cgc.cmd;
        cmd->sg_io.sbp = cmd->_sense.u;
        cmd->sg_io.flags = SG_FLAG_LUN_INHIBIT | SG_FLAG_DIRECT_IO;
}
Ejemplo n.º 7
0
int32_t	console_clear(void)
{
    /* clear the video buffer memory */
    memzero((void *)g_console_video, CONSOLE_VIDEO_BUFFER_S);

    /* reset column and line to 0 */
    g_console_column = g_console_line = 0;

    return ERR_NONE;
}
Ejemplo n.º 8
0
uint8_t* TigerHash::finalize()
{
	size_t tmppos = (size_t)(pos & BLOCK_SIZE - 1);
#ifdef TIGER_BIG_ENDIAN
	uint8_t buf[BLOCK_SIZE];
	int j;
#endif
	// Tmp buffer always has at least one pos, otherwise it would have
	// been processed in update()
	
	tmp[tmppos++] = 0x01;
	
	if (tmppos > (BLOCK_SIZE - sizeof(uint64_t)))
	{
		memzero(tmp + tmppos, BLOCK_SIZE - tmppos);
#ifdef TIGER_BIG_ENDIAN
		for (j = 0; j < BLOCK_SIZE; j++)
			buf[j ^ 7] = ((uint8_t*)tmp)[j];
		tiger_compress_macro(((uint64_t*)buf), res);
#else
		tiger_compress_macro(((uint64_t*)tmp), res);
#endif
		memzero(tmp, BLOCK_SIZE);
	}
	else
	{
		memzero(tmp + tmppos, BLOCK_SIZE - tmppos - sizeof(uint64_t));
#ifdef TIGER_BIG_ENDIAN
		for (j = 0; j < BLOCK_SIZE; j++)
			buf[j ^ 7] = ((uint8_t*)tmp)[j];
		memcpy(tmp, buf, BLOCK_SIZE);
#endif
	}
	
	((uint64_t*)(&(tmp[56])))[0] = pos << 3;
	tiger_compress_macro(((uint64_t*)tmp), res);
#ifdef TIGER_BIG_ENDIAN
	for (j = 0; j < BYTES; j++)
		buf[j ^ 7] = ((uint8_t*)res)[j];
	memcpy(res, buf, BYTES);
#endif
	return getResult();
}
Ejemplo n.º 9
0
static void mpi_export(void *buf, size_t buflen, const gcry_mpi_t x) {
        unsigned len;
        size_t nwritten;

        assert(gcry_mpi_cmp_ui(x, 0) >= 0);
        len = (gcry_mpi_get_nbits(x) + 7) / 8;
        assert(len <= buflen);
        memzero(buf, buflen);
        gcry_mpi_print(GCRYMPI_FMT_USG, buf + (buflen - len), len, &nwritten, x);
        assert(nwritten == len);
}
Ejemplo n.º 10
0
void resetNewVif(int idx)
{
    // Safety Reset : Reassign all VIF structure info, just in case the VU1 pointers have
    // changed for some reason.

    nVif[idx].idx   = idx;
    nVif[idx].bSize = 0;
    memzero(nVif[idx].buffer);

    if (newVifDynaRec) dVifReset(idx);
}
Ejemplo n.º 11
0
void arp_packet_init(struct ether_arp *arp) {
        assert(arp);

        memzero(arp, sizeof(struct ether_arp));
        /* Header */
        arp->ea_hdr.ar_hrd = htons(ARPHRD_ETHER); /* HTYPE */
        arp->ea_hdr.ar_pro = htons(ETHERTYPE_IP); /* PTYPE */
        arp->ea_hdr.ar_hln = ETH_ALEN; /* HLEN */
        arp->ea_hdr.ar_pln = sizeof arp->arp_spa; /* PLEN */
        arp->ea_hdr.ar_op = htons(ARPOP_REQUEST); /* REQUEST */
}
Ejemplo n.º 12
0
int menu(const GUID& id, const wstring& title, const MenuItems& items, const wchar_t* help) {
  vector<FarMenuItem> menu_items;
  menu_items.reserve(items.size());
  FarMenuItem mi;
  for (unsigned i = 0; i < items.size(); i++) {
    memzero(mi);
    mi.Text = items[i].c_str();
    menu_items.push_back(mi);
  }
  return g_far.Menu(&c_plugin_guid, &id, -1, -1, 0, FMENU_WRAPMODE, title.c_str(), NULL, help, NULL, NULL, menu_items.data(), static_cast<int>(menu_items.size()));
}
Ejemplo n.º 13
0
void send_u2fhid_error(uint32_t fcid, uint8_t err)
{
	U2FHID_FRAME f;

	memzero(&f, sizeof(f));
	f.cid = fcid;
	f.init.cmd = U2FHID_ERROR;
	f.init.bcntl = 1;
	f.init.data[0] = err;
	queue_u2f_pkt(&f);
}
Ejemplo n.º 14
0
bool ChatCtrl::HitURL() {
	long lSelBegin = 0, lSelEnd = 0;
	GetSel(lSelBegin, lSelEnd);

	CHARFORMAT2 cfSel;
	memzero(&cfSel, sizeof(CHARFORMAT2)); //PPA
	cfSel.cbSize = sizeof(cfSel);
	GetSelectionCharFormat(cfSel);

	return (cfSel.dwEffects & CFE_LINK) == CFE_LINK;
}
Ejemplo n.º 15
0
void FolderTree::checkRemovedDirs(const tstring& aParentPath, HTREEITEM hParent) {
	string parentPath = Text::fromT(aParentPath);
	for(auto& sd: sp->getCurItems()) {
		if (sd->found || !sd->isCurItem())
			continue;

		auto dir = Util::getParentDir(sd->dir->path);
		if (dir == parentPath) {
			//this should have been inserted
			FolderTreeItemInfo* pItem = new FolderTreeItemInfo;
			pItem->m_sFQPath = Text::toT(sd->dir->path);
			pItem->m_sRelativePath = Text::toT(Util::getLastDir(sd->dir->path));
			pItem->m_removed = true;

			tstring sLabel;

			//Correct the label if need be
			if(IsDrive(pItem->m_sFQPath) && m_bShowDriveLabels)
				sLabel = GetDriveLabel(pItem->m_sFQPath);
			else
				sLabel = GetCorrectedLabel(pItem);

			sLabel = _T("REMOVED: ") + sLabel;

			//Add the actual item
			TV_INSERTSTRUCT tvis;
			memzero(&tvis, sizeof(TV_INSERTSTRUCT));
			tvis.hParent = hParent;
			tvis.hInsertAfter = TVI_FIRST;
			tvis.item.mask = TVIF_CHILDREN | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
			//tvis.item.iImage = 7;
			//tvis.item.iSelectedImage = 7;
			tvis.item.iImage = 1;
			tvis.item.iSelectedImage = 1;

			tvis.item.lParam = (LPARAM) pItem;
			tvis.item.pszText = (LPWSTR)sLabel.c_str();
			tvis.item.cChildren = false;
	
			tvis.item.mask |= TVIF_STATE;
			tvis.item.stateMask |= TVIS_OVERLAYMASK;
			tvis.item.state = TVIS_BOLD | INDEXTOOVERLAYMASK(1); //1 is the index for the shared overlay image
			tvis.item.state |= TVIS_BOLD;

			//tvis.item.state = TVIS_BOLD;
			//tvis.item.stateMask = TVIS_BOLD;

			HTREEITEM hItem = InsertItem(&tvis);
			//SetItemImage(hItem, MAKEINTRESOURCE(IDI_ERROR), MAKEINTRESOURCE(IDI_ERROR));
			SetChecked(hItem, true);
			SetItemState(hItem, TVIS_BOLD, TVIS_BOLD);
		}
	}
}
Ejemplo n.º 16
0
int32_t	console_refresh(FILE	*stream,
                        uint32_t	lastline)
{
    char		line[CONSOLE_COLUMN_N];

    /* argument checking */
    if (stream == NULL)
        return ERR_NULLPTR;

    if (fseek(stream, lastline, SEEK_SET) != ERR_NONE)
        return ERR_UNKNOWN;
    memzero(line, CONSOLE_COLUMN_N);
    while (NULL != fgets(line, CONSOLE_COLUMN_N, stream))
    {
        console_printf(line, BG_BLACK | FG_WHITE);
        memzero(line, CONSOLE_COLUMN_N);
    }

    return ftell(stream);
}
Ejemplo n.º 17
0
int FolderTree::GetSelIconIndex(HTREEITEM hItem)
{
	TV_ITEM tvi;
	memzero(&tvi, sizeof(TV_ITEM));
	tvi.mask = TVIF_HANDLE | TVIF_SELECTEDIMAGE;
	tvi.hItem = hItem;
	if (GetItem(&tvi))
		return tvi.iSelectedImage;
	else
		return -1;
}
Ejemplo n.º 18
0
/*
 * verify_exchange_address - verify address specified in exchange contract belongs to device.
 *
 * INPUT
 *     coin - the CoinType
 *     address_n_count - depth of node
 *     address_n - pointer to node path
 *     address_str - string representation of address
 *     address_str_len - address length
 *     root - root hd node
 *
 * OUTPUT
 *     true/false - success/failure
 */
static bool verify_exchange_address(const CoinType *coin, size_t address_n_count,
                                    uint32_t *address_n, char *address_str, size_t address_str_len,
                                    const HDNode *root, bool is_token)
{
    static CONFIDENTIAL HDNode node;
    memcpy(&node, root, sizeof(HDNode));
    if (hdnode_private_ckd_cached(&node, address_n, address_n_count, NULL) == 0) {
        memzero(&node, sizeof(node));
        return false;
    }

    if (isEthereumLike(coin->coin_name) || is_token) {
        char tx_out_address[sizeof(((ExchangeAddress *)NULL)->address)];
        EthereumAddress_address_t ethereum_addr;

        ethereum_addr.size = 20;
        if (hdnode_get_ethereum_pubkeyhash(&node, ethereum_addr.bytes) == 0) {
            memzero(&node, sizeof(node));
            return false;
        }

        data2hex((char *)ethereum_addr.bytes, 20, tx_out_address);
        return addresses_same(tx_out_address, sizeof(tx_out_address),
                              address_str, address_str_len, true);
    }

    const curve_info *curve = get_curve_by_name(coin->curve_name);
    if (!curve) {
        memzero(&node, sizeof(node));
        return false;
    }

    char tx_out_address[36];
    hdnode_fill_public_key(&node);
    ecdsa_get_address(node.public_key, coin->address_type, curve->hasher_pubkey,
                      curve->hasher_base58, tx_out_address,
                      sizeof(tx_out_address));

    memzero(&node, sizeof(node));
    return strncmp(tx_out_address, address_str, sizeof(tx_out_address)) == 0;
}
Ejemplo n.º 19
0
static void test_alloca(void) {
        static const uint8_t zero[997] = { };
        char *t;

        t = alloca_align(17, 512);
        assert_se(!((uintptr_t)t & 0xff));
        memzero(t, 17);

        t = alloca0_align(997, 1024);
        assert_se(!((uintptr_t)t & 0x1ff));
        assert_se(!memcmp(t, zero, 997));
}
Ejemplo n.º 20
0
int32_t	console_scrolldown(void)
{
    memcpy((void *)g_console_video,
           (void *)(&g_console_video[CONSOLE_COLUMN_N * 2]),
           CONSOLE_COLUMN_N * (CONSOLE_LINE_N - 2) * 2);

    memzero((void *)(&g_console_video[CONSOLE_COLUMN_N
                                      * (CONSOLE_LINE_N - 2) * 2]),
            CONSOLE_COLUMN_N * 2);

    return 0;
}
Ejemplo n.º 21
0
CClosableTabCtrl::CClosableTabCtrl()
{
	m_bCloseable = true;
//==> Optimizer [shadow2004]
#ifdef OPTIM
	memzero(&m_iiCloseButton, sizeof m_iiCloseButton);
#else
	memset(&m_iiCloseButton, 0, sizeof m_iiCloseButton);
#endif
//<== Optimizer [shadow2004]
	m_ptCtxMenu.SetPoint(-1, -1);
}
Ejemplo n.º 22
0
void
prf_init(void) {
	/* Just in case */
	fassert(lengthof(l_defaults) == lengthof(l_keys));
	fassert(lengthof(l_defaults) == lengthof(l_values));

	/* Init the mutex */
	mutex_init(l_mutex);

	/* No values set yet */
	memzero(l_values, sizeof l_values);
}
Ejemplo n.º 23
0
/*
 * new_grent - initialize the values in a group file entry
 *
 *	new_grent() takes all of the values that have been entered and fills
 *	in a (struct group) with them.
 */
static void new_grent (struct group *grent)
{
	memzero (grent, sizeof *grent);
	grent->gr_name = group_name;
	if (pflg) {
		grent->gr_passwd = group_passwd;
	} else {
		grent->gr_passwd = SHADOW_PASSWD_STRING;	/* XXX warning: const */
	}
	grent->gr_gid = group_id;
	grent->gr_mem = &empty_list;
}
Ejemplo n.º 24
0
/*
 * new_sgent - initialize the values in a shadow group file entry
 *
 *	new_sgent() takes all of the values that have been entered and fills
 *	in a (struct sgrp) with them.
 */
static void new_sgent (struct sgrp *sgent)
{
	memzero (sgent, sizeof *sgent);
	sgent->sg_name = group_name;
	if (pflg) {
		sgent->sg_passwd = group_passwd;
	} else {
		sgent->sg_passwd = "!";	/* XXX warning: const */
	}
	sgent->sg_adm = &empty_list;
	sgent->sg_mem = &empty_list;
}
Ejemplo n.º 25
0
Archivo: glom.c Proyecto: muennich/rc3
extern List *concat(List *s1, List *s2) {
	int n1, n2;
	List *r, *top;
	if (s1 == NULL)
		return s2;
	if (s2 == NULL)
		return s1;
	if ((n1 = listnel(s1)) != (n2 = listnel(s2)) && n1 != 1 && n2 != 1)
		rc_error("bad concatenation");
	for (r = top = nnew(List); 1; r = r->n = nnew(List)) {
		size_t x = strlen(s1->w);
		size_t y = strlen(s2->w);
		size_t z = x + y + 1;
		r->w = nalloc(z);
		strcpy(r->w, s1->w);
		strcat(r->w, s2->w);
		if (s1->m == NULL && s2->m == NULL) {
			r->m = NULL;
		} else {
			r->m = nalloc(z);
			if (s1->m == NULL)
				memzero(r->m, x);
			else
				memcpy(r->m, s1->m, x);
			if (s2->m == NULL)
				memzero(&r->m[x], y);
			else
				memcpy(&r->m[x], s2->m, y);
			r->m[z] = 0;
		}
		if (n1 > 1)
			s1 = s1->n;
		if (n2 > 1)
			s2 = s2->n;
		if (s1 == NULL || s2 == NULL || (n1 == 1 && n2 == 1))
			break;
	}
	r->n = NULL;
	return top;
}
Ejemplo n.º 26
0
void psxRcntInit() {
	int i;

	memzero( psxCounters );

	for (i=0; i<3; i++) {
		psxCounters[i].rate = 1;
		psxCounters[i].mode|= 0x0400;
		psxCounters[i].target = IOPCNT_FUTURE_TARGET;
	}
	for (i=3; i<6; i++) {
		psxCounters[i].rate = 1;
		psxCounters[i].mode|= 0x0400;
		psxCounters[i].target = IOPCNT_FUTURE_TARGET;
	}

	psxCounters[0].interrupt = 0x10;
	psxCounters[1].interrupt = 0x20;
	psxCounters[2].interrupt = 0x40;

	psxCounters[3].interrupt = 0x04000;
	psxCounters[4].interrupt = 0x08000;
	psxCounters[5].interrupt = 0x10000;

	if (SPU2async != NULL)
	{
		psxCounters[6].rate = 768*12;
		psxCounters[6].CycleT = psxCounters[6].rate;
		psxCounters[6].mode = 0x8;
	}

	if (USBasync != NULL)
	{
		psxCounters[7].rate = PSXCLK/1000;
		psxCounters[7].CycleT = psxCounters[7].rate;
		psxCounters[7].mode = 0x8;
	}

#ifdef ENABLE_NEW_IOPDMA
		psxCounters[8].rate = 2000;
		psxCounters[8].CycleT = psxCounters[7].rate;
		psxCounters[8].mode = 0x8;
#endif

	for (i=0; i<8; i++)
		psxCounters[i].sCycleT = psxRegs.cycle;

	// Tell the IOP to branch ASAP, so that timers can get
	// configured properly.
	psxNextCounter = 1;
	psxNextsCounter = psxRegs.cycle;
}
Ejemplo n.º 27
0
int EncoderMFC::PopFrame(char *stream_buf,int b_size)
{
    struct v4l2_buffer buf;
    struct v4l2_plane planes[NPPBuf[DIR_OUT]];
    int ret;

    memzero(buf);

    buf.type = io_dir_to_type(DIR_OUT);
    buf.memory = V4L2_MEMORY_MMAP;
    buf.m.planes = planes;
    buf.length = NPPBuf[DIR_OUT];

    buf.index=BufInx[DIR_OUT];


    ret = ioctl(fd, VIDIOC_DQBUF, &buf);
    if (ret != 0) {
        printf("\nEncoderMFC: Pop, Dequeue buffer %d error, %s!\n",buf.index,strerror(errno));
        return -1;
    }



    BufInx[DIR_OUT]=buf.index;

    if(BufInx[DIR_OUT]>=NBufs[DIR_OUT]){
        printf("\nEncoderMFC: Pop, Index error!\n");
        return -1;
    }


    if(buf.m.planes[0].bytesused>b_size){
        printf("\nEncoderMFC: Pop, Buffer %d overrun %d error!",buf.index,buf.m.planes[0].bytesused);
    }else{
        b_size=buf.m.planes[0].bytesused;
    }

    memcpy(stream_buf,BufAddr[DIR_OUT][buf.index][0],b_size);

    //printf("\nEncoderMFC: Enc frame %d,%d\n",buf.m.planes[0].bytesused,BufInx[DIR_OUT]);

    ret = ioctl(fd, VIDIOC_QBUF, &buf);
    if (ret != 0) {
        printf("\nEncoderMFC: Pop, Queue buffer %d error! %s\n",BufInx[DIR_OUT],strerror(errno));
        return -1;
    }

    //BufInx[DIR_OUT]++;

    return b_size;
}
Ejemplo n.º 28
0
/* ===========================================================================
 * Initialize the "longest match" routines for a new file
 */
void lm_init (int pack_level, /* 1: best speed, 9: best compression */
              ush *flags)     /* general purpose bit flag */
{
    register unsigned j;

    if (pack_level < 1 || pack_level > 9) gzip_error ("bad pack level");

    /* Initialize the hash table. */
    memzero((char*)head, HASH_SIZE*sizeof(*head));
    /* prev will be initialized on the fly */

    /* rsync params */
    rsync_chunk_end = 0xFFFFFFFFUL;
    rsync_sum = 0;

    /* Set the default configuration parameters:
     */
    max_lazy_match   = configuration_table[pack_level].max_lazy;
    good_match       = configuration_table[pack_level].good_length;
#ifndef FULL_SEARCH
    nice_match       = configuration_table[pack_level].nice_length;
#endif
    max_chain_length = configuration_table[pack_level].max_chain;
    if (pack_level == 1) {
       *flags |= FAST;
    } else if (pack_level == 9) {
       *flags |= SLOW;
    }
    /* ??? reduce max_chain_length for binary files */

    strstart = 0;
    block_start = 0L;

    lookahead = read_buf((char*)window,
			 sizeof(int) <= 2 ? (unsigned)WSIZE : 2*WSIZE);

    if (lookahead == 0 || lookahead == (unsigned)EOF) {
       eofile = 1, lookahead = 0;
       return;
    }
    eofile = 0;
    /* Make sure that we always have enough lookahead. This is important
     * if input comes from a device such as a tty.
     */
    while (lookahead < MIN_LOOKAHEAD && !eofile) fill_window();

    ins_h = 0;
    for (j=0; j<MIN_MATCH-1; j++) UPDATE_HASH(ins_h, window[j]);
    /* If lookahead < MIN_MATCH, ins_h is garbage, but this is
     * not important since only literal bytes will be emitted.
     */
}
Ejemplo n.º 29
0
int
spritz_stream(unsigned char *out, size_t outlen,
              const unsigned char *key, size_t keylen)
{
    State state;

    initialize_state(&state);
    absorb(&state, key, keylen);
    squeeze(&state, out, outlen);
    memzero(&state, sizeof state);

    return 0;
}
Ejemplo n.º 30
0
SpyFrame::SpyFrame() : CFlyTimerAdapter(m_hWnd), CFlyTaskAdapter(m_hWnd), m_total(0), m_current(0),
	m_ignoreTTH(BOOLSETTING(SPY_FRAME_IGNORE_TTH_SEARCHES)),
	m_showNick(BOOLSETTING(SHOW_SEEKERS_IN_SPY_FRAME)),
	m_LogFile(BOOLSETTING(LOG_SEEKERS_IN_SPY_FRAME)),
	m_ignoreTTHContainer(WC_BUTTON, this, SPYFRAME_IGNORETTH_MESSAGE_MAP),
	m_ShowNickContainer(WC_BUTTON, this, SPYFRAME_SHOW_NICK),
	m_SpyLogFileContainer(WC_BUTTON, this, SPYFRAME_LOG_FILE),
	m_log(nullptr), m_needsUpdateTime(true), m_needsResort(false) //[+]IRainman refactoring SpyFrame
{
	memzero(m_perSecond, sizeof(m_perSecond));
	ClientManager::getInstance()->addListener(this);
	SettingsManager::getInstance()->addListener(this);
}